/* TutorPlace public site. Hand-written, no build step, no third-party CSS.
   Tokens follow the newer GP7 web apps (gp7-play / gp7-library design-tokens.css):
   system fonts, 4/8-pt grid, 12px cards, 44px hit targets, GP7 blue as the action colour.
   The warm gradient is TutorPlace's own brand colour and is used for the hero only.

   Themes (R380): dark is the default and lives on :root, so a page is dark even before any script runs.
   Light is the [data-theme="light"] override below. The attribute is set by the one-line script in each
   page's <head> (before this file is read, so the wrong theme is never painted) and by the header button
   (site.js). Every colour is a custom property: a rule never names a colour of its own, except white text
   on the fixed-colour buttons and hero. Text and controls meet WCAG AA in both themes (ratios in the README). */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;

  --radius-card: 12px;
  --radius-control: 8px;
  --hit-target: 44px;

  --header-h: 60px;
  --page-max: 1080px;

  /* Dark theme (the default). */
  color-scheme: dark;
  --color-bg: #0e1115;
  --color-surface: #161a20;
  --color-surface-hover: #1d222a;
  --color-separator: #2a313b;
  --color-button-border: #3a424e;
  --color-label: #eef1f5;
  --color-secondary-label: #a7b0bd;
  /* Filled buttons: white text on these in both themes. */
  --color-accent: #337ab7;
  --color-accent-strong: #285f8f;
  --color-on-accent: #ffffff;
  /* Links and other accent-coloured text. */
  --color-link: #7fbdf0;
  --color-accent-soft: #17293a;
  --color-attention: #ff9257;
  /* Brand: the bright pair is decoration only; the hero pair carries white text. */
  --brand-from: #d53369;
  --brand-to: #daae51;
  --brand-ink: #f29bb8;
  --hero-from: #b8254f;
  --hero-to: #8f5e12;
  --color-on-hero: #ffffff;
  --color-video-bg: #1c1f24;
}

[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f2f4f7;
  --color-surface: #ffffff;
  --color-surface-hover: #f2f4f7;
  --color-separator: #e2e5ea;
  --color-button-border: #c5cad3;
  --color-label: #14171c;
  --color-secondary-label: #515864;
  --color-link: #285f8f;
  --color-accent-soft: #e6f1fa;
  --color-attention: #e8590c;
  --brand-ink: #7a1d3d;
  --hero-from: #c22a5c;
  --hero-to: #9a6410;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--color-label);
  background: var(--color-bg);
}

img,
svg {
  max-width: 100%;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  font-weight: 800;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.125rem);
  font-weight: 750;
}

h3 {
  font-size: 1.125rem;
  font-weight: 650;
}

p {
  margin: 0;
}

a {
  color: var(--color-link);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-attention);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.skip {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 50;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-button-border);
  border-radius: var(--radius-control);
}

.skip:focus {
  top: var(--space-2);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-separator);
}

.site-header .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--hit-target);
  font-size: 1.3125rem;
  font-weight: 800;
  color: var(--color-label);
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 28px;
  height: 28px;
}

.site-nav {
  display: none;
  gap: var(--space-1);
  margin-left: var(--space-4);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-target);
  padding: 0 var(--space-3);
  color: var(--color-secondary-label);
  text-decoration: none;
  font-size: 1rem;
  border-radius: var(--radius-control);
}

.site-nav a:hover {
  color: var(--color-label);
  background: var(--color-surface-hover);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* The light / dark switch: one 44px button, always in the header, so nothing moves when it is used.
   It shows what a click gives: a sun while the page is dark, a moon while it is light. Without the
   <head> script (no JavaScript) the page stays dark and the button, which could do nothing, is not shown;
   its place is kept. */
.theme-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--hit-target);
  height: var(--hit-target);
  padding: 0;
  border: 1px solid var(--color-button-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-label);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--color-surface-hover);
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
}

.theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

html:not([data-theme]) .theme-toggle {
  visibility: hidden;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--hit-target);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-primary:hover {
  background: var(--color-accent-strong);
}

.btn-quiet {
  background: var(--color-surface);
  color: var(--color-link);
  border-color: var(--color-button-border);
}

.btn-quiet:hover {
  background: var(--color-accent-soft);
}

.btn-large {
  min-height: 52px;
  padding: 0 var(--space-6);
  font-size: 1.125rem;
}

.btn-compact {
  padding: 0 var(--space-4);
}

/* ---------- Hero ---------- */

.hero {
  background: linear-gradient(100deg, var(--hero-from) 0%, var(--hero-to) 100%);
  color: var(--color-on-hero);
  padding: var(--space-7) 0 var(--space-8);
}

