/* Cycles, Explained — muted pastel light scheme (matches almanac/): cream ground, bold dark text, muted data colours,
   dark outlines. Plum = cool/below, ochre = warm/above; no blue hues. */
:root {
  --ink: #F0EAD4; --ink2: #E9DFC6; --olive: #65743A; --glass: rgba(249, 248, 231, 0.93); --line: rgba(51, 15, 10, 0.5);
  --text: #330F0A; --text2: #394F49; --muted: #5E5640;
  --now: #7A4A1E; --sky: #66BAA2; --sun: #D08C65; --life: #6E7C37; --moon: #6E5A7D; --ocean: #B38FCF;
  --warm: #B08F65; --cool: #A182AB; --mid: #AFAAA3; --ice: #C9C3BA;
  --sci: #4A7667; --folk: #C9A86A; --fringe: #A96DA1; --tk: #895777;
  --font: "JetBrains Mono", ui-monospace, Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--ink); color: var(--text); font: 500 16px/1.55 var(--font); }
[hidden] { display: none !important; }
h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.05; margin: 4px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 22px; line-height: 1.2; margin: 2px 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--text); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 8px 0; }
a { color: var(--text); text-decoration-color: var(--olive); }
b { color: var(--text); }
.eyebrow, .step { color: var(--now); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin: 0; }
.lead { font-size: 18px; color: var(--text2); }
.small { font-size: 13px; color: var(--muted); }
.note { font-size: 14px; color: var(--text2); border-left: 3px solid var(--line); padding-left: 10px; }
.howto { padding-left: 18px; color: var(--text2); }

/* App frame: top bar, picture (main), text panel (secondary, right; bottom on phones) */
#app { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
#bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top, 0px));
  background: var(--ink2); border-bottom: 1px solid var(--line); }
#viewTitle { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn { display: inline-flex; align-items: center; gap: 4px; color: var(--text); text-decoration: none; background: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; font-size: 14px; }
.btn:hover { border-color: var(--now); }
.btn.nav { font-size: 20px; line-height: 1; padding: 3px 12px 6px; }
#work { display: flex; min-height: 0; }
#stageWrap { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--ink); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage:active { cursor: grabbing; }
#grip { flex: 0 0 6px; cursor: col-resize; background: var(--olive); touch-action: none; }
#grip:hover { background: var(--now); }
#info { flex: 0 0 var(--info-w, 400px); width: var(--info-w, 400px); overflow: auto; background: var(--ink2); }
.info-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 8px 12px 8px 20px;
  background: var(--ink2); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.info-bar span:first-child { flex: 1; }
.info-bar button { text-transform: none; letter-spacing: 0; padding: 3px 9px; }
#tour .panel { padding: 16px 20px 8px; }
.info-foot { display: flex; justify-content: space-between; gap: 8px; padding: 8px 20px 24px; }
.info-foot .btn { max-width: 48%; font-size: 13px; }
body.no-info #info, body.no-info #grip { display: none; }

/* On the picture: tools (top right), key (top left), controls (bottom left), hint */
#tools { position: absolute; top: 12px; right: 12px; z-index: 3; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 70%; }
#tools button { background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); min-width: 36px; }
.card { position: absolute; left: 12px; z-index: 3; width: min(340px, 42%); overflow: auto; background: var(--glass); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 12px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 8px 30px rgba(51,15,10,.15); }
.card summary { cursor: pointer; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--now); padding: 4px 0; }
#keyCard { top: 12px; max-height: calc(50% - 18px); }
#ctlCard { bottom: 12px; max-height: calc(50% - 18px); }
#keyBody .key { margin: 0 0 6px; padding: 0; border: 0; background: none; }
#keyBody .key h3 { display: none; }
#ctlBody .controls { margin: 4px 0 8px; }
#ctlBody .story { font-size: 14px; margin: 8px 0 6px; }
#hint { position: absolute; right: 12px; bottom: 12px; z-index: 2; margin: 0; max-width: min(320px, 50%); font-size: 12px; color: var(--text2);
  background: var(--glass); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; pointer-events: none; transition: opacity .6s; }
