/* =====================================================================
 * hub.css: the "Why does my child get this wrong?" hub page only
 * (why-does-my-child-keep-making-maths-mistakes.html), loaded after site.css.
 * The marked mistake card itself (.mark-card, .script, .working, .pen-ring,
 * .pen-note, .mark-stamp, .frac, .sqrt, .sr-only) lives in components.css;
 * nothing here restyles it. This file adds the hub layout around the cards:
 * hero grid, top-10 table, "How we know" box, topic share table, filter
 * chips, inline CTA strips, the home check and small card add-ons.
 * ===================================================================== */

/* anything the page hides (filtered cards, JS-only controls) stays hidden,
 * even where a class below sets display */
main [hidden] { display: none !important; }

/* anchors land below the sticky topbar */
.hub-topic,
.mark-card,
#home-check,
#questions,
#how-we-know,
#careless-mistakes,
#key-takeaways { scroll-margin-top: 96px; }

/* one shared column for every section, the width of a marked card, so the
 * headings, tables and cards all start on the same line */
.hub-col { max-width: 1040px; margin-inline: auto; }
.hub-col > p,
.hub-col > .hub-steps,
.hub-col > .hub-takeaways { max-width: 68ch; }
.hub-col > .section-title,
.hub-topic__head .section-title {
  font-size: clamp(1.75rem, 1.35rem + 1.5vw, 2.6rem);
  line-height: 1.1;
  max-width: 24ch;
  text-wrap: balance;
}
.hub-col > .faq-list { max-width: 820px; }

/* the cards carry their own question numbers in the margin, so the
 * section numbers of the exam-script layout would double up here */
main > .section:not(.section-dark)::before { content: none !important; }

/* ------------------------------------------------------------- hero
 * The two-column hero (text left, paper object right) comes from the shared
 * template (.hero-main / .hero-aside). Here: the H1's second line, the byline,
 * and the featured mini card, which only shows beside the H1 on desktop. */
.page-hero .hero-main .headline { max-width: 19ch; margin-block-end: var(--space-4); }
.hub-h1-line2 {
  display: block;
  margin-top: 0.5em;
  font-size: 0.52em;
  line-height: 1.22;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--color-bone-dim);
}
.page-hero .hub-byline {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-bone-dim);
  margin: 0 0 var(--space-4);
  max-width: 60ch;
}
.page-hero .hub-byline a { color: var(--color-bone); }
.page-hero .hub-byline a:hover { color: var(--color-brand-primary); }
.hub-hero-aside .mark-card--mini { margin-inline: auto 0; }
.hub-hero-aside .mark-card__meta { color: var(--color-pen-text); }
@media (max-width: 959px) {
  /* on phones the first card below is this same mistake, marked in full */
  .page-hero .hub-hero-aside { display: none; }
}
.mark-card .hub-hero__more {
  margin: 0.4rem 0 0;
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: right;
}
.hub-hero__more a { color: var(--color-amber-deep); }
.hub-hero__more a:hover { color: var(--color-ink); }

/* ------------------------------------------------------------- prose blocks */
.hub-direct {
  font-size: var(--text-lg);
  line-height: 1.6;
  max-width: 64ch;
  margin-block: var(--space-4) 0;
  padding-left: var(--space-5);
  border-left: 3px solid var(--color-pen);
}
.hub-takeaways { gap: var(--space-3); }
.hub-takeaways li { font-size: var(--text-lg); line-height: 1.55; }
.hub-note,
.hub-source {
  font-size: var(--text-sm);
  color: var(--color-muted-text);
  margin-top: var(--space-3);
  max-width: 72ch;
}
.hub-source a { color: var(--color-ink); }

/* ------------------------------------------------------------- tables (shared frame) */
.hub-table-wrap {
  margin-top: var(--space-6);
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.hub-top10,
.hub-sharetable {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  color: var(--color-ink);
}
.hub-top10 caption,
.hub-sharetable caption {
  caption-side: top;
  text-align: left;
  padding: var(--space-5) var(--space-5) var(--space-3);
  font: italic 500 var(--text-xl)/1.25 var(--font-display);
  color: var(--color-ink);
}
.hub-top10 th,
.hub-top10 td,
.hub-sharetable th,
.hub-sharetable td {
  padding: 0.85rem var(--space-4);
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--color-border);
}
.hub-top10 thead th,
.hub-sharetable thead th {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  background: rgba(245, 166, 35, 0.14);
  vertical-align: bottom;
}

/* ------------------------------------------------------------- top-10 table */
.hub-top10__rank {
  width: 3.2rem;
  text-align: center;
  font: italic 500 1.55rem/1 var(--font-display);
  color: var(--color-pen);
}
.hub-top10 td.hub-top10__rank { padding-top: 0.8rem; }
.hub-top10 th.hub-top10__mistake {
  font-weight: 600;
  font-size: var(--text-base);
  line-height: 1.45;
  min-width: 15rem;
}
.hub-top10__topic,
.hub-top10__years,
.hub-top10__often { color: var(--color-ink-muted); }
.hub-top10__often { white-space: nowrap; font-weight: 700; color: var(--color-ink); }
.hub-top10__link { white-space: nowrap; }
.hub-top10__link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -0.6rem;
  font-weight: 700;
  color: var(--color-amber-deep);
}
.hub-top10__link a:hover { color: var(--color-ink); }
.hub-top10 tbody tr:hover { background: rgba(245, 166, 35, 0.06); }

