/* ============================================================
   OCKHAM LAZOR — single-screen site
   Change the look here: palette, fonts, sizes are all variables.
   ============================================================ */
:root {
  /* Earth-tone palette */
  --umber:  #2a1d15;   /* page background */
  --soil:   #3b2a1e;   /* panels */
  --clay:   #a4583a;
  --ochre:  #c8913a;   /* accent / active */
  --sage:   #8a9a6b;
  --bone:   #ece3d0;   /* text */
  --forest: #4a8452;   /* header title — forest green tuned for contrast on umber (#2f5d34 is the deep version) */
  --logo-color: var(--forest);
  --bone-dim: rgba(236, 227, 208, .55);
  --line:   rgba(236, 227, 208, .22);

  --font-display: Futura, "Futura PT", "Futura Medium", "Jost", "Century Gothic", sans-serif;
  --font-body: "Jost", Futura, "Futura PT", system-ui, sans-serif;

  --header-align: center;            /* center | flex-start  (or use body.align-left) */
  --logo-size: clamp(1.25rem, 2.2vw + 1.6vh, 2.6rem);
  --logo-spacing: .32em;

  --pad: clamp(10px, 2vw, 28px);
  --gap: clamp(10px, 1.6vw, 24px);
  --btn: clamp(44px, 6.2vh, 64px);   /* song button size */
  --player-h: 44px;
  --ar-w: 16; --ar-h: 9;             /* stage aspect ratio */
  --fade: 1.6s;                      /* default crossfade */
}
body.align-left { --header-align: flex-start; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  height: 100vh; height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--umber);
  background-image: radial-gradient(120% 80% at 50% 0%, #3a2819 0%, var(--umber) 60%, #1e140e 100%);
  color: var(--bone);
  font-family: var(--font-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

/* ---------- Header ---------- */
.site-header {
  display: flex; justify-content: var(--header-align); align-items: center;
  padding: clamp(10px, 2.2vh, 26px) var(--pad) clamp(8px, 1.6vh, 18px);
}
.logo {
  margin: 0; font-family: var(--font-display); font-weight: 500;
  font-size: var(--logo-size); letter-spacing: var(--logo-spacing);
  line-height: 1; text-transform: uppercase; color: var(--logo-color);
  /* letter-spacing adds trailing space; compensate so centering is true */
  margin-right: calc(var(--logo-spacing) * -1);
}
body.align-left .logo { margin-right: 0; }
.logo-img[hidden] { display: none; }
.logo-img { display: block; height: calc(var(--logo-size) * 1.4); width: auto; }
.logo.has-image .logo-text { display: none; }
.rule { height: 1px; background: var(--line); width: 100%; }

/* ---------- Main layout ---------- */
.main {
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap) var(--pad);
}
.songs {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: clamp(10px, 2.2vh, 22px);
  padding-bottom: var(--player-h);    /* centre against the stage, not the player */
}
.song-btn {
  position: relative; text-decoration: none;
  width: var(--btn); height: var(--btn); padding: 0;
  border-radius: 50%; border: 1px solid var(--line);
  background: rgba(59, 42, 30, .55);
  display: grid; place-items: center; cursor: pointer;
  transition: border-color .3s, background .3s, transform .3s;
}
.song-btn img { width: 62%; height: 62%; object-fit: contain; opacity: .82; transition: opacity .3s; pointer-events: none; }
.song-btn:hover, .song-btn:focus-visible { border-color: var(--ochre); outline: none; }
.song-btn.is-link { border-style: dashed; }   /* non-song buttons (e.g. dice -> craps page) */
.song-btn:hover img { opacity: 1; }
.song-btn[aria-pressed="true"] { border-color: var(--ochre); background: rgba(200, 145, 58, .14); box-shadow: 0 0 0 3px rgba(200,145,58,.12); }
.song-btn[aria-pressed="true"] img { opacity: 1; }

/* Stage box: sized to the largest 16:9 that fits (width AND height), via container units */
.stage-wrap { min-height: 0; min-width: 0; container-type: size; display: grid; place-items: center; }
.deck {
  width: min(100cqw, (100cqh - var(--player-h)) * var(--ar-w) / var(--ar-h));
  display: flex; flex-direction: column;
}
.stage {
  position: relative; width: 100%; aspect-ratio: var(--ar-w) / var(--ar-h);
  overflow: hidden; background: var(--soil);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  isolation: isolate;
}
.layer { position: absolute; inset: 0; opacity: 0; transition: opacity var(--fade) ease; }
.layer.on { opacity: 1; z-index: 1; }
.media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: 50% 50%; will-change: transform; }

