/* Civic Mosaic website: shared foundations, header, theme control, controls, question styles and footer, loaded before
   each page's own stylesheet (home.css or site.css). Colours and fonts come from tokens.css (generated from the app's
   theme): --world and its companions for the page around the sheets, which follow the visitor's theme. */

/* ---------- Foundations ---------- */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --margin: clamp(16px, 4vw, 56px);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --radius: 14px;
  scrollbar-color: var(--world-rule) var(--world-far);
}
html { background: var(--world-far); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--world);
  color: var(--on-world);
  font: 400 1.125rem/1.6 'Nunito', system-ui, sans-serif;
  font-variant-numeric: lining-nums;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset { margin: 0; }
h1, h2, h3, h4 { font-weight: 800; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
::selection { background: var(--world-action); color: var(--on-world-action); }
:focus-visible { outline: 2px solid var(--world-action); outline-offset: 3px; border-radius: 6px; }
.skip {
  position: absolute; left: var(--margin); top: 12px; z-index: 30;
  padding: 10px 16px; border-radius: 10px;
  background: var(--world-action); color: var(--on-world-action); font-weight: 800;
}
/* Clipped, not moved above the page: Safari's pull-down overscroll shows what sits above it. Screen readers still read it. */
.skip:not(:focus) { clip-path: inset(50%); }
/* Main takes focus only as the skip link's target; a ring round the whole page would mark nothing. */
#main:focus { outline: none; }

/* ---------- Header ---------- */
.site-header {
  position: absolute; inset: 0 0 auto; z-index: 10;
  display: flex; align-items: center; gap: 16px 32px; flex-wrap: wrap;
  padding: 20px var(--margin);
  max-width: 1440px; margin-inline: auto;
}
.brand { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; font-weight: 800; font-size: 1.25rem; text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; }
.site-header ul { display: flex; gap: 4px 28px; list-style: none; padding: 0; }
.site-header nav a { display: inline-block; padding: 10px 0; color: var(--on-world-muted); font-weight: 600; font-size: 1rem; text-decoration: none; transition: color 180ms ease; }
.site-header nav a:hover { color: var(--on-world); text-decoration: underline; }
.site-header nav a[aria-current="page"] { color: var(--on-world); text-decoration: underline; }

/* ---------- Theme control: System, Light, Dark (assets/theme.js) ----------
   A segmented control like the country switch, quieter: a neutral thumb, not indigo, so it never competes with the
   page's actions. The thumb follows data-theme on <html>, which the head's script sets before the first paint, so a
   saved choice shows at once. Hover shows the name on fine pointers; no motion. */
.theme-switch { display: inline-flex; gap: 2px; margin: 0; padding: 3px; min-inline-size: 0; border: 0; border-radius: 13px; background: var(--seg-track); box-shadow: inset 0 0 0 1px var(--world-edge); }
html:not(.js) .theme-switch { display: none; }
.theme-switch label { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--on-world-muted); cursor: pointer; }
.theme-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-switch svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) { .theme-switch label:hover { color: var(--on-world); } }
html:not([data-theme]) [data-theme-option="system"],
html[data-theme="light"] [data-theme-option="light"],
html[data-theme="dark"] [data-theme-option="dark"] { background: var(--seg-thumb); box-shadow: var(--seg-thumb-shadow); color: var(--on-world); }
.theme-switch label:has(input:focus-visible) { outline: 2px solid var(--world-action); outline-offset: 2px; }
/* Switching themes is instant: no colour fades in one by one (theme.js holds transitions for two frames). */
html.theme-instant, html.theme-instant *, html.theme-instant *::before, html.theme-instant *::after { transition: none !important; }

