/*
   White, ink and one marker colour (plan, decision 39). Marked means chosen; colour carries no other
   meaning. The sentence is set in Space Grotesk, everything else in Inter, both served from here.
*/

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url("../fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --paper: #FFFFFF;
    --ink: #101828;
    --muted: #475467;
    --line: #E4E7EC;
    --field: #F2F4F7;
    --mark: #FFE45C;
    --text-face: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --sentence-face: "Space Grotesk", "Inter", system-ui, sans-serif;
    --gutter: 3.5rem;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--text-face);
    font-size: 1.0625rem;
    line-height: 1.5;
}

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

a:hover {
    color: var(--muted);
}

:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

h1,
h2 {
    font-family: var(--sentence-face);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

h1 {
    margin-top: 0;
    font-weight: 500;
}

h2 {
    font-weight: 600;
}

/* Header and footer */

.site-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.75rem var(--gutter);
}

.site-name {
    font-family: var(--sentence-face);
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.site-name strong {
    font-weight: 700;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    font-size: 1rem;
}

.site-nav > a {
    padding: 0.75rem 0;
}

.sign-out {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    color: var(--muted);
}

.site-footer {
    padding: 1.375rem var(--gutter);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9375rem;
}

main {
    flex-grow: 1;
    width: 100%;
    max-width: 73.75rem;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 1.5rem var(--gutter) 4.5rem;
}

/* The start: the sentence alone, in the middle of the page. */
main:has(.sentence-text.opening) {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.25rem;
}

.column,
.program {
    max-width: 50.5rem;
    margin: 0 auto;
}

.intro {
    margin: 0;
    font-weight: 500;
    color: var(--muted);
}

/* The sentence */

.sentence-text {
    margin: 0;
    font-family: var(--sentence-face);
    font-weight: 500;
    font-size: clamp(1.625rem, 2.9vw, 2.375rem);
    line-height: 1.5;
    letter-spacing: -0.015em;
}

.sentence-text.opening {
    font-size: clamp(2rem, 5.6vw, 4.75rem);
    line-height: 1.25;
    letter-spacing: -0.025em;
}

/*
   An open word: a field with the word as placeholder, as wide as that word. The page gives the
   number of letters; a letter of the sentence's typeface is a good half em wide on average.
*/
.field input {
    font: inherit;
    letter-spacing: inherit;
    width: calc(var(--letters) * 0.55em + 0.5em);
    max-width: 100%;
    box-sizing: border-box;
    color: var(--ink);
    background: var(--field);
    border: 0;
    border-bottom: 0.1em solid var(--ink);
    border-radius: 0.2em 0.2em 0 0;
    padding: 0 0.16em;
}

.field input::placeholder {
    color: var(--muted);
    opacity: 1;
}

.field input:focus {
    outline: 2px solid var(--ink);
    outline-offset: 4px;
    box-shadow: 0 0 0 4px var(--mark);
}

/* A chosen word: marked, and still to be changed. */
.word {
    font: inherit;
    letter-spacing: inherit;
    color: var(--ink);
    background: var(--mark);
    border: 0;
    border-radius: 0.18em;
    padding: 0 0.2em;
    text-decoration: none;
    cursor: pointer;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

select.word {
    appearance: none;
    -webkit-appearance: none;
}

.word:hover {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.12em;
}

/* The way to send the sentence without script; with script it only shows when it has the focus. */
.go,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 3.25rem;
    padding: 0 1.75rem;
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0.625rem;
    text-decoration: none;
    cursor: pointer;
}

.go {
    margin-top: 1.25rem;
}

.js .go:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
}

/* The choices of a field, with how many programs each one gives. */
.choices {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 38.75rem;
    margin-top: 1.25rem;
}

.choices.open {
    display: flex;
}

