/* Home page. Detail pages keep using style.css + details/detail-style.css. */

:root {
    --paper: #f6f4ee;
    --paper-raised: #fbfaf6;
    --ink: #1c1b19;
    --ink-soft: #4a4740;
    --muted: #6f6b62;
    --rule: #d9d4c8;
    --track: #e3ded2;
    --hover: #efebe2;
    --accent: #c4410c;
    --done: #2f6f4f;

    --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
    --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

    /* Segmented bar geometry: block width + gap */
    --seg: 6px;
    --gap: 2px;
}

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

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 1040px;
    margin: 0 auto;
    padding: 56px 24px 64px;
}

a { color: inherit; }

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    background: var(--ink);
    color: var(--paper);
    padding: 8px 14px;
    text-decoration: none;
    z-index: 3000;
}
.skip-link:focus { top: 12px; }

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

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- masthead */

.masthead {
    padding-bottom: 32px;
    border-bottom: 2px solid var(--ink);
}

.wordmark {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 20px;
}

h1 {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(2.4rem, 6.5vw, 4.25rem);
    line-height: 1.04;
    letter-spacing: -0.02em;
    max-width: 14ch;
}


.tally {
    margin-top: 32px;
    font-family: var(--mono);
    font-size: 0.95rem;
    color: var(--ink-soft);
}
.tally-part { white-space: nowrap; }
.tally strong { color: var(--ink); font-weight: 500; }

/* ---------------------------------------------------------------- bars */

.progress-bar {
    position: relative;
    height: 14px;
    /* the empty blocks */
    background: repeating-linear-gradient(90deg, var(--track) 0 var(--seg), transparent var(--seg) calc(var(--seg) + var(--gap)));
}

.progress-fill {
    display: block;
    height: 100%;
    width: 0;
    /* filled blocks share the track's phase, so they land exactly on top of it */
    background: repeating-linear-gradient(90deg, var(--ink) 0 var(--seg), transparent var(--seg) calc(var(--seg) + var(--gap)));
}


.is-done .progress-fill {
    background: repeating-linear-gradient(90deg, var(--done) 0 var(--seg), transparent var(--seg) calc(var(--seg) + var(--gap)));
}

/* ---------------------------------------------------------------- controls */

.controls-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 14px 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}

.filter-pills { display: flex; flex-wrap: wrap; gap: 4px 18px; }

.filter-btn {
    background: none;
    border: none;
    font: inherit;
    font-size: 0.92rem;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}

.filter-btn:hover { color: var(--ink); }
.filter-btn.active { color: var(--ink); border-bottom-color: var(--ink); }

.controls-right { display: flex; align-items: center; gap: 18px; }

.search-input {
    width: 150px;
    font: inherit;
    font-size: 0.92rem;
    color: var(--ink);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--rule);
    padding: 4px 0;
    outline: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-bottom-color: var(--ink); }

/* ---------------------------------------------------------------- sections + rows */

.category-section { margin-top: 48px; }

.category-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ink);
}

.category-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
}

.stat-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 300px) 4.6rem 3.4rem;
    align-items: center;
    gap: 24px;
    padding: 16px 8px;
    margin: 0 -8px;
    border-bottom: 1px solid var(--rule);
    color: inherit;
    text-decoration: none;
}

