/* ppuzzle.works - Victorian Technomancy */

:root {
    --parchment: #f2e8d5;
    --walnut: #2d2319;
    --linen: #e8dcc8;
    --teal: #00b4a6;
    --magenta: #d4145a;
    --copper: #8b5e3c;
    --gold: #c9a84c;
    --mahogany: #4a1c1c;
    --grid-dot: #e0d4be;
}

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

body {
    background-color: var(--parchment);
    background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
    background-size: 20px 20px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--walnut);
}

h1, h2, h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mahogany);
}

h1 {
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    margin-bottom: 1rem;
}

h3 {
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    margin-bottom: 0.5rem;
}

.patent-ref {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--copper);
}

/* Chamber layout */
.chamber {
    min-height: 100dvh;
    position: relative;
    padding: clamp(40px, 8vw, 100px) clamp(20px, 4vw, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chamber-3,
.chamber-5 {
    background-color: var(--walnut);
    background-image: radial-gradient(circle, rgba(139,94,60,0.15) 1px, transparent 1px);
    background-size: 20px 20px;
}

.chamber-3 h2, .chamber-3 h3,
.chamber-5 h2, .chamber-5 h3 {
    color: var(--parchment);
}

.chamber-3 p, .chamber-5 p {
    color: var(--linen);
}

.chamber-3 .drawing-caption,
.chamber-5 .seal-text {
    color: var(--linen);
}

.chamber-label {
    position: sticky;
    top: 24px;
    left: 24px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 2rem);
    text-transform: uppercase;
    color: var(--gold);
    z-index: 10;
    position: absolute;
    top: 24px;
    left: 24px;
}

/* Corner Brackets */
.chamber-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    padding: clamp(30px, 5vw, 60px);
}

.corner {
    position: absolute;
    width: 40px;
    height: 40px;
}

.corner::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--copper);
}

.corner.top-left {
    top: 0; left: 0;
    border-top: 2px solid var(--copper);
    border-left: 2px solid var(--copper);
}
.corner.top-left::after { top: -3px; left: -3px; }

.corner.top-right {
    top: 0; right: 0;
    border-top: 2px solid var(--copper);
    border-right: 2px solid var(--copper);
}
.corner.top-right::after { top: -3px; right: -3px; }

.corner.bottom-left {
    bottom: 0; left: 0;
    border-bottom: 2px solid var(--copper);
    border-left: 2px solid var(--copper);
}
.corner.bottom-left::after { bottom: -3px; left: -3px; }

.corner.bottom-right {
    bottom: 0; right: 0;
    border-bottom: 2px solid var(--copper);
    border-right: 2px solid var(--copper);
}
.corner.bottom-right::after { bottom: -3px; right: -3px; }

/* Hero Grid - Chamber I */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(12px, 2vw, 24px);
    align-items: center;
}

.hero-text {
    grid-column: 2 / 8;
    grid-row: 1 / 3;
}

.hero-subtitle {
    margin-top: 1.5rem;
    max-width: 500px;
    font-weight: 600;
}

.hero-diagram {
    grid-column: 7 / 12;
    grid-row: 2 / 4;
    display: flex;
    justify-content: center;
}

.hero-diagram .iso-piece {
    width: 100%;
    max-width: 280px;
}

/* Spec Grid - Chamber II */
.spec-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(12px, 2vw, 24px);
}

.spec-col-1 {
    grid-column: 1 / 5;
}

.spec-col-2 {
    grid-column: 5 / 9;
    margin-top: 60px;
}

.spec-col-3 {
    grid-column: 9 / 13;
    margin-top: 120px;
}

.spec-col .iso-piece {
    width: 100%;
    max-width: 180px;
    margin: 1rem 0;
}

.spec-col .iso-piece.small {
    max-width: 120px;
}

/* Drawings Grid - Chamber III */
.drawings-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(12px, 2vw, 24px);
}

.drawing-item {
    padding: 1.5rem;
    border: 1px solid var(--copper);
    outline: 1px solid var(--copper);
    outline-offset: -6px;
}

.drawing-1 { grid-column: 1 / 5; }
.drawing-2 { grid-column: 4 / 8; margin-top: -40px; }
.drawing-3 { grid-column: 7 / 11; margin-top: -80px; }
.drawing-4 { grid-column: 9 / 13; margin-top: -40px; }

.drawing-item .iso-piece {
    width: 100%;
    max-width: 180px;
    margin: 0.5rem auto;
    display: block;
}

.drawing-caption {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.08em;
    margin-top: 0.5rem;
}

/* Method Steps - Chamber IV */
.method-steps {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.method-step {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    padding: 1.5rem;
    border: 1px solid var(--copper);
    outline: 1px solid var(--copper);
    outline-offset: -6px;
    box-shadow: 4px 4px 0 rgba(45, 35, 25, 0.15);
}

.method-step:nth-child(1) { margin-left: 0; }
.method-step:nth-child(2) { margin-left: 40px; }
.method-step:nth-child(3) { margin-left: 80px; }
.method-step:nth-child(4) { margin-left: 120px; }

.step-number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}

.step-content {
    flex: 1;
}

/* Seal - Chamber V */
.seal-content {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seal-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.seal-cog {
    width: 160px;
    height: 160px;
}

.seal-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--copper);
}

/* Ornamental Dividers */
.ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 2rem 0;
}

.ornament-line {
    width: 30%;
    height: 1px;
    background: var(--copper);
    position: relative;
}

.ornament-line::before,
.ornament-line::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--copper);
    top: -1.5px;
}

.ornament-line::before { left: 0; }
.ornament-line::after { right: 0; }

.ornament-diamond {
    width: 8px;
    height: 8px;
    background: var(--copper);
    transform: rotate(45deg);
}

/* Circuit SVGs */
.circuit-svg {
    display: block;
    width: 100%;
    height: 80px;
}

.circuit-path {
    stroke: var(--teal);
    stroke-width: 1.5;
    fill: none;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.circuit-path.active {
    animation: trace-draw 2s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes trace-draw {
    to { stroke-dashoffset: 0; }
}

/* Stagger Animation */
@keyframes stagger-enter {
    from {
        opacity: 0;
        transform: translateY(30px) translateX(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateX(0);
    }
}

[data-stagger-index] {
    opacity: 0;
}

[data-stagger-index].visible {
    animation: stagger-enter 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Iso piece hover */
.iso-piece {
    transition: filter 400ms ease;
    cursor: pointer;
}

.iso-piece:hover {
    filter: drop-shadow(0 4px 12px rgba(0, 180, 166, 0.3));
}

.iso-piece:hover .face-top {
    fill: var(--teal);
    transition: fill 400ms ease;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-grid {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    .spec-grid {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    .spec-col-2, .spec-col-3 {
        margin-top: 0;
    }

    .drawings-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .drawing-1, .drawing-2, .drawing-3, .drawing-4 {
        margin-top: 0;
    }

    .method-step:nth-child(2),
    .method-step:nth-child(3),
    .method-step:nth-child(4) {
        margin-left: 0;
    }
}
