/* ============================================================
   ghsj.me/mowers — riding mower decision tool
   Vanilla CSS. Light/dark via prefers-color-scheme + manual
   data-theme override, matching the rest of the site. Tokens
   first, then layout, then the filter/table/card views.
   ============================================================ */

/* ---------- Tokens ---------- */

:root {
    --accent: #667eea;
    --accent-2: #764ba2;
    --accent-ink: #4f5fd6;
    --bg: #f7f8fc;
    --bg-card: #ffffff;
    --bg-inset: #eef0f8;
    --text: #1f2430;
    --text-soft: #5a6172;
    --text-faint: #70788c;
    --line: #dfe3ef;
    --line-strong: #c9cede;
    --good: #157e4f;
    --good-bg: #e4f4ec;
    --warn: #8a5f10;
    --warn-bg: #fdf1d8;
    --bad: #b8323f;
    --bad-bg: #fceaec;
    --shadow: 0 10px 30px rgba(31, 36, 48, 0.08);
    --radius: 16px;
    --radius-sm: 10px;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent-ink: #9aa8ff;
        --bg: #12141c;
        --bg-card: #1a1d29;
        --bg-inset: #212536;
        --text: #e8eaf2;
        --text-soft: #aab0c2;
        --text-faint: #8a92a8;
        --line: #2b3042;
        --line-strong: #3a4057;
        --good: #46c98a;
        --good-bg: #12321f;
        --warn: #e0a93e;
        --warn-bg: #35290f;
        --bad: #e87c87;
        --bad-bg: #3a1c20;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --accent-ink: #9aa8ff;
    --bg: #12141c;
    --bg-card: #1a1d29;
    --bg-inset: #212536;
    --text: #e8eaf2;
    --text-soft: #aab0c2;
    --text-faint: #8a92a8;
    --line: #2b3042;
    --line-strong: #3a4057;
    --good: #46c98a;
    --good-bg: #12321f;
    --warn: #e0a93e;
    --warn-bg: #35290f;
    --bad: #e87c87;
    --bad-bg: #3a1c20;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

/* ---------- Base ---------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent-ink);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--bg-card);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 0 0 var(--radius-sm) 0;
    z-index: 100;
    font-weight: 600;
}

.skip-link:focus {
    left: 0;
}

/* ---------- Masthead ---------- */

.masthead {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #ffffff;
    padding: 22px 0 52px;
}

/* Same max-width and inline padding as <main>, so the hero text lines up with
   the panel edges below it rather than sitting 24px proud of them. */
.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 68rem;
    margin: 0 auto 26px;
    padding: 0 clamp(16px, 4vw, 24px);
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.crumbs a {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
}

.crumbs a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.crumbs .sep {
    color: rgba(255, 255, 255, 0.45);
}

.theme-toggle {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: none;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
}

.theme-toggle svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
}

.theme-toggle .icon-moon {
    fill: currentColor;
    stroke: none;
}

.theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }

    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: block;
    }
}

.mast-inner {
    max-width: 68rem;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 24px);
}

.masthead h1 {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    letter-spacing: -0.02em;
    line-height: 1.12;
}

.masthead .dek {
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.9);
    max-width: 54ch;
    font-size: 1.05rem;
}

.width-warning {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: rgba(255, 255, 255, 0.94);
    font-size: 0.95rem;
    max-width: 68ch;
}

.width-warning strong {
    color: #ffffff;
}

/* ---------- Layout ---------- */

main {
    max-width: 68rem;
    margin: -28px auto 60px;
    padding: 0 clamp(16px, 4vw, 24px);
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(18px, 3vw, 26px);
    margin-bottom: 20px;
}

