/* A page from Scribble Ball's sketchbook: cream graph paper, graphite pencil, the game's
   coloured-pencil pieces, Patrick Hand lettering, wobbly hand-drawn boxes, tilted paper
   notes like the win card, and the piece tray as its own band. */

@font-face {
  font-family: "Patrick Hand";
  src: url("/scribble-ball/fonts/patrick-hand-latin.woff2") format("woff2");
  font-display: swap;
}

/* Colours come from the game's Palette.swift. --ink-blue and --muted are darker versions
   for small text, so it keeps 4.5:1 contrast on the paper. */
:root {
  color-scheme: light;
  --paper: #f5f0e3;
  --paper-shade: #ece3cb;
  --grid: #e4ddcc;
  --graphite: #3a3a40;
  --muted: #5c5b61;
  --wall: #6b6b73;
  --teal: #2a9d8f;
  --orange: #d98b2b;
  --green: #5b9f45;
  --red: #d7263d;
  --blue: #2b6cd4;
  --ink-blue: #2457b0;
  --vermilion: #e4572e;
  --ochre: #c99700;
  --coral: #e6613b;
  --purple: #7a4fc9;
  --magenta: #c24090;
  --sky: #3e8fc2;

  --hand: "Patrick Hand", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --wobble: 255px 14px 225px 16px / 16px 225px 14px 255px;
  --wobble-2: 14px 225px 16px 255px / 225px 16px 255px 14px;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--graphite);
  font: 400 1.25rem/1.45 var(--hand);
  /* The game's 30-point pencil grid. */
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 30px 30px;
  background-position: -1px -1px;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }
figure { margin: 0; }
.muted { color: var(--muted); }
a { color: var(--ink-blue); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--graphite); }
:focus-visible { outline: 3px solid var(--ink-blue); outline-offset: 4px; border-radius: 6px; }
h1, h2, h3 { font-weight: 400; line-height: 1.05; margin: 0; }
p { margin: 0; }

.wrap { width: min(1120px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { width: min(760px, 100% - 2 * var(--gutter)); }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--paper); padding: 6px 12px; }
.skip-link:focus { left: 12px; }

/* ---- Hand-drawn boxes: a wobbly outline plus a second, lighter pencil pass ---- */

.sketch {
  position: relative;
  border: 2px solid var(--graphite);
  border-radius: var(--wobble);
}
.sketch::after {
  content: "";
  position: absolute;
  inset: -4px -3px -3px -5px;
  border: 1.5px solid var(--graphite);
  border-radius: var(--wobble-2);
  opacity: 0.35;
  transform: rotate(-0.6deg);
  pointer-events: none;
}

/* A sheet of paper laid on the page, like the win card. */
.note {
  background: var(--paper);
  box-shadow: 3px 7px 16px rgb(58 58 64 / 0.18);
}

/* Text buttons like the game's: a sketchy box, optionally with coloured-pencil hatching. */
.btn {
  display: inline-block;
  padding: 0.3em 1em 0.4em;
  color: var(--graphite);
  text-decoration: none;
  font-size: 1.35rem;
  background: var(--paper);
  transition: transform 0.12s ease;
}
.btn:hover { color: var(--graphite); transform: rotate(-1.5deg) scale(1.04); }
.btn.hatch-green { background: var(--paper) repeating-linear-gradient(60deg, rgb(91 159 69 / 0.28) 0 1.5px, transparent 1.5px 5px); }
.btn.hatch-blue { background: var(--paper) repeating-linear-gradient(60deg, rgb(43 108 212 / 0.22) 0 1.5px, transparent 1.5px 5px); }

/* ---- Header: the game's HUD, a round back button and the title ---- */

.hud {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-block: 18px;
}
.round {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50% 47% 52% 48% / 48% 52% 47% 50%;
  border: 2px solid var(--graphite);
  color: var(--graphite);
  text-decoration: none;
  font-size: 1.6rem;
  line-height: 1;
  background: var(--paper);
}
.round:hover { color: var(--graphite); transform: rotate(-6deg); }
.hud-title { line-height: 1.05; }
.hud-title strong { display: block; font-weight: 400; font-size: 1.5rem; }
.hud-title span { font-size: 1rem; color: var(--muted); }
.hud nav { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 18px; }
.hud nav a { color: var(--graphite); text-decoration: none; font-size: 1.2rem; padding: 2px 0; background: linear-gradient(var(--blue), var(--blue)) 0 100% / 0 2px no-repeat; transition: background-size 0.2s ease; }
.hud nav a:hover { background-size: 100% 2px; }

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  padding-block: clamp(20px, 4vw, 48px) clamp(48px, 7vw, 96px);
}
.hero-icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: 2px 6px 14px rgb(58 58 64 / 0.2); transform: rotate(-4deg); margin-bottom: 18px; }
.wordmark {
  font-size: clamp(3.6rem, 10vw, 7.4rem);
  line-height: 0.95;
  transform: rotate(-3deg);
  transform-origin: left center;
  letter-spacing: -0.01em;
}
.underline { width: min(520px, 92%); height: auto; margin: 8px 0 22px; }
.byline { font-size: clamp(1.3rem, 2.4vw, 1.6rem); color: var(--muted); }
.pitch { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.2; margin-top: 14px; max-width: 26ch; }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 22px; margin-top: 30px; }
.status { padding: 12px 22px 14px; transform: rotate(1.5deg); }
.status strong { display: block; font-weight: 400; font-size: 1.6rem; color: var(--ink-blue); }
.status span { color: var(--muted); font-size: 1.1rem; }
.free-note { font-size: 1.25rem; max-width: 18ch; line-height: 1.2; transform: rotate(-2deg); }
.free-note b { font-weight: 400; color: var(--ink-blue); }

