/* Poppl. An overprint sheet: pale cool paper, three fluorescent inks, circles only. */

/* Self-hosted variable fonts (SIL OFL). */
@font-face {
  font-family: "Schibsted Grotesk";
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Schibsted Grotesk";
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/schibsted-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Unbounded";
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/unbounded-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #e9ecf4;
  --ink: #16193b;
  --ink-2: #444a70;
  --blue: #0078bf;
  --pink: #ff48b0;
  --orange: #ff6c2f;
  --yellow: #ffe600;

  --display: "Unbounded", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  --text: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  font: 400 1rem/1.5 var(--text);
  background: var(--paper);
  overflow-x: hidden;
}

::selection {
  background: var(--yellow);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Layout ---------------------------------------------------------------- */

.sheet {
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font: 700 1.05rem/1 var(--display);
  letter-spacing: -0.02em;
}

.reg {
  flex: none;
  color: var(--ink);
}

.issue {
  display: flex;
  gap: 0.75rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.issue span:first-child {
  font: 500 0.8125rem/1.5 var(--display);
  color: var(--ink);
}

.stage {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}

/* The plate: the canvas plus registration ticks at its corners ------------- */

.plate {
  position: relative;
  width: min(100%, calc(100svh - 9rem));
  min-width: 15rem;
  margin-inline: auto;
  aspect-ratio: 1;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: crosshair;
}

#board:focus-visible {
  outline-offset: 6px;
}

.mark {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 0 solid var(--ink);
  pointer-events: none;
}
.mark.tl { top: -11px; left: -11px; border-right-width: 1px; border-bottom-width: 1px; }
.mark.tr { top: -11px; right: -11px; border-left-width: 1px; border-bottom-width: 1px; }
.mark.bl { bottom: -11px; left: -11px; border-right-width: 1px; border-top-width: 1px; }
.mark.br { bottom: -11px; right: -11px; border-left-width: 1px; border-top-width: 1px; }

/* Panel ---------------------------------------------------------------------- */

.panel {
  display: grid;
  align-content: start;
  gap: 1.25rem;
  min-height: 13.5rem;
}

.lede {
  margin: 0;
  max-width: 34ch;
  font-size: 1.125rem;
  line-height: 1.4;
  text-wrap: pretty;
}

#hint {
  display: grid;
  gap: 1.25rem;
  justify-items: start;
}

.how {
  color: var(--ink-2);
  font-size: 0.9375rem;
  max-width: 44ch;
}

.how summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.25em;
}

.how summary::-webkit-details-marker {
  display: none;
}

.how summary::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  transition: background-color 180ms var(--ease-out);
}

.how[open] summary::before {
  background: var(--pink);
}

.how p {
  margin: 0.75rem 0 0;
}

.counter {
  margin: 0;
  font: 700 1.375rem/1.2 var(--display);
  letter-spacing: -0.02em;
}

.counter span,
.num {
  font-variant-numeric: tabular-nums;
}

.verdict {
  margin: 0;
  font: 700 clamp(1.5rem, 1.1rem + 2.2vw, 2.25rem) / 1.15 var(--display);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.detail {
  margin: 0.5rem 0 0;
  max-width: 38ch;
  color: var(--ink-2);
}

.actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.links {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
}

/* Secondary paths: practice and back. Quiet, set apart from the result actions. */
.more {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  margin: 0;
}

#result .more {
  margin-top: 1.25rem;
}

/* Controls: circles, because every shape in this game is one ------------- */

.disc {
  flex: none;
  width: 5.25rem;
  height: 5.25rem;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font: 700 0.8125rem/1 var(--display);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

@media (hover: hover) {
  .disc:hover {
    background: var(--pink);
  }
}

.disc:active {
  transform: scale(0.96);
}

.link {
  padding: 0.375rem 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.25em;
  text-decoration-color: var(--ink);
  cursor: pointer;
}

@media (hover: hover) {
  .link:hover {
    text-decoration-color: var(--pink);
    text-decoration-thickness: 3px;
  }
}

/* Touch: every control gets a 44px hit area; the visible underline stays tight. */
@media (pointer: coarse) {
  .link,
  .how summary {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
  }

  .links {
    gap: 0;
  }

  /* Drop appears after the first aim; hold its space so "How it works" doesn't jump.
     visibility:hidden keeps it out of the tab order and the accessibility tree. */
  #drop[hidden] {
    display: block !important;
    visibility: hidden;
  }
}

.fallback {
  display: block;
  width: 100%;
  max-width: 24rem;
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 0.9375rem/1.5 var(--text);
  resize: none;
}

.foot {
  margin: 1.5rem 0 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.fineprint {
  max-width: 52ch;
  margin: 2.5rem 0 0;
  color: var(--ink-2);
  font-size: 0.8125rem;
}

/* Wide screens: board left, panel right ----------------------------------------- */

@media (min-width: 56rem) {
  .sheet {
    padding-top: 1.5rem;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) 21rem;
    gap: 3.5rem;
  }

  .plate {
    margin-inline: 0;
    width: min(100%, calc(100svh - 9.5rem));
  }

  .panel {
    padding-top: 0.75rem;
  }
}

/* Phones held sideways: the board is sized by height, so put the panel beside it. */
@media (orientation: landscape) and (max-height: 34rem) and (max-width: 55.99rem) {
  .sheet {
    padding-top: 0.5rem;
  }

  .masthead {
    padding-bottom: 0.75rem;
  }

  .stage {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2rem;
  }

  .plate {
    margin-inline: 0;
    min-width: 0;
    width: calc(100svh - 5.5rem);
  }

  .panel {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .disc,
  .how summary::before {
    transition: none;
  }
}
