/*
 * Served as a content-hashed stylesheet, cached hard.  No web fonts, no external
 * requests: the system font stack and about 4 KB of CSS.
 */

:root {
    color-scheme: light dark;
    --bg: #ffffff;
    --fg: #16181d;
    --muted: #5c6370;
    --line: #e2e5ea;
    --card: #f6f7f9;
    --chip: #eaedf1;
    --tier-common: #1a7f4b;
    --tier-standard: #6b7280;
    --tier-rare: #a06a1b;
    --accent: #1a5fb4;
    --accent-fg: #ffffff;
    --maxw: 46rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --fg: #e8eaed;
        --muted: #a0a6b0;
        --line: #2b2f36;
        --card: #1c1f25;
        --chip: #262b34;
        --tier-common: #5fd39b;
        --tier-standard: #9aa2ae;
        --tier-rare: #d9b45f;
        --accent: #78aeff;
        --accent-fg: #10131a;
    }
}

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    /*
    Font size must be at least 16px on input elements (16px -> 1rem here) to prevent iOS
    from autozooming when focused on an input field.  Thanks to blog post by Rick Strahl:
    https://weblog.west-wind.com/posts/2023/Apr/17/Preventing-iOS-Textbox-Auto-Zooming-and-ViewPort-Sizing
    */
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    background: var(--bg);
    color: var(--fg);
}

.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

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

/* ---------- header ---------- */

.site-header {
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.75rem;
}

.site-header .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 1.25rem;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--fg);
    text-decoration: none;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.95rem;
}

/* ---------- headings and prose ---------- */

h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 0.75rem; }
h2 { font-size: 1.25rem; margin: 2.25rem 0 0.6rem; }
h3 { font-size: 1.02rem; margin: 1.5rem 0 0.4rem; }
.subhead { font-size: 0.62em; font-weight: normal; color: var(--muted); display: block; }
.lede { font-size: 1.08rem; margin: 0 0 1.5rem; }
.muted { color: var(--muted); }

p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.3rem; }
li { margin-bottom: 0.3rem; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.25rem;
    padding: 0.05rem 0.3rem;
}

/* ---------- search ---------- */

.search {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    padding: 1rem;
    margin: 0 0 2rem;
}

.search > label { display: block; font-weight: 600; margin-bottom: 0.4rem; }

/* Mode switch. Which reading of the input is about to run is a decision the user
   makes, not something inferred from whether they happened to type a "?". */
.modes {
    border: 0;
    padding: 0;
    margin: 0 0 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
}

.modes legend {
    float: left;
    width: 100%;
    padding: 0;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.modes label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.modes input { margin: 0; accent-color: var(--accent); }

.explainer {
    font-size: 0.92rem;
    color: var(--muted);
    margin: 0.55rem 0 0;
    min-height: 1.4em;
}

.explainer strong { color: var(--fg); letter-spacing: 0.04em; }

.search .hint { font-size: 0.88rem; color: var(--muted); margin: 0.6rem 0 0; }

.search-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.75rem;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.filters input[type="text"], .filters select {
    flex: 0 0 auto;
    width: auto;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: normal;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 0.3rem;
    background: var(--bg);
    color: var(--fg);
}

.filters input[type="text"] { width: 3.2rem; text-transform: uppercase; text-align: center; }

input[type="text"] {
    font-size: 1rem;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    background: var(--bg);
    color: var(--fg);
    flex: 1 1 12rem;
    min-width: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}

.noscript-note {
    border: 1px solid var(--tier-rare);
    border-radius: 0.4rem;
    padding: 0.7rem 0.85rem;
    margin: 0.9rem 0 0;
    font-size: 0.92rem;
}

.show-all {
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    padding: 0.55rem 1.2rem;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    background: var(--accent);
    color: var(--accent-fg);
    cursor: pointer;
}

/* ---------- results ---------- */

.results-summary { color: var(--muted); margin: 0 0 1.25rem; }

.wordgroup { margin: 0 0 1.75rem; }
.wordgroup h2 { margin-top: 1.75rem; }

/*
 * Tier headings. Everyday words come first; the archaic group is labelled so nobody
 * stakes a turn on "orsel" thinking it is ordinary vocabulary. The dot carries the
 * colour so the heading text stays readable.
 */
.tier-heading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    margin: 1rem 0 0.4rem;
}

