/* Fonts are hosted alongside the app (Poppins + JetBrains Mono, SIL Open Font Licence): no third-party requests */
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("../assets/fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("../assets/fonts/poppins-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("../assets/fonts/poppins-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("../assets/fonts/poppins-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 800; font-display: swap; src: url("../assets/fonts/poppins-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("../assets/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("../assets/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }
/* DesignClass brand tokens (Brand & Style Guide 1.0), shared with DesignClass CFD, CAM, Render and Studio Pro */
:root {
  --ink: #0A1020;          /* Drawing Ink */
  --ink2: #121B36;         /* Night Sheet */
  --paper: #F4F2EC;        /* Tracing Paper */
  --white: #FFFFFF;
  --blue: #2448FF;         /* Drafting Blue */
  --blue-d: #1630D6;       /* Pressed Blue */
  --cyan: #4FE3FF;         /* Blueprint Cyan */
  --text: #121726;         /* Graphite */
  --pencil: #4D566A;       /* Pencil Grey */
  --field: #C9CDD8;        /* Field Line */
  --body-dark: #B9C4E2;
  --tb-label: #7186BB;
  --tb-value: #C9D3EE;
  --danger: #E0352B;
  --amber: #F2A900;
  --line: rgba(18, 23, 38, .14);
  --line-dark: rgba(160, 195, 255, .22);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --header-h: 64px;
  --tap: 40px;             /* smallest button height; 44px on touch screens (below) */
  --blueprint:
    linear-gradient(rgba(120, 170, 255, .07) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(120, 170, 255, .07) 1px, transparent 1px) 0 0 / 40px 40px;
}
@media (pointer: coarse) { :root { --tap: 44px; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 400 16px/1.5 var(--sans); color: var(--text); background: var(--paper);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.site-header :focus-visible, .hero :focus-visible { outline-color: var(--white); }

/* ---------------------------------------------------------------- header */
.site-header {
  height: var(--header-h); flex: none; position: relative; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 clamp(14px, 2vw, 24px); color: var(--white);
  background: radial-gradient(60% 180% at 85% 0%, rgba(36, 72, 255, .38), transparent 70%), var(--blueprint), var(--ink);
  border-bottom: 1px solid var(--line-dark);
}
.brand { display: block; line-height: 0; flex: none; }
.brand img { height: 40px; width: auto; display: block; }
.brand-text {
  display: flex; flex-direction: column; line-height: 1.15; min-width: 0;
  padding-left: 16px; border-left: 1px solid var(--line-dark);
}
.eyebrow { font: 500 .68rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--cyan); }
.app-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; white-space: nowrap; }
.app-name .accent { color: var(--cyan); }
.header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* rank and XP */
.rank-chip {
  margin-left: auto; display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: baseline;
  padding: 6px 14px 7px; border: 1px solid var(--line-dark); border-radius: 12px; background: rgba(10, 16, 32, .6);
  min-width: 170px;
}
.rank-chip + .header-actions { margin-left: 8px; }
.rank-name { font-weight: 700; font-size: .82rem; color: var(--white); white-space: nowrap; }
.rank-xp { font: 500 .72rem var(--mono); color: var(--cyan); text-align: right; white-space: nowrap; }
.rank-chip .meter { grid-column: 1 / -1; }
.meter { height: 3px; border-radius: 3px; background: rgba(160, 195, 255, .2); margin-top: 4px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--cyan); transition: width .4s var(--ease); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --h: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: var(--h); padding: 0 1.15em; border-radius: 999px; border: 1.5px solid var(--text);
  background: transparent; color: var(--text); font-weight: 600; font-size: .86rem; line-height: 1.1;
  cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none; text-align: center;
  transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.btn:hover { background: var(--text); color: var(--white); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--white); box-shadow: 0 10px 24px -10px var(--blue); }
.btn.primary:hover { background: var(--blue-d); border-color: var(--blue-d); }
.btn.ghost { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .55); color: var(--white); }
.btn.ghost:hover { background: rgba(255, 255, 255, .14); }
.btn.ghost[aria-expanded="true"] { background: var(--cyan); border-color: var(--cyan); color: var(--ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--white); }
.btn:disabled { opacity: .45; pointer-events: none; box-shadow: none; }
/* the "unsaved" dot on Save progress */
.save-btn .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--amber); flex: none;
  box-shadow: 0 0 0 3px rgba(242, 169, 0, .3);
}
.save-btn.nag { animation: nag 1.6s var(--ease) 3; }
@keyframes nag { 50% { box-shadow: 0 0 0 8px rgba(36, 72, 255, .35); } }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none; border-radius: 999px; border: 1.5px solid var(--field); background: transparent;
  cursor: pointer; color: var(--pencil); font-size: 1rem; line-height: 1;
}
.icon-btn:hover { border-color: var(--text); color: var(--text); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.readout { font: 500 .78rem/1.5 var(--mono); color: var(--pencil); }

/* ---------------------------------------------------------------- hub (home screen) */
.hub { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: clamp(20px, 4vw, 56px); align-items: center;
  padding: clamp(28px, 4vw, 56px) clamp(16px, 4vw, 56px);
  color: var(--body-dark);
  background: radial-gradient(ellipse at 20% 0%, rgba(36, 72, 255, .3), transparent 60%), var(--blueprint), var(--ink);
}
.hero-title { margin: 0 0 12px; color: var(--white); font-weight: 800; font-size: clamp(1.8rem, 3.4vw, 2.8rem); letter-spacing: -.03em; line-height: 1.08; }
.hero-title b { color: var(--cyan); font-weight: 800; display: block; }
.hero-sub { margin: 0; max-width: 560px; font-size: 1rem; }
.warn-line { color: var(--amber); margin-top: 14px; }
.start-card {
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  border: 1px solid var(--line-dark); border-radius: 20px; background: rgba(18, 27, 54, .7);
}
.start-new, .welcome { display: flex; flex-direction: column; gap: 2px; }
.start-new strong, .welcome strong { color: var(--white); font-size: 1.1rem; }
.start-label { font: 700 .66rem/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--tb-label); }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; min-height: 104px; padding: 14px; border: 1.5px dashed var(--line-dark); border-radius: 16px; cursor: pointer;
  background: rgba(10, 16, 32, .5); color: var(--body-dark); text-align: center;
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.dropzone::before, .dropzone::after { content: ""; position: absolute; width: 14px; height: 14px; border: 1.5px solid var(--cyan); }
.dropzone::before { top: -8px; left: -8px; border-right: 0; border-bottom: 0; }
.dropzone::after { bottom: -8px; right: -8px; border-left: 0; border-top: 0; }
.dropzone:hover { border-color: var(--cyan); background: rgba(79, 227, 255, .08); }
.dropzone strong { font-weight: 600; color: var(--white); font-size: 1rem; }
.dropzone span { font-size: .84rem; }
.dropzone b { color: var(--cyan); font-family: var(--mono); font-weight: 500; }
.keep-note { margin: 0; font-size: .82rem; color: var(--tb-value); }
.keep-note span { color: var(--amber); }