#hint.gone { opacity: 0; }

/* Full screen: the picture or the text (API, with a CSS fallback class) */
#stageWrap:fullscreen, #stageWrap.max { position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; }
#info:fullscreen, #info.max { position: fixed; inset: 0; z-index: 40; width: 100%; font-size: 18px; }
#info:fullscreen #tour, #info.max #tour, #info:fullscreen .info-foot, #info.max .info-foot { max-width: 760px; margin: 0 auto; }
#info:fullscreen h2, #info.max h2 { font-size: 30px; }
#info:fullscreen .key ul, #info.max .key ul, #info:fullscreen .note, #info.max .note { font-size: 16px; }
:fullscreen::backdrop { background: var(--ink); }
button.on, .btn.on { border-color: var(--now); color: var(--text); }

/* Home: the menu of views over a slowly turning clock */
#home { position: fixed; inset: 0; z-index: 20; overflow: auto; background: linear-gradient(180deg, rgba(240,234,212,.55), rgba(240,234,212,.94) 60%); }
body:not(.home) #home { display: none; }
body.home #bar, body.home #info, body.home #grip, body.home #tools, body.home .card, body.home #hint { display: none; }
.home-in { max-width: 1180px; margin: 0 auto; padding: max(6vh, env(safe-area-inset-top, 0px)) 16px max(6vh, env(safe-area-inset-bottom, 0px)); }
.hero { max-width: 760px; }
.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 24px; }
.tile { display: flex; flex-direction: column; color: var(--text); text-decoration: none; background: var(--glass); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; transition: border-color .2s, transform .2s; }
.tile:hover, .tile:focus-visible { border-color: var(--now); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .tile, .tile:hover { transition: none; transform: none; } }
.tile img, .tile .noimg { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--ink); }
.tile-body { display: grid; gap: 4px; padding: 10px 14px 14px; }
.tile-head { display: flex; align-items: baseline; gap: 8px; }
.tile .num { color: var(--now); font-weight: 700; font-size: 14px; }
.tile .name { font-size: 16px; line-height: 1.25; }
.tile .sub { font-size: 14px; color: var(--text2); }
.tile .badges .badge { font-size: 11px; }

body.no-webgl #stageWrap, body.no-webgl #grip { display: none; }
body.no-webgl #info { flex: 1; width: auto; }