@media (max-width: 760px) {
  /* each row becomes a small marked entry; roles in the HTML keep it a table */
  .hub-top10 thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .hub-top10,
  .hub-top10 tbody,
  .hub-top10 caption { display: block; }
  .hub-top10 tr {
    display: grid;
    grid-template-columns: 2.4rem minmax(0, 1fr);
    column-gap: var(--space-2);
    padding: 0.9rem var(--space-4) 0.6rem;
    border-top: 1px solid var(--color-border);
  }
  .hub-top10 th,
  .hub-top10 td {
    display: block;
    padding: 0;
    border: 0;
  }
  .hub-top10 td.hub-top10__rank {
    grid-row: 1 / span 5;
    width: auto;
    padding-top: 0.1rem;
    text-align: left;
  }
  .hub-top10 tr > :not(.hub-top10__rank) { grid-column: 2; }
  .hub-top10 th.hub-top10__mistake { min-width: 0; margin-bottom: 0.3rem; }
  .hub-top10 td[data-label] { font-size: var(--text-sm); line-height: 1.5; white-space: normal; }
  .hub-top10 td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--color-ink-muted);
  }
  .hub-top10__link a { margin-block: 0; }
}

/* ------------------------------------------------------------- how we know + where */
.hub-evidence-grid {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
}
@media (min-width: 1000px) {
  .hub-evidence-grid {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    align-items: start;
  }
}
.hub-evidence-grid > * { min-width: 0; }
.hub-evidence {
  position: relative;
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  padding: clamp(1.25rem, 3vw, 2.1rem);
  border-top: 4px solid var(--color-pen);
}
.hub-evidence p { max-width: 62ch; }
.hub-evidence__facts {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-5) 0;
  padding: var(--space-4) 0;
  border-block: 1px dashed rgba(28, 39, 66, 0.18);
}
.hub-evidence__facts li { line-height: 1.5; color: var(--color-ink-muted); }
.hub-evidence__facts strong {
  display: block;
  font: italic 500 clamp(1.5rem, 1.3rem + 0.8vw, 1.9rem)/1.1 var(--font-display);
  color: var(--color-pen);
  margin-bottom: 0.15rem;
}
.hub-evidence__more { font-size: var(--text-sm); margin-top: var(--space-4); }
.hub-where > p { color: var(--color-ink-muted); max-width: 62ch; }

.hub-sharetable th[scope="row"] { font-weight: 400; }
.hub-sharetable td,
.hub-sharetable th { padding-block: 0.6rem; vertical-align: middle; }
.hub-share__name { display: block; font-weight: 700; color: var(--color-ink); }
.hub-share__desc { display: block; font-size: 0.85rem; line-height: 1.4; color: var(--color-muted-text); }
.hub-share__pct { width: 42%; white-space: nowrap; }
.hub-share__num {
  display: inline-block;
  width: 2.9em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
}
.hub-share__bar {
  display: inline-block;
  vertical-align: middle;
  width: calc(100% - 3.2em);
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(28, 39, 66, 0.07);
  overflow: hidden;
}
.hub-share__bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--color-ink-mid);
}
@media (max-width: 480px) {
  .hub-share__pct { width: 34%; }
  .hub-share__bar { display: block; width: 100%; margin-top: 0.3rem; }
}

/* ------------------------------------------------------------- filter + chips */
.hub-filter-band { padding-block: clamp(1.75rem, 3.5vw, 2.75rem); }
.hub-filter__lead { max-width: 70ch; color: var(--color-ink-muted); margin: 0; }
.hub-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.hub-chips__label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin-right: var(--space-1);
}
.hub-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(28, 39, 66, 0.18);
  background: #fff;
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.hub-chip:hover { border-color: var(--color-ink-muted); color: var(--color-ink); }
.hub-chip:focus-visible { outline: 3px solid var(--color-ink); outline-offset: 2px; }
.hub-chip[aria-pressed="true"] {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: #fff;
}
.hub-filter__count {
  min-height: 1.6em;
  margin: var(--space-3) 0 0;
  font-weight: 700;
  color: var(--color-ink);
}
@media (max-width: 760px) {
  /* the 12 topic chips: one swipeable row, edge to edge, never wider than the screen */
  .hub-chips:not(.hub-chips--years) {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    margin-inline: calc(-1 * clamp(1rem, 3vw, 2.5rem));
    padding: 0.15rem clamp(1rem, 3vw, 2.5rem) 0.35rem;
  }
  .hub-chips::-webkit-scrollbar { display: none; }
  .hub-chips:not(.hub-chips--years) .hub-chip { flex: none; }
  /* the 5 year buttons wrap under their label, so the label never scrolls away */
  .hub-chips--years .hub-chips__label { flex-basis: 100%; margin: 0; }
}

