/* ============================================
   genpatsu.io — Nuclear Control Room Interface
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --containment-black: #0A0F0A;
    --reactor-hall-dark: #141E14;
    --oxidized-panel-green: #3A4A3A;
    --instrument-pale-green: #B8C4B0;
    --reactor-amber: #C4A35A;
    --coolant-green: #4AB882;
    --warning-sodium: #E8A828;
    --scram-red: #D94F4F;
    --console-sage: #8A9B8A;
    --phosphor-bright: #3DD68C;
    --dark-emerald: #1B3A2A;
    --copper-conductor: #5A3A1A;
    --void-gap: #1A1A1A;
    --pure-black: #000000;

    --font-heading: 'Share Tech Mono', monospace;
    --font-jp: 'Noto Sans JP', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-data: 'Space Mono', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-body);
    font-weight: 300;
    color: var(--instrument-pale-green);
    background: var(--containment-black);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Console Frame --- */
#console-frame {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    border: 2px solid var(--oxidized-panel-green);
    border-radius: 3px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

#console-frame.visible {
    opacity: 1;
}

.rivet {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #6A7A6A, #3A4A3A 60%, #2A3A2A);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5), 0 0 3px rgba(58, 74, 58, 0.3);
}

.rivet-tl { top: -5px; left: -5px; }
.rivet-tr { top: -5px; right: -5px; }
.rivet-bl { bottom: -5px; left: -5px; }
.rivet-br { bottom: -5px; right: -5px; }

/* --- CRT Scan Line --- */
#scan-line {
    position: fixed;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--coolant-green);
    opacity: 0;
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(74, 184, 130, 0.3), 0 0 60px rgba(74, 184, 130, 0.1);
}

#scan-line.active {
    animation: scanDown 1.2s ease-in-out forwards;
}

@keyframes scanDown {
    0% { top: 0; opacity: 0.05; }
    10% { opacity: 0.05; }
    90% { opacity: 0.05; }
    100% { top: 100vh; opacity: 0; }
}

/* --- Blueprint Grid Background --- */
.blueprint-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(#0D1B0D08 1px, transparent 1px),
        linear-gradient(90deg, #0D1B0D08 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0;
    transition: opacity 1.5s ease-out;
    pointer-events: none;
}

.blueprint-grid.visible {
    opacity: 1;
}

/* --- Kanji Watermarks --- */
.kanji-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-jp);
    font-weight: 900;
    font-size: 15vw;
    color: var(--reactor-hall-dark);
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
    user-select: none;
    line-height: 1;
}

/* --- Radiation Particle System --- */
#particle-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.rad-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    opacity: 0.15;
    animation: floatUp linear infinite;
}

.rad-particle svg {
    width: 100%;
    height: 100%;
    fill: var(--phosphor-bright);
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    5% {
        opacity: 0.15;
    }
    95% {
        opacity: 0.15;
    }
    100% {
        transform: translateY(-20px) rotate(360deg);
        opacity: 0;
    }
}

/* --- Side Panel (Gauges) --- */
#side-panel {
    position: fixed;
    top: 50%;
    right: 28px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 100;
    opacity: 0;
    transition: opacity 1s ease-out 1.5s;
}

#side-panel.visible {
    opacity: 1;
}

.gauge {
    width: 100px;
    text-align: center;
    background: rgba(20, 30, 20, 0.85);
    border: 1px solid rgba(74, 184, 130, 0.12);
    border-radius: 4px;
    padding: 8px 6px 6px;
    backdrop-filter: blur(4px);
}

.gauge svg {
    width: 80px;
    height: 80px;
    display: block;
    margin: 0 auto;
}

.gauge-track {
    fill: none;
    stroke: rgba(58, 74, 58, 0.3);
    stroke-width: 4;
    stroke-dasharray: 4 2;
}

.gauge-fill {
    fill: none;
    stroke: var(--coolant-green);
    stroke-width: 2;
    stroke-dasharray: 260;
    stroke-dashoffset: 260;
    transform-origin: center;
    transform: rotate(-90deg);
    transition: stroke-dashoffset 1.5s cubic-bezier(0.34, 1.56, 0.64, 1), stroke 0.8s ease;
}

.gauge.active .gauge-fill {
    stroke-dashoffset: 80;
}

.gauge.caution .gauge-fill {
    stroke: var(--reactor-amber);
}

