:root {
  --red: #d71920;
  --red-dark: #9f1118;
  --gold: #d4af37;
  --charcoal: #2f2f2f;
  --muted: #6b7280;
  --background: #fafafa;
  --card: #ffffff;
  --line: #eeeeee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--background);
  color: var(--charcoal);
}

.site-header {
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  border: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -1px;
}

.brand p {
  margin: 3px 0 0;
  color: var(--gold);
  font-weight: bold;
}

nav {
  display: flex;
  gap: 28px;
}

nav a {
  color: var(--charcoal);
  text-decoration: none;
  font-weight: bold;
}

nav a:hover {
  color: var(--red);
}

.hero {
  padding: 90px 40px;
  background:
    radial-gradient(circle at top right, rgba(215,25,32,0.12), transparent 35%),
    linear-gradient(180deg, white, #fafafa);
}

.hero div {
  max-width: 900px;
  margin: auto;
}

.eyebrow {
  color: var(--red);
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 2px;
  font-weight: bold;
}

.hero h2 {
  font-size: 56px;
  line-height: 1.05;
  margin: 10px 0 20px;
  letter-spacing: -2px;
}

.hero-text {
  max-width: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.5;
}

.primary-button {
  display: inline-block;
  margin-top: 18px;
  background: var(--red);
  color: white;
  text-decoration: none;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: bold;
  box-shadow: 0 12px 25px rgba(215,25,32,0.22);
}

.primary-button:hover {
  background: var(--red-dark);
}

main {
  max-width: 1150px;
  margin: auto;
  padding: 50px 40px 80px;
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading h2 {
  font-size: 34px;
  margin: 6px 0 0;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
}

.topic-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px;
  text-decoration: none;
  color: var(--charcoal);
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 35px rgba(0,0,0,0.09);
}

.icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #fff3f3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 18px;
}

.topic-card h3 {
  margin: 0 0 10px;
  font-size: 21px;
}

.topic-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.card-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--red);
  font-weight: bold;
}

button {
  background: var(--red);
  color: white;
  border: none;
  padding: 11px 18px;
  margin-top: 8px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
}

button:hover {
  background: var(--red-dark);
}

.question-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  padding: 18px;
  margin: 16px 0;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

.answer {
  display: none;
  background: #fff8df;
  padding: 12px;
  margin-top: 10px;
  border-radius: 10px;
  border-left: 4px solid var(--red);
}

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--red);
  text-decoration: none;
  font-weight: bold;
}

@media (max-width: 900px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 24px;
  }

  nav {
    gap: 16px;
    flex-wrap: wrap;
  }

  .hero {
    padding: 60px 24px;
  }

  .hero h2 {
    font-size: 40px;
  }

  main {
    padding: 40px 24px;
  }
}
.spaced-section {
  margin-top: 60px;
}
.topic-hero {
  background: white;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 34px;
  margin-bottom: 28px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
}

.topic-hero h2 {
  font-size: 48px;
  margin: 8px 0 12px;
  letter-spacing: -1.5px;
}

.topic-hero p {
  color: var(--muted);
  font-size: 18px;
}

.learning-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.learning-menu a {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  text-decoration: none;
  color: var(--charcoal);
  font-weight: bold;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

.learning-menu a:hover {
  color: var(--red);
  transform: translateY(-2px);
}

.content-section {
  margin-bottom: 60px;
}

.content-section h2 {
  font-size: 32px;
  margin-bottom: 18px;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.04);
}

.panel h3 {
  margin-top: 0;
}

.progress-box {
  margin: 20px 0;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  margin-bottom: 8px;
}

.progress-bar {
  background: #eeeeee;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
}

#progressFill {
  background: linear-gradient(90deg, var(--red), var(--gold));
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.checklist {
  display: grid;
  gap: 12px;
}

.checklist label {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}

.checklist input {
  margin-right: 10px;
}
.checklist-section {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin: 18px 0;
}

.checklist-section h4 {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--charcoal);
}

.mini-progress-bar {
  background: #eeeeee;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.mini-fill {
  background: linear-gradient(90deg, var(--red), var(--gold));
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.quiz-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.quiz-stats div {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

.quiz-stats strong {
  display: block;
  font-size: 30px;
  color: var(--red);
  margin-bottom: 6px;
}

.quiz-stats span {
  color: var(--muted);
  font-weight: bold;
}

input[type="number"] {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 16px;
  margin-right: 8px;
  max-width: 180px;
}
.mastery-message {
  display: none;
  margin-top: 16px;
  background: #fff8df;
  border: 1px solid var(--gold);
  border-left: 6px solid var(--gold);
  border-radius: 16px;
  padding: 16px;
  font-weight: bold;
  color: var(--charcoal);
}

.content-section a {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--gold);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.content-section a:hover {
  color: var(--red-dark);
  border-bottom-color: var(--red);
}

#combinedProgressFill,
#tripleProgressFill {
  background: linear-gradient(90deg, var(--red), var(--gold));
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.section-intro {
  color: var(--muted);
  font-size: 17px;
  max-width: none;
  line-height: 1.5;
}

/* ---------- Additional Resources ---------- */

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.resource-card {
  display: block;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  text-decoration: none;
  transition: 0.25s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}

.resource-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.10);
}

