/* ===== PROWL — first-person cat playground HUD =====
   Self-contained styles for prowl.html. Reuses the repo's glass recipe
   (rgba(0,0,0,0.4) + blur(10px) + 1px white border) and the corner-button look
   from style.css so it feels like the same product. */

body.prowl {
    background: #0a0a0f;
    cursor: default;
    -webkit-user-select: none;
    user-select: none;   /* dragging to orbit never selects page text */
}

#prowl-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
    touch-action: none;   /* we own touch gestures — block scroll/zoom/back-swipe on the canvas */
}

/* The mouse is never captured — show a grab affordance for drag-to-orbit. */
body.prowl.engaged #prowl-canvas { cursor: grab; }
body.prowl.dragging #prowl-canvas { cursor: grabbing; }

/* ===== Cinematic vignette + grade (free "post-processing") ===== */
#vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;   /* above the canvas, below the HUD */
    background:
        radial-gradient(ellipse at 50% 42%, transparent 50%, rgba(5, 5, 13, 0.52) 100%),
        linear-gradient(to bottom, rgba(12, 14, 30, 0.22), transparent 16%, transparent 84%, rgba(4, 4, 12, 0.38));
}

/* ===== In-game brand chip ===== */
#prowl-brand {
    position: fixed;
    top: 1rem;
    left: 3.6rem;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 40px;
    padding: 0 0.95rem;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    font-family: 'Fredoka', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.75);
    pointer-events: none;
}

#prowl-brand span {
    font-family: 'Nunito', sans-serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.32);
    text-transform: uppercase;
}

/* ===== HUD shell ===== */
#prowl-hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.4s ease;
}

/* Dim the whole HUD while paused (not engaged). */
body.prowl:not(.engaged) #prowl-hud { opacity: 0.45; }

/* ===== State readout (top-center) ===== */
#state-readout {
    position: absolute;
    top: 1.1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 0.6rem 1.4rem 0.75rem;
    min-width: 220px;
}

#state-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #9aa0b5;
    line-height: 1;
}

#state-name.pop { animation: statePop 0.16s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes statePop {
    from { transform: scale(0.7); }
    to   { transform: scale(1); }
}

#speed-meter {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

#speed-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #43A047, #66BB6A, #FFD54F);
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(102, 187, 106, 0.6);
    transition: width 0.08s linear;
}

/* Air-strafe celebration: glow harder when you exceed run speed */
#speed-fill.over { box-shadow: 0 0 14px rgba(255, 213, 79, 0.9); }

#speed-value {
    font-family: 'Nunito', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.5);
}

/* ===== Controls legend (bottom-left) ===== */
#legend {
    position: absolute;
    bottom: 1.1rem;
    left: 1.1rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 0.75rem 0.9rem;
    pointer-events: auto;
    transition: opacity 0.5s ease;
}

#legend.collapsed .legend-rows { display: none; }

.legend-rows { display: flex; flex-direction: column; gap: 0.5rem; }

.legend-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.kc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.7rem;
    height: 1.7rem;
    padding: 0 0.4rem;
    font-family: 'Fredoka', system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.04));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-bottom-width: 3px;
    border-radius: 7px;
    transition: all 0.08s ease;
}

.kc.wide { min-width: auto; }

/* Live input feedback — the held key lights up cucumber-green */
.kc.active {
    color: #fff;
    background: linear-gradient(180deg, rgba(102,187,106,0.7), rgba(67,160,71,0.5));
    border-color: rgba(102, 187, 106, 0.9);
    box-shadow: 0 0 10px rgba(102, 187, 106, 0.6);
    transform: translateY(1px);
    border-bottom-width: 2px;
}

.kc-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    margin-right: 0.5rem;
    letter-spacing: 0.04em;
}

#legend-toggle {
    position: absolute;
    top: -0.6rem;
    right: -0.6rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(10px);
}
#legend-toggle:hover { color: #fff; }

