/* ===========================================================
   prototypic.dev — Breadboard Modular Composition
   Palette: warm parchment with generative accents
   =========================================================== */

:root {
    --bg: #F7F3ED;            /* warm cream */
    --bg-module: #FFFDF8;     /* pale linen */
    --border: #D4CCC0;        /* warm gray */
    --text-h: #2C2416;        /* dark umber */
    --text-b: #5A4F3F;        /* medium umber */
    --text-m: #7D6B52;        /* soft brown / marginalia */
    --acc-gen: #B85C38;       /* burnt sienna */
    --acc-int: #2A6B5E;       /* deep teal */
    --node: #8B7355;          /* warm bronze */
    --trace: #C9A96E;         /* faded amber */
    --wire-line: #C4B8A8;     /* prototype wire (left margin), per DESIGN spec */

    --shadow-rest: 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.08);

    --grid-max: 1200px;
    --gutter: 24px;
    --margin: 48px;

    --f-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --f-mono: 'IBM Plex Mono', 'Roboto Mono', ui-monospace, monospace;
    --f-marg: 'Crimson Pro', 'Lora', Georgia, serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text-b);
    font-family: var(--f-mono);
    font-size: clamp(0.875rem, 1.2vw, 1rem);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* ---------- Grid-dot pattern underlay ---------- */
.grid-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    animation: dot-fade 600ms ease-out 200ms forwards;
}

@keyframes dot-fade {
    from { opacity: 0; }
    to   { opacity: 0.55; }
}

/* ---------- Prototype wire (left margin) ---------- */
.wire {
    position: fixed;
    top: 0;
    left: 24px;
    width: 24px;
    height: 100vh;
    pointer-events: none;
    z-index: 5;
}

.wire-line {
    position: absolute;
    top: 0;
    left: 11px;
    width: 1px;
    height: 100%;
    background-color: var(--wire-line);
    overflow: hidden;
    transform-origin: top;
    transform: scaleY(0);
    animation: wire-draw 800ms ease-out 800ms forwards;
}

.wire-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 0%;
    background-color: var(--acc-gen);
    transition: height 100ms linear;
}

@keyframes wire-draw {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

.wire-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 100%;
}

.wire-node {
    position: absolute;
    left: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid var(--node);
    background-color: var(--bg);
    transform: translateY(-50%);
    transition: background-color 200ms ease-out, border-color 200ms ease-out, transform 200ms ease-out;
    opacity: 0;
    animation: node-fade 400ms ease-out forwards;
}

@keyframes node-fade {
    to { opacity: 1; }
}

.wire-node.activated {
    background-color: var(--acc-gen);
    border-color: var(--acc-gen);
    transform: translateY(-50%) scale(1.05);
}

/* mobile horizontal progress bar */
.mobile-wire {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--border);
    z-index: 10;
}

.mobile-wire-fill {
    height: 100%;
    width: 0%;
    background-color: var(--acc-gen);
    transition: width 80ms linear;
}

/* ---------- Composition / grid ---------- */
.composition {
    position: relative;
    z-index: 2;
    max-width: var(--grid-max);
    margin: 0 auto;
    padding: var(--margin) var(--margin) calc(var(--margin) * 2) calc(var(--margin) + 24px);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 24px 24px;
}

/* ---------- Title band ---------- */
.title-band {
    grid-column: 1 / -1;
    padding: 64px 0 40px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(12px);
    animation: title-in 700ms ease-out 1100ms forwards;
}

@keyframes title-in {
    to { opacity: 1; transform: translateY(0); }
}

.meta-tag {
    font-family: var(--f-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-m);
    margin-bottom: 16px;
}

.title {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--text-h);
    line-height: 0.95;
    letter-spacing: -0.035em;
    margin-bottom: 24px;
}

.title-sub {
    font-family: var(--f-marg);
    font-style: italic;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    color: var(--text-m);
    max-width: 60ch;
    line-height: 1.55;
}

.title-sub em {
    font-family: var(--f-mono);
    font-style: normal;
    color: var(--text-h);
    font-size: 0.9em;
    margin-right: 4px;
}

/* ---------- Rows / module groups ---------- */
.row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 24px;
}

.row-genesis-notation {
    margin-top: 64px;
}

