/* ============================================
   doublestandard.xyz - Coastal Instrument Panel
   Skeuomorphic maritime navigation interface
   ============================================ */

/* --- CSS Variables / Palette (Coastal Blend) --- */
:root {
    /* Primary Deep */
    --midnight-hull: #1B2838;
    /* Secondary Deep */
    --slate-sea: #2A3F52;
    /* Mid Tone */
    --weathered-zinc: #6B7B8D;
    /* Light Surface */
    --fog-bank: #C8D8DC;
    /* Warm Accent */
    --compass-brass: #E8C47C;
    /* Warm Secondary */
    --coral-horizon: #D4836A;
    /* Cool Accent */
    --tide-pool: #4A7B8C;
    /* Background Wood */
    --teak-deck: #3D2B1F;
    --teak-mid: #4A3728;
    --teak-dark: #2E1F15;
    /* Alert / Error */
    --storm-warning: #C44B3F;
    /* Subtle Glow */
    --bioluminescence: #5AACA8;
    /* Brass tones */
    --brass-dark: #8B6914;
    --brass-mid: #C4A04A;
    /* Metal tones */
    --metal-light: #6B7B8D;
    --metal-dark: #5A6A78;
    /* Secondary label color */
    --secondary-label: #8FA5B0;

    /* Spring easing tokens */
    --spring-overshoot: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-damped: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--midnight-hull);
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    color: var(--fog-bank);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Particle Canvas (z-0 background layer) --- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* --- Teak Wood Background (z-0) --- */
#teak-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.6s ease;
    /* CSS-only woodgrain from layered linear-gradients at slight angles */
    background:
        linear-gradient(2deg,
            rgba(61, 43, 31, 0.7) 0%,
            rgba(74, 55, 40, 0.5) 30%,
            rgba(46, 31, 21, 0.6) 60%,
            rgba(61, 43, 31, 0.7) 100%
        ),
        linear-gradient(3deg,
            transparent 0%,
            rgba(74, 55, 40, 0.3) 25%,
            transparent 50%,
            rgba(46, 31, 21, 0.2) 75%,
            transparent 100%
        ),
        linear-gradient(5deg,
            rgba(61, 43, 31, 0.4) 0%,
            transparent 20%,
            rgba(74, 55, 40, 0.3) 40%,
            transparent 60%,
            rgba(46, 31, 21, 0.4) 80%,
            transparent 100%
        );
    background-size: 100% 100%, 200px 100%, 150px 100%;
    background-color: var(--teak-deck);
}

/* Wood grain noise overlay (2x2 SVG data-URI at 3% opacity) */
#teak-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Crect width='1' height='1' fill='%23000' fill-opacity='0.06'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23000' fill-opacity='0.06'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0.03;
    pointer-events: none;
}

/* Atmospheric Gradient Overlay - horizontal directional light simulation */
#teak-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--midnight-hull), var(--slate-sea), var(--tide-pool));
    opacity: 0.6;
    pointer-events: none;
}

/* --- Instrument Panel (z-1 metal surface) --- */
#instrument-panel {
    position: fixed;
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    z-index: 2;
    border-radius: 4px;
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.7s var(--spring-overshoot),
                transform 0.7s var(--spring-overshoot);

    /* Brushed metal surface - horizontal repeating gradient */
    background:
        repeating-linear-gradient(90deg,
            var(--metal-dark) 0px,
            var(--metal-light) 0.5px,
            var(--metal-dark) 1px
        );
    background-color: var(--slate-sea);

    /* Chamfered aluminum edge - 4 shadows as specified */
    box-shadow:
        0 0 0 2px var(--weathered-zinc),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

/* Metal noise overlay (5% opacity) */
#instrument-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Crect width='1' height='1' fill='%23fff' fill-opacity='0.04'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23000' fill-opacity='0.04'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

/* --- Registration Marks (vintage nautical chart references) --- */
.reg-mark {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    font-weight: 500;
    color: var(--weathered-zinc);
    opacity: 0.3;
    line-height: 1;
    pointer-events: none;
    z-index: 1;
    user-select: none;
}

.reg-mark-tl { top: 12px; left: 16px; }
.reg-mark-tr { top: 12px; right: 16px; }
.reg-mark-bl { bottom: 12px; left: 16px; }
.reg-mark-br { bottom: 12px; right: 16px; }

/* --- Coordinate Annotation Labels (decorative) --- */
.coord-label {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.6rem, 0.8vw, 0.75rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--secondary-label);
    opacity: 0.35;
    pointer-events: none;
    z-index: 1;
    user-select: none;
}

.coord-top-left { top: 32px; left: 16px; }
.coord-top-right { top: 32px; right: 16px; }
.coord-bottom-left { bottom: 32px; left: 16px; }
.coord-bottom-right { bottom: 32px; right: 16px; }

/* --- Content Sections (cross-fade driven by compass) --- */
.section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    z-index: 2;
}

.section.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Instrument Clusters (asymmetric ship bridge groupings) --- */
.instrument-cluster {
    display: flex;
    align-items: center;
    gap: clamp(24px, 4vw, 60px);
    max-width: 900px;
    padding: 40px;
}

/* Each cluster has its own layout direction for asymmetry */
.cluster-north {
    flex-direction: row;
}

.cluster-east {
    flex-direction: row-reverse;
}

.cluster-south {
    flex-direction: row;
    transform: translateX(-20px);
}

.cluster-west {
    flex-direction: row-reverse;
    transform: translateX(20px);
}

