/*
 * Every interactive control on the site: dropdowns, filter inputs, and the
 * model toggle.
 *
 * WEB-10. Before this there were four treatments of the same `<select>`:
 *
 *   1. `background: white; border: 2px solid #333`, inline in chart.html,
 *      weekly.html and lines.html -- a white box on a dark page;
 *   2. `border: 2px solid #ff6600` in upcoming.css, for `.week-picker`;
 *   3. that same orange rule again as a 200-character `style=` attribute,
 *      pasted verbatim into upcoming.html, previous_week.html and
 *      historical_week.html;
 *   4. `border: 2px solid rgba(102,126,234,.3)` in chart.css, for the two
 *      chart filters.
 *
 * And `.model-toggle` had no rules at all -- it rendered as body text and a
 * default browser link, on every page, since WEB-8.
 *
 * The tokens below are not a new palette. They are the values already
 * load-bearing elsewhere in the site, named once so a control cannot drift
 * from the page it sits on: the panel and accent are the table and navbar's,
 * the hairline is the table border, the radius is the nav button's.
 *
 * Loaded by both skeletons. The site has two -- the sacred views open with a
 * bare <html> and their own sheets, while everything else extends base.html --
 * so this is linked six times rather than folded into base.css, which
 * base.html does not load. Adding base.css there instead would have brought
 * its `h1` and `h1::after` rules onto pages that style their heading through
 * `.main-title`, which is a visual change to a sacred view and not what was
 * asked for.
 */

:root {
    --control-surface: rgba(30, 41, 59, 0.7);
    --control-surface-hover: rgba(30, 41, 59, 0.95);
    --control-border: rgba(102, 126, 234, 0.35);
    --control-border-hover: rgba(102, 126, 234, 0.8);
    --control-ink: #ffffff;
    --control-ink-muted: #94a3b8;
    --control-radius: 8px;
    --accent-start: #667eea;
    --accent-end: #764ba2;
}

/*
 * Applied by element, not by class. The controls are spread over nine
 * templates under five different wrappers -- `.year-selector`, `.controls`,
 * `.week-picker`, `.dropdown-container` and none at all -- and a class-based
 * rule would have meant editing every one of them to opt in, which is how the
 * four treatments happened in the first place.
 */
select,
input[type="text"],
input[type="search"] {
    padding: 10px 16px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: var(--control-ink);
    background-color: var(--control-surface);
    border: 2px solid var(--control-border);
    border-radius: var(--control-radius);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

input[type="text"],
input[type="search"] {
    cursor: text;
    min-width: 200px;
}

/* The native arrow is drawn in the OS's colours and cannot be recoloured, so
   it reads as a light-mode artefact on a dark control. Replaced with an inline
   SVG -- a data URI, because the site loads no icon font and one glyph is not
   worth a request. */
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

select:hover,
input[type="text"]:hover,
input[type="search"]:hover {
    background-color: var(--control-surface-hover);
    border-color: var(--control-border-hover);
}

/* Keyboard focus has to be visible and has to differ from hover -- hover moves
   the border colour, so focus moves the ring. */
select:focus-visible,
input[type="text"]:focus-visible,
input[type="search"]:focus-visible {
    outline: 2px solid var(--accent-start);
    outline-offset: 2px;
}

/* The open dropdown is drawn by the OS and inherits nothing from the control.
   Left alone it is white-on-white in a dark browser theme. */
select option {
    background-color: #1e293b;
    color: var(--control-ink);
}

input::placeholder {
    color: var(--control-ink-muted);
    opacity: 1; /* Firefox dims placeholders by default; the muted ink already has. */
}

/*
 * There is deliberately no bare `label` rule here.
 *
 * One was written and removed. `<label>` is used for two unrelated jobs in
 * this codebase -- the caption beside a control, and the clickable text of
 * each team in `/chart`'s checkbox list -- and an element rule cannot tell
 * them apart. `.team-checkbox label` sets only cursor, font-weight and
 * user-select, so a global `text-transform: uppercase` would have won on the
 * properties it does not set and rendered all 138 team names in caps; the
 * same rule turned "Select Year:" into "SELECT YEAR:" on two sacred views.
 *
 * The cascade golden cannot catch this. It compares selector to selector, and
 * this is one selector reaching past another with different specificity --
 * which `tests/test_css.py` says in as many words is the part still needing a
 * human. Labels keep their per-page rules.
 */

/* ------------------------------------------------------------------------
 * The model toggle
 *
 * A segmented control rather than a label and a link. It has exactly two
 * mutually exclusive states and shows which one is live, which is what a
 * segment group is for -- and "switch to Elo" as a sentence made the reader
 * work out that the *other* word was the current one.
 * ---------------------------------------------------------------------- */

.model-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 18px 0;
}

.model-toggle-label {
    color: var(--control-ink-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.model-switch {
    display: inline-flex;
    padding: 3px;
    background: var(--control-surface);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 999px;
}

.model-option {
    padding: 7px 20px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--control-ink-muted);
    text-decoration: none;
    border-radius: 999px;
    transition: color 0.2s ease, background 0.2s ease;
}

/*
 * `.model-option` is a <span> and an <a> in the model toggle, and two
 * <button>s in the lines page's view switch. A button brings the UA's own
 * background and border with it, so without this reset the inactive segment
 * renders as a light pill on a dark page while the identical <span> beside it
 * renders correctly -- which is exactly how it shipped until a screenshot
 * showed it.
 *
 * `font-family` rather than the `font` shorthand: `font: inherit` here would
 * out-specify `.model-option` above and throw away its size and weight.
 */
button.model-option {
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

.model-option:hover {
    color: var(--control-ink);
}

.model-option.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent-start) 0%, var(--accent-end) 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.model-option:focus-visible {
    outline: 2px solid var(--accent-start);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    select,
    input[type="text"],
    input[type="search"],
    .model-option {
        transition: none;
    }
}
