/* Greenroom chrome — "backstage": dark warm green-charcoal stage, the deck is the star. */

:root {
  --bg: #121714;
  --panel: #181F1B;
  --canvas: #0C100E;
  --line: rgba(233, 228, 216, .08);
  --ink: #E9E4D8;
  --ink-dim: #93A096;
  --accent: #3FA47C;
  --amber: #E8B04B;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Archivo", -apple-system, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* mono micro-label voice: uppercase, letter-spaced, 11px */
.micro {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
}

button {
  font-family: var(--font-ui);
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: default; }
button:disabled:active { transform: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wordmark-dot { color: var(--accent); }

/* ============ EMPTY / LANDING ============ */

.gr-empty {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(63, 164, 124, .05), transparent 60%),
    var(--bg);
}
.empty-stack {
  display: flex; flex-direction: column; align-items: center;
  gap: 28px; width: 100%; padding: 0 24px;
}
.empty-wordmark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "opsz" 144;
  font-size: clamp(64px, 9vw, 96px);
  line-height: 1.05;
  letter-spacing: -.015em;
}
.empty-tagline { color: var(--ink-dim); }

.dropzone {
  /* 16:9 "stage floor" (SPEC §5) at every viewport: constrain WIDTH on short
     windows (38vh-equivalent) — a max-height would clamp height alone and
     silently break the aspect ratio below ~947px-tall viewports. */
  width: min(640px, 84vw, calc(38vh * 16 / 9));
  aspect-ratio: 16 / 9;
  margin-top: 12px;
  border: 1.5px dashed rgba(233, 228, 216, .22);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(233, 228, 216, .015), rgba(233, 228, 216, .035));
  transition: transform 160ms var(--ease), border-color 160ms var(--ease),
              background-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.dropzone.dragover { background-color: rgba(63, 164, 124, .06); }
.dropzone-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; /* keep dragleave from firing on children */
}
.dz-glyph { font-size: 26px; color: var(--accent); line-height: 1; }
.dz-label { color: var(--ink); }
.dz-sub { color: var(--ink-dim); }

.empty-error { color: var(--amber); min-height: 14px; }
.empty-footer {
  position: fixed; bottom: 22px; left: 0; right: 0;
  text-align: center; color: var(--ink-dim); opacity: .65;
}

/* staggered fade-up on load (CSS only). `backwards` fill + from-keyframe, NOT
   base styles + `forwards`: a persistent forwards fill would pin transform:none
   and permanently override the dropzone's hover/dragover translateY lift. */
.fade-up {
  animation: fadeUp 480ms var(--ease) backwards;
  animation-delay: var(--d, 0ms);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

/* ============ APP SHELL ============ */

.gr-app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}
.gr-main { flex: 1; display: flex; min-height: 0; }

/* ---- topbar ---- */
.topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; }
.tb-wordmark {
  font-family: var(--font-display);
  font-style: italic; font-weight: 500;
  font-variation-settings: "opsz" 60;
  font-size: 19px;
}
.filechip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dirty-dot {
  width: 6px; height: 6px; flex: none;
  border-radius: 50%; background: var(--amber);
}
.modebadge {
  padding: 3px 8px;
  border: 1px solid rgba(232, 176, 75, .35);
  border-radius: 4px;
  color: var(--amber);
}

.iconbtn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  color: var(--ink-dim);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.iconbtn:hover:not(:disabled) { background: rgba(233, 228, 216, .07); color: var(--ink); }

.savebtn {
  margin-left: 4px;
  padding: 6px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #0C100E;
  font-size: 13px; font-weight: 500;
  transition: background-color 140ms var(--ease), color 140ms var(--ease),
              filter 140ms var(--ease), box-shadow 140ms var(--ease);
}
.savebtn:hover { filter: brightness(1.1); }
.savebtn.flash {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
}