.gauge.alarm .gauge-fill {
    stroke: var(--scram-red);
}

.gauge-needle {
    stroke: var(--reactor-amber);
    stroke-width: 2;
    stroke-linecap: round;
    transform-origin: 60px 60px;
    transform: rotate(-120deg);
    transition: transform 1.5s cubic-bezier(0.34, 1.56, 0.64, 1), stroke 0.8s ease;
}

.gauge.active .gauge-needle {
    transform: rotate(30deg);
    animation: needleOscillate 3s ease-in-out infinite;
}

.gauge.caution .gauge-needle {
    stroke: var(--warning-sodium);
}

.gauge.alarm .gauge-needle {
    stroke: var(--scram-red);
}

.gauge.shutdown .gauge-needle {
    transform: rotate(-120deg);
    animation: none;
}

.gauge.shutdown .gauge-fill {
    stroke-dashoffset: 260;
}

@keyframes needleOscillate {
    0%, 100% { transform: rotate(30deg); }
    25% { transform: rotate(35deg); }
    50% { transform: rotate(28deg); }
    75% { transform: rotate(33deg); }
}

.gauge-center {
    fill: var(--void-gap);
    stroke: var(--oxidized-panel-green);
    stroke-width: 1;
}

.gauge-label {
    font-family: var(--font-heading);
    font-size: 0.5rem;
    color: var(--console-sage);
    letter-spacing: 0.1em;
    margin-top: 4px;
    text-transform: uppercase;
}

.gauge-value {
    font-family: var(--font-data);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--coolant-green);
    font-feature-settings: "tnum";
    transition: color 0.8s ease;
}

.gauge.caution .gauge-value {
    color: var(--reactor-amber);
}

.gauge.alarm .gauge-value {
    color: var(--scram-red);
}

.gauge-unit {
    font-family: var(--font-data);
    font-size: 0.55rem;
    color: var(--oxidized-panel-green);
}

/* --- Sections --- */
section {
    position: relative;
    min-height: 100vh;
    padding: 80px 40px 80px 40px;
    overflow: hidden;
}

/* --- Hero Section --- */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 60px;
}

#hero-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

#site-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    color: var(--reactor-amber);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    line-height: 1.15;
    text-shadow: 0 0 8px rgba(196, 163, 90, 0.4);
    min-height: 1.2em;
    margin-bottom: 20px;
}

#site-title .cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--reactor-amber);
    margin-left: 2px;
    animation: blink 0.8s step-end infinite;
    vertical-align: text-bottom;
}

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

.hero-subtitle {
    font-family: var(--font-jp);
    font-weight: 500;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--console-sage);
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 1s ease-out;
    line-height: 1.6;
}

.hero-subtitle.visible {
    opacity: 1;
}

/* Reactor Schematic */
#reactor-schematic {
    margin-top: 40px;
    z-index: 10;
    position: relative;
}

#reactor-svg {
    width: 300px;
    height: 450px;
    max-height: 60vh;
}

.reactor-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 3s ease-out;
}

.reactor-path.drawn {
    stroke-dashoffset: 0;
}

.reactor-label {
    opacity: 0;
    transition: opacity 1s ease-out 3s;
}

.reactor-path.drawn ~ .reactor-label,
.reactor-label.visible {
    opacity: 0.6;
}

/* --- Cable Tray Divider --- */
.cable-tray {
    width: 100%;
    height: 24px;
    background-color: var(--void-gap);
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        #2A2A2A 3px,
        #2A2A2A 4px
    );
    position: relative;
    margin: 40px 0;
    overflow: hidden;
}

.cable-tray::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--reactor-amber);
    opacity: 0.4;
}

.cable-tray::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--coolant-green);
    opacity: 0.3;
}

.cable-tray-red::before {
    background: var(--scram-red);
}

.cable-tray-red::after {
    background: var(--scram-red);
    opacity: 0.2;
}

