:root { color-scheme: light dark; --bg: #fff; --text: #172133; --muted: #536277; --line: #c7d0dd; --surface: #f3f6fa; --accent: #0055bc; --good: #176338; --bad: #ae2635; --focus: #805100; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6; font-size: 1.0625rem; }
a { color: var(--accent); text-underline-offset: .22em; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); padding: .8rem 1.2rem; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
h1:focus { outline: none; }
h1 { font-size: 1.18rem; line-height: 1.4; font-weight: 650; margin: 0 0 1rem; }
h2 { font-size: 1rem; margin: 0 0 .7rem; color: var(--muted); }
p { margin: 0 0 1.25rem; }
.site-header { padding-bottom: 1.75rem; text-align: center; }
.branding { padding: 2.5rem 1.25rem 0; text-align: center; }
.branding a { display: inline-flex; border-radius: 8px; background: transparent; padding: 13px 20px; }
.branding img { display: block; width: min(244px, 65vw); height: auto; }
.domain { display: flex; gap: .7rem; align-items: center; justify-content: center; font-size: .8rem; letter-spacing: .07em; color: var(--muted); margin: .7rem auto 0; }
.domain::before, .domain::after { content: ''; height: 1px; width: 25px; background: var(--line); }
main { width: min(100% - 2.5rem, 640px); margin: 0 auto; min-height: 24rem; }
body:has(.branding[hidden]) main { padding-top: .5rem; }
.sentence { color: var(--accent); font-size: clamp(1.45rem, 3.6vw, 1.9rem); line-height: 1.5; font-weight: 600; margin-block: 1.4rem 1.7rem; overflow-wrap: break-word; }
.instruction { color: var(--muted); font-size: .95rem; }
.choices { display: grid; gap: .8rem; margin-bottom: 1.8rem; container-type: inline-size; }
.choice { text-align: left; display: flex; align-items: center; gap: 1rem; background: var(--bg); color: var(--text); min-height: 64px; font-size: 1.15rem; }
.radio-ring { flex: 0 0 20px; height: 20px; border: 2px solid var(--muted); border-radius: 50%; }
.primary { color: white; background: #0055bc; border-color: #0055bc; }
.secondary { color: var(--accent); background: var(--bg); }
.summary { padding: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 1rem; }
.summary h1 { font-size: 1.6rem; margin-bottom: .5rem; }
.score { margin: 0; font-size: 1.15rem; font-weight: 600; }
.review { padding: 0; list-style: none; margin: 2rem 0; }
.review-card { padding: 1.5rem 0; border-bottom: 1px solid var(--line); content-visibility: auto; contain-intrinsic-size: auto 300px; }
.review-card .sentence { font-size: 1.2rem; margin: .5rem 0 1.1rem; }
.review-choices { list-style: none; padding: 0; display: grid; gap: .5rem; }
.review-choices li { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; padding: .4rem .6rem; border-radius: 6px; }
.answer-mark { font-size: .9rem; }
.correct { color: var(--good); background: var(--surface); }
.incorrect { color: var(--bad); background: var(--surface); }
footer { margin-top: 0; }
summary { cursor: pointer; min-height: 44px; padding-block: .5rem; color: var(--text); }
details p { margin-block: 1rem; }
.skip-link { position: absolute; left: 1rem; top: -8rem; padding: .75rem; background: var(--bg); z-index: 1; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
@media (prefers-color-scheme: dark) { :root { --bg: #101827; --text: #edf2fa; --muted: #a9b8ce; --line: #40516c; --surface: #1a263b; --accent: #80b6ff; --good: #83dca2; --bad: #ffa4ae; --focus: #ffcf70; } }
@media (max-height: 520px) { .branding { padding-top: 1rem; } .site-header { padding-bottom: 1rem; } }
@media (forced-colors: active) { .choice, .summary { border: 1px solid ButtonText; } }
@container (width < 17.5rem) { .choice { margin-inline: -1rem; padding-inline: .6rem; gap: .6rem; } }


/* The footer follows a full-height activity area and never covers the controls. */
.page-content {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
}
.page-content > main {
    flex: 1 0 auto;
    padding-bottom: 4rem;
}

/* Keep enlarged Quiz headings inside narrow footer columns. */
footer .footer-heading { overflow-wrap: anywhere; }

/* Footer navigation is grouped by purpose and stays open at every size.
   The brand, the link groups and Connect share one grid, so every column
   gap is equal and the last column ends flush with the legal links below.
   The two link groups sit in a subgrid to keep their named navigation. */
footer.site-footer {
    --footer-ink: var(--ink, var(--text));
    --footer-link: var(--brand, var(--accent));
    --footer-line: var(--border, var(--line));
    --footer-gap: 3rem;
    flex-shrink: 0;
    width: 100%;
    margin-inline: auto;
    margin-bottom: 0;
    padding: 3rem 1.5rem 1.5rem;
    border-top: 1px solid var(--footer-line);
    color: var(--muted);
    text-align: left;
    overflow-wrap: anywhere;
    font-size: .875rem;
    line-height: 1.6;
}
footer .footer-inner { max-width: 72rem; margin: 0 auto; container: site-footer / inline-size; }
footer .footer-main {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
    gap: 2.5rem var(--footer-gap);
}
footer.footer-native .footer-main { grid-template-columns: minmax(0, 1fr) minmax(9rem, max-content) max-content; }
footer .footer-brand { min-width: 0; }
footer .footer-brand img { display: block; width: 140px; max-width: 100%; height: auto; }
footer .footer-tagline { max-width: 17rem; margin: .875rem 0 0; padding: 0; color: var(--muted); font-size: .875rem; line-height: 1.6; text-wrap: balance; }
footer .footer-navigation {
    display: grid;
    grid-column: span 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-columns: subgrid;
    gap: 0 var(--footer-gap);
    margin: 0;
}
footer.footer-native .footer-navigation { grid-column: span 1; grid-template-columns: minmax(0, 1fr); grid-template-columns: subgrid; }
footer .footer-heading {
    margin: 0 0 .75rem;
    padding: 0;
    border: 0;
    font: 600 .75rem/1.5 var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
}
footer .links {
    display: grid;
    align-items: start;
    justify-content: start;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}
footer .links li { min-width: 0; }
footer .links a { overflow-wrap: anywhere; }
footer .links a,
footer .footer-social,
footer .footer-legal a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    max-width: 100%;
    padding: .45rem 0;
    color: var(--footer-ink);
    font-size: .875rem;
    line-height: 1.5;
    font-weight: 400;
    text-decoration: none;
    overflow-wrap: anywhere;
    border-radius: 2px;
}
footer a:hover { color: var(--footer-link); }
footer a:focus-visible { outline: 2px solid var(--footer-link); outline-offset: 4px; }
/* Connect follows the same 44 pixel rows as the link lists. The badge keeps
   more than Apple's minimum clear space of a quarter of its height. */
footer .footer-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; }
footer .app-store-badge { display: inline-flex; padding: 2px 10px; margin-left: -10px; border-radius: 6px; }
footer .app-store-link { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; color: var(--footer-link); font-size: .875rem; overflow-wrap: anywhere; }
footer .app-store-badge img { display: block; width: 120px; height: 40px; }
footer .footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem 2rem;
    margin-top: 2.5rem;
    padding-top: .75rem;
    border-top: 1px solid var(--footer-line);
}
footer .copyright { margin: 0; font-size: .75rem; }
footer .footer-legal { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin: 0; }
footer .footer-legal a { color: var(--muted); font-size: .75rem; }
footer .footer-legal a:hover { color: var(--footer-link); }
footer .trade-name-notice { margin: .5rem 0 0; font-size: .75rem; line-height: 1.6; }
footer .app-store-credit { max-width: 56rem; margin: .5rem 0 0; font-size: .6875rem; line-height: 1.6; }
/* Tablet. The brand takes its own row and the link groups share three
   equal columns. Native footers have room to keep the brand in line. */
@media (max-width: 76rem) {
    footer .footer-main, footer.footer-native .footer-main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    footer .footer-brand { grid-column: 1 / -1; }
    footer.footer-native .footer-brand { grid-column: 1 / -1; }
    footer.footer-native .footer-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Phone. Two link columns, with the brand and Connect each on a full row. */
@media (max-width: 37.5rem) {
    footer.site-footer { --footer-gap: 1.5rem; padding: 2.5rem 1.25rem 1.5rem; }
    footer .footer-main, footer.footer-native .footer-main { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 2rem; }
    footer.footer-native .footer-brand, footer .footer-actions { grid-column: 1 / -1; }
    footer.footer-native .footer-navigation { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr); }
    footer .footer-actions { flex-direction: row; align-items: center; flex-wrap: wrap; column-gap: 1.5rem; }
    footer .footer-actions .footer-heading { flex-basis: 100%; }
    footer .footer-bottom { align-items: flex-start; flex-direction: column; gap: 0; margin-top: 2rem; }
}

/* Reflow follows the actual footer width and its text size. Media queries
   above remain the baseline for browsers without container-query support. */
@container site-footer (max-width: 70em) {
    footer .footer-main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    footer .footer-brand { grid-column: 1 / -1; }
    footer.footer-native .footer-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    footer.footer-native .footer-brand { grid-column: 1 / -1; }
}
@container site-footer (max-width: 48em) {
    footer .footer-main, footer.footer-native .footer-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    footer .footer-brand, footer .footer-actions, footer.footer-native .footer-navigation { grid-column: 1 / -1; }
    footer.footer-native .footer-navigation { grid-template-columns: minmax(0, 1fr); }
    footer .footer-actions { flex-direction: row; align-items: center; flex-wrap: wrap; column-gap: 1.5rem; }
    footer .footer-actions .footer-heading { flex-basis: 100%; }
}
@container site-footer (max-width: 14em) {
    footer .footer-main, footer.footer-native .footer-main { grid-template-columns: minmax(0, 1fr); }
    footer .footer-navigation { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr); row-gap: 2rem; }
}


.leave-dialog { width: min(32rem, calc(100% - 2rem)); max-height: calc(100% - 2rem); overflow: auto; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; }
.leave-dialog::backdrop { background: rgb(0 0 0 / .6); }
.leave-dialog h2 { font-size: 1.25rem; color: var(--text); margin: 0 0 1rem; }
.leave-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 1rem; margin-top: 1.5rem; }
.leave-actions button { font: inherit; padding: .75rem 1.25rem; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.leave-dialog:focus,
.leave-dialog:focus-visible,
.leave-actions button:focus,
.leave-actions button:focus-visible { outline: none; }


/* Enlarged question text and choice labels retain their content width. */
main { overflow-wrap: anywhere; }
.choice > strong { min-width: 0; overflow-wrap: anywhere; }
.summary { padding-inline: min(1.5rem, 10%); }

/* Wait, What? questions, locked choices and feedback in the same view. */
.question { font-size: clamp(1.3rem, 3.2vw, 1.6rem); line-height: 1.45; font-weight: 650; margin-block: 1.2rem 1.4rem; overflow-wrap: break-word; }
.condition { color: var(--muted); font-size: .95rem; margin: -.4rem 0 1.4rem; }
.choice-label { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.choice-label > strong { min-width: 0; overflow-wrap: anywhere; }
.choice:disabled { cursor: default; }
.choice.selected .radio-ring { background: currentColor; box-shadow: inset 0 0 0 3px var(--bg); }
.choice.correct { border-color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
.choice.incorrect { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.choice .answer-mark { font-size: .95rem; font-weight: 600; }
.choice.correct .answer-mark { color: var(--good); }
.choice.incorrect .answer-mark { color: var(--bad); }
.feedback { margin: 0 0 2rem; padding: 1.25rem min(1.5rem, 6%); background: var(--surface); border: 1px solid var(--line); border-inline-start: 6px solid var(--good); border-radius: 16px; }
.feedback.is-incorrect { border-inline-start-color: var(--bad); }
.feedback h2 { font-size: 1.25rem; color: var(--text); margin: 0 0 .5rem; }
[tabindex="-1"]:focus { outline: none; }
.verdict-detail { font-weight: 600; margin-bottom: .75rem; }
.explanation { margin-bottom: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .8rem; }
.actions button { max-width: 100%; }
.review-card .question { font-size: 1.15rem; margin: .5rem 0 1rem; }
.review-card .explanation { margin: 1rem 0 0; }

/* Edition links sit directly under the logo, as in Practice and School. The Wait, What? name line follows. */
/* Language entry in the page header. It is a sibling of the logo and domain, which the results screen hides, so it stays at every step.
   Scoped to the header so no other link or button changes. */
.site-header .language-entry { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; justify-content: center; margin: 1rem auto 0; color: var(--muted); font-size: .95rem; }
.site-header:has(.branding[hidden]) { padding-top: 1rem; padding-bottom: .5rem; }
.site-header:has(.branding[hidden]) .language-entry { margin-top: 0; }
.site-header .language-entry .language-option { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; max-width: 100%; min-width: 0; }
.site-header .language-entry .language-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .5rem 1.25rem; border-radius: 999px; border: 1px solid #0055bc; background: #0055bc; color: #fff; font-weight: 600; text-decoration: none; }
.site-header .language-entry .language-link:hover { background: #00459a; border-color: #00459a; }
.site-header .language-entry .language-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Language choices wrap as paired units at narrow widths. */
.site-header .language-entry .language-link { padding: .35rem .8rem; font-size: .9rem; min-height: 44px; }
.site-header .language-entry + .domain { margin-top: 1rem; }

/* Exit buttons stay inside the dialog on narrow phones with enlarged text, in every edition.
   The dialog uses a little more of a narrow screen, and labels may wrap rather than overflow. */
.leave-dialog { width: min(32rem, calc(100% - 1rem)); padding-inline: min(1.5rem, 5%); }
.leave-actions button { max-width: 100%; overflow-wrap: anywhere; }

/* Fun Quiz note directly above its Wait, What? link, as one compact group.
   The link keeps its 44 pixel target, which extends below the text. */
footer .links .footer-fun-quiz { padding-top: .45rem; }
footer .links .footer-fun-quiz .footer-note { display: block; line-height: 1.5; }
footer .links .footer-fun-quiz a { padding-top: 0; align-items: flex-start; vertical-align: top; }