.resource-type {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.resource-title {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--charcoal);
}

.resource-description {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Mobile improvements ---------- */

@media (max-width: 700px) {
  body {
    font-size: 16px;
  }

  .brand h1 {
    font-size: 24px;
  }

  .brand p {
    font-size: 14px;
  }

  .logo {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .hero h2,
  .topic-hero h2 {
    font-size: 34px;
    line-height: 1.1;
  }

  .hero-text,
  .topic-hero p {
    font-size: 17px;
  }

  .topic-grid,
  .learning-menu,
  .resource-grid,
  .quiz-stats {
    grid-template-columns: 1fr;
  }

  .topic-card,
  .panel,
  .question-card,
  .resource-card,
  .checklist-section {
    border-radius: 18px;
    padding: 18px;
  }

  .checklist label {
    padding: 16px;
    line-height: 1.45;
  }

  .checklist input {
    transform: scale(1.25);
    margin-right: 12px;
  }

  button,
  .primary-button {
    width: 100%;
    padding: 14px 18px;
    font-size: 17px;
  }

  input[type="number"] {
    width: 100%;
    max-width: none;
    margin: 8px 0 12px;
  }

  .answer {
    line-height: 1.5;
  }

  .question-card p {
    line-height: 1.5;
  }
}

/* Allows long equations/formulae to scroll rather than spill off phone screens */
.question-card,
.answer,
.panel,
.checklist label {
  overflow-wrap: anywhere;
}

/* ---------- Header navigation ---------- */

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}

.home-button {
  display: none;
  color: var(--red);
  font-weight: bold;
  text-decoration: none;
}

.menu-toggle {
  display: none;
}

/* Desktop nav stays normal */
#mainNav {
  display: flex;
  gap: 28px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: white;
}

/* Mobile header */
@media (max-width: 900px) {
  .site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: white;
}

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .home-button,
  .menu-toggle {
    display: block;
    background: #fafafa;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 11px 14px;
    text-align: center;
    font-size: 15px;
  }

  .menu-toggle {
    width: auto;
    margin: 0;
    color: var(--charcoal);
    font-weight: bold;
  }

  #mainNav {
    display: none;
    grid-column: 1 / -1;
    background: white;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px;
    gap: 8px;
  }

  #mainNav.show {
    display: grid;
    grid-template-columns: 1fr;
  }

  #mainNav a {
    display: block;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
  }
}

@media (max-width: 900px) {
  .menu-toggle {
    display: block !important;
  }

  .home-button {
    display: block !important;
  }

  #mainNav {
    display: none !important;
  }

  #mainNav.show {
    display: grid !important;
  }
}

.back-link {
  position: sticky;
  top: 90px;
  z-index: 900;
  display: inline-block;
  background: white;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

@media (max-width: 900px) {
  .back-link {
    top: 145px;
  }
}

.site-header {
  position: sticky !important;
  top: 0;
  z-index: 1000;
  background: white;
  display: flex;
  align-items: center;
  width: 100%;
}

.header-actions {
  margin-left: auto;
}

#mainNav {
  margin-left: auto;
}

/* Additional Resources card grid */
.additional-resources-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  align-items: stretch;
}

.additional-resources-grid .resource-card {
  width: auto;
  min-width: 0;
  height: 100%;
}

@media (max-width: 1000px) {
  .additional-resources-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .additional-resources-grid {
    grid-template-columns: 1fr;
  }
}

/* Additional Resources category headings */
.resource-category > h4 {
  margin: 28px 0 18px;
  padding: 10px 14px;
  font-size: 1.15rem;
  font-weight: 750;
  color: #222;
  background: #f7f7f7;
  border-left: 4px solid #e3ad18;
  border-radius: 6px;
}

.resource-category:first-of-type > h4 {
  margin-top: 8px;
}

/* ==================================================
   TOPIC PAGE NAVIGATION
   ================================================== */

/* Desktop/tablet topic header */
.topic-page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}

/* Back to GCSE Topics inside the header */
.header-back-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;

  color: var(--red);
  text-decoration: none;
  font-weight: 700;

  border-radius: 10px;

  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.header-back-link:hover {
  background: #fff8df;
  color: var(--red-dark);
  transform: translateX(-2px);
}

.header-back-mobile {
  display: none;
}

/* Home icon */
.home-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 44px;
  height: 44px;

  border-radius: 12px;

  text-decoration: none;
  font-size: 23px;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.home-icon:hover {
  background: #fafafa;
  transform: translateY(-1px);
}


/* ==================================================
   BACK TO TOP
   ================================================== */

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 950;

  width: 44px !important;
  height: 44px;
  min-width: 44px;

  margin: 0;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 2px solid var(--gold);
  border-radius: 50%;

  background: var(--red);
  color: var(--gold);

  font-size: 25px;
  font-weight: 800;
  line-height: 1;

  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.16);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transform: translateY(8px);

  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.back-to-top:hover {
  background: var(--red-dark);
  transform: translateY(-2px);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}


