/* Loose Ends · Web animations — the shared shell.
   Dark HUD bars top and bottom, a frosted parameter drawer on the left,
   aligned readouts. Colours are the Loose Ends tokens (/assets/tokens.css):
   orange #f86916 marks anything interactive; themes pair a token accent
   with a token stage. */

:root {
  /* Loose Ends tokens */
  --ui-accent: #f86916;   /* the one interactive colour */
  --le-teal: #3fbdac;
  --le-navy: #12263f;
  --le-mist: #cfe5e6;
  --le-ink: #111111;

  /* HUD surfaces and text */
  --bg-surface: #111111;
  --border-subtle: rgba(255, 255, 255, 0.10);
  --border-hud: rgba(255, 255, 255, 0.12);
  --text-main: #FFFFFF;
  --text-muted: #9BA3B4;
  --text-dim: #646E82;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --hud-top: 56px;
  --hud-bottom: 52px;
  --drawer-w: 380px;

  /* Theme slots (set by body.theme-*): the motion's colour and the stage behind it */
  --accent: var(--le-teal);
  --accent-soft: rgba(63, 189, 172, 0.14);
  --stage: var(--bg-surface);
}

/* Themes: each pairs a token accent (the motion's colour) with a token stage. */
body.theme-teal-ink { --accent: #3fbdac; --stage: #111111; }
body.theme-orange-ink { --accent: #f86916; --stage: #111111; }
body.theme-teal-navy { --accent: #3fbdac; --stage: #12263f; }
body.theme-orange-navy { --accent: #f86916; --stage: #12263f; }
body.theme-mist-navy { --accent: #cfe5e6; --stage: #12263f; }
body.theme-light { --accent: #f86916; --stage: #ffffff; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--stage);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background-color 0.4s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

/* ---- Stage: the full-bleed canvas / svg / video behind the HUD ---- */
.stage { position: fixed; inset: 0; z-index: 0; touch-action: none; cursor: grab; }
/* With the drawer open, the stage sits beside it rather than under it (desktop; phones keep the bottom sheet). */
@media (min-width: 701px) {
  body.drawer-open:not(.hud-hidden) .stage { left: var(--drawer-w); }
  body.drawer-open:not(.hud-hidden) .source-bar { right: 20px; }
}
.stage:active { cursor: grabbing; }
.stage canvas, .stage svg, .stage video { display: block; width: 100%; height: 100%; }

/* ---- Top bar ---- */
.hud-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--hud-top);
  background: #000; border-bottom: 1px solid var(--border-hud);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; z-index: 100;
  transition: transform 0.35s var(--ease-out);
}
.crumb { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--text-main); text-decoration: none; font-size: 13px; }
.crumb .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ui-accent); box-shadow: 0 0 8px var(--ui-accent); flex: none; }
.crumb .lab { color: var(--text-muted); white-space: nowrap; }
.crumb .sep { color: var(--text-dim); }
.crumb .here { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.presets { display: flex; gap: 4px; padding: 4px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border-subtle); border-radius: 10px; }
.preset { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.preset kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }
.preset:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.08); }
.preset[aria-pressed="true"] { color: var(--ui-accent); background: rgba(248, 105, 22, 0.12); font-weight: 600; }
.preset[aria-pressed="true"] kbd { color: inherit; }

.actions { display: flex; gap: 8px; }
.action { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-subtle); background: rgba(255, 255, 255, 0.06); color: var(--text-muted); font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.action:hover { color: var(--text-main); border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.12); }
.action[aria-pressed="true"] { color: var(--ui-accent); border-color: rgba(248, 105, 22, 0.35); }
.action kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }

/* ---- Bottom bar ---- */
.hud-footer {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--hud-bottom);
  background: #000; border-top: 1px solid var(--border-hud);
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; z-index: 100;
  transition: transform 0.35s var(--ease-out);
}
.track { flex: 1 1 260px; min-width: 120px; height: 20px; position: relative; cursor: pointer; touch-action: none; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 2px; background: rgba(255, 255, 255, 0.14); border-radius: 2px; }
.track .fill { position: absolute; left: 0; top: 9px; height: 2px; background: var(--ui-accent); border-radius: 2px; }
.track .knob { position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--ui-accent); box-shadow: 0 0 10px rgba(248, 105, 22, 0.6); }
.telemetry { display: flex; gap: 18px; font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.telemetry span { color: var(--text-dim); }
.telemetry b { color: var(--text-main); font-weight: 500; margin-left: 6px; font-variant-numeric: tabular-nums; }
.themes { display: flex; gap: 6px; }
.theme-pill { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.18); cursor: pointer; padding: 0; }
.theme-pill[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15); }

