/* Guess the Verdict. The look is described in STYLE.md. */

/* ---------- Fonts ---------- */
/* Kept in the project (free licences in css/fonts/), so the page calls no other site.
   Latin letters only: that covers English and French. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;

  --scarlet: oklch(52% 0.205 22);
  --ermine: oklch(97.5% 0.004 106);
  --ink: oklch(21% 0.012 265);
  --slate: oklch(46% 0.015 265);
  --white: oklch(100% 0 none);
  --line: color-mix(in oklch, var(--ink) 18%, transparent);
  --ink-hover: color-mix(in oklch, var(--ink), white 16%);
  --ink-wash: color-mix(in oklch, var(--ink) 8%, transparent);
  --manila: oklch(92.6% 0.032 89);
  --manila-edge: oklch(80.7% 0.05 88);

  --font-display: "Bricolage Grotesque", "Arial Black", sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;

  --text-small: 0.9375rem;
  --text-body: clamp(1.0625rem, 1.02rem + 0.2vw, 1.1875rem);
  --text-question: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --text-ruling: clamp(1.75rem, 1.45rem + 1.4vw, 2.5rem);
  --text-headline: clamp(2rem, 1.45rem + 2.6vw, 3.5rem);
  --text-score: clamp(4.5rem, 3rem + 7vw, 8rem);

  --gutter: clamp(1.25rem, 0.75rem + 2.5vw, 2.5rem);
  --space-s: 0.75rem;
  --space-m: 1.25rem;
  --space-l: 2rem;
  --space-xl: 3rem;

  --radius: 12px;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- Reset ---------- */

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

:root {
  text-wrap: pretty;
  overflow-wrap: break-word;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ermine);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
}

h1, h2, h3 {
  margin: 0;
  text-wrap: balance;
}

p, ul, ol {
  margin: 0;
}

button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

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

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: clip;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Page layout ---------- */

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
}

.side {
  display: grid;
  align-content: start;
  gap: var(--space-l);
  padding: var(--space-m) var(--gutter) var(--space-l);
  background: var(--scarlet);
  color: var(--white);
}

.side :focus-visible {
  outline-color: var(--white);
}

.sheet {
  display: grid;
  align-content: start;
  gap: var(--space-m);
  inline-size: 100%;
  max-inline-size: 42rem;
  padding: var(--space-l) var(--gutter) var(--space-xl);
}

@media (width >= 60rem) {
  .app {
    grid-template-columns: minmax(22rem, 5fr) 7fr;
    grid-template-rows: none;
  }

  .side {
    position: sticky;
    inset-block-start: 0;
    block-size: 100svh;
    padding-block: var(--space-l) var(--space-xl);
    overflow-y: auto;
  }

  .sheet {
    padding-block: clamp(3rem, 12vh, 7rem) var(--space-xl);
    padding-inline: clamp(2rem, 5vw, 5rem);
  }
}

/* ---------- Scarlet side ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}

.lang-switch {
  min-block-size: 44px;
  padding-inline: 1rem;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--text-small);
  font-weight: 700;
  cursor: pointer;
}

.lang-switch {
  flex: none;
  margin-inline-start: auto;
  white-space: nowrap;
}

.mute-button {
  flex: none;
  display: inline-grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.mute-button .icon {
  inline-size: 1.25rem;
  block-size: 1.25rem;
}

.panel {
  display: grid;
  gap: var(--space-s);
}

.panel h1 {
  max-inline-size: 18ch;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-headline);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.kicker {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel .bench {
  margin-block-start: var(--space-s);
}

.panel .seat {
  background: var(--white);
}

.panel .seat.is-dissent {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--white);
}

.panel h1.score {
  font-size: var(--text-score);
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-ruling);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

/* The round's five cases as small folders, each with its stamp. */
.files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-block: var(--space-s) var(--space-s);
}

.mini {
  position: relative;
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2rem;
  margin-block-start: 0.3rem;
  border: 1px solid var(--manila-edge);
  border-radius: 2px 4px 4px;
  background: var(--manila);
  color: var(--scarlet);
}

.mini::before {
  content: "";
  position: absolute;
  inset-block-end: 100%;
  inset-inline-start: -1px;
  inline-size: 1rem;
  block-size: 0.3rem;
  border: 1px solid var(--manila-edge);
  border-block-end: none;
  border-radius: 3px 3px 0 0;
  background: var(--manila);
}

.mini.is-wrong {
  color: var(--ink);
}

.mini .icon {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  rotate: -12deg;
}