/* Per-scene animations. JS sets --dur (scene length) and --delay (negative = already into scene, keeps seeks in sync) */
.media[class*="anim-"] { animation-duration: var(--dur, 10s); animation-delay: var(--delay, 0s); animation-timing-function: linear; animation-fill-mode: both; }
.anim-kenburns-in  { animation-name: kbIn; }
.anim-kenburns-out { animation-name: kbOut; }
.anim-drift-left   { animation-name: driftL; }
.anim-drift-right  { animation-name: driftR; }
.anim-breathe      { animation-name: breathe; animation-iteration-count: infinite; animation-duration: 6s !important; animation-timing-function: ease-in-out !important; }
@keyframes kbIn   { from { transform: scale(1.02); } to { transform: scale(1.16) translate(-1.5%, -1%); } }
@keyframes kbOut  { from { transform: scale(1.16) translate(1%, 1%); } to { transform: scale(1.02); } }
@keyframes driftL { from { transform: scale(1.12) translateX(3%); } to { transform: scale(1.12) translateX(-3%); } }
@keyframes driftR { from { transform: scale(1.12) translateX(-3%); } to { transform: scale(1.12) translateX(3%); } }
/* gentle moves for the original drawings (never crop much of the art) */
.anim-soft-in    { animation-name: softIn; }
.anim-soft-out   { animation-name: softOut; }
.anim-soft-drift { animation-name: softDrift; }
@keyframes softIn    { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes softOut   { from { transform: scale(1.06); } to { transform: scale(1); } }
@keyframes softDrift { from { transform: scale(1.04) translateX(-1%); } to { transform: scale(1.04) translateX(1%); } }
/* contained art: the whole sheet, centred over a blurred, paper-toned copy of itself */
.media.art { background: #cdbb98; overflow: hidden; }
.art-bg { position: absolute; inset: -8%; width: 116%; height: 116%; object-fit: cover; filter: blur(22px) saturate(.75) brightness(.72); opacity: .9; }
.art-fg { position: absolute; inset: 3% 3%; width: 94%; height: 94%; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(20,12,8,.45)); }
@keyframes breathe { 0%,100% { transform: scale(1.03); } 50% { transform: scale(1.08); } }
.stage.paused .media { animation-play-state: paused; }

/* Effects overlays, toggled by cue "fx" list -> classes on .stage */
.fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s ease; z-index: 3; }
.fx-vignette { background: radial-gradient(ellipse at center, transparent 45%, rgba(20, 12, 8, .75) 100%); }
.fx-grain {
  inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .95  0 0 0 0 .85  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay; animation: grain 0.9s steps(6) infinite;
}
.stage.has-grain .fx-grain { opacity: .35; }
.stage.has-vignette .fx-vignette { opacity: 1; }
.stage.has-flicker .layer.on { animation: flicker 4.5s infinite; }
@keyframes grain { 0%{transform:translate(0,0)} 20%{transform:translate(-4%,3%)} 40%{transform:translate(3%,-5%)} 60%{transform:translate(-2%,4%)} 80%{transform:translate(5%,1%)} 100%{transform:translate(0,0)} }
@keyframes flicker { 0%,100%{filter:brightness(1)} 7%{filter:brightness(.88)} 8%{filter:brightness(1.04)} 9%{filter:brightness(.94)} 52%{filter:brightness(1)} 53%{filter:brightness(.9)} 55%{filter:brightness(1.02)} }
.stage.paused .fx-grain, .stage.paused .layer.on { animation-play-state: paused; }

.caption {
  position: absolute; left: 0; right: 0; bottom: 7%; z-index: 4; text-align: center;
  font-family: var(--font-display); letter-spacing: .28em; text-transform: uppercase;
  font-size: clamp(.68rem, 1.1vw + .3rem, 1.05rem); color: var(--bone);
  text-shadow: 0 2px 12px rgba(0,0,0,.7);
  opacity: 0; transform: translateY(6px); transition: opacity 1s ease, transform 1s ease;
  padding: 0 6%;
}
.caption.on { opacity: .92; transform: none; }

