/* ---------- Theme tokens ---------- */
:root {
  /* Paper (light) */
  --bg: #fbf8f1;
  --ink: #2b2d42;
  --ink-soft: #5c5f77;
  --accent: #c8553d;          /* red-pen */
  --rule: rgba(80, 130, 200, 0.18); /* blue ruled lines */
  --margin: rgba(200, 85, 61, 0.45); /* red margin line */
  --grain-opacity: 0.35;
  --text-shadow: none;
  --frame: transparent;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Chalkboard (dark) */
    --bg: #2e3b32;
    --ink: #f1f0e8;
    --ink-soft: #c9cbbf;
    --accent: #f7d774;        /* yellow chalk */
    --rule: transparent;
    --margin: transparent;
    --grain-opacity: 0.5;
    --text-shadow: 0 0 1px rgba(241, 240, 232, 0.6), 0 0 6px rgba(241, 240, 232, 0.12);
    --frame: #6b4a2b;         /* wooden frame */
    color-scheme: dark;
  }
}

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

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Patrick Hand", "Comic Neue", "Segoe Print", cursive;
  font-size: 1.25rem;
  line-height: 2rem;             /* matches the ruled-line spacing */
  text-shadow: var(--text-shadow);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Ruled lines + margin (paper) — invisible in chalkboard mode */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, transparent 4.5rem, var(--margin) 4.5rem, var(--margin) calc(4.5rem + 2px), transparent calc(4.5rem + 2px)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(2rem - 1px), var(--rule) calc(2rem - 1px), var(--rule) 2rem);
  z-index: 0;
}

/* Grain: paper fibres / chalk dust */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.25 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
  z-index: 0;
}

@media (prefers-color-scheme: dark) {
  body::after { mix-blend-mode: screen; opacity: 0.18; }
  /* wooden chalkboard frame */
  body { box-shadow: inset 0 0 0 10px var(--frame), inset 0 0 0 12px rgba(0,0,0,0.35), inset 0 0 120px rgba(0,0,0,0.45); }
}

main, footer { position: relative; z-index: 1; }

h1, h2, h3 {
  font-family: "Caveat", "Patrick Hand", cursive;
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: underline wavy;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
a:hover { text-decoration-style: solid; }

:focus-visible { outline: 2px dashed var(--accent); outline-offset: 4px; }

/* ---------- Coming soon page ---------- */
.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem 1rem 2rem 5.5rem; /* clear the margin line */
}

.hero h1 {
  font-size: clamp(3.5rem, 12vw, 7rem);
  transform: rotate(-2deg);
}

.hero .tag {
  color: var(--ink-soft);
  font-size: 1.4rem;
  margin: 0 0 2rem;
}

.underline-scribble {
  display: block;
  width: min(320px, 70vw);
  height: 18px;
  margin: -0.5rem auto 1.5rem;
  color: var(--accent);
}

.hero nav { font-size: 1.15rem; }

/* ---------- Document pages (privacy etc.) ---------- */
.doc {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem 5.75rem;
}
.doc h1 { font-size: clamp(2.75rem, 7vw, 4rem); }
.doc h2 { font-size: 2rem; margin-top: 2rem; color: var(--accent); }
.doc p, .doc li { margin: 0 0 1rem; }
.doc .meta { color: var(--ink-soft); }
.doc .back { display: inline-block; margin-bottom: 1.5rem; }

.doc ul { padding-left: 1.25rem; }
.doc strong { font-weight: normal; color: var(--accent); }

/* Tables: hand-drawn grid, scroll sideways on narrow screens */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; }
.doc table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: 1.1rem;
  line-height: 1.5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
}
.doc th, .doc td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--ink-soft);
}
.doc th {
  font-family: "Caveat", "Patrick Hand", cursive;
  font-size: 1.5rem;
  color: var(--accent);
}

/* Home page footer sits on top of the full-height hero */
.site-footer { position: absolute; left: 0; right: 0; bottom: 0; }

footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 1rem;
  padding: 0 1rem 2rem 5.5rem;
}

/* Small screens: pull the margin line in */
@media (max-width: 600px) {
  body::before {
    background-image:
      linear-gradient(to right, transparent 1.75rem, var(--margin) 1.75rem, var(--margin) calc(1.75rem + 2px), transparent calc(1.75rem + 2px)),
      repeating-linear-gradient(to bottom, transparent 0, transparent calc(2rem - 1px), var(--rule) calc(2rem - 1px), var(--rule) 2rem);
  }
  .hero, footer { padding-left: 2.5rem; padding-right: 1rem; }
  .doc { padding-left: 2.75rem; padding-right: 1rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .underline-scribble path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: draw 1.2s 0.3s ease-out forwards;
  }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
