@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-latin-400-italic.woff2') format('woff2');
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-latin-700-normal.woff2') format('woff2');
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-latin-700-italic.woff2') format('woff2');
}

:root {
    --bg: #1a1512;
    --bg-alt: #241d18;
    --fg: #d9cfc0;
    --fg-dim: #8f8172;
    --accent: #b8873f;
    --accent-dim: #6e5233;
    --border: #3a2f27;
    --error: #e05a5a;
    --sans: "IBM Plex Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background:
        linear-gradient(rgba(26, 21, 18, 0.88), rgba(26, 21, 18, 0.88)),
        url('/images/site-bg.jpg');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    color: var(--fg);
    font-family: var(--sans);
    line-height: 1.6;
}

code, pre, kbd, samp {
    font-family: var(--mono);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

header.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
}

header.site-header .brand {
    color: var(--accent);
    font-weight: bold;
    letter-spacing: 0.05em;
}

header.site-header nav a {
    margin-left: 1.5rem;
    color: var(--fg-dim);
}

header.site-header nav a:hover {
    color: var(--accent);
}

main.wide {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Two-panel layout: static left rail + content column */
.page-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    column-gap: 3rem;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 2rem;
}

.site-rail {
    position: sticky;
    top: 1.5rem;
    align-self: start;
    padding-top: 1.5rem;
    font-size: 0.85rem;
}

.rail-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.75rem;
}

.rail-label {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
}

@media (max-width: 640px) {
    .page-layout {
        display: block;
        padding: 0 1.5rem;
    }

    .site-rail {
        position: static;
        margin-bottom: 2.5rem;
    }
}

main > p,
main > li,
main > ul,
main > h2 {
    max-width: 75ch;
}

main > h1 {
    color: var(--accent);
}

main > h2 {
    color: var(--accent);
    font-size: 1.2rem;
    margin: 2.5rem 0 0.75rem;
}

footer.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 4rem;
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--fg-dim);
    font-size: 0.85rem;
}

/* Home hero */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4rem 1rem 3rem;
}

.hero h1 {
    color: var(--accent);
    font-size: 1.75rem;
    letter-spacing: 0.08em;
    margin: 1.5rem 0 0.5rem;
}

.hero p.tagline {
    color: var(--fg-dim);
    margin: 0;
}

/* Captioned thumbnail figures (click opens full image via js/figure-zoom.js) */
.figure-thumb {
    float: right;
    width: 280px;
    /* Right edge lines up with the 75ch prose column, not main's edge. */
    margin: 0.35rem max(0px, calc(100% - 75ch)) 1rem 1.75rem;
}

.figure-thumb img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
}

.figure-thumb a:hover img {
    border-color: var(--accent-dim);
}

.figure-thumb figcaption {
    margin-top: 0.4rem;
    color: var(--fg-dim);
    font-size: 0.75rem;
    line-height: 1.4;
}

@media (max-width: 640px) {
    .figure-thumb {
        float: none;
        width: 100%;
        margin: 0 0 1.5rem;
    }
}

.figure-zoom-dialog {
    padding: 0;
    border: 1px solid var(--border);
    background: var(--bg);
    max-width: 95vw;
    max-height: 95vh;
    cursor: zoom-out;
}

.figure-zoom-dialog::backdrop {
    background: rgba(0, 0, 0, 0.8);
}

.figure-zoom-dialog img {
    display: block;
    max-width: 95vw;
    max-height: 95vh;
    height: auto;
}

/* Manual quote blocks */
.manual-quote {
    clear: both;
    background: var(--bg-alt);
    border-left: 3px solid var(--accent-dim);
    padding: 1.25rem 1.5rem;
    margin: 2.5rem 0;
}

.manual-quote p {
    margin: 0 0 0.75rem;
}

.manual-quote cite {
    display: block;
    color: var(--fg-dim);
    font-style: normal;
    font-size: 0.85rem;
}

.section-note {
    color: var(--fg-dim);
}

/* Backroom / admin stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 2.5rem;
}

.stat-card {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 1rem;
}

.stat-card .value {
    color: var(--accent);
    font-size: 1.75rem;
    font-weight: bold;
}

.stat-card .label {
    color: var(--fg-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

table.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 2.5rem;
}

table.log-table th, table.log-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

table.log-table th {
    color: var(--fg-dim);
    font-weight: normal;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.status-2xx { color: var(--accent); }
.status-3xx { color: #d9c95f; }
.status-4xx { color: #e0883a; }
.status-5xx { color: var(--error); }

/* Base converter */
.converter {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-width: 75ch;
    margin: 2rem 0;
}

