/* ============================================================
   ReadMetric — "Editorial Reading Studio" design system
   Fonts: Fraunces (display) + General Sans (body) — loaded in <head>
   Colors: OKLCH via light-dark(); .dark-mode / prefers-color-scheme
   NOTE: every id/class hook used by script.js / site.js is preserved.
   ============================================================ */

:root {
    color-scheme: light dark;
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
:root {

    --primary: light-dark(oklch(42% 0.16 315), oklch(78% 0.14 315));
    --primary-strong: light-dark(oklch(34% 0.17 315), oklch(85% 0.11 315));
    --accent: light-dark(oklch(58% 0.13 175), oklch(72% 0.13 175));
    --accent-strong: light-dark(oklch(48% 0.13 175), oklch(80% 0.11 175));

    --ink: light-dark(oklch(20% 0.02 290), oklch(94% 0.01 290));
    --ink-soft: light-dark(oklch(38% 0.03 290), oklch(80% 0.02 290));
    --muted: light-dark(oklch(52% 0.02 290), oklch(66% 0.02 290));

    --paper: light-dark(oklch(98% 0.008 90), oklch(19% 0.02 290));
    --paper-2: light-dark(oklch(95.5% 0.012 90), oklch(23% 0.02 290));
    --paper-3: light-dark(oklch(92% 0.014 90), oklch(27% 0.02 290));
    --line: light-dark(oklch(88% 0.012 90), oklch(33% 0.02 290));
    --line-strong: light-dark(oklch(80% 0.014 90), oklch(40% 0.02 290));

    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 26px;
    --shadow-sm: 0 1px 2px oklch(20% 0.02 290 / .08);
    --shadow: 0 14px 34px -16px oklch(20% 0.02 290 / .28), 0 2px 8px oklch(20% 0.02 290 / .06);
    --shadow-lg: 0 34px 80px -24px oklch(20% 0.02 290 / .38);
    --ring: 0 0 0 3px color-mix(in oklch, var(--primary) 45%, transparent);

    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body: 'General Sans', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; font-weight: 600; color: var(--ink); letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 4.4vw + 1rem, 3.6rem); font-weight: 500; }
h2 { font-size: clamp(1.6rem, 2.6vw + 0.6rem, 2.3rem); margin-bottom: .5rem; }
h3 { font-size: 1.2rem; margin-bottom: .4rem; }
p { color: var(--ink-soft); text-wrap: pretty; max-width: 68ch; }

a { color: var(--primary-strong); text-decoration-color: color-mix(in oklch, var(--primary) 40%, transparent); }
a:hover { color: var(--accent-strong); }

img, svg { max-width: 100%; height: auto; display: block; }
ul, ol { padding-left: 1.2rem; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 22px; }
.container-narrow { max-width: 760px; }

/* ---------- Accessibility ---------- */
.skip-link {
    position: absolute; left: 14px; top: -60px;
    background: var(--primary); color: #fff; padding: 10px 18px;
    border-radius: var(--radius-sm); z-index: 2000; font-weight: 600;
    transition: top .2s ease;
}
.skip-link:focus { top: 14px; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
@media (forced-colors: active) { :focus-visible { outline: 3px solid ButtonText; } }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 900;
    background: color-mix(in oklch, var(--paper) 85%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.nav-wrap { display: flex; align-items: center; gap: 18px; min-height: 68px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 1.3rem; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; }
.brand-name span { color: var(--primary); }
.site-nav { margin-left: auto; }
.nav-menu { list-style: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.nav-menu a { display: inline-block; padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; color: var(--ink-soft); }
.nav-menu a:hover, .nav-menu a[aria-current="page"] { color: var(--primary-strong); background: var(--paper-2); }

.icon-btn {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); border-radius: 50%;
    cursor: pointer; transition: background .2s ease, transform .2s ease;
}
.icon-btn:hover { background: var(--paper-3); transform: translateY(-1px); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: 999px;
    font-weight: 600; font-size: .98rem; border: 1.5px solid transparent; cursor: pointer;
    min-height: 44px; transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .2s ease, background .2s ease;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-strong); box-shadow: var(--shadow); transform: translateY(-2px); color: #fff; }
.btn-secondary { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-strong); }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 40px; align-items: center; }
.hero-copy p.hero-sub { font-size: 1.1rem; margin: 18px 0 26px; }
.hero-copy em { font-style: italic; color: var(--primary-strong); }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.trust-row { display: flex; flex-wrap: wrap; gap: 10px 18px; font-size: .88rem; color: var(--muted); }
.trust-row span::before { content: "\2713 "; color: var(--accent-strong); font-weight: 700; }

