/* ==========================================================================
   CodaiPro — "the exam paper"
   Warm paper, ink serif, red margin line. Zero external dependencies.
   ========================================================================== */

:root {
    /* Color roles */
    --paper: #f6f4ee;        /* page */
    --paper-raised: #fbfaf5; /* raised surfaces */
    --ink: #26221b;          /* primary text */
    --ink-soft: #5f584b;     /* secondary text */
    --rule: #ddd7c9;         /* warm hairlines */
    --rule-blue: #bccfe3;    /* notebook ruling, answer sheet only */
    --red: #c23a24;          /* margin line, links, stamps */
    --red-deep: #9c2c1a;     /* hover / pressed red */

    /* Type */
    --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
    --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;

    /* Rhythm: 1/4/9 units — 4px, 16px, 36px, 72px */
    --u1: 4px;
    --u4: 16px;
    --u9: 36px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.0625rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--red);
    color: var(--paper);
}

.wrap {
    width: min(72rem, 92%);
    margin-inline: auto;
}

section {
    scroll-margin-top: var(--u9);
}

a {
    color: var(--red);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--red-deep);
}

code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    padding: 1px 6px;
    border-radius: 2px;
}

/* Focus is architecture */
:focus-visible {
    outline: 3px solid var(--red);
    outline-offset: 3px;
    border-radius: 2px;
}

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

.masthead {
    border-bottom: 3px double var(--ink);
    background: var(--paper);
}

.masthead-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--u4);
    padding-block: var(--u4);
    flex-wrap: wrap;
}

.wordmark {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}

.wordmark .dot {
    color: var(--red);
}

.site-nav {
    display: flex;
    gap: var(--u4);
    flex-wrap: wrap;
}

.site-nav a {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    padding: 10px 4px;
}

.site-nav a:hover {
    color: var(--red);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: var(--u9);
    align-items: center;
    padding-block: var(--u9) 72px;
}

.kicker {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: var(--u4);
}

.hero-copy h1 {
    font-size: clamp(2.4rem, 5.2vw, 4.1rem);
    line-height: 1.05;
    letter-spacing: -0.015em;
    font-weight: 700;
    text-wrap: balance;
}

.lede {
    max-width: 34rem;
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--ink-soft);
    margin-top: var(--u4);
}

.cta-row {
    display: flex;
    gap: var(--u4);
    flex-wrap: wrap;
    margin-top: var(--u9);
}

/* Buttons — letterpress press-in, 44px targets */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 24px;
    border: 2px solid var(--ink);
    background: var(--paper-raised);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease,
                border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
    background: var(--ink);
    color: var(--paper);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--red);
    border-color: var(--red);
    color: var(--paper);
}

.btn-primary:hover {
    background: var(--red-deep);
    border-color: var(--red-deep);
    color: var(--paper);
}

.btn:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
}

/* The answer sheet — ruled paper with a red margin line */
.sheet {
    position: relative;
    background:
        linear-gradient(to right, transparent 0 44px, var(--red) 44px 45px, transparent 45px),
        repeating-linear-gradient(to bottom, transparent 0 27px, var(--rule-blue) 27px 28px),
        var(--paper-raised);
    background-position: 0 8px;
    border: 1px solid var(--rule);
    box-shadow: 0 1px 0 var(--rule), 0 12px 24px -18px rgba(38, 34, 27, 0.4);
    padding: var(--u4) var(--u4) var(--u4) 60px;
    transform: rotate(0.6deg);
}

.sheet-title {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: var(--u4);
}

.sheet-fields div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--u4);
    padding-block: 7px;
}

