/* ============================================
   scriptgrapher.com - Zen Dashboard Glitch Temple
   Muji-Glitch Zen Aesthetic
   ============================================ */

/* Custom Properties - Neon Palette */
:root {
    --paper-white: #FAFAFA;
    --void-black: #0A0A0A;
    --ink: #1A1A1A;
    --pencil-gray: #4A4A4A;
    --glitch-magenta: #FF00FF;
    --neon-mint: #00FFD1;
    --dopamine-pink: #FF2D6A;
    --electric-violet: #7B61FF;
    --scan-yellow: #FFFF00;
    --grid-seam: rgba(255, 0, 255, 0.15);
    --grid-seam-bright: rgba(255, 0, 255, 0.35);
}

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

html {
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    color: var(--ink);
    background: var(--paper-white);
    overflow-x: hidden;
    min-height: 100vh;
}

/* ============================================
   Floor Layout
   ============================================ */
.floor {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    scroll-snap-align: start;
}

.floor-one {
    background: var(--paper-white);
}

.floor-two {
    background: var(--void-black);
}

.floor-three {
    background: var(--paper-white);
}

/* ============================================
   Grid Overlay (Visible Architecture)
   ============================================ */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 2s ease;
}

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

.grid-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, var(--grid-seam) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-seam) 1px, transparent 1px);
    background-size:
        calc(100% / 12) 100%,
        100% calc(100% / 6);
    animation: gridPulse 6s ease-in-out infinite;
}

.grid-overlay-dark::before {
    background-image:
        linear-gradient(to right, var(--grid-seam-bright) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-seam-bright) 1px, transparent 1px);
}

.grid-overlay-fading::before {
    animation: gridFadeOut 8s ease-in-out infinite;
}

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

@keyframes gridFadeOut {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 0.45; }
}

/* ============================================
   Dashboard Grid
   ============================================ */
.dashboard-grid {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 2px;
    padding: 2px;
    z-index: 2;
}

.dashboard-grid-dark {
    background: transparent;
}

/* ============================================
   Floor One Modules
   ============================================ */

/* Top spacer */
.top-spacer-1 {
    grid-column: 1 / 13;
    grid-row: 1 / 2;
    background: transparent;
}

/* Breath Module (6col x 2row) */
.breath-module {
    grid-column: 1 / 7;
    grid-row: 2 / 4;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: var(--paper-white);
    overflow: hidden;
}

.breath-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 100;
    font-size: clamp(2rem, 6vw, 5rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink);
    animation: breathe 8s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes breathe {
    0%, 100% { letter-spacing: 0.1em; }
    50% { letter-spacing: 0.4em; }
}

.breath-subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.85vw, 0.9rem);
    color: var(--pencil-gray);
    letter-spacing: 0.02em;
    margin-top: 1.8rem;
}

/* Scan line inside breath module */
.scan-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--neon-mint);
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 0 8px var(--neon-mint), 0 0 16px var(--neon-mint);
    top: 0;
}

.scan-line.active {
    animation: scanDown 200ms linear forwards;
}

@keyframes scanDown {
    0% { top: 0; opacity: 1; }
    100% { top: 100%; opacity: 0.3; }
}

/* Void Modules */
.void-module {
    position: relative;
    background: transparent;
    border: 1px solid var(--grid-seam);
    transition: box-shadow 200ms ease;
}

.void-1 {
    grid-column: 7 / 10;
    grid-row: 2 / 4;
}

.void-2 {
    grid-column: 10 / 13;
    grid-row: 2 / 4;
}

.void-module:hover {
    box-shadow: inset 0 0 20px rgba(255, 45, 106, 0.15), 0 0 10px rgba(255, 45, 106, 0.08);
}

/* Coordinate readout below breath */
.coord-module {
    grid-column: 1 / 4;
    grid-row: 4 / 5;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 1.2rem;
    gap: 0.4rem;
    border-top: 1px solid var(--grid-seam);
}

.coord-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    font-size: 0.65rem;
    color: var(--pencil-gray);
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.coord-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--ink);
    letter-spacing: 0.05em;
}

.empty-1 {
    grid-column: 4 / 13;
    grid-row: 4 / 6;
    background: transparent;
}

/* Ticker Module (full bottom strip) */
.ticker-module {
    grid-column: 1 / 13;
    grid-row: 6 / 7;
    background: var(--void-black);
    overflow: hidden;
    display: flex;
    align-items: center;
    position: relative;
}