.row-genesis-notation .module-genesis {
    grid-column: span 5;
}
.row-genesis-notation .module-notation {
    grid-column: span 3;
}

.row-notation-genesis {
    margin-top: 64px;
}
.row-notation-genesis .module-notation {
    grid-column: span 3;
}
.row-notation-genesis .module-genesis {
    grid-column: span 5;
}

.row-fragments {
    margin-top: 40px;
}

.row-fragments .module-fragment {
    grid-column: span 2;
}

.row-fragments .fragment-code {
    grid-column: span 4;
}

.row-fragments-2 {
    margin-top: 40px;
}
.row-fragments-2 .fragment-code-2 { grid-column: span 4; }
.row-fragments-2 .fragment-trace  { grid-column: span 2; }
.row-fragments-2 .fragment-marg   { grid-column: span 2; }

/* ---------- Specimen bands ---------- */
.specimen-band {
    grid-column: 1 / -1;
    margin-top: 64px;
    margin-bottom: 24px;
    padding: 40px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 700ms ease-out, transform 700ms ease-out;
}

.specimen-band.in-view {
    opacity: 1;
    transform: translateY(0);
}

.specimen-text {
    font-family: var(--f-display);
    font-weight: 500;
    font-size: clamp(1.5rem, 3.6vw, 2.75rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-h);
    max-width: 28ch;
}

.specimen-text strong {
    color: var(--acc-gen);
    font-weight: 700;
}

.specimen-quiet .specimen-text {
    font-family: var(--f-marg);
    font-style: italic;
    font-weight: 400;
    color: var(--text-h);
}

.specimen-attr {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-m);
}

.closing {
    margin-top: 96px;
    padding: 64px 0 16px;
    border-bottom: none;
}

.closing-text {
    color: var(--text-m);
}

.closing-accent {
    color: var(--acc-gen);
}

.closing-foot {
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-m);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ---------- Modules (general) ---------- */
.module {
    position: relative;
    background-color: var(--bg-module);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 24px;
    box-shadow: var(--shadow-rest);
    transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
    opacity: 0;
    transform: translateY(8px);
    overflow: hidden;
}

.module.in-view {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 400ms ease-out 300ms, transform 400ms ease-out 300ms, border-color 200ms ease-out, box-shadow 200ms ease-out;
}

.module:hover {
    border-color: var(--node);
    box-shadow: var(--shadow-hover);
}

/* path-draw style border using pseudo overlay */
.module::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    border: 1px solid transparent;
    box-sizing: border-box;
}

.module.in-view::before {
    animation: border-draw 400ms ease-out forwards;
}

@keyframes border-draw {
    0%   { clip-path: inset(0 100% 100% 0); border-color: var(--node); }
    25%  { clip-path: inset(0 0 100% 0); border-color: var(--node); }
    50%  { clip-path: inset(0 0 0 0); border-color: var(--node); }
    100% { clip-path: inset(0 0 0 0); border-color: transparent; }
}

.iter-marker {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    z-index: 2;
}

.iter-marker svg {
    width: 100%;
    height: 100%;
}

.module-head {
    margin-bottom: 16px;
}

.module-id {
    display: block;
    font-family: var(--f-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-m);
    margin-bottom: 8px;
}

