/* ============================================================
   a6c.xyz — A Hand-Drawn Atlas of Abstract Technology
   Honeyed-neutral palette, layered-depth, typewriter rhythm.
   ============================================================ */

:root {
    --vellum:        #F5E9D0;
    --honeycomb:     #E4CFA3;
    --amber-resin:   #C99A5B;
    --walnut-ink:    #8A5A2B;
    --espresso-soot: #3B2A1A;
    --sunlit-vellum: #F9F3E3;
    --burnt-caramel: #A37744;
    --ember-shadow:  #1E1208;

    --font-display: "Azeret Mono", ui-monospace, monospace;
    --font-header:  "DM Sans", system-ui, sans-serif;
    --font-body:    "Special Elite", "Courier New", monospace;
    --font-tech:    "Share Tech Mono", ui-monospace, monospace;
}

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

html {
    scroll-behavior: smooth;
    background: var(--vellum);
}

body {
    font-family: var(--font-body);
    color: var(--espresso-soot);
    background:
        radial-gradient(ellipse at 20% 10%, var(--sunlit-vellum) 0%, transparent 55%),
        linear-gradient(180deg, var(--vellum) 0%, var(--honeycomb) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    letter-spacing: 0.005em;
    cursor: crosshair;
}

/* paper texture overlay via repeating noise feel using gradients */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 39px,
            rgba(138, 90, 43, 0.04) 40px
        ),
        repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent 39px,
            rgba(138, 90, 43, 0.03) 40px
        );
    mix-blend-mode: multiply;
    opacity: 0.45;
}

/* ============================================================
   Cursor candle — amber radial glow lerp-trailed by JS
   ============================================================ */
#candle {
    position: fixed;
    width: 360px;
    height: 360px;
    pointer-events: none;
    background: radial-gradient(circle, rgba(201, 154, 91, 0.32) 0%, rgba(201, 154, 91, 0.12) 35%, rgba(201, 154, 91, 0) 70%);
    transform: translate3d(-50%, -50%, 0);
    left: 0;
    top: 0;
    mix-blend-mode: multiply;
    z-index: 9000;
    will-change: transform;
}

/* ============================================================
   Plate ribbon navigation — five tiny circles, hairline
   ============================================================ */
#ribbon {
    position: fixed;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9100;
    display: flex;
    flex-direction: column;
    gap: 28px;
    align-items: center;
    padding: 22px 0;
}

#ribbon .ribbon-line {
    position: absolute;
    top: 22px;
    bottom: 22px;
    left: 50%;
    width: 1px;
    background: var(--walnut-ink);
    opacity: 0.45;
    transform: translateX(-50%);
}

#ribbon .dot {
    position: relative;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--walnut-ink);
    z-index: 1;
}

#ribbon .dot-mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid var(--walnut-ink);
    background: var(--vellum);
    transition: background 0.4s ease, transform 0.4s ease, box-shadow 0.4s ease;
}

#ribbon .dot.active .dot-mark {
    background: var(--amber-resin);
    transform: scale(1.4);
    box-shadow: 0 0 0 3px rgba(201, 154, 91, 0.18);
}

#ribbon .dot-label {
    position: absolute;
    left: 24px;
    font-family: var(--font-tech);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--walnut-ink);
    opacity: 0;
    transition: opacity 0.4s ease;
    white-space: nowrap;
}

#ribbon .dot:hover .dot-label,
#ribbon .dot.active .dot-label {
    opacity: 0.9;
}

/* ============================================================
   3D stage and Z-planes
   ============================================================ */
#stage {
    position: relative;
    perspective: 1200px;
    perspective-origin: 50% 30%;
    transform-style: preserve-3d;
    z-index: 2;
}

.z-plane {
    position: fixed;
    inset: 0;
    pointer-events: none;
    transform-style: preserve-3d;
    will-change: transform;
}

/* Rear vellum (Z-300) */
.z-plane--rear {
    z-index: 1;
    background:
        radial-gradient(ellipse at 80% 90%, rgba(138, 90, 43, 0.16), transparent 50%),
        radial-gradient(ellipse at 10% 5%, rgba(249, 243, 227, 0.6), transparent 60%);
}

.vellum-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(0deg, transparent 0, transparent 79px, rgba(138, 90, 43, 0.08) 80px),
        linear-gradient(90deg, transparent 0, transparent 79px, rgba(138, 90, 43, 0.06) 80px);
    background-size: 80px 80px;
    opacity: 0.7;
    filter: blur(0.4px);
}

.vellum-stain {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(138, 90, 43, 0.10) 0%, rgba(138, 90, 43, 0) 70%);
    filter: blur(3px);
}
.vellum-stain.stain-1 { width: 320px; height: 320px; top: 8%; right: -80px; }
.vellum-stain.stain-2 { width: 480px; height: 480px; bottom: -120px; left: -120px; }

/* Draft pencil sketches (Z-200) */
.z-plane--draft { z-index: 2; }

