/* ==========================================================================
   Friendrelaypoppis – shared stylesheet
   Contemporary Interactive Education Workspace
   ========================================================================== */

:root {
  /* Brand palette */
  --primary: #635BDB;
  --primary-dark: #4B43BF;
  --secondary: #20A89A;
  --secondary-dark: #137A6F;   /* AA-contrast teal for text/buttons with white text */
  --accent: #FFB85C;
  --bg: #F5F7FC;
  --surface: #FFFFFF;
  --text: #20243A;
  --muted: #737B91;            /* decorative / large text */
  --muted-text: #565E75;       /* AA-contrast muted text */
  --line: #E2E6F3;

  /* Subject colours */
  --math: #5B6EE1;
  --science: #1DAA92;
  --english: #D978A7;
  --history: #E7A642;
  --languages: #5E9DE6;
  --cs: #8B68D9;

  /* Type */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  /* Radii / spacing / shadows / motion */
  --r-sm: 10px; --r-md: 18px; --r-lg: 28px; --r-pill: 999px;
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem; --sp-8: 5rem;
  --shadow-sm: 0 2px 8px rgba(32, 36, 58, .06);
  --shadow-md: 0 10px 30px rgba(32, 36, 58, .10);
  --shadow-lg: 0 24px 60px rgba(99, 91, 219, .20);
  --t-fast: .18s; --t-med: .35s; --ease: cubic-bezier(.2, .7, .2, 1);
}

