/* ============================================================
   mv-md3.css — Material Design 3 (Material You) surface layer.

   Sourced from the material-3 skill: MD3 colour roles, the 15-step type
   scale, and the 9-step shape scale.

   HARD CONSTRAINT: layout is unchanged. This sheet sets no width,
   height, min/max, margin, padding, gap, grid, flex or position. Only
   colour, background, border, radius, shadow, font and opacity.
   ============================================================ */

:root {
  /* ---- MD3 colour roles ------------------------------------------
     Generated from the site's existing seed hues: blue #2d70b6 and
     cyan #62c8df. Primary is the blue, secondary the cyan, tertiary a
     complementary teal so result states never fight the accents. */
  --md-sys-color-primary: #2d70b6;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d6e3ff;
  --md-sys-color-on-primary-container: #001b3d;

  --md-sys-color-secondary: #00687a;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #a8edfc;
  --md-sys-color-on-secondary-container: #001f26;

  --md-sys-color-tertiary: #00696b;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #9cf1f2;
  --md-sys-color-on-tertiary-container: #002020;

  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;

  /* Surfaces: the 5-step container hierarchy MD3 uses for depth */
  --md-sys-color-surface: #fdfcff;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-on-surface-variant: #42474e;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f7f9fc;
  --md-sys-color-surface-container: #f1f4f9;
  --md-sys-color-surface-container-high: #ebeef3;
  --md-sys-color-surface-container-highest: #e5e8ed;
  --md-sys-color-surface-dim: #d9dde3;
  --md-sys-color-surface-bright: #fdfcff;

  --md-sys-color-inverse-surface: #2f3033;
  --md-sys-color-inverse-on-surface: #f1f0f4;
  --md-sys-color-inverse-primary: #a6c8ff;

  --md-sys-color-outline: #72777f;
  --md-sys-color-outline-variant: #c2c7cf;

  /* ---- Shape scale ------------------------------------------------- */
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* ---- Elevation: MD3 uses tonal overlays, not hard shadows --------- */
  --md-sys-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-2: 0 1px 2px rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.30);

  /* Roboto is MD3's typeface; the stack degrades gracefully */
  --md-sys-typescale-font: Roboto, "Helvetica Neue", -apple-system,
                           BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

/* ---- Type scale: letter-spacing and weight only. --------------------
   Font-size is set exclusively on pure text nodes; no component box
   receives a size change, so nothing reflows a container. */
body, input, select, textarea, button {
  font-family: var(--md-sys-typescale-font);
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface);
}

h1 {
  font-weight: 400;
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface);
}

h2, h3 {
  font-weight: 400;
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface);
}

h4, h5, h6 {
  font-weight: 500;
  letter-spacing: 0.15px;
  color: var(--md-sys-color-on-surface);
}

/* Body roles: 0.5px tracking at 16px, 0.25px at 14px */
p, li, .desc, .sub { color: var(--md-sys-color-on-surface-variant); }

small, .muted, .hint { color: var(--md-sys-color-on-surface-variant); }

/* Labels: MD3 labels are medium weight with positive tracking */
.badge, .bdge, .free-badge, .chip, .tag, .tier {
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

button, .btn {
  font-weight: 500;
  letter-spacing: 0.1px;
  text-transform: none;
}

a { color: var(--md-sys-color-primary); }

/* ---- Buttons: fully-rounded MD3 filled button --------------------- */
button, .btn, .btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-full);
  box-shadow: none;
  transition: background-color 200ms cubic-bezier(0.2, 0, 0, 1),
              box-shadow 200ms cubic-bezier(0.2, 0, 0, 1),
              transform 120ms cubic-bezier(0.2, 0, 0, 1);
}

/* MD3 state layers: hover 8%, focus 10%, pressed 12% of primary */
@media (hover: hover) and (pointer: fine) {
  button:hover, .btn:hover, .btn-primary:hover {
    background-color: color-mix(in srgb,
      var(--md-sys-color-on-primary) 8%, var(--md-sys-color-primary));
    box-shadow: var(--md-sys-elevation-1);
  }
}

.btn-outline, button.secondary, .btn-secondary {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}
.btn-outline:hover, button.secondary:hover {
  background-color: color-mix(in srgb,
    var(--md-sys-color-primary) 8%, transparent);
}

/* ---- Cards: tonal surface-container, no border, elevation only ----
   This is the most visible MD3 signature: nested containers expressed
   as tonal steps rather than drawn outlines. */
