/* ==========================================================
   MasqueradeProtocol.com - Cyberpunk Data-Viz Dashboard
   Colors: #0A0A0F, #00FFC8, #FFD700, #C41E3A, #1A1A2E,
           #3A3A5C, #E8E8F0, #7B2FBE, #1B998B
   Fonts: Share Tech Mono, Cinzel Decorative, Rajdhani, Overpass Mono
   ========================================================== */

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

html, body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #0A0A0F;
    color: #E8E8F0;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 300;
    cursor: none;
}

/* --- Custom Cursor --- */
#custom-cursor {
    position: fixed;
    width: 16px;
    height: 16px;
    pointer-events: none;
    z-index: 10000;
    mix-blend-mode: screen;
    transition: width 0.2s ease, height 0.2s ease;
    transform: translate(-50%, -50%);
}

#custom-cursor.expanded {
    width: 24px;
    height: 24px;
}

#custom-cursor .cursor-h,
#custom-cursor .cursor-v {
    position: absolute;
    background: #00FFC8;
}

#custom-cursor .cursor-h {
    width: 100%;
    height: 1px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

#custom-cursor .cursor-v {
    width: 1px;
    height: 100%;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

/* --- Outer Ring - Cipher Scroll --- */
#outer-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.cipher-band {
    position: absolute;
    background: #0A0A0F;
    overflow: hidden;
    font-family: 'Overpass Mono', monospace;
    font-size: 10px;
    color: #1B998B;
    letter-spacing: 0.05em;
    white-space: nowrap;
    opacity: 0.7;
}

.cipher-horizontal {
    height: 28px;
    left: 0;
    width: 100%;
    line-height: 28px;
    border-bottom: 1px solid #1A1A2E;
}

#cipher-top {
    top: 0;
    border-bottom: 1px solid #1A1A2E;
}

#cipher-bottom {
    bottom: 0;
    top: auto;
    border-top: 1px solid #1A1A2E;
    border-bottom: none;
}

.cipher-vertical {
    width: 28px;
    top: 28px;
    height: calc(100% - 56px);
    writing-mode: vertical-rl;
    line-height: 28px;
    text-orientation: mixed;
    border-right: 1px solid #1A1A2E;
}

#cipher-left {
    left: 0;
    border-right: 1px solid #1A1A2E;
}

#cipher-right {
    right: 0;
    left: auto;
    border-left: 1px solid #1A1A2E;
    border-right: none;
}

/* --- Corner Sigils --- */
.corner-sigil {
    position: fixed;
    width: 80px;
    height: 80px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: none;
    transition: transform 0.3s ease;
}

.corner-sigil .sigil-svg {
    width: 50px;
    height: 50px;
    color: #00FFC8;
    filter: drop-shadow(0 0 6px rgba(0, 255, 200, 0.3));
    transition: color 0.4s ease, filter 0.4s ease, transform 0.3s ease;
}

.corner-sigil .sigil-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.12em;
    color: #3A3A5C;
    margin-top: 4px;
    text-transform: uppercase;
    transition: color 0.4s ease;
}

.corner-sigil:hover .sigil-label {
    color: #00FFC8;
}

.corner-sigil:hover .sigil-svg {
    filter: drop-shadow(0 0 12px rgba(0, 255, 200, 0.6));
    transform: scale(1.1);
}

.corner-sigil.active .sigil-svg {
    color: #FFD700;
    filter: drop-shadow(0 0 14px rgba(255, 215, 0, 0.5));
}

.corner-sigil.active .sigil-label {
    color: #FFD700;
}

#sigil-intercept {
    top: 32px;
    left: 32px;
    animation: sigil-pulse 3s ease-in-out infinite;
}

#sigil-decrypt {
    top: 32px;
    right: 32px;
    animation: sigil-pulse 3s ease-in-out 0.75s infinite;
}

#sigil-analyze {
    bottom: 32px;
    left: 32px;
    animation: sigil-pulse 3s ease-in-out 1.5s infinite;
}

#sigil-masque {
    bottom: 32px;
    right: 32px;
    animation: sigil-pulse 3s ease-in-out 2.25s infinite;
}

@keyframes sigil-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1.0; }
}

/* --- Dashboard Container --- */
#dashboard {
    position: fixed;
    top: 28px;
    left: 28px;
    width: calc(100% - 56px);
    height: calc(100% - 56px);
    overflow: hidden;
}

/* --- Background Canvases --- */
#particle-canvas,
#hex-rain-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#particle-canvas {
    z-index: 2;
}

#hex-rain-canvas {
    z-index: 1;
}