/* --- Bento Grid --- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 60px;
    position: relative;
    z-index: 10;
}

.panel {
    background: var(--reactor-hall-dark);
    border: 1px solid rgba(74, 184, 130, 0.12);
    border-radius: 2px;
    padding: 28px 24px;
    position: relative;
    transition: border-color 0.6s ease;
}

.panel.in-focus {
    border-color: rgba(74, 184, 130, 0.25);
}

.panel-wide {
    grid-column: span 2;
}

.panel-tall {
    grid-row: span 2;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(58, 74, 58, 0.2);
}

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    color: var(--reactor-amber);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.4;
    text-shadow: 0 0 6px rgba(196, 163, 90, 0.3);
    flex: 1;
}

.en-label {
    font-family: var(--font-heading);
    font-size: 0.65rem;
    color: var(--console-sage);
    letter-spacing: 0.15em;
    display: block;
    margin-top: 2px;
}

.panel-id {
    font-family: var(--font-data);
    font-size: 0.6rem;
    color: var(--oxidized-panel-green);
    white-space: nowrap;
}

.panel-id.alarm {
    color: var(--scram-red);
    animation: alarmPulse 4s ease-in-out infinite;
}

@keyframes alarmPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.panel-content p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--instrument-pale-green);
    margin-bottom: 14px;
}

.panel-content p:last-child {
    margin-bottom: 0;
}

.panel-content strong {
    font-weight: 400;
    color: var(--coolant-green);
}

.panel-content em {
    font-style: italic;
    color: var(--reactor-amber);
}

/* --- Dosimeter Badge --- */
.dosimeter-badge {
    width: 32px;
    min-width: 32px;
    height: 48px;
    background: linear-gradient(to right, var(--dark-emerald), var(--dark-emerald));
    border: 1px solid var(--oxidized-panel-green);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.dosimeter-badge::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(to right, var(--dark-emerald), var(--coolant-green));
    transition: width 1.5s ease-out;
}

.dosimeter-badge.filling::after {
    width: 100%;
}

.dosimeter-red {
    border-color: rgba(217, 79, 79, 0.3);
}

.dosimeter-red::after {
    background: linear-gradient(to right, #3A1A1A, var(--scram-red));
}

/* --- Reveal Animation --- */
.reveal-panel {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.reveal-panel[data-reveal="left"] {
    transform: translateX(-30px);
}

.reveal-panel[data-reveal="right"] {
    transform: translateX(30px);
}

.reveal-panel[data-reveal="bottom"] {
    transform: translateY(30px);
}

.reveal-panel.revealed {
    opacity: 1;
    transform: translate(0, 0);
}

/* --- Timeline Section --- */
#timeline {
    padding: 80px 40px;
    min-height: 150vh;
}

.strip-chart {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.strip-chart svg {
    width: 100%;
    height: 100%;
}

#strip-trace {
    animation: stripScroll 8s linear infinite;
}

@keyframes stripScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100px); }
}

.timeline-container {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 0;
    z-index: 10;
}

.timeline-axis {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--oxidized-panel-green);
    transform: translateX(-50%);
}

.timeline-entry {
    position: relative;
    margin-bottom: 80px;
    display: flex;
    align-items: flex-start;
}

.timeline-node {
    position: absolute;
    left: 50%;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--containment-black);
    border: 2px solid var(--coolant-green);
    transform: translateX(-50%);
    z-index: 2;
    transition: background 0.5s ease, box-shadow 0.5s ease, border-color 0.5s ease;
}

.timeline-entry.revealed .timeline-node {
    background: var(--coolant-green);
    box-shadow: 0 0 12px rgba(61, 214, 140, 0.5);
    border-color: var(--phosphor-bright);
}

.timeline-connector {
    position: absolute;
    top: 25px;
    height: 1px;
    background: var(--oxidized-panel-green);
    width: 40px;
    z-index: 1;
}

.timeline-connector.left {
    right: 50%;
    margin-right: 6px;
}

.timeline-connector.right {
    left: 50%;
    margin-left: 6px;
}

.timeline-content {
    width: 42%;
    background: var(--reactor-hall-dark);
    border: 1px solid rgba(74, 184, 130, 0.12);
    border-radius: 2px;
    padding: 20px;
}

.timeline-content.left {
    margin-right: auto;
    margin-left: 0;
}

.timeline-content.right {
    margin-left: auto;
    margin-right: 0;
}

.timeline-date {
    margin-bottom: 8px;
}

.date-jp {
    font-family: var(--font-jp);
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--console-sage);
    display: block;
}

.date-en {
    font-family: var(--font-data);
    font-size: 0.7rem;
    color: var(--oxidized-panel-green);
    display: block;
    margin-top: 2px;
}

