/* ===== ppuzzle.works v2 — sci-fi magazine spread ===== */

:root {
    --chrome-silver: #C0C0C0;
    --polished-steel: #E8E8EC;
    --deep-graphite: #2C2C34;
    --hud-cyan: #00D4FF;
    --alert-magenta: #FF2D78;
    --warm-brass: #B8956A;
    --frost-white: #F8F8FA;

    --font-display: "Oswald", "Inter", sans-serif;
    --font-body: "Crimson Text", Georgia, serif;
    --font-mono: "Share Tech Mono", "Courier New", monospace;

    --sidebar-w: 60px;
    --pad-x: clamp(32px, 5vw, 96px);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--chrome-silver);
    color: var(--deep-graphite);
    font-family: var(--font-body);
    font-size: clamp(17px, 1.6vw, 20px);
    line-height: 1.75;
    overflow-x: hidden;
    padding-right: var(--sidebar-w);
}

/* ===== HUD Frame (corner ornaments) ===== */
.hud-frame {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}
.hud-corner {
    position: absolute;
    width: 80px;
    height: 80px;
    color: var(--hud-cyan);
    opacity: 0;
    animation: hud-draw 800ms 200ms ease forwards;
}
.hud-corner path { stroke-dasharray: 120; stroke-dashoffset: 120; animation: stroke-draw 800ms 200ms ease forwards; }
.hud-corner--tl { top: 16px; left: 16px; }
.hud-corner--tr { top: 16px; right: calc(var(--sidebar-w) + 16px); }
.hud-corner--bl { bottom: 16px; left: 16px; animation-delay: 400ms; }
.hud-corner--br { bottom: 16px; right: calc(var(--sidebar-w) + 16px); animation-delay: 500ms; }

@keyframes hud-draw { to { opacity: 0.7; } }
@keyframes stroke-draw { to { stroke-dashoffset: 0; } }

/* ===== Page-turn wipe ===== */
.page-wipe {
    position: fixed;
    top: 0;
    left: -4px;
    width: 2px;
    height: 100vh;
    background: var(--hud-cyan);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.5);
    z-index: 80;
    pointer-events: none;
    opacity: 0;
}
.page-wipe.active {
    animation: wipe 0.4s ease forwards;
}
@keyframes wipe {
    0% { opacity: 1; left: -4px; }
    100% { opacity: 0; left: 100vw; }
}

/* ===== Sidebar HUD ===== */
.sidebar-hud {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, rgba(232, 232, 236, 0.85), rgba(192, 192, 192, 0.7));
    border-left: 1px solid rgba(44, 44, 52, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 24px 8px;
    z-index: 40;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.sidebar-top, .sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--deep-graphite);
}

.sidebar-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    opacity: 0.7;
}
.sidebar-id {
    color: var(--hud-cyan);
    font-weight: bold;
}
.sidebar-readout {
    color: var(--alert-magenta);
    font-size: 10px;
    font-weight: bold;
}

.sidebar-progress {
    width: 100%;
    height: 50%;
    flex: 1;
    margin: 12px 0;
}

.section-dot {
    fill: transparent;
    stroke: var(--deep-graphite);
    stroke-width: 1.5;
    transition: fill 0.3s, transform 0.3s, r 0.3s;
    transform-origin: center;
    transform-box: fill-box;
}
.section-dot.active {
    fill: var(--hud-cyan);
    stroke: var(--hud-cyan);
    animation: dot-pulse 0.3s ease;
}

@keyframes dot-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.sidebar-alert {
    background: transparent;
    border: 1px solid var(--alert-magenta);
    color: var(--alert-magenta);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.sidebar-alert:hover {
    background: rgba(255, 45, 120, 0.1);
}

/* ===== Spread base ===== */
.spread {
    min-height: 100vh;
    padding: 80px var(--pad-x);
    display: grid;
    position: relative;
    overflow: hidden;
}

/* ===== Cover spread ===== */
.spread--cover {
    background: linear-gradient(135deg, #C0C0C0 0%, #E8E8EC 50%, #C0C0C0 100%);
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "meta meta"
        "headline illust"
        "deck footer";
    gap: 32px 64px;
    align-items: center;
}
.cover-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(248, 248, 250, 0.5), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(184, 149, 106, 0.15), transparent 60%);
    pointer-events: none;
}
.cover-grid {
    display: contents;
}
.cover-meta {
    grid-area: meta;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    border-top: 1px solid var(--deep-graphite);
    padding-top: 14px;
}
.meta-line {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--deep-graphite);
    opacity: 0.85;
}
.meta-line--cyan {
    color: var(--hud-cyan);
    opacity: 1;
    font-weight: bold;
}

.masthead {
    grid-area: headline;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(64px, 11vw, 156px);
    line-height: 0.92;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--deep-graphite);
}
.masthead-line {
    display: block;
    overflow: hidden;
    position: relative;
}
.masthead-line:nth-child(2) {
    color: transparent;
    -webkit-text-stroke: 2px var(--deep-graphite);
}
.masthead-line .typed {
    display: inline-block;
}

.cover-deck {
    grid-area: deck;
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(18px, 1.7vw, 22px);
    color: var(--deep-graphite);
    max-width: 500px;
    border-left: 2px solid var(--hud-cyan);
    padding-left: 20px;
}

.cover-illustration {
    grid-area: illust;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.85);
    animation: hero-in 1.2s 1.4s ease forwards;
}
@keyframes hero-in {
    to { opacity: 1; transform: scale(1); }
}
.hero-svg {
    width: 100%;
    max-width: 480px;
    height: auto;
    filter: drop-shadow(0 8px 30px rgba(44, 44, 52, 0.3));
}

