/* ================================================================
   OpenResPublica TruthChain — Public GitHub Pages
   System fonts · Navy/Gold civic palette · No external deps
   ================================================================ */

:root {
    --navy:       #002147;
    --navy-deep:  #001530;
    --navy-mid:   #003366;
    --navy-light: #e8edf4;
    --gold:       #C9A84C;
    --gold-pale:  #FDF3D0;
    --gold-dark:  #9a7a30;
    --white:      #FAFAF7;
    --ink:        #1a1a2e;
    --muted:      #6b7280;
    --border:     rgba(0,33,71,.1);
    --green:      #1E7A3E;
    --green-pale: #F0FAF4;
    --green-b:    #86EFAC;
    --red:        #B91C1C;
    --red-pale:   #FEF2F2;
    --red-b:      #FCA5A5;

    --font-sans:  ui-sans-serif, system-ui, -apple-system,
                  BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
                  Arial, sans-serif;
    --font-serif: ui-serif, Georgia, 'Times New Roman', serif;
    --font-mono:  ui-monospace, 'Cascadia Code', 'Fira Code',
                  'Courier New', monospace;

    --radius:    10px;
    --radius-sm: 6px;
    --shadow:    0 4px 6px -1px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: #F0F2F5;
    color: var(--ink);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    background: var(--navy-deep);
    border-bottom: 3px solid var(--gold);
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto;
    padding: .7rem 1.5rem;
    display: flex; align-items: center;
    justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-badge {
    width: 32px; height: 32px;
    background: var(--gold); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
}
.brand-name {
    display: block; font-family: var(--font-serif);
    color: #fff; font-size: .92rem; font-weight: 700;
}
.brand-sub {
    display: block; color: var(--gold);
    font-size: .6rem; opacity: .8;
}
.topnav { display: flex; gap: .15rem; }
.nav-link {
    color: rgba(255,255,255,.75);
    text-decoration: none; font-size: .82rem; font-weight: 500;
    padding: .35rem .7rem; border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.nav-link:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 700; }

/* ── Utilities ───────────────────────────────────────────────── */
.container   { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.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;
}

/* ── Page layouts ────────────────────────────────────────────── */
.page-main {
    max-width: 720px; margin: 2.5rem auto; padding: 0 1.5rem;
}
.page-main--wide {
    max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem;
}
.page-header { margin-bottom: 1.5rem; }
.page-header h1 {
    font-family: var(--font-serif); font-size: 1.75rem;
    color: var(--navy-mid); margin: 0 0 .4rem;
}
.page-sub { color: var(--muted); font-size: .9rem; margin: 0; }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-mid) 100%);
    border-bottom: 3px solid var(--gold);
    padding: 4rem 1.5rem;
    display: flex; align-items: center; justify-content: center;
    gap: 3rem; flex-wrap: wrap;
}
.hero-inner { max-width: 520px; }
.hero-badge {
    display: inline-block;
    background: rgba(201,168,76,.15); color: var(--gold);
    border: 1px solid rgba(201,168,76,.3);
    padding: 4px 12px; border-radius: 99px;
    font-size: .72rem; font-weight: 700; letter-spacing: .06em;
    margin-bottom: 1rem;
}
.hero-title {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3rem);
    color: #fff; margin: 0 0 1rem;
    line-height: 1.15; font-weight: 700;
}
.hero-sub {
    color: rgba(255,255,255,.75); font-size: .95rem;
    margin: 0 0 1.75rem; line-height: 1.7;
}
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.btn-hero-primary {
    background: var(--gold); color: var(--navy-deep);
    padding: .75rem 1.5rem; border-radius: var(--radius-sm);
    font-weight: 700; font-size: .9rem;
    text-decoration: none; display: inline-block;
    transition: background .15s;
}
.btn-hero-primary:hover { background: #e0bc5c; }

.btn-hero-outline {
    background: transparent; color: #fff;
    border: 1.5px solid rgba(255,255,255,.4);
    padding: .75rem 1.5rem; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .9rem;
    text-decoration: none; display: inline-block;
    transition: border-color .15s, background .15s;
}
.btn-hero-outline:hover { border-color: #fff; background: rgba(255,255,255,.06); }

/* Chain preview visual */
.chain-preview { display: flex; flex-direction: column; gap: .5rem; }
.chain-block {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius-sm);
    padding: .6rem 1rem; min-width: 200px; text-align: center;
}
.chain-block--active {
    background: rgba(201,168,76,.15);
    border-color: rgba(201,168,76,.4);
}
.cb-seq  { font-family: var(--font-mono); color: var(--gold); font-size: .7rem; font-weight: 700; }
.cb-hash { font-family: var(--font-mono); color: rgba(255,255,255,.4); font-size: .65rem; margin-top: .2rem; }
.cb-arrow { color: rgba(255,255,255,.25); font-size: .8rem; margin-top: .3rem; }

/* ── Feature grid ────────────────────────────────────────────── */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem; padding: 2.5rem 1.5rem;
}
.feature-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--shadow);
}
.feature-icon { font-size: 1.75rem; margin-bottom: .6rem; }
.feature-card h3 {
    font-family: var(--font-serif); font-size: 1rem;
    color: var(--navy-mid); margin: 0 0 .5rem; font-weight: 700;
}
.feature-card p { font-size: .85rem; color: var(--muted); margin: 0; line-height: 1.6; }

