/* vaoSPY — one-page site
 *
 * The rules this design follows:
 *   1. Black and white only. The games' own artwork is the only colour.
 *   2. Round is for the bomb. Buttons are slightly rounded rectangles. Everything else is square.
 *   3. Serif is for the vaoSPY wordmark only. Everything else, figures included, is Source Sans.
 */

:root {
  --black: #000;
  --white: #fff;
  --ink: #fff;
  --ink-muted: #a8a8a8;   /* 8.9:1 on black */
  --ash: #4a4a4a;         /* decoration only, never text */
  --line: #2a2a2a;
  --surface: #121212;

  --font-sans: "Source Sans 3", "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Bodoni Moda", "Didot", "Bodoni MT", "Times New Roman", serif;

  --container: 1240px;
  --gutter: clamp(20px, 4.5vw, 56px);
  --section-gap: clamp(72px, 10vw, 144px);

  --fast: 150ms;
  --medium: 320ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.125rem; /* Source Sans runs small, so the base size is 18px */
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img, svg { display: block; }
img { max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
[hidden] { display: none !important; }

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

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 0;
  z-index: 10;
  padding: 12px 20px;
  background: var(--white);
  color: var(--black);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-120%);
}
.skip-link:focus { transform: translateY(12px); }

/* Type ------------------------------------------------------------------ */

.wordmark {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

h1, h2 {
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 4.8vw + 0.75rem, 5rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(2.125rem, 3.6vw + 0.75rem, 3.75rem);
  line-height: 1.05;
}

h1 .wordmark, h2 .wordmark {
  font-size: 1.07em;
  letter-spacing: -0.02em;
}

h3 {
  font-size: clamp(1.75rem, 1.7vw + 1.05rem, 2.375rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.lead {
  max-width: 44ch;
  margin-top: 24px;
  color: var(--ink-muted);
  font-size: clamp(1.1875rem, 0.5vw + 1.05rem, 1.4375rem);
  line-height: 1.5;
}

.lead + .lead { margin-top: 14px; }

/* Header ---------------------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 16px;
  padding-block: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 1.875rem;
  text-decoration: none;
}

.nav {
  display: flex;
  margin-inline: -12px; /* the links' padding lines up with the page edge */
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 12px;
  color: var(--ink-muted);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--fast);
}
.nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 0.3em; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 26px;
  border: 1px solid var(--white);
  border-radius: 8px;
  background: transparent;
  color: var(--white);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--fast), color var(--fast);
}
.btn-primary { background: var(--white); color: var(--black); }

/* Hover only where there is a real pointer, so a tap on a phone does not leave
   a button stuck in its hover colours. */
@media (hover: hover) {
  .btn:hover { background: var(--white); color: var(--black); }
  .btn-primary:hover { background: transparent; color: var(--white); }
}

.btn:active { background: #d9d9d9; color: var(--black); }
.btn-primary:active { background: #2a2a2a; color: var(--white); }

.text-btn {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

/* Figures: rows of label + live number ---------------------------------- */

.rows { border-bottom: 1px solid var(--line); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center; /* the label sits midway between the row's two lines */
  justify-content: space-between;
  column-gap: 20px;
  padding-block: 14px;
  border-top: 1px solid var(--line);
}

.row dt { color: var(--ink-muted); }

.row dd:not(.ratio),
.bomb-number,
.members-number {
  font-weight: 600;
  /* Same-width digits, so a number does not shift sideways as it updates. */
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.01em;
}

.bomb-number,
.members-number {
  font-weight: 700;
  letter-spacing: -0.025em;
}

.row dd:not(.ratio) {
  margin-left: auto; /* stays on the right even when it wraps under its label */
  font-size: clamp(1.625rem, 1vw + 1.25rem, 2rem);
  line-height: 1.15;
  text-align: right;
}

/* Likes compared with dislikes */
.ratio { flex-basis: 100%; margin-top: 10px; }

.ratio-bar {
  display: block;
  height: 6px;
  background: var(--line);
  overflow: hidden;
}

.ratio-fill {
  display: block;
  height: 100%;
  background: var(--white);
  transform: scaleX(var(--ratio, 0));
  transform-origin: left center;
  transition: transform 700ms var(--ease-out);
}

.ratio-note {
  display: block;
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 1rem;
}

/* Placeholder while the first numbers load */
.sk {
  display: inline-block;
  width: var(--w, 5ch);
  max-width: 100%;
  height: 0.72em;
  background: #1e1e1e;
  animation: sk-pulse 900ms ease-in-out infinite alternate;
}
@keyframes sk-pulse { from { opacity: 0.45; } to { opacity: 1; } }

/* Hero ------------------------------------------------------------------ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 40px;
  padding-block: clamp(28px, 5vw, 72px) 0;
}

.totals { align-self: end; }

@media (min-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    grid-template-areas:
      "copy live"
      "totals live";
    column-gap: clamp(32px, 5vw, 88px);
    row-gap: 48px;
    align-items: center;
  }
  .hero-copy { grid-area: copy; align-self: end; }
  .totals { grid-area: totals; align-self: start; }
  .hero-live { grid-area: live; }
}

.hero-live { text-align: center; }

.bomb {
  position: relative;
  width: min(100%, 560px);
  margin-inline: auto;
  aspect-ratio: 1;
  container-type: inline-size;
}

.bomb-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bomb-art .line,
.spark-rays path {
  fill: none;
  stroke: var(--white);
  stroke-width: 1.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* The fuse is measured and dashed by the script in the drawing's own units,
   so it must scale with the drawing (no non-scaling-stroke here). */
.fuse,
.fuse-ash {
  fill: none;
  stroke: var(--white);
  stroke-width: 2.6;
  stroke-linecap: round;
}

.bomb-art .glint { opacity: 0.55; }
.fuse-ash { stroke: var(--ash); stroke-width: 2; stroke-dasharray: 1 8; }
.spark-core { fill: var(--white); }

.bomb-body {
  transform-box: fill-box;
  transform-origin: 50% 60%;
}

.bomb-readout {
  position: absolute;
  /* centre of the bomb's circle inside the 620 x 620 drawing */
  left: 43.55%;
  top: 59.68%;
  width: 66%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.bomb-number {
  display: block;
  /* Shrinks as the number gains digits, so it always sits inside the bomb.
     --chars is the number's length, set by app.js. */
  font-size: min(22cqw, calc(110cqw / var(--chars, 5)));
  line-height: 1;
}

.bomb-label {
  display: block;
  margin-top: 1.5cqw;
  color: var(--ink-muted);
  font-size: clamp(1rem, 3.6cqw, 1.1875rem);
}

.live-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  min-height: 44px;
  margin-top: 12px;
  font-weight: 500;
}
#updated { color: var(--ink-muted); font-weight: 400; }

.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--white);
  border-radius: 50%;
}
.live-dot[data-state="live"] { background: var(--white); }
.live-dot[data-state="live"]::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 50%;
  background: var(--white);
  animation: live-ring 2s var(--ease-out) infinite;
}
@keyframes live-ring {
  from { transform: scale(1); opacity: 0.7; }
  to { transform: scale(3.2); opacity: 0; }
}

