/* Slop: a photocopied noticeboard look, the opposite of the posters it shows. */

:root {
  --paper: #f2eee4;
  --ink: #1c1b18;
  --ink-soft: #4a4740;
  --pencil: #8b867b;
  --red: #d2241c;
  --rule: rgba(28, 27, 24, 0.14);
  --note-bg: #f6e27c;
  --note-ink: #1c1b18;
  --grain-opacity: 0.08;

  --font-display: "Archivo Black", "Arial Black", sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-hand: "Permanent Marker", "Comic Sans MS", cursive;

  color-scheme: light;
}

/* Dark mode is a blackboard. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1e2622;
    --ink: #ebe7da;
    --ink-soft: #bdb9ad;
    --pencil: #7f877f;
    --red: #ff5d50;
    --rule: rgba(235, 231, 218, 0.16);
    --grain-opacity: 0.12;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1e2622;
  --ink: #ebe7da;
  --ink-soft: #bdb9ad;
  --pencil: #7f877f;
  --red: #ff5d50;
  --rule: rgba(235, 231, 218, 0.16);
  --grain-opacity: 0.12;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html.locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--font-body);
  overflow-x: hidden;
}

/* Photocopy grain over everything, never blocking clicks. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 3px; }

button { font: inherit; color: inherit; }

main, .masthead, .colophon {
  width: min(100% - 32px, 1080px);
  margin-inline: auto;
}

/* Masthead: the letters drop in like stamped type when the page loads. */