.hero-grid {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

.hero p.lede {
  margin-top: var(--space-4);
  font-size: 1.25rem;
  max-width: 34em;
}

.hero-art {
  display: none;
}

.doors {
  margin-top: calc(-1 * var(--space-7));
  display: grid;
  gap: var(--space-4);
}

.door {
  background: var(--color-surface);
  border: 1px solid var(--color-separator);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.door .who {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-ink);
}

.door p {
  color: var(--color-secondary-label);
}

.door .actions {
  margin-top: auto;
  padding-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---------- Sections ---------- */

.section {
  padding: var(--space-8) 0 0;
}

.section:last-of-type {
  padding-bottom: var(--space-8);
}

.section > .wrap > h2 + p {
  margin-top: var(--space-3);
  color: var(--color-secondary-label);
  max-width: 44em;
}

.cards {
  margin-top: var(--space-5);
  display: grid;
  gap: var(--space-4);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-separator);
  border-radius: var(--radius-card);
  padding: var(--space-5);
}

.card h2 {
  font-size: 1.125rem;
  font-weight: 650;
}

.card p {
  margin-top: var(--space-2);
  color: var(--color-secondary-label);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-3);
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-link);
  font-weight: 750;
}

.feature-list {
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-4) var(--space-6);
}

.feature-list li {
  padding-left: var(--space-5);
  position: relative;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(100deg, var(--brand-from), var(--brand-to));
}

.feature-list strong {
  display: block;
}

.feature-list span {
  color: var(--color-secondary-label);
}

.price {
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: var(--space-2);
}

.fineprint {
  margin-top: var(--space-4);
  font-size: 0.9375rem;
  color: var(--color-secondary-label);
  max-width: 52em;
}

/* ---------- Video: one reserved 16:9 box; the player loads only after a click ---------- */

.video {
  position: relative;
  margin-top: var(--space-5);
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 860px;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--color-video-bg);
}

.video iframe,
.video .video-start {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video .video-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
  font: inherit;
  font-weight: 650;
  color: var(--color-on-hero);
  text-align: center;
  cursor: pointer;
  background: linear-gradient(100deg, var(--hero-from), var(--hero-to));
}

.video .video-start svg {
  width: 64px;
  height: 64px;
}

.video .video-start small {
  font-weight: 400;
  opacity: 0.92;
}

/* ---------- Guides: a secondary list, collapsed until asked for ---------- */

.guides {
  margin-top: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-separator);
  border-radius: var(--radius-card);
}

.guides details + details {
  border-top: 1px solid var(--color-separator);
}

.guides summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) var(--space-5);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.guides summary::-webkit-details-marker {
  display: none;
}

.guides summary::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-left: 7px solid var(--color-link);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 120ms ease-out;
}

.guides details[open] > summary::before {
  transform: rotate(90deg);
}

.guides summary .tag {
  margin-left: auto;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-secondary-label);
  white-space: nowrap;
}

.guides .guide-body {
  padding: 0 var(--space-5) var(--space-5);
}

.guides .guide-body .video {
  margin-top: 0;
}

.guides .guide-body p {
  margin-bottom: var(--space-3);
  color: var(--color-secondary-label);
}

/* ---------- Plain pages (help, terms) ---------- */

.page {
  padding: var(--space-7) 0 var(--space-8);
}

.page h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

.page .lede {
  margin-top: var(--space-3);
  color: var(--color-secondary-label);
  max-width: 40em;
}

.legal {
  margin-top: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-separator);
  border-radius: var(--radius-card);
  /* The legal text brings its own 30px margin (kept unchanged); the card adds none. */
  padding: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  /* Only the spacing around the unchanged legal text is narrowed on a phone, so lines are not 25 characters long. */
  .legal > div {
    margin: var(--space-4) !important;
  }
}

/* The legal text sets its own colour (black) in the page; it follows the theme instead. */
.legal > div {
  color: var(--color-label) !important;
}

.legal ul,
.legal ol {
  padding-left: var(--space-5);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--color-separator);
  background: var(--color-surface);
  padding: var(--space-5) 0;
  font-size: 0.9375rem;
  color: var(--color-secondary-label);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  margin-left: auto;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-target);
}

/* ---------- Wider screens ---------- */

@media (min-width: 720px) {
  .doors {
    grid-template-columns: 1fr 1fr;
  }

  /* R448 571 B: the free math practice card spans both columns under the two doors */
  .door-wide {
    grid-column: 1 / -1;
  }

  .cards.three {
    grid-template-columns: repeat(3, 1fr);
  }

  .feature-list {
    grid-template-columns: 1fr 1fr;
  }

  .wrap {
    padding: 0 var(--space-5);
  }
}

@media (min-width: 960px) {
  .site-nav {
    display: flex;
  }

  .hero-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .hero-art {
    display: block;
    justify-self: end;
    width: 100%;
    max-width: 420px;
    height: auto;
  }

  .feature-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* On a phone the header keeps only what a visitor came for: join or sign in. */
@media (max-width: 420px) {
  .brand {
    font-size: 1.125rem;
  }

  .header-actions .btn {
    padding: 0 var(--space-3);
    font-size: 0.9375rem;
  }

  /* Room for the light / dark switch beside the two doors: the name stays, its small picture goes. */
  .brand img {
    display: none;
  }

  .site-header .wrap {
    gap: var(--space-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .guides summary::before {
    transition: none;
  }
}