/* ── CTA strip ───────────────────────────────────────────────── */
.cta-strip {
    background: var(--navy-light);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 2.5rem 1.5rem; text-align: center;
}
.cta-strip h2 {
    font-family: var(--font-serif); color: var(--navy-mid);
    margin: 0 0 .5rem; font-size: 1.4rem;
}
.cta-strip p { color: var(--muted); margin: 0 0 1.25rem; font-size: .9rem; }

/* ── Stats strip ─────────────────────────────────────────────── */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem; padding: 2rem 1.5rem; text-align: center;
}
.stat-n {
    font-family: var(--font-serif); font-size: 1.75rem;
    font-weight: 700; color: var(--navy-mid);
}
.stat-l {
    font-size: .72rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); font-weight: 600;
}

/* ── Verify card ─────────────────────────────────────────────── */
.verify-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem;
}
.verify-header { text-align: center; margin-bottom: 1.75rem; }
.verify-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.verify-header h1 {
    font-family: var(--font-serif); font-size: 1.6rem;
    color: var(--navy-mid); margin: 0 0 .4rem;
}
.verify-sub { color: var(--muted); font-size: .88rem; margin: 0; }

.hash-input-wrap { margin-bottom: 1rem; }
.hash-input {
    width: 100%; padding: .8rem 1rem;
    font-family: var(--font-mono); font-size: .85rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.hash-input:focus {
    outline: none; border-color: var(--navy-mid);
    box-shadow: 0 0 0 3px rgba(0,51,102,.1);
}
.hash-hint { font-size: .73rem; color: var(--muted); margin: .35rem 0 0; }

.btn-verify {
    width: 100%; padding: .85rem;
    background: var(--navy-mid); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-family: var(--font-sans); font-size: .9rem; font-weight: 700;
    cursor: pointer; transition: background .15s;
}
.btn-verify:hover    { background: var(--navy); }
.btn-verify:disabled { opacity: .6; cursor: not-allowed; }

.verify-loading {
    display: flex; align-items: center; gap: .75rem;
    color: var(--muted); font-size: .88rem; margin-top: 1.25rem;
}

/* Result cards */
.result-card {
    margin-top: 1.5rem; border-radius: var(--radius);
    border: 2px solid var(--border); overflow: hidden;
    animation: fadeIn .25s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.result-found    { border-color: var(--green-b); }
.result-notfound { border-color: var(--red-b); }

.result-badge {
    padding: .6rem 1.25rem;
    font-weight: 700; font-size: .88rem; letter-spacing: .03em;
}
.result-badge--ok  { background: var(--green-pale); color: var(--green); }
.result-badge--err { background: var(--red-pale);   color: var(--red); }

.result-card h2 {
    font-family: var(--font-serif); font-size: 1.2rem;
    margin: 1rem 1.25rem .25rem; color: var(--navy-mid);
}
.result-intro { font-size: .88rem; color: var(--muted); margin: 0 1.25rem 1rem; }

.result-kv {
    display: grid; grid-template-columns: auto 1fr;
    gap: .3rem 1rem; padding: 0 1.25rem 1rem; font-size: .84rem;
}
.result-kv dt { font-weight: 700; color: var(--muted); white-space: nowrap; }
.result-kv dd { margin: 0; word-break: break-word; }

.result-chain {
    padding: .9rem 1.25rem;
    background: var(--navy-light);
    border-top: 1px solid var(--border); font-size: .82rem;
}
.result-chain h3 {
    font-size: .78rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted);
    margin: 0 0 .5rem; font-weight: 700;
}
.result-chain dl {
    display: grid; grid-template-columns: auto 1fr;
    gap: .3rem 1rem; margin: 0;
}
.result-chain dt { font-weight: 700; color: var(--muted); white-space: nowrap; }
.result-chain dd {
    margin: 0; font-family: var(--font-mono);
    font-size: .75rem; word-break: break-all;
}

.hash-block {
    display: inline-block;
    font-family: var(--font-mono); font-size: .72rem;
    background: rgba(0,51,102,.06); padding: 1px 4px;
    border-radius: 3px; margin: 1px;
}
.hash-formatted { word-break: break-all; }

.sig-details {
    padding: .75rem 1.25rem 1rem;
    border-top: 1px solid var(--border); font-size: .8rem;
}
.sig-details summary {
    cursor: pointer; font-weight: 600;
    color: var(--muted); font-size: .78rem;
}
.sig-pre {
    margin: .75rem 0 0;
    font-family: var(--font-mono); font-size: .68rem;
    white-space: pre-wrap; word-break: break-all;
    background: #F9FAFB; padding: .75rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); max-height: 200px; overflow-y: auto;
    color: var(--muted);
}

.notfound-hints {
    padding: 0 1.25rem 1.25rem;
    font-size: .85rem; color: var(--muted);
}
.notfound-hints ul { margin: .3rem 0 0 1.2rem; }
.notfound-hints li { margin-bottom: .3rem; }
.hash-display {
    display: block; font-family: var(--font-mono); font-size: .73rem;
    word-break: break-all;
    background: #F9FAFB; padding: .5rem .9rem;
    border-radius: var(--radius-sm); margin: .5rem 1.25rem .75rem;
    border: 1px solid var(--border);
}

/* ── Ledger table ────────────────────────────────────────────── */
.ledger-toolbar {
    display: flex; align-items: center;
    justify-content: space-between; gap: 1rem;
    margin-bottom: 1rem; flex-wrap: wrap;
}
.search-input {
    flex: 1; min-width: 220px; max-width: 380px;
    padding: .6rem .9rem; font-family: inherit; font-size: .88rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s;
}
.search-input:focus { outline: none; border-color: var(--navy-mid); }
.ledger-count { font-size: .8rem; color: var(--muted); white-space: nowrap; }

table { width: 100%; border-collapse: collapse; }
th {
    background: #F9FAFB; text-align: left;
    padding: .8rem 1rem; font-size: .67rem;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); border-bottom: 2px solid var(--border);
    font-weight: 700;
}
td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); font-size: .84rem; }
tr:hover td { background: rgba(0,51,102,.02); }

