/* ═══════════════════════════════════════════════════════════════════
   Live demo widget — two-column layout (story pane + control rail).

   Its own stylesheet on purpose: marketing.css ships as a hand-synced
   marketing.min.css, and keeping widget styles out of that pair removes a
   whole class of "edited the source but shipped the minified" bugs.
   Scoped entirely under .dw- classes.
   ═══════════════════════════════════════════════════════════════════ */

.dw {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(4, 4, 9, 0.5);
  overflow: hidden;
}

/* ── Left: the story ─────────────────────────────────────────────── */
.dw-story {
  padding: 26px 30px 24px;
  min-width: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  /* Column so the text fills the card's full height instead of stopping at a
     fixed cap and leaving dead space under it. */
  display: flex;
  flex-direction: column;
}

.dw-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-teal, #5884D6);
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dw-eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-teal, #5884D6);
  box-shadow: 0 0 10px rgba(88, 132, 214, 0.8);
  flex-shrink: 0;
}

.dw-eyebrow__meta {
  color: var(--text-muted-night);
  font-weight: 600;
  letter-spacing: 0.10em;
}

/* Live character count in paste mode. Amber near the cap so the 800-character
   limit is visible before it bites. */
.dw-eyebrow__count {
  margin-left: auto;
  color: var(--text-muted-night);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}
.dw-eyebrow__count.is-near { color: var(--accent-amber, #E3B341); }

/* Fills the card height and scrolls only when the text actually overflows.
   No bottom fade: capped height put the fade in the middle of the box, which
   read as a rendering glitch rather than "more below". */
.dw-prose {
  margin-top: 20px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 18px;
  font-family: var(--font-heading, 'Space Grotesk', sans-serif);
  font-size: 20px;
  line-height: 1.68;
  color: #D6D9E2;
}

.dw-prose p { margin: 0 0 1.15em; }
.dw-prose p:last-child { margin-bottom: 0; }

.dw-prose::-webkit-scrollbar { width: 5px; }
.dw-prose::-webkit-scrollbar-track { background: transparent; }
.dw-prose::-webkit-scrollbar-thumb {
  background: rgba(220, 231, 247, 0.28);
  border-radius: 99px;
}
.dw-prose::-webkit-scrollbar-thumb:hover { background: rgba(220, 231, 247, 0.45); }
/* Firefox can only do width + colour; close, not identical. */
.dw-prose { scrollbar-width: thin; scrollbar-color: rgba(220,231,247,0.28) transparent; }

/* Dyslexia mode swaps the face on the prose and the editor alike. */
.dw.is-dyslexic .dw-prose,
.dw.is-dyslexic .dw-editor {
  font-family: 'OpenDyslexic', var(--font-sans, sans-serif);
  font-size: 15.5px;
  line-height: 1.85;
}

/* During playback demo-widget.js swaps in its karaoke reader. Give it the same
   typography and box as the prose so the column doesn't change shape, and hide
   the static prose while it's on (is-reading is set by the widget chrome). */
.dw-story #demo-reader-display {
  margin-top: 20px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 18px;
  font-family: var(--font-heading, 'Space Grotesk', sans-serif);
  font-size: 20px;
  line-height: 1.68;
  color: #D6D9E2;
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 231, 247, 0.28) transparent;
}
.dw-story #demo-reader-display::-webkit-scrollbar { width: 5px; }
.dw-story #demo-reader-display::-webkit-scrollbar-thumb {
  background: rgba(220, 231, 247, 0.28);
  border-radius: 99px;
}
.dw.is-reading .dw-prose { display: none; }
.dw.is-dyslexic .dw-story #demo-reader-display {
  font-family: 'OpenDyslexic', var(--font-sans, sans-serif);
  font-size: 15.5px;
  line-height: 1.85;
}

/* The paste-your-own editor replaces the prose in place. */
.dw-editor {
  display: none;
  width: 100%;
  margin-top: 20px;
  flex: 1;
  min-height: 0;
  resize: none;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px 16px;
  color: #D6D9E2;
  font-family: var(--font-heading, 'Space Grotesk', sans-serif);
  font-size: 18px;
  line-height: 1.68;
}
.dw-editor:focus { outline: none; border-color: rgba(88, 132, 214, 0.5); }
.dw.is-editing .dw-prose { display: none; }
.dw.is-editing .dw-editor { display: block; }

