/* The only file that holds color literals (hex and rgb). Everything else reads these variables. */
:root {
  color-scheme: light dark;

  --ml-bg: #FFFFFF;
  --ml-surface: #F4F4F5;
  --ml-text: #18181B;
  --ml-text-muted: #52525B;
  --ml-border: #E4E4E7;
  --ml-button-bg: #18181B;
  --ml-button-text: #FFFFFF;
  --ml-focus: #18181B;
  --ml-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.10);

  --sc-bg: #F5F7FB;
  --sc-surface: #FFFFFF;
  --sc-surface-raised: #FFFFFF;
  --sc-text: #0F172A;
  --sc-text-muted: #4B5563;
  --sc-accent: #1D4ED8;
  --sc-primary: #15803D;
  --sc-primary-text: #FFFFFF;
  --sc-primary-edge: #0E5A2B;
  --sc-border: #D6DCE5;
  --sc-trail: #F3EBDD;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

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

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ml-bg: #09090B;
    --ml-surface: #18181B;
    --ml-text: #FAFAFA;
    --ml-text-muted: #A1A1AA;
    --ml-border: #27272A;
    --ml-button-bg: #FAFAFA;
    --ml-button-text: #09090B;
    --ml-focus: #FAFAFA;
    --ml-shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 8px 24px rgb(0 0 0 / 0.45);

    --sc-bg: #0B1020;
    --sc-surface: #131A2E;
    --sc-surface-raised: #1B2440;
    --sc-text: #F1F5F9;
    --sc-text-muted: #AEB8CC;
    --sc-accent: #7AA7FF;
    --sc-primary: #4ADE80;
    --sc-primary-text: #052E16;
    --sc-primary-edge: #1E8E4E;
    --sc-border: #2A3452;
    --sc-trail: #16203A;
  }
}

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

html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

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

h1, h2, h3 { margin: 0 0 var(--space-4); }
h1 { font-size: clamp(2rem, 1.4rem + 3vw, 3rem); line-height: 1.1; font-weight: 700; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem); line-height: 1.2; font-weight: 700; }
h3 { font-size: 1.25rem; line-height: 1.3; font-weight: 650; }
p, ul, ol { margin: 0 0 var(--space-4); }

img { max-width: 100%; height: auto; }
picture { display: block; }

a {
  color: var(--ml-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 120ms ease-out, text-decoration-thickness 120ms ease-out;
}
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ml-focus); outline-offset: 2px; border-radius: 4px; }
.sc :focus-visible { outline-color: var(--sc-accent); }

.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
@media (min-width: 600px) { .container { padding-inline: 32px; } }

main:focus { outline: none; }
.muted { color: var(--ml-text-muted); }
.sc .muted { color: var(--sc-text-muted); }
.lead { font-size: 1.1875rem; max-width: 60ch; }