.band { padding: 28px clamp(16px, 4vw, 56px) 8px; }
.band-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.band-head h2 { margin: 0; font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }
.sheet-tag {
  display: inline-flex; align-items: center; gap: .7em; padding-right: .7em; flex: none;
  border: 1.5px solid var(--text); border-radius: 6px; overflow: hidden;
  font: 700 .68rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
}
.sheet-tag .num { background: var(--text); color: var(--white); padding: .45em .6em; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; width: 100%; height: 100%; min-height: 150px;
  padding: 16px; text-align: left; cursor: pointer;
  background: var(--white); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 28px 50px -34px rgba(18, 23, 38, .45);
  transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}
.card:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 30px 50px -30px rgba(36, 72, 255, .5); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-num {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px;
  background: var(--ink); color: var(--cyan); font: 700 .86rem var(--mono);
}
.card-tool { font: 500 .66rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--pencil); }
.card h3 { margin: 0; font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; line-height: 1.25; }
.card p { margin: 0; color: var(--pencil); font-size: .86rem; line-height: 1.45; flex: 1; }
.card .soon {
  align-self: flex-start; padding: 3px 9px; border-radius: 999px; background: rgba(18, 23, 38, .06);
  font: 500 .66rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--pencil);
}
/* the four lesson steps: Learn → Try → Check → Challenge */
.steps { display: flex; gap: 4px; }
.steps span { flex: 1; height: 5px; border-radius: 3px; background: var(--field); }
.steps span.done { background: var(--blue); }
.card.done { border-color: var(--blue); }
.card.done .card-num { background: var(--blue); color: var(--white); }

.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.badge {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--white); border: 1px dashed var(--field); border-radius: 16px; color: var(--pencil);
}
.badge .medal {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px dashed var(--field); font: 700 .8rem var(--mono); color: var(--field);
}
.badge b { display: block; font-size: .86rem; color: var(--pencil); }
.badge small { display: block; font-size: .74rem; line-height: 1.35; }
.badge.earned { border: 1px solid var(--blue); color: var(--text); }
.badge.earned .medal { border: 0; background: var(--blue); color: var(--white); box-shadow: 0 0 0 4px rgba(36, 72, 255, .15); }
.badge.earned b { color: var(--text); }

