/* ============================================
   diplomacy.day - Swiss Diplomatic Dashboard
   ============================================ */

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

html {
    font-size: 16px;
    scroll-behavior: auto;
}

body {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 15px;
    line-height: 1.65;
    color: #5C4033;
    background-color: #FAF3E8;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Background Wave Texture --- */
#bg-wave-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 18px,
        #D4A574 18px,
        #D4A574 19px
    );
}

/* --- Glitch Overlay --- */
.glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 50ms;
}

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

.glitch-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(199, 91, 57, 0.08) 3px,
        rgba(199, 91, 57, 0.08) 5px
    );
}

.glitch-overlay .glitch-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: #C75B39;
    opacity: 0.7;
}

/* --- Dashboard Layout --- */
.dashboard {
    display: grid;
    grid-template-columns: minmax(200px, 3fr) 6fr 3fr;
    height: 100vh;
    width: 100vw;
    position: relative;
    z-index: 1;
}

/* --- Grid Lines Overlay (visible faint grid) --- */
.dashboard::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    /* Grid lines in #E8C4A0 warm sand at 8% opacity */
    background-image:
        repeating-linear-gradient(
            90deg,
            #E8C4A014 0px,
            #E8C4A014 1px,
            transparent 1px,
            transparent calc(100% / 12)
        );
}

/* --- Left Sidebar --- */
.sidebar-left {
    background-color: #F0E4D0;
    border-right: 1px solid #D4A574;
    display: flex;
    flex-direction: column;
    padding: 48px 16px 24px 16px;
    overflow-y: auto;
    z-index: 2;
}

.sidebar-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #D4A574;
}

.sidebar-label {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8B5E3C;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #D4A574;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-caption {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 11px;
    line-height: 1.4;
    color: #A0845C;
}

/* --- Channel List --- */
.channel-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.channel-item {
    padding: 10px 12px;
    border: 1px solid #D4A574;
    cursor: pointer;
    transition: background-color 100ms, transform 100ms;
    position: relative;
    overflow: hidden;
}

.channel-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #C75B39;
    opacity: 0;
    transition: opacity 100ms;
    pointer-events: none;
}

.channel-item:hover {
    transform: translateX(2px);
}

.channel-item:hover::after {
    opacity: 0.04;
}

.channel-name {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: #5C4033;
    display: block;
    margin-bottom: 4px;
}

.waveform-container {
    width: 100%;
    height: 30px;
}

.waveform-svg {
    width: 100%;
    height: 100%;
}

.waveform-path {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.waveform-path.active {
    stroke: #C75B39;
}

.waveform-path.dormant {
    stroke: #D4A574;
}

/* --- Main Scroll Area --- */
.main-scroll {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    height: 100vh;
    scrollbar-width: none;
    z-index: 2;
}

.main-scroll::-webkit-scrollbar {
    display: none;
}

/* --- Panel (Each viewport section) --- */
.panel {
    scroll-snap-align: start;
    height: 100vh;
    display: grid;
    grid-template-columns: 2fr 1fr;
    position: relative;
}

.panel-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    border-right: 1px solid #D4A574;
    position: relative;
}

.center-content {
    width: 100%;
    max-width: 640px;
}

.panel-right {
    background-color: #F0E4D0;
    padding: 48px 24px;
    overflow-y: auto;
    border-left: none;
}

/* --- Data Labels --- */
.data-label {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 11px;
    line-height: 1.4;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #A0845C;
    display: block;
    margin-bottom: 24px;
}

/* --- Headings --- */
.hero-heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(48px, 8vw, 96px);
    letter-spacing: 0.08em;
    line-height: 1;
    color: #3D2B1F;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.section-heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(36px, 5vw, 64px);
    letter-spacing: 0.08em;
    line-height: 1.1;
    color: #3D2B1F;
    text-transform: uppercase;
    margin-bottom: 24px;
}

/* --- Glitch Text Characters --- */
.glitch-char {
    display: inline-block;
    position: relative;
    transition: transform 50ms;
}

.glitch-char.glitching {
    animation: charGlitch 200ms steps(3) forwards;
}