.skip-link {
  position: absolute; left: var(--space-2); top: var(--space-2); z-index: 10;
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 var(--space-4);
  background: var(--ml-surface); color: var(--ml-text); border-radius: var(--radius-md);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* Header */
.site-header { background: var(--ml-bg); border-bottom: 1px solid var(--ml-border); }
.site-header__inner { display: flex; flex-direction: column; }
.wordmark {
  display: inline-flex; align-items: center; align-self: flex-start; min-height: 56px;
  font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; text-decoration: none; color: var(--ml-text);
}
.wordmark span { font-weight: 400; color: var(--ml-text-muted); margin-left: 0.25em; }
.site-nav { display: flex; gap: var(--space-1); margin-left: -12px; font-size: 0.9375rem; }
.site-nav a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 12px; text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
@media (min-width: 600px) {
  .site-header__inner { flex-direction: row; align-items: center; justify-content: space-between; min-height: 64px; }
  .wordmark { font-size: 1.25rem; min-height: 64px; }
  .site-nav { gap: var(--space-2); margin-left: 0; margin-right: -12px; font-size: 1rem; }
}

/* Footer */
.site-footer { background: var(--ml-surface); padding-block: var(--space-7); font-size: 0.875rem; line-height: 1.5; }
.site-footer__inner { display: flex; flex-direction: column; gap: var(--space-3); }
.site-footer__copy { margin: 0; }
.site-footer__nav { display: flex; flex-direction: column; }
.site-footer__nav a { display: inline-flex; align-items: center; min-height: 48px; overflow-wrap: anywhere; }
.site-footer__notice { margin: 0; max-width: 70ch; color: var(--ml-text-muted); }
@media (min-width: 960px) {
  .site-footer__inner { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: var(--space-6); }
  .site-footer__nav { flex-direction: row; justify-content: flex-end; gap: var(--space-5); }
  .site-footer__notice { grid-column: 1 / -1; }
}

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 var(--space-5);
  background: var(--ml-button-bg); color: var(--ml-button-text); border-radius: var(--radius-pill);
  font-size: 1.0625rem; font-weight: 600; text-decoration: none;
}
.button:hover { text-decoration: underline; }
.button--green {
  background: var(--sc-primary); color: var(--sc-primary-text); border-bottom: 4px solid var(--sc-primary-edge);
  font-family: var(--font-rounded); font-weight: 700;
}
.badge-link { display: inline-flex; align-items: center; min-height: 48px; margin-bottom: var(--space-4); }
.badge { display: block; height: 48px; width: auto; }

/* Home */
.intro { padding-top: var(--space-7); padding-bottom: var(--space-6); }
.intro h1 { max-width: 20ch; }
.intro .lead { margin: 0; }
.section-apps h2 { margin-bottom: var(--space-5); }
.section-more { padding-top: var(--space-8); padding-bottom: var(--space-8); }
@media (min-width: 960px) { .intro { padding-top: var(--space-9); padding-bottom: var(--space-8); } }

.sc { color: var(--sc-text); }
.sc a { color: var(--sc-accent); }
.sc .button--green { color: var(--sc-primary-text); }
.sc h1, .sc h2, .sc h3, .division__number { font-family: var(--font-rounded); font-weight: 700; }
.sc h1 { font-weight: 800; }

.app-card {
  background: var(--sc-surface); border: 1px solid var(--sc-border); border-radius: var(--radius-xl);
  padding: var(--space-5); display: grid; gap: var(--space-5);
}
.app-card h3 { font-size: 1.75rem; margin-bottom: var(--space-3); }
.eyebrow { margin: var(--space-3) 0 var(--space-1); color: var(--sc-text-muted); font-size: 0.875rem; font-weight: 600; }
.app-card__shots { display: flex; gap: 12px; align-items: center; justify-content: center; }
.app-card__shots .shot { flex: 0 0 calc((100% - 12px) / 2); }
.hide-narrow { display: none; }
@media (min-width: 600px) {
  .app-card__shots { gap: var(--space-4); }
  .app-card__shots .shot { flex: 0 1 200px; }
  .hide-narrow { display: block; }
}
@media (min-width: 960px) {
  .app-card { grid-template-columns: 5fr 7fr; padding: var(--space-7) 40px; gap: var(--space-6); align-items: center; }
}

/* Screenshots and Andy */
.shot {
  border: 1px solid var(--ml-border); border-radius: var(--radius-xl); box-shadow: var(--ml-shadow); overflow: hidden;
}
.sc .shot { border-color: var(--sc-border); }
.shot img { display: block; width: 100%; height: auto; }
.andy { display: block; max-width: none; object-fit: contain; }
.andy--card { width: 96px; height: 96px; }
.andy--hero { width: 160px; height: 160px; }
@media (min-width: 600px) {
  .andy--card { width: 120px; height: 120px; }
  .andy--hero { width: 200px; height: 200px; }
}