.hero-visual { display: flex; justify-content: center; }
.hero-book { width: min(280px, 100%); height: auto; }
.hb-cover { fill: var(--paper-2); stroke: var(--line-strong); stroke-width: 2; }
.hb-line { fill: var(--line-strong); }
.hb-line.l2 { fill: var(--primary); opacity: .55; }
.hb-line.l3 { fill: var(--accent); opacity: .6; }
.hb-ring { fill: none; stroke: var(--line); stroke-width: 8; }
.hb-arc { fill: none; stroke: var(--primary); stroke-width: 8; stroke-linecap: round;
    animation: arc-sweep 3.2s ease-in-out infinite; transform-origin: 110px 150px; }
@keyframes arc-sweep { 0%, 100% { stroke-dasharray: 40 200; } 50% { stroke-dasharray: 140 200; } }

/* ---------- Sections ---------- */
.section { padding: 60px 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 36px; }
.section-head p { margin: 0 auto; color: var(--muted); }

/* ---------- Calculator ---------- */
.calculator-card {
    background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 28px; box-shadow: var(--shadow);
}
.tool-tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--paper); border-radius: 999px; padding: 5px; border: 1px solid var(--line); }
.tool-tab {
    flex: 1; padding: 10px 14px; border: none; background: transparent; border-radius: 999px;
    font-family: var(--font-body); font-weight: 600; font-size: .92rem; color: var(--muted); cursor: pointer;
    min-height: 44px; transition: background .2s ease, color .2s ease;
}
.tool-tab.active { background: var(--primary); color: #fff; }
.tool-tab:not(.active):hover { background: var(--paper-3); color: var(--ink); }

textarea#text-input {
    width: 100%; min-height: 230px; padding: 18px; border: 1.5px solid var(--line-strong);
    border-radius: var(--radius); resize: vertical; font-size: 1rem; font-family: var(--font-body);
    background: var(--paper); color: var(--ink); margin-bottom: 20px; transition: border-color .2s ease, box-shadow .2s ease;
}
textarea#text-input::placeholder { color: var(--muted); font-style: italic; }
textarea#text-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.result-bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.result-cell {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; text-align: center;
}
.result-cell h3 { font-family: var(--font-body); font-size: .82rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.result-cell .value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--ink); }
.result-hero { grid-column: span 3; background: color-mix(in oklch, var(--primary) 10%, var(--paper)); border-color: color-mix(in oklch, var(--primary) 30%, var(--line)); }
.result-hero .value { font-size: clamp(2rem, 3vw + 1rem, 2.6rem); color: var(--primary-strong); }
@media (min-width: 620px) {
    .result-hero { grid-column: span 1; grid-row: span 2; }
    .result-bento { grid-template-columns: 1.3fr 1fr; grid-template-rows: auto auto; }
}

.speed-controls { padding-top: 6px; }
.speed-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; flex-wrap: wrap; gap: 6px; }
.speed-row h3 { margin: 0; color: var(--ink); }
.speed-value { font-weight: 600; color: var(--primary-strong); }

.persona-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.persona-chip {
    padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--paper);
    color: var(--ink-soft); font-family: var(--font-body); font-weight: 600; font-size: .85rem; cursor: pointer;
    min-height: 40px; transition: all .2s ease;
}
.persona-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.persona-chip:not(.active):hover { border-color: var(--accent); color: var(--accent-strong); }

input[type="range"].speed-slider {
    -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; outline: none;
}
input[type="range"].speed-slider::-webkit-slider-runnable-track { width: 100%; height: 10px; border-radius: 6px; background: var(--line-strong); }
input[type="range"].speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
    cursor: pointer; box-shadow: var(--shadow-sm); margin-top: -8px; border: 3px solid var(--paper);
}
input[type="range"].speed-slider::-moz-range-track { width: 100%; height: 10px; border-radius: 6px; background: var(--line-strong); }
input[type="range"].speed-slider::-moz-range-thumb { width: 26px; height: 26px; border: 3px solid var(--paper); border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: var(--shadow-sm); }

/* ---------- Bento features ---------- */
.bento-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.bento-card {
    background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px;
    transition: transform .25s cubic-bezier(.4,0,.2,1), box-shadow .25s ease;
}
.bento-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.bento-wide { grid-column: span 1; }
@media (min-width: 720px) { .bento-wide { grid-column: span 2; } }

/* ---------- How it works ---------- */
.how-to-use { background: color-mix(in oklch, var(--primary) 8%, var(--paper)); padding: 64px 0; border-block: 1px solid var(--line); }
.timeline { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 30px; position: relative; }
.timeline-step { text-align: center; }
.step-num {
    display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px;
    border-radius: 50%; background: var(--primary); color: #fff; font-family: var(--font-display); font-weight: 600;
    font-size: 1.2rem; margin-bottom: 14px;
}