.fuse-note {
  color: var(--ink-muted);
  font-size: 1rem;
  font-variant-numeric: tabular-nums; /* the countdown does not wobble as digits change */
}

/* One orchestrated moment: when the fuse reaches the bomb, the bomb kicks. */
.bomb.is-bang .bomb-body { animation: bang 460ms var(--ease-out); }
@keyframes bang {
  0% { transform: scale(1); }
  35% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.spark-rays { animation: flicker 620ms steps(1, end) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes flicker {
  0% { transform: rotate(0deg) scale(1); opacity: 1; }
  25% { transform: rotate(22deg) scale(0.7); opacity: 0.75; }
  50% { transform: rotate(45deg) scale(1.1); opacity: 1; }
  75% { transform: rotate(67deg) scale(0.8); opacity: 0.85; }
}

/* Sections -------------------------------------------------------------- */

.section {
  padding-top: var(--section-gap);
  scroll-margin-top: 0;
}

.section > h2 { margin-bottom: clamp(32px, 4vw, 56px); }

/* Games ----------------------------------------------------------------- */

/* Small screens: title, description, artwork, figures, in that order.
   Wide screens: title over the artwork, description over the figures. */
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 20px;
}
.game + .game { margin-top: clamp(64px, 8vw, 120px); }

@media (min-width: 960px) {
  .game {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    column-gap: clamp(32px, 4.5vw, 72px);
    row-gap: 28px;
  }
  .game-head, .game .game-desc { align-self: end; }
  .game-art, .game-figures { align-self: start; }
}

.game-art {
  aspect-ratio: 16 / 9;
  background: var(--surface);
  overflow: hidden;
}
.game-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.game-art img[data-art] { opacity: 0; transition: opacity var(--medium) linear; }
.game-art img[data-art].is-loaded { opacity: 1; }

.game-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-icon {
  flex: none;
  width: 64px;
  height: 64px;
  background: var(--surface);
  object-fit: cover;
}

.game .game-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.stage {
  padding: 1px 8px;
  border: 1px solid var(--ink-muted);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.5;
}

.game-desc {
  max-width: 46ch;
  color: var(--ink-muted);
  font-size: 1.1875rem;
}

.game-figures .btn { margin-top: 28px; }

.community-copy .game-desc { margin-top: 20px; }
.community-copy .btn { margin-top: 28px; }

/* Community ------------------------------------------------------------- */

.community {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 40px;
  padding-block: clamp(48px, 7vw, 96px);
  border-block: 1px solid var(--line);
}

@media (min-width: 960px) {
  .community {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: clamp(32px, 4.5vw, 72px);
    align-items: end;
  }
  .members { text-align: right; }
}

.community h2 { font-size: clamp(1.75rem, 2.2vw + 1rem, 2.75rem); }

.verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--ink-muted);
  font-size: 1rem;
}

.members-number {
  display: block;
  font-size: clamp(3.5rem, 18vw, 7.5rem); /* full-width column on small screens */
  line-height: 0.95;
}
@media (min-width: 960px) {
  .members-number { font-size: clamp(5.5rem, 11vw, 9rem); }
}

.members-label {
  display: block;
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: clamp(1.1875rem, 0.5vw + 1.05rem, 1.4375rem);
}

/* Contact --------------------------------------------------------------- */

#contact .lead { margin-top: 0; max-width: 60ch; }

.contact-line { margin-top: 12px; }

.contact-email {
  display: inline-block;
  padding-block: 8px; /* keeps the tap target at 44px or more on phones */
  font-size: clamp(1.75rem, 5.4vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.14em;
  transition: text-decoration-thickness var(--fast);
}
.contact-email:hover { text-decoration-thickness: 5px; }

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin-top: 32px;
}
.socials a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-underline-offset: 0.25em;
}

/* Footer ---------------------------------------------------------------- */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: var(--section-gap);
  padding-block: 28px 40px;
  color: var(--ink-muted);
  font-size: 1rem;
}
.site-footer .wordmark { color: var(--ink); font-size: 1.125rem; }
.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-underline-offset: 0.25em;
}
.site-footer a:hover { color: var(--ink); }

/* Reduced motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sk, .spark-rays, .live-dot[data-state="live"]::after, .bomb.is-bang .bomb-body { animation: none; }
  .ratio-fill, .game-art img[data-art] { transition: none; }
}