/* ==================================================
   MOBILE TOPIC HEADER
   ================================================== */

@media (max-width: 700px) {

  .topic-page-header {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;

    gap: 8px;
    padding: 12px 14px;
  }

  .topic-page-header .brand {
    gap: 10px;
    min-width: 0;
  }

  .topic-page-header .logo {
    width: 42px;
    height: 42px;
    font-size: 21px;
    border-radius: 13px;
  }

  .topic-page-header .brand h1 {
    font-size: 20px;
    white-space: nowrap;
  }

  .topic-page-header .brand p {
    display: none;
  }

  /* Mobile gets a discreet arrow rather than text */
  .header-back-full {
    display: none;
  }

  .header-back-mobile {
    display: inline;
  }

  .header-back-link {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;

    justify-content: center;

    border: 1px solid var(--line);
    border-radius: 12px;

    background: #fafafa;

    font-size: 22px;
  }

  .home-icon {
    width: 40px;
    height: 40px;
    font-size: 21px;
  }

  .back-to-top {
    width: 42px !important;
    height: 42px;
    min-width: 42px;

    right: 14px;
    bottom: 14px;

    font-size: 23px;
  }
}

.back-to-top-arrow {
  width: 25px;
  height: 25px;

  fill: none;
  stroke: var(--gold);
  stroke-width: 2.8;

  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==================================================
   GENERATE NEW QUIZ
   ================================================== */

.new-quiz-box {
  display: flex;
  justify-content: center;
  margin: 28px 0 10px;
}

.new-quiz-button {
  margin: 0;
  padding: 12px 20px;
  background: white;
  color: var(--red);
  border: 2px solid var(--red);
  box-shadow: none;
}

.new-quiz-button:hover {
  background: var(--red);
  color: white;
}

@media (max-width: 700px) {
  .new-quiz-button {
    width: 100%;
  }
}

#quiz {
  scroll-margin-top: 110px;
}

/* ==================================================
   COLLAPSIBLE CHECKLIST
   ================================================== */

.checklist-content {
  overflow: hidden;
  transition:
    max-height 0.35s ease,
    opacity 0.25s ease,
    margin-top 0.25s ease;
}

.checklist-content.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.checklist-content.expanded {
  max-height: 5000px;
  opacity: 1;
  margin-top: 18px;
}

.checklist-toggle {
  width: auto;
  margin-top: 14px;
  padding: 10px 16px;

  background: white;
  color: var(--red);

  border: 2px solid var(--red);
  border-radius: 999px;

  box-shadow: none;
}

.checklist-toggle:hover {
  background: #fff6f6;
  color: var(--red-dark);
}

@media (max-width: 700px) {
  .checklist-toggle {
    width: 100%;
  }
}

/* ==================================================
   TOPIC PAGE SECTIONS
   ================================================== */

.topic-section {
  margin: 64px 0;
  scroll-margin-top: 110px;
}

/* Clear heading area for each major section */

.topic-section-heading {
  display: flex;
  align-items: center;
  gap: 14px;

  margin-bottom: 24px;
  padding-bottom: 16px;

  border-bottom: 2px solid var(--line);
}

.topic-section-heading h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.5px;
}

.topic-section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.topic-section-icon {
  width: 48px;
  flex: 0 0 48px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 34px;
  line-height: 1;
}


/* Give the sections a subtle visual identity */

.checklist-section-main .topic-section-heading {
  border-bottom-color: var(--gold);
}

.notes-section .topic-section-heading,
.resources-section .topic-section-heading,
.quiz-section .topic-section-heading,
.exam-section .topic-section-heading {
  border-bottom-color: var(--red);
}


/* Mobile */

@media (max-width: 700px) {

  .topic-section {
    margin: 44px 0;
  }

  .topic-section-heading {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }

  .topic-section-heading h2 {
    font-size: 25px;
  }

  .topic-section-heading p {
    font-size: 15px;
  }

  .topic-section-icon {
  width: 40px;
  flex-basis: 40px;
  font-size: 29px;
}
}

/* ==================================================
   HOMEPAGE COMPACT DESKTOP LAYOUT
   ================================================== */

@media (min-width: 901px) {

  body.home-page .hero {
    padding: 42px 40px 34px;
  }

  body.home-page .hero h2 {
    font-size: 48px;
    margin: 8px 0 14px;
  }

  body.home-page .hero-text {
    font-size: 18px;
    line-height: 1.4;
    margin-bottom: 0;
  }

  body.home-page main {
    padding: 28px 40px 36px;
  }

  body.home-page .topic-grid {
    gap: 18px;
  }

  body.home-page .topic-card {
    padding: 22px;
  }

  body.home-page .icon {
    width: 46px;
    height: 46px;
    font-size: 23px;
    margin-bottom: 14px;
  }

  body.home-page .topic-card h3 {
    margin-bottom: 7px;
  }

  body.home-page .card-link {
    margin-top: 14px;
  }
}

.section-heading > h2 + .eyebrow {
  margin-top: 12px;
  margin-bottom: 0;
}