/* =========================================================
   MathsHub – Home page styles
   Colours, fonts and spacing live in :root so they're easy to tweak.
   ========================================================= */

:root {
  --ink: #1d1b3a;
  --ink-soft: #55547a;
  --bg: #fffdf8;
  --tint: #f3f0ff;
  --white: #ffffff;

  --purple: #6c4cf5;
  --purple-dark: #5235d6;
  --pink: #ff5c8a;
  --orange: #ff9f1c;
  --teal: #13c4a3;
  --blue: #3a86ff;
  --yellow: #ffd23f;

  --radius: 20px;
  --shadow: 0 10px 30px rgba(29, 27, 58, 0.08);
  --shadow-lg: 0 20px 50px rgba(29, 27, 58, 0.16);

  --font-head: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.container { width: min(1140px, 100% - 40px); margin-inline: auto; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.1; }
h2 { font-size: clamp(2rem, 4vw, 2.8rem); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  font-weight: 800;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.btn--lg { padding: 0.95rem 1.8rem; font-size: 1.05rem; }
.btn--primary {
  background: var(--purple); color: var(--white);
  box-shadow: 0 6px 0 var(--purple-dark);
}
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 9px 0 var(--purple-dark); }
.btn--primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--purple-dark); }
.btn--ghost { border-color: var(--ink); background: transparent; }
.btn--ghost:hover { background: var(--ink); color: var(--white); transform: translateY(-2px); }

.pill {
  display: inline-block;
  padding: .35rem .9rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--purple);
  font-weight: 800;
  font-size: .85rem;
  letter-spacing: .02em;
  margin-bottom: 1rem;
}
.pill--light { background: rgba(255,255,255,.12); color: var(--yellow); }

/* ---------- Navbar ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  padding: 1.1rem 0;
  transition: background .3s ease, padding .3s ease, box-shadow .3s ease;
}
.nav.is-scrolled {
  background: rgba(255, 253, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(29,27,58,.06);
  padding: .6rem 0;
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: .55rem; font-family: var(--font-head); font-weight: 700; font-size: 1.45rem; }
/* The logo icon (stacked tiles with a Σ, chosen 29 Nov 2026) is assets/img/logo.svg; it is also the favicon */
.logo__mark {
  display: block; flex: none;
  width: 40px; height: 40px;
  background: url("../img/logo.svg") center / contain no-repeat;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}
.logo:hover .logo__mark { transform: rotate(8deg) scale(1.1); }
.logo__io { color: var(--purple); }
.logo--small { font-size: 1.2rem; }
.logo--small .logo__mark { width: 32px; height: 32px; }

.nav__links { display: flex; align-items: center; gap: 1.6rem; font-weight: 700; }
.nav__links > a:not(.btn) { position: relative; }
.nav__links > a:not(.btn)::after {
  content: ""; position: absolute; left: 0; bottom: -4px;
  width: 100%; height: 3px; border-radius: 3px; background: var(--pink);
  transform: scaleX(0); transform-origin: right; transition: transform .3s ease;
}
.nav__links > a:not(.btn):hover::after { transform: scaleX(1); transform-origin: left; }