@media (prefers-reduced-motion: no-preference) {
  /* The folders slide into the row, the score counts up (app.js), then the
     rank appears. App.js only hides the rank when it will count. */
  .files.is-fresh .mini {
    animation: folder-in 300ms var(--ease-out) backwards;
    animation-delay: calc(var(--i) * 80ms);
  }

  .rank,
  .rank-line {
    transition: opacity 250ms var(--ease-out), translate 250ms var(--ease-out);
  }

  .is-waiting {
    opacity: 0;
    translate: 0 0.4rem;
  }

  /* Screen changes: the old screen slides out, the new one slides in. The
     top bar stays put. */
  .panel {
    view-transition-name: panel;
  }

  .sheet {
    view-transition-name: sheet;
  }

  /* Each screen part sits at its new place and only fades and slides
     sideways. Moving it from its old place would sweep it up or down the
     page, because the new screen starts scrolled to the top. */
  ::view-transition-group(panel),
  ::view-transition-group(sheet) {
    animation: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }

  ::view-transition-old(panel),
  ::view-transition-old(sheet) {
    animation: screen-out 300ms var(--ease-out) both;
  }

  ::view-transition-new(panel),
  ::view-transition-new(sheet) {
    animation: screen-in 300ms var(--ease-out) both;
  }
}

@keyframes screen-out {
  to {
    opacity: 0;
    translate: -2rem 0;
  }
}

@keyframes screen-in {
  from {
    opacity: 0;
    translate: 2rem 0;
  }
}

/* ---------- The case folder ---------- */

.folder {
  position: relative;
  max-inline-size: 28rem;
  margin-block-start: 1.6rem;
  padding: var(--space-m);
  border: 1px solid var(--manila-edge);
  border-radius: 2px 6px 6px;
  background: var(--manila);
  color: var(--ink);
}

.panel .folder {
  margin-block-start: calc(var(--space-m) + 1.6rem);
}

