/* ==========================================================================
   buildlog.css — shared shell for the long-form hardware build pages
   (retrovolt, huskylens-vision, rig-arm, roborock-valetudo).

   These pages are documentation, not product pages: someone lands here from a
   search like "roborock s7 TPA17 fel root" and needs to read a procedure on a
   phone in a garage. So the type is bigger than the rest of the site, the
   measure is capped near 70ch, and every interactive flourish is optional.

   Each page sets its own --ac / --ac-soft / --ac-dim in a scoped :root block;
   everything below is keyed off those three so the pages stay siblings rather
   than clones. Deliberately independent of style.css — index.html carries a
   lot of scroll machinery these pages have no use for.
   ========================================================================== */

:root {
    --bg:        #07090e;
    --bg-2:      #0b0f17;
    --bg-3:      #10151f;
    --ink:       #f2f5f9;
    --ink-soft:  #c3ccda;
    --ink-mute:  #8b97a9;
    --ink-faint: #63708395;
    --line:      rgba(255, 255, 255, 0.09);
    --line-2:    rgba(255, 255, 255, 0.16);
    --card:      rgba(255, 255, 255, 0.035);

    /* Overridden per page. Amber is only the fallback. */
    --ac:      #fbbf24;
    --ac-soft: rgba(251, 191, 36, 0.14);
    --ac-dim:  rgba(251, 191, 36, 0.32);

    --warn:    #fb7185;
    --warn-bg: rgba(251, 113, 133, 0.10);
    --ok:      #6ee7b7;

    --font-sans:    Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Outfit', var(--font-sans);
    --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --shell: 1180px;
    --measure: 70ch;
}

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

html {
    overflow-x: clip;
    scroll-behavior: smooth;
    /* Sticky nav is 60px; leave the heading room to breathe under it. */
    scroll-padding-top: 92px;
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    background: var(--bg);
    color: var(--ink-soft);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a { color: inherit; }

::selection { background: var(--ac-dim); color: #fff; }

:focus-visible {
    outline: 2px solid var(--ac);
    outline-offset: 3px;
    border-radius: 4px;
}

.skip {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 12px 18px;
    background: var(--ac);
    color: #06080c;
    font-weight: 600;
}
.skip:focus { left: 12px; top: 12px; }

/* ============================ nav ============================ */

.bl-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 18px;
    height: 60px;
    padding: 0 clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: rgba(7, 9, 14, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.bl-nav__mark {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-decoration: none;
}
.bl-nav__mark span { color: var(--ac); }

.bl-nav__crumb {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.bl-nav__crumb a { color: var(--ink-mute); text-decoration: none; }
.bl-nav__crumb a:hover { color: var(--ac); }
.bl-nav__crumb b {
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bl-nav__back {
    margin-left: auto;
    flex: none;
    padding: 8px 15px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--ink-soft);
    text-decoration: none;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.bl-nav__back:hover {
    border-color: var(--ac);
    background: var(--ac-soft);
    color: var(--ink);
}

@media (max-width: 620px) {
    .bl-nav__crumb a, .bl-nav__crumb i { display: none; }
}

/* ============================ hero ============================ */

.bl-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(56px, 9vw, 104px) clamp(18px, 5vw, 48px) clamp(40px, 6vw, 64px);
    border-bottom: 1px solid var(--line);
    background:
        radial-gradient(ellipse 80% 60% at 18% -10%, var(--ac-soft), transparent 62%),
        linear-gradient(180deg, var(--bg-2), var(--bg));
}

/* Faint engineering grid — texture, not decoration you can actually read. */
.bl-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 58px 58px;
    -webkit-mask-image: radial-gradient(ellipse at 30% 0%, #000, transparent 72%);
    mask-image: radial-gradient(ellipse at 30% 0%, #000, transparent 72%);
    opacity: 0.55;
}

.bl-hero__inner {
    position: relative;
    width: min(100%, var(--shell));
    margin: 0 auto;
}

.bl-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ac);
}
.bl-eyebrow::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ac);
    box-shadow: 0 0 0 4px var(--ac-soft), 0 0 16px var(--ac);
}

.bl-hero h1 {
    max-width: 18ch;
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 6.2vw, 4.3rem);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -0.045em;
    color: var(--ink);
}

.bl-hero__lede {
    max-width: var(--measure);
    margin-top: 26px;
    font-size: clamp(1.04rem, 1.5vw, 1.22rem);
    line-height: 1.68;
    color: var(--ink-soft);
}
.bl-hero__lede strong { color: var(--ink); font-weight: 600; }

/* Spec strip — the at-a-glance answer for someone skim-reading. */
.bl-specs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 1px;
    margin-top: 40px;
    list-style: none;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}
.bl-specs li { padding: 16px 18px; background: var(--bg-2); }
.bl-specs b {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 1.7vw, 1.4rem);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.bl-specs span {
    display: block;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.bl-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 26px;
}
.bl-tags span {
    padding: 6px 13px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    color: var(--ink-mute);
}

/* ============================ layout ============================ */