.panel h2 {
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.count {
    font-size: 0.9rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.sub {
    color: var(--text-soft);
    font-size: 0.94rem;
    margin-top: 8px;
    max-width: 78ch;
}

/* Comparison panel breaks out of the reading column on wide screens. */
@media (min-width: 1180px) {
    .panel.wide {
        width: min(calc(100vw - 48px), 102rem);
        margin-left: calc(50% - min(calc(100vw - 48px), 102rem) / 2);
    }
}

.needs-js {
    display: none;
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid currentColor;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.no-js .needs-js {
    display: block;
}

/* ---------- Filters ---------- */

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.control {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: var(--bg-inset);
}

.control label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 7px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control input[type="number"],
.control select {
    width: 100%;
    font: inherit;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 10px 12px;
    min-height: 44px;
}

.control select {
    cursor: pointer;
}

.control .unit {
    color: var(--text-faint);
    font-size: 0.9rem;
    font-weight: 600;
    flex: none;
}

.hint {
    margin-top: 7px;
    font-size: 0.8rem;
    color: var(--text-faint);
    line-height: 1.4;
}

.switches {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px 6px;
    margin-top: 16px;
}

.switches legend {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 0 6px;
}

.switch {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 4px;
    cursor: pointer;
    border-radius: 8px;
    min-height: 44px;
}

.switch:hover {
    background: var(--bg-inset);
}

.switch input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex: none;
    accent-color: var(--accent);
    cursor: pointer;
}

.switch strong {
    display: block;
    font-size: 0.96rem;
    font-weight: 600;
}

.switch em {
    display: block;
    font-style: normal;
    font-size: 0.85rem;
    color: var(--text-faint);
    line-height: 1.45;
    margin-top: 1px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.pill.good {
    background: var(--good-bg);
    color: var(--good);
    border-color: currentColor;
}

.pill.warn {
    background: var(--warn-bg);
    color: var(--warn);
    border-color: currentColor;
}

.pill.bad {
    background: var(--bad-bg);
    color: var(--bad);
    border-color: currentColor;
}

.reset {
    appearance: none;
    margin-top: 16px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-ink);
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 9px 18px;
    min-height: 44px;
    cursor: pointer;
}

.reset:hover {
    background: var(--bg-inset);
    border-color: var(--accent-ink);
}

/* ---------- Rank cards ---------- */

.rankcards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.rankcard {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    background: var(--bg-inset);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.rankcard.top {
    border-color: var(--accent-ink);
    border-width: 2px;
    padding: 15px 17px;
}

.rankcard .rank {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.rankcard.top .rank {
    color: var(--accent-ink);
}

.rankcard h3 {
    font-size: 1.1rem;
    line-height: 1.25;
}

.rankcard h3 a {
    text-decoration: none;
    color: var(--text);
}

.rankcard h3 a:hover {
    color: var(--accent-ink);
    text-decoration: underline;
}

.scoreline {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-soft);
}

.scoreline .score {
    font-weight: 800;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    white-space: nowrap;
    flex: none;
}

.scoreline .drive {
    min-width: 0;
    text-align: right;
    line-height: 1.35;
}

.bar {
    height: 7px;
    background: var(--line);
    border-radius: 99px;
    overflow: hidden;
}

.bar > i {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
    transition: width 0.25s ease;
}

.rankcard p {
    font-size: 0.9rem;
    color: var(--text-soft);
    line-height: 1.5;
}

.rankcard .pkg {
    font-size: 0.88rem;
    color: var(--text-soft);
}

.ranknote {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid currentColor;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ranknote strong {
    font-weight: 700;
}

.empty {
    margin-top: 18px;
    padding: 22px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    text-align: center;
    font-size: 0.95rem;
}

/* ---------- Fit chips ---------- */

.fit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
}

.fit-yes {
    background: var(--good-bg);
    color: var(--good);
}

.fit-no {
    background: var(--bad-bg);
    color: var(--bad);
}

.fit-verify {
    background: var(--warn-bg);
    color: var(--warn);
}

.tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 1px 8px;
    color: var(--text-faint);
    white-space: nowrap;
}

.tag.t-verify {
    color: var(--warn);
    border-color: currentColor;
}

.tag.t-yes {
    color: var(--good);
    border-color: currentColor;
}

.tag.t-no {
    color: var(--text-faint);
}

/* ---------- Drive premium ---------- */

.drive-compare {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.drive-cell {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: var(--bg-inset);
}

.drive-cell .dc-label {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.drive-cell .dc-price {
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin-top: 5px;
    letter-spacing: -0.01em;
}

.drive-cell .dc-model {
    font-size: 0.86rem;
    color: var(--text-soft);
    margin-top: 3px;
}

.drive-cell.delta {
    background: transparent;
    border-style: dashed;
    border-color: var(--accent-ink);
}

.drive-cell.delta .dc-price {
    color: var(--accent-ink);
}

.drive-cell.none .dc-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-faint);
}

/* ---------- Comparison table (desktop) ---------- */

.tablewrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-top: 16px;
    max-height: 78vh;
    overscroll-behavior-x: contain;
}

.tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1240px;
    font-size: 0.88rem;
}

.tbl th,
.tbl td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

.tbl thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--bg-card);
    border-bottom: 2px solid var(--line-strong);
    padding: 0;
    white-space: nowrap;
}

/* The one unsortable header carries no button, so it repeats the button's
   padding and type to stay on the same baseline as the rest. */
.tbl thead th.plain {
    padding: 13px 12px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.tbl thead th button {
    appearance: none;
    width: 100%;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: transparent;
    border: 0;
    padding: 13px 12px;
    text-align: left;
    cursor: pointer;
}

.tbl thead th button:hover {
    color: var(--accent-ink);
}

.tbl thead th button::after {
    content: "";
    display: inline-block;
    width: 0.7em;
    margin-left: 4px;
    opacity: 0.55;
}

.tbl thead th[aria-sort="ascending"] button::after {
    content: "▲";
}

.tbl thead th[aria-sort="descending"] button::after {
    content: "▼";
}

.tbl thead th[aria-sort] button {
    color: var(--accent-ink);
}

/* Score + model stay pinned while the rest scrolls horizontally. */
.tbl th:nth-child(1),
.tbl td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-card);
    width: 74px;
    min-width: 74px;
}