/* --- Circuit Filigree Background --- */
#circuit-filigree-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M10,60 Q30,30 60,40 T110,60' fill='none' stroke='%2300FFC8' stroke-width='0.5'/%3E%3Cpath d='M60,10 Q80,30 70,60 T60,110' fill='none' stroke='%2300FFC8' stroke-width='0.5'/%3E%3Ccircle cx='60' cy='40' r='2' fill='%2300FFC8'/%3E%3Ccircle cx='60' cy='60' r='2' fill='%2300FFC8'/%3E%3Ccircle cx='30' cy='45' r='1.5' fill='%2300FFC8'/%3E%3Ccircle cx='90' cy='55' r='1.5' fill='%2300FFC8'/%3E%3Ccircle cx='60' cy='80' r='1.5' fill='%2300FFC8'/%3E%3Cpath d='M30,45 L40,50' fill='none' stroke='%2300FFC8' stroke-width='0.3'/%3E%3Cpath d='M80,50 L90,55' fill='none' stroke='%2300FFC8' stroke-width='0.3'/%3E%3Cpath d='M10,90 C30,80 50,100 70,85 S100,95 110,90' fill='none' stroke='%2300FFC8' stroke-width='0.4'/%3E%3Ccircle cx='35' cy='88' r='1.2' fill='%2300FFC8'/%3E%3Ccircle cx='85' cy='92' r='1.2' fill='%2300FFC8'/%3E%3Cpath d='M20,15 Q40,5 50,20 T80,15' fill='none' stroke='%2300FFC8' stroke-width='0.3'/%3E%3Ccircle cx='50' cy='15' r='1' fill='%2300FFC8'/%3E%3C/svg%3E");
    background-size: 120px 120px;
}

/* --- The Eye (Central Mask) --- */
#the-eye {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40vmin;
    height: 40vmin;
    max-width: 400px;
    max-height: 400px;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mask-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

#masquerade-mask {
    width: 85%;
    height: auto;
    animation: mask-breathe 4s ease-in-out infinite, mask-sway 7s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(0, 255, 200, 0.15));
}

#mask-outline {
    animation: mask-draw 8s linear infinite;
}

@keyframes mask-breathe {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.02); }
}

@keyframes mask-sway {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(0.5deg); }
    75% { transform: rotate(-0.5deg); }
}

@keyframes mask-draw {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -100; }
}

#mask-title {
    margin-top: 8px;
    text-align: center;
}

.mask-title-text {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.15em;
    color: #FFD700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

#mode-indicator {
    margin-top: 6px;
    text-align: center;
}

.mode-prefix {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.1em;
    color: #3A3A5C;
}

.mode-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #00FFC8;
    text-shadow: 0 0 8px rgba(0, 255, 200, 0.4);
}

/* --- Concentric Rings --- */
#concentric-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70vmin;
    height: 70vmin;
    max-width: 700px;
    max-height: 700px;
    transform: translate(-50%, -50%);
    z-index: 5;
    pointer-events: none;
    animation: rings-rotate 60s linear infinite;
}

@keyframes rings-rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* --- Data Panels (Trapezoidal Compass Rose) --- */
.data-panel {
    position: absolute;
    z-index: 15;
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid #00FFC8;
    box-shadow: 0 0 12px rgba(0, 255, 200, 0.08), inset 0 0 20px rgba(0, 255, 200, 0.02);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

.data-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(0, 255, 200, 0.15);
}

.data-panel .panel-id {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #E8E8F0;
    text-transform: uppercase;
}

.data-panel .panel-status {
    font-family: 'Overpass Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.06em;
    color: #1B998B;
}

.data-panel .panel-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    min-height: 0;
}

.data-panel .panel-viz {
    width: 100%;
    height: 100%;
}

.data-panel .panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    border-top: 1px solid rgba(0, 255, 200, 0.1);
}

.data-panel .data-label {
    font-family: 'Overpass Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.06em;
    color: #3A3A5C;
    text-transform: uppercase;
}

.data-panel .data-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #00FFC8;
    text-shadow: 0 0 6px rgba(0, 255, 200, 0.3);
}

/* North Panel */
#panel-north {
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    height: 150px;
    clip-path: polygon(10% 0%, 90% 0%, 100% 100%, 0% 100%);
}

/* East Panel */
#panel-east {
    top: 50%;
    right: 5%;
    transform: translateY(-50%);
    width: 200px;
    height: 160px;
    clip-path: polygon(0% 0%, 100% 10%, 100% 90%, 0% 100%);
}

/* South Panel */
#panel-south {
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    height: 150px;
    clip-path: polygon(0% 0%, 100% 0%, 90% 100%, 10% 100%);
}

/* West Panel */
#panel-west {
    top: 50%;
    left: 5%;
    transform: translateY(-50%);
    width: 200px;
    height: 160px;
    clip-path: polygon(0% 10%, 100% 0%, 100% 100%, 0% 90%);
}