/* Without script the list of a field shows while the field, or a choice in the list, is in use. */
html:not(.js) .sentence:has(#subject:focus) #subject-list,
html:not(.js) .sentence:has(#level:focus) #level-list,
html:not(.js) .sentence:has(#near:focus) #near-list,
html:not(.js) .choices:focus-within,
html:not(.js) .choices:hover {
    display: flex;
}

.options,
.answers {
    display: flex;
    flex-direction: column;
}

.options {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.5rem 1.25rem;
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0.75rem;
}

.options:empty {
    display: none;
}

.answers {
    max-width: 38.75rem;
    border-top: 2px solid var(--ink);
}

.options a,
.answers a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    box-sizing: border-box;
    min-height: 3.5rem;
    padding: 0.875rem 0.125rem;
    border-bottom: 1px solid var(--line);
    font-size: 1.1875rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
}

.options a:last-child {
    border-bottom: 0;
}

.options a.any {
    font-weight: 400;
}

.options a strong {
    font-weight: 600;
}

.options a:hover,
.answers a:hover {
    text-decoration: underline;
}

/* The choice the arrow keys are on. */
.options a.active {
    margin: 0 -1.25rem;
    padding-left: 1rem;
    padding-right: 1.25rem;
    border-left: 0.25rem solid var(--ink);
    background: var(--field);
}

.count {
    flex-shrink: 0;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.choices-note,
.choices-hint,
.hint {
    margin: 0;
    font-size: 1rem;
    color: var(--muted);
}

.choices-note:empty {
    display: none;
}

/* How many programs fit, and what can be added to the sentence. */
.fit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 1.75rem;
    row-gap: 0.25rem;
    margin-top: 1.125rem;
}

.fit p {
    margin: 0;
}

.fit strong {
    font-weight: 600;
}

.fit.opening {
    margin-top: 2.25rem;
    font-size: 1.3125rem;
}

.marked {
    padding: 0.125rem 0.5rem;
    background: var(--mark);
    border-radius: 0.375rem;
}

.more {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--muted);
    text-decoration: underline dotted;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.3em;
}

.more:hover {
    color: var(--ink);
}

/* The question that shortens a list too long to read through. */
.question {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2.75rem;
}

.question h2 {
    margin: 0;
    font-size: 1.375rem;
}

.question p {
    margin: 0.75rem 0 0;
}

/* The results: one quiet column. */
.hits {
    list-style: none;
    margin: 2.75rem 0 0;
    padding: 0;
    border-top: 2px solid var(--ink);
}

.hits li {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--line);
}

.hits h2 {
    margin: 0;
    font-size: 1.5rem;
}

.hits h2 a {
    text-decoration: none;
}

.hits h2 a:hover {
    text-decoration: underline;
}

.hits p {
    margin: 0;
}

.provider,
.reference,
dt {
    color: var(--muted);
}

.hits .provider {
    font-size: 1rem;
}

.hits .summary {
    max-width: 68ch;
    margin-top: 0.25rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.facts {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.5rem;
    row-gap: 0.25rem;
    margin-top: 0.375rem;
    font-size: 1rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.paging {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: center;
    margin-top: 2rem;
}

.notice {
    margin: 1.5rem 0 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--ink);
    background: var(--field);
}

/* The page of a program and the administration. */
.program h1,
main > h1 {
    font-size: clamp(1.75rem, 3.4vw, 2.5rem);
    font-weight: 600;
    overflow-wrap: anywhere;
}

dd {
    margin: 0 0 0.75rem 0;
}

.description {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.facts-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
}

.facts-list dd {
    margin: 0;
}

.starts {
    border-collapse: collapse;
}

.starts th,
.starts td {
    padding: 0.35rem 1rem 0.35rem 0;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

/* A phone. */
@media (max-width: 40rem) {
    :root {
        --gutter: 1.25rem;
    }

    .site-header {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .site-name {
        font-size: 1.125rem;
    }

    main {
        padding-top: 0.75rem;
        padding-bottom: 2rem;
    }

    .sentence-text {
        font-size: 1.75rem;
    }

    .sentence-text.opening {
        font-size: 2rem;
    }

    .fit.opening {
        font-size: 1.125rem;
    }

    .question .button {
        display: flex;
    }

    .hits h2 {
        font-size: 1.3125rem;
    }
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}