/* A phone drawn in pencil, holding level 1 in the hero and the gameplay video. */
.phone {
  position: relative;
  width: 100%;
  padding: 11px;
  background: var(--graphite);
  border: 2px solid #26262b;
  border-radius: 48px 46px 50px 45px / 46px 49px 45px 50px;
  box-shadow: 4px 10px 22px rgb(58 58 64 / 0.28), inset 0 0 0 2px rgb(255 255 255 / 0.08);
  margin-inline: auto;
}
/* A second, lighter pencil pass around the body. */
.phone::after {
  content: "";
  position: absolute;
  inset: -5px -3px -4px -6px;
  border: 1.5px solid var(--graphite);
  border-radius: 52px 48px 54px 47px / 49px 53px 47px 52px;
  opacity: 0.3;
  transform: rotate(-0.7deg);
  pointer-events: none;
}
/* Side buttons. */
.phone::before {
  content: "";
  position: absolute;
  inset: 24% -6px auto;
  height: 10%;
  border-inline: 4px solid var(--graphite);
  border-radius: 3px;
}
.phone .screen {
  overflow: hidden;
  aspect-ratio: 9 / 19.5;
  display: grid;
  align-content: center;
  background: var(--paper);
  border-radius: 37px;
}
.phone .island {
  position: absolute;
  z-index: 1;
  top: 21px;
  left: 50%;
  width: 30%;
  height: 22px;
  translate: -50% 0;
  border-radius: 12px;
  background: #1c1c20;
}
.page { max-width: 340px; transform: rotate(1.6deg); }
.page-art {
  width: 100%;
  height: auto;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 7.692% 3.846%;
  background-position: 3.85% 1.92%;
  display: block;
}
.page-art .start { font: 15px var(--hand); fill: var(--graphite); opacity: 0.75; }
.page-art .spin { animation: spin 8s linear infinite; transform-box: fill-box; transform-origin: center; }
.page-art .ball-still { display: none; }
.caption-small { text-align: center; color: var(--muted); font-size: 1rem; margin-top: 8px; transform: rotate(1.2deg); }
@keyframes spin { to { transform: rotate(-360deg); } }

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