/* --- Glass Panel (z-2 glass gauge cover) --- */
.glass-panel {
    position: relative;
    background: rgba(42, 63, 82, 0.5);
    border: 1px solid rgba(107, 123, 141, 0.4);
    border-radius: 6px;
    padding: clamp(24px, 3vw, 40px);
    max-width: 440px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 8px 24px rgba(0, 0, 0, 0.2);
    transition: border-color 0.3s ease;
}

/* Glass highlight - radial gradient simulating curved glass */
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background: radial-gradient(ellipse at 30% 20%, rgba(200, 216, 220, 0.08), transparent 70%);
    pointer-events: none;
}

/* --- Typography System --- */

/* Primary Display / Headlines - Righteous */
.section-title {
    font-family: 'Righteous', cursive;
    font-size: clamp(2.5rem, 6vw + 0.5rem, 5.5rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fog-bank);
    margin-bottom: 16px;
    line-height: 1.1;
}

/* Body / Reading Text - Crimson Pro */
.section-body {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    font-weight: 400;
    line-height: 1.7;
    letter-spacing: normal;
    color: var(--fog-bank);
}

/* --- Gauge Group --- */
.gauge-group {
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex-shrink: 0;
}

/* --- Gauge (analog pressure/depth meter style) --- */
.gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: default;
}

.gauge-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--weathered-zinc);
    background: var(--slate-sea);
    position: relative;
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        var(--compass-brass) 0%,
        var(--compass-brass) var(--gauge-percent, 0%),
        transparent var(--gauge-percent, 0%),
        transparent 100%
    );
    opacity: 0.35;
    transition: background 1.2s var(--spring-overshoot);
}

.gauge-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

/* Monospace / Data Values - IBM Plex Mono (amber LCD readout color) */
.gauge-reading {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.8rem, 1vw, 1rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--compass-brass);
    line-height: 1.2;
    transition: color 0.3s ease;
}

/* Secondary Display / Instrument Labels - Josefin Sans */
.gauge-unit {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary-label);
}

.gauge-label {
    font-family: 'Josefin Sans', sans-serif;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary-label);
}

/* --- Compass Container --- */
#compass-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Compass Rose - brass radial gradient simulating reflective aged brass */
#compass-rose {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    cursor: grab;
    background: radial-gradient(circle at 40% 35%,
        var(--compass-brass),
        var(--brass-mid),
        var(--brass-dark)
    );
    box-shadow:
        0 0 0 3px var(--weathered-zinc),
        inset 0 2px 6px rgba(0, 0, 0, 0.3),
        0 4px 16px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(232, 196, 124, 0.15);
}

#compass-rose:active {
    cursor: grabbing;
}

#compass-dial {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    transition: transform 0.4s var(--spring-overshoot);
}

/* --- Compass Points (Josefin Sans labels) --- */
.compass-point {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-point span {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--midnight-hull);
    text-shadow: 0 1px 0 rgba(232, 196, 124, 0.5);
    transition: text-shadow 0.3s ease;
}

.compass-n {
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-e {
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-s {
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-w {
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
}

/* --- Compass Needle (brass triangle with glow) --- */
#compass-needle {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 48px;
    background: var(--compass-brass);
    clip-path: polygon(50% 0%, 20% 100%, 80% 100%);
    filter: drop-shadow(0 0 6px rgba(232, 196, 124, 0.4));
    z-index: 2;
}

#compass-center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff, var(--compass-brass));
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

/* --- Power-On Overlay --- */
#power-on-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--midnight-hull);
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

/* --- Shake-Error Animation (signature micro-interaction) --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
    animation: shake 500ms ease;
}

.shake-border {
    border-color: var(--storm-warning) !important;
    transition: border-color 0.3s ease;
}

/* --- Active compass section indicator (glowing text) --- */
.compass-point.active span {
    color: var(--midnight-hull);
    text-shadow: 0 0 8px rgba(232, 196, 124, 0.8);
}

/* --- Hover states with coral horizon --- */
.gauge:hover .gauge-ring {
    border-color: var(--coral-horizon);
}

.glass-panel:hover {
    border-color: rgba(212, 131, 106, 0.4);
}

/* --- Responsive: Narrow viewports --- */
@media (max-width: 768px) {
    #instrument-panel {
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .instrument-cluster {
        flex-direction: column !important;
        padding: 20px;
        gap: 20px;
        transform: none !important;
    }

    .glass-panel {
        max-width: 100%;
    }

    .gauge-group {
        flex-direction: row;
        gap: 16px;
    }

    /* Compass shrinks to 64px diameter but remains functional */
    #compass-rose {
        width: 64px;
        height: 64px;
    }

    #compass-needle {
        top: 6px;
        width: 4px;
        height: 24px;
    }

    #compass-center-dot {
        width: 8px;
        height: 8px;
    }

    .compass-point span {
        font-size: 0.5rem;
    }

    .compass-n { top: 3px; }
    .compass-e { right: 3px; }
    .compass-s { bottom: 3px; }
    .compass-w { left: 3px; }

    #compass-container {
        bottom: 12px;
    }

    .section-title {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .coord-label {
        display: none;
    }

    .gauge-ring {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .section-title {
        font-size: 1.6rem;
    }

    .section-body {
        font-size: 0.9rem;
    }

    .gauge-ring {
        width: 50px;
        height: 50px;
    }

    .gauge-reading {
        font-size: 0.7rem;
    }
}