/* Panel scramble/glitch effect */
.data-panel.scrambling .panel-content {
    animation: panel-glitch 0.2s steps(3) forwards;
}

@keyframes panel-glitch {
    0% { opacity: 1; filter: none; }
    33% { opacity: 0.7; filter: hue-rotate(90deg) brightness(1.5); }
    66% { opacity: 0.4; filter: hue-rotate(180deg) brightness(0.5); }
    100% { opacity: 1; filter: none; }
}

/* State transition: full scramble */
.data-panel.state-transition .panel-content {
    animation: state-scramble 0.4s steps(5) forwards;
}

@keyframes state-scramble {
    0% { opacity: 1; filter: none; transform: none; }
    20% { opacity: 0.5; filter: hue-rotate(60deg); transform: skewX(2deg); }
    40% { opacity: 0.8; filter: hue-rotate(120deg) brightness(1.3); transform: skewX(-1deg); }
    60% { opacity: 0.3; filter: hue-rotate(200deg) brightness(0.7); transform: skewX(3deg); }
    80% { opacity: 0.6; filter: hue-rotate(300deg); transform: skewX(-2deg); }
    100% { opacity: 1; filter: none; transform: none; }
}

/* --- Data Overlays / Readouts --- */
#data-overlays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

.data-readout {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.data-readout .readout-label {
    font-family: 'Overpass Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.1em;
    color: #3A3A5C;
    text-transform: uppercase;
}

.data-readout .readout-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    letter-spacing: 0.08em;
    color: #E8E8F0;
}

#readout-tl {
    top: 15%;
    left: 12%;
}

#readout-tr {
    top: 15%;
    right: 12%;
    text-align: right;
}

#readout-bl {
    bottom: 15%;
    left: 12%;
}

#readout-br {
    bottom: 15%;
    right: 12%;
    text-align: right;
}

/* --- Mode-specific accent color overrides --- */
body[data-mode="INTERCEPT"] .data-panel {
    border-color: #C41E3A;
    box-shadow: 0 0 12px rgba(196, 30, 58, 0.12), inset 0 0 20px rgba(196, 30, 58, 0.03);
}
body[data-mode="INTERCEPT"] .data-panel .data-value,
body[data-mode="INTERCEPT"] .mode-value {
    color: #C41E3A;
    text-shadow: 0 0 8px rgba(196, 30, 58, 0.4);
}
body[data-mode="INTERCEPT"] .corner-sigil .sigil-svg {
    color: #C41E3A;
    filter: drop-shadow(0 0 6px rgba(196, 30, 58, 0.3));
}
body[data-mode="INTERCEPT"] #mask-outline {
    stroke: #C41E3A;
}
body[data-mode="INTERCEPT"] .readout-value {
    color: #C41E3A;
}

body[data-mode="DECRYPT"] .data-panel {
    border-color: #FFD700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.12), inset 0 0 20px rgba(255, 215, 0, 0.03);
}
body[data-mode="DECRYPT"] .data-panel .data-value,
body[data-mode="DECRYPT"] .mode-value {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}
body[data-mode="DECRYPT"] .corner-sigil .sigil-svg {
    color: #FFD700;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.3));
}
body[data-mode="DECRYPT"] #mask-outline {
    stroke: #FFD700;
}
body[data-mode="DECRYPT"] .readout-value {
    color: #FFD700;
}

body[data-mode="ANALYZE"] .data-panel {
    border-color: #00FFC8;
    box-shadow: 0 0 12px rgba(0, 255, 200, 0.08), inset 0 0 20px rgba(0, 255, 200, 0.02);
}
body[data-mode="ANALYZE"] .data-panel .data-value,
body[data-mode="ANALYZE"] .mode-value {
    color: #00FFC8;
    text-shadow: 0 0 8px rgba(0, 255, 200, 0.4);
}
body[data-mode="ANALYZE"] .corner-sigil .sigil-svg {
    color: #00FFC8;
    filter: drop-shadow(0 0 6px rgba(0, 255, 200, 0.3));
}
body[data-mode="ANALYZE"] #mask-outline {
    stroke: #00FFC8;
}

body[data-mode="MASQUE"] .data-panel {
    border-color: #7B2FBE;
    box-shadow: 0 0 12px rgba(123, 47, 190, 0.12), inset 0 0 20px rgba(123, 47, 190, 0.03);
}
body[data-mode="MASQUE"] .data-panel .data-value,
body[data-mode="MASQUE"] .mode-value {
    color: #7B2FBE;
    text-shadow: 0 0 8px rgba(123, 47, 190, 0.4);
}
body[data-mode="MASQUE"] .corner-sigil .sigil-svg {
    color: #7B2FBE;
    filter: drop-shadow(0 0 6px rgba(123, 47, 190, 0.3));
}
body[data-mode="MASQUE"] #mask-outline {
    stroke: #7B2FBE;
}
body[data-mode="MASQUE"] .readout-value {
    color: #7B2FBE;
}