.folder-tab {
  position: absolute;
  inset-block-end: 100%;
  inset-inline-start: -1px;
  padding: 0.1rem 0.75rem;
  border: 1px solid var(--manila-edge);
  border-block-end: none;
  border-radius: 6px 6px 0 0;
  background: var(--manila);
  font-size: var(--text-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.exhibit {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  margin: 0;
}

.exhibit-picture {
  flex: none;
  inline-size: clamp(6rem, 35%, 10rem);
  block-size: auto;
  /* The pictures are square: hold their space before they load. */
  aspect-ratio: 1;
  padding: 0.5rem;
  background: var(--white);
  box-shadow: 3px 4px 0 var(--manila-edge);
  rotate: -2deg;
}

.exhibit figcaption {
  display: grid;
  justify-items: start;
  gap: 0.4rem;
}

.exhibit-label {
  padding: 0.05rem 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  font-size: var(--text-small);
  font-weight: 700;
  rotate: -2deg;
}

.exhibit-caption {
  color: var(--slate);
  font-size: var(--text-small);
  line-height: 1.35;
}

@media (prefers-reduced-motion: no-preference) {
  /* A new case: the folder slides in from the left (never the right, which
     would make the page scroll sideways), then the picture drops on. */
  .folder.is-entering {
    animation: folder-in 350ms var(--ease-out) backwards;
  }

  .folder.is-entering .exhibit-picture {
    animation: exhibit-drop 350ms var(--ease-out) 120ms backwards;
  }
}

@keyframes folder-in {
  from {
    opacity: 0;
    translate: -2.5rem 0;
    rotate: -1.5deg;
  }
}

@keyframes exhibit-drop {
  from {
    opacity: 0;
    translate: 0 -0.75rem;
    rotate: -9deg;
    scale: 1.06;
  }
}

/* ---------- Reading sheet ---------- */

.lead {
  font-size: var(--text-question);
  line-height: 1.4;
}

.fine-print {
  color: var(--slate);
  font-size: var(--text-small);
}

.facts,
.why {
  display: grid;
  gap: 0.6rem;
  padding-inline-start: 1.2em;
}

.facts li::marker,
.why li::marker {
  color: var(--scarlet);
}

.question {
  margin-block-start: var(--space-s);
  scroll-margin-block-start: var(--space-m);
  font-size: var(--text-question);
  font-weight: 700;
  line-height: 1.25;
}

/* ---------- Buttons ---------- */

.options {
  display: grid;
  gap: var(--space-s);
}

.option {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem var(--space-s);
  inline-size: 100%;
  min-block-size: 3.5rem;
  padding: 0.8rem 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
}

.option:disabled {
  cursor: default;
}

.option.is-picked {
  background: var(--ink);
  color: var(--white);
}

.option.is-other {
  border-color: var(--line);
  color: var(--slate);
}

.option-label {
  flex: 1 1 9rem;
}

.option-tag {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--text-small);
  white-space: nowrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  min-block-size: 3.25rem;
  padding: 0.7rem 1.5rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--white);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button.is-quiet {
  background: transparent;
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .option:not(:disabled):hover,
  .button.is-quiet:hover {
    background: var(--ink-wash);
  }

  .button:not(.is-quiet):hover {
    border-color: var(--ink-hover);
    background: var(--ink-hover);
  }

  .lang-switch:hover,
  .mute-button:hover {
    background: color-mix(in oklch, var(--white) 16%, transparent);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .option,
  .button,
  .lang-switch,
  .mute-button {
    transition: transform 160ms var(--ease-out), background-color 120ms var(--ease-out);
  }

  .option:not(:disabled):active,
  .button:active,
  .lang-switch:active,
  .mute-button:active {
    transform: scale(0.96);
  }
}

.icon {
  display: inline-flex;
  flex: none;
  inline-size: 1.25em;
  block-size: 1.25em;
}

.icon svg {
  inline-size: 100%;
  block-size: 100%;
}

/* ---------- The reveal ---------- */

.reveal {
  display: grid;
  gap: var(--space-s);
  margin-block-start: var(--space-s);
}

/* The verdict slip: a sheet of paper right under the answers. The stamp
   floats in its top corner so the ruling wraps around it, never under it. */
.slip {
  display: flow-root;
  padding: var(--space-m);
  border: 1px solid var(--manila-edge);
  border-radius: 6px;
  background: var(--white);
  box-shadow: 3px 4px 0 var(--manila-edge);
}

.slip .ruling,
.slip .bench,
.slip .votes {
  margin-block-start: var(--space-s);
}

.stamp {
  float: inline-end;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-block: 0.35rem var(--space-s);
  margin-inline: var(--space-m) 0.25rem;
  padding: 0.15rem 0.6rem;
  border: 3px solid currentColor;
  border-radius: 6px;
  color: var(--scarlet);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.1;
  rotate: -12deg;
}

.stamp.is-wrong {
  color: var(--ink);
}

.result-line {
  font-weight: 700;
}

@media (prefers-reduced-motion: no-preference) {
  /* The slip appears, the stamp comes down and lands at about 250 ms, the
     slip shakes once, and the judges' dots follow from 400 ms. The sound
     timings in app.js follow these numbers. */
  .slip.is-fresh {
    animation:
      slip-in 150ms var(--ease-out) backwards,
      slip-shake 150ms var(--ease-out) 250ms;
  }

  .slip.is-fresh .stamp {
    animation: stamp-down 200ms var(--ease-out) 100ms backwards;
  }
}

@keyframes slip-in {
  from {
    opacity: 0;
    translate: 0 0.5rem;
  }
}

@keyframes stamp-down {
  from {
    opacity: 0;
    scale: 1.7;
  }

  75% {
    opacity: 1;
    scale: 0.96;
  }
}

@keyframes slip-shake {
  30% {
    rotate: -0.6deg;
  }

  65% {
    rotate: 0.35deg;
  }
}

.ruling {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-ruling);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.bench {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 0.25rem;
}

.seat {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border-radius: 50%;
  background: var(--scarlet);
}

.seat.is-dissent {
  background: var(--ermine);
  box-shadow: inset 0 0 0 2px var(--ink);
}

@media (prefers-reduced-motion: no-preference) {
  .bench.is-fresh .seat {
    animation: seat-in 320ms var(--ease-out) backwards;
    animation-delay: calc(var(--i) * 70ms + 400ms);
  }
}

@keyframes seat-in {
  from {
    opacity: 0;
    transform: scale(0.25);
  }
}

.votes {
  font-weight: 700;
}

.reveal h3 {
  margin-block-start: var(--space-s);
  font-size: var(--text-body);
  font-weight: 700;
}

.source {
  display: grid;
  gap: 0.15rem;
  margin-block: var(--space-s);
  color: var(--slate);
  font-size: var(--text-small);
}

a {
  color: var(--scarlet);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.source a {
  justify-self: start;
  padding-block: 0.7rem;
}

/* ---------- Results ---------- */

.recap {
  display: grid;
  padding: 0;
  list-style: none;
}

.recap li {
  display: flex;
  gap: var(--space-s);
  padding-block: var(--space-s);
  border-block-end: 1px solid var(--line);
}

.recap li .icon {
  margin-block-start: 0.15em;
}

.recap li div {
  display: grid;
  gap: 0.1rem;
}

.recap-headline {
  font-weight: 700;
}

.recap a {
  justify-self: start;
  padding-block: 0.7rem;
  font-size: var(--text-small);
  font-weight: 400;
  text-decoration-thickness: 1px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  margin-block-start: var(--space-s);
}

.share-status {
  min-block-size: 1.5em;
  font-weight: 700;
}

.share-text {
  margin: 0;
  padding: var(--space-s);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  white-space: pre-wrap;
  user-select: all;
}