/* ---------- Prose ---------- */
.prose h2 { margin-top: 2rem; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin-bottom: 1rem; max-width: 70ch; }
.prose ul, .prose ol { margin-bottom: 1rem; color: var(--ink-soft); }
.prose li { margin-bottom: .35rem; }

/* ---------- FAQ ---------- */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); overflow: hidden; }
.faq-item summary {
    padding: 18px 20px; cursor: pointer; font-weight: 600; font-family: var(--font-body); list-style: none;
    display: flex; justify-content: space-between; align-items: center; min-height: 44px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.3rem; color: var(--primary); margin-left: 12px; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-body { padding: 0 20px 18px; }
.faq-body p { max-width: none; }

/* ---------- Footer ---------- */
footer[role="contentinfo"] { margin-top: auto; background: var(--paper-2); border-top: 1px solid var(--line); padding: 56px 0 30px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; margin-bottom: 34px; }
.footer-brand p { margin-top: 10px; font-size: .92rem; }
.footer-col h4 { font-family: var(--font-body); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 12px; }
.footer-col ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: var(--ink-soft); font-size: .95rem; }
.footer-col a:hover { color: var(--primary-strong); }
.footer-bottom { border-top: 1px solid var(--line); padding-top: 20px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: .88rem; color: var(--muted); }

/* ---------- Breadcrumb / page-hero (subpages) ---------- */
.breadcrumb { margin: 18px 0 6px; font-size: .88rem; color: var(--muted); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 6px; color: var(--line-strong); }
.page-hero { padding: 20px 0 10px; }
.page-hero p { color: var(--muted); }

.callout { background: color-mix(in oklch, var(--accent) 10%, var(--paper-2)); border: 1px solid color-mix(in oklch, var(--accent) 30%, var(--line)); border-radius: var(--radius); padding: 20px 22px; margin: 1.2rem 0; }
.callout p { max-width: none; }

.table-wrap { overflow-x: auto; margin: 1.2rem 0; }
table.data { width: 100%; border-collapse: collapse; min-width: 420px; }
table.data th, table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; }
table.data thead th { background: var(--paper-2); font-family: var(--font-body); font-weight: 600; }
table.data caption { text-align: left; font-weight: 600; margin-bottom: 8px; color: var(--ink); }

.tool-cta { background: color-mix(in oklch, var(--primary) 12%, var(--paper-2)); border-radius: var(--radius-lg); padding: 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 1.6rem 0; }
.tool-cta p { max-width: none; margin: 0; font-weight: 500; color: var(--ink); }

.related-links { display: flex; flex-wrap: wrap; gap: 10px; }
.related-links a { background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: .9rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.guide-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; transition: transform .25s ease, box-shadow .25s ease; }
.guide-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.guide-card .gc-link { color: var(--primary-strong); font-weight: 600; font-size: .92rem; }
.guide-category { margin: 44px 0 18px; font-family: var(--font-display); font-size: 1.3rem; }
.guide-category:first-of-type { margin-top: 0; }

/* ---------- Ads ---------- */
.ad-slot { text-align: center; margin: 26px auto; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.ad-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.ad-skyscraper { float: right; margin-left: 20px; }
@media (max-width: 768px) { .desktop-only { display: none; } }
@media (min-width: 769px) { .mobile-only { display: none; } }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .hb-arc { animation: none; }
}

/* ---------- Responsive ---------- */
.mobile-menu-toggle { display: none; }
@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-visual { order: -1; max-width: 200px; margin: 0 auto; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .mobile-menu-toggle { display: inline-flex; }
    .nav-wrap { justify-content: space-between; position: relative; }
    .site-nav { 
        display: none; position: absolute; top: 100%; left: -22px; right: -22px;
        background: var(--paper-2); border-bottom: 1px solid var(--line);
        padding: 14px 0; box-shadow: var(--shadow-lg); z-index: 1000;
    }
    .site-nav.is-open { display: block; }
    .nav-menu { flex-direction: column; align-items: stretch; gap: 8px; overflow-x: visible; }
    .nav-menu a { font-size: 1.1rem; padding: 12px 20px; text-align: center; }
    .footer-grid { grid-template-columns: 1fr; }
    .calculator-card { padding: 18px; }
    .result-bento { grid-template-columns: 1fr; }
    .result-hero { grid-column: span 1; }
    .tool-tabs { flex-wrap: wrap; }
    .hero { padding: 36px 0 24px; }
    .section { padding: 44px 0; }
}