/* Idle overlay: big quiet play prompt */
.stage-play {
  position: absolute; inset: 0; z-index: 6; border: 0; background: rgba(30, 20, 14, .25);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  cursor: pointer; color: var(--bone);
}
.stage.idle .stage-play { display: flex; }
.stage-play svg { width: clamp(52px, 5vw, 72px); height: clamp(52px, 5vw, 72px); fill: var(--bone); opacity: .9;
  border: 1px solid var(--bone-dim); border-radius: 50%; padding: clamp(14px, 1.4vw, 20px); padding-left: clamp(17px, 1.7vw, 24px); transition: transform .3s, border-color .3s; }
.stage-play:hover svg { transform: scale(1.06); border-color: var(--ochre); }
.stage-play span { font-size: .72rem; letter-spacing: .32em; text-transform: uppercase; color: var(--bone-dim); }

/* ---------- Player ---------- */
.player {
  height: var(--player-h); display: flex; align-items: center; gap: 14px; min-width: 0; overflow: hidden;
  padding: 0 2px; font-size: .78rem; letter-spacing: .12em;
}
.pp { width: 30px; height: 30px; flex: none; border: 1px solid var(--line); border-radius: 50%; background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0; }
.pp:hover { border-color: var(--ochre); }
.pp svg { width: 14px; height: 14px; fill: var(--bone); }
.pp .i-pause, .player.playing .pp .i-play { display: none; }
.player.playing .pp .i-pause { display: block; }
.time { flex: none; color: var(--bone-dim); font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.scrub {
  --pct: 0%;
  flex: 1; min-width: 40px; height: 18px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.scrub::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--ochre) var(--pct), var(--line) var(--pct)); }
.scrub::-moz-range-track { height: 2px; background: var(--line); }
.scrub::-moz-range-progress { height: 2px; background: var(--ochre); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4px; border-radius: 50%; background: var(--bone); border: 0; }
.scrub::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--bone); border: 0; }
.scrub:focus-visible { outline: 1px solid var(--ochre); outline-offset: 4px; }

/* ---------- Footer ---------- */
.site-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: clamp(6px, 1.4vh, 14px) var(--pad) max(clamp(8px, 1.6vh, 16px), env(safe-area-inset-bottom));
  border-top: 1px solid rgba(236, 227, 208, .08);
  font-size: .68rem; letter-spacing: .26em; text-transform: uppercase;
}
.social { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.social a { color: var(--bone-dim); text-decoration: none; transition: color .3s; }
.social a:hover, .social a:focus-visible { color: var(--ochre); outline: none; }
.copy { color: rgba(236, 227, 208, .32); font-size: inherit; letter-spacing: .2em; }

/* ---------- Narrow / portrait: buttons become a row under the stage ---------- */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1024px) {
  :root { --ar-w: 4; --ar-h: 5; --logo-spacing: .26em; --btn: clamp(44px, 7vh, 58px); }
  /* stack: stage + player, then the song row; the group is centred vertically */
  :root { --chrome-h: 300px; }        /* header + footer + song row + player + gaps (approx) */
  .main { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: clamp(12px, 2.6vh, 26px); }
  .stage-wrap { container-type: normal; width: 100%; flex: 0 1 auto; }
  .deck { width: min(100%, calc((100dvh - var(--chrome-h)) * var(--ar-w) / var(--ar-h))); }
  .songs { order: 2; flex-direction: row; padding-bottom: 0; gap: clamp(14px, 6vw, 28px); flex: none; }
  .player { gap: 10px; }
  .stage-wrap, .deck { min-width: 0; max-width: 100%; }
  .time { font-size: .72rem; }
  .site-footer { justify-content: center; }
  .copy { display: none; }
  .social { justify-content: center; gap: 6px 18px; }
}
/* Very short landscape screens (phones sideways) */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --btn: 40px; --player-h: 36px; }
  .site-header { padding-top: 6px; padding-bottom: 6px; }
  .copy { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .media[class*="anim-"], .fx-grain, .stage.has-flicker .layer.on { animation: none !important; }
}