/* ------------------------------------------------------------- topic sections */
.hub-topic__head,
.hub-topic__end,
.hub-empty,
.hub-cta,
.hub-am-links {
  max-width: 1040px;
  margin-inline: auto;
}
.hub-topic__head { margin-bottom: clamp(1.75rem, 3.5vw, 2.75rem); }
.hub-topic__tag { margin: 0 0 var(--space-2); }
.hub-topic__intro {
  max-width: 66ch;
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--color-ink-muted);
}
.hub-topic__end {
  margin-top: -1rem;
  color: var(--color-ink-muted);
}
/* the two notes that sit straight in the section container: a reading measure,
 * but starting on the card column's left edge (the shared 68ch rule centres them) */
.hub-topic .container > .hub-topic__end,
.hub-topic .container > .hub-empty {
  max-width: 68ch;
  margin-left: max(0px, calc((100% - 1040px) / 2));
  margin-right: auto;
}
.hub-topic__end a,
.hub-am-links__more a { color: var(--color-ink); font-weight: 600; }
.hub-empty {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: #fff;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  color: var(--color-ink-muted);
}
.hub-empty .text-link { min-height: 44px; }

/* small add-ons inside a marked card (the card itself is components.css) */
.mark-card .hub-answer {
  max-width: 70ch;
  margin: 0 0 var(--space-4);
  font-size: var(--text-base);
  line-height: 1.65;
}
.mark-card .hub-question {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: clamp(1.02rem, 0.98rem + 0.2vw, 1.12rem);
  line-height: 1.5;
}
.hub-question__label {
  display: block;
  margin-bottom: 0.1rem;
  font: 800 0.72rem/1.5 var(--font-body);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-pen-text);
}
.working .w-note {
  font-family: var(--font-body);
  font-size: 0.66em;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-ink-muted);
  white-space: nowrap;
}
.mark-card .hub-card-more { margin: var(--space-3) 0 0; font-size: var(--text-sm); }
.mark-card .hub-card-more a { color: var(--color-ink); font-weight: 700; }
html:not(.js) .hub-share { display: none !important; }
/* Tablet widths (761 to 1000 px): several working lines on this page are too
 * long for two panels side by side, so the two panels stack here. Below 761 px
 * the phone layout of the marked card (components.css) already stacks them.
 * Candidate to move into the "Marked mistakes" block if other pages need it. */
@media (min-width: 761px) and (max-width: 1000px) {
  .hub-topic .mark-card__body { grid-template-columns: minmax(0, 1fr); }
  .hub-topic .script--right {
    border-left: 0;
    border-top: 1.5px dashed rgba(28, 39, 66, 0.2);
  }
}

/* ------------------------------------------------------------- inline CTA strip */
.hub-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-6);
  margin-top: -1.25rem;
  margin-bottom: 3.5rem;
  padding: var(--space-4) var(--space-5);
  background: #FFF6DF;
  border-left: 3px solid var(--color-brand-primary);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.hub-cta p {
  flex: 1 1 20rem;
  margin: 0;
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-ink);
}
.hub-cta .button { flex: none; }

/* ------------------------------------------------------------- Add Maths topic links */
.hub-am-links {
  margin-bottom: clamp(2rem, 4vw, 3rem);
  padding: var(--space-5);
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
}
.hub-am-links__title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
}
.hub-am-links ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
}
.hub-am-links li a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(28, 39, 66, 0.16);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
  color: var(--color-ink);
}
.hub-am-links li a:hover { border-color: var(--color-ink-muted); color: var(--color-ink); }
.hub-am-links__more { margin: var(--space-4) 0 0; font-size: var(--text-sm); color: var(--color-ink-muted); }

/* ------------------------------------------------------------- home check */
.hub-steps {
  counter-reset: hub-step;
  display: grid;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}
.hub-steps li {
  counter-increment: hub-step;
  position: relative;
  min-height: 2.2rem;
  padding-left: 3rem;
  line-height: 1.6;
}
.hub-steps li::before {
  content: counter(hub-step);
  position: absolute;
  left: 0.2rem;
  top: -0.2rem;
  font: italic 500 1.85rem/1 var(--font-display);
  color: var(--color-pen);
}

/* ------------------------------------------------------------- FAQ: questions are h3 headings */
.hub-faq-q {
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  color: inherit;
}

/* ------------------------------------------------------------- closing frame */
.hub-closing .section-title { max-width: 22ch; text-wrap: balance; }
.hub-closing p { max-width: 62ch; }
.hub-closing .cta-row { margin-block: var(--space-6); }
.hub-closing__small a { color: var(--color-bone); }
.hub-closing__small a:hover { color: var(--color-brand-primary); }
.hub-closing__share { margin-top: var(--space-4); }
.hub-closing__share .text-link { min-height: 44px; }
