/* ============================================================
   BENTO DECK — engine.css
   Flat, hairline, no cards outside the bento tiles themselves.
   Every design-space px scales with the frame via --px.
   ============================================================ */
:root {
  --bg: #191919; --canvas: #191919; --ink: #FFF4EA; --muted: rgba(255,244,234,.58);
  --accent: #F26157; --tile: #242424; --tile-alt: #2B2B2B; --line: rgba(255,244,234,.14); --headline: #FFF4EA;
  --font-display: 'Darker Grotesque', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --stage-pad: 28px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--font-body); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--font-mono); }

/* ---------- shell ---------- */
.deck { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 0; background: var(--bg); color: var(--ink); }
.deck.is-editing { grid-template-columns: minmax(0, 1fr) 340px; }
.stage { position: relative; min-width: 0; min-height: 0; padding: var(--stage-pad); display: grid; }
.stage:fullscreen { --stage-pad: 0px; background: var(--bg); }
.slide { display: none; container-type: size; width: 100%; height: 100%; place-items: center; }
.slide.is-active { display: grid; }
.frame {
  position: relative; container-type: inline-size;
  width: min(100cqw, calc(100cqh * var(--ar)));
  aspect-ratio: var(--ar);
  background: var(--canvas); overflow: hidden;
}
.canvas {
  --px: calc(100cqw / var(--dw, 1920));
  --gap: 12; --padding: 24; --radius: 16;
  position: absolute; inset: 0; padding: calc(var(--padding) * var(--px));
  background: var(--canvas); overflow: hidden;
}