/* Subject colour hooks */
[data-subject="math"] { --subj: var(--math); }
[data-subject="science"] { --subj: var(--science); }
[data-subject="english"] { --subj: var(--english); }
[data-subject="history"] { --subj: var(--history); }
[data-subject="languages"] { --subj: var(--languages); }
[data-subject="cs"] { --subj: var(--cs); }
[data-subject="other"] { --subj: var(--primary); }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.65; color: var(--text); background: var(--bg); }
img, svg { max-width: 100%; display: block; }
h1, h2, h3, .h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2.3rem, 6vw, 4.2rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.5rem); }
h3, .h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--primary-dark); text-underline-offset: 3px; }
a:hover { color: var(--primary); }
code { background: #ECEEF9; padding: .1em .4em; border-radius: 6px; font-size: .92em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; box-shadow: 0 0 0 6px #fff; border-radius: 6px; }
main:focus { outline: none; }
.container { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
.sr-only { position: absolute !important; 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: 1rem; top: -4rem; background: var(--text); color: #fff; padding: .6rem 1rem; border-radius: var(--r-sm); z-index: 100; }
.skip-link:focus { top: 1rem; }
.center { text-align: center; }
.tiny { font-size: .85rem; color: var(--muted-text); }
.muted { color: var(--muted-text); }
.lead { font-size: 1.2rem; color: var(--muted-text); max-width: 62ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; font-weight: 700; color: var(--secondary-dark); margin-bottom: .6rem; }
.text-link { font-weight: 600; }
.grad-text { background: linear-gradient(100deg, var(--primary), var(--secondary)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Header (NOT sticky/fixed: scrolls away with the page) ---------- */
.site-header { position: relative; background: rgba(255, 255, 255, .85); border-bottom: 1px solid var(--line); z-index: 20; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .85rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--primary); }
.brand-mark { width: 38px; height: 38px; flex: none; border-radius: 10px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='16' fill='%23635BDB'/%3E%3Cpath d='M12 20c7-3 14-3 20 2 6-5 13-5 20-2v26c-7-3-14-3-20 2-6-5-13-5-20-2z' fill='%23fff'/%3E%3Cpath d='M32 22v26' stroke='%23635BDB' stroke-width='2'/%3E%3Cpath d='M48 6l2.4 5 5.6.8-4 4 1 5.6-5-2.7-5 2.7 1-5.6-4-4 5.6-.8z' fill='%23FFB85C'/%3E%3C/svg%3E") center/cover no-repeat; }
.primary-nav ul { list-style: none; display: flex; gap: .3rem; margin: 0; padding: 0; }
.primary-nav a { display: block; padding: .5rem .9rem; border-radius: var(--r-pill); color: var(--text); text-decoration: none; font-weight: 600; font-size: .98rem; transition: background var(--t-fast); }
.primary-nav a:hover { background: #ECEEF9; }
.primary-nav a[aria-current="page"] { background: var(--primary); color: #fff; }
.nav-toggle { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); width: 46px; height: 46px; cursor: pointer; align-items: center; justify-content: center; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; position: relative; transition: transform var(--t-fast); }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -7px; } .nav-toggle-bars::after { top: 7px; }
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .js .primary-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md); padding: .75rem 1.25rem 1rem; }
  .js .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; }
  .primary-nav a { padding: .8rem 1rem; }
}

/* ---------- Buttons & chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 700; font-size: .98rem; padding: .7rem 1.2rem; border-radius: var(--r-pill); border: 2px solid transparent; cursor: pointer; text-decoration: none; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), background var(--t-fast); line-height: 1.2; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary-dark); color: #fff; }
.btn-secondary:hover { background: #0F655C; color: #fff; }
.btn-accent { background: var(--accent); color: var(--text); }
.btn-accent:hover { background: #FFA939; color: var(--text); }
.btn-outline { background: var(--surface); color: var(--primary-dark); border-color: var(--primary); }
.btn-outline:hover { background: #F0EFFD; color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-lg { padding: .9rem 1.6rem; font-size: 1.05rem; }
.btn-sm { padding: .45rem .9rem; font-size: .88rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { --subj: var(--primary); display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .92rem; font-weight: 600; padding: .45rem .95rem; border-radius: var(--r-pill); border: 2px solid color-mix(in srgb, var(--subj) 35%, white); background: color-mix(in srgb, var(--subj) 8%, white); color: var(--text); cursor: pointer; text-decoration: none; transition: transform var(--t-fast) var(--ease), background var(--t-fast), color var(--t-fast); }
.chip:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--subj) 18%, white); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--subj); border-color: var(--subj); color: #fff; }
.chip[data-subject="history"][aria-pressed="true"] { color: var(--text); }
.chip-icon { font-weight: 800; }

.badge { --subj: var(--primary); display: inline-block; font-size: .76rem; font-weight: 700; letter-spacing: .02em; padding: .2rem .65rem; border-radius: var(--r-pill); background: color-mix(in srgb, var(--subj) 14%, white); color: color-mix(in srgb, var(--subj) 45%, var(--text)); }
.badge-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }
.badge-more { --subj: var(--muted); }

/* ---------- Hero: Interactive Learning Orbit ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(2rem, 5vw, 4.5rem) 0 clamp(2.5rem, 5vw, 4rem); background:
  radial-gradient(900px 500px at 85% 10%, rgba(99, 91, 219, .16), transparent 60%),
  radial-gradient(700px 420px at 0% 100%, rgba(32, 168, 154, .14), transparent 60%),
  radial-gradient(500px 300px at 60% 100%, rgba(255, 184, 92, .20), transparent 60%); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem; align-items: center; }
.hero-copy { position: relative; z-index: 3; }
.hero-copy h1 { margin-bottom: .35em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1.4rem 0 1rem; }
.encourage { display: inline-block; background: rgba(255, 255, 255, .8); border: 1px dashed var(--accent); border-radius: var(--r-md); padding: .55rem 1rem; font-size: .95rem; color: var(--text); margin: 0; }

.search-form { position: relative; margin: 1.4rem 0 1rem; max-width: 640px; }
.search-box { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-pill); padding: .4rem .45rem .4rem 1.1rem; box-shadow: var(--shadow-md); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.search-box:focus-within { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.search-icon { width: 20px; height: 20px; flex: none; border: 3px solid var(--muted); border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; width: 3px; height: 9px; background: var(--muted); right: -4px; bottom: -7px; transform: rotate(-45deg); border-radius: 2px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; background: transparent; padding: .6rem .2rem; color: var(--text); }
.search-box input:focus-visible { box-shadow: none; }
.suggest-list { list-style: none; margin: .5rem 0 0; padding: .4rem; position: absolute; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-lg); z-index: 15; max-height: 340px; overflow: auto; }
.suggest-list a { display: block; padding: .6rem .8rem; border-radius: var(--r-sm); text-decoration: none; color: var(--text); }
.suggest-list a:hover, .suggest-list a:focus-visible { background: #F0EFFD; }
.suggest-list a span { display: block; font-size: .85rem; color: var(--muted-text); }
.suggest-empty { padding: .7rem .8rem; color: var(--muted-text); font-size: .95rem; }
.subject-shortcuts { display: flex; flex-wrap: wrap; gap: .5rem; }

.orbit-stage { position: relative; min-height: 500px; z-index: 1; }
.layer { position: absolute; pointer-events: none; transform: translate3d(calc(var(--mx, 0) * var(--depth, 0) * 1px), calc(var(--my, 0) * var(--depth, 0) * 1px), 0); transition: transform .3s ease-out; }
.float { animation: float var(--dur, 8s) ease-in-out infinite; animation-delay: var(--delay, 0s); }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 50% { transform: translateY(-14px) rotate(calc(var(--rot, 0deg) + 2deg)); } }
.float-card { background: var(--surface); border-radius: var(--r-md); padding: .9rem 1rem; box-shadow: var(--shadow-md); border: 1px solid var(--line); }
.float-card p { margin: 0; font-weight: 700; }
.fc-label { --subj: var(--primary); display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .5rem; border-radius: var(--r-pill); margin-bottom: .4rem; background: color-mix(in srgb, var(--subj) 16%, white); color: color-mix(in srgb, var(--subj) 45%, var(--text)); }
.formula-small { font-size: .8rem; font-weight: 500 !important; color: var(--muted-text); }
.l-formula { top: 2%; left: 0; width: 190px; }
.l-science { bottom: 4%; left: 2%; width: 160px; }
.l-flash { top: 6%; right: 0; width: 170px; perspective: 600px; }
.flash-3d { transform-style: preserve-3d; background: linear-gradient(135deg, #fff, #F0EFFD); border-bottom: 5px solid var(--cs); }
.l-book { bottom: 6%; right: 6%; }
.css-book { width: 88px; height: 112px; background: linear-gradient(135deg, var(--primary), #8F89F0); border-radius: 6px 14px 14px 6px; box-shadow: inset 9px 0 0 rgba(0, 0, 0, .18), 5px 5px 0 #fff, 7px 7px 0 #D9DCF1, 12px 14px 24px rgba(32, 36, 58, .25); position: relative; }
.css-book::after { content: ""; position: absolute; left: 22px; top: 26px; width: 44px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .8); box-shadow: 0 14px 0 rgba(255, 255, 255, .55); }
.shape { display: block; }
.shape-ring { width: 80px; height: 80px; border-radius: 50%; border: 10px solid rgba(255, 184, 92, .6); }
.shape-tri { width: 0; height: 0; border-left: 28px solid transparent; border-right: 28px solid transparent; border-bottom: 48px solid rgba(32, 168, 154, .45); }
.shape-dot { width: 22px; height: 22px; border-radius: 50%; background: rgba(217, 120, 167, .7); }
.l-shape1 { top: 38%; left: -6%; } .l-shape2 { top: 2%; left: 48%; } .l-shape3 { bottom: 30%; right: -2%; }
.l-goal { top: 50%; left: 50%; margin: -150px 0 0 -145px; width: 290px; pointer-events: auto; }
.goal-card { background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.2rem; text-align: center; box-shadow: var(--shadow-lg); }
.goal-title { font-family: var(--font-body); font-size: .95rem; font-weight: 700; letter-spacing: .02em; margin-bottom: .6rem; }
.goal-ring-wrap { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #E6E9F6; stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--secondary); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: .95rem; }
.goal-note { margin: .6rem 0; font-size: .92rem; color: var(--muted-text); }
.goal-controls { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-bottom: .4rem; }
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .orbit-stage { min-height: 440px; max-width: 560px; width: 100%; margin-inline: auto; }
}
@media (max-width: 600px) {
  .orbit-stage { min-height: 0; }
  .layer:not(.l-goal) { display: none; }
  .l-goal { position: static; margin: 0 auto; width: 100%; max-width: 320px; }
}

/* ---------- Sections & cards ---------- */
.section { padding: clamp(2.5rem, 6vw, 5rem) 0; }
.section-tight { padding: 2rem 0 4rem; }
.section-tint { background: linear-gradient(180deg, #ECEEF9, var(--bg)); }
.section-head { max-width: 760px; margin-bottom: 2rem; }
.page-hero { padding: clamp(2.5rem, 6vw, 4.5rem) 0 1rem; background: radial-gradient(700px 300px at 90% 0%, rgba(99, 91, 219, .14), transparent 70%); }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.2rem; margin: 0 0 1rem; font-weight: 600; color: var(--muted-text); }
.status-line p { margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.4rem; }
.resource-card, .guide-card { --subj: var(--primary); background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: transform var(--t-med) var(--ease), box-shadow var(--t-med); border-top: 5px solid var(--subj); }
.guide-card { border-top-width: 1px; }
.resource-card:hover, .guide-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.card-media { margin: 0; aspect-ratio: 3 / 2; overflow: hidden; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.resource-card:hover img, .guide-card:hover img { transform: scale(1.05); }
.card-body { padding: 1.2rem 1.3rem 1.4rem; display: flex; flex-direction: column; flex: 1; }
.card-body h3, .card-body .h3 { margin-bottom: .4rem; }
.card-body p { color: var(--muted-text); font-size: .98rem; }
.meta-list { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .86rem; color: var(--muted-text); display: grid; gap: .25rem; }
.meta-list li::before { content: "•"; color: var(--secondary); margin-right: .4rem; }
.card-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: .6rem; }
.card-actions .btn { flex: 1 1 auto; font-size: .9rem; padding: .6rem .8rem; }
.empty-state { text-align: center; padding: 2rem; border: 2px dashed var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--muted-text); grid-column: 1 / -1; }
.empty-state h3 { color: var(--text); }
.loading-state { color: var(--muted-text); grid-column: 1 / -1; }
.panel { background: rgba(255, 255, 255, .85); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(1.2rem, 3vw, 2rem); box-shadow: var(--shadow-sm); }

/* Reveal animation (JS only, disabled for reduced motion) */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* Goal chooser */
.goal-layout { display: grid; grid-template-columns: 1fr 1.3fr; gap: 1.5rem; align-items: start; }
.goal-options { display: grid; gap: .7rem; }
.goal-option { text-align: left; font: inherit; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-md); padding: .9rem 1.1rem; cursor: pointer; display: grid; gap: .15rem; transition: transform var(--t-fast) var(--ease), border-color var(--t-fast), background var(--t-fast); color: var(--text); }
.goal-option span { font-size: .9rem; color: var(--muted-text); }
.goal-option:hover { transform: translateX(4px); border-color: var(--primary); }
.goal-option[aria-pressed="true"] { border-color: var(--primary); background: #F0EFFD; box-shadow: inset 5px 0 0 var(--primary); }
.goal-output:focus { outline: none; }
.goal-output ol, .goal-output ul { padding-left: 1.2rem; }
.goal-output .out-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pop-in { animation: popIn .45s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) { .goal-layout { grid-template-columns: 1fr; } }

/* Tool tiles, how it works, guides */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.2rem; }
.tool-tile { --subj: var(--primary); display: block; padding: 1.4rem; background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); text-decoration: none; color: var(--text); position: relative; overflow: hidden; transition: transform var(--t-med) var(--ease), box-shadow var(--t-med); }
.tool-tile::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%; background: color-mix(in srgb, var(--subj) 16%, white); }
.tool-tile:hover { transform: translateY(-6px) rotate(-.5deg); box-shadow: var(--shadow-lg); color: var(--text); }
.tool-tile p { color: var(--muted-text); position: relative; z-index: 1; margin: 0; }
.tool-tile h3 { position: relative; z-index: 1; }
.tool-ico { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--subj); color: #fff; font-weight: 800; margin-bottom: .8rem; position: relative; z-index: 1; }
.tool-tile[data-subject="history"] .tool-ico { color: var(--text); }
.guide-feature-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 1.4rem; margin-bottom: 2rem; }
.guide-card-lg .card-media { aspect-ratio: 4 / 3; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.2rem; }
.guide-grid .card-media { aspect-ratio: 16 / 10; }
@media (max-width: 900px) { .guide-feature-grid { grid-template-columns: 1fr; } }
.how-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.2rem; counter-reset: s; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.4rem; }
.step:nth-child(even) { transform: translateY(14px); }
.step-num { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); font-weight: 800; margin-bottom: .6rem; }
.integrity { background: linear-gradient(135deg, var(--primary), #4B43BF 60%, var(--secondary-dark)); color: #fff; border-radius: var(--r-lg); padding: clamp(1.6rem, 4vw, 3rem); }
.integrity p { max-width: 70ch; color: #EEF0FF; }

/* ---------- Footer ---------- */
.site-footer { background: #171A2E; color: #D6DAEE; margin-top: 3rem; padding: 3rem 0 2rem; font-size: .95rem; }
.site-footer a { color: #fff; }
.site-footer :focus-visible { outline-color: var(--accent); box-shadow: none; }
.site-footer h2 { font-family: var(--font-body); font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: .8rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.site-footer address { font-style: normal; }
.site-footer address p { margin: 0 0 .4rem; }
.site-footer .tiny { color: #A9AFCB; }
.brand-light { color: #fff; margin-bottom: .6rem; }
.brand-light:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.4fr; gap: 2rem; }
.footer-legal { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid rgba(255, 255, 255, .14); font-size: .82rem; color: #B7BCD6; }
.copyright { color: #fff; font-weight: 600; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
.field { display: grid; gap: .3rem; }
.field-grow { flex: 1 1 220px; }
.field label, legend { font-weight: 700; font-size: .88rem; }
input[type="text"], input[type="search"], input[type="number"], select { font: inherit; padding: .65rem .8rem; border: 2px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text); min-width: 0; width: 100%; }
input:focus, select:focus { border-color: var(--primary); }
.form-row, .filter-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; margin-bottom: .8rem; }
.filter-row .field { flex: 1 1 160px; }
.filter-panel { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.chip-fieldset { border: 0; padding: 0; margin: 0; }
.chip-fieldset legend { margin-bottom: .4rem; padding: 0; }
.field-btn { flex: 0 0 auto !important; }
.error-text { color: #B3261E; font-weight: 600; min-height: 1.4em; margin: 0 0 .5rem; font-size: .92rem; }
.success-text { color: var(--secondary-dark); font-weight: 700; }
progress { width: 100%; height: 12px; border-radius: var(--r-pill); accent-color: var(--secondary); }
progress { -webkit-appearance: none; appearance: none; border: 0; background: #E6E9F6; overflow: hidden; }
progress::-webkit-progress-bar { background: #E6E9F6; border-radius: var(--r-pill); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--secondary), var(--primary)); border-radius: var(--r-pill); transition: width .5s var(--ease); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--secondary), var(--primary)); border-radius: var(--r-pill); }

/* ---------- Study tools ---------- */
.jump-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.tools-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.tool-wide { grid-column: 1 / -1; }
.tool-panel { scroll-margin-top: 1rem; }
.task-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .5rem; }
.task { --subj: var(--primary); display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--subj); border-radius: var(--r-sm); }
.task input { width: 22px; height: 22px; accent-color: var(--secondary-dark); flex: none; }
.task label { flex: 1; cursor: pointer; }
.task .t-meta { font-size: .8rem; color: var(--muted-text); display: block; }
.task.done label { text-decoration: line-through; color: var(--muted-text); }
.task.pop { animation: popIn .5s var(--ease); background: #E6F7F4; }
.icon-btn { background: transparent; border: 0; cursor: pointer; font-size: 1.1rem; padding: .3rem .5rem; border-radius: var(--r-sm); color: var(--muted-text); }
.icon-btn:hover { background: #FDECEC; color: #B3261E; }
.progress-block { margin: 1rem 0 0; }
.timer-wrap { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
.timer-ring { width: 170px; height: 170px; margin: 0; }
.timer-ring .ring-label strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: .6rem 0; }
.center-row { justify-content: center; }
@media (max-width: 540px) { .timer-wrap { grid-template-columns: 1fr; justify-items: center; } .timer-side { width: 100%; } }
.flash-count { font-weight: 700; color: var(--muted-text); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .8rem 0; }
.flip-card { --subj: var(--primary); display: block; width: 100%; min-height: 220px; background: none; border: 0; padding: 0; cursor: pointer; perspective: 1000px; font: inherit; color: var(--text); text-align: center; margin: .5rem 0 .8rem; }
.flip-inner { position: relative; display: block; width: 100%; min-height: 220px; transform-style: preserve-3d; transition: transform .6s var(--ease); }
.flip-card.is-flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1.4rem; border-radius: var(--r-lg); backface-visibility: hidden; -webkit-backface-visibility: hidden; font-weight: 600; font-size: 1.2rem; line-height: 1.4; box-shadow: var(--shadow-md); }
.face.front { background: var(--surface); border: 3px solid var(--subj); border-bottom-width: 8px; }
.face.back { background: var(--subj); color: #fff; transform: rotateY(180deg); }
.flip-card[data-subject="history"] .face.back { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.quiz-options { display: grid; gap: .6rem; margin: 1rem 0; }
.quiz-option { font: inherit; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-md); padding: .8rem 1rem; cursor: pointer; color: var(--text); transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast); }
.quiz-option:hover:not([disabled]) { border-color: var(--primary); transform: translateX(3px); }
.quiz-option[disabled] { cursor: default; }
.quiz-option.correct { border-color: var(--secondary-dark); background: #E3F6F3; }
.quiz-option.wrong { border-color: #B3261E; background: #FDECEC; }
.quiz-feedback { min-height: 3.2em; margin-bottom: 1rem; }
.quiz-feedback p { margin: 0; }
.quiz-result { text-align: center; animation: popIn .5s var(--ease); }
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1rem 0; }
.p-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem; }
.p-tile h3 { font-family: var(--font-body); font-size: 1rem; }
.p-tile p { font-size: .92rem; color: var(--muted-text); margin-bottom: .6rem; }
.overall { font-weight: 700; }
dialog { border: 0; border-radius: var(--r-lg); padding: 1.8rem; max-width: min(460px, 92vw); box-shadow: var(--shadow-lg); color: var(--text); }
dialog::backdrop { background: rgba(23, 26, 46, .55); }
dialog h2 { font-size: 1.5rem; }

/* ---------- Detail page ---------- */
.breadcrumb { font-size: .92rem; color: var(--muted-text); margin-bottom: 1.2rem; }
.detail-hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; margin-bottom: 2rem; }
.detail-hero figure { margin: 0; }
.detail-hero img { border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.detail-hero figcaption { font-size: .8rem; color: var(--muted-text); margin-top: .5rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.detail-layout { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.5rem; align-items: start; }
.detail-main section { margin-bottom: 1.5rem; }
.detail-main h2 { font-size: 1.6rem; }
.detail-main ul, .detail-main ol { padding-left: 1.2rem; }
.detail-main li { margin-bottom: .4rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.pros { border-left: 5px solid var(--secondary); } .cons { border-left: 5px solid var(--accent); }
.glance dl { margin: 0; display: grid; gap: .8rem; }
.glance dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-text); font-weight: 700; }
.glance dd { margin: 0; font-weight: 600; }
.note-box { background: #FFF6E8; border: 1px solid #F6DDB4; border-radius: var(--r-md); padding: 1rem 1.2rem; font-size: .95rem; }
.related-list { list-style: none; padding: 0 !important; display: grid; gap: .5rem; }
.related-list a { font-weight: 600; }
@media (max-width: 900px) { .detail-hero, .detail-layout, .two-col { grid-template-columns: 1fr; } }

/* ---------- Guide & prose ---------- */
.prose { max-width: 760px; }
.prose h2 { font-size: 1.6rem; margin-top: 1.8rem; }
.prose-wide { max-width: 900px; display: grid; gap: 1.5rem; }
.guide-article h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.steps-list { padding-left: 1.2rem; }
.steps-list li { margin-bottom: .5rem; }
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; background: var(--surface); border-radius: var(--r-sm); overflow: hidden; }
th, td { padding: .65rem .8rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: #ECEEF9; }
.check-list { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.check-list li { display: flex; gap: .6rem; align-items: flex-start; }
.check-list input { width: 20px; height: 20px; margin-top: .25rem; accent-color: var(--secondary-dark); flex: none; }
details.exercise { background: #F0EFFD; border-radius: var(--r-md); padding: .8rem 1.1rem; margin: 1rem 0; }
details summary { cursor: pointer; font-weight: 700; }
details details { margin-top: .6rem; background: #fff; padding: .5rem .8rem; border-radius: var(--r-sm); }
.related { font-size: .95rem; color: var(--muted-text); margin: 0; }
.guide-article[hidden], .guide-card[hidden] { display: none; }
.guide-article { scroll-margin-top: 1rem; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .js .reveal { opacity: 1; transform: none; }
  .float { animation: none; }
}