.ticker-track {
    display: flex;
    white-space: nowrap;
    animation: tickerScroll 90s linear infinite;
    will-change: transform;
}

.ticker-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.85vw, 0.9rem);
    color: var(--neon-mint);
    letter-spacing: 0.02em;
    filter: blur(1.5px);
    padding-right: 4rem;
    text-shadow: 0 0 8px rgba(0, 255, 209, 0.4);
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============================================
   Floor Two Modules
   ============================================ */

/* Graph Module (6col x 3row) */
.graph-module {
    grid-column: 1 / 7;
    grid-row: 1 / 4;
    background: var(--void-black);
    border: 1px solid var(--grid-seam-bright);
    display: flex;
    flex-direction: column;
    padding: 1.2rem;
    gap: 0.8rem;
    position: relative;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
}

.graph-label {
    color: var(--pencil-gray);
    text-transform: uppercase;
}

.graph-status {
    color: var(--neon-mint);
    text-shadow: 0 0 8px rgba(0, 255, 209, 0.5);
    animation: blink 2s ease-in-out infinite;
}

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

.waveform-svg {
    width: 100%;
    flex: 1;
    min-height: 0;
}

.waveform-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 4s ease-out;
}

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

.graph-axis {
    display: flex;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: var(--pencil-gray);
    letter-spacing: 0.1em;
    border-top: 1px solid var(--grid-seam-bright);
    padding-top: 0.5rem;
}

/* Data Modules */
.data-module {
    background: var(--void-black);
    border: 1px solid var(--grid-seam-bright);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem;
    position: relative;
}

.data-module::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    background: var(--electric-violet);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--electric-violet);
}

.data-module-1 {
    grid-column: 7 / 10;
    grid-row: 1 / 2;
}

.data-module-2 {
    grid-column: 7 / 10;
    grid-row: 2 / 3;
}

.data-module-3 {
    grid-column: 7 / 10;
    grid-row: 3 / 4;
}

.data-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.6rem, 0.7vw, 0.75rem);
    color: var(--pencil-gray);
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.data-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.4rem, 2.6vw, 2.4rem);
    color: var(--electric-violet);
    text-shadow: 0 0 10px rgba(123, 97, 255, 0.5), 0 0 20px rgba(123, 97, 255, 0.3);
    letter-spacing: 0.04em;
}

.data-unit {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: var(--pencil-gray);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Empty dark cells */
.empty-dark-1 {
    grid-column: 10 / 13;
    grid-row: 1 / 4;
    background: transparent;
}

/* Dark Void Module (with pulse) */
.void-dark {
    grid-column: 10 / 13;
    grid-row: 4 / 6;
    background: var(--void-black);
    border: 1px solid var(--grid-seam-bright);
}

.void-pulse {
    animation: voidPulse 6s ease-in-out infinite;
}

@keyframes voidPulse {
    0%, 100% {
        box-shadow: inset 0 0 0 1px rgba(255, 45, 106, 0.1);
        border-color: var(--grid-seam-bright);
    }
    50% {
        box-shadow: inset 0 0 30px rgba(255, 45, 106, 0.25), 0 0 20px rgba(255, 45, 106, 0.15);
        border-color: rgba(255, 45, 106, 0.6);
    }
}

/* Status strip */
.status-strip {
    grid-column: 1 / 10;
    grid-row: 4 / 6;
    background: transparent;
    border-top: 1px solid var(--grid-seam-bright);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--neon-mint);
    letter-spacing: 0.08em;
    text-shadow: 0 0 6px rgba(0, 255, 209, 0.3);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--neon-mint);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--neon-mint);
    animation: blink 1.6s ease-in-out infinite;
    flex-shrink: 0;
}

.status-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   Floor Three Modules
   ============================================ */
.dashboard-grid-return {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

.return-spacer-1 {
    grid-column: 1 / 13;
    grid-row: 1 / 3;
}

.return-spacer-2 {
    grid-column: 1 / 5;
    grid-row: 3 / 4;
}

.return-module {
    grid-column: 5 / 9;
    grid-row: 3 / 4;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

.return-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2vw, 2rem);
    color: var(--ink);
    letter-spacing: 0.2em;
    filter: blur(4px);
    transition: filter 2s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    text-transform: lowercase;
}

.return-title.focused {
    filter: blur(0px);
}

.return-spacer-3 {
    grid-column: 9 / 13;
    grid-row: 3 / 4;
}

