/* ============================================================
   SimWorld demo — shared styles
   UI + icon language referenced from seedance2.ai/guide
   (shadcn/ui "zinc" theme, lucide icons). Dark by default.
   ============================================================ */

/* ---- Theme tokens: light is the base, .dark overrides ---- */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: rgba(250, 250, 250, 0.7);
  --card-solid: #fafafa;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --border-soft: #ececef;
  --accent-hover: rgba(0, 0, 0, 0.05);
  --header-bg: rgba(255, 255, 255, 0.72);
  --code-bg: #f6f6f7;
  --slot-bg: #f1f1f3;
  --slot-hatch: rgba(0, 0, 0, 0.04);

  --blue-fg: #2563eb;  --blue-bg: rgba(37, 99, 235, 0.10);
  --green-fg: #16a34a; --green-bg: rgba(22, 163, 74, 0.10);
  --amber-fg: #b45309; --amber-bg: rgba(245, 158, 11, 0.12);

  --radius: 12px;
  --maxw: 56rem;              /* max-w-4xl */
  --bodyw: 88rem;             /* shared body/header/footer width (was 80rem) — keep all sections uniform */
  --header-h: 57px;
  --grad: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html.dark {
  --background: #0a0a0a;
  --foreground: #fafafa;
  --card: rgba(23, 23, 23, 0.5);
  --card-solid: #171717;
  --muted: rgba(38, 38, 38, 0.6);
  --muted-foreground: #a1a1aa;
  --border: rgba(63, 63, 70, 0.6);
  --border-soft: rgba(63, 63, 70, 0.35);
  --accent-hover: rgba(250, 250, 250, 0.1);
  --header-bg: rgba(10, 10, 10, 0.6);
  --code-bg: #0d0d0f;
  --slot-bg: #161618;
  --slot-hatch: rgba(255, 255, 255, 0.03);

  --blue-fg: #93c5fd;  --blue-bg: rgba(59, 130, 246, 0.14);
  --green-fg: #86efac; --green-bg: rgba(34, 197, 94, 0.14);
  --amber-fg: #fcd34d; --amber-bg: rgba(245, 158, 11, 0.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--background); color: var(--foreground);
  font-family: var(--sans); -webkit-font-smoothing: antialiased; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: .85em; }

/* ---- Icons (lucide via sprite) ---- */
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }

/* ---- Header / nav ---- */
header {
  position: sticky; top: 0; z-index: 50; padding: 8px 24px;
  background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
header nav { max-width: var(--bodyw); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 1.2rem; }
.brand .logo { width: 28px; height: 28px; flex: none; display: inline-flex; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { padding: 8px 16px; border-radius: 10px; font-size: .875rem; color: var(--muted-foreground); transition: background .15s, color .15s; }
.nav-links a:hover { background: var(--accent-hover); color: var(--foreground); }
.nav-links a.active { color: var(--foreground); font-weight: 500; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--foreground); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--accent-hover); }
.menu-btn { display: none; }
/* theme toggle icon swap */
.theme-toggle .moon { display: none; }
.theme-toggle .sun  { display: block; }
html.dark .theme-toggle .moon { display: block; }
html.dark .theme-toggle .sun  { display: none; }

/* ---- Layout ---- */
main.page { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; }
.full { width: 100%; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* Hero (full width, centered) — seedance: py-8 px-4 text-center, inner max-w-4xl */
.hero { padding: 40px 16px 24px; text-align: center; }
.hero-inner { max-width: 56rem; margin: 0 auto; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted-foreground);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; margin-bottom: 18px; }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--grad); }
h1 { font-size: clamp(1.9rem, 5vw, 2.5rem); line-height: 1.1; margin: 0 0 12px; letter-spacing: -0.02em; font-weight: 700; }
.lede { color: var(--muted-foreground); font-size: 1.02rem; max-width: 44rem; margin: 0 auto; }
.lede code { color: var(--foreground); background: var(--muted); padding: 1px 6px; border-radius: 5px; }

/* Two-column body: sticky left sidebar TOC + content — seedance: flex gap-8 max-w-7xl */
.layout { display: flex; gap: 2rem; width: 100%; max-width: var(--bodyw); margin: 0 auto; padding: 8px 16px 0; }
.sidebar { width: 16rem; flex: none; }
.sidebar .sticky { position: sticky; top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 36px); overflow-y: auto; padding-right: 4px; }
.content { flex: 1; min-width: 0; padding-bottom: 4rem; }