.timeline-content h3 {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--reactor-amber);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 10px;
    text-shadow: 0 0 6px rgba(196, 163, 90, 0.3);
    line-height: 1.4;
}

.timeline-content p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--instrument-pale-green);
}

/* --- Core Chamber Section --- */
#core-chamber {
    background: var(--pure-black);
    min-height: 100vh;
    padding: 80px 40px;
}

.core-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: relative;
    z-index: 10;
}

.panel-core {
    border-color: rgba(217, 79, 79, 0.08);
    transition: border-color 4s ease-in-out;
    animation: corePulse 4s ease-in-out infinite;
}

@keyframes corePulse {
    0%, 100% { border-color: rgba(217, 79, 79, 0.08); }
    50% { border-color: rgba(217, 79, 79, 0.2); }
}

.panel-core .panel-header h2 {
    color: var(--scram-red);
    text-shadow: 0 0 6px rgba(217, 79, 79, 0.3);
}

.panel-core .panel-content strong {
    color: var(--scram-red);
}

/* --- Shutdown Section --- */
#shutdown {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--containment-black);
}

.shutdown-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

.shutdown-label {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--reactor-amber);
    letter-spacing: 0.15em;
    text-shadow: 0 0 8px rgba(196, 163, 90, 0.4);
    transition: color 3s ease, text-shadow 3s ease;
}

.shutdown-label.dimming {
    color: var(--oxidized-panel-green);
    text-shadow: none;
}

.shutdown-sublabel {
    font-family: var(--font-jp);
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: var(--console-sage);
    letter-spacing: 0.08em;
    margin-top: 12px;
    opacity: 0.7;
    transition: opacity 3s ease;
}

.shutdown-sublabel.dimming {
    opacity: 0.2;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    #console-frame {
        border-width: 1px;
    }

    .rivet {
        display: none;
    }

    #side-panel {
        position: fixed;
        top: 16px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        flex-direction: row;
        gap: 8px;
    }

    .gauge {
        width: 60px;
        padding: 4px;
    }

    .gauge svg {
        width: 32px;
        height: 32px;
    }

    .gauge-label {
        font-size: 0.35rem;
    }

    .gauge-value {
        font-size: 0.6rem;
    }

    .gauge-unit {
        font-size: 0.4rem;
    }

    section {
        padding: 60px 20px;
    }

    .bento-grid {
        grid-template-columns: 1fr;
        padding: 0 10px;
    }

    .panel-wide,
    .panel-tall {
        grid-column: span 1;
        grid-row: span 1;
    }

    #reactor-svg {
        width: 200px;
        height: 300px;
        max-height: 40vh;
    }

    .kanji-watermark {
        font-size: 30vw;
    }

    .cable-tray {
        height: 4px;
        background-image: none;
        background-color: var(--reactor-amber);
        opacity: 0.3;
    }

    .cable-tray::before,
    .cable-tray::after {
        display: none;
    }

    .cable-tray-red {
        background-color: var(--scram-red);
    }

    .timeline-axis {
        left: 20px;
    }

    .timeline-node {
        left: 20px;
    }

    .timeline-connector {
        display: none;
    }

    .timeline-content,
    .timeline-content.left,
    .timeline-content.right {
        width: calc(100% - 50px);
        margin-left: 50px;
        margin-right: 0;
    }

    /* Simplify reveals on mobile */
    .reveal-panel[data-reveal="left"],
    .reveal-panel[data-reveal="right"] {
        transform: translateY(20px);
    }
}

/* --- Indicator Lights (floating) --- */
.indicator-light {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 101;
    pointer-events: none;
}

.indicator-light.green {
    background: var(--coolant-green);
    box-shadow: 0 0 6px rgba(74, 184, 130, 0.5);
    animation: indicatorPulse 3s ease-in-out infinite;
}

.indicator-light.amber {
    background: var(--reactor-amber);
    box-shadow: 0 0 6px rgba(196, 163, 90, 0.5);
    animation: indicatorPulse 4s ease-in-out infinite 1s;
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.3; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--containment-black);
}

::-webkit-scrollbar-thumb {
    background: var(--oxidized-panel-green);
    border-radius: 2px;
}

/* --- Selection --- */
::selection {
    background: rgba(74, 184, 130, 0.2);
    color: var(--phosphor-bright);
}