.return-line-container {
    grid-column: 1 / 13;
    grid-row: 4 / 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4rem;
    background: transparent;
}

.return-line {
    width: 0;
    height: 1px;
    background: var(--neon-mint);
    box-shadow: 0 0 8px var(--neon-mint), 0 0 16px var(--neon-mint);
    transition: width 3s ease-out;
}

.return-line.drawn {
    width: 100%;
}

.return-spacer-4 {
    grid-column: 1 / 13;
    grid-row: 5 / 6;
}

.return-footer {
    grid-column: 1 / 13;
    grid-row: 6 / 7;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: transparent;
    padding-bottom: 1.5rem;
}

.return-footer-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--pencil-gray);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ============================================
   Floor indicator (corner label)
   ============================================ */
.floor-indicator {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    pointer-events: none;
}

.floor-indicator-light .floor-num {
    color: var(--ink);
}

.floor-indicator-light .floor-name {
    color: var(--pencil-gray);
}

.floor-indicator-dark .floor-num {
    color: var(--paper-white);
    text-shadow: 0 0 8px rgba(255, 0, 255, 0.5);
}

.floor-indicator-dark .floor-name {
    color: var(--pencil-gray);
}

.floor-num {
    font-size: 1.2rem;
    letter-spacing: 0.1em;
}

.floor-name {
    font-size: 0.65rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

/* ============================================
   Glitch Overlay (Floor Transitions)
   ============================================ */
.glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    background: rgba(255, 255, 0, 0.03);
    transition: opacity 50ms;
}

.glitch-overlay.active {
    opacity: 1;
}

/* Glitch class applied to modules during transitions */
.glitch-shift {
    animation: glitchShift 300ms steps(4) forwards;
}

@keyframes glitchShift {
    0% { transform: translateX(0); }
    25% { transform: translateX(5px); }
    50% { transform: translateX(-3px); }
    75% { transform: translateX(7px); }
    100% { transform: translateX(0); }
}

/* RGB Channel Split effect */
.rgb-split {
    position: relative;
    text-shadow:
        2px 0 rgba(255, 0, 0, 0.7),
        -2px 0 rgba(0, 0, 255, 0.7);
    animation: rgbSplitFlicker 600ms steps(4) forwards;
}

@keyframes rgbSplitFlicker {
    0% {
        text-shadow:
            2px 0 rgba(255, 0, 0, 0.7),
            -2px 0 rgba(0, 0, 255, 0.7);
    }
    50% {
        text-shadow:
            -3px 0 rgba(255, 0, 0, 0.7),
            3px 0 rgba(0, 0, 255, 0.7);
    }
    100% {
        text-shadow: none;
    }
}

/* ============================================
   Scan Lines Container
   ============================================ */
.scan-lines-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.ambient-scan-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    pointer-events: none;
    opacity: 0;
    animation: scanFlash 200ms linear forwards;
}

@keyframes scanFlash {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* ============================================
   Data Mosh Blocks
   ============================================ */
.data-mosh-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 49;
}

.data-mosh-block {
    position: absolute;
    width: 20px;
    height: 20px;
    opacity: 0.3;
    animation: moshCycle 400ms steps(5) infinite;
}

@keyframes moshCycle {
    0% { background: var(--neon-mint); }
    20% { background: var(--glitch-magenta); }
    40% { background: var(--dopamine-pink); }
    60% { background: var(--electric-violet); }
    80% { background: var(--scan-yellow); }
    100% { background: var(--neon-mint); }
}

/* ============================================
   Module shared styles
   ============================================ */
.module {
    position: relative;
    overflow: hidden;
}

.empty-cell,
.empty-cell-dark {
    background: transparent;
    border: none;
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .breath-title {
        animation: none;
        letter-spacing: 0.2em;
    }

    .ticker-track {
        animation: none;
    }

    .scan-line,
    .ambient-scan-line,
    .data-mosh-block {
        display: none;
    }

    .grid-overlay::before {
        animation: none;
        opacity: 0.5;
    }

    .void-pulse,
    .graph-status,
    .status-dot {
        animation: none;
    }

    .waveform-path {
        stroke-dashoffset: 0;
        transition: none;
    }

    .return-title {
        filter: none;
        transition: none;
    }

    .return-line {
        width: 100%;
        transition: none;
    }

    .glitch-shift {
        animation: none;
    }

    html {
        scroll-snap-type: none;
    }
}