/* Active sigil highlight */
body[data-mode="INTERCEPT"] #sigil-intercept .sigil-svg,
body[data-mode="DECRYPT"] #sigil-decrypt .sigil-svg,
body[data-mode="ANALYZE"] #sigil-analyze .sigil-svg,
body[data-mode="MASQUE"] #sigil-masque .sigil-svg {
    transform: scale(1.15);
}

body[data-mode="INTERCEPT"] #sigil-intercept .sigil-label,
body[data-mode="DECRYPT"] #sigil-decrypt .sigil-label,
body[data-mode="ANALYZE"] #sigil-analyze .sigil-label,
body[data-mode="MASQUE"] #sigil-masque .sigil-label {
    color: #E8E8F0;
}

/* --- SVG bar/element accent color transitions --- */
.data-panel .bar,
.data-panel .hex-cell,
.data-panel .node,
.data-panel .waveform-line,
.data-panel line {
    transition: fill 0.6s ease, stroke 0.6s ease;
}

body[data-mode="INTERCEPT"] .data-panel .bar { fill: #C41E3A; }
body[data-mode="INTERCEPT"] .data-panel .hex-cell { fill: #C41E3A; }
body[data-mode="INTERCEPT"] .data-panel .node { fill: #C41E3A; }
body[data-mode="INTERCEPT"] .data-panel .waveform-line { stroke: #C41E3A; }
body[data-mode="INTERCEPT"] .data-panel .graph-edges line { stroke: #C41E3A; }

body[data-mode="DECRYPT"] .data-panel .bar { fill: #FFD700; }
body[data-mode="DECRYPT"] .data-panel .hex-cell { fill: #FFD700; }
body[data-mode="DECRYPT"] .data-panel .node { fill: #FFD700; }
body[data-mode="DECRYPT"] .data-panel .waveform-line { stroke: #FFD700; }
body[data-mode="DECRYPT"] .data-panel .graph-edges line { stroke: #FFD700; }

body[data-mode="MASQUE"] .data-panel .bar { fill: #7B2FBE; }
body[data-mode="MASQUE"] .data-panel .hex-cell { fill: #7B2FBE; }
body[data-mode="MASQUE"] .data-panel .node { fill: #7B2FBE; }
body[data-mode="MASQUE"] .data-panel .waveform-line { stroke: #7B2FBE; }
body[data-mode="MASQUE"] .data-panel .graph-edges line { stroke: #7B2FBE; }

/* --- Mask rotation on state change --- */
#masquerade-mask.rotate-to-tl {
    animation: mask-breathe 4s ease-in-out infinite, rotate-tl 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
#masquerade-mask.rotate-to-tr {
    animation: mask-breathe 4s ease-in-out infinite, rotate-tr 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
#masquerade-mask.rotate-to-bl {
    animation: mask-breathe 4s ease-in-out infinite, rotate-bl 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
#masquerade-mask.rotate-to-br {
    animation: mask-breathe 4s ease-in-out infinite, rotate-br 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
#masquerade-mask.rotate-reset {
    animation: mask-breathe 4s ease-in-out infinite, mask-sway 7s ease-in-out infinite;
}

@keyframes rotate-tl { to { transform: rotate(-15deg) scale(1.0); } }
@keyframes rotate-tr { to { transform: rotate(15deg) scale(1.0); } }
@keyframes rotate-bl { to { transform: rotate(-15deg) scale(1.0); } }
@keyframes rotate-br { to { transform: rotate(15deg) scale(1.0); } }

/* --- Responsive adjustments --- */
@media (max-width: 900px) {
    #panel-north, #panel-south {
        width: 180px;
        height: 120px;
    }
    #panel-east, #panel-west {
        width: 160px;
        height: 130px;
    }
    .mask-title-text {
        font-size: 14px;
    }
    .corner-sigil {
        width: 60px;
        height: 60px;
    }
    .corner-sigil .sigil-svg {
        width: 36px;
        height: 36px;
    }
    .corner-sigil .sigil-label {
        font-size: 6px;
    }
}

@media (max-width: 600px) {
    #panel-north, #panel-south {
        width: 140px;
        height: 100px;
    }
    #panel-east, #panel-west {
        width: 120px;
        height: 110px;
    }
    #the-eye {
        width: 50vmin;
        height: 50vmin;
    }
    .mask-title-text {
        font-size: 12px;
    }
    .data-readout {
        display: none;
    }
}