.cover-footer {
    grid-area: footer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--deep-graphite);
    padding-top: 14px;
}
.cover-arrow {
    font-size: 24px;
    color: var(--hud-cyan);
    animation: arrow-bob 1.6s ease-in-out infinite;
}
@keyframes arrow-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* ===== Feature spread ===== */
.spread--feature {
    grid-template-columns: 1fr 1fr;
    gap: 0 80px;
    align-items: center;
    background: linear-gradient(180deg, var(--polished-steel) 0%, var(--chrome-silver) 100%);
}
.spread--feature:nth-child(odd) {
    background: linear-gradient(180deg, var(--chrome-silver) 0%, var(--polished-steel) 100%);
}

.spread--feature[data-orientation="text-right"] .feature-illustration { order: 1; }
.spread--feature[data-orientation="text-right"] .feature-text { order: 2; }

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 540px;
}
.feature-meta {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    border-top: 1px solid var(--deep-graphite);
    padding-top: 12px;
}
.feature-headline {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(36px, 6vw, 84px);
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--deep-graphite);
}
.feature-pull {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(20px, 1.9vw, 24px);
    line-height: 1.5;
    color: var(--warm-brass);
    border-left: 3px solid var(--alert-magenta);
    padding-left: 18px;
}
.feature-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: var(--deep-graphite);
}
.feature-body p { line-height: 1.75; }

.feature-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
    border-top: 1px dashed rgba(44, 44, 52, 0.4);
    padding-top: 18px;
}
.stat-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 3vw, 40px);
    color: var(--deep-graphite);
    letter-spacing: 0.02em;
}
.stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--deep-graphite);
    opacity: 0.7;
}

.feature-illustration {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 480px;
}
.feature-svg {
    width: 100%;
    max-width: 460px;
    height: auto;
    filter: drop-shadow(0 10px 40px rgba(44, 44, 52, 0.25));
}

.hud-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.hud-arc {
    position: absolute;
    width: 80px;
    height: 80px;
    top: 0;
    left: 0;
    opacity: 0.8;
}
.hud-tag {
    position: absolute;
    top: 20px;
    left: 92px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--hud-cyan);
}
.hud-tag--right {
    left: auto;
    right: 0;
    top: auto;
    bottom: 20px;
    color: var(--alert-magenta);
}

/* ===== Alert list (feature 03) ===== */
.alert-list {
    list-style: none;
    margin-top: 16px;
    border-top: 1px solid rgba(44, 44, 52, 0.4);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.alert-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 14px;
    padding: 10px 12px;
    background: rgba(248, 248, 250, 0.5);
    border-left: 2px solid var(--alert-magenta);
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--deep-graphite);
}
.alert-item:hover {
    background: rgba(255, 45, 120, 0.08);
}
.alert-id {
    color: var(--alert-magenta);
    font-weight: bold;
}
.alert-text {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0;
}

/* ===== Shake animation (DESIGN.md spec) ===== */
@keyframes shake {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-5px); }
    40%  { transform: translateX(5px); }
    60%  { transform: translateX(-3px); }
    80%  { transform: translateX(3px); }
    100% { transform: translateX(0); }
}
.shake { animation: shake 0.3s ease; }

/* ===== Editorial close ===== */
.spread--close {
    background: linear-gradient(160deg, var(--polished-steel) 0%, var(--chrome-silver) 50%, var(--warm-brass) 200%);
    grid-template-columns: 1fr;
    align-items: center;
    justify-items: center;
    text-align: center;
    position: relative;
}
.close-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 50%, rgba(0, 212, 255, 0.06), transparent 60%),
        radial-gradient(circle at 30% 70%, rgba(184, 149, 106, 0.18), transparent 50%);
}
.close-content {
    position: relative;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}
.close-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--hud-cyan);
    border: 1px solid var(--hud-cyan);
    padding: 6px 14px;
}
.close-text {
    font-family: var(--font-body);
    font-size: clamp(24px, 2.4vw, 36px);
    line-height: 1.5;
    color: var(--deep-graphite);
    font-weight: 400;
}
.close-text em {
    font-style: italic;
    color: var(--warm-brass);
}
.close-sign {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sign-line {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--deep-graphite);
    opacity: 0.8;
}
.sign-line--cyan {
    color: var(--hud-cyan);
    opacity: 1;
}

/* ===== Reveal animation for spreads ===== */
.spread {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}
.spread.in-view {
    opacity: 1;
    transform: translateY(0);
}
.spread--cover {
    opacity: 1;
    transform: none;
}

/* ===== Mobile ===== */
@media (max-width: 900px) {
    body { padding-right: 0; }
    .sidebar-hud { display: none; }
    .hud-corner--tr, .hud-corner--br { right: 16px; }

    .spread { padding: 60px 24px; }

    .spread--cover {
        grid-template-columns: 1fr;
        grid-template-areas:
            "meta"
            "headline"
            "illust"
            "deck"
            "footer";
        gap: 24px;
    }

    .spread--feature {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    .spread--feature[data-orientation="text-right"] .feature-illustration { order: 0; }
    .spread--feature[data-orientation="text-right"] .feature-text { order: 1; }
    .feature-illustration { min-height: 360px; }

    .feature-stats { gap: 8px; }
    .stat-num { font-size: 24px; }
}

@media (max-width: 500px) {
    .feature-stats { grid-template-columns: 1fr 1fr; }
    .feature-stats .stat-block:last-child { grid-column: span 2; }
    .alert-item { grid-template-columns: 50px 1fr; gap: 10px; }
}
