/* ==========================================================================
   Document page — layout and bespoke pieces on top of HeroUI (docs/heroui.css).
   Not part of the broadcast library.
   ========================================================================== */
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  background:
    radial-gradient(1200px 640px at 50% -220px, rgba(31, 96, 181, 0.32), rgba(31, 96, 181, 0) 70%),
    radial-gradient(900px 460px at 50% -40px, rgba(255, 192, 58, 0.05), rgba(255, 192, 58, 0) 70%),
    var(--background);
  background-attachment: fixed;
}
code { font: 12.5px/1.5 var(--font-mono); color: var(--link); }
.chip { white-space: nowrap; flex-shrink: 0; }

/* ---- Navbar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--background) 78%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--separator);
}
.topbar__link { color: var(--muted); font-size: 14px; padding: 6px 12px; border-radius: 10px; text-decoration: none; transition: color .2s, background-color .2s; }
.topbar__link:hover { color: var(--foreground); background: var(--default); }

/* ---- Hero --------------------------------------------------------------- */
.hero { text-align: center; padding: 64px 0 36px; }
.hero__logo { width: 220px; height: auto; margin: 0 auto 20px; filter: drop-shadow(0 22px 48px rgba(255, 192, 58, 0.22)); }
.hero__title { font: 500 32px/1.15 var(--font-serif); letter-spacing: 0.32em; text-transform: uppercase; color: #ffdba9; margin: 8px 0 14px; }

/* ---- Sections ----------------------------------------------------------- */
.section { margin-top: 56px; }
.section__head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.section__title { font: 500 24px/1.2 var(--font-serif); letter-spacing: 0.24em; text-transform: uppercase; color: #ffdba9; }

/* Accordion: slower, softer than HeroUI's default 200 ms */
.accordion__panel { --disclosure-panel-height: 0px; transition: height 480ms cubic-bezier(.32,.72,0,1), opacity 360ms ease; }
.accordion__trigger { padding-block: 18px; }

/* ---- Swatches ----------------------------------------------------------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.swatch { text-align: start; border-radius: 14px; overflow: hidden; background: var(--surface-secondary); box-shadow: var(--surface-shadow); cursor: pointer; transition: transform .25s cubic-bezier(.32,.72,0,1); }
.swatch:hover { transform: translateY(-2px); }
.swatch i { display: block; height: 66px; }
.swatch div { padding: 9px 11px; }
.swatch b { display: block; font-size: 12.5px; color: var(--foreground); font-weight: 600; }
.swatch span { font: 12px var(--font-mono); color: var(--muted); }

/* ---- Stages (1920-wide canvases scaled to fit) -------------------------- */
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #000; }
.stage--wide { aspect-ratio: 16 / 6; }
.stage__canvas { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; display: flex; align-items: center; justify-content: center; }
.stage--wide .stage__canvas { height: 720px; }
body[data-stage-bg="brand"] .stage { background: radial-gradient(70% 80% at 50% 40%, #1f4f9a 0%, #0f2a5c 35%, #0a1733 65%, #070a16 100%); }
body[data-stage-bg="checker"] .stage { background: repeating-conic-gradient(#1a1d26 0 25%, #12141b 0 50%) 0 0 / 28px 28px; }

.stage-card { border-radius: 16px; overflow: hidden; background: var(--surface-secondary); box-shadow: var(--surface-shadow); }
.stage-card__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13px; }
.stage-card__head span { color: var(--muted); font-size: 12px; }
.controls { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 14px; }
.controls label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.controls input[type=range] { width: 150px; accent-color: var(--accent); }
.controls input[type=checkbox] { accent-color: var(--accent); }
.text-field { background: var(--field-background); border-radius: var(--field-radius); color: var(--foreground); padding: 7px 11px; font: 600 15px var(--font-sans); direction: rtl; width: 220px; box-shadow: 0 0 0 1px var(--border) inset; outline: none; }
.text-field:focus { box-shadow: 0 0 0 2px var(--focus) inset; }
.val { color: var(--foreground); font-variant-numeric: tabular-nums; min-width: 40px; }

/* ---- Code --------------------------------------------------------------- */
.code { border-radius: 16px; background: #050812; box-shadow: var(--surface-shadow); overflow: hidden; }
.code__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--separator); }
.code pre { margin: 0; padding: 16px; overflow: auto; max-height: 440px; font: 12.5px/1.65 var(--font-mono); color: #d9d3c4; white-space: pre; direction: ltr; text-align: left; }

/* ==========================================================================
   COMPONENT CARDS
   Rest: final frame. Hover: plays. Click: expands to a full-width sheet.
   The expand/collapse is a View Transition (the card morphs, its neighbours
   slide), so it stays smooth without hand-written FLIP code.
   ========================================================================== */
.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 600px), 1fr));
  grid-auto-flow: row dense;
  gap: 24px;
}
.tfe-card {
  padding: 0;
  gap: 0;
  overflow: hidden;
  border-radius: 26px;
  scroll-margin-top: 84px;
  transition: box-shadow .35s ease;
}
.tfe-card:not(.is-expanded):hover { box-shadow: 0 0 0 1px rgba(230, 188, 103, 0.38) inset, 0 24px 60px rgba(0, 0, 0, 0.4); }
.tfe-card.is-expanded { grid-column: 1 / -1; box-shadow: 0 0 0 1px rgba(230, 188, 103, 0.28) inset, 0 30px 80px rgba(0, 0, 0, 0.45); }

.tfe-card__head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 16px; }
.tfe-card__name { font-size: 20px; font-weight: 700; line-height: 1.2; color: var(--foreground); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tfe-card__name .ar { color: #dcc099; font-weight: 700; }
.tfe-card__desc { margin-top: 6px; font-size: 13.5px; color: var(--muted); max-width: 70ch; }
.tfe-card__meta { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.tfe-card__close { display: none; }
.tfe-card.is-expanded .tfe-card__close { display: inline-flex; }

.tfe-card__preview { position: relative; margin: 0 16px; border-radius: 18px; overflow: hidden; cursor: zoom-in; outline: none; }
.tfe-card__preview:focus-visible { box-shadow: 0 0 0 2px var(--focus); }
.tfe-card.is-expanded .tfe-card__preview { cursor: default; background: #000; }
body[data-stage-bg="brand"] .tfe-card.is-expanded .tfe-card__preview { background: #0a1733; }
.tfe-card.is-expanded .tfe-card__preview .stage { width: min(100%, calc(68vh * 16 / 9)); margin-inline: auto; }
.tfe-card__hint {
  position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 6px);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; color: var(--foreground);
  background: color-mix(in oklab, var(--overlay) 82%, transparent); backdrop-filter: blur(8px);
  box-shadow: var(--overlay-shadow); opacity: 0; pointer-events: none;
  transition: opacity .35s ease, transform .45s cubic-bezier(.32,.72,0,1);
}
.tfe-card:not(.is-expanded):hover .tfe-card__hint { opacity: 1; transform: translate(-50%, 0); }

.tfe-card__live { display: none; align-items: center; gap: 8px; padding: 12px 16px 0; }
.tfe-card.is-expanded .tfe-card__live { display: flex; }
.tfe-card__state { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-inline-start: 6px; min-width: 70px; }

.tfe-card__foot { display: flex; align-items: center; gap: 8px; padding: 16px 24px 22px; }
.tfe-card__sheet { display: none; padding: 4px 24px 28px; }
.tfe-card.is-expanded .tfe-card__sheet { display: block; animation: tfe-sheet-in 620ms 180ms cubic-bezier(.32,.72,0,1) both; }
@keyframes tfe-sheet-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.sheet-section { margin-top: 28px; }
.sheet-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-section__head h4 { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }

/* View Transition tuning: the card's box morphs; contents cross-fade unscaled. */
::view-transition-group(*) { animation-duration: 640ms; animation-timing-function: cubic-bezier(.32,.72,0,1); }
::view-transition-image-pair(*) { overflow: hidden; border-radius: 26px; }
::view-transition-image-pair(root) { border-radius: 0; }
::view-transition-old(*), ::view-transition-new(*) { width: 100%; height: 100%; object-fit: none; object-position: top left; }
::view-transition-old(*) { animation-duration: 260ms; }
::view-transition-new(*) { animation-duration: 520ms; }

/* ---- Toast (HeroUI overlay tokens) -------------------------------------- */
.tfe-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 14px; font-size: 13px; color: var(--foreground);
  background: var(--overlay); box-shadow: var(--overlay-shadow);
  transition: opacity .35s ease, transform .45s cubic-bezier(.32,.72,0,1);
}
.tfe-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.tfe-toast b { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 1ms; }
}

/* Unchanged page areas swap instantly; only named parts (cards, sections below) animate. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