/* ── Right: the control rail ─────────────────────────────────────── */
.dw-rail {
  padding: 22px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Transport: skip / play / skip */
.dw-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.dw-skip {
  /* Sized against .dw-play, not in isolation. Play is a 62px filled disc; the
     skips are bare glyphs with no chrome, so they read at their GLYPH size,
     not their box. At 21px against 62px that is a ratio of 0.34 and they
     looked like afterthoughts. 30px lands at 0.48, in line with how other
     players weight a secondary transport control against the primary one.
     Deliberately NOT taken further: past ~0.55 the skips stop deferring to
     play and the row loses its hierarchy. The webplayer's pair is a different
     case and correctly left alone, because its skips wear rings. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: var(--text-muted-night);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.18s ease, background 0.18s ease;
}
.dw-skip:hover { color: #E9EBF0; background: rgba(255, 255, 255, 0.07); }
.dw-skip:focus-visible { outline: 2px solid #5884D6; outline-offset: 2px; }

.dw-play {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  background: radial-gradient(circle at 34% 28%, #FFFFFF 0%, #E4EDF7 42%, #AFC2D8 100%);
  box-shadow:
    0 0 0 6px rgba(88, 132, 214, 0.12),
    0 0 26px rgba(88, 132, 214, 0.45),
    0 8px 22px rgba(4, 4, 9, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #191E2A;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.dw-play:hover { transform: translateY(-1px); box-shadow: 0 0 0 7px rgba(88, 132, 214,0.16), 0 0 32px rgba(88, 132, 214,0.6), 0 10px 26px rgba(4, 4, 9,0.55); }
.dw-play:focus-visible { outline: 2px solid #5884D6; outline-offset: 4px; }
.dw-play svg { margin-left: 2px; }
.dw.is-playing .dw-play svg { margin-left: 0; }

.dw-status {
  margin: 10px 0 0;
  min-height: 1.2em;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted-night);
  transition: color 0.18s ease;
}
.dw-status.playing { color: #42C7B5; }
.dw-status.error   { color: #E3B341; }

/* Scrubber */
.dw-scrub {
  position: relative;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
}
.dw-scrub__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 99px;
  background: var(--accent-teal, #5884D6);
}
.dw-scrub__dot {
  position: absolute;
  right: -6px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent-teal, #5884D6);
  box-shadow: 0 0 10px rgba(88, 132, 214, 0.8);
}
.dw-times {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted-night);
  font-variant-numeric: tabular-nums;
}

.dw-rule { height: 1px; background: rgba(255, 255, 255, 0.08); }

/* Labelled control rows */
.dw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dw-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted-night);
  flex-shrink: 0;
}
.dw-row--stacked { flex-direction: column; align-items: stretch; gap: 8px; }

/* Segmented controls (Mode, Speed) */
.dw-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.09);
}
.dw-seg button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 5px 13px;
  border-radius: 99px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted-night);
  transition: background 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}
.dw-seg button:hover { color: #E9EBF0; }
.dw-seg button.is-on {
  background: rgba(244, 248, 255, 0.94);
  color: #191E2A;
  font-weight: 700;
}
.dw-seg button:focus-visible { outline: 2px solid #5884D6; outline-offset: 1px; }
/* Summary is unavailable while pasting your own text. */
.dw-seg button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--text-muted-night);
  background: none;
}
.dw-seg button:disabled:hover { color: var(--text-muted-night); }

/* Nothing pasted yet means nothing to play. */
.dw-play:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.05), 0 6px 16px rgba(4, 4, 9, 0.4);
}
.dw-play:disabled:hover { transform: none; }

/* Toggle switch (dyslexia font) */
.dw-toggle {
  position: relative;
  width: 42px;
  height: 23px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.dw-toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #C8D5E8;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}
.dw-toggle[aria-pressed="true"] {
  background: rgba(88, 132, 214, 0.28);
  border-color: rgba(88, 132, 214, 0.55);
}
.dw-toggle[aria-pressed="true"] .dw-toggle__knob {
  transform: translateX(19px);
  background: #5884D6;
}
.dw-toggle:focus-visible { outline: 2px solid #5884D6; outline-offset: 2px; }

/* Rail footer button */
.dw-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.03);
  color: #C8D5E8;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.dw-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  color: #E9EBF0;
}
.dw-ghost:focus-visible { outline: 2px solid #5884D6; outline-offset: 2px; }

.dw-rail__foot { margin-top: auto; display: flex; flex-direction: column; gap: 9px; }

/* ── Responsive: stack the rail under the story ──────────────────── */
@media (max-width: 900px) {
  .dw { grid-template-columns: 1fr; }
  .dw-story { border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.08); padding: 22px 20px; }
  .dw-prose { max-height: 240px; }
  .dw-rail { padding: 20px; }
  .dw-rail__foot { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .dw-play, .dw-toggle__knob, .dw-seg button, .dw-ghost { transition: none; }
}