.nav__toggle { display: none; background: none; border: 0; cursor: pointer; width: 36px; height: 36px; position: relative; }
.nav__toggle span {
  position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 3px; background: var(--ink);
  transition: transform .3s ease, opacity .3s ease;
}
.nav__toggle span:nth-child(1) { top: 10px; }
.nav__toggle span:nth-child(2) { top: 17px; }
.nav__toggle span:nth-child(3) { top: 24px; }
.nav__toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.is-open span:nth-child(2) { opacity: 0; }
.nav__toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex; align-items: center;
  padding: 8rem 0 5rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(108,76,245,.10), transparent 40%),
    radial-gradient(circle at 85% 70%, rgba(255,92,138,.10), transparent 40%),
    var(--bg);
}
.hero__symbols { position: absolute; inset: 0; pointer-events: none; }
.symbol {
  position: absolute;
  font-family: var(--font-head);
  font-weight: 600;
  opacity: 0;
  animation: floatUp linear infinite, fadeIn 1.2s ease forwards;
  will-change: transform;
  user-select: none;
}
.symbol__inner { display: inline-block; transition: transform .6s cubic-bezier(.22,1,.36,1); }

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg); }
  50%  { transform: translateY(-40px) rotate(8deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes fadeIn { to { opacity: var(--o, .35); } }

.hero__content { position: relative; z-index: 2; text-align: center; max-width: 820px; }
.hero__title { font-size: clamp(2.8rem, 8vw, 5.5rem); margin-bottom: 1.2rem; }
.hero__highlight { position: relative; display: inline-flex; align-items: center; gap: .2em; color: var(--purple); }
.hero__highlight::after {
  content: ""; position: absolute; left: -2%; right: 18%; bottom: .06em; height: .22em;
  background: var(--yellow); border-radius: 6px; z-index: -1;
  transform: scaleX(0); transform-origin: left;
  animation: underline .8s .9s cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes underline { to { transform: scaleX(1); } }

.tick { width: .8em; height: .8em; }
.tick path {
  fill: none; stroke: var(--teal); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 50; stroke-dashoffset: 50;
  animation: draw .6s 1.5s ease forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.hero__sub { font-size: 1.2rem; color: var(--ink-soft); max-width: 620px; margin: 0 auto 2rem; }
.hero__cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.hero__stats { list-style: none; display: flex; justify-content: center; gap: 3rem; margin-top: 3.5rem; flex-wrap: wrap; }
.hero__stats li { display: flex; flex-direction: column; }
.hero__stats strong { font-family: var(--font-head); font-size: 2.2rem; color: var(--ink); }
.hero__stats span { color: var(--ink-soft); font-weight: 700; font-size: .9rem; }

.hero__scroll {
  position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%);
  width: 26px; height: 42px; border: 3px solid var(--ink); border-radius: 20px; z-index: 2;
}
.hero__scroll span {
  position: absolute; top: 7px; left: 50%; width: 5px; height: 8px; margin-left: -2.5px;
  background: var(--ink); border-radius: 3px; animation: scrollDot 1.6s ease-in-out infinite;
}
@keyframes scrollDot { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(14px); } }

/* ---------- Sections ---------- */
.section { padding: 6rem 0; }
.section--tint { background: var(--tint); }
.section--dark { background: var(--ink); color: var(--white); }
.section__head { text-align: center; max-width: 640px; margin: 0 auto 3.5rem; }
.section__head p { color: var(--ink-soft); font-size: 1.1rem; margin-top: .8rem; }

/* ---------- Topic tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.4rem; }
.tile {
  --c: var(--purple);
  position: relative;
  display: flex; flex-direction: column;
  padding: 1.8rem 1.5rem;
  border-radius: var(--radius);
  background: var(--c);
  color: var(--white);
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(0,0,0,.15);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .35s ease;
}
.tile::before {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.12); top: -60px; right: -60px;
  transition: transform .5s ease;
}
.tile:hover { transform: translateY(-10px) rotate(-1.5deg); box-shadow: 0 18px 0 rgba(0,0,0,.12); }
.tile:hover::before { transform: scale(1.4); }
.tile--pure   { --c: var(--purple); }
.tile--stats  { --c: var(--pink); }
.tile--mech   { --c: var(--blue); }
.tile--papers { --c: var(--teal); }
.tile__badge { font-size: .78rem; font-weight: 800; opacity: .85; letter-spacing: .04em; text-transform: uppercase; }
.tile__icon { font-family: var(--font-head); font-size: 2.6rem; font-weight: 700; margin: 1rem 0 .6rem; }
.tile h3 { font-size: 1.45rem; margin-bottom: .5rem; }
.tile p { opacity: .92; font-size: .95rem; flex: 1; }
.tile__go { margin-top: 1.2rem; font-weight: 800; transition: transform .3s ease; display: inline-block; }
.tile:hover .tile__go { transform: translateX(6px); }

.papers-banner {
  margin-top: 2rem;
  display: flex; align-items: center; gap: 1rem;
  padding: 1.2rem 1.6rem;
  border: 3px dashed var(--orange);
  border-radius: var(--radius);
  background: #fff7ea;
  transition: background .3s ease, transform .3s ease;
}
.papers-banner:hover { background: #ffefd2; transform: scale(1.01); }
.papers-banner__icon { font-size: 1.6rem; }
.papers-banner__go { margin-left: auto; font-weight: 800; color: var(--orange); white-space: nowrap; }

/* ---------- Try a question ---------- */
.try { display: grid; grid-template-columns: 1fr 1.1fr; gap: 4rem; align-items: center; }
.try__text p { color: var(--ink-soft); font-size: 1.1rem; margin-top: 1rem; }

.qcard {
  background: var(--white);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.qcard__top { display: flex; justify-content: space-between; margin-bottom: 1rem; font-weight: 800; font-size: .85rem; }
.qcard__tag { color: var(--purple); }
.qcard__marks { color: var(--ink-soft); }
.qcard__q { color: var(--ink-soft); font-weight: 700; }
.qcard__expr { font-family: var(--font-head); font-size: 2.2rem; margin: .4rem 0 1.4rem; }
.qcard__options { display: grid; gap: .8rem; }

.opt {
  display: flex; align-items: center; gap: 1rem;
  width: 100%;
  padding: .9rem 1.1rem;
  border: 2px solid #e4e1f5;
  border-radius: 14px;
  background: var(--white);
  font-family: var(--font-head);
  font-size: 1.25rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}
.opt__text { white-space: nowrap; }
sup { font-size: .6em; line-height: 0; vertical-align: super; }
.opt__letter {
  display: grid; place-items: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--tint); color: var(--purple);
  font-family: var(--font-body); font-weight: 800; font-size: .95rem;
}
.opt:hover:not(:disabled) { border-color: var(--purple); transform: translateX(6px); }
.opt:disabled { cursor: default; }
.opt.is-correct { border-color: var(--teal); background: #e8fbf6; animation: pop .45s cubic-bezier(.34,1.56,.64,1); }
.opt.is-correct .opt__letter { background: var(--teal); color: var(--white); }
.opt.is-wrong { border-color: var(--pink); background: #fff0f4; animation: shake .45s ease; }
.opt.is-wrong .opt__letter { background: var(--pink); color: var(--white); }
.opt.is-faded { opacity: .45; }

@keyframes pop { 50% { transform: scale(1.05); } }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.qcard__feedback {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .5s ease, opacity .4s ease, margin .4s ease;
  border-radius: 14px;
  font-size: .98rem;
}
.qcard__feedback.is-shown { max-height: 300px; opacity: 1; margin-top: 1.2rem; }
.qcard__feedback .fb { padding: 1rem 1.2rem; border-radius: 14px; }
.qcard__feedback .fb--good { background: #e8fbf6; }
.qcard__feedback .fb--bad { background: #fff0f4; }
.qcard__feedback strong { font-family: var(--font-head); font-size: 1.15rem; display: block; margin-bottom: .3rem; }
.qcard__reset { margin-top: 1rem; }

.confetti {
  position: absolute; width: 10px; height: 10px; border-radius: 2px; pointer-events: none;
  animation: confetti 1s ease-out forwards;
}
@keyframes confetti {
  to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; }
}

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6rem; counter-reset: s; }
.step {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 2px solid #efecfb;
  transition: transform .3s ease, box-shadow .3s ease;
}
.step:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.step__num {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 16px;
  font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; color: var(--white);
  margin-bottom: 1.2rem;
}
.step:nth-child(1) .step__num { background: var(--orange); }
.step:nth-child(2) .step__num { background: var(--pink); }
.step:nth-child(3) .step__num { background: var(--teal); }
.step h3 { font-size: 1.5rem; margin-bottom: .5rem; }
.step p { color: var(--ink-soft); }

/* ---------- Teachers ---------- */
.teachers { display: grid; grid-template-columns: 1fr 1.1fr; gap: 4rem; align-items: center; }
.teachers h2 { margin-bottom: 1.5rem; }
.checklist { list-style: none; margin-bottom: 2rem; }
.checklist li { padding-left: 2.1rem; position: relative; margin-bottom: .8rem; font-size: 1.08rem; opacity: .92; }
.checklist li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 800;
  background: var(--teal); color: var(--ink);
}

.dash {
  background: #2a2850;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0,0,0,.35);
  transform: perspective(1000px) rotateY(-8deg) rotateX(4deg);
  transition: transform .6s ease;
}
.dash:hover { transform: perspective(1000px) rotateY(0) rotateX(0); }
.dash__bar { display: flex; align-items: center; gap: .45rem; padding: .9rem 1.2rem; background: #33316100; border-bottom: 1px solid rgba(255,255,255,.08); }
.dash__bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--pink); }
.dash__bar i:nth-child(2) { background: var(--yellow); }
.dash__bar i:nth-child(3) { background: var(--teal); }
.dash__bar span { margin-left: .8rem; font-size: .85rem; font-weight: 700; opacity: .7; }
.dash__body { padding: 1.5rem 1.4rem; display: grid; gap: 1.1rem; }
.dash__row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 1rem; font-size: .92rem; font-weight: 700; }
.dash__row em { font-style: normal; text-align: right; opacity: .8; }
.meter { height: 12px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
.meter b {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--purple), var(--teal));
  transition: width 1.4s cubic-bezier(.22,1,.36,1);
}
.meter--warn b { background: linear-gradient(90deg, var(--orange), var(--pink)); }
.dash.is-visible .meter b { width: var(--v); }