.draft-sketch {
    position: absolute;
    opacity: 0.5;
    filter: blur(0.4px);
}
.draft-sketch--1 {
    width: 36vw; max-width: 540px;
    top: 20%;
    left: 4%;
    transform: rotate(-6deg);
}
.draft-sketch--2 {
    width: 22vw; max-width: 320px;
    top: 55%;
    right: 5%;
    transform: rotate(4deg);
}

/* Diagrams ambient layer (Z-100) */
.z-plane--diagrams { z-index: 3; }

/* Dust motes canvas (Z+300) */
.z-plane--motes {
    z-index: 9050;
    pointer-events: none;
    width: 100vw;
    height: 100vh;
}

/* ============================================================
   Plates — each is full viewport
   ============================================================ */
.plate {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 8vw;
    z-index: 10;
    transform-style: preserve-3d;
}

.plate-paper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    min-height: 80vh;
    background:
        radial-gradient(ellipse at 15% 10%, var(--sunlit-vellum) 0%, transparent 60%),
        var(--vellum);
    border-radius: 2px;
    padding: 64px clamp(24px, 5vw, 80px);
    box-shadow:
        0 30px 60px -20px rgba(30, 18, 8, 0.25),
        0 12px 24px -10px rgba(30, 18, 8, 0.18),
        inset 0 0 80px rgba(138, 90, 43, 0.08);
    transform: translateZ(0);
    overflow: hidden;
}

.plate-paper::before {
    /* hand-ruled margin lines, never quite parallel */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to right, transparent 56px, rgba(138, 90, 43, 0.18) 57px, transparent 58px);
    opacity: 0.6;
    transform: rotate(0.18deg);
}

.plate-paper::after {
    /* grain */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 90% 80%, rgba(138, 90, 43, 0.15), transparent 55%),
        radial-gradient(ellipse at 5% 95%, rgba(138, 90, 43, 0.08), transparent 50%);
    mix-blend-mode: multiply;
    opacity: 0.55;
}

.plate-numeral {
    position: absolute;
    top: 24px;
    right: 32px;
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.32em;
    color: var(--walnut-ink);
    opacity: 0.7;
}

.plate-header {
    font-family: var(--font-header);
    font-weight: 500;
    letter-spacing: -0.01em;
    font-size: clamp(1.75rem, 3vw, 2.75rem);
    color: var(--walnut-ink);
    margin-bottom: 36px;
    line-height: 1.1;
}

/* ============================================================
   Typewriter mechanics — character-by-character, persistent caret
   ============================================================ */
.typewriter {
    visibility: hidden;
}
.typewriter.is-typing,
.typewriter.is-done {
    visibility: visible;
}

.tw-char {
    opacity: 0;
    display: inline;
}
.tw-char.tw-revealed {
    opacity: 1;
    animation: tw-press 90ms ease-out;
}
.tw-char.tw-space {
    /* preserve normal spacing */
}

.tw-caret {
    display: inline-block;
    color: var(--walnut-ink);
    margin-left: 1px;
    animation: caret-blink 0.6s steps(2) infinite;
    transform: translateY(2px);
}
.tw-caret.tw-caret-fade {
    animation: caret-blink 0.6s steps(2) 1, caret-fade 0.6s 0.6s forwards;
}