/* Exit for presentation mode: faint until hovered or focused, only while the HUD is hidden. */
.exit-present { position: fixed; top: 16px; right: 16px; z-index: 110; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
body.hud-hidden .exit-present { opacity: 0.4; pointer-events: auto; }
body.hud-hidden .source-bar { display: none !important; } /* module tool bars (03, 07) hide with the HUD */
body.hud-hidden .exit-present:hover, body.hud-hidden .exit-present:focus-visible { opacity: 1; }
body.hud-hidden .hud-header { transform: translateY(-100%); }
body.hud-hidden .hud-footer { transform: translateY(100%); }
body.hud-hidden .drawer { transform: translateX(-100%); }

/* ---- Parameter drawer ---- */
.drawer {
  position: fixed; top: var(--hud-top); bottom: var(--hud-bottom); left: 0; width: var(--drawer-w);
  background: rgba(14, 18, 28, 0.88);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-hud);
  transform: translateX(-100%); transition: transform 0.35s var(--ease-out);
  z-index: 90; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 1px solid var(--border-subtle); }
.drawer-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.drawer-head .close { border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 20px 20px; }
.group { padding: 14px 0; border-bottom: 1px solid var(--border-subtle); }
.group:last-child { border-bottom: 0; }
.group h3 { margin: 0 0 10px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-accent); }
.ctrl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; margin-bottom: 12px; font-size: 12.5px; }
.ctrl label { color: var(--text-muted); }
.ctrl output { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-main); font-variant-numeric: tabular-nums; }
.ctrl input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--ui-accent); }
.ctrl select { grid-column: 2; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.ctrl.toggle input { accent-color: var(--ui-accent); width: 16px; height: 16px; }
.ctrl.text .text-field { grid-column: 1 / -1; width: 100%; color: var(--text-main); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; resize: vertical; }
.swatch-pick { grid-column: 2; display: inline-flex; align-items: center; gap: 8px; }
.swatch-pick select { max-width: 190px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.swatch-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.3); flex: none; }
.sets-row { display: flex; gap: 6px; margin-bottom: 8px; }
.sets-row input, .sets-row select { flex: 1; min-width: 0; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
/* Safari/WebKit draws its own light select and keeps our light text (white on white), so drop the native look
   and draw the chevron ourselves. Same result in every engine. */
.drawer select { -webkit-appearance: none; appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a3abb8' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.drawer select option { background: #0e121c; color: #fff; }
.sets-row .action { padding: 5px 10px; }
.sets textarea { width: 100%; margin: 6px 0; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 8px; font: 11px/1.4 var(--font-mono); color: var(--text-main); resize: vertical; }
.linkish { background: none; border: 0; padding: 2px 0; color: var(--ui-accent); font-size: 12px; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.sets-msg { margin: 6px 0 0; min-height: 1.2em; font-size: 11.5px; color: var(--ui-accent); }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border-subtle); display: flex; gap: 8px; }
.drawer-foot button { flex: 1; }
.copied { color: var(--ui-accent) !important; }

/* Two-column aligned readouts */
.specs-grid { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; row-gap: 8px; align-items: baseline; font-size: 12px; line-height: 1.5; }
.spec-label { font-family: var(--font-mono); font-weight: 600; color: var(--text-main); white-space: nowrap; }
.spec-value { color: var(--text-muted); word-break: break-word; }

/* Shortcut help (?) */
.help { position: fixed; right: 20px; bottom: calc(var(--hud-bottom) + 16px); z-index: 95; width: 300px; padding: 16px; border-radius: 12px; background: rgba(14, 18, 28, 0.92); border: 1px solid var(--border-hud); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.help h3 { margin: 0 0 10px; font-size: 12px; }
kbd.k { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-subtle); background: rgba(255, 255, 255, 0.06); color: var(--text-main); }

/* ---- Phones: the drawer becomes a bottom sheet, the bars simplify ---- */
@media (max-width: 700px) {
  :root { --drawer-w: 100vw; }
  .drawer { top: auto; height: 62vh; width: 100%; transform: translateY(110%); border-right: 0; border-top: 1px solid var(--border-hud); border-radius: 14px 14px 0 0; bottom: var(--hud-bottom); }
  .drawer.open { transform: translateY(0); }
  body.hud-hidden .drawer { transform: translateY(110%); }
  .crumb .lab, .crumb .sep, .preset span, .action span, .telemetry .extra, .themes { display: none; }
  .hud-header, .hud-footer { padding: 0 12px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .hud-header, .hud-footer, .drawer { transition: none; }
}

/* ---- Notes: the effect's writeup, in a panel on the right ---- */
.notes { position: fixed; top: var(--hud-top); bottom: var(--hud-bottom); right: 0; width: min(460px, 100vw); z-index: 92; display: flex; flex-direction: column; background: rgba(14, 18, 28, 0.94); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border-left: 1px solid var(--border-hud); }
.notes-body { flex: 1; overflow-y: auto; padding: 8px 24px 28px; font-size: 14.5px; line-height: 1.65; color: rgba(255, 255, 255, 0.86); }
.notes-body h3 { margin: 22px 0 6px; font-size: 13px; font-weight: 700; color: var(--text-main); }
.notes-body p { margin: 0 0 10px; }
.notes-body a { color: var(--ui-accent); }
.notes-body .credit { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border-subtle); font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
body.hud-hidden .notes { display: none; }
@media (min-width: 701px) {
  body.notes-open:not(.hud-hidden) .stage { right: min(460px, 100vw); }
  body.notes-open:not(.hud-hidden) .source-bar { right: calc(min(460px, 100vw) + 20px) !important; }
}
@media (max-width: 700px) { .notes { width: 100vw; border-left: 0; } }