.module h2 {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    color: var(--text-h);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.module h3 {
    font-family: var(--f-display);
    font-weight: 500;
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    color: var(--text-h);
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.module-foot {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.caption {
    font-family: var(--f-mono);
    font-size: 0.72rem;
    color: var(--text-m);
    letter-spacing: 0.04em;
}

/* ---------- Genesis modules ---------- */
.module-genesis {
    min-height: 360px;
    display: flex;
    flex-direction: column;
}

.genesis-canvas {
    flex: 1;
    width: 100%;
    height: 280px;
    background-color: transparent;
    display: block;
    margin-top: 8px;
}

.genesis-branching .genesis-canvas { background-color: rgba(247, 243, 237, 0.4); }
.genesis-particles .genesis-canvas { background-color: rgba(247, 243, 237, 0.4); }
.genesis-automaton .genesis-canvas { background-color: rgba(247, 243, 237, 0.4); }

/* ---------- Notation modules ---------- */
.module-notation {
    display: flex;
    flex-direction: column;
}

.module-notation p {
    margin-bottom: 14px;
    color: var(--text-b);
    font-size: 0.92rem;
}

.module-notation p:last-child {
    margin-bottom: 0;
}

.notation-list {
    list-style: none;
    counter-reset: notes;
    margin-top: 4px;
}

.notation-list li {
    counter-increment: notes;
    position: relative;
    padding-left: 28px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-b);
}

.notation-list li::before {
    content: counter(notes, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 0;
    color: var(--acc-int);
    font-family: var(--f-mono);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

.ts {
    color: var(--text-m);
    font-size: 0.78rem;
    margin-right: 6px;
    letter-spacing: 0.04em;
}

.marg, em.marg {
    font-family: var(--f-marg);
    font-style: italic;
    color: var(--text-m);
    font-size: 1.02em;
}

/* ---------- Fragment modules ---------- */
.module-fragment {
    min-height: 200px;
}

.poetic-code {
    font-family: var(--f-mono);
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--text-b);
    overflow: hidden;
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-word;
}

.poetic-code .kw  { color: var(--acc-int); font-weight: 500; }
.poetic-code .str { color: var(--acc-gen); }
.poetic-code .cm  { color: var(--trace); font-style: italic; }
.poetic-code .fn  { color: var(--text-h); }
.poetic-code .arg { color: var(--text-b); }

.poetic-code .char-fade {
    opacity: 0;
    transition: opacity 220ms ease-out;
}

.poetic-code .char-fade.show {
    opacity: 1;
}

/* swatch list */
.swatch-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 12px;
    margin-top: 6px;
}

.swatch-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-m);
}

.sw {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid var(--border);
    border-radius: 1px;
    flex-shrink: 0;
}

.swatch-list code {
    color: var(--text-h);
    font-family: var(--f-mono);
    font-size: 0.7rem;
}

.swatch-list .lbl {
    margin-left: auto;
    color: var(--text-m);
    letter-spacing: 0.04em;
}

/* diagram svg */
.diagram-svg, .trace-svg {
    width: 100%;
    height: auto;
    margin: 12px 0;
    display: block;
}

/* marginalia fragment */
.marg-quote {
    font-family: var(--f-marg);
    font-style: italic;
    font-size: clamp(1.05rem, 1.6vw, 1.35rem);
    color: var(--text-h);
    line-height: 1.45;
    margin-top: 12px;
}

.marg-attr {
    margin-top: 16px;
    font-size: 0.72rem;
    color: var(--text-m);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* breadboard trace decorative line behind rows */
.row::before {
    content: "";
    position: absolute;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .composition {
        padding: 32px 32px 80px 56px;
        gap: 16px;
    }
    .title-band { padding-top: 32px; }
}

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

    .wire { display: none; }
    .mobile-wire { display: block; }

    .composition {
        grid-template-columns: repeat(4, 1fr);
        padding: 24px 24px 64px;
        gap: 16px;
    }

    .row {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .row-genesis-notation .module-genesis,
    .row-notation-genesis .module-genesis,
    .row-genesis-notation .module-notation,
    .row-notation-genesis .module-notation {
        grid-column: 1 / -1;
    }

    .row-fragments .module-fragment,
    .row-fragments .fragment-code {
        grid-column: span 2;
    }

    .row-fragments-2 .fragment-code-2 { grid-column: 1 / -1; }
    .row-fragments-2 .fragment-trace  { grid-column: span 2; }
    .row-fragments-2 .fragment-marg   { grid-column: span 2; }

    .module-genesis { min-height: 300px; }
    .genesis-canvas { height: 240px; }

    .row-genesis-notation,
    .row-notation-genesis { margin-top: 40px; }

    .specimen-band { margin-top: 40px; padding: 24px 0; }

    .title-band { padding: 24px 0; }
}

@media (max-width: 480px) {
    .composition {
        padding: 16px 16px 48px;
        gap: 12px;
    }

    .row-fragments .module-fragment,
    .row-fragments .fragment-code,
    .row-fragments-2 .fragment-code-2,
    .row-fragments-2 .fragment-trace,
    .row-fragments-2 .fragment-marg {
        grid-column: 1 / -1;
    }

    .swatch-list { grid-template-columns: 1fr; }
}
