/*
 * theme.css — Kathakar Story Studio.
 *
 * The brief: a workbench for writing serialised audio fiction in English,
 * Hindi and Hinglish. Dense and fast where the work happens, like Linear —
 * but the subject is pulp serial drama, so the SURFACE is a printed
 * paperback: warm paper, a marigold ember for the one action that matters,
 * squared corners and a letterpress edge under every button. Nothing is
 * rounded-12px-on-white here.
 *
 * Light mode is that paper. Dark mode is a recording booth after hours —
 * warm near-black, the ember turned up so it still reads as the same brand
 * rather than the light palette inverted.
 *
 * Display is Instrument Serif (one weight, 400 — it has no other), body is
 * Archivo, figures and slugs in DM Mono. Noto Devanagari rides in both text
 * stacks so a Hindi episode sets properly beside an English one.
 */

:root {
  --canvas: #faf5ec;
  --surface: #ffffff;
  --surface-2: #f2eadc;
  --border: #e3d8c5;
  --border-strong: #9f8c6f;
  --ink: #1e1915;
  --muted: #6a5f51;
  --accent: #b4530a;
  --accent-hover: #944106;
  --accent-ink: #fffaf3;
  --accent-text: #8d3e05;
  --accent-soft: #f7e7d2;
  --accent-strong: #763304;
  --accent-border: #ad8449;
  --success: #2f6b3c;
  --success-ink: #f4fbf5;
  --success-soft: #e1eee4;
  --success-strong: #255831;
  --warning: #8f5a05;
  --warning-ink: #fffaf2;
  --warning-soft: #f6e9cf;
  --warning-strong: #744804;
  --danger: #a32820;
  --danger-ink: #fff8f7;
  --danger-soft: #f7e0dd;
  --danger-strong: #8a211a;
  --chart-1: #b4530a;
  --chart-2: #7a3e6b;
  --chart-3: #2f6b3c;
  --chart-4: #1f5b6b;
  --chart-5: #8a6d1f;
  --chart-6: #574a86;

  --font-display: "Instrument Serif", "Noto Serif Devanagari", Georgia, "Times New Roman", serif;
  --font-body: "Archivo Variable", "Noto Sans Devanagari", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Archivo Variable", "Noto Sans Devanagari", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 400;
  --display-tracking: -0.015em;
  --eyebrow-tracking: 0.16em;

  --radius-btn: 3px;
  --radius-card: 5px;
  --radius-input: 3px;
  --border-w: 1px;
  --border-strong-w: 1px;
  --card-pad: 1.5rem;
  --caps: none;
  --caps-tracking: 0.01em;
  --btn-weight: 600;
  --measure: 64ch;
  --shadow-card: 0 1px 0 color-mix(in srgb, var(--ink) 7%, transparent);
  --shadow-raised: 0 14px 34px color-mix(in srgb, var(--ink) 18%, transparent);
  --shadow-btn: 0 1px 0 color-mix(in srgb, var(--ink) 16%, transparent);

  --x-rule: #ece0cc;
  --x-spine: #d9c3a0;
  --x-booth: #f2eadc;
  --x-wave: #b4530a;
  --x-script-ground: #fffdf8;
}

html[data-theme="dark"] {
  --canvas: #15110e;
  --surface: #1f1a16;
  --surface-2: #2a231d;
  --border: #392f27;
  --border-strong: #7d6b58;
  --ink: #f7f0e5;
  --muted: #b0a08d;
  --accent: #e8903c;
  --accent-hover: #f2a558;
  --accent-ink: #2a1403;
  --accent-text: #f0ab68;
  --accent-soft: #342616;
  --accent-strong: #f2b377;
  --accent-border: #8a6734;
  --success: #2f6b3c;
  --success-ink: #f4fbf5;
  --success-soft: #18291c;
  --success-strong: #86c194;
  --warning: #8f5a05;
  --warning-ink: #fffaf2;
  --warning-soft: #2e2112;
  --warning-strong: #e0b06d;
  --danger: #a32820;
  --danger-ink: #fff8f7;
  --danger-soft: #2e1715;
  --danger-strong: #ea958c;
  --chart-1: #e8903c;
  --chart-2: #cd7fb3;
  --chart-3: #86c194;
  --chart-4: #6fb5cc;
  --chart-5: #c9ae63;
  --chart-6: #9b90d4;

  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.5);
  --shadow-raised: 0 16px 38px rgba(0, 0, 0, 0.62);
  --shadow-btn: 0 1px 0 rgba(0, 0, 0, 0.55);

  --x-rule: #241d18;
  --x-spine: #4a3a2a;
  --x-booth: #1a1512;
  --x-wave: #e8903c;
  --x-script-ground: #1c1713;
}

/*
 * app.css — Kathakar Story Studio's own screens.
 *
 * Only what no primitive and no utility covers: the GROUND, the display
 * face, the SCRIPT PAGE an episode is read from, the EPISODE SPINE, and the
 * narrator. Tokens only.
 *
 * MOTION: exactly one thing in this app moves, and it moves because it is
 * telling the truth — the narrator's bars rise and fall only while the
 * browser is actually speaking. Everything else is still. The bars rest
 * VISIBLE at a third of their height, so a visitor whose JavaScript never
 * ran sees a sensible meter rather than a blank gap.
 */

