/* ═══════════════════════════════════════════════
       CONFIGURATION — easy to customize
═══════════════════════════════════════════════ */
:root {
    /* Accent color — cyan is default; cycled via Space / two-finger tap */
    --accent: #00d4ff;
    --accent-dim: rgba(0, 212, 255, 0.15);
    --accent-glow: rgba(0, 212, 255, 0.4);
    --accent-bright: rgba(0, 212, 255, 0.85);

    /* Background */
    --bg: #050508;
    --bg-gradient: radial-gradient(ellipse at 50% 50%, #0a0a12 0%, #050508 70%, #000000 100%);

    /* Text */
    --text-muted: #4a4a56;
    --text-dim: #5c5c6a;
    --text-ghost: #2a2a34;

    /* Fonts */
    --font-clock: 'Orbitron', monospace;
    --font-label: 'Space Grotesk', 'JetBrains Mono', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ═══════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    cursor: none;
    /* Prevent iOS long-press text selection / callout menu over the canvas */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    font-family: var(--font-label);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════
   CANVAS
   ═══════════════════════════════════════════════ */
#constellation-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Prevent native touch gestures (selection, callout, scroll/zoom) on the canvas */
    touch-action: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* ═══════════════════════════════════════════════
   VIGNETTE OVERLAY
   ═══════════════════════════════════════════════ */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(
            ellipse at 50% 50%,
            transparent 50%,
            rgba(0, 0, 0, 0.35) 85%,
            rgba(0, 0, 0, 0.65) 100%
    );
}

/* ═══════════════════════════════════════════════
   SCANLINES OVERLAY
   ═══════════════════════════════════════════════ */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
    );
    opacity: 0.5;
}

/* ═══════════════════════════════════════════════
   CLOCK DISPLAY
   ═══════════════════════════════════════════════ */
.clock-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    pointer-events: none;
}

/* The primary display area — holds greeting OR clock */
.clock-display-area {
    position: relative;
    min-height: 1em; /* prevent layout shift */
}

#greeting {
    font-family: var(--font-clock);
    font-weight: 600;
    font-size: clamp(2.2rem, 7vw, 5.5rem);
    color: var(--accent);
    letter-spacing: 0.04em;
    text-shadow:
            0 0 20px var(--accent-glow),
            0 0 60px var(--accent-dim);
    opacity: 0;
    transition: none;
    white-space: nowrap;
}

#greeting.fade-in {
    animation: greetFadeIn 1.2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

#greeting.fade-out {
    animation: greetFadeOut 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes greetFadeIn {
    0% {
        opacity: 0;
        filter: blur(12px);
        transform: scale(0.95);
    }
    100% {
        opacity: 0.85;
        filter: blur(0px);
        transform: scale(1);
    }
}

@keyframes greetFadeOut {
    0% {
        opacity: 0.85;
        filter: blur(0px);
        transform: scale(1);
    }
    100% {
        opacity: 0;
        filter: blur(10px);
        transform: scale(1.02);
    }
}

#clock-wrapper {
    opacity: 0;
}

#clock-wrapper.reveal {
    animation: clockReveal 2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes clockReveal {
    0% {
        opacity: 0;
        filter: blur(16px);
        transform: scale(0.94);
    }
    60% {
        filter: blur(1px);
    }
    100% {
        opacity: 1;
        filter: blur(0px);
        transform: scale(1);
    }
}

#clock {
    font-family: var(--font-clock);
    font-weight: 600;
    font-size: clamp(3rem, 10vw, 8rem);
    color: #fff;
    letter-spacing: 0.06em;
    text-shadow:
            0 0 20px var(--accent-glow),
            0 0 60px var(--accent-dim),
            0 0 120px var(--accent-dim);
    position: relative;
    white-space: nowrap;
}

/* Slow ambient glow pulse on clock — 5s cycle, very subtle */
#clock-wrapper.reveal #clock {
    animation: clockGlowPulse 5s ease-in-out infinite;
    animation-delay: 2s;
}

@keyframes clockGlowPulse {
    0%, 100% {
        text-shadow:
                0 0 20px var(--accent-glow),
                0 0 60px var(--accent-dim),
                0 0 120px var(--accent-dim);
    }
    50% {
        text-shadow:
                0 0 28px var(--accent-glow),
                0 0 80px var(--accent-dim),
                0 0 160px var(--accent-glow);
    }
}

/* Colons — always visible, no blink */
.clock-colon {
    display: inline-block;
}

#wip-label {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.65rem, 1.8vw, 0.95rem);
    color: var(--text-muted);
    letter-spacing: 0.35em;
    text-transform: uppercase;
    margin-top: 1.2em;
    position: relative;
    /* Always visible — stays during greeting too */
    opacity: 0;
    animation: subtleFadeIn 2.5s 0.5s ease forwards;
}

@keyframes subtleFadeIn {
    to { opacity: 1; }
}