/* ---------- CTA ---------- */
.cta__inner {
  text-align: center;
  padding: 4rem 2rem;
  border-radius: 32px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: var(--white);
  position: relative; overflow: hidden;
}
.cta__inner::before, .cta__inner::after {
  content: "π"; position: absolute; font-family: var(--font-head); font-size: 12rem; opacity: .1; line-height: 1;
}
.cta__inner::before { left: 4%; top: -10%; }
.cta__inner::after { content: "∞"; right: 4%; bottom: -20%; }
.cta__inner p { font-size: 1.15rem; opacity: .9; margin: .8rem 0 2rem; }
.cta .btn--primary { background: var(--white); color: var(--purple); box-shadow: 0 6px 0 rgba(0,0,0,.18); }

/* ---------- Footer ---------- */
.footer { padding: 2.5rem 0; border-top: 1px solid #ece9f6; }
.footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; font-size: .92rem; color: var(--ink-soft); }
.footer nav { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; font-weight: 700; }
.footer nav a:hover { color: var(--purple); }

/* ---------- Scroll animations ---------- */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .8s ease, transform .8s cubic-bezier(.22,1,.36,1); }
.reveal.is-visible { opacity: 1; transform: none; }

.bounce-in { opacity: 0; transform: translateY(60px) scale(.9); }
.bounce-in.is-visible { animation: bounceIn .8s cubic-bezier(.34,1.56,.64,1) forwards; animation-delay: var(--delay, 0s); }
@keyframes bounceIn { to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .try, .teachers { grid-template-columns: 1fr; gap: 3rem; }
  .steps { grid-template-columns: 1fr; }
  .dash { transform: none; }
}

