/* Studio Day, Watch mode (assets/js/modules/director.js, cards.js): the director's bar over the foot of
   the viewport (the caption, Pause, Skip to premiere, the six named chapters, the language, "Tap for
   sound" and the "Book a demo" chip) and the one card beside the caption. Loaded with home.css
   wherever the game can open. The game is a dark island (.fg.is-dark). Motion only under
   prefers-reduced-motion: no-preference. */

/* Watching is hands off: the viewport takes no drags (the panel is inert in JS). */
.fg[data-mode="watch"] .fg__canvas { pointer-events: none; }
.fg[data-mode="watch"] .fg__cursor { display: none; }

.fg__director {
  position: absolute; z-index: 6; left: 50%; bottom: 16px; translate: -50% 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 16px;
  width: min(760px, calc(100% - 32px)); padding: 12px 12px 12px 18px;
  border: 1px solid var(--fg-line2, rgb(255 255 255 / 0.14)); border-radius: 6px;
  background: rgb(11 11 14 / 0.82); box-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.7);
  color: #efede8;
}
.fg__director[hidden] { display: none; }
@supports (backdrop-filter: blur(1px)) { .fg__director { background: rgb(11 11 14 / 0.66); backdrop-filter: blur(10px); } }
.fg__dir-text { min-width: 0; }
.fg__dir-who { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font: 700 0.6875rem/1.2 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); }
.fg__dir-who::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.fg[data-layout="card"] .fg__dir-who, .fg.is-premiere .fg__dir-who { display: none; }
.fg__dir-caption { margin: 0; font: 600 1rem/1.4 var(--font-body); text-wrap: balance; }
.fg__dir-caption:lang(ta) { font-size: 0.9375rem; line-height: 1.5; }
.fg__dir-btns { display: flex; gap: 6px; }
.fg__dir-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 1px solid rgb(255 255 255 / 0.18); border-radius: 4px; background: rgb(255 255 255 / 0.06);
  color: inherit; font: 600 0.8125rem/1 var(--font-body); white-space: nowrap; cursor: pointer;
}
.fg__dir-btn:hover { background: rgb(255 255 255 / 0.12); }
:is(.fg__dir-btn, .fg__dir-chip, .fg__dir-lang-btn):focus-visible { outline: 2px solid #f5c518; outline-offset: 2px; }
.fg__dir-btn:disabled { opacity: 0.45; cursor: default; }
.fg__dir-btn .icon { width: 16px; height: 16px; }
.fg__dir-btn[aria-pressed="true"] { border-color: #f5c518; color: #f5c518; }
.fg__dir-ico { display: inline-flex; }
.fg__dir-btn[aria-pressed="true"] .fg__dir-ico--pause, .fg__dir-btn:not([aria-pressed="true"]) .fg__dir-ico--play { display: none; }
.fg__dir-btn--skip { background: #f5c518; border-color: #f5c518; color: #141414; }
.fg__dir-btn--skip:hover { background: #ffd84a; }

/* The foot of the bar: the chapters, then the small tools. */
.fg__dir-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; min-width: 0; }
.fg__dir-progress { flex: 1; min-width: 0; }
.fg__dir-chapters { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.fg__dir-chapter { flex: 1; min-width: 0; display: grid; gap: 5px; }
.fg__dir-chap-name { overflow: hidden; font: 700 0.6875rem/1.1 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; text-overflow: ellipsis; color: rgb(255 255 255 / 0.42); }
.fg__dir-chapter[data-state="done"] .fg__dir-chap-name { color: rgb(255 255 255 / 0.72); }
.fg__dir-chapter[data-state="now"] .fg__dir-chap-name { color: #f5c518; }
.fg__dir-chap-bar { position: relative; display: block; height: 3px; overflow: hidden; border-radius: 2px; background: rgb(255 255 255 / 0.14); }
.fg__dir-chap-bar::after { content: ""; position: absolute; inset: 0; background: #f5c518; transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
.fg__dir-chapter[data-state="done"] .fg__dir-chap-bar::after { background: rgb(245 197 24 / 0.6); }
@media (prefers-reduced-motion: no-preference) { .fg__dir-chap-bar::after { transition: transform 0.2s linear; } }
.fg__dir-chap-now { display: none; margin: 0; }

.fg__dir-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.fg__dir-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid rgb(255 255 255 / 0.22); border-radius: 999px; background: rgb(255 255 255 / 0.06);
  color: inherit; font: 600 0.8125rem/1 var(--font-body); white-space: nowrap; cursor: pointer;
}
.fg__dir-chip[hidden] { display: none; }
.fg__dir-chip .icon { width: 15px; height: 15px; }
.fg__dir-chip:hover { background: rgb(255 255 255 / 0.12); }
.fg__dir-chip--lead { border-color: rgb(245 197 24 / 0.7); color: #f5c518; }
.fg__dir-chip--lead:hover { background: rgb(245 197 24 / 0.12); }
.fg__dir-lang { display: inline-flex; padding: 2px; border: 1px solid rgb(255 255 255 / 0.18); border-radius: 999px; }
.fg__dir-lang-btn { min-height: 28px; min-width: 36px; padding: 0 9px; border: 0; border-radius: 999px; background: none; color: rgb(255 255 255 / 0.66); font: 600 0.75rem/1 var(--font-body); cursor: pointer; }
.fg__dir-lang-btn[aria-pressed="true"] { background: rgb(255 255 255 / 0.16); color: #fff; }
/* Touch: every chip and language button is a 44px target. */
@media (pointer: coarse) { :is(.fg__dir-chip, .fg__dir-lang-btn) { min-height: 44px; } .fg__dir-lang-btn { min-width: 44px; } }
@media (prefers-reduced-motion: no-preference) {
  /* One fade-in for the chip, one pulse for "Tap for sound"; nothing loops. */
  .fg__dir-chip--lead:not([hidden]) { animation: fg-dir-in 0.4s ease-out both; }
  .fg__dir-chip--sound:not([hidden]) { animation: fg-dir-pulse 1.2s ease-out 1 both; }
}
@keyframes fg-dir-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes fg-dir-pulse { 0% { box-shadow: 0 0 0 0 rgb(245 197 24 / 0.55); } 100% { box-shadow: 0 0 0 10px rgb(245 197 24 / 0); } }

/* Animate: the timeline shortens the viewport and Frame jumps the full height of it, so in the editor the
   bar docks bottom-right, in the room the camera keeps free for the card (Frame stays in the left ~58%):
   one column, the caption over the buttons, the chapters over the tools. */
.fg[data-layout="editor"][data-scene="animate"] .fg__director { left: auto; right: 16px; translate: none; width: min(420px, calc(40% - 24px)); grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
.fg[data-layout="editor"][data-scene="animate"] .fg__dir-caption { font-size: 0.9375rem; }
.fg[data-layout="editor"][data-scene="animate"] .fg__dir-caption:lang(ta) { font-size: 0.875rem; line-height: 1.45; }
.fg[data-layout="editor"][data-scene="animate"] .fg__dir-foot { flex-wrap: wrap; gap: 8px; }
.fg[data-layout="editor"][data-scene="animate"] .fg__dir-progress { flex-basis: 100%; }

/* The end: the last caption over the credits, nothing else; gone once the finale's page is up. */
.fg__director[data-state="end"] :is(.fg__dir-btns, .fg__dir-foot) { display: none; }
.fg__director[data-state="end"] { grid-template-columns: minmax(0, 1fr); text-align: center; }
.fg:not(.is-premiere) .fg__director[data-state="end"], .fg[data-scene="finale"]:not(.is-premiere) .fg__director { display: none; }
/* Over the credits: the last line sits in the upper letterbox band, clear of Frame and the cards. */
.fg.is-premiere .fg__director { top: calc(var(--fg-band, 18%) / 2); bottom: auto; translate: -50% -50%; padding: 0; border: 0; background: none; box-shadow: none; backdrop-filter: none; }
.fg.is-premiere .fg__dir-caption { font-size: 1.125rem; letter-spacing: 0.02em; color: rgb(255 255 255 / 0.86); }
/* Loading: the studio's progress bar speaks for itself. */
.fg__stage:has(.fg__loading:not([hidden])) :is(.fg__director, .fg__cards) { display: none; }

/* Phones (the card layout): one slim row docked on the viewport's foot (~60 px, so Frame keeps the
   stage): the caption, two lines, or three small ones within the buttons' 44px (director.js steps its
   size down to fit; the full line is spoken to screen readers), then Pause, Skip, the other language and the chips (all 44px). The chapters are a
   segmented line on its top edge. Pause and Skip keep 44px targets, their long words visually hidden
   (still their names); "Tap for sound" shows its icon only. */
.fg[data-layout="card"] .fg__director { left: 0; bottom: 0; translate: none; width: 100%; grid-template-columns: minmax(0, 1fr) auto auto; padding: 6px 6px 6px 12px; gap: 6px; border-width: 1px 0 0; border-radius: 0; }
.fg[data-layout="card"] .fg__dir-caption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--fg-cap-lines, 2); line-clamp: var(--fg-cap-lines, 2); overflow: hidden; font-size: var(--fg-cap-size, 0.8125rem); line-height: 1.25; text-wrap: pretty; }
.fg[data-layout="card"] .fg__dir-caption:lang(ta) { font-size: var(--fg-cap-size, 0.78125rem); line-height: 1.25; }
.fg[data-layout="card"] .fg__dir-btns { gap: 4px; }
.fg[data-layout="card"] .fg__dir-btn { min-width: 44px; min-height: 44px; justify-content: center; padding: 0 10px; }
.fg[data-layout="card"] :is(.fg__dir-label, .fg__dir-long, .fg__dir-chip--sound span) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fg[data-layout="card"] .fg__dir-foot { display: contents; }
.fg[data-layout="card"] .fg__dir-progress { position: absolute; left: 0; right: 0; top: -1px; }
.fg[data-layout="card"] .fg__dir-chapters { gap: 2px; }
.fg[data-layout="card"] .fg__dir-chap-name, .fg[data-layout="card"] .fg__dir-chap-now { display: none; }
.fg[data-layout="card"] .fg__dir-chap-bar { border-radius: 0; }
.fg[data-layout="card"] .fg__dir-tools { gap: 4px; }
.fg[data-layout="card"] .fg__dir-chip { min-height: 44px; padding: 0 10px; font-size: 0.75rem; }
.fg[data-layout="card"] .fg__dir-chip--sound { min-width: 44px; justify-content: center; padding: 0; }
/* The language: one 44px button, the language to switch to (the one on is hidden; still pressed). */
.fg[data-layout="card"] .fg__dir-lang { padding: 0; border: 0; }
.fg[data-layout="card"] .fg__dir-lang-btn { min-height: 44px; min-width: 44px; padding: 0 8px; border: 1px solid rgb(255 255 255 / 0.18); border-radius: 4px; font-size: 0.75rem; }
.fg[data-layout="card"] .fg__dir-lang-btn[aria-pressed="true"] { display: none; }
.fg[data-layout="card"].is-premiere .fg__director { left: 50%; translate: -50% -50%; width: calc(100% - 24px); }
.fg[data-layout="card"] .fg__director[data-state="end"] { grid-template-columns: minmax(0, 1fr); }
.fg[data-layout="card"] .fg__director[data-state="end"] .fg__dir-foot { display: none; }
.fg[data-layout="card"].is-premiere .fg__dir-caption { display: block; overflow: visible; font-size: 1rem; line-height: 1.35; }

/* Watching on the card: Frame, the tabs, the bar and the station's controls; nothing else. */
.fg[data-mode="watch"][data-layout="card"] :is(.fg__foot, .fg__lesson, .fg__more, .fg__kicker, .fg__pane-h) { display: none; }

/* ---------- Cards (cards.js) ----------
   One at a time. Editor: the right third of the stage, under its top edge (the camera leaves that room
   free: Frame sits at ~38% of the width). Card layout: a slim one-line band at the top of the stage. */
.fg__cards { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.fg-card {
  position: absolute; top: 14%; right: 20px; width: min(320px, 30%); box-sizing: border-box; padding: 14px 16px;
  border: 1px solid var(--fg-line2, rgb(255 255 255 / 0.14)); border-left: 3px solid #f5c518; border-radius: 6px;
  background: rgb(11 11 14 / 0.8); box-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.7); color: #efede8;
  opacity: 0;
}
.fg-card.is-in { opacity: 1; }
.fg-card.is-out { opacity: 0; }
@supports (backdrop-filter: blur(1px)) { .fg-card { background: rgb(11 11 14 / 0.62); backdrop-filter: blur(10px); } }
/* Animate: the bar is docked under it in the same room; the card stays at the top. */
.fg[data-layout="editor"][data-scene="animate"] .fg-card { top: 16px; width: min(420px, calc(40% - 24px)); right: 16px; }
.fg-card p { margin: 0; }
.fg-card__body { display: grid; gap: 4px; }
/* term: icon (or a colour swatch), the word, its line */
.fg-card[data-kind="term"] .fg-card__body { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 12px; }
.fg-card__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgb(245 197 24 / 0.14); color: #f5c518; }
.fg-card__icon .icon { width: 20px; height: 20px; }
.fg-card__icon.is-swatch { background: var(--c); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25); }
.fg-card__words { display: grid; gap: 3px; min-width: 0; }
.fg-card__word { font: 700 1.0625rem/1.25 var(--font-body); color: #fff; }
.fg-card__text { font: 400 0.875rem/1.45 var(--font-body); color: rgb(255 255 255 / 0.78); }
/* fact: a big value, its label, its source */
.fg-card__value { font: 700 1.25rem/1.2 var(--font-display, var(--font-body)); color: #f5c518; text-wrap: balance; font-variant-numeric: tabular-nums; }
.fg-card__label { font: 400 0.8125rem/1.45 var(--font-body); color: rgb(255 255 255 / 0.8); }
.fg-card__src { font: 500 0.6875rem/1.3 var(--font-body); color: rgb(255 255 255 / 0.5); }
/* step: chips with arrows, done / now / next */
.fg-card__steps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; margin: 0; padding: 0; list-style: none; }
.fg-card__step { display: inline-flex; align-items: center; gap: 6px; font: 600 0.8125rem/1 var(--font-body); color: rgb(255 255 255 / 0.5); }
.fg-card__step + .fg-card__step::before { content: "→"; color: rgb(255 255 255 / 0.35); font-weight: 400; }
.fg-card__step[data-state="plain"] { color: #fff; }
.fg-card__step[data-state="now"] { color: #f5c518; }
.fg-card__step[data-state="done"] { color: #fff; }
.fg-card__step[data-state="done"]::after { content: "✓"; color: #f5c518; font-size: 0.75rem; }
@media (prefers-reduced-motion: no-preference) {
  .fg-card { transform: translateY(8px); transition: opacity 0.22s ease-out, transform 0.22s ease-out; }
  .fg-card.is-in { transform: none; }
  .fg-card.is-out { transform: translateY(-4px); transition-duration: 0.16s; transition-timing-function: ease-in; }
  .fg-card:not(.is-patched) .fg-card__step { animation: fg-card-chip 0.22s ease-out both; animation-delay: calc(var(--i, 0) * 120ms + 120ms); }
  .fg[data-dir-paused] .fg-card__step { animation-play-state: paused; }
}
@keyframes fg-card-chip { from { opacity: 0; transform: translateY(4px); } }

/* Phones: one line across the top of the stage, no camera room (the stage is too short to push Frame
   down): a fact shows its value, a term its word and line, a step its chips. */
.fg[data-layout="card"] .fg-card { top: 8px; left: 12px; right: 12px; width: auto; max-height: 25%; padding: 7px 10px; border-left-width: 3px; }
.fg[data-layout="card"] .fg-card__body { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fg[data-layout="card"] .fg-card__icon { flex: none; width: 22px; height: 22px; }
.fg[data-layout="card"] .fg-card__icon .icon { width: 13px; height: 13px; }
.fg[data-layout="card"] .fg-card__words { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 0.8125rem; }
.fg[data-layout="card"] :is(.fg-card__word, .fg-card__text) { display: inline; font-size: 0.8125rem; line-height: 1.3; white-space: nowrap; }
.fg[data-layout="card"] .fg-card__text::before { content: " · "; color: rgb(255 255 255 / 0.4); }
.fg[data-layout="card"] .fg-card__value { overflow: hidden; font-size: 0.875rem; white-space: nowrap; text-overflow: ellipsis; }
.fg[data-layout="card"] :is(.fg-card__label, .fg-card__src) { display: none; }
.fg[data-layout="card"] .fg-card__steps { flex-wrap: nowrap; overflow: hidden; gap: 4px; }
.fg[data-layout="card"] .fg-card__step { flex: none; gap: 4px; font-size: 0.6875rem; white-space: nowrap; }