/* ---- filmstrip ---- */
.filmstrip {
  width: 224px; flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 228, 216, .14) transparent;
}
.fs-inner { position: relative; }
.fs-frame {
  position: absolute;
  overflow: hidden;
  border-radius: 2px;
}
.fs-frame iframe {
  border: 0; display: block;
  pointer-events: none;
  transform-origin: top left;
  background: #fff;
}
.fs-row { position: absolute; left: 0; width: 100%; }
.fs-hit {
  position: absolute; inset: 0; width: 100%;
  border-radius: 4px;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease),
              background-color 140ms var(--ease);
}
.fs-row:hover .fs-hit { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
.fs-hit::before { /* thumb border + active accent bar live on the hit, over the iframe */
  content: ""; position: absolute; inset: 0; left: 36px;
  border: 1px solid var(--line); border-radius: 2px;
  pointer-events: none;
  transition: border-color 140ms var(--ease);
}
.fs-row.active .fs-hit::before { border-color: rgba(63, 164, 124, .55); }
.fs-row.active .fs-hit::after {
  content: ""; position: absolute; left: 30px; top: 2px; bottom: 2px;
  width: 2px; background: var(--accent); border-radius: 2px;
}
.fs-num {
  position: absolute; left: 0; top: 4px; width: 28px;
  text-align: right;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em;
  color: var(--ink-dim);
}
.fs-row.active .fs-num { color: var(--accent); }
.fs-tools {
  position: absolute; right: 6px; top: 4px;
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity 140ms var(--ease);
}
.fs-row:hover .fs-tools, .fs-tools:focus-within { opacity: 1; }
.fs-tool {
  min-width: 22px; height: 22px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  background: rgba(12, 16, 14, .82);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
  transition: color 140ms var(--ease), border-color 140ms var(--ease);
}
.fs-tool:hover { color: var(--ink); border-color: rgba(233, 228, 216, .25); }
.fs-tool.confirm { color: var(--amber); border-color: rgba(232, 176, 75, .5); text-transform: uppercase; }
.fs-dropline {
  position: absolute; left: 34px; right: 6px; height: 2px;
  background: var(--accent); border-radius: 2px;
  box-shadow: 0 0 8px rgba(63, 164, 124, .6);
  pointer-events: none;
}
.fs-row.dragging .fs-hit { opacity: .45; }
.filmstrip.is-dragging, .filmstrip.is-dragging .fs-hit { cursor: grabbing; }

/* ---- canvas pit ---- */
.canvas {
  flex: 1; min-width: 0;
  position: relative;
  background: var(--canvas);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.canvas::before { /* vignette */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(85% 75% at 50% 46%, transparent 55%, rgba(0, 0, 0, .42) 100%);
  z-index: 2;
}
.canvas::after { /* faint grain */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .025;
  z-index: 2;
}
.stage-box { position: relative; z-index: 1; }
.stage {
  width: 1920px; height: 1080px;
  transform-origin: top left;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 40px rgba(0, 0, 0, .5),
              0 40px 120px rgba(0, 0, 0, .45);
}
.stage iframe { width: 1920px; height: 1080px; border: 0; display: block; }

.statusline {
  position: absolute; right: 18px; bottom: 14px; z-index: 3;
  color: var(--ink-dim);
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}

/* reload shimmer: 2px accent line sweeping across canvas top */
.shimmer {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  z-index: 4; overflow: hidden;
  opacity: 0;
  transition: opacity 140ms var(--ease);
}
.shimmer.on { opacity: 1; }
.shimmer::before {
  content: ""; position: absolute; top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.shimmer.on::before { animation: sweep 900ms linear infinite; }
@keyframes sweep { to { left: 100%; } }

/* ============ CHART POPOVER ============ */

.popover {
  position: fixed; z-index: 50;
  width: 320px; max-height: min(540px, 80vh);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid rgba(233, 228, 216, .12);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4), 0 24px 70px rgba(0, 0, 0, .55);
  animation: popIn 150ms var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(5px) scale(.985); } }

.pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-dim);
}
.pop-close { width: 24px; height: 24px; border-radius: 6px; color: var(--ink-dim); }
.pop-close:hover { background: rgba(233, 228, 216, .07); color: var(--ink); }
.pop-body { padding: 12px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.seg {
  display: flex;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 2px; gap: 2px;
}
.seg button {
  flex: 1; padding: 5px 0; border-radius: 6px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.seg button[aria-pressed="true"] { background: rgba(63, 164, 124, .16); color: var(--accent); }

.pop-rows { display: flex; flex-direction: column; gap: 6px; }
.pop-row { display: flex; gap: 6px; align-items: center; }
.pop-row input, .pop-caption input {
  background: rgba(12, 16, 14, .6);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font: 13px var(--font-ui);
  padding: 6px 9px;
  min-width: 0;
  transition: border-color 140ms var(--ease);
}
.pop-row input:focus, .pop-caption input:focus { outline: none; border-color: var(--accent); }
.pop-row .in-label { flex: 1 1 auto; }
.pop-row .in-value { flex: 0 0 76px; font-family: var(--font-mono); font-size: 12px; }
.row-x {
  width: 24px; height: 24px; flex: none;
  border-radius: 6px; color: var(--ink-dim); font-size: 13px;
}
.row-x:hover { color: var(--amber); background: rgba(232, 176, 75, .08); }
.pop-add {
  align-self: flex-start;
  padding: 4px 9px; border-radius: 6px;
  border: 1px dashed rgba(233, 228, 216, .2);
  color: var(--ink-dim);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
.pop-add:hover { color: var(--accent); border-color: rgba(63, 164, 124, .5); }
.pop-caption { display: flex; flex-direction: column; gap: 5px; }
.pop-caption label { color: var(--ink-dim); }
.pop-caption input { width: 100%; }

.pop-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.pop-cancel { padding: 6px 12px; border-radius: 8px; color: var(--ink-dim); font-size: 13px; }
.pop-cancel:hover { color: var(--ink); }
.pop-apply {
  padding: 6px 16px; border-radius: 8px;
  background: var(--accent); color: #0C100E;
  font-size: 13px; font-weight: 500;
}
.pop-apply:hover:not(:disabled) { filter: brightness(1.1); }

/* ============ TOAST ============ */

.toast {
  position: fixed; bottom: 26px; left: 50%; z-index: 60;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  animation: toastIn 180ms var(--ease);
}
.toast.out { opacity: 0; transition: opacity 180ms var(--ease); } /* §5: 120–180ms */
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ============ REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .shimmer.on::before { animation: none; left: 0; width: 100%; }
}

/* ============ TOPBAR TOOLS (insert / theme / present / pdf) ============ */
.toolbtn {
  appearance: none; background: none; border: 1px solid transparent;
  color: var(--ink-dim); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 6px 9px; border-radius: 7px; cursor: pointer;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}
.toolbtn:hover { color: var(--ink); background: rgba(233, 228, 216, .06); }
.toolbtn:active { transform: translateY(1px); }
.toolbtn:disabled { opacity: .35; cursor: default; }
.toolbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }

/* ============ FLOATING BLOCK TOOLBAR ============ */
.blockbar {
  position: fixed; z-index: 70; display: flex; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 14px 40px rgba(0, 0, 0, .35);
  animation: bbIn 140ms var(--ease);
}
@keyframes bbIn { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .blockbar { animation: none; } }
.bb-btn {
  appearance: none; background: none; border: 0; color: var(--ink-dim);
  font-family: var(--font-mono); font-size: 13px; line-height: 1;
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: 6px; cursor: pointer;
  transition: color 120ms var(--ease), background 120ms var(--ease);
}
.bb-btn:hover { color: var(--ink); background: rgba(233, 228, 216, .07); }
.bb-btn:active { transform: translateY(1px); }
.bb-div { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.bb-swatch {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid rgba(233, 228, 216, .25); cursor: pointer; padding: 0; margin: 0 2px;
  transition: transform 120ms var(--ease);
}
.bb-swatch:hover { transform: scale(1.25); border-color: var(--ink); }

/* ============ THEME MENU ============ */
.thememenu {
  position: fixed; z-index: 75; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 18px 50px rgba(0, 0, 0, .4);
  display: flex; flex-direction: column; gap: 2px;
  animation: bbIn 140ms var(--ease);
}
.theme-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer;
}
.theme-row:hover { background: rgba(233, 228, 216, .05); }
.theme-row .micro { color: var(--ink-dim); }
.theme-row input[type="color"] {
  appearance: none; width: 26px; height: 20px; border: 1px solid var(--line);
  border-radius: 5px; background: none; padding: 0; cursor: pointer;
}
.theme-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 1px; }
.theme-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }

.empty-legal { color: var(--ink-dim); text-decoration: none; border-bottom: 1px solid var(--line); }
.empty-legal:hover { color: var(--accent); border-color: var(--accent); }

.empty-demo { margin-top: 18px; color: var(--ink-dim); }
.empty-demo a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px solid var(--line); transition: color 140ms var(--ease), border-color 140ms var(--ease); }
.empty-demo a:hover { color: var(--accent); border-color: var(--accent); }
