/* ===========================================
   mujun.xyz - Contradiction Command Center
   Palette:
     Signal purple:    #6B2FA0
     Electric gold:    #F0C830
     Dopamine magenta: #E83880
     Bubble aqua:      #40D8E8
     Cream base:       #FAF5E0
     Deep violet:      #1A0830
     Retro orange:     #E87830
   Fonts:
     Commissioner (variable: wdth 75-125, wght 100-900)
     Share Tech Mono
   =========================================== */

@property --needle-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

@property --font-width {
    syntax: '<number>';
    inherits: true;
    initial-value: 75;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 100;
    font-weight: 400;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.7;
    background: #1A0830;
    color: #FAF5E0;
    overflow-x: hidden;
}

/* ---- Typography ---- */
.domain-title {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 125;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 56px);
    letter-spacing: -0.01em;
    color: #F0C830;
    text-align: center;
}

.panel-label,
.widget-label,
.meter-label,
.readout-label {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 75;
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #40D8E8;
}

.gauge-readout,
.status-readout,
.readout-value,
.wg-value,
.mono {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: #F0C830;
}

.section-title {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 125;
    font-weight: 700;
    font-size: clamp(22px, 3vw, 42px);
    letter-spacing: -0.01em;
    color: #F0C830;
    text-align: center;
    margin-bottom: 40px;
}

/* ---- COMMAND CENTER ---- */
#command-center {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: #1A0830;
    overflow: hidden;
}

.command-header {
    text-align: center;
    margin-bottom: 48px;
    z-index: 2;
}

.command-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 75;
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #40D8E8;
    margin-top: 8px;
}

/* Instrument Grid */
.instrument-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 900px;
    z-index: 2;
}