/* ===== Pointer-lock overlay ===== */
#lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10,10,15,0.35), rgba(10,10,15,0.85));
    backdrop-filter: blur(2px);
    transition: opacity 0.35s ease;
    /* Click-through: the dim backdrop must not swallow the corner buttons / legend
       (which sit below it). Only the card itself is interactive; clicking the
       backdrop falls through to the canvas, which re-requests pointer lock. */
    pointer-events: none;
}

#lock-overlay.hidden { display: none !important; }

.lock-card {
    pointer-events: auto;
    text-align: center;
    background: rgba(2, 3, 8, 0.55);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 2.6rem 3.2rem 2.2rem;
    box-shadow:
        0 0 90px rgba(102, 187, 106, 0.18),
        0 24px 60px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

@media (prefers-reduced-motion: no-preference) {
    .lock-card { animation: cardFloat 6s ease-in-out infinite; }
}

@keyframes cardFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.lock-eyebrow {
    font-family: 'Nunito', sans-serif;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: rgba(102, 187, 106, 0.75);
    margin-bottom: 0.9rem;
}

.lock-footer {
    margin-top: 1.4rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.22);
}

.lock-title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(2.6rem, 7vw, 4.5rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, #FFB74D, #66BB6A);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 50px rgba(102, 187, 106, 0.3);
    line-height: 1;
}

.lock-sub {
    margin-top: 0.5rem;
    font-size: clamp(0.9rem, 2vw, 1.15rem);
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.05em;
    font-style: italic;
}

#prowl-start {
    margin-top: 1.8rem;
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(1rem, 2vw, 1.35rem);
    font-weight: 600;
    padding: 0.85em 2.2em;
    border: none;
    border-radius: 60px;
    background: linear-gradient(135deg, #43A047, #66BB6A);
    color: #fff;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4), 0 0 40px rgba(76, 175, 80, 0.15);
}

#prowl-start:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.6), 0 0 60px rgba(76, 175, 80, 0.3);
}
#prowl-start:active { transform: translateY(0) scale(0.98); }

.lock-hint {
    margin-top: 1.6rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.05em;
}

/* ===== Corner buttons (matches style.css recipe) ===== */
#prowl-back, #prowl-sound {
    position: fixed;
    top: 1rem;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

#prowl-back { left: 1rem; }
#prowl-sound { right: 1rem; font-size: 1.1rem; }

#prowl-back:hover, #prowl-sound:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: scale(1.1);
}

#prowl-sound.muted { opacity: 0.55; }

/* ===== Touch fallback ===== */
#touch-ui { position: fixed; inset: 0; z-index: 22; pointer-events: none; }
#touch-ui.hidden { display: none !important; }

#touch-stick {
    position: absolute;
    bottom: 6%;
    left: 6%;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: auto;
    touch-action: none;
}

#touch-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(102, 187, 106, 0.4);
    border: 1px solid rgba(102, 187, 106, 0.7);
    transform: translate(-50%, -50%);
}

#touch-buttons {
    position: absolute;
    bottom: 6%;
    right: 6%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.7rem;
    pointer-events: none;
}

.touch-btn {
    pointer-events: auto;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 64px;
    height: 64px;
    font-size: 0.7rem;
    backdrop-filter: blur(10px);
    touch-action: none;
    user-select: none;
}
.touch-btn.big { width: 84px; height: 84px; font-size: 0.9rem; background: rgba(67, 160, 71, 0.35); }
.touch-btn.on { background: rgba(102, 187, 106, 0.6); border-color: rgba(102, 187, 106, 0.9); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    #state-readout { top: 0.6rem; padding: 0.45rem 1rem 0.6rem; min-width: 170px; }
    #state-name { font-size: 1.15rem; }
    #speed-meter { width: 150px; }
    .lock-card { padding: 1.8rem 1.6rem; }
    #prowl-brand { display: none; }
}