.converter-field {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.converter-field label {
    color: var(--fg-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex-shrink: 0;
}

.converter-field input[type="text"] {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--fg);
    font-family: var(--mono);
    font-size: 1.1rem;
    padding: 0.6rem 0.75rem;
}

.converter-field input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.converter-field input[type="text"][readonly] {
    color: var(--fg-dim);
}

.converter-lgp30-times {
    color: var(--fg-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.converter-field input.converter-q {
    flex: 0 0 4.5rem;
    width: 4.5rem;
}

.conv-error {
    color: #e0883a;
    font-size: 0.85rem;
    margin: 0;
}

/* Aligned label column in the full converter */
.converter:not(.converter-compact) .converter-field label {
    flex: 0 0 6.5rem;
}

.converter-decode {
    margin: -0.4rem 0 0 7.1rem;
    color: var(--fg-dim);
    font-family: var(--mono);
    font-size: 0.85rem;
    min-height: 1.3em;
}

/* Compact converter (IDE calculator panel) */
.converter-compact {
    gap: 0.45rem;
    margin: 0;
}

.converter-compact .converter-field label {
    flex: 0 0 2.6rem;
    font-size: 0.7rem;
}

.converter-compact .converter-field input[type="text"] {
    font-size: 0.85rem;
    padding: 0.3rem 0.45rem;
}

.converter-compact .converter-decode {
    margin: -0.2rem 0 0 3.2rem;
    font-size: 0.75rem;
}

.calc-panel {
    position: fixed;
    top: 10.25rem; /* below the IDE toolbar, so Help and the status stay visible */
    right: 1rem;
    z-index: 50;
    width: 22rem;
    max-width: calc(100vw - 2rem);
    background: var(--bg-alt);
    border: 1px solid var(--accent-dim);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    padding: 0.75rem 0.9rem 0.8rem;
}

.calc-panel[hidden] {
    display: none;
}

.calc-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    color: var(--accent);
    font-weight: bold;
    font-size: 0.9rem;
}

.calc-panel-header button {
    background: none;
    border: none;
    color: var(--fg-dim);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
}

.calc-panel-header button:hover {
    color: var(--fg);
}

.calc-panel-full {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    text-align: right;
}

.conv-note {
    color: var(--fg-dim);
    font-size: 0.85rem;
}

/* Auth (register / login / password reset / verify email) */
.auth-card {
    max-width: 420px;
    margin: 2rem auto 4rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1.5rem;
}

.auth-field {
    font-size: 0.8rem;
    color: var(--fg-dim);
    display: block;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--fg);
    font-family: var(--sans);
    padding: 0.5rem;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-field input[aria-invalid="true"] {
    border-color: var(--error);
}

.field-error,
.field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.field-error {
    color: var(--error);
}

.field-hint {
    color: var(--fg-dim);
}

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--fg-dim);
}

.auth-button {
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--fg);
    font-family: var(--sans);
    padding: 0.6rem;
    cursor: pointer;
}