@keyframes tw-press {
    0%   { opacity: 0; transform: translateY(-1px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes caret-blink {
    0%, 50%   { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

@keyframes caret-fade {
    0%   { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* ============================================================
   PLATE I — frontispiece
   ============================================================ */
.plate--frontispiece .plate-paper {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.frontispiece-mark {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--walnut-ink);
    margin-bottom: 24px;
    opacity: 0.7;
}

.hero-domain {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(3rem, 7vw, 6.5rem);
    letter-spacing: 0.08em;
    color: var(--espresso-soot);
    margin-bottom: 28px;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(249, 243, 227, 0.6);
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    color: var(--walnut-ink);
    max-width: 640px;
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

.hero-meta {
    font-family: var(--font-tech);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--burnt-caramel);
    margin-top: 24px;
}

/* brass specimen pin */
.prop {
    position: absolute;
    transform-style: preserve-3d;
    will-change: transform;
    filter: drop-shadow(0 8px 12px rgba(30, 18, 8, 0.35));
}

.prop--pin {
    width: 110px;
    height: 140px;
    top: 24px;
    left: 36px;
    transform: rotate(-12deg);
}

/* ============================================================
   PLATE II — specimen (CPU exploded view + watch)
   ============================================================ */
.specimen-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 60vh;
    margin: 0 auto 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.diagram path,
.diagram line,
.diagram rect:not([fill]),
.diagram circle:not([fill]),
.diagram ellipse:not([fill]) {
    /* drawn-in animation handled per-element via JS */
}

.diagram--cpu {
    max-width: 900px;
    transform: translateZ(-30px) rotateX(2deg);
}

.prop--watch {
    width: 140px;
    height: 150px;
    bottom: -20px;
    right: 8%;
    transform: translateZ(80px) rotate(8deg);
}

.marginalia {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--espresso-soot);
    max-width: 720px;
    margin: 0 auto;
    padding-left: 28px;
    border-left: 1px dashed rgba(138, 90, 43, 0.4);
}

/* ============================================================
   PLATE III — marginalia
   ============================================================ */
.marginalia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 56px 48px;
    margin-bottom: 48px;
    position: relative;
    z-index: 2;
}

.margin-block {
    position: relative;
    padding-left: 36px;
}

.margin-glyph {
    position: absolute;
    left: 0;
    top: -2px;
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--amber-resin);
    line-height: 1;
}

.margin-block p {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.78;
    color: var(--espresso-soot);
    letter-spacing: 0.005em;
}

.prop--pen {
    width: 280px;
    height: 60px;
    top: 18%;
    right: 4%;
    transform: rotate(23deg) translateZ(60px);
}

.prop--magnifier {
    width: 140px;
    height: 140px;
    bottom: 8%;
    left: 4%;
    transform: rotate(-14deg) translateZ(70px);
}

/* ============================================================
   PLATE IV — cross-section / exploded
   ============================================================ */
.exploded-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 7;
    max-height: 64vh;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram--exploded {
    max-width: 1000px;
    transform-style: preserve-3d;
}

.exploded-layer {
    transform-origin: 450px 350px;
    transform-box: fill-box;
    transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.prop--paperweight {
    width: 120px;
    height: 120px;
    bottom: 6%;
    right: 4%;
    transform: translateZ(80px);
}

/* ============================================================
   PLATE V — colophon
   ============================================================ */
.plate--colophon .plate-paper {
    text-align: center;
}

.colophon-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding-top: 24px;
}

.prop--tube {
    width: 100px;
    height: 180px;
    margin: 0 auto;
    position: relative;
    transform: translateZ(40px);
}

.prop--seal {
    width: 130px;
    height: 130px;
    margin: 0 auto;
    position: relative;
    transform: translateZ(60px) rotate(-6deg);
}

.colophon-text-block {
    margin-top: 24px;
    max-width: 640px;
}

.colophon-domain {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2rem, 4vw, 3.2rem);
    letter-spacing: 0.08em;
    color: var(--espresso-soot);
    margin-bottom: 20px;
}

.colophon-date,
.colophon-coords {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--walnut-ink);
    margin-bottom: 12px;
}

.colophon-coords {
    font-family: var(--font-tech);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--burnt-caramel);
}

.colophon-end {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--burnt-caramel);
    margin-top: 28px;
    opacity: 0.75;
}

/* ============================================================
   Coffee ring stains
   ============================================================ */
.coffee-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(163, 119, 68, 0.25);
    background: radial-gradient(circle, transparent 60%, rgba(163, 119, 68, 0.10) 70%, transparent 80%);
    pointer-events: none;
    filter: blur(0.6px);
}
.coffee-ring--top {
    width: 120px;
    height: 120px;
    top: 60px;
    right: 80px;
    transform: rotate(-12deg) scale(1, 0.95);
}
.coffee-ring--bottom {
    width: 90px;
    height: 90px;
    bottom: 80px;
    right: 12%;
    transform: rotate(8deg) scale(0.95, 1);
}

.plate-corner-fold {
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--vellum) 50%, var(--honeycomb) 50%);
    box-shadow: -2px 2px 4px rgba(30, 18, 8, 0.15);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    opacity: 0.7;
}

/* ============================================================
   Initial reveal — first paint deliberately slow
   ============================================================ */
.is-pre-typed { opacity: 0; }

/* hide all plates except first until JS init? No — keep visible
   to allow scroll, but typewriter stays invisible until trigger */

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    #ribbon { left: 12px; gap: 22px; }
    .plate { padding: 60px 4vw; }
    .plate-paper { padding: 40px 22px; }
    .plate-numeral { top: 14px; right: 18px; font-size: 0.72rem; }
    .prop--pin { width: 70px; height: 90px; top: 14px; left: 18px; }
    .prop--watch { width: 90px; height: 96px; right: 4%; }
    .prop--pen { width: 180px; height: 40px; right: 2%; }
    .prop--magnifier { width: 90px; height: 90px; }
    .marginalia-grid { gap: 40px 24px; }
    .specimen-stage { aspect-ratio: 3 / 2.4; max-height: 48vh; }
    .exploded-stage { aspect-ratio: 5 / 6; max-height: none; }
    .draft-sketch--1 { width: 70vw; }
    .draft-sketch--2 { width: 50vw; }
}

@media (prefers-reduced-motion: reduce) {
    .tw-char { opacity: 1 !important; animation: none !important; }
    .tw-caret { display: none; }
    .typewriter { visibility: visible !important; }
}