/* ---------- Shared controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--radius);
  font: 800 1.0625rem/1 'Nunito', sans-serif; text-decoration: none; cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 180ms ease;
}
.btn:active { transform: scale(0.97); }
.btn--world { min-height: 52px; background: var(--world-action); color: var(--on-world-action); }
@media (hover: hover) and (pointer: fine) { .btn--world:hover { background: var(--world-action-hover); } }
.btn--primary { width: 100%; background: var(--indigo); color: var(--on-indigo); }
.text-link { font-weight: 700; color: var(--on-world); }
.status { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--on-world); }
.status-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--world-action); flex: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

/* Mastery tiles: the app's shapes. Outline (not started), dot (learning), half (nearly there), full (mastered). */
.mt { position: relative; display: block; aspect-ratio: 1; border-radius: 2.5px; border: 1.25px solid var(--harbour-tile); }
.mt.l1::after { content: ''; position: absolute; inset: 35%; border-radius: 50%; background: var(--harbour-tile); }
.mt.l2 { border-color: var(--c); background: linear-gradient(to top, var(--c) 50%, transparent 50%); }
.mt.l3 { border-color: var(--c); background: var(--c); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend .mt { width: 14px; --c: var(--h1); }

/* ---------- Questions: answer options, the reveal and the answer (the home's screen and the practice pages) ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--selected); font-size: 0.8125rem; font-weight: 700; white-space: nowrap; }
.chip .sw { --c: var(--t0); }
.quiz { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.quiz fieldset { border: 0; padding: 0; min-width: 0; }
.q-text { display: block; float: left; width: 100%; padding: 0; margin: 0 0 12px; font-weight: 800; font-size: 1.1875rem; line-height: 1.3; letter-spacing: -0.005em; text-wrap: balance; }
.options { clear: both; display: grid; gap: 8px; }
.option {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); font-weight: 600; cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out);
}
label.option:active { transform: scale(0.985); }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option:has(input:focus-visible) { outline: 2px solid var(--indigo); outline-offset: 2px; }
.key { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--ground); border: 1px solid var(--line); font-size: 0.8125rem; font-weight: 800; color: var(--muted); }
.opt-text { flex: 1; line-height: 1.3; }
.tick { flex: none; width: 18px; height: 18px; }
.option:has(input:checked):not(.is-right, .is-wrong), .option.is-selected { border-color: var(--indigo); background: var(--selected); }
.option:has(input:checked):not(.is-right, .is-wrong) .key, .option.is-selected .key { background: var(--indigo); border-color: var(--indigo); color: var(--on-indigo); }
.option.is-right { border-color: var(--success); background: var(--success-bg); }
.option.is-right .key { background: var(--success); border-color: var(--success); color: var(--surface); }
.option.is-right .tick { background: var(--success); -webkit-mask: var(--icon-check) center / contain no-repeat; mask: var(--icon-check) center / contain no-repeat; }
.option.is-wrong { border-color: var(--danger); background: var(--danger-bg); }
.option.is-wrong .key { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.option.is-wrong .tick { background: var(--danger); -webkit-mask: var(--icon-cross) center / contain no-repeat; mask: var(--icon-cross) center / contain no-repeat; }
:root {
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 12.5l5 5 10-11' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.quiz.is-answered .option { cursor: default; }
.quiz-status:empty { display: none; }
.quiz-status { font-weight: 800; }
.quiz.is-correct .quiz-status { color: var(--success); }
.quiz.is-wrong .quiz-status, .quiz.is-shown .quiz-status { color: var(--ink); }
.quiz-actions { margin-top: auto; }
html:not(.js) .quiz-actions { display: none; }
.quiz.is-answered .quiz-actions { display: none; }
.reveal summary {
  display: flex; justify-content: center; align-items: center; min-height: 40px;
  font-weight: 700; color: var(--indigo); cursor: pointer; list-style: none; border-radius: 10px;
}
.reveal summary::-webkit-details-marker { display: none; }
.quiz.is-answered .reveal summary { display: none; }
.reveal-body { display: grid; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line); font-size: 0.875rem; line-height: 1.45; }
.quiz.is-correct .reveal-body { background: var(--success-bg); border-color: transparent; }
.quiz.is-answered .reveal-body .answer, .quiz.is-answered .reveal-body .accepted { display: none; }
.rl { font-weight: 800; margin-right: 4px; }
.answer { font-weight: 700; }
.why { color: var(--ink); }
.src { color: var(--muted); font-size: 0.8125rem; }
.src a, .reveal-body a { color: var(--indigo); }
.quiz-after { display: none; justify-content: space-between; align-items: center; font-size: 0.875rem; font-weight: 700; }
.quiz.is-answered .quiz-after { display: flex; margin-top: auto; }
.quiz-after a { color: var(--indigo); }
.quiz-after button { min-height: 40px; padding: 0 4px; border: 0; background: none; font: inherit; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Footer ---------- */
.site-footer { position: relative; z-index: 1; background: var(--world-far); color: var(--on-world-muted); font-size: 0.9375rem; box-shadow: inset 0 1px 0 var(--world-edge); }
.footer-inner { display: grid; gap: 12px; max-width: 1440px; margin-inline: auto; padding: 56px var(--margin) 64px; }
.footer-brand { font-weight: 800; font-size: 1.5rem; color: var(--on-world); }
.independence { color: var(--on-world); max-width: 46rem; }
.footer-nav ul { display: flex; flex-wrap: wrap; gap: 4px 24px; padding: 0; list-style: none; }
.footer-nav a { display: inline-block; padding-block: 6px; color: var(--on-world); font-weight: 700; }
.footer-nav a[aria-current="page"] { text-decoration: none; }

/* Something the owner still has to provide: plain to see, and `check.mjs --launch` fails while any remain. */
.placeholder { display: inline-block; padding: 6px 12px; border: 2px dashed #B45309; border-radius: 10px; background: #FEF3C7; color: #78350F; font-weight: 700; }

/* ---------- Phone and tablet ---------- */
@media (max-width: 1023px) {
  /* The brand and the theme control share the first row; the navigation has the second to itself. */
  .site-header { gap: 4px 12px; padding-top: 14px; }
  .site-header nav { order: 1; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .site-header ul { gap: 22px; white-space: nowrap; }
}

/* ---------- Reduced motion: gentler, not none ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn:active, label.option:active { transform: none; }
}
.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; }