.auth-error {
    color: var(--error);
    border: 1px solid var(--error);
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.lgp30-demo {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin: 2rem 0;
}

.lgp30-demo pre {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 0;
}

.lgp30-demo button {
    align-self: flex-start;
}

.lgp30-demo button:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-status {
    color: var(--fg);
    border: 1px solid var(--accent-dim);
    background: var(--bg-alt);
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.auth-links {
    font-size: 0.8rem;
    color: var(--fg-dim);
    margin-top: 1.25rem;
}

.auth-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Courses */
.course-list, .lesson-list {
    list-style: none;
    margin: 2rem 0;
    padding: 0;
}

.course-list-item {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.lesson-part-heading {
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.8rem;
    margin: 1.75rem 0 0.5rem;
}

.lesson-part-heading:first-child {
    margin-top: 0;
}

.lesson-list-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.lesson-complete-mark {
    color: var(--accent);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Lesson body — continuous-feed printer paper look, shared by both the
   concept/examples prose and the Exercises/Answer Key card (two separate
   .lesson-paper sheets, not merged into one). Sprocket holes are two
   columns of small circles, repeated down the left/right edges, punched
   through to var(--bg) so they read as holes rather than dots. Colors
   invert to dark-ink-on-paper deliberately, unlike the rest of the
   (dark-on-light) site UI — the point is that these blocks read as a
   physical printout, not another UI panel. */
.lesson-paper {
    --paper: #ece2cd;
    --ink: #2c2015;
    --ink-dim: #5c4526;
    position: relative;
    background: var(--paper);
    color: var(--ink);
    margin: 2rem 0;
    padding: 2.5rem 3rem;
    background-image:
        radial-gradient(circle at 10px 0, var(--bg) 5px, transparent 5.5px),
        radial-gradient(circle at calc(100% - 10px) 0, var(--bg) 5px, transparent 5.5px);
    background-repeat: repeat-y;
    background-size: 100% 28px;
    box-shadow: 0 0 0 1px var(--border);
}

.lesson-paper h2 {
    color: var(--ink-dim);
    font-size: 1rem;
    margin-top: 2.5rem;
}

.lesson-paper > h2:first-child,
.lesson-banner + h2 {
    margin-top: 0;
}

.lesson-banner {
    color: var(--ink-dim);
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.25);
}

.lesson-paper h3 {
    color: var(--ink-dim);
    font-size: 0.9rem;
}

.lesson-paper strong {
    color: var(--ink);
}

.lesson-paper code {
    background: rgba(0, 0, 0, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.18);
    padding: 0.1rem 0.35rem;
    font-size: 0.9em;
}

.lesson-paper pre {
    background: rgba(0, 0, 0, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.18);
    padding: 1rem;
    overflow-x: auto;
}

.lesson-paper pre code {
    background: none;
    border: none;
    padding: 0;
}

.lesson-paper blockquote {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--ink-dim);
    margin: 1.5rem 0;
    padding: 0.75rem 1.25rem;
}

.lesson-paper ul, .lesson-paper ol {
    padding-left: 1.5rem;
}

.lesson-paper li {
    margin: 0.4rem 0;
}

@media (max-width: 640px) {
    .lesson-paper {
        padding: 2.5rem 1.75rem;
    }
}

/* Questions card — Exercises + Answer Key. Same continuous-feed paper look
   as .lesson-paper (it just adds that class in the view too), kept as its
   own separate sheet rather than merged into the lesson prose above. */
details.answer-key {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.18);
    margin: 1.5rem 0 0;
    padding: 1rem 1.25rem;
}

details.answer-key summary {
    cursor: pointer;
    color: var(--ink-dim);
    font-weight: bold;
}

details.answer-key[open] summary {
    margin-bottom: 1rem;
}

.lesson-complete-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2.5rem 0;
}

.lesson-signin-note {
    margin: 2.5rem 0;
}

.lesson-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin: 1.5rem 0 3rem;
}

/* Machine section menu (lgp30/partials/nav), replacing the site rail on
 * that machine's pages. Title is prominent but plain: bigger, bold, no box. */
.section-nav-title {
    display: block;
    margin-bottom: 1rem;
    color: var(--accent);
    font-size: 1.25rem;
    font-weight: bold;
    letter-spacing: 0.04em;
}

.section-nav-title:hover {
    text-decoration: none;
}

.section-nav-link.is-current {
    color: var(--fg);
}

.section-nav-link.is-current::before {
    content: '▸ ';
    color: var(--accent);
}

/* IDE pages: half-width rail (short link list) and a tighter gap, so the
 * IDE itself gets the space. Stacking on narrow screens is inherited. */
.page-layout.ide-page {
    grid-template-columns: 120px minmax(0, 1fr);
    column-gap: 1.5rem;
}

/* Reference tables in prose pages (e.g. LGP-30 Programming's instruction list) */
table.ref-table {
    max-width: 75ch;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 1rem 0 1.5rem;
}

table.ref-table th,
table.ref-table td {
    text-align: left;
    padding: 0.35rem 0.75rem 0.35rem 0;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

table.ref-table th {
    color: var(--fg-dim);
    font-weight: normal;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

main > pre {
    max-width: 75ch;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    overflow-x: auto;
}

/* Word notation switch (public/js/hex-notation.js): a small text toggle
 * used in the calculators and the debugger's Memory pane header. */
.hex-switch {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--fg-dim);
    font-family: var(--sans);
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
    white-space: nowrap;
}

.hex-switch:hover {
    color: var(--fg);
    border-color: var(--accent-dim);
}
