/* Rules Goblin site. No external requests: fonts, textures and drawings are served from here.
   Drawings are alpha masks (img/doodle-*.webp), coloured per theme with mask-image.
   Fonts: Almendra Bold (titles) and Alegreya (text), both SIL Open Font License. To try another pairing,
   change --title-font and --text-font below. */

@font-face {
  font-family: "Almendra";
  src: url("/fonts/almendra-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("/fonts/alegreya.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("/fonts/alegreya-italic.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --title-font: "Almendra", Georgia, serif;
  --text-font: "Alegreya", "Palatino", Georgia, serif;

  /* Light: parchment */
  --bg: #efe3c6;
  --texture: url("/img/parchment.webp");
  --vignette: rgba(110, 70, 20, 0.16);
  --panel: rgba(255, 250, 236, 0.55);
  --line: #ccb68a;
  --fg: #2b2118;
  --muted: #52443a;
  --faint: #806d57;
  --heading: #4a2e12;
  --accent: #3f6a1c;          /* goblin green, from the crayon */
  --accent-fill: #4b7a22;
  --accent-ink: #fbf5e6;
  --doodle: rgba(59, 42, 26, 0.85);
  --shadow: 0 8px 24px rgba(80, 55, 20, 0.12);
  --shot-edge: rgba(60, 40, 15, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark: an old leather cover */
    --bg: #1d1814;
    --texture: url("/img/leather.webp");
    --vignette: rgba(0, 0, 0, 0.5);
    --panel: rgba(255, 238, 205, 0.045);
    --line: #3e342a;
    --fg: #ecdfc4;
    --muted: #c5b597;
    --faint: #94846c;
    --heading: #e3c58b;
    --accent: #b5d878;
    --accent-fill: #a9d06c;
    --accent-ink: #1b220d;
    --doodle: rgba(236, 222, 196, 0.72);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shot-edge: rgba(236, 222, 196, 0.28);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg) var(--texture) repeat;
  background-size: 384px 384px;
  color: var(--fg);
  font: 400 1.18rem/1.55 var(--text-font);
  overflow-x: hidden;
}
/* Darker edges, like an old page. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 50% 40%, transparent 55%, var(--vignette) 100%);
  pointer-events: none;
}

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent-fill); color: var(--accent-ink);
  padding: 0.5rem 1rem; font-weight: 700; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 42rem; }
@media (min-width: 40rem) { .wrap { padding: 0 1.5rem; } }

h1, h2, h3, .brand {
  font-family: var(--title-font);
  font-weight: 700;              /* only Almendra Bold is bundled; don't fake other weights */
  font-synthesis: none;
  color: var(--heading);
  line-height: 1.15;
  letter-spacing: 0;
}
h1 { font-size: clamp(2rem, 6vw, 2.6rem); margin: 0 0 1rem; }
h2 { font-size: clamp(1.4rem, 4vw, 1.8rem); margin: 0 0 0.9rem; }
h3 { font-size: 1.12rem; margin: 0 0 0.35rem; }
h4 { font-size: 1.15rem; margin: 1.4rem 0 0.2rem; color: var(--fg); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 1.1rem;
}
.brand { font-size: 1.3rem; text-decoration: none; white-space: nowrap; }
.top nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.25rem 1.1rem; font-size: 1.05rem; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--fg); text-decoration: underline; }
@media (max-width: 26rem) { .brand { font-size: 0.95rem; } .top { gap: 0.6rem; } .top nav { font-size: 0.95rem; gap: 0.2rem 0.6rem; flex-wrap: nowrap; } }

/* ---------- home hero ---------- */
.hero { display: grid; gap: 2rem; padding-block: 0.5rem 2.5rem; align-items: center; }
.title {
  font-size: clamp(2.6rem, 10vw, 4.2rem); line-height: 1.02; margin: 0 0 1.25rem;
}
.intro { max-width: 34rem; }
.intro p { margin: 0 0 1rem; color: var(--muted); }
.intro p:first-of-type {
  color: var(--fg); font-size: clamp(1.4rem, 4vw, 1.75rem); line-height: 1.3; font-weight: 500;
}
.intro p:first-of-type strong { font-weight: 800; color: var(--accent); }
.intro .soon {
  display: inline-block; margin-top: 0.25rem;
  padding: 0.5rem 1.05rem; border-radius: 999px;
  background: var(--accent-fill); color: var(--accent-ink);
  font-weight: 700; font-size: 1.05rem;
}
.intro .small { font-size: 1rem; color: var(--faint); }

/* The kid's title page, put back together: RULES, the juggler, GOBLIN. */
.title-page { margin: 0 auto; width: min(100%, 24rem); text-align: center; rotate: 1.5deg; }
.title-page .word { display: block; }
.title-page .word img { display: block; width: 100%; height: auto; }
.title-page .word-rules { width: 82%; margin-left: 2%; }
.title-page .word-goblin { width: 96%; margin: -4% 0 0 4%; }
.title-page .doodle-juggler { --w: 62%; margin: -2% auto -6%; rotate: -3deg; }

@media (min-width: 56rem) {
  .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 3.5rem; padding-block: 1.5rem 3.5rem; }
  .title-page { width: min(100%, 26rem); }
}