a.stat-card:hover { background: var(--hover); }
a.stat-card:hover h3 { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.row-text h3 { font-size: 1.02rem; font-weight: 600; line-height: 1.3; }

.description {
    margin-top: 2px;
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.45;
}

.percentage {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 500;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.is-done .percentage { color: var(--done); }

.share-btn {
    justify-self: end;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.8rem;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
}
.stat-card:hover .share-btn,
.stat-card:focus-within .share-btn,
.share-btn:focus-visible { opacity: 1; }
.share-btn:hover { color: var(--ink); text-decoration: underline; }

@media (hover: none) { .share-btn { opacity: 1; } }

.empty-state {
    padding: 48px 0;
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--muted);
}

/* ---------------------------------------------------------------- daily round */

.daily { margin-top: 40px; }
.daily[hidden] { display: none; }

.daily-meta { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

.daily-list { list-style: none; }

.daily-q { padding: 18px 0 16px; border-bottom: 1px solid var(--rule); }
.daily-q[data-state="pending"] { display: none; }

.daily-q-num { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }

.daily-q-text {
    margin-top: 4px;
    font-family: var(--serif);
    font-weight: 400;
    font-size: 1.3rem;
    line-height: 1.3;
    letter-spacing: -0.005em;
    max-width: 40ch;
}

.daily-q-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4.6rem auto;
    align-items: center;
    gap: 16px;
    max-width: 760px;
    margin-top: 14px;
}

.guess-bar {
    height: 22px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.daily-q[data-state="active"] .guess-bar { cursor: ew-resize; }

.guess-bar .progress-fill,
.guess-fill {
    position: absolute;
    left: 0;
    top: 0;
}

.guess-fill {
    height: 100%;
    background: repeating-linear-gradient(90deg, var(--accent) 0 var(--seg), transparent var(--seg) calc(var(--seg) + var(--gap)));
}
.daily-q[data-state="done"] .guess-fill { display: none; }

.guess-mark {
    position: absolute;
    top: -5px;
    bottom: -5px;
    width: 2px;
    margin-left: -1px;
    background: var(--accent);
}

.daily-q-value { text-align: right; }
.daily-q[data-state="active"] .daily-q-value { color: var(--accent); }

.daily-submit {
    font: inherit;
    font-size: 0.88rem;
    background: var(--ink);
    color: var(--paper);
    border: none;
    padding: 7px 14px;
    cursor: pointer;
}
.daily-submit:hover { background: #000; }

.daily-q-result {
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--ink-soft);
}
.daily-q-result:empty { display: none; }
.daily-q-result a { color: var(--ink); text-underline-offset: 2px; }

.daily-end { padding: 20px 0 4px; }
.daily-end[hidden] { display: none; }

.daily-score {
    font-family: var(--serif);
    font-size: 2rem;
    line-height: 1.1;
}
.daily-total { font-weight: 500; }

.daily-share {
    margin: 14px 0 12px;
    font-family: var(--mono);
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--ink);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.daily-foot {
    margin-top: 12px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
}

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

footer {
    margin-top: 64px;
    padding-top: 20px;
    border-top: 2px solid var(--ink);
    font-size: 0.85rem;
    color: var(--muted);
}


/* ---------------------------------------------------------------- share modal + toast */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 27, 25, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.active { display: flex; }

.modal-card {
    width: 100%;
    max-width: 480px;
    background: var(--paper-raised);
    border: 1px solid var(--ink);
    padding: 24px;
}

.modal-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.modal-header h3 { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; }
.close-btn { background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; }
.close-btn:hover { color: var(--ink); }

.stat-quote-box {
    font-family: var(--serif);
    font-size: 1.05rem;
    line-height: 1.45;
    padding: 12px 0 16px;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 16px;
    overflow-wrap: anywhere;
}

.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.btn {
    font: inherit;
    font-size: 0.88rem;
    padding: 7px 12px;
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--hover); }
.primary-btn { background: var(--ink); color: var(--paper); }
.primary-btn:hover { background: #000; }

.embed-section label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.embed-row { display: flex; gap: 8px; }
.embed-input {
    flex: 1;
    min-width: 0;
    font-family: var(--mono);
    font-size: 0.75rem;
    padding: 6px 8px;
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink-soft);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 16px);
    background: var(--ink);
    color: var(--paper);
    font-size: 0.88rem;
    padding: 9px 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 720px) {
    .page { padding: 32px 16px 48px; }
    .controls-bar { position: static; }
    .controls-right { width: 100%; justify-content: space-between; }
    .search-input { flex: 1; width: auto; }

    .stat-card {
        grid-template-columns: minmax(0, 1fr) 4.2rem auto;
        gap: 8px 16px;
        padding: 14px 0;
        margin: 0;
    }
    .row-text { grid-column: 1 / -1; }
    .progress-bar { grid-column: 1; }
    .percentage { grid-column: 2; }
    .share-btn { grid-column: 3; opacity: 1; }

    .daily { margin-top: 28px; }
    .daily-q-text { font-size: 1.15rem; }
    .daily-q-row { grid-template-columns: minmax(0, 1fr) 3.4rem; gap: 12px; }
    .daily-submit { grid-column: 1 / -1; justify-self: start; }
}