.masthead {
  padding: 12vh 0 6vh;
  border-bottom: 3px solid var(--ink);
}
.masthead h1 {
  margin: 0;
  font: 400 clamp(5rem, 22vw, 13rem)/0.85 var(--font-display);
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.masthead h1 span {
  display: inline-block;
  animation: stamp 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.masthead h1 span:nth-child(2) { animation-delay: 0.09s; }
.masthead h1 span:nth-child(3) { animation-delay: 0.18s; }
.masthead h1 span:nth-child(4) { animation-delay: 0.27s; }
.deck {
  max-width: 34ch;
  margin: 1.2rem 0 0;
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  line-height: 1.4;
  animation: rise 0.8s ease-out 0.55s both;
}

@keyframes stamp {
  from { opacity: 0; transform: translateY(-0.35em) rotate(-10deg) scale(1.15); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
}

/* Scroll-in. Only applies when JS is running, so nothing stays hidden without it.
   The final state uses "none" so no transformed ancestor traps fixed children. */

.js .reveal {
  opacity: 0;
  translate: 0 28px;
  transition: opacity 0.7s ease, translate 0.8s cubic-bezier(0.2, 0.7, 0.2, 1), rotate 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.js .reveal.reveal-side { translate: -70px 0; rotate: -3deg; }
.js .flip .reveal.reveal-side { translate: 70px 0; rotate: 3deg; }
.js .reveal.reveal-build { translate: 36px 0; }
.js .flip .reveal.reveal-build { translate: -36px 0; }
.js .reveal.in { opacity: 1; translate: none; rotate: none; }

@media (prefers-reduced-motion: reduce) {
  .masthead h1 span, .deck { animation: none; }
  .js .reveal, .js .reveal.reveal-side, .js .reveal.reveal-build { opacity: 1; translate: none; rotate: none; transition: none; }
}

/* Commentary bookends */

.commentary {
  max-width: 62ch;
  margin: 12vh auto;
  font-size: 1.15rem;
}
.commentary p { margin: 0 0 1em; }

/* Placeholder copy is outlined so it can't be mistaken for final text. */
.placeholder {
  position: relative;
  outline: 2px dashed var(--pencil);
  outline-offset: 12px;
}
.placeholder::before {
  content: "Placeholder";
  position: absolute;
  top: -26px;
  left: 0;
  padding: 0 6px;
  background: var(--paper);
  color: var(--pencil);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Poster sections */

.activity, .exhibit {
  margin: 14vh 0;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.activity h2, .exhibit h2 {
  margin: 0 0 1rem;
  font: 400 clamp(2rem, 6vw, 3.4rem)/1 var(--font-display);
  text-transform: uppercase;
}
.intro {
  max-width: 62ch;
  margin: 1.2rem 0 2.2rem;
}
.activity .intro { margin: 2.2rem 0 2.5rem; }

/* Clip sideways so items waiting to slide in can't widen the page.
   "clip" (unlike "hidden") keeps the sticky side panel working. */
.workspace {
  display: grid;
  gap: 1.5rem;
  overflow-x: clip;
  overflow-clip-margin: 12px;
}
@media (min-width: 900px) {
  .workspace {
    grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
  }
  .flip .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 560px); }
  .flip .workspace .poster { order: 2; }
  .side {
    position: sticky;
    top: 2rem;
  }
}

.poster {
  position: relative;
  margin: 0;
  max-width: 560px;
  box-shadow: 0 1px 0 var(--rule), 6px 8px 0 rgba(0, 0, 0, 0.18);
  transform: rotate(-0.6deg);
}
.flip .poster { transform: rotate(0.6deg); }
.poster img {
  display: block;
  width: 100%;
  height: auto;
}
.poster-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* Observations: a hand-numbered list */

.obs {
  list-style: none;
  counter-reset: obs;
  margin: 0;
  padding: 0;
}
.obs li {
  counter-increment: obs;
  position: relative;
  margin-bottom: 1rem;
  padding: 0 0 1rem 2.8rem;
  border-bottom: 1px solid var(--rule);
}
.obs li:last-child { border-bottom: 0; }
.obs li::before {
  content: counter(obs);
  position: absolute;
  left: 0;
  top: -0.25rem;
  font: 400 1.7rem/1 var(--font-hand);
  color: var(--red);
}

/* Pins and rings sit on the poster, which is always light, so they keep
   fixed colors in both themes. */

.overlay {
  --mark-red: #d2241c;
  --mark-ink: #1c1b18;
  --mark-paper: #ffffff;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.overlay.revealed { cursor: default; }

.pin circle {
  fill: var(--mark-ink);
  stroke: var(--mark-paper);
  stroke-width: 4px;
}
.pin text {
  fill: var(--mark-paper);
  font-family: var(--font-body);
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}
.overlay.revealed .pins { pointer-events: none; }
.pin.hit circle { fill: var(--mark-red); }
.pin.miss { opacity: 0.45; }

.ring path {
  fill: none;
  stroke: var(--mark-red);
  stroke-width: 9px;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.7s ease-out forwards;
  animation-delay: var(--delay, 0ms);
}
.ring.missed path { stroke: var(--mark-ink); opacity: 0.55; }
.ring.active path { stroke-width: 15px; opacity: 1; }
.ring .hit {
  fill: transparent;
  cursor: pointer;
}
.ring:focus { outline: none; }
.ring:focus-visible path { stroke-width: 15px; }

@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .ring path { animation: none; stroke-dashoffset: 0; }
}

/* Controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}
.count, .score { margin: 0; flex-basis: 100%; }
.count { color: var(--ink-soft); }
.score {
  font: 400 clamp(1.6rem, 4vw, 2.2rem)/1.1 var(--font-hand);
  color: var(--red);
}
.score:empty { display: none; }

.check, .again, .start {
  padding: 0.6rem 1.6rem;
  border: 3px solid var(--ink);
  background: var(--paper);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
}
.check:active, .again:active, .start:active { translate: 2px 2px; box-shadow: 2px 2px 0 var(--ink); }
.check:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* Explanation note (desktop) */

.note {
  position: relative;
  margin-top: 1.5rem;
  padding: 1.4rem 1.4rem 1rem;
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: 3px 5px 0 rgba(0, 0, 0, 0.2);
  transform: rotate(0.8deg);
}
.note[hidden] { display: none; }
.note-meta {
  margin: 0 2.4rem 0.4rem 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.note-status, .pop-status { color: #9c1a14; }
.note-title {
  margin: 0 0 0.5rem;
  font: 400 1.5rem/1.2 var(--font-hand);
}
.note-body { margin: 0 0 1rem; }
.note-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  padding-top: 0.6rem;
}
.note-nav button {
  border: 0;
  background: none;
  color: var(--note-ink);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
}

/* Round close button, used by the viewer, the full-screen stage and popups. */

.round-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}
.viewer-close, .stage-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 45;
}

/* Full-screen viewer */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 8px 16px;
  background: rgba(14, 14, 12, 0.95);
  overflow: auto;
}
.viewer[hidden] { display: none; }
.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* The identifier's stage. On desktop it is just the poster. */

.stage { position: relative; }
.stage-close, .start { display: none; }

.popup {
  position: fixed;
  z-index: 35;
  width: min(100vw - 16px, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.1rem 0.4rem;
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.popup[hidden] { display: none; }
.popup .round-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-color: var(--note-ink);
  background: var(--note-ink);
  color: var(--note-bg);
  font-size: 1.3rem;
}
.popup .note-title { font-size: 1.25rem; }
.popup .note-body { font-size: 0.95rem; }

@media (max-width: 899px) {
  .activity .note { display: none !important; }

  .start {
    display: block;
    position: absolute;
    left: 50%;
    bottom: 18px;
    translate: -50% 0;
    background: var(--note-bg);
    color: var(--note-ink);
    border-color: var(--note-ink);
    box-shadow: 4px 4px 0 var(--note-ink);
  }
  .start:active { translate: calc(-50% + 2px) 2px; }

  .activity.full .stage {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 8px 88px;
    background: #121210;
  }
  .activity.full .poster {
    width: min(100%, calc((100dvh - 152px) * var(--ratio)));
    transform: none;
    box-shadow: none;
  }
  .activity.full .stage-close { display: grid; }
  .activity.full .start { display: none; }
  .activity.full .controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 31;
    flex-wrap: nowrap;
    justify-content: space-between;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 3px solid var(--ink);
  }
  .activity.full .count, .activity.full .score { flex-basis: auto; }
  .activity.full .score { font-size: 1.4rem; }
}

/* Citation, visible on purpose */

.cite {
  max-width: 62ch;
  margin-top: 2rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.cite p { margin: 0 0 0.5rem; }
.cite blockquote {
  margin: 0;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--ink);
  background: var(--rule);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink);
}

/* Colophon */

.colophon {
  padding: 2rem 0 4rem;
  border-top: 3px solid var(--ink);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
