/* =========================================================
   Unit pages (Pure A, Applied A, Pure B, Applied B)
   Loaded AFTER styles.css, so it reuses the same colours,
   fonts, buttons, nav and footer.
   Each page sets its own colour with a class on <body>.
   ========================================================= */

body.unit--pure-as    { --c: var(--purple); --c-soft: #f0ecff; }
body.unit--applied-as { --c: var(--pink);   --c-soft: #ffeef3; }
body.unit--pure-a2    { --c: var(--blue);   --c-soft: #eaf2ff; }
body.unit--applied-a2 { --c: var(--teal);   --c-soft: #e6faf5; }

/* ---------- Unit hero ---------- */
.uhero {
  position: relative;
  overflow: hidden;
  padding: 8.5rem 0 4rem;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.18), transparent 45%),
    var(--c);
  color: var(--white);
}
.uhero .hero__symbols .symbol { color: var(--white) !important; }
.uhero__content { position: relative; z-index: 2; }

.crumbs { display: flex; gap: .5rem; font-weight: 700; font-size: .9rem; opacity: .85; margin-bottom: 1.4rem; }
.crumbs a:hover { text-decoration: underline; }

.uhero__badge {
  display: inline-block;
  padding: .35rem .9rem;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  font-weight: 800; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase;
  margin-bottom: 1rem;
}
.uhero h1 { font-size: clamp(2.6rem, 7vw, 4.4rem); margin-bottom: 1rem; }
.uhero__sub { font-size: 1.15rem; max-width: 640px; opacity: .95; }

.uhero__facts { list-style: none; display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.uhero__facts li {
  display: flex; flex-direction: column;
  padding: .8rem 1.2rem;
  border-radius: 16px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  min-width: 120px;
}
.uhero__facts strong { font-family: var(--font-head); font-size: 1.4rem; line-height: 1.2; }
.uhero__facts span { font-size: .82rem; font-weight: 700; opacity: .85; }

/* The nav sits on a coloured hero, so make it white until the page scrolls */
.nav:not(.is-scrolled) .logo,
.nav:not(.is-scrolled) .nav__links > a:not(.btn) { color: var(--white); }
.nav:not(.is-scrolled) .nav__login { border-color: var(--white); color: var(--white); }
.nav:not(.is-scrolled) .nav__toggle span { background: var(--white); }
.nav:not(.is-scrolled) .logo__io { color: inherit; }
/* the purple logo tile would vanish on a purple hero, so it sits on a white tile until the page scrolls */
.nav:not(.is-scrolled) .logo__mark { background: var(--white) url("../img/logo.svg") center / 78% no-repeat; border-radius: 12px; }
.nav .btn--primary { background: var(--ink); box-shadow: 0 6px 0 #000; }
.nav.is-scrolled .btn--primary { background: var(--c); box-shadow: 0 6px 0 rgba(0,0,0,.2); }
/* Mobile menu has a light background, so keep its links dark */
.nav__links.is-open > a:not(.btn) { color: var(--ink) !important; }
.nav__toggle.is-open span { background: var(--ink) !important; }
.nav__links.is-open .nav__login { border-color: var(--ink) !important; color: var(--ink) !important; }

/* ---------- Toolbar: search + progress ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.search { position: relative; flex: 1; max-width: 420px; }
.search input {
  width: 100%;
  padding: .9rem 1rem .9rem 2.8rem;
  border: 2px solid #e4e1f5;
  border-radius: 14px;
  font: inherit; font-weight: 600;
  background: var(--white);
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search input:focus { outline: none; border-color: var(--c); box-shadow: 0 0 0 4px var(--c-soft); }
.search svg { position: absolute; left: 1rem; top: 50%; translate: 0 -50%; width: 18px; height: 18px; stroke: var(--ink-soft); }

.progress { display: flex; align-items: center; gap: .9rem; font-weight: 700; color: var(--ink-soft); }
.ring { width: 52px; height: 52px; }
.ring circle { fill: none; stroke-width: 6; }
.ring .ring__bg { stroke: #ebe8f7; }
.ring .ring__fg { stroke: var(--c); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset 1.2s ease; }
.progress strong { display: block; color: var(--ink); font-family: var(--font-head); font-size: 1.15rem; }

/* ---------- Topic groups ---------- */
.group { margin-bottom: 3rem; }
.group__title { display: flex; align-items: center; gap: .8rem; font-size: 1.6rem; margin-bottom: 1.2rem; }
.group__title i {
  font-style: normal; font-size: .8rem; font-family: var(--font-body); font-weight: 800;
  padding: .25rem .7rem; border-radius: 999px; background: var(--c-soft); color: var(--c);
}

.topics { display: grid; gap: 1rem; }

.topic {
  background: var(--white);
  border: 2px solid #efecfb;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease;
}
.topic:hover { border-color: var(--c); transform: translateY(-2px); }
.topic.is-open { border-color: var(--c); box-shadow: var(--shadow-lg); }
.topic[hidden] { display: none; }

.topic__head {
  width: 100%;
  display: flex; align-items: center; gap: 1.1rem;
  padding: 1.2rem 1.4rem;
  background: none; border: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}
.topic__num {
  display: grid; place-items: center; flex-shrink: 0;
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--c-soft); color: var(--c);
  font-family: var(--font-head); font-weight: 700; font-size: 1.2rem;
  transition: background .25s ease, color .25s ease, transform .4s cubic-bezier(.34,1.56,.64,1);
}
.topic.is-open .topic__num { background: var(--c); color: var(--white); transform: rotate(-8deg); }
.topic__name { flex: 1; }
.topic__name h3 { font-size: 1.25rem; }
.topic__name span { font-size: .88rem; color: var(--ink-soft); font-weight: 600; }
.topic__chev {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: #f5f3fc;
  transition: transform .35s ease, background .25s ease;
}
.topic__chev svg { width: 14px; height: 14px; stroke: var(--ink); fill: none; stroke-width: 3; }
.topic.is-open .topic__chev { transform: rotate(180deg); background: var(--c-soft); }

/* Accordion body: grid-rows trick animates height smoothly */
.topic__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s cubic-bezier(.22,1,.36,1); }
.topic.is-open .topic__body { grid-template-rows: 1fr; }
.topic__inner { overflow: hidden; }
.subtopics { list-style: none; padding: 0 1.4rem 1.4rem; display: grid; gap: .6rem; }
.subtopic {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .85rem 1rem;
  border-radius: 14px;
  background: #faf9ff;
  border: 1px solid #efecfb;
}
.subtopic__name { flex: 1; font-weight: 700; min-width: 180px; }
.subtopic__actions { display: flex; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .8rem; border-radius: 999px;
  font-size: .8rem; font-weight: 800;
  border: 2px solid #e4e1f5; color: var(--ink-soft); background: var(--white);
  cursor: not-allowed;
}
.chip--live {
  cursor: pointer; border-color: var(--c); background: var(--c); color: var(--white);
  transition: transform .2s ease, box-shadow .2s ease;
}
.chip--live:hover { transform: translateY(-2px); box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.subtopic.has-practice { border-color: var(--c); background: var(--c-soft); }
.soon--live { color: var(--teal) !important; }
.soon { font-size: .72rem; font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: .04em; }

.empty { display: none; text-align: center; padding: 3rem 1rem; color: var(--ink-soft); font-weight: 700; }
.empty.is-shown { display: block; }

/* ---------- Other units ---------- */
.others { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.other {
  --oc: var(--purple);
  display: flex; flex-direction: column; gap: .3rem;
  padding: 1.3rem 1.4rem;
  border-radius: var(--radius);
  background: var(--oc);
  color: var(--white);
  box-shadow: 0 6px 0 rgba(0,0,0,.15);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.other:hover { transform: translateY(-6px) rotate(-1deg); }
.other span { font-size: .78rem; font-weight: 800; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }
.other strong { font-family: var(--font-head); font-size: 1.3rem; }
.other--pure-as    { --oc: var(--purple); }
.other--applied-as { --oc: var(--pink); }
.other--pure-a2    { --oc: var(--blue); }
.other--applied-a2 { --oc: var(--teal); }

@media (max-width: 760px) {
  .others { grid-template-columns: 1fr; }
  .uhero { padding-top: 7rem; }
  .subtopic__actions { width: 100%; }
}

/* ---------- Unit switcher (jump between the four units) ---------- */
.uswitch {
  display: flex; width: fit-content; max-width: 100%; flex-wrap: wrap; gap: .35rem;
  padding: .35rem;
  margin-bottom: 1.6rem;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  backdrop-filter: blur(6px);
}
.uswitch__tab {
  display: inline-flex; align-items: baseline; gap: .45rem;
  padding: .55rem 1.05rem;
  border-radius: 999px;
  color: var(--white);
  font-size: .95rem;
  transition: background .2s, color .2s, transform .2s;
}
.uswitch__tab span { font-size: .72rem; font-weight: 800; letter-spacing: .05em; opacity: .75; }
.uswitch__tab:hover { background: rgba(255,255,255,.2); transform: translateY(-1px); }
.uswitch__tab.is-current { background: var(--white); color: var(--c, #6c4cf5); box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.uswitch__tab.is-current span { opacity: .7; }
.uswitch__tab:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }
@media (max-width: 560px) {
  .uswitch { border-radius: 18px; display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .uswitch__tab { justify-content: center; border-radius: 14px; }
}

/* Past papers button on unit pages */
.uhero__papers {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-top: 1.4rem;
  padding: .75rem 1.2rem;
  border-radius: 999px;
  background: var(--white); color: var(--c);
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  transition: transform .2s;
}
.uhero__papers:hover { transform: translateY(-2px); }
