/* NineGaps website (#58). Tokens and components: DESIGN.md. */

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

:root {
  --paper: #fbfbf8;
  --grid-line: #dfe6ee;
  --square: 20px;
  --ink: #2b4c9b;
  --text: #1a1a1b;
  --caption: #63676a;
  --correct: #1e8a33;
  --wrong: #c2402f;
  --sticky: #fff4a3;
  --photo: #f7f6f2;
  --flag-blue: #7fa8f0;
  --flag-pink: #f08ab0;
  --flag-pale: #c9d8f2;
  --t1: #f6cf4e; --t2: #f5a05a; --t3: #f08ab0; --t4: #b79aeb; --t5: #7fa8f0;
  --t6: #6fcbe3; --t7: #5ec2b2; --t8: #bbd565; --t9: #ffad94;
  --shadow: rgba(0, 0, 0, 0.14);
  --hand: "Caveat", "Bradley Hand", cursive;
  --print: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --numeral: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color-scheme: light;
}

@media (min-width: 900px) {
  :root { --square: 30px; }
}

* { box-sizing: border-box; }

html {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--square) var(--square);
}

body {
  margin: 0;
  color: var(--text);
  font: 18px/1.6 var(--print);
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; }

a { color: var(--ink); text-underline-offset: 3px; }
a:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

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

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.prose { max-width: 65ch; }
.prose p, .prose li { margin: 0 0 16px; }

/* Handwriting */
.hand, h1, h2, h3 {
  font-family: var(--hand);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  margin: 0;
}

h2 { font-size: 34px; margin: 0 0 16px; }
h3 { font-size: 26px; margin: 24px 0 4px; }

/* Secondary explanations: print, like all explaining text. Handwriting is for titles and labels. */
.caption {
  font: 15px/1.5 var(--print);
  color: var(--caption);
}

/* Header: wordmark and page flags */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
}

.mark {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 32px;
  color: var(--ink);
  text-decoration: none;
  transform: rotate(-2deg);
}

.flags { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }

.flag {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px 0 28px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 24px;
  color: var(--text);
  text-decoration: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.6) 0 16px, transparent 16px),
    var(--flag, var(--flag-pale));
  box-shadow: 0 2px 3px var(--shadow);
  transform: rotate(var(--tilt, -1.5deg));
  transition: transform 0.15s;
}

.flag:hover, .flag:focus-visible { transform: rotate(0) translateY(-2px); }
.flag[aria-current="page"] { --flag: var(--flag-blue); }
.flags li:nth-child(2) .flag { --tilt: 1.5deg; }
.flags li:nth-child(3) .flag { --tilt: -1deg; }

/* Hero */
.hero {
  display: grid;
  gap: 32px;
  align-items: center;
  padding: 32px 0 64px;
}

@media (min-width: 860px) {
  .hero { grid-template-columns: 1.1fr 0.9fr; gap: 48px; padding-top: 48px; }
}

.hero h1 {
  font-size: clamp(40px, 6vw, 60px);
  line-height: 1.05;
  transform: rotate(-1.5deg);
  transform-origin: left;
}

.hero h1 .last { display: inline-block; max-width: 13ch; }

.hero .lead {
  font-size: 20px;
  max-width: 34ch;
  margin: 24px 0;
}

/* Apple's badge, unaltered, with its clear space: a quarter of its height on every side. */
.store {
  display: inline-block;
  line-height: 0;
  border-radius: 9px;
}

.store img { height: 54px; width: auto; }

.devices { margin: 16px 0 0; }

/* The iPhone, in Apple's own bezel. Apple's marketing guidelines ask for product images "as is":
   no tilting, shadows or anything on top (developer.apple.com/app-store/marketing/guidelines). */
.device {
  margin: 0 auto;
  width: min(300px, 72vw);
}

@media (min-width: 860px) {
  .hero .device { margin-left: -4%; }
}

.device img { display: block; width: 100%; }

/* Sections */
.section { padding: 0 0 64px; }

.split { display: grid; gap: 40px; align-items: start; }

@media (min-width: 860px) {
  .split { grid-template-columns: 1fr 1fr; gap: 48px; }
}

/* A worked line: paper tiles, ink operators, the result in its verdict's ink */
.line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
}

.tile {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  font: 700 28px/1 var(--numeral);
  color: var(--text);
  box-shadow: 0 2px 2px var(--shadow), 0 6px 10px rgba(0, 0, 0, 0.08);
}

.tile:nth-of-type(odd) { transform: rotate(-1.5deg); }
.tile:nth-of-type(even) { transform: rotate(1.5deg); }

.op { font-family: var(--hand); font-weight: 700; font-size: 34px; color: var(--ink); }
.result { font-family: var(--hand); font-weight: 700; font-size: 46px; line-height: 1; }
.result.correct { color: var(--correct); }
.result.wrong { color: var(--wrong); }

/* An empty square on the board: dashed ink, as in the app. */
.gap {
  width: 56px;
  height: 56px;
  border: 2px dashed var(--ink);
  border-radius: 4px;
  opacity: 0.7;
}

/* The sticky note */
.sticky {
  background: var(--sticky);
  padding: 24px 28px;
  box-shadow: 0 1px 1px var(--shadow), 0 14px 24px rgba(0, 0, 0, 0.12);
  transform: rotate(-1.2deg);
}

.sticky p:last-child { margin-bottom: 0; }

/* Five levels, as clue diagrams */
.levels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.levels li { flex: 0 0 104px; text-align: center; }

@media (min-width: 640px) {
  .levels { justify-content: space-between; }
  .levels li { flex-basis: 140px; }
}

.levels small { display: block; line-height: 1.3; }

.clues {
  display: inline-grid;
  grid-template-columns: repeat(3, 18px);
  gap: 4px;
  margin-bottom: 8px;
}

.clues span { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 3px; }
.clues .given { background: var(--ink); }

.levels .hand { display: block; font-size: 26px; }
.levels small { color: var(--caption); font-size: 15px; }

/* Closing call */
.closing { text-align: center; padding-bottom: 64px; }
.closing h2 { font-size: 40px; }

/* Footer */
footer {
  padding: 32px 0 48px;
  color: var(--caption);
  font-size: 15px;
}

footer a { color: var(--caption); }
footer p { margin: 0 0 8px; }

/* Support and privacy pages */
.page-title {
  font-size: clamp(48px, 9vw, 72px);
  transform: rotate(-2deg);
  transform-origin: left;
  margin: 40px 0 16px;
}

.toc { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 40px; padding: 0; list-style: none; }
.toc a { font-family: var(--hand); font-weight: 700; font-size: 22px; }

.doc h2 { margin-top: 48px; }
.doc dt { font-family: var(--hand); font-weight: 700; font-size: 24px; color: var(--ink); margin-top: 24px; }
.doc dd { margin: 4px 0 0; }


@media (prefers-reduced-motion: reduce) {
  .flag { transition: none; }
}