.bl-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: clamp(32px, 5vw, 68px);
    width: min(100%, var(--shell));
    margin: 0 auto;
    padding: clamp(40px, 6vw, 72px) clamp(18px, 5vw, 48px) 100px;
}

.bl-toc {
    position: sticky;
    top: 92px;
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.bl-toc h2 {
    margin-bottom: 14px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.bl-toc ol { list-style: none; counter-reset: toc; }
.bl-toc li { counter-increment: toc; }
.bl-toc a {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 4px;
    padding: 7px 0;
    border-left: 2px solid transparent;
    padding-left: 12px;
    margin-left: -14px;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--ink-mute);
    text-decoration: none;
    transition: color 0.16s, border-color 0.16s;
}
.bl-toc a::before {
    content: counter(toc, decimal-leading-zero);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--ink-faint);
}
.bl-toc a:hover,
.bl-toc a.is-active { color: var(--ink); border-left-color: var(--ac); }
.bl-toc a.is-active::before { color: var(--ac); }

@media (max-width: 900px) {
    .bl-shell { grid-template-columns: minmax(0, 1fr); }
    .bl-toc {
        position: static;
        max-height: none;
        padding-bottom: 24px;
        border-bottom: 1px solid var(--line);
    }
    .bl-toc ol {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0 18px;
    }
}

/* ============================ prose ============================ */

.bl-body > section { scroll-margin-top: 92px; }
.bl-body > section + section { margin-top: clamp(56px, 8vw, 92px); }

.bl-body h2 {
    margin-bottom: 8px;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3.1vw, 2.15rem);
    font-weight: 650;
    line-height: 1.14;
    letter-spacing: -0.035em;
    color: var(--ink);
}

.bl-body h3 {
    margin: 40px 0 12px;
    font-family: var(--font-display);
    font-size: clamp(1.12rem, 1.9vw, 1.3rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.bl-body h4 {
    margin: 28px 0 8px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ac);
}

.bl-kicker {
    margin-bottom: 18px;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.bl-body p { max-width: var(--measure); margin-bottom: 18px; }
.bl-body p strong { color: var(--ink); font-weight: 600; }
.bl-body p em { color: var(--ink); font-style: italic; }

.bl-body > section > p:first-of-type { font-size: 1.05rem; }

.bl-body a:not(.bl-btn):not(.bl-toc a) {
    color: var(--ac);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--ac-dim);
    transition: text-decoration-color 0.16s;
}
.bl-body a:not(.bl-btn):hover { text-decoration-color: var(--ac); }

.bl-body ul, .bl-body ol {
    max-width: var(--measure);
    margin: 0 0 20px 0;
    padding-left: 22px;
}
.bl-body li { margin-bottom: 9px; padding-left: 4px; }
.bl-body li::marker { color: var(--ac); }

code {
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--bg-3);
    font-family: var(--font-mono);
    font-size: 0.86em;
    color: var(--ink);
}

pre {
    margin: 0 0 22px;
    padding: 18px 20px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-left: 3px solid var(--ac-dim);
    border-radius: 10px;
    background: #05070b;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.68;
    color: var(--ink-soft);
    -webkit-overflow-scrolling: touch;
}
pre code { padding: 0; border: 0; background: none; font-size: inherit; }
pre .c { color: var(--ink-faint); }   /* comment */
pre .k { color: var(--ac); }          /* keyword / command */
pre .s { color: var(--ok); }          /* string / value */

/* ============================ steps ============================ */

.bl-steps { counter-reset: step; list-style: none; margin: 0; padding: 0; max-width: none; }

.bl-step {
    position: relative;
    counter-increment: step;
    margin: 0 0 4px;
    padding: 0 0 30px 58px;
    max-width: none;
}
/* Connector line between step markers. Last child stops it running past the end. */
.bl-step::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 38px;
    bottom: -4px;
    width: 1px;
    background: var(--line);
}
.bl-step:last-child { padding-bottom: 0; }
.bl-step:last-child::before { display: none; }

.bl-step::after {
    content: counter(step, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: 35px;
    height: 35px;
    border: 1px solid var(--ac-dim);
    border-radius: 50%;
    background: var(--bg-2);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ac);
}

.bl-step > h3 {
    margin: 4px 0 10px;
    font-size: 1.14rem;
}
.bl-step p, .bl-step ul, .bl-step ol { max-width: 66ch; }

/* ============================ callouts ============================ */

.bl-note {
    max-width: var(--measure);
    margin: 26px 0;
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--ac);
    border-radius: 10px;
    background: var(--card);
}
.bl-note p { margin: 0; }
.bl-note p + p { margin-top: 12px; }
.bl-note__label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ac);
}

.bl-note--warn { border-left-color: var(--warn); background: var(--warn-bg); }
.bl-note--warn .bl-note__label { color: var(--warn); }

/* ============================ tables ============================ */