@media (max-width: 760px) {
  .nav__toggle { display: block; z-index: 60; }
  .nav__links {
    /* Explicit size: the blurred nav bar would otherwise shrink this menu to its own height */
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    flex-direction: column; justify-content: center; gap: 2rem;
    background: var(--bg);
    font-size: 1.3rem;
    transform: translateY(-100%);
    visibility: hidden;
    transition: transform .45s cubic-bezier(.22,1,.36,1), visibility 0s .45s;
  }
  .nav__links.is-open { transform: none; visibility: visible; transition: transform .45s cubic-bezier(.22,1,.36,1); }
  .hero__stats { gap: 2rem; }
  .papers-banner { flex-wrap: wrap; }
  .papers-banner__go { margin-left: 0; }
}

@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; }
  .dash__row { grid-template-columns: 100px 1fr 40px; font-size: .82rem; }
  .qcard { padding: 1.4rem; }
}

/* Respect users who turn animations off */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal, .bounce-in { opacity: 1; transform: none; }
}

/* ---------- Try-a-question: several questions in a row ---------- */
.qcard__count { color: var(--ink-soft); }
.qcard__dots { display: flex; gap: .4rem; margin: -.3rem 0 1rem; }
.qcard__dots span { flex: 1; height: 6px; border-radius: 999px; background: #ece9f8; transition: background .3s; }
.qcard__dots span.is-current { background: var(--purple); }
.qcard__dots span.is-right { background: var(--teal); }
.qcard__dots span.is-wrong { background: var(--pink); }
.qcard.is-swapping .qcard__body, .qcard.is-swapping .qcard__options { animation: qIn .45s cubic-bezier(.22,1,.36,1); }
@keyframes qIn { from { opacity: 0; transform: translateX(24px); } }
.qcard__next { margin-top: 1rem; width: 100%; justify-content: center; }
.qcard__next[hidden] { display: none; }
.qcard__score { text-align: center; padding: .5rem 0 1rem; }
.qcard__big { display: block; font-family: var(--font-head); font-size: 3.4rem; color: var(--purple); line-height: 1.1; }
.qcard__score strong { display: block; font-family: var(--font-head); font-size: 1.4rem; margin: .2rem 0 .5rem; }
.qcard__score p { color: var(--ink-soft); }
.qcard__end { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .qcard.is-swapping .qcard__body, .qcard.is-swapping .qcard__options { animation: none; } }

/* ---------- Welsh / English switch ---------- */
.nav__links { margin-left: auto; }
.langswitch { display: inline-flex; margin-left: 1.2rem; padding: 3px; border-radius: 999px; background: #efecfb; position: relative; z-index: 60; flex-shrink: 0; }
.langswitch button { border: 0; background: none; font: inherit; font-weight: 800; font-size: .8rem; letter-spacing: .04em; color: var(--ink-soft); padding: .35rem .7rem; border-radius: 999px; cursor: pointer; transition: background .2s, color .2s; }
.langswitch button:hover { color: var(--ink); }
.langswitch button.is-on { background: var(--purple); color: var(--white); cursor: default; }
.langswitch button:focus-visible { outline: 3px solid rgba(108, 76, 245, .35); outline-offset: 1px; }
.langswitch--float { position: fixed; right: 16px; bottom: 16px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
@media (max-width: 760px) {
  .langswitch { margin-left: auto; margin-right: .6rem; }
}
/* Welsh labels are longer: keep the navbar on one line */
.nav__links a { white-space: nowrap; }
@media (min-width: 761px) {
  html[lang="cy"] .nav__links { gap: .85rem; font-size: .9rem; margin-left: 1.5rem; }
  html[lang="cy"] .nav__links .btn { padding-left: 1rem; padding-right: 1rem; }
}
@media (max-width: 1240px) and (min-width: 761px) {
  html[lang="cy"] .nav__links { gap: .75rem; font-size: .84rem; }
  html[lang="cy"] .langswitch { margin-left: .7rem; }
}
/* Not enough room for every link (narrow laptops, longer Welsh words): use the menu button instead */
.nav--compact .nav__toggle { display: block; z-index: 60; }
.nav--compact .nav__links {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; margin: 0;
  flex-direction: column; justify-content: center; gap: 2rem;
  background: var(--bg); font-size: 1.3rem;
  transform: translateY(-100%); visibility: hidden;
  transition: transform .45s cubic-bezier(.22,1,.36,1), visibility 0s .45s;
}
.nav--compact .nav__links.is-open { transform: none; visibility: visible; transition: transform .45s cubic-bezier(.22,1,.36,1); }
.nav--compact .langswitch { margin-left: auto; margin-right: .6rem; }
html .nav.nav--compact .nav__links { font-size: 1.3rem; gap: 2rem; margin: 0; }
html .nav.nav--compact .langswitch { margin-left: auto; } /* beats the Welsh narrow-laptop margin above */

/* ---------- Contact dialog ---------- */
.contact { margin: auto; width: min(440px, calc(100vw - 2rem)); border: 0; border-radius: 24px; padding: 1.8rem 1.6rem 1.5rem; box-shadow: 0 24px 60px rgba(29, 27, 58, .25); color: var(--ink); background: var(--white); }
.contact::backdrop { background: rgba(29, 27, 58, .45); backdrop-filter: blur(3px); }
.contact h2 { font-size: 1.6rem; margin-bottom: .4rem; }
.contact__lead { color: var(--ink-soft); margin-bottom: 1.1rem; }
.contact__x { position: absolute; top: .9rem; right: .9rem; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f3f1fb; color: var(--ink); font-size: 1rem; cursor: pointer; }
.contact__x:hover { background: #e9e5fa; }
.contact__row { display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; border: 2px solid #efecfb; border-radius: 16px; margin-bottom: .7rem; transition: border-color .2s, background .2s; }
.contact__row:hover { border-color: var(--purple); background: #faf9ff; }
.contact__icon { font-size: 1.5rem; }
.contact__row small { display: block; font-size: .78rem; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.contact__row b { font-size: 1.02rem; word-break: break-all; }
.contact__copy { width: 100%; margin-top: .3rem; }
@media (max-width: 420px) {
  .contact { padding: 1.5rem 1.1rem 1.2rem; }
  .contact__row { padding: .75rem .8rem; gap: .7rem; }
  .contact__row b { font-size: .92rem; }
}

/* ---------- Topic search on the home page ("Stuck on a question?") ---------- */
.tsearch { position: relative; max-width: 760px; margin: -1.6rem auto 2.6rem; z-index: 5; }
.tsearch__box { display: flex; align-items: center; gap: .6rem; background: var(--white); border: 3px solid var(--purple); border-radius: 999px; padding: .35rem .5rem .35rem 1.2rem; box-shadow: var(--shadow); transition: box-shadow .2s; }
.tsearch__box:focus-within { box-shadow: 0 0 0 6px rgba(108, 76, 245, .18), var(--shadow); }
.tsearch__icon { font-size: 1.2rem; }
.tsearch__box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 1.05rem; font-weight: 600; color: var(--ink); padding: .65rem 0; }
.tsearch__box input::placeholder { color: var(--ink-soft); font-weight: 600; }
.tsearch__chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; justify-content: center; margin-top: .8rem; font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.tsearch__chips button { border: 2px solid var(--tint); background: var(--white); border-radius: 999px; padding: .25rem .75rem; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }
.tsearch__chips button:hover, .tsearch__chips button:focus-visible { border-color: var(--purple); color: var(--purple); outline: 0; }
.tsearch__results { position: absolute; left: 0; right: 0; top: calc(100% - 2.4rem); background: var(--white); border-radius: 22px; box-shadow: 0 18px 50px rgba(29, 27, 58, .22); padding: .6rem; max-height: min(70vh, 560px); overflow-y: auto; display: grid; gap: .45rem; }
.tsearch__results[hidden] { display: none; }
.tsearch__hit { border-radius: 16px; padding: .35rem; }
.tsearch__hit.is-best { background: var(--tint); }
.tsearch__topic { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .1rem .7rem; padding: .55rem .7rem; border-radius: 12px; color: var(--ink); text-decoration: none; }
.tsearch__topic strong { font-family: var(--font-head); font-size: 1.12rem; }
.tsearch__topic small { grid-column: 2; color: var(--ink-soft); font-weight: 700; font-size: .8rem; }
.tsearch__unit { grid-row: span 2; align-self: start; margin-top: .2rem; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--white); border-radius: 99px; padding: .2rem .55rem; white-space: nowrap; background: var(--purple); }
.tsearch__unit--applied-as { background: var(--pink); }
.tsearch__unit--pure-a2 { background: var(--blue); }
.tsearch__unit--applied-a2 { background: var(--teal); }
.tsearch__qs { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 .7rem .45rem; }
.tsearch__qs a { display: inline-flex; gap: .35rem; align-items: center; background: var(--white); border: 2px solid #e6e1fb; border-radius: 99px; padding: .2rem .7rem; font-size: .85rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.tsearch__qs a b { color: var(--purple); }
.tsearch__topic:hover, .tsearch__topic.is-on { background: var(--white); outline: 2px solid var(--purple); }
.tsearch__qs a:hover, .tsearch__qs a.is-on { border-color: var(--purple); }
.tsearch__none { padding: .8rem 1rem; color: var(--ink-soft); font-weight: 700; }
.tsearch__none p + p { margin-top: .35rem; font-weight: 600; }
/* Show / hide symbols button inside the box */
.tsearch__toggle { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; border: 2px solid var(--tint); background: var(--white); color: var(--ink); border-radius: 999px; padding: .38rem .8rem; font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer; }
.tsearch__toggle > span:first-child { font-family: var(--font-head); }
.tsearch__toggle.is-on { background: var(--tint); border-color: var(--purple); color: var(--purple); }
.tsearch__toggle:hover, .tsearch__toggle:focus-visible { border-color: var(--purple); outline: 0; }
.tsearch__keys[hidden] { display: none; }
/* Symbol buttons under the box */
.tsearch__keys { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem; margin-top: .7rem; }
.tsearch__keys button { min-width: 2.3rem; border: 2px solid var(--tint); background: var(--white); border-radius: 10px; padding: .22rem .5rem; font: inherit; font-size: .92rem; font-weight: 700; color: var(--ink); cursor: pointer; line-height: 1.3; }
.tsearch__keys button:hover, .tsearch__keys button:focus-visible { border-color: var(--purple); color: var(--purple); outline: 0; }
.tsearch__keys button:active { transform: translateY(1px); }
/* Results open just below the symbol buttons; the "Try:" examples step aside while they're open */
.tsearch__results { top: calc(100% + .45rem); }
.tsearch.is-open .tsearch__chips { display: none; }
/* Preview of the closest practice question */
.tsearch__preview { display: grid; gap: .2rem; margin: 0 .7rem .5rem; padding: .55rem .8rem; border-radius: 12px; background: var(--white); border: 2px dashed #d9d2fb; color: var(--ink); text-decoration: none; }
.tsearch__plabel { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--purple); }
.tsearch__ptext { font-size: .92rem; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.tsearch__pgo { font-size: .8rem; font-weight: 800; color: var(--purple); }
.tsearch__preview:hover, .tsearch__preview.is-on { border-style: solid; border-color: var(--purple); }
/* On the unit pages the finder sits above the topic filter */
.tsearch--unit { margin: 0 auto 1.8rem; }
@media (max-width: 640px) {
  .tsearch { margin: -2rem auto 2rem; }
  .tsearch--unit { margin: 0 auto 1.4rem; }
  .tsearch__box { padding-left: .9rem; }
  .tsearch__box input { font-size: 1rem; }
  .tsearch__toggle { padding: .38rem .65rem; }
  .tsearch__toggletext { display: none; }
  .tsearch__chips { display: none; }
  /* One swipeable row of symbols on phones */
  .tsearch__keys { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .tsearch__keys button { flex: 0 0 auto; }
  /* Unit badge above the topic name, so the name gets the full width */
  .tsearch__topic { grid-template-columns: 1fr; gap: .25rem; }
  .tsearch__unit { grid-row: auto; justify-self: start; margin-top: 0; }
  .tsearch__topic small { grid-column: 1; }
}

/* ---------- SOUND BUTTON + FEEDBACK ANIMATIONS (28 Nov 2026) ----------
   The speaker button (🔊/🔇) sits at the start of the EN/CY switch (made by script.js).
   The animations below only play once, when something happens (marking, a streak, a finished paper).
   They all start from a visible resting state, and are switched off for reduced motion. */
.soundbtn {
  flex-shrink: 0; width: 34px; height: 34px; margin-left: 1.2rem; padding: 0;
  border: 0; border-radius: 50%; background: #efecfb; cursor: pointer;
  display: inline-grid; place-items: center; color: var(--purple);
  transition: background .2s, color .2s, transform .15s;
}
/* Normally it sits inside the EN/CY pill, with a thin line after it */
.langswitch .soundbtn { width: auto; height: auto; margin: 0 .2rem 0 0; padding: .3rem .45rem; border-radius: 999px; background: none; color: var(--purple); position: relative; }
.langswitch .soundbtn::after { content: ""; position: absolute; right: -.15rem; top: 25%; height: 50%; width: 1.5px; background: #d9d3f5; }
.soundbtn:hover, .langswitch .soundbtn:hover { background: #e2dcfb; color: var(--purple); }
.soundbtn:active { transform: scale(.9); }
.soundbtn.is-off, .langswitch .soundbtn.is-off { color: var(--ink-soft); }
.soundbtn:focus-visible { outline: 3px solid rgba(108, 76, 245, .35); outline-offset: 1px; }
.soundbtn.is-pop { animation: sbPop .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes sbPop { from { transform: scale(.7); } }

/* Mark scheme: the lines slide in one after another, and the ticks pop */
.scheme li { animation: schemeIn .32s cubic-bezier(.22,1,.36,1) backwards; }
.scheme li:nth-child(2) { animation-delay: .06s; }
.scheme li:nth-child(3) { animation-delay: .12s; }
.scheme li:nth-child(4) { animation-delay: .18s; }
.scheme li:nth-child(5) { animation-delay: .24s; }
.scheme li:nth-child(n+6) { animation-delay: .3s; }
@keyframes schemeIn { from { opacity: 0; transform: translateY(5px); } }
.scheme li.is-ok .scheme__tick { display: inline-block; animation: tickPop .4s cubic-bezier(.34,1.56,.64,1) backwards; animation-delay: inherit; }
@keyframes tickPop { from { transform: scale(0); } }

/* Score numbers in the practice header: bump when they go up, wobble when a streak ends */
.uhero__facts li { position: relative; }
.uhero__facts strong.is-bump, .card__marks.is-bump, #cardMarks.is-bump { display: inline-block; animation: numBump .45s cubic-bezier(.34,1.56,.64,1); }
@keyframes numBump { 40% { transform: scale(1.25); } }
.uhero__facts strong.is-drop { display: inline-block; animation: numDrop .4s ease; }
@keyframes numDrop { 30% { transform: translateY(3px); opacity: .5; } }
.streakpop {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  white-space: nowrap; padding: .25rem .65rem; border-radius: 999px;
  background: var(--white); color: var(--ink); font-weight: 800; font-size: .85rem;
  box-shadow: 0 6px 18px rgba(29, 27, 58, .2); pointer-events: none;
  animation: streakPop 2.6s ease forwards;
  --sx: -50%;
}
@keyframes streakPop {
  0% { opacity: 0; transform: translate(var(--sx), 8px) scale(.8); }
  12% { opacity: 1; transform: translate(var(--sx), 0) scale(1.05); }
  20%, 80% { opacity: 1; transform: translate(var(--sx), 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--sx), -6px); }
}
@media (max-width: 520px) { .streakpop { --sx: 0; left: auto; right: .6rem; bottom: auto; top: -.9rem; transform: none; } }
.banner--topic { animation: cardIn .5s cubic-bezier(.22,1,.36,1); }

/* Finished paper: the score circle pops in and the topic bars grow */
.presult__big { animation: resultPop .55s cubic-bezier(.34,1.56,.64,1) backwards; }
@keyframes resultPop { from { transform: scale(.6); opacity: 0; } }
.presult__bar b { transform-origin: left; animation: barGrow .9s cubic-bezier(.22,1,.36,1) .25s backwards; }
@keyframes barGrow { from { transform: scaleX(0); } }

/* Draw the forces: the result box eases in */
.ft__out.is-new { animation: schemeIn .3s cubic-bezier(.22,1,.36,1); }

/* Buttons and tabs give a little press when tapped (purple buttons keep their own 3D press) */
.btn:not(.btn--primary):active, .qtab:active, .choice:active { transform: scale(.97); }

@media (prefers-reduced-motion: reduce) {
  .scheme li, .scheme li.is-ok .scheme__tick, .presult__big, .presult__bar b, .ft__out.is-new, .banner--topic,
  .uhero__facts strong.is-bump, .uhero__facts strong.is-drop, #cardMarks.is-bump, .soundbtn.is-pop { animation: none !important; }
  .streakpop { animation: none; opacity: 1; }
  .btn:not(.btn--primary):active, .qtab:active, .choice:active, .soundbtn:active { transform: none; }
}

/* Privacy / terms / schools links in every footer (29 Nov 2026) */
.footer__legal { width: 100%; text-align: center; font-size: .85rem; margin: .2rem 0 0; }
.footer__legal a { color: inherit; }
.footer__legal a:hover { color: var(--purple); }