/* Sidebar TOC */
.toc-title { font-size: .8rem; font-weight: 600; color: var(--muted-foreground); margin: 0 0 12px; }
.toc-nav { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.toc-link { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 12px; font-size: .875rem; border-radius: 8px; color: var(--muted-foreground);
  transition: background .15s, color .15s; }
.toc-link:hover { color: var(--foreground); background: var(--accent-hover); }
.toc-link.active { background: var(--blue-bg); color: var(--blue-fg); font-weight: 500; }
.toc-sub { margin-left: 0.9rem; border-left: 1px solid var(--border-soft); padding-left: 10px;
  display: flex; flex-direction: column; gap: 2px; margin-top: 2px; margin-bottom: 4px; }
.toc-sublink { display: flex; align-items: baseline; gap: 7px; width: 100%; text-align: left;
  padding: 5px 8px; font-size: .78rem; border-radius: 6px; color: var(--muted-foreground);
  transition: color .15s, background .15s; }
.toc-sublink:hover { color: var(--foreground); background: var(--accent-hover); }
.toc-sublink.active { color: var(--blue-fg); }

/* Mobile TOC (shown only when sidebar is hidden) */
.mobile-toc { display: none; margin-bottom: 24px; padding: 12px 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border-soft); }
.mobile-toc .toc-title { margin-bottom: 8px; }
.mobile-toc .toc-nav { flex-flow: row wrap; gap: 6px; }
.mobile-toc .toc-link { width: auto; padding: 6px 10px; font-size: .8rem; }

/* Section header: inline blue icon + "0N Title" (seedance style) */
section.doc { scroll-margin-top: calc(var(--header-h) + 20px); }
.content > section.doc + section.doc { border-top: 1px solid var(--border); margin-top: 3rem; padding-top: 3rem; }
.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sec-head .icon { width: 24px; height: 24px; color: #3b82f6; flex: none; }
.sec-head h2 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; }
.sec-intro { color: var(--muted-foreground); margin: 4px 0 8px; }
.sec-intro code { color: var(--foreground); background: var(--muted); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 1279px) {
  .sidebar { display: none; }
  .mobile-toc { display: block; }
  .layout { max-width: 56rem; }
}