@keyframes charGlitch {
    0% { transform: translateX(-6px); color: #C75B39; }
    33% { transform: translateX(4px); color: #D4A04A; }
    66% { transform: translateX(-2px); color: #8B5E3C; }
    100% { transform: translateX(0); color: #3D2B1F; }
}

/* --- Hero Content --- */
.hero-content {
    text-align: left;
}

.hero-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 18px;
    line-height: 1.65;
    color: #5C4033;
    max-width: 480px;
    margin-bottom: 32px;
}

.accent-number {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(80px, 10vw, 120px);
    color: #C75B39;
    line-height: 1;
    display: block;
    margin-top: 16px;
    opacity: 0.2;
}

/* --- Body Text --- */
.body-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 15px;
    line-height: 1.65;
    color: #5C4033;
    max-width: 480px;
    margin-top: 24px;
}

/* --- Wave Divider --- */
.wave-divider {
    width: 100%;
    height: 40px;
    margin-bottom: 24px;
}

.wave-divider-svg {
    width: 100%;
    height: 100%;
}

.wave-divider-path {
    fill: none;
    stroke: #D4A574;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.wave-peak {
    fill: #C75B39;
    animation: wavePeakPulse 2s ease-in-out infinite;
}

@keyframes wavePeakPulse {
    0%, 100% { transform-origin: center; r: 3; opacity: 1; }
    50% { r: 4.2; opacity: 0.7; }
}

/* Using scale transform for better browser compat */
.wave-peak {
    animation: wavePeakScale 2s ease-in-out infinite;
}

@keyframes wavePeakScale {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
}

/* --- Topology Map --- */
.topology-map {
    width: 100%;
    max-width: 600px;
    margin: 16px 0;
}

.topology-map svg {
    width: 100%;
    height: auto;
}

.topology-node {
    transition: r 200ms, fill 200ms;
}

.topology-node.pulse {
    animation: nodePulse 2s ease-in-out infinite;
}

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

.topology-connection {
    fill: none;
    stroke: #D4A574;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.topology-connection.active {
    stroke: #C75B39;
    animation: connectionDraw 2s ease-out forwards;
}

@keyframes connectionDraw {
    from { stroke-dashoffset: 500; }
    to { stroke-dashoffset: 0; }
}

.topology-label {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 9px;
    fill: #A0845C;
    text-anchor: middle;
}

/* --- Treaty Diagram --- */
.treaty-diagram {
    width: 100%;
    max-width: 600px;
    margin: 16px 0;
}

.treaty-diagram svg {
    width: 100%;
    height: auto;
}

.treaty-layer {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.treaty-clause {
    stroke: #D4A574;
    stroke-width: 1;
}

.treaty-signatory {
    fill: #C75B39;
}

.treaty-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 9px;
    fill: #A0845C;
}

/* --- Timeline Visualization --- */
.timeline-visualization {
    width: 100%;
    max-width: 600px;
    margin: 16px 0;
}

.timeline-visualization svg {
    width: 100%;
    height: auto;
}

.timeline-wave {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.timeline-marker {
    fill: #D4A04A;
}

.timeline-label {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 9px;
    fill: #A0845C;
}

.timeline-axis {
    stroke: #D4A574;
    stroke-width: 1;
}

/* --- Handshake Motif --- */
.handshake-motif {
    width: 300px;
    max-width: 100%;
    margin: 0 0 32px 0;
}

.handshake-motif svg {
    width: 100%;
    height: auto;
}

.handshake-line {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hand-left {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.hand-right {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.interlock {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.handshake-line.drawn {
    transition: stroke-dashoffset 1.2s ease-out;
    stroke-dashoffset: 0;
}

/* --- Dispatch Feed (Right Sidebar) --- */
.dispatch-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

.feed-label {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8B5E3C;
    padding-bottom: 12px;
    border-bottom: 1px solid #D4A574;
}

.dispatch-item {
    padding: 12px 0;
    border-bottom: 1px solid #D4A574;
    transition: background-color 100ms, transform 100ms;
    position: relative;
    overflow: hidden;
}

.dispatch-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: #C75B39;
    opacity: 0;
    transition: opacity 200ms;
}

.dispatch-item:hover::before {
    opacity: 1;
}

.dispatch-item:hover {
    padding-left: 12px;
}

.dispatch-time {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: #8B5E3C;
    display: block;
    margin-bottom: 4px;
}

.dispatch-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 13px;
    line-height: 1.5;
    color: #5C4033;
}

/* --- Panel-specific Backgrounds --- */
.panel-1 .panel-center {
    background: linear-gradient(180deg, #FAF3E8 0%, rgba(250, 243, 232, 0.95) 100%);
}

.panel-2 .panel-center,
.panel-3 .panel-center {
    background-color: #FAF3E8;
}

.panel-4 .panel-center {
    background-color: #FAF3E8;
}

.panel-5 .panel-center {
    background: linear-gradient(180deg, #FAF3E8 0%, rgba(240, 228, 208, 0.4) 100%);
}

/* --- Glitch Transition Effect on Panels --- */
.panel.glitch-active .panel-center {
    animation: panelGlitch 400ms steps(4) forwards;
}

@keyframes panelGlitch {
    0% { transform: translateX(0); filter: none; }
    25% { transform: translateX(48px); filter: hue-rotate(10deg); }
    50% { transform: translateX(-96px); background-color: #2A1810; }
    75% { transform: translateX(24px); filter: none; }
    100% { transform: translateX(0); filter: none; background-color: transparent; }
}

.panel.glitch-active .panel-right {
    animation: panelGlitchRight 400ms steps(4) forwards;
}

@keyframes panelGlitchRight {
    0% { transform: translateX(0); }
    25% { transform: translateX(-24px); }
    50% { transform: translateX(48px); }
    75% { transform: translateX(-12px); }
    100% { transform: translateX(0); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: 180px 1fr;
    }

    .panel {
        grid-template-columns: 1fr;
    }

    .panel-right {
        display: none;
    }

    .panel-center {
        border-right: none;
    }
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .sidebar-left {
        display: none;
    }

    .panel-center {
        padding: 32px 24px;
    }

    .hero-heading {
        font-size: 48px;
    }

    .section-heading {
        font-size: 36px;
    }
}