.bl-tablewrap {
    max-width: 100%;
    margin: 0 0 26px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
caption {
    padding: 14px 18px 0;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    text-align: left;
    color: var(--ink-mute);
}
th, td {
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-mute);
    white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
td b { color: var(--ink); font-weight: 600; }
td code { white-space: nowrap; }

/* ============================ photo slots ============================

   Every figure ships pointing at a file that does not exist yet. The <img>
   fires onerror, which flips the figure into placeholder mode and shows the
   caption plus the exact path to drop the photo at. Adding the real photo is
   therefore a file copy with no HTML edit — which matters, because the whole
   point is that Sean fills these in later from his camera roll.
   ==================================================================== */

.bl-shot {
    position: relative;   /* anchors the collapsed <img> in placeholder state */
    margin: 30px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-2);
}
.bl-shot img {
    width: 100%;
    height: auto;
    border-bottom: 1px solid var(--line);
}
.bl-shot figcaption {
    padding: 13px 18px;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--ink-mute);
}
.bl-shot figcaption b {
    color: var(--ink-soft);
    font-weight: 600;
}

/* --- placeholder state --- */
.bl-shot.is-empty {
    border-style: dashed;
    border-color: var(--line-2);
    background: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 9px,
        rgba(255, 255, 255, 0.014) 9px,
        rgba(255, 255, 255, 0.014) 18px
    );
}
/* Hidden outright, and the markup deliberately does NOT use loading="lazy".
   A hidden image never intersects the viewport, so a lazy image here would wait
   forever on a load event that can never fire — the figure would be stuck as a
   placeholder even with the photo sitting right there on disk. (A collapsed 1px
   box does not rescue it either; the fetch still never starts.) So slot images
   load eagerly at low fetch priority instead. Keep them compressed. */
.bl-shot.is-empty img { display: none; }
.bl-shot.is-empty figcaption {
    display: grid;
    gap: 9px;
    padding: clamp(30px, 6vw, 52px) 22px;
    text-align: center;
}
.bl-shot.is-empty figcaption::before {
    content: 'Photo slot';
    justify-self: center;
    padding: 5px 12px;
    border: 1px solid var(--ac-dim);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ac);
}
.bl-shot.is-empty .bl-shot__path {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-faint);
    word-break: break-all;
}
/* Path is redundant noise once the real photo is in — it only helps while empty. */
.bl-shot:not(.is-empty) .bl-shot__path { display: none; }

.bl-shotgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin: 30px 0;
}
.bl-shotgrid .bl-shot { margin: 0; }

/* ============================ misc blocks ============================ */

.bl-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin: 26px 0;
    list-style: none;
    padding: 0;
    max-width: none;
}
.bl-cards li {
    margin: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
}
.bl-cards h4 { margin: 0 0 8px; }
.bl-cards p { margin: 0; font-size: 0.9rem; }

/* ASCII wiring diagrams etc. — monospace art needs its own scroll box. */
.bl-diagram {
    margin: 26px 0;
    padding: 22px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #05070b;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    line-height: 1.75;
    white-space: pre;
    color: var(--ink-soft);
}

.bl-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 6px 10px 6px 0;
    padding: 11px 20px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
.bl-btn:hover { border-color: var(--ac); background: var(--ac-soft); transform: translateY(-1px); }
.bl-btn--primary { border-color: var(--ac); background: var(--ac-soft); }

/* ============================ footer ============================ */

.bl-foot {
    padding: clamp(44px, 6vw, 68px) clamp(18px, 5vw, 48px);
    border-top: 1px solid var(--line);
    background: var(--bg-2);
}
.bl-foot__inner {
    width: min(100%, var(--shell));
    margin: 0 auto;
}
.bl-foot h2 {
    margin-bottom: 10px;
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 2.4vw, 1.75rem);
    font-weight: 650;
    letter-spacing: -0.03em;
    color: var(--ink);
}
.bl-foot p { max-width: 58ch; margin-bottom: 22px; color: var(--ink-mute); }

.bl-more {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 30px 0 0;
    padding: 0;
    list-style: none;
}
.bl-more a {
    display: block;
    height: 100%;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    text-decoration: none;
    transition: border-color 0.18s, background 0.18s;
}
.bl-more a:hover { border-color: var(--ac); background: var(--ac-soft); }
.bl-more b {
    display: block;
    margin-bottom: 5px;
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--ink);
}
.bl-more span { font-size: 0.85rem; color: var(--ink-mute); }

.bl-colophon {
    margin-top: 40px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    color: var(--ink-faint);
}
.bl-colophon a { color: var(--ink-mute); text-decoration: none; }
.bl-colophon a:hover { color: var(--ac); }

/* ============================ print ============================
   Someone following a wiring procedure at a bench may well print it.
   ============================================================== */

@media print {
    body { background: #fff; color: #000; font-size: 11pt; }
    .bl-nav, .bl-toc, .bl-foot, .skip { display: none; }
    .bl-hero { border-bottom: 1px solid #ccc; background: none; padding: 0 0 18pt; }
    .bl-hero::before { display: none; }
    .bl-hero h1, .bl-body h2, .bl-body h3 { color: #000; }
    .bl-shell { display: block; padding: 0; }
    pre, .bl-diagram { background: #f4f4f4; color: #000; border-color: #ccc; }
    .bl-shot.is-empty { display: none; }
    a { color: #000; }
}