.card, .tcard, .list-item, .option-card, .panel, .box, .qcard {
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: none;
  transition: background-color 200ms cubic-bezier(0.2, 0, 0, 1),
              box-shadow 200ms cubic-bezier(0.2, 0, 0, 1);
}

@media (hover: hover) and (pointer: fine) {
  .card:hover, .tcard:hover, .list-item:hover, .option-card:hover {
    background-color: var(--md-sys-color-surface-container);
    box-shadow: var(--md-sys-elevation-1);
  }
}

/* ---- Top app bar: surface-container with a hairline outline -------- */
.hdr, header, .appbar, nav.top {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: none;
}
.hdr a, header a, .appbar a { color: var(--md-sys-color-on-surface); }

/* ---- Chips and badges: outlined assist-chip style ------------------ */
.badge, .bdge, .free-badge, .free-bdge, .chip, .tag, .tier {
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
}

/* Selected / paid chip uses the secondary container, MD3's convention */
.tier[data-tier="pro"], .chip.pro, .tag.pro {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* ---- Options (quiz): MD3 selectable list items --------------------- */
.opt, .option-card {
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: none;
  transition: background-color 160ms cubic-bezier(0.2, 0, 0, 1),
              border-color 160ms cubic-bezier(0.2, 0, 0, 1),
              transform 120ms cubic-bezier(0.2, 0, 0, 1);
}

@media (hover: hover) and (pointer: fine) {
  .opt:hover:not([disabled]), .option-card:hover:not([disabled]) {
    background-color: color-mix(in srgb,
      var(--md-sys-color-primary) 8%, var(--md-sys-color-surface-container-low));
    border-color: var(--md-sys-color-outline);
  }
}

/* Result states use the error / primary-container roles MD3 defines */
.opt.is-correct, .option-card.is-correct {
  background-color: #c8efd4;
  color: #00210f;
  border-color: transparent;
}

.opt.is-incorrect, .option-card.is-incorrect {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-color: transparent;
}

/* ---- Inputs: MD3 outlined text field ------------------------------- */
input, select, textarea {
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  box-shadow: none;
  transition: border-color 160ms cubic-bezier(0.2, 0, 0, 1),
              box-shadow 160ms cubic-bezier(0.2, 0, 0, 1);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}

/* ---- Explanation / snackbar-like panels ---------------------------- */
#expl, #expBox, .expl-box {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-medium);
}

/* The "no answer key" notice uses the MD3 tertiary container so it
   reads as informational rather than as an error. */
#zvNoKey {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-medium);
}

/* ---- Dividers use outline-variant, never outline (MD3 rule) -------- */
td { border-bottom: 1px solid var(--md-sys-color-outline-variant); }
th {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--md-sys-color-outline);
}
tr:last-child td { border-bottom: none; }

/* ---- Focus ring: MD3 uses the primary role ------------------------ */
:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ---- Dark scheme: MD3's own dark surface ramp ---------------------
   Scoped to the site's toggle, exactly as before — the OS preference
   must not flip this site on its own. */
[data-mvtheme="dark"], .dark, html.dark body {
  --md-sys-color-primary: #a6c8ff;
  --md-sys-color-on-primary: #00315e;
  --md-sys-color-primary-container: #15497e;
  --md-sys-color-on-primary-container: #d6e3ff;

  --md-sys-color-surface: #111316;
  --md-sys-color-on-surface: #e2e2e6;
  --md-sys-color-on-surface-variant: #c2c7cf;
  --md-sys-color-surface-container-lowest: #0c0e11;
  --md-sys-color-surface-container-low: #191c1f;
  --md-sys-color-surface-container: #1d2023;
  --md-sys-color-surface-container-high: #272a2e;
  --md-sys-color-surface-container-highest: #323539;

  --md-sys-color-outline: #8c9199;
  --md-sys-color-outline-variant: #42474e;

  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;
  --md-sys-color-tertiary-container: #004f50;
  --md-sys-color-on-tertiary-container: #9cf1f2;
}

[data-mvtheme="dark"] body, .dark body, html.dark body {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

[data-mvtheme="dark"] .opt.is-correct, .dark .opt.is-correct {
  background-color: #0f5223;
  color: #c8efd4;
}

/* ---- Reduced motion: MD3 keeps colour feedback, drops movement ----- */
@media (prefers-reduced-motion: reduce) {
  button, .btn, .card, .tcard, .list-item, .opt, .option-card, input, select, textarea {
    transition-duration: 1ms !important;
  }
}
