/* Base: colour tokens, reset, typography, layout, navigation, buttons, toast and footer */

/* Colour tokens */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sunken: #e9edf2;
  --text: #16233f;
  --muted: #566178;
  --line: #d9dfe8;
  --signal: #f2c02a;
  --on-signal: #16233f;
  --btn-bg: #40577e;
  --btn-fg: #ffffff;
  --btn-hover: #344a70;
  --ok: #1e8757;
  --ok-bg: #e2f2e9;
  --err: #ba3a31;
  --err-bg: #fae7e5;
  --board: #e9edf2;
  --flap: #ffffff;
  --flap-ink: #16233f;
  --paper: #fbfaf7;
  --ink: #16233f;
  --stamp: #2d3a8c;
  --shadow: 0 2px 6px -2px rgba(22, 35, 63, 0.08), 0 26px 50px -28px rgba(22, 35, 63, 0.55);
  --grain: 0.06;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --nav-h: 60px;
  --z-sticky: 10;
  --z-nav: 20;
  --z-toast: 30;
  --z-skip: 40;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  /* motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* depth: hairline highlight on top edges, then shadow sizes */
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  --shadow-1: 0 1px 2px rgba(22, 35, 63, 0.06), 0 1px 1px rgba(22, 35, 63, 0.03);
  --shadow-2: 0 2px 4px -1px rgba(22, 35, 63, 0.06), 0 12px 28px -14px rgba(22, 35, 63, 0.28);
  --btn-shadow: 0 1px 2px rgba(22, 35, 63, 0.24), 0 10px 22px -12px rgba(22, 35, 63, 0.6);
  --spot: rgba(242, 192, 42, 0.16);
}

/* Reset and page */
*,
*::before,
*::after {
  box-sizing: inherit;
}
html {
  height: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 76px);
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
img,
svg {
  max-width: 100%;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
}
main:focus {
  outline: none;
}
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: var(--z-skip);
  background: var(--signal);
  color: var(--on-signal);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus {
  top: calc(env(safe-area-inset-top, 0px) + 8px);
}

/* Typography */
h1,
h2,
h3 {
  font-family: var(--cond);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  text-wrap: balance;
}
h1 {
  font-size: clamp(40px, 6.2vw, 66px);
}
h2 {
  font-size: clamp(28px, 3.6vw, 38px);
}
h3,
.h3 {
  font-size: 22px;
  letter-spacing: 0;
}
p {
  margin: 0 0 1em;
  max-width: 65ch;
  text-wrap: pretty;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 15px;
}
.center {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}
.num {
  font-variant-numeric: tabular-nums;
}
section {
  padding: 52px 0 60px;
}

/* Navigation: top bar and mobile dock */
header.nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: var(--z-nav);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--nav-h);
}
.logo {
  flex-shrink: 0;
  font: 700 25px/1 var(--cond);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3.5px var(--text);
  display: inline-block;
}
.topnav {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.topnav a {
  white-space: nowrap;
  text-decoration: none;
  padding: 8px 13px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
  transition:
    color 0.2s,
    background-color 0.2s;
}
.topnav a:hover {
  color: var(--text);
}
.topnav a[aria-current="page"] {
  color: var(--text);
  background: var(--sunken);
}
/* When JavaScript is running, a pill slides between the links instead (see js/ui/effects.js) */
.topnav,
.dock {
  position: relative;
}
.topnav a,
.dock a {
  position: relative;
  z-index: 1;
}
.topnav.has-pill a[aria-current="page"],
.dock.has-pill a[aria-current="page"] {
  background: transparent;
}
.topnav.has-pill a[data-nav="lessons"][aria-current="page"] {
  background: var(--sunken);
}
.topnav .pill,
.dock .pill {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  border-radius: 9px;
  background: var(--sunken);
  pointer-events: none;
}
.dock .pill {
  border-radius: 12px;
}
/* Words due for review, counted on the Flashcards links */
.due-badge {
  position: absolute;
  top: -3px;
  right: -5px;
  z-index: 2;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--signal);
  color: var(--on-signal);
  font: 700 11px/19px var(--sans);
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}
.dock .due-badge {
  top: 3px;
  right: calc(50% - 25px);
}
.dock {
  display: none;
}
@media (max-width: 860px) {
  .topnav {
    display: none;
  }
  .dock {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-nav);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .dock a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0 5px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border-radius: 12px;
    transition:
      background-color 0.2s,
      color 0.2s;
  }
  .dock a[aria-current="page"] {
    color: var(--text);
    background: var(--sunken);
  }
  .dock svg {
    width: 22px;
    height: 22px;
  }
  body {
    padding-bottom: 74px;
  }
}