.hub-foot { padding: 28px clamp(16px, 4vw, 56px) 36px; color: var(--pencil); font-size: .76rem; }

/* ---------------------------------------------------------------- Data Booklet drawer */
.booklet {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; z-index: 30; width: min(460px, 92vw);
  display: flex; flex-direction: column; background: var(--paper); border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px -30px rgba(10, 16, 32, .5);
  transform: translateX(105%); visibility: hidden;
  transition: transform .28s var(--ease), visibility 0s linear .28s;
}
.booklet.open { transform: none; visibility: visible; transition: transform .28s var(--ease); }
.booklet:focus { outline: none; }
.booklet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px;
  background: var(--blueprint), var(--ink); color: var(--white);
}
.booklet-head h2 { margin: 0; font-weight: 800; font-size: 1.2rem; }
.booklet-head .icon-btn { border-color: var(--line-dark); color: var(--white); }
.booklet-body { overflow-y: auto; padding: 4px 20px 28px; -webkit-overflow-scrolling: touch; }
.booklet h3 { margin: 20px 0 8px; font: 700 .7rem/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--pencil); }
.booklet table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .86rem; }
.booklet th, .booklet td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.booklet tr:last-child > * { border-bottom: 0; }
.booklet thead th { font: 700 .64rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--pencil); background: rgba(18, 23, 38, .04); }
.formulae th { font-weight: 600; width: 34%; }
.formulae td:nth-child(2) { font-size: 1.05rem; white-space: nowrap; }
.formulae .note { color: var(--pencil); font-size: .76rem; }
var { font-family: "Cambria Math", "Times New Roman", serif; font-style: italic; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; white-space: nowrap; }
.frac > span + span { border-top: 1px solid currentColor; }   /* numerator, then the line, then denominator */
.aside-note { margin-top: 18px; padding: 2px 14px 10px; border: 1px dashed var(--field); border-radius: 12px; }
.aside-note ul { margin: 0; padding-left: 18px; font-size: .86rem; display: flex; flex-direction: column; gap: 6px; }
.scrim { position: fixed; inset: var(--header-h) 0 0 0; z-index: 25; background: rgba(10, 16, 32, .35); }

/* ---------------------------------------------------------------- overlays */
.drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 16, 32, .8); color: var(--white); font-size: 1.3rem; font-weight: 600; text-align: center;
  pointer-events: none;
}
.drop-overlay > div { padding: 40px 48px; border: 2px dashed var(--cyan); border-radius: 24px; }
.drop-overlay b { color: var(--cyan); font-family: var(--mono); font-weight: 500; }

.modal {
  width: min(480px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 20px;
  color: var(--text); background: var(--white); box-shadow: 0 40px 80px -30px rgba(10, 16, 32, .6);
}
.modal::backdrop { background: rgba(10, 16, 32, .55); }
.modal h2 { margin: 0 0 8px; font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.modal p { margin: 0 0 20px; color: var(--pencil); white-space: pre-line; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; max-width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--white); border: 1px solid var(--line-dark);
  font-size: .9rem; text-align: center; box-shadow: 0 20px 40px -20px rgba(10, 16, 32, .6);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* below an iPad held landscape (1024 × 768) the tools don't fit, so ask for a wider screen */
.too-small {
  display: none; position: fixed; inset: 0; z-index: 100; place-items: center; padding: 24px; text-align: center;
  background: var(--blueprint), var(--ink); color: var(--body-dark);
}
.too-small > div { display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.too-small strong { color: var(--white); font-size: 1.3rem; }
@media (max-width: 979px) { .too-small { display: grid; } }

/* narrower laptops and tablets: tighten the header */
@media (max-width: 1180px) {
  .app-prefix, .wide-only { display: none; }
  .rank-chip { min-width: 140px; }
}
@media (max-width: 1100px) {
  .brand-text { display: none; }
}

/* ---------------------------------------------------------------- automatic checks page (?tests) */
.tests h2 { margin: 0 0 8px; font-weight: 800; font-size: 1.5rem; }
.tests h3 { margin: 20px 0 6px; font: 700 .72rem/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--pencil); }
.tests ul { list-style: none; margin: 0; padding: 0; font: 500 .82rem/1.7 var(--mono); }
.tests-pass, .tests .pass { color: #13804a; }
.tests-fail, .tests .fail { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