.sheet-fields dt {
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.sheet-fields dd {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.02rem;
    text-align: right;
}

.sheet-stamp {
    display: inline-block;
    margin-top: var(--u4);
    padding: 4px 12px;
    border: 2px solid var(--red);
    border-radius: 3px;
    color: var(--red);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transform: rotate(-3deg);
}

/* --------------------------------------------------------------------------
   Facts band
   -------------------------------------------------------------------------- */

.band {
    border-block: 1px solid var(--ink);
    background: var(--paper-raised);
}

.band-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px var(--u4);
    padding-block: 14px;
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.band .star {
    color: var(--red);
}

/* --------------------------------------------------------------------------
   Section scaffolding
   -------------------------------------------------------------------------- */

.section-head {
    margin-bottom: var(--u9);
    max-width: 40rem;
}

.section-head h2 {
    font-size: clamp(1.9rem, 3.6vw, 2.7rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.section-lede {
    margin-top: var(--u4);
    color: var(--ink-soft);
}

.section-head .kicker {
    margin-bottom: 8px;
}

/* --------------------------------------------------------------------------
   Syllabus — numbered editorial rows
   -------------------------------------------------------------------------- */

.syllabus {
    padding-block: 72px var(--u9);
}

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

.syllabus-list li {
    display: grid;
    grid-template-columns: 4rem 1fr;
    gap: var(--u4);
    padding-block: var(--u4);
    border-top: 1px solid var(--rule);
}

.syllabus-list li:last-child {
    border-bottom: 1px solid var(--rule);
}

.syllabus-list .no {
    font-family: var(--mono);
    font-size: 0.9rem;
    color: var(--red);
    padding-top: 5px;
}

.syllabus-list h3 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.syllabus-list p {
    color: var(--ink-soft);
    max-width: 62ch;
}

/* --------------------------------------------------------------------------
   Download — forms, not cards
   -------------------------------------------------------------------------- */

.download {
    padding-block: 72px var(--u9);
    border-top: 3px double var(--ink);
}

.options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--u9);
    margin-bottom: var(--u9);
}

.option {
    position: relative;
    border: 1px solid var(--rule);
    background: var(--paper-raised);
    padding: var(--u9) var(--u9) var(--u4);
}

.option-primary {
    border: 2px solid var(--ink);
}

.option h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.option > p {
    color: var(--ink-soft);
    margin-bottom: var(--u4);
    max-width: 44ch;
}

.ticks {
    list-style: none;
    margin-bottom: var(--u9);
}

.ticks li {
    padding-block: 7px;
    padding-left: 28px;
    position: relative;
    font-size: 0.98rem;
}

.ticks li::before {
    content: "✓";
    position: absolute;
    left: 2px;
    color: var(--red);
    font-weight: 700;
}

.option .btn {
    width: 100%;
}

.meta {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-top: var(--u4);
}

.stamp {
    position: absolute;
    top: -14px;
    right: var(--u4);
    padding: 5px 14px;
    border: 2px solid var(--red);
    border-radius: 3px;
    background: var(--paper);
    color: var(--red);
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transform: rotate(-4deg);
}

/* Bring a model — spec table */
.models {
    border-top: 1px solid var(--ink);
    padding-top: var(--u9);
}

.models h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.models > p {
    color: var(--ink-soft);
    max-width: 62ch;
    margin-bottom: var(--u4);
}

.models table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.models th,
.models td {
    text-align: left;
    padding: 12px 12px 12px 0;
    border-bottom: 1px solid var(--rule);
}

.models thead th {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.models tbody th {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
}

.models td {
    font-family: var(--mono);
    font-size: 0.88rem;
    color: var(--ink-soft);
}

.models td a {
    font-family: var(--sans);
    font-weight: 600;
    white-space: nowrap;
}

.models h4 {
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.models h4 + .tiny-models,
.models h4 + table,
.models h4 + p + table {
    margin-top: 0;
}

.models .tiny-models + .meta {
    margin-top: 12px;
}

.models h4:not(:first-of-type) {
    margin-top: var(--u9);
}

/* Tiny models — under 1 GB */
.tiny-models {
    list-style: none;
}

.tiny-models li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px var(--u4);
    padding-block: 10px;
    border-top: 1px solid var(--rule);
}

.tiny-models li:last-child {
    border-bottom: 1px solid var(--rule);
}

.tm-name {
    font-family: var(--sans);
    font-size: 0.98rem;
    font-weight: 600;
}

.tm-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border: 1px solid var(--red);
    border-radius: 2px;
    color: var(--red);
    font-family: var(--mono);
    font-style: normal;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    vertical-align: 2px;
}

.tm-size {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.tm-links {
    margin-left: auto;
    display: flex;
    gap: var(--u4);
}

.tm-links a {
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Venues — timetable rows
   -------------------------------------------------------------------------- */

.venues {
    padding-block: 72px var(--u9);
    border-top: 3px double var(--ink);
}

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

.venues-list li {
    display: grid;
    grid-template-columns: minmax(10rem, 16rem) 1fr;
    gap: var(--u4) var(--u9);
    align-items: baseline;
    padding-block: var(--u4);
    border-top: 1px solid var(--rule);
}

.venues-list li:last-child {
    border-bottom: 1px solid var(--rule);
}

.venues-list h3 {
    font-size: 1.25rem;
}

.venues-list p {
    color: var(--ink-soft);
    max-width: 60ch;
}

/* --------------------------------------------------------------------------
   Letter from the developer
   -------------------------------------------------------------------------- */

.letter-section {
    padding-block: 72px;
    border-top: 3px double var(--ink);
}

.letter {
    max-width: 60ch;
}

.letter p {
    font-size: 1.12rem;
    line-height: 1.8;
    margin-bottom: var(--u4);
}

.letter > p:first-of-type::first-letter {
    font-size: 3.3em;
    font-weight: 700;
    float: left;
    line-height: 0.82;
    padding-right: 10px;
    padding-top: 4px;
    color: var(--red);
}

.signature {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.5rem;
    display: inline-block;
    border-bottom: 2px solid var(--red);
    padding-bottom: 2px;
    margin-bottom: var(--u4);
}

.letter-links {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   Colophon
   -------------------------------------------------------------------------- */

.colophon {
    border-top: 3px double var(--ink);
    background: var(--paper-raised);
    padding-top: var(--u9);
}

.colophon-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--u9);
    flex-wrap: wrap;
    padding-bottom: var(--u9);
}

.colophon-tag {
    color: var(--ink-soft);
    margin-top: 4px;
}

.colophon-nav {
    display: flex;
    gap: var(--u4);
    flex-wrap: wrap;
}

.colophon-nav a {
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    padding: 8px 0;
}

.colophon-nav a:hover {
    color: var(--red);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.colophon-base {
    display: flex;
    justify-content: space-between;
    gap: var(--u4);
    flex-wrap: wrap;
    border-top: 1px solid var(--rule);
    padding-block: var(--u4) 28px;
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Reveal on scroll (JS adds .js to <html>; no-JS users see everything)
   -------------------------------------------------------------------------- */

.js .reveal-init {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.js .reveal-init.is-in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .js .reveal-init {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .btn,
    .btn:active {
        transform: none;
        transition: none;
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        gap: var(--u9);
        padding-block: var(--u9);
    }

    .sheet {
        max-width: 30rem;
    }

    .options {
        grid-template-columns: 1fr;
    }

    .venues-list li {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 1rem;
    }

    .models thead th:nth-child(3),
    .models tbody td:nth-child(3) {
        display: none;
    }

    .models th,
    .models td {
        padding-right: 8px;
    }

    .colophon-base {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 400px) {
    .option {
        padding: var(--u9) var(--u4) var(--u4);
    }

    .syllabus-list li {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .syllabus-list .no {
        padding-top: 0;
    }
}

/* --------------------------------------------------------------------------
   GitHub star chip (hero)
   -------------------------------------------------------------------------- */

.gh-chip {
    margin-top: var(--u4);
    font-family: var(--mono);
    font-size: 0.85rem;
}

.gh-chip a {
    color: var(--ink-soft);
    text-decoration: none;
}

.gh-chip a:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.gh-chip .star,
.gh-chip strong {
    color: var(--red);
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   Poll — real votes, stored as GitHub issues
   -------------------------------------------------------------------------- */

.poll {
    padding-block: 72px var(--u9);
    border-top: 3px double var(--ink);
}

.poll .section-lede {
    max-width: 58ch;
}

.poll-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--u4);
}

.poll-option.is-voted {
    border-color: var(--red);
    color: var(--red);
}

.poll-option.is-voted:hover {
    background: var(--paper-raised);
    color: var(--red);
}

.poll-results {
    margin-top: var(--u9);
    max-width: 44rem;
}

.poll-total {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-bottom: var(--u4);
}

.poll-rows {
    list-style: none;
}

.poll-row {
    display: grid;
    grid-template-columns: minmax(11rem, 16rem) 3.5rem 1fr;
    gap: var(--u4);
    align-items: center;
    padding-block: 10px;
}

.poll-row .poll-label {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
}

.poll-row .poll-label .yours {
    color: var(--red);
    font-weight: 400;
}

.poll-row .poll-count {
    font-family: var(--mono);
    font-size: 0.9rem;
    color: var(--red);
    text-align: right;
}

.poll-track {
    height: 12px;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
}

.poll-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--red);
    transition: width 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.poll-unavailable {
    font-family: var(--sans);
    font-size: 0.9rem;
    color: var(--ink-soft);
}

/* Footer view counter */
.colophon-base .views img {
    display: block;
    opacity: 0.85;
}

@media (max-width: 640px) {
    .poll-row {
        grid-template-columns: 1fr 3.5rem;
    }

    .poll-row .poll-track {
        grid-column: 1 / -1;
    }

    .poll-options .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .poll-fill {
        transition: none;
    }
}