section { padding-block: clamp(48px, 8vw, 104px); }
.head { margin-bottom: clamp(26px, 4vw, 44px); }
.head h2 { font-size: clamp(2.4rem, 6vw, 3.8rem); transform: rotate(-1.5deg); transform-origin: left; display: inline-block; }
.head h2::after {
  content: "";
  display: block;
  height: 10px;
  margin-top: 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C 80 3, 160 8, 298 4' stroke='%232b6cd4' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.head p { margin-top: 14px; font-size: 1.35rem; color: var(--muted); max-width: 46ch; }

/* The tray band, like the bottom of the game screen. */
.band {
  background: rgb(236 227 203 / 0.92);
  border-top: 2px solid rgb(58 58 64 / 0.7);
  border-bottom: 2px solid rgb(58 58 64 / 0.15);
}

/* Video */
.film-wrap { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.film { transform: rotate(-1.4deg); }
/* Black below the video, so its controls run on into the bottom of the screen. */
.film .screen { background: linear-gradient(var(--paper) 50%, #000 50%); }
.film video { display: block; width: 100%; height: auto; aspect-ratio: 9 / 16; background: var(--paper); }
.film-text p + p { margin-top: 14px; }
.film-text .muted { color: var(--muted); font-size: 1.1rem; }

/* How to play */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.step { padding: 22px 24px 26px; }
.step:nth-child(1) { transform: rotate(-1.2deg); }
.step:nth-child(2) { transform: rotate(0.8deg); }
.step:nth-child(3) { transform: rotate(-0.5deg); }
.step-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.num { position: relative; width: 52px; height: 52px; flex: none; display: grid; place-items: center; font-size: 1.7rem; color: var(--ink-blue); }
.num .ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.step h3 { font-size: 1.75rem; }
.step-art { height: 92px; display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 10px; }
.step-art .piece-icon { width: 92px; height: 92px; }
.step-art .mark { width: 54px; height: 54px; }
.step-art .play { width: 62px; height: 62px; }

.stars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 40px; padding: 18px 24px; transform: rotate(0.6deg); }
.stars div { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; line-height: 1.2; }
.stars .row { display: flex; flex: none; }
.stars .star { width: 30px; height: 30px; margin-right: -4px; }

/* Pieces */
.pieces { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 30px 28px; }
.pieces li { display: grid; grid-template-columns: 84px 1fr; gap: 4px 14px; align-items: center; }
.pieces .piece-icon { width: 84px; height: 84px; grid-row: span 2; }
.pieces h3 { font-size: 1.55rem; align-self: end; }
.pieces p { font-size: 1.1rem; line-height: 1.25; align-self: start; color: var(--muted); }
.sub-head { font-size: 1.9rem; margin: 52px 0 22px; transform: rotate(-1deg); transform-origin: left; }

/* Worlds */
.worlds { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px; }
.world { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 6px; }
.world:nth-child(odd) { transform: rotate(-1deg); }
.world:nth-child(even) { transform: rotate(0.8deg); }
.world h3 { font-size: 1.8rem; }
.world .meta { color: var(--muted); font-size: 1.1rem; }
.world p { font-size: 1.15rem; line-height: 1.3; }
.world .tag { align-self: flex-start; margin-top: auto; padding: 1px 12px 3px; font-size: 1.05rem; border-radius: var(--wobble); border: 1.5px solid var(--graphite); }
.world.free { background-image: repeating-linear-gradient(60deg, rgb(91 159 69 / 0.12) 0 1.5px, transparent 1.5px 6px); }
.world.daily {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 6px 22px;
  transform: rotate(-0.4deg);
  background-image: repeating-linear-gradient(60deg, rgb(43 108 212 / 0.1) 0 1.5px, transparent 1.5px 6px);
}
.world.daily .tag { margin-top: 0; align-self: center; }

/* The promise */
.promise { display: grid; grid-template-columns: auto 1fr; gap: clamp(20px, 4vw, 44px); align-items: center; padding: clamp(22px, 4vw, 38px); transform: rotate(-0.8deg); }
.promise .stamp { width: 150px; height: 150px; display: grid; place-items: center; text-align: center; font-size: 1.5rem; line-height: 1; color: var(--ink-blue); border: 3px solid var(--blue); border-radius: 50% 48% 52% 49% / 49% 52% 48% 50%; transform: rotate(-8deg); }
.promise h2 { font-size: clamp(2rem, 4vw, 2.6rem); margin-bottom: 12px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { padding-left: 30px; position: relative; font-size: 1.25rem; line-height: 1.3; }
.checks li::before { content: "✓"; position: absolute; left: 2px; top: -1px; color: var(--green); font-size: 1.35rem; }

/* Footer */
.site-footer { padding: 40px var(--gutter) 48px; text-align: center; color: var(--muted); font-size: 1.1rem; }
.site-footer a { color: var(--graphite); }

/* ---- Support and privacy pages ---- */
.doc { padding-block: 16px 64px; }
.doc .sheet { padding: clamp(22px, 5vw, 48px); }
.doc h1 { font-size: clamp(2.6rem, 7vw, 3.6rem); transform: rotate(-1.5deg); transform-origin: left; margin-bottom: 10px; }
.doc h2 { font-size: 1.8rem; margin: 34px 0 8px; }
.doc h3 { font-size: 1.45rem; margin: 22px 0 4px; }
.doc p, .doc li { font-size: 1.2rem; }
.doc p + p { margin-top: 10px; }
.doc ul { padding-left: 1.2em; margin: 8px 0 0; }
.doc .muted { color: var(--muted); }
.doc .lead { font-size: 1.4rem; margin-top: 12px; }

/* ---- Narrow screens ---- */

@media (max-width: 860px) {
  .hero, .film-wrap { grid-template-columns: 1fr; }
  .page { max-width: 290px; }
  .steps, .stars { grid-template-columns: 1fr; }
  .worlds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .film { max-width: 300px; }
}
@media (max-width: 560px) {
  .hud { flex-wrap: wrap; }
  .hud nav { margin-left: 0; width: 100%; justify-content: flex-start; gap: 2px 16px; }
  .promise { grid-template-columns: 1fr; }
  .promise .stamp { width: 120px; height: 120px; font-size: 1.25rem; }
  .pieces { grid-template-columns: 1fr; }
  .worlds { grid-template-columns: 1fr; }
  .world.daily { grid-template-columns: 1fr; }
  .world.daily .tag { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .page-art .ball-run { display: none; }
  .page-art .ball-still { display: inline; }
}