/* ---------- screenshots ---------- */
.screens {
  display: grid; gap: 1.25rem; margin: 1.25rem 0 0;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
}
.screen { margin: 0; text-align: center; }
.screen .phone {
  display: block; margin: 0 auto; width: min(100%, 15rem);
  border-radius: 1.9rem; overflow: hidden;
  border: 1px solid var(--shot-edge); background: #121612;
  box-shadow: var(--shadow);
}
.screen img { display: block; width: 100%; height: auto; }
.screen figcaption { margin-top: 0.6rem; font-size: 1rem; color: var(--muted); }
/* Phones: a row you can swipe through. */
@media (max-width: 34rem) {
  .screens {
    display: flex; gap: 0.9rem; overflow-x: auto; scroll-snap-type: x mandatory;
    margin-inline: -1rem; padding: 0.25rem 1rem 0.75rem; scrollbar-width: none;
  }
  .screen { flex: 0 0 62%; scroll-snap-align: center; }
}

/* ---------- sections ---------- */
.block { position: relative; padding: 2.25rem 0; }
.block + .block::before {
  content: "❦"; display: block; text-align: center; margin: -2.9rem 0 1.8rem;
  color: var(--faint); font-size: 1.1rem; opacity: 0.8;
}
.block p, .block li { color: var(--muted); }
.block strong { color: var(--fg); }
.home .narrow.wide { max-width: 56rem; }

.cards { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.95rem 1.1rem 0.85rem;
  box-shadow: var(--shadow);
}
.card p { margin: 0; font-size: 1.08rem; }

/* ---------- document pages ---------- */
.doc { padding-block: 1rem 2rem; }
.doc .block:first-child { padding-top: 0; }
.doc p, .doc li { color: var(--muted); }
.doc strong { color: var(--fg); }
.doc .small { color: var(--faint); font-size: 1rem; }
.doc ol, .doc ul { padding-left: 1.3rem; }
.doc li { margin: 0.35rem 0; }
.doc h4 + p { margin-top: 0; }
blockquote {
  margin: 1.25rem 0; padding: 0.9rem 1.1rem;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--accent-fill); border-radius: 8px;
}
blockquote p { margin: 0.4rem 0; color: var(--fg) !important; }
code {
  font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 5px; padding: 0.05em 0.35em;
}
.table { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 1.05rem; }
th, td { text-align: left; vertical-align: top; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); }
th { color: var(--fg); font-weight: 700; }
td { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* ---------- footer ---------- */
.foot { padding-block: 2rem 3rem; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.98rem; line-height: 1.5; }
.foot p { margin: 0 0 0.75rem; }
.foot a { color: var(--muted); }
.foot-nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; }

/* ---------- doodles ----------
   {doodle NAME left|right|center} in the Markdown. They float beside the text on phones and hang in
   the margin on wide screens. Each one is a mask, so it takes the theme's ink colour. */
.doodle {
  display: block;
  background: var(--doodle);
  -webkit-mask: var(--src) center / contain no-repeat;
  mask: var(--src) center / contain no-repeat;
  aspect-ratio: var(--ar);
  width: var(--w, 7rem);
  pointer-events: none;
  rotate: var(--tilt, 0deg);
}
.doodle-books   { --src: url("/img/doodle-books.webp");   --ar: 315 / 640; --w: 5.5rem; --tilt: 3deg; }
.doodle-claws   { --src: url("/img/doodle-claws.webp");   --ar: 452 / 640; --w: 7.5rem; --tilt: -2deg; }
.doodle-sun     { --src: url("/img/doodle-sun.webp");     --ar: 499 / 640; --w: 7.5rem; --tilt: 4deg; }
.doodle-juggler { --src: url("/img/doodle-juggler.webp"); --ar: 511 / 640; --w: 9rem;   --tilt: -3deg; }
.doodle-shelf   { --src: url("/img/doodle-shelf.webp");   --ar: 393 / 640; --w: 5.5rem; --tilt: 1deg; }

.doodle-right { float: right; margin: 0.25rem -0.25rem 0.75rem 1rem; }
.doodle-left  { float: left;  margin: 0.25rem 1rem 0.75rem -0.25rem; }
.doodle-center { margin: 1.5rem auto; }
.block::after { content: ""; display: block; clear: both; }

/* Beside a grid of cards a float would squeeze the grid, so the doodle sits on the section's top edge. */
.features .doodle-right, .features .doodle-left {
  position: absolute; float: none; margin: 0; top: -2.5rem; --w: 4.75rem;
}
.features .doodle-right { right: 0.5rem; }
.features .doodle-left { left: 0.5rem; }

/* Wide screens: hang the doodles in the margins, a little bigger. */
@media (min-width: 72rem) {
  .doodle-right { position: absolute; float: none; right: -13rem; top: 2.5rem; margin: 0; }
  .doodle-left  { position: absolute; float: none; left: -13rem;  top: 2.5rem; margin: 0; }
  .doodle-books { --w: 7rem; }
  .doodle-claws { --w: 9.5rem; }
  .doodle-sun   { --w: 10rem; }
  .doodle-shelf { --w: 7rem; }
}
