/* ============================================================
   ENGINEERS REPUBLIC — stylesheet
   Register: graphite, precise, materials-first.
   Deliberately cooler and harder than KSE Labs (cream/terracotta).
   ============================================================ */

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

:root {
    /* Graphite ground — from the brand concept */
    --ink-900: #0f1114;   /* deep well: inputs, plates */
    --ink-800: #14161a;   /* page */
    --ink-700: #1b1e23;   /* raised band, cards */
    --ink-600: #212429;   /* hover */
    --line:    #2a2e35;
    --line-hi: #3a3f47;

    /* Type */
    --steel-100: #ecedef;
    --steel-200: #c9ced6;
    --steel-400: #8b929c;
    --steel-500: #6e7680;

    /* Bronze — the one warm note, used sparingly */
    --accent:     #b08d57;
    --accent-hi:  #c9a56d;
    --accent-dim: rgba(176, 141, 87, 0.22);

    --font-display: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --shell: 1180px;
    --gut: 28px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    background: var(--ink-800);
    color: var(--steel-200);
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: var(--ink-900); }

:focus-visible {
    outline: 2px solid var(--accent-hi);
    outline-offset: 3px;
}

.shell {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 var(--gut);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: var(--ink-900);
    padding: 10px 16px;
    z-index: 100;
    font-family: var(--font-mono);
    font-size: 13px;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ── Wordmark ───────────────────────────────────────────── */

.wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 0.42em;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.16em;
    line-height: 1;
    color: var(--steel-100);
    white-space: nowrap;
}
.wordmark__b { color: var(--steel-500); font-weight: 500; }
.wordmark__dot { color: var(--accent); font-weight: 400; }
.wordmark:hover .wordmark__b { color: var(--accent); }
.wordmark__b, .wordmark__a { transition: color 0.25s var(--ease); }
.wordmark--sm { font-size: 13px; }

/* Nav wordmark folds to "ER" once the page scrolls. script.js wraps every
   [data-fold] character in .wm-c and sets --in / --out stagger delays. */
.wordmark--morph { transition: gap 0.5s var(--ease) 0.12s; }
.wm-c {
    display: inline-grid;
    grid-template-columns: 1fr;
    transition: grid-template-columns 0.45s var(--ease) var(--in);
}
.wm-c > span {
    min-width: 0;
    overflow: hidden;
    transition: opacity 0.3s var(--ease) var(--in), transform 0.45s var(--ease) var(--in);
}
.nav.is-compact .wordmark--morph { gap: 0; transition-delay: 0s; }
.nav.is-compact .wm-c {
    grid-template-columns: 0fr;
    transition: grid-template-columns 0.45s var(--ease) var(--out);
}
.nav.is-compact .wm-c > span {
    opacity: 0;
    transform: translateY(-0.6em);
    transition: opacity 0.25s var(--ease) var(--out), transform 0.45s var(--ease) var(--out);
}

/* ── Nav ────────────────────────────────────────────────── */

.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(20, 22, 26, 0.84);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.nav.is-stuck { border-bottom-color: var(--line); }

.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: 30px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.06em;
    color: var(--steel-400);
}
.nav__links a { transition: color 0.2s var(--ease); }
.nav__links a:hover { color: var(--steel-100); }

.nav__cta {
    border: 1px solid var(--line-hi);
    padding: 8px 16px;
    color: var(--steel-200);
}
.nav__cta:hover { border-color: var(--accent); color: var(--accent-hi) !important; }

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.06em;
    padding: 14px 26px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.22s var(--ease);
}
.btn--solid {
    background: var(--steel-100);
    color: var(--ink-900);
    font-weight: 500;
}
.btn--solid:hover { background: var(--accent-hi); }
.btn--ghost {
    border-color: var(--line-hi);
    color: var(--steel-200);
}
.btn--ghost:hover { border-color: var(--steel-400); color: var(--steel-100); }

/* ── Hero ───────────────────────────────────────────────── */

.hero { padding: 116px 0 0; }

.eyebrow {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 30px;
}
.eyebrow::before {
    content: '';
    width: 22px;
    height: 1px;
    background: var(--accent);
    flex: none;
}

.hero__title {
    font-size: clamp(38px, 6.1vw, 82px);
    line-height: 1;
    letter-spacing: -0.035em;
    font-weight: 600;
    color: var(--steel-100);
    max-width: 22ch;
}
.hero__title em {
    font-style: normal;
    color: var(--accent);
}

.hero__lede {
    margin-top: 34px;
    max-width: 60ch;
    color: var(--steel-400);
    font-size: clamp(16px, 1.6vw, 19px);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 42px;
}

.hero__rule {
    margin: 96px 0 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line-hi) 18%, var(--line-hi) 82%, transparent);
}

/* Spec bar — the "spec sheet" note */
.specbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--line);
}
.specbar__item {
    padding: 26px 0 30px;
    border-right: 1px solid var(--line);
    padding-right: 20px;
}
.specbar__item:last-child { border-right: 0; }
.specbar dt {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--steel-500);
    margin-bottom: 9px;
}
.specbar dd {
    font-size: 15px;
    color: var(--steel-200);
    line-height: 1.4;
}

.dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 8px;
    vertical-align: middle;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── Sections ───────────────────────────────────────────── */

.section { padding: 104px 0; border-bottom: 1px solid var(--line); }
.section--alt { background: var(--ink-700); }

.grid-2 {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 56px;
}

.section__label .idx {
    display: block;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin-bottom: 12px;
}
.section__label h2 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--steel-400);
}