/* Keys */
.key { background: #EFF0E1; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 8px; margin: 12px 0; }
.key ul { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--text2); }
.key li { margin: 5px 0; line-height: 1.4; }
.sw { display: inline-block; vertical-align: -2px; margin-right: 4px; }
.sw.ring { width: 16px; height: 16px; border-radius: 50%; border: 3px solid currentColor; }
.sw.ring.sky { color: var(--sky); } .sw.ring.sun { color: var(--sun); } .sw.ring.life { color: var(--life); }
.sw.ring.moon { color: var(--moon); } .sw.ring.ocean { color: var(--ocean); }
.sw.bead { width: 12px; height: 12px; border-radius: 50%; background: #330F0A; }
.sw.line { width: 18px; height: 3px; border-radius: 2px; vertical-align: 3px; }
.sw.line.now { background: var(--now); box-shadow: 0 0 6px var(--now); }
.sw.dot { width: 10px; height: 10px; border-radius: 50%; }
.sw.dot.hi { background: #65452F; } .sw.dot.lo { background: #E8D9BA; border: 1px solid var(--line); }
.sw.arrow { width: 18px; height: 4px; background: var(--now); clip-path: polygon(0 30%, 70% 30%, 70% 0, 100% 50%, 70% 100%, 70% 70%, 0 70%); height: 10px; }
.sw.bar { width: 10px; height: 14px; border-radius: 2px; }
.sw.bar.ice { background: var(--ice); } .sw.bar.warm { background: var(--warm); } .sw.bar.cool { background: var(--cool); }
.sw.bar.mid { background: var(--mid); } .sw.bar.life { background: var(--life); } .sw.bar.sky { background: var(--sky); }
.sw.bar.sci { background: var(--sci); } .sw.bar.folk { background: var(--folk); } .sw.bar.fringe { background: var(--fringe); }
.sw.plane { width: 22px; height: 10px; border: 1px solid rgba(51,15,10,.7); background: rgba(57,79,73,.16); border-radius: 2px; }
.sw.arch { width: 18px; height: 10px; border: 3px solid var(--sun); border-bottom: none; border-radius: 10px 10px 0 0; }
.sw.aurora { width: 18px; height: 14px; background: linear-gradient(#6BAD8F, rgba(158,107,158,0)); border-radius: 2px; }
.sw.grad { width: 30px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #7B5B85, #D08C65, #B08F65, #65452F); }
.sw.link { width: 26px; height: 0; border-top: 3px solid; vertical-align: 4px; }
.sw.link.a { border-color: #330F0A; } .sw.link.b { border-color: rgba(57,79,73,.7); border-top-width: 2px; }
.sw.link.c { border-color: var(--mid); border-top-style: dotted; } .sw.link.tk { border-color: var(--tk); border-top-style: dashed; }

/* Evidence badges */
.sure { margin-top: 14px; font-size: 14px; color: var(--text2); border-top: 1px solid var(--line); padding-top: 10px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; margin-right: 4px; color: #330F0A; border: 1px solid #330F0A; }
.badge.a { background: #B8CDA1; } .badge.b { background: #B9D0BC; } .badge.c { background: #D6C08E; }
.badge.d { background: #D4B49D; } .badge.tk { background: #DEBACF; }

/* Controls */
.controls { margin: 12px 0; display: grid; gap: 8px; font-size: 14px; color: var(--text2); }
.controls label { display: grid; gap: 4px; }
input[type="range"] { width: 100%; accent-color: var(--now); }
select, button { font: inherit; font-size: 14px; color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
button { cursor: pointer; }
button:hover, button.on { border-color: var(--now); color: var(--text); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.readout { font-variant-numeric: tabular-nums; color: var(--text); }
canvas.mini { width: 100%; height: auto; background: #F9F8E7; border: 1px solid var(--line); border-radius: 8px; }
.names, .claims { font-size: 14px; color: var(--text2); padding-left: 18px; }
.names li, .claims li { margin: 3px 0; }
.story { font-size: 15px; color: var(--text); min-height: 2.5em; }
ol { padding-left: 20px; color: var(--text2); font-size: 14px; }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 15px; }
.glossary dt { font-weight: 600; color: var(--text); }
.glossary dd { margin: 0; color: var(--text2); }

.tip { position: absolute; z-index: 10; pointer-events: none; max-width: 300px; background: rgba(249, 248, 231, 0.97); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(51,15,10,.2); }
.tip b { color: var(--now); }

@media (max-width: 760px) {
  .lbl { display: none; }
  #bar { padding: 6px 10px; }
  #work { flex-direction: column; }
  #grip { display: none; }
  #info { flex: 0 0 44%; width: auto; border-top: 1px solid var(--line); }
  #tools { top: 8px; right: 8px; gap: 4px; }
  .card { left: 8px; width: min(320px, calc(100% - 16px)); }
  #keyCard { top: 52px; }
  #ctlCard { bottom: 8px; }
  #hint { display: none; }
  .glossary { grid-template-columns: 1fr; }
  .menu { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile .sub, .tile .badges { display: none; }
}
@media (max-width: 420px) { .menu { grid-template-columns: 1fr; } .tile .sub { display: block; } }

/* Credit footer */
.credit { text-align: center; font-size: 12.5px; font-weight: 600; padding: 18px 16px 28px; }
.credit a { color: inherit; font-weight: 800; }
#info .credit { font-size: 11.5px; padding: 4px 20px 24px; }