.instrument-panel {
    background: rgba(107, 47, 160, 0.15);
    border: 1px solid rgba(107, 47, 160, 0.4);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    opacity: 0;
    transform: scale(0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.instrument-panel.visible {
    opacity: 1;
    transform: scale(1);
    animation: bounceIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.instrument-panel:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 32px rgba(107, 47, 160, 0.4);
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.8); }
    60% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* Gauge SVGs */
.gauge {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 16px auto;
}

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

.gauge-track {
    fill: none;
    stroke: rgba(107, 47, 160, 0.3);
    stroke-width: 8;
}

.gauge-fill {
    fill: none;
    stroke: #F0C830;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 314;
    stroke-dashoffset: 314;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1.2s ease-out;
}

.gauge-needle {
    stroke: #E83880;
    stroke-width: 2;
    stroke-linecap: round;
    transform-origin: 60px 60px;
    transform: rotate(0deg);
    transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gauge-needle:hover {
    animation: wobble 0.4s ease-in-out;
}

@keyframes wobble {
    0%, 100% { transform: rotate(var(--current-angle, 0deg)); }
    25% { transform: rotate(calc(var(--current-angle, 0deg) + 3deg)); }
    75% { transform: rotate(calc(var(--current-angle, 0deg) - 3deg)); }
}

.gauge-center {
    fill: #E83880;
}

.gauge-readout {
    font-size: 24px;
    margin-top: 8px;
}

/* Status Panel */
.status-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.status-lights {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.status-light {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.light-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(250, 245, 224, 0.2);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.status-light[data-color="magenta"] .light-dot {
    background: rgba(232, 56, 128, 0.3);
}
.status-light[data-color="gold"] .light-dot {
    background: rgba(240, 200, 48, 0.3);
}
.status-light[data-color="aqua"] .light-dot {
    background: rgba(64, 216, 232, 0.3);
}

.status-light.active[data-color="magenta"] .light-dot {
    background: #E83880;
    box-shadow: 0 0 12px #E83880, 0 0 24px rgba(232, 56, 128, 0.4);
}
.status-light.active[data-color="gold"] .light-dot {
    background: #F0C830;
    box-shadow: 0 0 12px #F0C830, 0 0 24px rgba(240, 200, 48, 0.4);
}
.status-light.active[data-color="aqua"] .light-dot {
    background: #40D8E8;
    box-shadow: 0 0 12px #40D8E8, 0 0 24px rgba(64, 216, 232, 0.4);
}

.light-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.05em;
    color: #FAF5E0;
    opacity: 0.6;
}

.status-light.active .light-label {
    opacity: 1;
}

.status-readout {
    font-size: 18px;
    color: #F0C830;
    letter-spacing: 0.04em;
}

/* Mini Bar Gauges */
.mini-bar {
    width: 100%;
    height: 8px;
    background: rgba(107, 47, 160, 0.3);
    border-radius: 4px;
    margin: 16px 0 8px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6B2FA0, #E83880);
    border-radius: 4px;
    transition: width 1.2s ease-out;
}

/* ---- CONTRADICTION DASHBOARD ---- */
#contradiction-dashboard {
    position: relative;
    padding: 80px 20px;
    background: #1A0830;
    overflow: hidden;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Widget sizes */
.widget-2x1 {
    grid-column: span 2;
}

.widget-1x2 {
    grid-row: span 2;
}

/* Widget base */
.widget {
    perspective: 1000px;
    cursor: pointer;
    min-height: 200px;
}

.widget-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 200px;
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
}

.widget.flipped .widget-inner {
    transform: rotateY(180deg);
}

.widget-front,
.widget-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.widget-front {
    background: rgba(107, 47, 160, 0.2);
    border: 1px solid rgba(107, 47, 160, 0.4);
}

.widget-back {
    background: #F0C830;
    color: #1A0830;
    transform: rotateY(180deg);
    border: 1px solid rgba(240, 200, 48, 0.6);
}

.widget-back .widget-label {
    color: #6B2FA0;
}

.widget-back .widget-text {
    color: #1A0830;
}

.widget:hover .widget-inner {
    box-shadow: 0 8px 32px rgba(107, 47, 160, 0.3);
}

.widget:hover .widget-front {
    transform: scale(1.01);
}

.widget-title {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 110;
    font-weight: 600;
    font-size: 18px;
    color: #F0C830;
}

.widget-text {
    font-size: clamp(13px, 1vw, 15px);
    line-height: 1.6;
    color: #FAF5E0;
    opacity: 0.9;
}

/* Widget gauge */
.widget-gauge {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 8px auto;
}

.widget-gauge-svg {
    width: 100%;
    height: 100%;
}

.wg-track {
    fill: none;
    stroke: rgba(107, 47, 160, 0.3);
    stroke-width: 6;
}

.wg-fill {
    fill: none;
    stroke: #E87830;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 251;
    stroke-dashoffset: 251;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1.2s ease-out;
}

.wg-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    color: #E87830;
}

/* Meter Bars */
.widget-meter {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meter-bar {
    width: 100%;
    height: 6px;
    background: rgba(250, 245, 224, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: var(--fill, 50%);
    background: linear-gradient(90deg, #E87830, #F0C830);
    border-radius: 3px;
    transition: width 0.8s ease-out;
}

/* Retro Patterns */
.pattern-zigzag .widget-front::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 10px,
        rgba(240, 200, 48, 0.08) 10px,
        rgba(240, 200, 48, 0.08) 12px
    );
    border-radius: 12px;
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.pattern-dots .widget-front::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle 2px at 12px 12px, rgba(232, 56, 128, 0.1) 100%, transparent 100%);
    background-size: 24px 24px;
    border-radius: 12px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.pattern-chevron .widget-front::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        60deg,
        transparent,
        transparent 14px,
        rgba(64, 216, 232, 0.07) 14px,
        rgba(64, 216, 232, 0.07) 16px
    ),
    repeating-linear-gradient(
        -60deg,
        transparent,
        transparent 14px,
        rgba(64, 216, 232, 0.07) 14px,
        rgba(64, 216, 232, 0.07) 16px
    );
    border-radius: 12px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.pattern-memphis .widget-front::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle 3px at 20px 20px, rgba(232, 120, 48, 0.1) 100%, transparent 100%),
        radial-gradient(circle 2px at 50px 35px, rgba(240, 200, 48, 0.08) 100%, transparent 100%),
        linear-gradient(45deg, transparent 48%, rgba(232, 56, 128, 0.06) 48%, rgba(232, 56, 128, 0.06) 52%, transparent 52%);
    background-size: 60px 60px;
    border-radius: 12px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.widget:hover .widget-front::before {
    opacity: 2;
}