.tbl-center {
    text-align: center; padding: 2.5rem; color: var(--muted);
}
.tbl-error { color: var(--red); }

.chain-seq-badge {
    font-family: var(--font-mono); font-size: .72rem; font-weight: 700;
    color: var(--gold-dark); background: var(--gold-pale);
    padding: 2px 7px; border-radius: 4px; display: inline-block;
}
.ctrl-no {
    font-family: var(--font-mono); font-size: .77rem;
    color: var(--navy-mid); font-weight: 600;
}
.badge-type {
    background: var(--gold-pale); color: var(--gold-dark);
    padding: 2px 8px; border-radius: 99px;
    font-size: .67rem; font-weight: 700; display: inline-block;
}
.ts-cell  { font-size: .78rem; color: var(--muted); }
.hash-short {
    font-family: var(--font-mono); font-size: .72rem;
    background: #F1F5F9; padding: 2px 5px; border-radius: 3px;
    color: var(--navy-mid);
}
.btn-verify-link {
    display: inline-block; padding: .22rem .65rem;
    background: transparent; color: var(--navy-mid);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    text-decoration: none; font-size: .72rem; font-weight: 600;
    transition: background .15s, border-color .15s;
}
.btn-verify-link:hover { background: var(--gold-pale); border-color: var(--gold); }