/* ---- Item / subsection (a capability or move: h3 + chips + samples) ---- */
.item { padding: 22px 0 4px; border-top: 1px solid var(--border-soft); scroll-margin-top: calc(var(--header-h) + 20px); }
.item:first-of-type { border-top: none; padding-top: 8px; }
.item-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.item-head h3 { font-size: 1.2rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.item-head h3 .fn { font-family: var(--mono); font-size: 1.05rem; }

/* Auto-number sub-items as N.M (section 01 -> 1.1, 1.2 ... like seedance) */
.content { counter-reset: sec; }
.content section.doc { counter-increment: sec; counter-reset: subitem; }
.content .item { counter-increment: subitem; }
.item-head h3::before { content: counter(sec) "." counter(subitem) "\00a0\00a0";
  color: var(--muted-foreground); font-weight: 600; }
/* Same N.M in the sidebar / mobile table of contents */
.toc-nav { counter-reset: tsec; }
.toc-nav .toc-link { counter-increment: tsec; }
.toc-sub { counter-reset: tsub; }
.toc-sublink { counter-increment: tsub; font-variant-numeric: tabular-nums; }
.toc-sublink::before { content: counter(tsec) "." counter(tsub); flex: 0 0 auto;
  min-width: 2.35em; opacity: .6; }
.item-desc { color: var(--muted-foreground); font-size: .92rem; margin: 6px 0 0; }
.format-line { margin: 10px 0 0; }
.format-line code { display: block; font-size: .76rem; line-height: 1.5; color: var(--muted-foreground);
  background: var(--code-bg); border: 1px solid var(--border-soft); border-radius: 8px; padding: 8px 11px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

/* method chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.chip { font-family: var(--mono); font-size: .76rem; padding: 3px 8px; border-radius: 6px;
  background: var(--muted); border: 1px solid var(--border-soft); color: var(--foreground); white-space: nowrap; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; font-size: .7rem; font-weight: 600;
  padding: 2px 8px; border: 1px solid var(--border); color: var(--muted-foreground); letter-spacing: .02em; }
.badge.blue  { color: var(--blue-fg);  background: var(--blue-bg);  border-color: transparent; }
.badge.green { color: var(--green-fg); background: var(--green-bg); border-color: transparent; }
.badge.amber { color: var(--amber-fg); background: var(--amber-bg); border-color: transparent; }

/* ---- Sample card (seedance-style): media, a framed prompt box, and annotations ---- */
.samples { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-top: 16px; }
.sample { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
/* before/after pairs & modality stacks: media row on top, prompt + annotations below (full width) */
.sample.pair, .sample.refgen { grid-column: 1 / -1; }
/* single / story: media beside a prompt + annotations column, so the row stays full and balanced */
.sample.solo { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 14px; align-items: start; }
.sample.solo .side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@media (max-width: 720px) { .sample.solo { grid-template-columns: 1fr; } }

.slot-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.sample.pair .slot-row { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .sample.pair .slot-row { grid-template-columns: 1fr; } }

/* the video placeholder frame — drop a <video> in here later */
.video-slot { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; border: 1px solid var(--border-soft);
  background: var(--slot-bg);
  display: grid; place-items: center; overflow: hidden; }
.video-slot .play { width: 32px; height: 32px; color: var(--muted-foreground); opacity: .55; }
/* the "video" hint only marks an empty placeholder slot, not a real clip */
.video-slot.empty::after { content: "video"; position: absolute; bottom: 7px; right: 9px; font-size: .66rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); opacity: .8; }
/* tag badge sits on the frame (works over real <video>, which can't take ::before) */
.video-slot.tagged::before { content: attr(data-tag); position: absolute; z-index: 2; top: 7px; left: 9px;
  font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px;
  border-radius: 5px; background: var(--card-solid); border: 1px solid var(--border-soft); color: var(--muted-foreground); }
/* real media fills the slot frame */
.video-slot > video, .video-slot > iframe, .video-slot > img { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border: 0; display: block; background: #000; }

/* reference-guided: one big generated clip, a strip of reference stills beneath it */
.sample.refgen .refgen-refs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.sample.refgen .refgen-refs .video-slot { border-radius: 8px; }

figcaption { margin: 0; font-size: .78rem; color: var(--muted-foreground); line-height: 1.5; }
figcaption .pill { display: inline-flex; align-items: center; gap: 5px; margin-right: 6px; }

/* Framed prompt box (seedance-style): a labeled header + the prompt body (beside the media for
   single takes, under the media row for before/after pairs and modality stacks). */
.prompt { border: 1px solid var(--border-soft); border-radius: 10px; background: var(--card); overflow: hidden; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; background: var(--muted); border-bottom: 1px solid var(--border-soft); }
.prompt-label { display: inline-flex; align-items: center; gap: 6px; font-size: .66rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.prompt-kind { font-family: var(--mono); font-size: .66rem; color: var(--muted-foreground); opacity: .85; }
.prompt-text { margin: 0; padding: 11px 13px; font-family: var(--mono); font-size: .82rem; line-height: 1.65;
  color: var(--foreground); white-space: pre-wrap; word-break: break-word; }
/* Empty (placeholder) prompt — mirrors the video slot's empty look; no filler prose. */
.prompt.is-empty { background: var(--slot-bg); }
.prompt.is-empty .prompt-head { background: transparent; }
.prompt-empty { min-height: 44px; }

/* The before/after comparison slider lives in its own component — see compare-slider.js
   (it injects its own styles). The gallery just emits <compare-slider> for `type:"compare"`. */

/* Annotation row beneath a sample — small labels / tags (seedance keeps these under the prompt). */
.annot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.annot .tag { display: inline-flex; align-items: center; gap: 5px; font-size: .66rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground);
  background: var(--muted); border: 1px solid var(--border-soft); border-radius: 6px; padding: 3px 8px; }
.annot .note { font-size: .74rem; color: var(--muted-foreground); }

/* Footer */
footer { margin-top: 64px; border-top: 1px solid var(--border-soft); background: var(--card); }
.foot-grid { max-width: var(--bodyw); margin: 0 auto; padding: 44px 24px; display: grid; gap: 32px; grid-template-columns: 2fr 1fr 1fr; }
.foot-brand .brand { margin-bottom: 12px; }
.foot-brand p { color: var(--muted-foreground); font-size: .9rem; max-width: 30rem; margin: 0; }
.foot-col h5 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); margin: 0 0 12px; }
.foot-col a { display: block; color: var(--muted-foreground); font-size: .9rem; padding: 4px 0; }
.foot-col a:hover { color: var(--foreground); }
.copyright { max-width: var(--bodyw); margin: 0 auto; padding: 16px 24px 40px; color: var(--muted-foreground); font-size: .78rem; border-top: 1px solid var(--border-soft); }

@media (max-width: 768px) {
  header { padding: 8px 16px; }
  .menu-btn { display: grid; }
  /* nav links collapse into a dropdown panel toggled by the menu button (nav.js) */
  .nav-links {
    position: absolute; top: calc(100% + 1px); right: 12px; z-index: 60;
    flex-direction: column; align-items: stretch; gap: 2px; min-width: 190px;
    padding: 8px; border-radius: 12px;
    background: var(--card-solid); border: 1px solid var(--border);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
  }
  header.nav-open .nav-links { opacity: 1; visibility: visible; transform: translateY(0); }
  .nav-links a { padding: 10px 12px; font-size: .9rem; }
  .nav-links a.active { background: var(--accent-hover); }
  .foot-grid { grid-template-columns: 1fr; padding: 32px 20px; gap: 24px; }
  .copyright { padding: 16px 20px 32px; }
  .hero { padding: 32px 16px 20px; }
}