/* Buttons and links: lift on hover, press down on click */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 12px;
  min-height: 48px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    var(--btn-shadow);
  transition:
    background-color 0.25s,
    box-shadow 0.35s var(--ease-out),
    translate 0.35s var(--ease-out),
    scale 0.35s var(--ease-out);
}
/* hover and press use the translate/scale properties, so they never fight GSAP's transforms */
.btn:hover {
  background: var(--btn-hover);
  translate: 0 -2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    var(--btn-shadow),
    0 16px 30px -18px color-mix(in srgb, var(--btn-bg) 70%, transparent);
}
.btn:active {
  translate: 0 0;
  scale: 0.97;
  transition-duration: 0.08s;
}
.btn-arrow {
  width: 18px;
  height: 18px;
  margin-right: -4px;
  transition: transform 0.35s var(--ease-out);
}
.btn:hover .btn-arrow {
  transform: translateX(3px);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 2px var(--line);
}
.btn.ghost:hover {
  box-shadow: inset 0 0 0 2px var(--text);
}
.btn.small {
  min-height: 38px;
  padding: 7px 14px;
  font-size: 15px;
  border-radius: 10px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  translate: none;
  scale: none;
}
/* Text link: yellow underline; on hover a dark line sweeps across it from the left */
.tlink {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding-bottom: 3px;
  background-image:
    linear-gradient(var(--text), var(--text)), linear-gradient(var(--signal), var(--signal));
  background-size:
    0% 2px,
    100% 2px;
  background-position:
    0 100%,
    0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.5s var(--ease-out);
}
.tlink:hover {
  background-size:
    100% 2px,
    100% 2px;
}
.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  color: var(--muted);
}
.link-btn:hover {
  color: var(--text);
}

/* Breadcrumb */
.crumb {
  font-size: 15px;
  color: var(--muted);
  margin: 28px 0 10px;
}
.crumb a {
  color: var(--muted);
}

/* Loading and error message */
.boot {
  max-width: 640px;
  padding: 56px 0 72px;
}
.boot code {
  white-space: nowrap;
  font-size: 15px;
  background: var(--sunken);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Smooth scrolling (Lenis, desktop only) */
html.lenis,
html.lenis body {
  height: auto;
}
html.lenis {
  scroll-behavior: auto;
}
.lenis [data-lenis-prevent] {
  overscroll-behavior: contain;
}

/* The page on its way out doesn't take clicks */
#app.is-leaving {
  pointer-events: none;
}

/* Headlines split into lines slide up from behind a mask. The mask clips with clip-path instead of
   overflow so it can reach past the line box (umlauts above, descenders below) without changing
   the layout. */
.split-line-mask {
  overflow: visible !important;
  clip-path: inset(-0.14em -0.25em -0.12em);
}

/* Toast and footer */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  z-index: var(--z-toast);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 500;
  max-width: calc(100% - 32px);
  box-shadow: var(--shadow-2);
  transition:
    opacity 0.25s,
    transform 0.5s var(--ease-spring);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 860px) {
  .toast {
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }
}
.foot {
  border-top: 1px solid var(--line);
  padding: 26px 0 30px;
  color: var(--muted);
  font-size: 15px;
}
.foot .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