#date-label {
    font-family: var(--font-label);
    font-weight: 300;
    font-size: clamp(0.55rem, 1.4vw, 0.8rem);
    color: var(--text-ghost);
    letter-spacing: 0.18em;
    margin-top: 0.8em;
    opacity: 0;
    animation: subtleFadeIn 2.5s 1s ease forwards;
}

#weather-label {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.5rem, 1.3vw, 0.72rem);
    color: var(--text-dim);
    letter-spacing: 0.2em;
    text-transform: none;
    margin-bottom: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45em;
    opacity: 0;
    transition: opacity 1.2s ease;
    min-height: 1.2em;
}

#weather-label.visible {
    opacity: 1;
}

#weather-label svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    vertical-align: middle;
}

#weather-label .weather-sep {
    color: var(--text-ghost);
    margin: 0 0.1em;
}

/* ═══════════════════════════════════════════════
   GLITCH EFFECT
   ═══════════════════════════════════════════════ */
.glitch-active #clock {
    animation: glitch 0.15s steps(2) forwards !important;
}

@keyframes glitch {
    0% {
        text-shadow:
                2px 0 #ff0040,
                -2px 0 var(--accent),
                0 0 20px var(--accent-glow);
        transform: translate(1px, 0);
    }
    25% {
        text-shadow:
                -2px 0 #ff0040,
                2px 0 var(--accent),
                0 0 20px var(--accent-glow);
        transform: translate(-1px, 1px);
    }
    50% {
        text-shadow:
                1px 0 #ff0040,
                -1px 0 var(--accent),
                0 0 20px var(--accent-glow);
        transform: translate(0, -1px);
    }
    100% {
        text-shadow:
                0 0 20px var(--accent-glow),
                0 0 60px var(--accent-dim),
                0 0 120px var(--accent-dim);
        transform: translate(0, 0);
    }
}

/* ═══════════════════════════════════════════════
   HUD CORNERS
   ═══════════════════════════════════════════════ */
.hud-corner {
    position: fixed;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    animation: hudFadeIn 3s 1.5s ease forwards;
}

@keyframes hudFadeIn {
    to { opacity: 1; }
}

.hud-corner svg {
    width: 60px;
    height: 60px;
}

.hud-corner.top-left { top: 20px; left: 20px; }
.hud-corner.top-right { top: 20px; right: 20px; transform: scaleX(-1); }
.hud-corner.bottom-left { bottom: 20px; left: 20px; transform: scaleY(-1); }
.hud-corner.bottom-right { bottom: 20px; right: 20px; transform: scale(-1, -1); }

/* ═══════════════════════════════════════════════
   CUSTOM CURSOR
   ═══════════════════════════════════════════════ */
#custom-cursor {
    position: fixed;
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--accent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.2s, height 0.2s, border-color 0.2s, opacity 0.3s;
    opacity: 0;
    box-shadow: 0 0 8px var(--accent-dim), inset 0 0 6px var(--accent-dim);
}

#custom-cursor::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 3px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px var(--accent-glow);
}

#custom-cursor.active {
    width: 32px;
    height: 32px;
    border-color: var(--accent-bright);
}

/* Mobile: hide custom cursor */
@media (hover: none) and (pointer: coarse) {
    #custom-cursor { display: none; }
    html, body { cursor: auto; }
}

/* ═══════════════════════════════════════════════
   MOBILE TWEAKS
   ═══════════════════════════════════════════════ */
@media (max-width: 600px) {
    .hud-corner svg {
        width: 36px;
        height: 36px;
    }
    .hud-corner.top-left { top: 10px; left: 10px; }
    .hud-corner.top-right { top: 10px; right: 10px; }
    .hud-corner.bottom-left { bottom: 10px; left: 10px; }
    .hud-corner.bottom-right { bottom: 10px; right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    #clock-wrapper.reveal #clock {
        animation: none !important;
    }
    .scanlines { opacity: 0.25; }
}

#debug-panel {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    background: rgba(8, 8, 16, 0.92);
    border: 1px solid rgba(123, 47, 247, 0.2);
    border-radius: 8px;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #8a8a9a;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    min-width: 200px;
    cursor: auto;
    pointer-events: auto;
    /* Debug panel is a real UI — allow normal text selection/interaction inside it */
    -webkit-user-select: auto;
    user-select: auto;
    -webkit-touch-callout: default;
}

#debug-panel.visible {
    display: block;
}

#debug-panel .debug-title {
    color: var(--accent);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 10px;
    opacity: 0.7;
}

#debug-panel button {
    display: block;
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: #b0b0c0;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 6px 10px;
    margin-bottom: 4px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}

#debug-panel button:hover {
    background: rgba(123, 47, 247, 0.08);
    border-color: rgba(123, 47, 247, 0.25);
    color: #e0e0f0;
}

#debug-panel button:active {
    background: rgba(123, 47, 247, 0.15);
}

#debug-panel button:last-child {
    margin-bottom: 0;
}