.tier-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    flex: 0 0 auto;
    background: currentColor;
}

.tier-dot.tier-common { color: var(--tier-common); }
.tier-dot.tier-standard { color: var(--tier-standard); }
.tier-dot.tier-rare { color: var(--tier-rare); }

/*
 * Flex rather than a grid of fixed columns.  Equal-width columns cannot hold the long
 * tail -- "consubstantiationist" needs about 162px in a 134px cell, and 170 results of
 * a single query overran their background.  Flex items take their content width and
 * then share out what is left, so short words still line up tidily and long ones simply
 * take the room they need.
 */
ul.words {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
}

/*
 * Each result sits on its own rounded fill.  The words are left at normal weight so
 * that the bold "N Letter Words" heading above them stays clearly the heading -- when
 * both were semibold and separated only by a hairline rule, the two ran together.
 */
ul.words li {
    margin: 0;
    padding: 0.3rem 0.6rem;
    background: var(--chip);
    border-radius: 0.4rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;

    /* Start every chip at a common width so short words align, grow to fill the row,
       but never shrink below what the word itself needs. */
    flex: 1 1 8rem;
    min-width: min-content;
    max-width: 100%;
}

ul.words .s {
    font-size: 0.78rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* A score reduced by a blank tile is not the word's face value; mark it. */
ul.words .s-blank { font-style: italic; }

/* Archaic results are dimmed, so the eye lands on the usable words first. */
ul.words.tier-rare li { opacity: 0.72; }

/* ---------- generated pages ---------- */

/* Definition lists carry both the FAQs and the per-page statistics. */
dl { margin: 0 0 1rem; }
dl dt { margin-top: 0.9rem; }
dl dd { margin: 0.2rem 0 0; padding: 0; }

/*
 * The stats block is a two-column table of numbers computed from this page's own words.
 * It collapses to stacked rows on a phone, where two columns would leave the values
 * squeezed against the right edge.
 */
dl.stats {
    display: grid;
    grid-template-columns: minmax(10rem, max-content) 1fr;
    gap: 0.3rem 1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    padding: 0.9rem 1rem;
}

dl.stats dt { margin: 0; color: var(--muted); }
dl.stats dd { margin: 0; }

.breadcrumbs { font-size: 0.88rem; color: var(--muted); }
.breadcrumbs p { margin: 0 0 0.9rem; }
.breadcrumbs .sep { opacity: 0.5; padding: 0 0.15rem; }

/* A-Z rows under a length hub: dense enough to scan, big enough to tap. */
ul.letter-grid {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

ul.letter-grid li { margin: 0; }

ul.letter-grid a {
    display: block;
    min-width: 2.2rem;
    padding: 0.35rem 0.5rem;
    text-align: center;
    background: var(--chip);
    border-radius: 0.4rem;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

ul.letter-grid a:hover { background: var(--line); }

/* Card lists: a link, a count, and a line saying what is behind it. */
ul.cards {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 0.5rem;
}

ul.cards li {
    margin: 0;
    padding: 0.6rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
}

ul.cards .blurb {
    display: block;
    font-size: 0.88rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.anagram-sets .rack { letter-spacing: 0.12em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

ul.linklist { list-style: none; margin: 0 0 1rem; padding: 0; }
ul.linklist li { margin: 0 0 0.35rem; }

/*
 * "There is a page for this search."  Shown when what someone has typed happens to be a
 * question the site already has a page for -- a URL they can share or come back to,
 * rather than state that dies with the tab.
 */
.page-link {
    margin: 0 0 1.25rem;
    padding: 0.6rem 0.8rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 0.4rem;
    font-size: 0.95rem;
}

@media (max-width: 32rem) {
    dl.stats { grid-template-columns: 1fr; gap: 0 1rem; }
    dl.stats dd { margin-bottom: 0.5rem; }
}

/* ---------- footer ---------- */

.site-footer {
    border-top: 1px solid var(--line);
    margin-top: 3rem;
    padding-top: 1.25rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.site-footer p { margin: 0.4rem 0; }

@media (max-width: 32rem) {
    h1 { font-size: 1.6rem; }
    ul.words li { flex-basis: 6.5rem; }
}