/* Scroll-reveal flip for dashboard widgets */
.widget {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.widget.in-view {
    opacity: 1;
}

/* ---- FLIP ARCHIVE ---- */
#flip-archive {
    padding: 80px 20px;
    background: linear-gradient(180deg, #1A0830 0%, #2A1048 100%);
    overflow: hidden;
}

.archive-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 20px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #6B2FA0 #1A0830;
}

.archive-scroll::-webkit-scrollbar {
    height: 6px;
}

.archive-scroll::-webkit-scrollbar-track {
    background: #1A0830;
}

.archive-scroll::-webkit-scrollbar-thumb {
    background: #6B2FA0;
    border-radius: 3px;
}

.archive-card {
    flex: 0 0 280px;
    height: 360px;
    perspective: 1000px;
    cursor: pointer;
    scroll-snap-align: start;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.archive-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
}

.card-front {
    background: #6B2FA0;
    color: #F0C830;
    border: 1px solid rgba(240, 200, 48, 0.3);
}

.card-back {
    background: #F0C830;
    color: #6B2FA0;
    transform: rotateY(180deg);
    border: 1px solid rgba(107, 47, 160, 0.3);
}

.card-number {
    font-family: 'Share Tech Mono', monospace;
    font-size: 36px;
    opacity: 0.4;
}

.card-front h3 {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 120;
    font-weight: 700;
    font-size: 22px;
}

.card-front p {
    font-size: 14px;
    opacity: 0.8;
    line-height: 1.5;
}

.card-back p {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 100;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.7;
}

.archive-card:hover .card-inner {
    box-shadow: 0 12px 40px rgba(107, 47, 160, 0.4);
}

/* ---- CELEBRATION FOOTER ---- */
#celebration-footer {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1A0830;
    overflow: hidden;
}

.celebration-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.celebration-title {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 125;
    font-weight: 700;
    font-size: clamp(32px, 6vw, 72px);
    color: #F0C830;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
    text-shadow: 0 0 40px rgba(240, 200, 48, 0.3);
}

.celebration-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-variation-settings: 'wdth' 100;
    font-weight: 400;
    font-size: clamp(14px, 1.5vw, 18px);
    color: #FAF5E0;
    max-width: 600px;
    margin: 0 auto 40px;
    line-height: 1.7;
    opacity: 0.85;
}

.celebration-readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.readout-value {
    font-size: 64px;
    color: #E83880;
    text-shadow: 0 0 20px rgba(232, 56, 128, 0.5);
}

/* ---- WATER BUBBLES ---- */
.bubble-field {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(64, 216, 232, 0.4), rgba(64, 216, 232, 0.1));
    pointer-events: none;
    transition: transform 0.3s ease;
}

.bubble::after {
    content: '';
    position: absolute;
    top: 20%;
    left: 25%;
    width: 30%;
    height: 25%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.6), transparent);
    border-radius: 50%;
}

.bubble-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 7px;
    color: rgba(250, 245, 224, 0.7);
    white-space: nowrap;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(100%) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-120%) translateX(var(--drift, 20px));
        opacity: 0;
    }
}

/* ---- CONFETTI ---- */
.confetti-field {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    opacity: 0;
}

.confetti.square {
    border-radius: 1px;
}

.confetti.circle {
    border-radius: 50%;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg) scale(0.5);
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .instrument-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .widget-2x1 {
        grid-column: span 1;
    }

    .widget-1x2 {
        grid-row: span 1;
    }

    .archive-card {
        flex: 0 0 240px;
        height: 320px;
    }

    .readout-value {
        font-size: 48px;
    }
}

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

    .archive-card {
        flex: 0 0 220px;
        height: 300px;
    }
}