/* ---------- grid ---------- */
.canvas > .tile, .canvas > .split { width: 100%; height: 100%; }
.split { position: relative; display: grid; width: 100%; height: 100%; min-width: 0; min-height: 0; gap: calc(var(--gap) * var(--px)); }
.tile {
  position: relative; overflow: hidden; min-width: 0; min-height: 0;
  border-radius: calc(var(--radius) * var(--px));
  background: var(--tile); color: var(--ink);
  transform: translateZ(0);
}
.tile.alt { background: var(--tile-alt); }
.tile > img, .tile > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; will-change: transform; }
.tile-fallback { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; }
.tile-fallback span { font-family: var(--font-display); font-weight: 700; font-size: 6cqw; letter-spacing: -.05em; color: var(--ink); opacity: .18; }
.deck.is-editing .tile-fallback, .deck.show-ids .tile-fallback { opacity: 1; }
.tile-index {
  position: absolute; top: calc(12 * var(--px)); left: calc(12 * var(--px)); z-index: 6;
  font: 500 .8cqw/1 var(--font-mono); padding: .35cqw .5cqw; background: #FFF4EA; color: #191919;
  display: none; pointer-events: none;
}
.deck.is-editing .tile-index, .deck.show-ids .tile-index { display: block; }
.tile.is-selected::after { content: ""; position: absolute; inset: 0; z-index: 5; border: 3px double #fff; pointer-events: none; border-radius: inherit; }

/* ---------- dividers (edit mode) ---------- */
.divider { display: none; position: absolute; z-index: 10; background: transparent; border: 0; padding: 0; transform: translate(-50%, -50%); touch-action: none; }
.deck.is-editing .divider { display: block; }
.divider-row { width: 16px; height: 100%; top: 50%; cursor: col-resize; }
.divider-column { width: 100%; height: 16px; left: 50%; cursor: row-resize; }
.divider span { position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; transform: translate(-50%, -50%); background: #fff; border: 1px solid #111; opacity: 0; }
.divider:hover span, .divider:active span, .divider:focus-visible span { opacity: 1; }

/* ---------- text tiles ---------- */
.tile-text, .tile-overlay {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  padding: calc(var(--tpad, 36) * var(--px)); gap: calc(10 * var(--px)); text-align: left;
}
.align-top-left { justify-content: flex-start; }
.align-top-right { justify-content: flex-start; align-items: flex-end; text-align: right; }
.align-bottom-right { align-items: flex-end; text-align: right; }
.align-center { justify-content: center; align-items: center; text-align: center; }
.align-center .body { margin-inline: auto; }
.kicker { font-family: var(--font-mono); font-size: 1cqw; letter-spacing: .1em; text-transform: uppercase; color: var(--tmuted, var(--muted)); }
.kicker.foot { margin-top: auto; }
.title { font-family: var(--font-display); font-weight: 700; line-height: .95; letter-spacing: -.025em; font-size: var(--title, 3.6cqw); text-wrap: balance; color: var(--theadline, var(--headline)); }
.tile-overlay .title { color: var(--theadline, inherit); }
.light { font-weight: 300; }
.font-serif .title, .font-serif .stat-value, .font-serif .quote { font-family: 'Fraunces', Georgia, serif; font-weight: 900; letter-spacing: -.01em; }
.font-elegant .title, .font-elegant .quote { font-family: 'Cormorant', Georgia, serif; font-weight: 700; letter-spacing: 0; }
.font-tech .title, .font-tech .stat-value { font-family: 'Syne', var(--font-display); font-weight: 800; letter-spacing: -.01em; }
.font-tech .kicker, .font-tech .body { font-family: 'Space Mono', var(--font-mono); }
.font-futuristic .title { font-family: 'Chakra Petch', var(--font-display); font-weight: 700; letter-spacing: 0; }
.quote { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-weight: 400; line-height: 1.1; letter-spacing: -.01em; font-size: var(--title, 3.6cqw); text-wrap: balance; color: var(--theadline, var(--headline)); }
.cite { font-family: var(--font-mono); font-size: 1cqw; letter-spacing: .1em; text-transform: uppercase; color: var(--tmuted, var(--muted)); margin-top: calc(6 * var(--px)); }
.size-s { --title: 2.4cqw; } .size-m { --title: 3.6cqw; } .size-l { --title: 5cqw; } .size-xl { --title: 7.2cqw; }
.body { font-size: 1.25cqw; line-height: 1.45; max-width: 38ch; color: var(--tmuted, var(--muted)); }
.size-l .body, .size-xl .body { font-size: 1.45cqw; }
.accent { color: var(--taccent, var(--accent)); }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: 8.5cqw; line-height: .88; letter-spacing: -.045em; color: var(--theadline, var(--headline)); }
.size-s .stat-value { font-size: 5cqw; } .size-l .stat-value { font-size: 11cqw; } .size-xl .stat-value { font-size: 14cqw; }
.stat-label { font-size: 1.25cqw; color: var(--tmuted, var(--muted)); max-width: 30ch; }
.list { list-style: none; margin: 0; padding: 0; width: 100%; }
.list li { font-size: 1.35cqw; line-height: 1.35; padding: calc(10 * var(--px)) 0; border-top: 1px solid var(--tmuted, var(--line)); }
.list li:first-child { border-top: 0; }
.tile-html { position: absolute; inset: 0; z-index: 2; padding: calc(var(--tpad, 36) * var(--px)); }

/* overlays on media */
.tile-overlay { color: #FFF4EA; --tmuted: rgba(255,244,234,.78); }
.tile-overlay.scrim-bottom { background: linear-gradient(to top, rgba(0,0,0,.62), rgba(0,0,0,0) 58%); }
.tile-overlay.scrim-top { background: linear-gradient(to bottom, rgba(0,0,0,.58), rgba(0,0,0,0) 55%); }
.tile-overlay.scrim-full { background: rgba(0,0,0,.35); }
.tile-overlay.scrim-none { background: none; }
.tile-overlay.scrim-none .title, .tile-overlay.scrim-none .kicker, .tile-overlay.scrim-none .body { text-shadow: 0 2px 20px rgba(10,8,5,.5); }
.tile-overlay.scrim-dark { background: rgba(10,8,5,.75); }
.tile.has-border::before { content: ""; position: absolute; inset: 0; z-index: 4; border: calc(3 * var(--px)) solid var(--border-color, #FFF4EA); border-radius: inherit; pointer-events: none; }
/* palette strip */
.tile-palette { position: absolute; inset: 0; display: flex; }
.tile-palette.dir-column { flex-direction: column; }
.swatch { flex: 1; position: relative; min-width: 0; min-height: 0; }
.swatch span { position: absolute; left: calc(14 * var(--px)); bottom: calc(12 * var(--px)); font-size: .8cqw; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.dir-column .swatch span { bottom: auto; top: 50%; transform: translateY(-50%); }
.deco { position: absolute; inset: 0; z-index: 24; pointer-events: none; --px: calc(100cqw / var(--dw, 1920)); }
/* chrome (brand header bar + wordmark) */
.chrome { position: absolute; left: calc(40 * var(--px)); right: calc(40 * var(--px)); z-index: 30; display: flex; justify-content: space-between; align-items: center; font-size: .78cqw; letter-spacing: .15em; text-transform: uppercase; color: var(--ink); opacity: .82; pointer-events: none; }
.chrome-top { top: calc(26 * var(--px)); }
.chrome-bottom { bottom: calc(26 * var(--px)); }
.chrome-top span:nth-child(2) { position: absolute; left: 50%; transform: translateX(-50%); }
.chrome-mark { display: inline-flex; align-items: center; gap: calc(8 * var(--px)); font-family: var(--font-body); font-weight: 500; letter-spacing: .06em; }
.chrome-mark .dot { width: calc(9 * var(--px)); height: calc(9 * var(--px)); border-radius: 50%; background: #F26157; display: inline-block; }
.frame.has-chrome .canvas { --chrome-h: 46; padding-top: calc((var(--padding) + var(--chrome-h)) * var(--px)); padding-bottom: calc((var(--padding) + var(--chrome-h)) * var(--px)); }
/* grain */
.grain { position: absolute; inset: 0; z-index: 25; pointer-events: none; filter: url(#bento-grain); mix-blend-mode: soft-light; }
.tile-caption {
  position: absolute; z-index: 3; font: 500 .9cqw/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase;
  color: #FFF4EA; text-shadow: 0 1px 8px rgba(0,0,0,.5); padding: 0; pointer-events: none;
}
.tile-caption.bottom-left { left: calc(18 * var(--px)); bottom: calc(16 * var(--px)); }
.tile-caption.bottom-right { right: calc(18 * var(--px)); bottom: calc(16 * var(--px)); }
.tile-caption.top-left { left: calc(18 * var(--px)); top: calc(16 * var(--px)); }
.tile-caption.top-right { right: calc(18 * var(--px)); top: calc(16 * var(--px)); }

/* ---------- enter animation ---------- */
.slide.enter-rise { --enter-name: bento-rise; }
.slide.enter-fade { --enter-name: bento-fade; }
.slide.enter-scale { --enter-name: bento-scale; }
.slide.enter-wipe { --enter-name: bento-wipe; }
.slide.enter-none { --enter-name: none; }
.slide.is-active .tile {
  animation-name: var(--enter-name, none);
  animation-duration: var(--enter-d, .7s);
  animation-timing-function: cubic-bezier(.2, .7, .2, 1);
  animation-fill-mode: both;
  animation-delay: calc(var(--i) * var(--enter-s, 80ms));
}
@keyframes bento-rise { from { opacity: 0; transform: translateY(calc(22 * var(--px))) translateZ(0); } to { opacity: 1; transform: translateY(0) translateZ(0); } }
@keyframes bento-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bento-scale { from { opacity: 0; transform: scale(.94) translateZ(0); } to { opacity: 1; transform: scale(1) translateZ(0); } }
@keyframes bento-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .slide .tile { animation: none !important; } }

/* ---------- hud / notes / help / toast ---------- */
.progress { position: absolute; top: 0; left: 0; height: 1px; width: 0; background: var(--ink); opacity: .55; transition: width .35s ease; }
.hud {
  position: absolute; left: var(--stage-pad); right: var(--stage-pad); bottom: 8px; display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); pointer-events: none;
}
.deck.hide-hud .hud, .deck.hide-hud .progress, .stage:fullscreen .hud { display: none; }
.notes {
  display: none; position: absolute; left: var(--stage-pad); right: var(--stage-pad); bottom: 30px; padding: 12px 0 0;
  border-top: 1px solid var(--line); font-size: 12px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; background: var(--bg); max-height: 30vh; overflow: auto;
}
.deck.show-notes .notes { display: block; }
.help { display: none; position: absolute; inset: 0; z-index: 50; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); }
.help.open { display: grid; }
.help-body { min-width: 340px; font-size: 13px; }
.help-body h2 { font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: -.03em; margin: 0 0 14px; }
.help-row { display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); }
.help-row .mono { color: var(--muted); font-size: 12px; }
.toast { position: absolute; left: 50%; bottom: 40px; transform: translate(-50%, 8px); font-size: 11px; letter-spacing: .06em; color: var(--ink); opacity: 0; transition: .25s; pointer-events: none; border-bottom: 1px solid var(--ink); padding-bottom: 4px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- edit panel (flat, hairlines only) ---------- */
.panel { display: none; min-width: 0; overflow: auto; border-left: 1px solid var(--line); padding: 18px 18px 40px; font-size: 12px; line-height: 1.4; background: var(--bg); }
.deck.is-editing .panel { display: block; }
.p-top { padding-bottom: 14px; }
.p-title { display: flex; justify-content: space-between; align-items: baseline; }
.p-title strong { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.p-title .mono { color: var(--muted); font-size: 10px; }
.p-actions { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.p-btn { background: none; border: 0; padding: 0 0 2px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line); color: var(--ink); }
.p-btn:hover { border-bottom-color: var(--ink); }
.p-btn.is-on { border-bottom: 2px solid var(--accent); }
.p-btn.is-danger { color: var(--accent); }
.p-section { border-top: 1px solid var(--line); padding: 14px 0; }
.p-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.p-head span { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.p-head small { color: var(--muted); font-size: 10px; font-family: var(--font-mono); }
.p-chips { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.p-inline { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--muted); }
.p-inline > span { min-width: 56px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.p-row { display: block; margin: 8px 0; }
.p-row > span { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.p-input, .p-select, textarea.p-input { width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 5px 0; color: var(--ink); outline: none; border-radius: 0; }
.p-input:focus, .p-select:focus { border-bottom-color: var(--ink); }
.p-select option { color: #191919; }
textarea.p-input { resize: vertical; line-height: 1.4; }
.p-file { display: block; margin: 8px 0; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 11px; cursor: pointer; }
.p-file:hover { border-bottom-color: var(--ink); }
.p-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.p-check { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink); }
.p-check .rec { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }
.p-prop { display: grid; gap: 4px; margin: 10px 0; }
.p-prop-head { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; }
.p-prop.is-track .p-prop-head span { color: var(--accent); }
.p-prop output { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.p-prop input[type=range], .p-scrub { width: 100%; height: 2px; margin: 0; accent-color: var(--ink); }
.key { width: 8px; height: 8px; padding: 0; border: 1px solid var(--muted); background: transparent; transform: rotate(45deg); }
.key.is-keyed { background: var(--accent); border-color: var(--accent); }
.p-transport { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.p-play { width: 28px; height: 28px; border: 1px solid var(--ink); background: transparent; font-size: 10px; }
.p-tc { font-size: 10px; color: var(--muted); }
.p-tracks { margin-top: 10px; }
.p-track { display: grid; grid-template-columns: 118px 1fr 18px; align-items: center; height: 26px; border-top: 1px solid var(--line); }
.p-track.is-track .p-track-label { color: var(--accent); }
.p-track-label { background: none; border: 0; padding: 0; text-align: left; font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-lane { position: relative; height: 100%; cursor: crosshair; }
.p-lane::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.p-key { position: absolute; top: 50%; width: 7px; height: 7px; background: var(--ink); transform: translate(-50%, -50%) rotate(45deg); cursor: pointer; }
.p-playhead { position: absolute; top: 4px; bottom: 4px; width: 1px; background: var(--accent); pointer-events: none; }
.p-track-clear { background: none; border: 0; color: var(--muted); padding: 0; }
.p-hint { color: var(--muted); font-size: 10px; line-height: 1.5; margin: 8px 0 0; }

/* ---------- print (one slide per page) ---------- */
@media print {
  html, body { overflow: visible; height: auto; }
  .deck { position: static; display: block; }
  .stage { display: block; padding: 0; }
  .slide { display: block !important; width: 100vw; height: 100vh; break-after: page; page-break-after: always; container-type: size; }
  .frame { width: 100vw !important; height: 100vh; }
  .panel, .hud, .progress, .help, .toast, .notes, .divider, .tile-index { display: none !important; }
  .grain { display: none; }
  .tile { animation: none !important; opacity: 1 !important; transform: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