.prose__lead {
    font-size: clamp(21px, 2.4vw, 28px);
    line-height: 1.38;
    letter-spacing: -0.018em;
    color: var(--steel-100);
    max-width: 34ch;
    margin-bottom: 28px;
}
.prose__lead--tight { max-width: 40ch; }

.prose p + p { margin-top: 20px; }
.prose p:not(.prose__lead) {
    color: var(--steel-400);
    max-width: 62ch;
}

/* ── Lineage line ───────────────────────────────────────── */

.lineage {
    border-left: 2px solid var(--accent);
    padding-left: 20px;
    max-width: 58ch;
    color: var(--steel-400);
    font-size: 16px;
}

/* ── Figures (the documentation log) ────────────────────── */

.fig {
    margin-top: 56px;
    padding-top: 30px;
    border-top: 1px solid var(--line);
}
.fig--plain { border-top: 0; padding-top: 0; margin-top: 40px; }

.fig__head {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.fig__id {
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}
.fig__title {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.018em;
    color: var(--steel-100);
}
.fig__spec {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.1em;
    color: var(--steel-500);
    border: 1px solid var(--line-hi);
    padding: 3px 10px;
    white-space: nowrap;
}

.fig__plates {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.fig__plates--three { grid-template-columns: repeat(3, 1fr); }

/* Plates match the source photographs (3:4 portrait), so nothing is cropped. */
.plate {
    position: relative;
    aspect-ratio: 3 / 4;
    background: var(--ink-900);
    border: 1px solid var(--line);
    overflow: hidden;
}
.plate--wide { max-width: 520px; }
.plate img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.82) contrast(1.04);
    transition: filter 0.4s var(--ease), transform 0.5s var(--ease);
}
.plate:hover img { filter: none; transform: scale(1.015); }

/* Empty state — names the file to drop in, reads as a contact sheet slot. */
.plate:empty::before,
.plate:not(:has(img))::before {
    content: attr(data-src);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--steel-500);
    background-image:
        linear-gradient(135deg, rgba(255, 255, 255, 0.022) 25%, transparent 25%,
            transparent 50%, rgba(255, 255, 255, 0.022) 50%, rgba(255, 255, 255, 0.022) 75%,
            transparent 75%);
    background-size: 10px 10px;
    text-align: center;
    padding: 10px;
}

.fig__specs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin-top: 18px;
    background: var(--line);
    border: 1px solid var(--line);
}
.fig__specs > div { background: var(--ink-700); padding: 14px 16px; }
.fig__specs dt {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--steel-500);
    margin-bottom: 7px;
}
.fig__specs dd {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--steel-200);
}

.fig__cap {
    margin-top: 18px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--steel-400);
    max-width: 62ch;
}

/* ── Tools strip ────────────────────────────────────────── */

.tools {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1px;
    margin-top: 44px;
    background: var(--line);
    border: 1px solid var(--line);
}
.tools li {
    background: var(--ink-800);
    padding: 18px 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--steel-500);
}
.tools span {
    display: block;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: -0.01em;
    color: var(--steel-100);
    margin-bottom: 6px;
}

.note {
    margin-top: 34px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    color: var(--steel-400);
    max-width: 62ch;
}
.note__tag {
    display: inline-block;
    border: 1px solid var(--line-hi);
    padding: 2px 8px;
    margin-right: 12px;
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--steel-500);
}
.note a { color: var(--accent-hi); border-bottom: 1px solid var(--line-hi); }
.note a:hover { border-bottom-color: var(--accent-hi); }

/* ── Form ───────────────────────────────────────────────── */

.form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 40px;
    max-width: 640px;
}
.field--full { grid-column: 1 / -1; }

.field label {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--steel-500);
    margin-bottom: 9px;
}
.field input,
.field textarea {
    width: 100%;
    background: var(--ink-900);
    border: 1px solid var(--line);
    color: var(--steel-100);
    font-family: var(--font-display);
    font-size: 15.5px;
    padding: 13px 14px;
    transition: border-color 0.2s var(--ease);
    resize: vertical;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--steel-500); }
.field input:focus,
.field textarea:focus { border-color: var(--accent); outline: none; }
.field.is-invalid input,
.field.is-invalid textarea { border-color: #b5645f; }

.form__foot {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.form__status {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--steel-500);
}
.form__status.is-ok { color: var(--accent-hi); }
.form__status.is-err { color: #c98682; }

/* ── Footer ─────────────────────────────────────────────── */

.footer { padding: 44px 0 56px; background: var(--ink-800); }
.footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.footer__meta,
.footer__link {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--steel-500);
}
.footer__link a { transition: color 0.2s var(--ease); }
.footer__link a:hover { color: var(--accent-hi); }

/* ── Reveal ─────────────────────────────────────────────── */

.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; gap: 26px; }
    .fig__specs { grid-template-columns: repeat(2, 1fr); }
    .hero { padding-top: 78px; }
    .hero__rule { margin-top: 68px; }
    .section { padding: 72px 0; }
}

@media (max-width: 620px) {
    :root { --gut: 20px; }
    .nav__links { gap: 18px; font-size: 11.5px; }
    .nav__links a:not(.nav__cta) { display: none; }
    .form { grid-template-columns: 1fr; }
    .hero__title { max-width: none; }
    .specbar { grid-template-columns: 1fr; }
    .specbar__item { border-right: 0; border-bottom: 1px solid var(--line); }
    .specbar__item:last-child { border-bottom: 0; }
    .fig__plates--three { grid-template-columns: 1fr 1fr; }
    .fig__plates--three .plate:first-child { grid-column: 1 / -1; }
    .fig__specs { grid-template-columns: 1fr 1fr; }
    .fig__spec { margin-left: 0; }
    .footer__inner { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}
