/* One Cat, Many Hands: the film and the wall. An atlas plate: one ink on one paper, with the
   paintings as the only colour. Dark theme turns the plate into a night atlas. */

:root {
  --paper: #dcd2bc;
  --paper-hi: #e6ddca;
  --ink: #2a2017;
  --ink-soft: #5e5040;
  --hair: rgba(42, 32, 23, 0.3);
  --accent: #9b2d20;
  --on-accent: #f4ecdc;
  --scrim: rgba(12, 9, 6, 0.62);
  --card: #efe6d2; /* title cards sit on the dim sets in either theme */
  --display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --display-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --body: "Alegreya Sans", "Gill Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #17130f;
    --paper-hi: #221c16;
    --ink: #e2d8c3;
    --ink-soft: #a89a84;
    --hair: rgba(226, 216, 195, 0.28);
    --accent: #e0765c;
    --on-accent: #17130f;
    --scrim: rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #17130f;
  --paper-hi: #221c16;
  --ink: #e2d8c3;
  --ink-soft: #a89a84;
  --hair: rgba(226, 216, 195, 0.28);
  --accent: #e0765c;
  --on-accent: #17130f;
  --scrim: rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--body);
}
body.in-film { overflow: hidden; }
body.in-film .explore { visibility: hidden; }

button {
  font: 500 15px/1 var(--body);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--ink); }
button:disabled { opacity: 0.35; cursor: default; border-color: var(--hair); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button.primary:hover { opacity: 0.88; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── the film ── */
.film {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--paper);
  transition: opacity 0.5s ease;
}
.film.leaving { opacity: 0; pointer-events: none; }
.film canvas { display: block; width: 100%; height: 100%; }
.film p { pointer-events: none; }

.opening {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font: italic 400 clamp(40px, 7.5vw, 92px)/1 var(--display);
  color: var(--ink);
  opacity: 0;
  text-wrap: balance;
}

.titlecard {
  position: absolute;
  left: clamp(20px, 6vw, 88px);
  right: 20px;
  bottom: calc(clamp(28px, 9vh, 96px) + env(safe-area-inset-bottom, 0px));
  margin: 0;
  color: var(--card);
  font: 400 clamp(20px, 2.3vw, 30px)/1.25 var(--display-sc);
  letter-spacing: 0.06em;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.75), 0 0 2px rgba(0, 0, 0, 0.6);
  opacity: 0;
}
.titlecard .rule {
  display: block;
  width: min(420px, 70%);
  height: 1px;
  margin-top: 10px;
  background: currentColor;
  opacity: 0.7;
  transform-origin: left;
  transform: scaleX(var(--rule, 0));
}

.titlecard .note {
  display: block;
  max-width: 44ch;
  margin-top: 12px;
  font: italic 400 clamp(15px, 1.45vw, 19px)/1.4 var(--display);
  letter-spacing: 0;
}
.titlecard .note:empty { display: none; }