/* ---- The display face --------------------------------------------------- */
/* Tailwind's font-mono and font-sans already read --font-mono and
   --font-sans, but there is no utility for a third family, and the serif is
   what makes this app look like a printed serial rather than a dashboard. */
.display {
  font-family: var(--font-display);
  font-weight: var(--display-weight, 400);
  letter-spacing: var(--display-tracking, -0.015em);
  line-height: 1.08;
  text-wrap: balance;
}

/* ---- The ground --------------------------------------------------------- */
/* Warm paper with one ember wash behind the masthead. Fixed, so scrolling a
   long draft does not drag a gradient up the screen with it. */
.paper {
  background-color: var(--canvas);
  background-image: radial-gradient(
    80rem 28rem at 78% -8rem,
    color-mix(in srgb, var(--accent-soft) 85%, transparent),
    transparent 70%
  );
  background-attachment: fixed;
  background-repeat: no-repeat;
}

.masthead {
  border-bottom: 1px solid var(--border);
  background-color: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: blur(8px);
}

/* ---- The script page ---------------------------------------------------- */
/* An episode draft exists to be read aloud, so it gets a real page: ruled
   lines at the prose's own line height, and a margin rule down the left the
   way a shooting script has one. Both are drawn, never an image. */
.script {
  position: relative;
  background-color: var(--x-script-ground);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.8 * 1.0625rem - 1px),
    var(--x-rule) calc(1.8 * 1.0625rem - 1px),
    var(--x-rule) calc(1.8 * 1.0625rem)
  );
  background-position: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 2rem 1.75rem 2rem 2.5rem;
}
.script::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 1.5rem;
  width: 1px;
  background-color: color-mix(in srgb, var(--accent-border) 55%, transparent);
}
@media (width < 40rem) {
  .script {
    padding: 1.5rem 1.125rem 1.5rem 1.625rem;
  }
  .script::before {
    left: 0.875rem;
  }
}

/* The sentence the narrator is on. A flat tint, no glow: it has to stay
   readable while it is lit, not become decoration. */
.chunk {
  border-radius: 2px;
  box-decoration-break: clone;
  transition: background-color 180ms var(--ease);
}
.chunk.is-active {
  background-color: var(--accent-soft);
  color: var(--accent-strong);
}

/* ---- The episode spine -------------------------------------------------- */
/* A season is not a table. One line down the page with a numbered node per
   episode, so the shape of the run is visible at a glance. */
.spine {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 3.25rem;
}
.spine::before {
  content: "";
  position: absolute;
  left: 1.3125rem;
  top: 1.5rem;
  bottom: 1.5rem;
  width: 1px;
  background-color: var(--x-spine);
}
.spine-item {
  position: relative;
}
.spine-num {
  position: absolute;
  left: -3.25rem;
  top: 1.15rem;
  display: grid;
  width: 2.625rem;
  height: 2rem;
  place-items: center;
  border: 1px solid var(--x-spine);
  border-radius: 2px;
  background-color: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
}
.spine-item.is-final .spine-num {
  border-color: var(--accent-border);
  background-color: var(--accent-soft);
  color: var(--accent-strong);
}
@media (width < 40rem) {
  .spine {
    padding-left: 0;
  }
  .spine::before {
    display: none;
  }
  .spine-num {
    position: static;
    left: auto;
    top: auto;
    margin-bottom: 0.625rem;
  }
}

/* ---- The narrator ------------------------------------------------------- */
.narrator {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-card);
  background-color: var(--x-booth);
}

/* A speed control is a utility, not the money moment — but it still should
   not be the browser's grey. accent-color tints the native track. */
.slider {
  width: 100%;
  height: 2.5rem;
  accent-color: var(--accent);
  cursor: pointer;
  background: transparent;
}
.slider:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 2px;
}

.waves {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 1.25rem;
}
.waves i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 1px;
  background-color: var(--x-wave);
  transform: scaleY(0.34);
  transform-origin: bottom center;
}
.is-speaking .waves i {
  animation: booth-wave 900ms ease-in-out infinite;
}
.is-speaking .waves i:nth-child(2) {
  animation-delay: 110ms;
}
.is-speaking .waves i:nth-child(3) {
  animation-delay: 220ms;
}
.is-speaking .waves i:nth-child(4) {
  animation-delay: 150ms;
}
.is-speaking .waves i:nth-child(5) {
  animation-delay: 60ms;
}

@keyframes booth-wave {
  0%,
  100% {
    transform: scaleY(0.34);
  }
  50% {
    transform: scaleY(1);
  }
}

/* Asked for less motion: the meter still shows that something is playing,
   it just stops moving. */
html.reduced-motion .is-speaking .waves i {
  animation: none;
  transform: scaleY(0.72);
}

/* ---- The workbench: two columns on a desk, one on a phone --------------- */
.bench {
  display: grid;
  gap: 1.75rem;
  align-items: start;
}
@media (width >= 64rem) {
  .bench {
    grid-template-columns: minmax(0, 1fr) 21rem;
    gap: 2.5rem;
  }
}
