/* Signal — fact-first news. Minimal, HN-inspired. */

:root {
    --orange: #ff6600;
    --beige: #f6f6ef;
    --text: #1a1a1a;
    --text-dim: #828282;
    --link: #000000;
    --border: #e0e0d8;
    --green: #2e7d32;
    --red: #c62828;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--beige);
    max-width: 900px;
    margin: 0 auto;
    padding: 0 8px;
}

/* Header */
header { background: var(--orange); padding: 6px 10px; margin-top: 8px; }
nav { display: flex; align-items: baseline; gap: 12px; }
.logo { font-weight: bold; font-size: 15px; color: #000; text-decoration: none; }
.tagline { font-size: 11px; color: rgba(0,0,0,0.65); flex: 1; }
.nav-link { font-size: 12px; color: #000; }

main { background: var(--beige); padding: 12px 10px 30px; min-height: 70vh; }

a { color: var(--link); }
a:hover { color: var(--orange); }

.flash {
    background: #fff8e6; border: 1px solid #f0d890;
    padding: 6px 10px; margin-bottom: 10px; font-size: 12px;
}

/* Region tabs */
.region-filter { margin-bottom: 14px; }
.filter-tab {
    display: inline-block; padding: 3px 12px; font-size: 12px;
    text-decoration: none; color: var(--text-dim);
    border-bottom: 2px solid transparent;
}
.filter-tab.active { color: var(--text); border-bottom-color: var(--orange); font-weight: bold; }
.filter-divider { color: var(--border); margin: 0 4px; }

/* Story list */
.story-list { list-style: none; }
.story-item { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rank { color: var(--text-dim); min-width: 22px; text-align: right; font-size: 13px; padding-top: 1px; }
.story-content { flex: 1; }
.story-title { font-size: 15px; font-weight: 600; text-decoration: none; line-height: 1.35; }

.fact-lede {
    list-style: none; margin: 4px 0 2px;
    font-size: 12.5px; color: #3a3a3a;
}
.fact-lede li { padding-left: 12px; position: relative; margin-bottom: 1px; }
.fact-lede li::before { content: "–"; position: absolute; left: 0; color: var(--orange); }

.corrob { color: var(--green); font-size: 11px; font-weight: 600; white-space: nowrap; }
.disputed { color: #b26a00; font-size: 11px; font-style: italic; }
.single-source { font-style: italic; }

.fact-badge {
    font-size: 10.5px; padding: 0 6px; border-radius: 8px;
    white-space: nowrap; vertical-align: 1px;
}
.fact-badge.corroborated { background: #e8f5e9; color: var(--green); }
.fact-badge.disputed-badge { background: #fff3e0; color: #b26a00; }
.fact-badge.single { background: #eceff1; color: #607d8b; }

.story-meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.separator { margin: 0 4px; }
.region-tag { letter-spacing: 0.5px; }

.score {
    display: inline-block; background: var(--orange); color: #fff;
    font-weight: bold; font-size: 11px; padding: 0 6px; border-radius: 8px;
}

.no-stories, .no-items { color: var(--text-dim); padding: 20px 0; }

/* Story page */
.story-page h1 { font-size: 21px; line-height: 1.3; margin-bottom: 6px; }
.story-page section { margin-top: 20px; }
.story-page h2 {
    font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-dim); margin-bottom: 8px;
    border-bottom: 1px solid var(--border); padding-bottom: 3px;
}

.facts-section .facts-list { list-style: none; }
.facts-list li {
    padding: 5px 0 5px 16px; position: relative; font-size: 14.5px;
}
/* Drawn with CSS, not a glyph: iOS renders U+25AA as a black emoji square and ignores color */
.facts-list li::before {
    content: ""; position: absolute; left: 1px; top: 12px;
    width: 6px; height: 6px; background: var(--orange); border-radius: 1px;
}

.dive-deeper { margin-top: 4px; }
.dive-deeper summary {
    cursor: pointer; list-style: none; display: inline-block;
    padding: 4px 0 4px 16px; font-size: 13px; color: var(--orange);
}
.dive-deeper summary::-webkit-details-marker { display: none; }
.dive-deeper summary:hover { text-decoration: underline; }
.dive-deeper .dive-close { display: none; }
.dive-deeper[open] .dive-open { display: none; }
.dive-deeper[open] .dive-close { display: inline; }
.dive-deeper[open] summary { margin-top: 4px; }

.summary p { margin-bottom: 10px; color: #333; }

.conflicts-section ul { padding-left: 18px; }
.conflicts-section li { margin-bottom: 5px; color: #7a4b00; }

.challenge-note { padding: 8px 10px; font-size: 13px; border-radius: 3px; }
.challenge-note.downgrade { background: #fff3e0; border: 1px solid #ffcc80; }
.challenge-note.uphold { background: #f1f8e9; border: 1px solid #c5e1a5; }

.votes-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.votes-table td { padding: 4px 8px 4px 0; vertical-align: top; border-bottom: 1px solid var(--border); }
.vote-score { font-weight: bold; color: var(--orange); width: 24px; }
.vote-agent { white-space: nowrap; font-weight: 600; width: 160px; }
.vote-reason { color: #555; }

.sources-section ul { list-style: none; }
.sources-section li { margin-bottom: 4px; }

.back-link { margin-top: 24px; font-size: 13px; }

/* Admin */
.admin-section {
    background: #fff; border: 1px solid var(--border);
    padding: 14px 16px; margin-bottom: 16px;
}
.admin-section h2 { font-size: 15px; margin-bottom: 10px; }

.automation-buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; }

.btn {
    background: #eee; border: 1px solid #ccc; padding: 5px 14px;
    font-size: 13px; cursor: pointer; border-radius: 3px;
}
.btn:hover { background: #e0e0e0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: #e65c00; }
.btn-large { padding: 8px 18px; font-size: 14px; }
.btn-small { padding: 2px 8px; font-size: 11px; }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fdecea; }

.hint { font-size: 11px; color: var(--text-dim); }
.stats { font-size: 12px; color: var(--text-dim); margin: 8px 0; }
.danger-zone { border-top: 1px dashed var(--border); margin-top: 12px; padding-top: 12px; }

.job-status { padding: 8px 10px; margin-bottom: 8px; font-size: 13px; border-radius: 3px; }
.job-status.running { background: #fff3e0; border: 1px solid #ffcc80; }
.job-status.done { background: #f1f8e9; border: 1px solid #c5e1a5; }
.spinner { display: inline-block; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.job-log {
    background: #1e1e1e; color: #d0d0d0; font-family: Menlo, Consolas, monospace;
    font-size: 11px; padding: 10px; max-height: 220px; overflow-y: auto;
    margin-bottom: 10px; white-space: pre-wrap;
}

.admin-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.admin-table th {
    text-align: left; font-size: 11px; text-transform: uppercase;
    color: var(--text-dim); padding: 4px 8px 4px 0; border-bottom: 2px solid var(--border);
}
.admin-table td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table .detail { color: var(--text-dim); font-size: 11.5px; }

.status-badge {
    font-size: 10.5px; padding: 1px 7px; border-radius: 8px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.status-badge.pending { background: #fff3e0; color: #a65f00; }
.status-badge.published { background: #e8f5e9; color: var(--green); }
.status-badge.rejected { background: #eceff1; color: #607d8b; }
.status-badge.error { background: #fdecea; color: var(--red); }

/* Forms */
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 12px; margin-bottom: 3px; color: #444; }
.form-group input[type="url"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group textarea {
    width: 100%; padding: 6px 8px; font-size: 13px;
    border: 1px solid #ccc; border-radius: 3px; font-family: inherit;
}

.login-page { max-width: 340px; margin: 40px auto; }
.login-form { background: #fff; border: 1px solid var(--border); padding: 20px; }

footer { padding: 14px 10px; font-size: 11px; color: var(--text-dim); border-top: 2px solid var(--orange); background: var(--beige); }

/* Mobile */
@media (max-width: 600px) {
    body { padding: 0 4px; }

    /* Header: logo on its own line, tagline wraps under it */
    nav { flex-wrap: wrap; row-gap: 2px; }
    .tagline { flex-basis: 100%; }

    /* Filter tabs: keep on one row, scroll sideways if needed */
    .region-filter {
        display: flex; align-items: center;
        overflow-x: auto; white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        margin-left: -4px; margin-right: -4px; padding: 0 4px;
    }
    .filter-tab { padding: 6px 10px; flex-shrink: 0; }
    .filter-divider { flex-shrink: 0; }

    /* Story list: slightly tighter, bigger tap targets */
    .rank { min-width: 18px; }
    .story-title { font-size: 15px; display: inline-block; padding: 1px 0; }
    .story-page h1 { font-size: 18px; }

    /* Long outlet lists in badges may wrap instead of overflowing */
    .fact-badge { white-space: normal; }

    /* Vote table stacks: score + agent inline, reasoning below */
    .votes-table, .votes-table tbody { display: block; }
    .votes-table tr {
        display: block; padding: 7px 0;
        border-bottom: 1px solid var(--border);
    }
    .votes-table td { display: inline; border: none; padding: 0 6px 0 0; }
    .votes-table .vote-agent { width: auto; }
    .votes-table .vote-reason { display: block; padding-top: 2px; }

    /* Admin tables scroll sideways rather than breaking the page */
    .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-table th, .admin-table td { white-space: nowrap; }
    .admin-table td:first-child { white-space: normal; min-width: 180px; }

    .automation-buttons { gap: 8px; }
    .btn { padding: 7px 14px; }
    .btn-small { padding: 4px 10px; }

    .form-group textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
    .form-group input[type="url"],
    .form-group input[type="password"],
    .form-group input[type="text"] { font-size: 16px; }
}

.usage-table { border-collapse: collapse; font-size: 12.5px; margin: 4px 0 12px; }
.usage-table th, .usage-table td { text-align: left; padding: 3px 12px 3px 0; border-bottom: 1px solid var(--border); }
.usage-table th { color: var(--text-dim); font-weight: normal; }