/* ── the landing: title, the play lens over the globe, a way straight to the gallery ── */
.landing { position: absolute; inset: 0; pointer-events: none; }
.landing > * { pointer-events: auto; }
.landing-title {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(clamp(14px, 2.6vh, 30px) + env(safe-area-inset-top, 0px));
  margin: 0;
  text-align: center;
  font: italic 400 clamp(30px, 4.6vw, 56px)/1 var(--display);
  color: var(--ink);
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.lens {
  position: absolute;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.lens:hover { border: 0; }
.lens:focus-visible { outline: 2px solid var(--accent); outline-offset: 10px; }
.landing-sub {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(clamp(24px, 9vh, 96px) + env(safe-area-inset-bottom, 0px));
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  font: italic 400 clamp(15px, 1.6vw, 19px)/1.6 var(--display);
  transition: opacity 0.5s ease;
}
.landing-sub a { color: var(--ink); font: 400 15px/1.6 var(--body); }
.landing.pressed .landing-title, .landing.pressed .landing-sub { opacity: 0; }
.film.at-landing .film-controls { display: none; }

/* ── film controls: faint icons, always there, brighter on pointer movement ── */
.film-controls {
  position: absolute;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.32;
  transition: opacity 0.4s ease;
}
.film-controls.awake, .film-controls:focus-within, .film-controls:hover { opacity: 1; }
.film-controls .icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  backdrop-filter: blur(4px);
}
.film-controls .icon:hover { background: color-mix(in srgb, var(--paper) 95%, transparent); }
.film-controls svg { width: 22px; height: 22px; font-family: var(--body); font-weight: 700; }

/* ── explore: the wall ── */
.explore {
  max-width: 1280px;
  margin: 0 auto;
  padding-inline: max(16px, 4vw);
  padding-block: 44px 40px;
}
.ex-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 40px;
}
.ex-title { max-width: 62ch; }
h1 {
  margin: 0 0 8px;
  font: 400 clamp(36px, 5.2vw, 60px)/1 var(--display);
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.lede { margin: 0; color: var(--ink-soft); font-size: 16.5px; }
.ex-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.poses {
  display: inline-flex;
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: 2px;
  gap: 2px;
}
.poses button { border: 0; padding: 3px 7px; line-height: 0; }
.poses svg { width: 40px; height: 27px; display: block; }
button.with-icon { display: inline-flex; align-items: center; gap: 7px; }
button.with-icon svg { width: 18px; height: 18px; flex: none; }
button.icon-only { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; }
button.icon-only svg { width: 20px; height: 20px; }
.poses button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.ribbon { display: block; width: 100%; height: 44px; margin: 30px 0 18px; }

.wall {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(168px, calc(50% - 8px)), 1fr));
  gap: 26px 16px;
}
.wall li { min-width: 0; }
.cat {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  text-align: left;
  font: inherit;
  line-height: 1.3;
}
.cat:hover { border: 0; }
.thumb {
  display: block;
  aspect-ratio: 600 / 750;
  max-width: 100%;
  margin-bottom: 8px;
  outline: 1px solid var(--hair);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.thumb canvas { display: block; width: 100%; height: 100%; transition: opacity 0.4s ease; }
.thumb.pending canvas { opacity: 0; }
.thumb.pending { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { background: color-mix(in srgb, var(--ink) 12%, transparent); } }
.cat:hover .thumb, .cat:focus-visible .thumb { transform: translateY(-3px); box-shadow: 0 14px 26px -18px rgba(0, 0, 0, 0.6); }
.cat .when { font: 400 13px/1.3 var(--display-sc); letter-spacing: 0.05em; color: var(--ink-soft); }
.cat .name { font: italic 400 19px/1.2 var(--display); }
.cat.tribute { cursor: default; }
.cat.tribute:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cat .note { font-size: 14px; line-height: 1.35; color: var(--ink-soft); font-style: italic; }

.ex-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 48px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
  color: var(--ink-soft);
  font-size: 14px;
}
.ex-foot a { color: inherit; }

/* ── the sheet ── */
.sheet {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 3px;
  background: var(--paper-hi);
  color: var(--ink);
}
.sheet::backdrop { background: var(--scrim); }
.sheet-grid {
  display: grid;
  grid-template-columns: minmax(0, min(calc((100dvh - 110px) * 0.8), 560px)) minmax(0, 1fr);
  gap: 28px;
  padding: 20px;
}
.sheet-art { margin: 0; }
.sheet-art canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 750;
  background: #111;
}
.sheet-text { min-width: 0; display: flex; flex-direction: column; }
.sheet-nav { display: flex; gap: 8px; padding: 14px 20px 0; }
.sheet-nav button { padding: 7px 11px; font-size: 14px; }
.sheet-nav .close { margin-left: auto; }
.meta { margin: 0; font: 400 15px/1.3 var(--display-sc); letter-spacing: 0.05em; color: var(--accent); }
.sheet h2 { margin: 4px 0 2px; font: 400 clamp(30px, 3.4vw, 42px)/1.05 var(--display); text-wrap: balance; }
.after { margin: 0 0 16px; color: var(--ink-soft); font-style: italic; font-size: 15px; }
.player { display: flex; align-items: center; gap: 10px; }
.player button { width: 36px; height: 36px; padding: 0; font-size: 12px; flex: none; }
.player .speed { width: 44px; font-variant-numeric: tabular-nums; }
.scrub { flex: 1; min-width: 0; accent-color: var(--accent); }
.time { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.phase { margin: 10px 0 0; font: italic 19px/1.3 var(--display); min-height: 1.3em; }
.caption { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
.caption:empty { display: none; }
.blurb { margin: 14px 0 10px; max-width: 62ch; }
details { border-top: 1px solid var(--hair); padding-top: 8px; }
summary { cursor: pointer; color: var(--ink-soft); font-size: 14px; }
details ul { margin: 8px 0 4px; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
details li { margin: 3px 0; }
.sheet-cat { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: auto; padding-top: 18px; }

@media (max-width: 820px) {
  .sheet-grid { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 14px; }
  .sheet-art canvas { max-width: min(100%, calc((100dvh - 170px) * 0.8)); margin: 0 auto; }
  .sheet-nav { padding: 12px 14px 0; }
}
@media (max-width: 600px) {
  .titlecard .when, .titlecard .where { display: block; }
  .titlecard .sep { display: none; }
  .explore { padding-block: 28px 32px; }
  .cat .name { font-size: 18px; }
  .cat .when { font-size: 12px; }
}