.tbl th:nth-child(2),
.tbl td:nth-child(2) {
    position: sticky;
    left: 74px;
    z-index: 3;
    background: var(--bg-card);
    min-width: 190px;
    box-shadow: 1px 0 0 var(--line-strong);
}

.tbl thead th:nth-child(1),
.tbl thead th:nth-child(2) {
    z-index: 6;
}

.tbl tbody tr:last-child td {
    border-bottom: 0;
}

.tbl tbody tr:hover td {
    background: var(--bg-inset);
}

.tbl .score {
    font-weight: 800;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.tbl .model a {
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    color: var(--text);
}

.tbl .model a:hover {
    color: var(--accent-ink);
    text-decoration: underline;
}

.tbl .small {
    display: block;
    font-size: 0.78rem;
    color: var(--text-faint);
    line-height: 1.4;
    margin-top: 3px;
}

.tbl .nowrap {
    white-space: nowrap;
}

.tbl .num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Columns whose content is long enough to shred into one-word lines
   if the browser is left to distribute width on its own. */
.tbl th:nth-child(7),
.tbl td:nth-child(7) {
    min-width: 175px;
}

.tbl th:nth-child(9),
.tbl td:nth-child(9) {
    min-width: 190px;
}

.tbl th:nth-child(10),
.tbl td:nth-child(10) {
    min-width: 195px;
}

.tbl th:nth-child(11),
.tbl td:nth-child(11) {
    min-width: 185px;
}

.tbl td.note-cell {
    min-width: 275px;
    max-width: 360px;
    color: var(--text-soft);
}

.tbl .excluded td {
    opacity: 0.62;
}

/* ---------- Comparison cards (mobile) ---------- */

.cardlist {
    display: none;
    margin-top: 16px;
    gap: 14px;
    flex-direction: column;
}

.mcard {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-inset);
    padding: 16px;
}

.mcard-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.mcard-head h3 {
    font-size: 1.05rem;
    line-height: 1.25;
}

.mcard-head h3 a {
    text-decoration: none;
    color: var(--text);
}

.mcard-head h3 a:hover {
    color: var(--accent-ink);
    text-decoration: underline;
}

.mcard-head .status {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-top: 3px;
}

.mcard-score {
    flex: none;
    text-align: right;
}

.mcard-score b {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.mcard-score span {
    font-size: 0.72rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mcard .fit {
    margin-top: 12px;
}

.mcard dl {
    margin-top: 14px;
    display: grid;
    grid-template-columns: minmax(90px, 34%) 1fr;
    gap: 8px 12px;
    font-size: 0.88rem;
}

.mcard dt {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding-top: 2px;
}

.mcard dd {
    color: var(--text);
    line-height: 1.45;
}

.mcard dd .small {
    display: block;
    font-size: 0.79rem;
    color: var(--text-faint);
    line-height: 1.4;
    margin-top: 2px;
}

.mcard .mnote {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 0.88rem;
    color: var(--text-soft);
    line-height: 1.5;
}

.mcard.excluded {
    opacity: 0.72;
}

@media (max-width: 899px) {
    .tablewrap {
        display: none;
    }

    .cardlist {
        display: flex;
    }
}

/* ---------- Notes, caveats, sources ---------- */

.notes {
    list-style: none;
    margin-top: 16px;
}

.notes li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 14px;
    color: var(--text-soft);
    font-size: 0.95rem;
    line-height: 1.6;
}

.notes li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.62em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.notes li:last-child {
    margin-bottom: 0;
}

.notes strong {
    color: var(--text);
}

.caveats {
    border-left: 4px solid var(--warn);
}

.caveats .notes li::before {
    background: var(--warn);
}

.sources summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05rem;
    list-style-position: outside;
}

.sources summary:hover {
    color: var(--accent-ink);
}

.linklist {
    list-style: none;
    margin-top: 14px;
    display: grid;
    gap: 9px;
}

.linklist li {
    font-size: 0.9rem;
    padding-left: 16px;
    position: relative;
}

.linklist li::before {
    content: "↗";
    position: absolute;
    left: 0;
    color: var(--text-faint);
    font-size: 0.8rem;
}

footer {
    text-align: center;
    color: var(--text-faint);
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 0 clamp(16px, 4vw, 24px) 48px;
    max-width: 60rem;
    margin: 0 auto;
}

footer a {
    color: var(--text-soft);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