/* Spell Champ page */
.sc-page { background: var(--sc-bg); padding-block: var(--space-7); }
.sc-page .block, .sc-page .hero, .sc-page .closing { margin-bottom: var(--space-7); }
.sc-page .block > h2 { margin-bottom: var(--space-4); }
.measure { max-width: 60ch; }
.hero { display: flex; flex-direction: column; gap: var(--space-4); }
.hero__text > p { max-width: 60ch; }
.hero__links { margin-top: 0; }
.hero__links a { display: inline-flex; align-items: center; min-height: 48px; }
.divisions { list-style: none; padding: 0; display: grid; gap: var(--space-4); }
.card {
  background: var(--sc-surface); border: 1px solid var(--sc-border); border-radius: var(--radius-xl); padding: var(--space-5);
}
.card > :last-child { margin-bottom: 0; }
.division__number { margin: 0; font-size: 2.5rem; font-weight: 800; line-height: 1.1; color: var(--sc-accent); }
.features { display: grid; gap: var(--space-7); }
.feature { display: grid; gap: var(--space-4); }
.feature__media { display: flex; justify-content: center; }
.feature__media .shot { width: min(72vw, 280px); }
.bullets { padding-left: 1.25em; }
.audience { display: grid; gap: var(--space-4); margin-top: var(--space-5); }
.closing {
  background: var(--sc-trail); border-radius: var(--radius-xl); padding: var(--space-5); text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.closing .andy { margin-inline: auto; }
.closing p { margin-bottom: var(--space-3); }
.closing a:not(.button):not(.badge-link) { display: inline-flex; align-items: center; min-height: 48px; }
.fine-print { max-width: 70ch; font-size: 0.875rem; line-height: 1.5; color: var(--sc-text-muted); margin: 0; }
@media (min-width: 600px) { .closing { padding: 40px; } }
@media (min-width: 960px) {
  .sc-page { padding-block: var(--space-8); }
  .hero { flex-direction: row-reverse; align-items: center; justify-content: space-between; }
  .hero__text { flex: 7; }
  .hero__art { flex: 5; display: flex; justify-content: center; }
  .divisions { grid-template-columns: repeat(3, 1fr); }
  .feature { grid-template-columns: 1fr 280px; align-items: center; gap: var(--space-8); }
  .feature--flip { grid-template-columns: 280px 1fr; }
  .feature--flip .feature__text { order: 2; }
  .feature__media .shot { width: 280px; }
  .audience { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 959px) { .hero__art { order: -1; } }

/* Support and reading layouts */
.reading { max-width: 1120px; padding-top: var(--space-7); padding-bottom: var(--space-8); }
.reading > * { max-width: 70ch; }
.contact-box { background: var(--ml-surface); border-radius: var(--radius-lg); padding: var(--space-5); margin-block: var(--space-6); }
.contact-box h2 { font-size: 1.5rem; }
.contact-box p { margin: 0; }
.email-link { display: inline-block; min-height: 48px; line-height: 48px; overflow-wrap: anywhere; }
.faq { margin-bottom: var(--space-6); }
.faq p { margin: 0; }

/* Privacy */
.privacy { font-size: 1.0625rem; line-height: 1.65; }
.privacy .lead { font-size: 1.1875rem; }
.toc { max-width: 70ch; margin-block: var(--space-6); }
.toc__label { font-size: 0.875rem; font-weight: 600; color: var(--ml-text-muted); margin-bottom: var(--space-2); }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc a { display: inline-block; padding-block: var(--space-1); }
@media (min-width: 960px) { .toc ol { columns: 2; column-gap: var(--space-6); } .toc li { break-inside: avoid; } }
.privacy section { margin-top: var(--space-7); }
.privacy h2 { font-size: 1.25rem; font-weight: 700; scroll-margin-top: 24px; }
.privacy p { margin-bottom: var(--space-4); }
.privacy .bullet { padding-left: 1.25em; text-indent: -1.25em; }
.source-note {
  margin-top: var(--space-7); padding-top: var(--space-4); border-top: 1px solid var(--ml-border);
  font-size: 0.875rem; line-height: 1.5; color: var(--ml-text-muted); overflow-wrap: anywhere;
}
.source-note code { font-family: var(--font-mono); }

/* 404 */
.not-found { max-width: 40ch; padding-top: var(--space-7); padding-bottom: var(--space-8); text-align: center; }
.not-found > * { margin-inline: auto; }
@media (min-width: 600px) { .not-found { padding-top: var(--space-9); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
