/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

.story-graph {
  width: 100%;
  background: color-mix(in srgb, var(--color-bg) 82%, var(--color-accent-light));
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px color-mix(in srgb, var(--color-text) 12%, transparent);
  padding: 1.25rem;
}

.story-graph__header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.story-graph__header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2rem);
}

.story-graph__header p {
  margin: 0.35rem 0 0;
  max-width: 64ch;
}

.story-graph__header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.story-graph__layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 2.3fr) minmax(260px, 1fr);
}

.story-graph__canvas-shell {
  min-height: 520px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background:
    linear-gradient(transparent 95%, color-mix(in srgb, var(--color-accent) 16%, transparent) 95%),
    linear-gradient(90deg, transparent 95%, color-mix(in srgb, var(--color-accent) 16%, transparent) 95%),
    color-mix(in srgb, var(--color-bg) 92%, var(--color-accent-light));
  background-size: 32px 32px;
  padding: 0.75rem;
}

.story-graph__canvas {
  width: 100%;
  min-height: 460px;
}

.story-graph__status {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.story-graph__details {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-raised);
  padding: 0.9rem;
}

.story-graph__details h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.story-graph__details p {
  margin: 0.35rem 0;
}

.story-graph__meta {
  font-size: 0.86rem;
  color: var(--color-muted);
}

.story-graph__detail-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.story-graph__branch-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
}

.story-graph__branch-form label {
  font-weight: 600;
}

.story-graph__branch-form input[type="text"] {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  background: var(--color-bg);
  color: var(--color-text);
}

.story-graph__button,
.story-graph__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--color-accent);
  padding: 0.45rem 0.85rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.story-graph__button {
  background: color-mix(in srgb, var(--color-accent) 24%, var(--color-bg));
  color: var(--color-text);
  cursor: pointer;
}

.story-graph__button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.story-graph__link {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-bg) 90%, var(--color-accent-light));
}

.story-graph__link-line {
  fill: none;
  stroke: color-mix(in srgb, var(--color-accent) 45%, transparent);
  stroke-width: 1.5;
}

.story-graph__node {
  cursor: pointer;
}

.story-graph__node-dot {
  stroke: var(--color-bg);
  stroke-width: 2;
}

.story-graph__node.is-selected .story-graph__node-dot {
  stroke: var(--color-accent-hover);
  stroke-width: 3;
}

.story-graph__node.is-current .story-graph__node-dot {
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--color-accent) 80%, transparent));
}

.story-graph__node-text {
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  pointer-events: none;
  fill: var(--color-text);
}

.story-graph__node-title {
  font-size: 0.86rem;
  font-weight: 700;
}

.story-graph__node-summary {
  font-size: 0.75rem;
  fill: var(--color-muted);
}

.loading-indicator-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.loading-indicator-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--color-accent);
  opacity: 0.35;
}

button,
input[type="submit"],
input[type="button"] {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

a,
summary {
  touch-action: manipulation;
}

.flash-toast {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .loading-indicator-dot {
    animation: talepath-loading-dot 1.05s ease-in-out infinite;
  }

  .loading-indicator-dot:nth-child(2) {
    animation-delay: 0.15s;
  }

  .loading-indicator-dot:nth-child(3) {
    animation-delay: 0.3s;
  }

  .flash-toast {
    animation: talepath-flash-enter 0.2s ease-out;
  }

  .flash-toast.is-dismissing {
    animation: talepath-flash-exit 0.3s ease forwards;
  }
}

@keyframes talepath-loading-dot {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-0.14rem);
  }
}

@keyframes talepath-flash-enter {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes talepath-flash-exit {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@media (max-width: 960px) {
  .story-graph__layout {
    grid-template-columns: 1fr;
  }

  .story-graph__canvas-shell {
    min-height: 420px;
  }

  .story-graph__canvas {
    min-height: 360px;
  }
}