.table-footer {
    display: flex; align-items: center;
    justify-content: space-between; padding: .65rem 1rem;
    background: #F9FAFB; border-top: 1px solid var(--border);
    font-size: .78rem; color: var(--muted);
}
.page-btns { display: flex; gap: .35rem; }
.page-btn {
    padding: .28rem .65rem; font-size: .75rem; font-family: inherit;
    font-weight: 600; border: 1px solid var(--border);
    background: #fff; border-radius: var(--radius-sm);
    cursor: pointer; color: var(--navy-mid); transition: background .15s;
}
.page-btn:hover:not(:disabled) { background: var(--gold-pale); border-color: var(--gold); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── About ───────────────────────────────────────────────────── */
.about-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 2rem 2.25rem;
}
.about-card h1 {
    font-family: var(--font-serif); font-size: 1.75rem;
    color: var(--navy-mid); margin: 0 0 .75rem;
}
.about-lead {
    font-size: 1rem; color: var(--muted);
    border-left: 4px solid var(--gold);
    padding-left: 1rem; margin: 0 0 1.75rem; line-height: 1.7;
}
.about-card h2 {
    font-family: var(--font-serif); font-size: 1.1rem;
    color: var(--navy-mid); margin: 1.75rem 0 .75rem;
    border-bottom: 1px solid var(--border); padding-bottom: .4rem;
}
.how-list { font-size: .9rem; color: var(--ink); padding-left: 1.4rem; }
.how-list li { margin-bottom: .6rem; line-height: 1.6; }
.security-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.sec-item { background: var(--navy-light); border-radius: var(--radius-sm); padding: 1rem 1.1rem; }
.sec-item h4 { font-size: .88rem; color: var(--navy-mid); margin: 0 0 .35rem; font-weight: 700; }
.sec-item p  { font-size: .82rem; color: var(--muted); margin: 0; line-height: 1.6; }
.about-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .5rem; }
.about-table th, .about-table td {
    padding: .6rem .75rem; border-bottom: 1px solid var(--border); text-align: left;
}
.about-table th { font-weight: 700; color: var(--muted); width: 40%; background: #F9FAFB; }
.about-footer-note {
    margin-top: 1.5rem; padding: .75rem 1rem;
    background: var(--navy-light); border-radius: var(--radius-sm);
    font-size: .82rem; color: var(--muted);
}

/* ── Spinner ─────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--navy-mid);
    border-radius: 50%; animation: spin .7s linear infinite;
    display: inline-block; vertical-align: middle;
}

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
    padding: 1.5rem; text-align: center;
    font-size: .72rem; color: var(--muted);
    border-top: 1px solid var(--border);
    background: var(--white); margin-top: 3rem;
}
.footer-inner { max-width: 1100px; margin: 0 auto; }

/* ── Accessibility ───────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--navy-mid); outline-offset: 2px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .hero           { padding: 2.5rem 1.25rem; gap: 1.5rem; }
    .hero-title     { font-size: 2rem; }
    .hero-visual    { display: none; }
    .topnav .nav-link { font-size: .75rem; padding: .3rem .5rem; }
    .page-main      { margin: 1.25rem auto; }
    .about-card     { padding: 1.25rem; }
    .ledger-toolbar { flex-direction: column; align-items: flex-start; }
    .search-input   { max-width: 100%; width: 100%; }
    .stats-strip    { grid-template-columns: repeat(2, 1fr); }
    .result-kv      { grid-template-columns: 1fr; }
    .result-chain dl{ grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .topnav            { display: none; }
    .hero-actions      { flex-direction: column; }
    .btn-hero-primary,
    .btn-hero-outline  { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
@media print {
    .topbar, .site-footer { display: none; }
    body { background: #fff; }
}
