/* LINGO — reset, document, typography, atmosphere, motion primitives */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.55;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video, canvas {
  max-width: 100%;
  display: block;
}

/* `hidden` must win over any class that sets display. Without this, every
   panel we hide with el.hidden = true stays on screen the moment it also
   carries .stack, .panel, .feedback or anything else with a display rule. */
[hidden] {
  display: none !important;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); letter-spacing: -0.022em; }
h4 { font-size: var(--step-1); letter-spacing: -0.015em; }

p { margin: 0; }

ul, ol { margin: 0; padding: 0; list-style: none; }

hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 0;
}

::selection {
  background: var(--accent);
  color: var(--text-on-accent);
}

/* ---- Focus: always visible, never a default outline glued to the edge ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---- Scrollbars ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: #2d3441; background-clip: content-box; }

/* ======================================================================
   Typography utilities
   ====================================================================== */

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 62ch;
}

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.nums { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.accent-text { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: -100px;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 10px 18px;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  font-weight: 600;
  transition: top var(--t) var(--ease);
}
.skip-link:focus-visible { top: 0; }

/* ======================================================================
   Layout primitives
   ====================================================================== */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.shell-wide { max-width: 1440px; }
.shell-narrow { max-width: 760px; }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }

.g1 { gap: var(--sp-1); }
.g2 { gap: var(--sp-2); }
.g3 { gap: var(--sp-3); }
.g4 { gap: var(--sp-4); }
.g5 { gap: var(--sp-5); }
.g6 { gap: var(--sp-6); }
.g7 { gap: var(--sp-7); }

.section { padding-block: clamp(64px, 9vw, 128px); }
.section-tight { padding-block: clamp(40px, 6vw, 72px); }

/* ======================================================================
   Atmosphere — aurora field + grain. Fixed, non-interactive, cheap.
   ====================================================================== */

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.atmosphere::before {
  content: "";
  position: absolute;
  top: -30vh;
  left: 50%;
  width: min(1400px, 150vw);
  aspect-ratio: 1.4;
  transform: translateX(-50%);
  background:
    radial-gradient(45% 45% at 30% 35%, rgba(200, 255, 77, 0.13), transparent 70%),
    radial-gradient(45% 45% at 72% 30%, rgba(91, 60, 240, 0.16), transparent 70%),
    radial-gradient(40% 40% at 50% 70%, rgba(86, 182, 255, 0.07), transparent 70%);
  filter: blur(40px);
  opacity: 0.9;
}

/* Fine grain so large flat fields don't band. SVG noise as a data URI. */
.atmosphere::after {
  content: "";
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.035;
  mix-blend-mode: overlay;
}

.app-root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ======================================================================
   Motion primitives
   ====================================================================== */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(0.82); opacity: 0; }
  70% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -12px, 0); }
}

@keyframes orbit {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-ring {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes shimmer {
  from { background-position: -200% 0; }
  to { background-position: 200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* View transition — every route entry runs this once.
   Opacity only, deliberately: an animated transform on the view root makes
   that root the containing block for `position: fixed` descendants, which
   re-anchors the mobile tab bar and the lesson footer to the bottom of the
   whole page instead of the screen. Never animate transform here. */
.view-enter {
  animation: fade var(--t-slow) var(--ease-out) both;
}

/* Staggered reveal on scroll. Resting state is VISIBLE; the observer only
   adds the entrance when it is safe to do so. */
.reveal { opacity: 1; }
.js .reveal { opacity: 0; transform: translateY(18px); }
.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
}

.float { animation: drift 7s ease-in-out infinite; }
.float-slow { animation: drift 11s ease-in-out infinite; }
