/* ==========================================================================
   HELLO KITTY SPEEDOMETER HUD — STYLES
   Reference-matched 3D Toy Dashboard + FiveM NUI Compatible
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: transparent !important;
    background: transparent !important;
    font-family: 'Outfit', 'Fredoka', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   Original API Compatibility Container (Headless/Integration Safe)
   -------------------------------------------------------------------------- */
main.speedometer {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   HUD Container — Fixed Bottom-Right Position
   -------------------------------------------------------------------------- */
.speedometer-hud {
    position: fixed;
    right: 2vw;
    bottom: 2.5vh;
    width: min(38vw, 620px);
    max-width: 640px;
    min-width: 280px;
    height: auto;
    aspect-ratio: 1000 / 580;
    z-index: 9999;
    pointer-events: none;
    filter: drop-shadow(0 16px 36px rgba(255, 105, 180, 0.28)) drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.4, 1), opacity 0.3s ease;
    transform-origin: bottom right;
}

.speedometer-hud svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

/* Enable pointer events only on interactive buttons */
.speedometer-hud .interactive-control {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.speedometer-hud .interactive-control:hover {
    filter: brightness(1.1) drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

.speedometer-hud .interactive-control:active {
    transform: scale(0.94);
}

/* --------------------------------------------------------------------------
   Analog Needles & Pivot Caps
   -------------------------------------------------------------------------- */
.hud-needle {
    transform-box: view-box;
    will-change: transform;
    transition: none !important; /* Managed via high-frequency requestAnimationFrame delta-lerp */
}

#needle-speed {
    transform-origin: 500px 295px;
}

#needle-rpm {
    transform-origin: 770px 345px;
}

#needle-health {
    transform-origin: 235px 250px;
}

#needle-fuel {
    transform-origin: 195px 410px;
}

/* --------------------------------------------------------------------------
   Hello Kitty Character Animations (Independent from Data)
   -------------------------------------------------------------------------- */
/* Natural Blinking */
.kitty-eye {
    transition: transform 0.08s ease-in-out;
}

#kitty-eye-left {
    transform-origin: 445px 126px;
}

#kitty-eye-right {
    transform-origin: 555px 126px;
}

.kitty-eye.blink {
    transform: scaleY(0.08);
}

/* Expressive Speed-Responsive Mouth & Rosy Cheeks */
#kitty-mouth {
    transition: none;
    will-change: d, fill-opacity;
}

#kitty-blush-left,
#kitty-blush-right {
    transition: opacity 0.15s ease-out;
}

/* Whiskers organic subtle twitches */
@keyframes whisker-twitch-left {
    0%, 100% { transform: rotate(0deg); }
    38% { transform: rotate(-2.4deg); }
    46% { transform: rotate(2deg); }
    54% { transform: rotate(-1deg); }
}

@keyframes whisker-twitch-right {
    0%, 100% { transform: rotate(0deg); }
    42% { transform: rotate(2.4deg); }
    50% { transform: rotate(-2deg); }
    58% { transform: rotate(1deg); }
}

#kitty-whiskers-left {
    transform-origin: 410px 136px;
    animation: whisker-twitch-left 5.2s ease-in-out infinite;
}

#kitty-whiskers-right {
    transform-origin: 590px 136px;
    animation: whisker-twitch-right 5.6s ease-in-out infinite 0.8s;
}

/* Bow subtle breathing idle */
@keyframes bow-idle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.028) rotate(0.6deg); }
}

#kitty-bow {
    transform-origin: 550px 75px;
    animation: bow-idle 4.2s ease-in-out infinite;
}

/* Floating perched characters */
@keyframes float-gentle-1 {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3.8px); }
}

@keyframes float-gentle-2 {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-4.4px); }
}

.char-float-1 {
    animation: float-gentle-1 3.5s ease-in-out infinite;
}

.char-float-2 {
    animation: float-gentle-2 4.2s ease-in-out infinite 0.9s;
}

.char-float-3 {
    animation: float-gentle-1 3.8s ease-in-out infinite 1.7s;
}

/* --------------------------------------------------------------------------
   Turn Signal Indicators
   -------------------------------------------------------------------------- */
@keyframes indicator-blink {
    0%, 49% {
        opacity: 1;
        filter: drop-shadow(0 0 10px #00ff66) drop-shadow(0 0 18px #00ff88);
    }
    50%, 100% {
        opacity: 0.18;
        filter: none;
    }
}

.indicator-arrow {
    opacity: 0.22;
    transition: opacity 0.2s, filter 0.2s;
}

.indicator-btn.blinking .indicator-arrow {
    animation: indicator-blink 0.68s infinite;
}

/* --------------------------------------------------------------------------
   Seatbelt Indicator
   -------------------------------------------------------------------------- */
@keyframes seatbelt-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 4px #ff1744);
        opacity: 1;
    }
    50% {
        filter: drop-shadow(0 0 12px #ff1744) drop-shadow(0 0 20px #ff5252);
        opacity: 0.85;
    }
}

.seatbelt-icon-group {
    transition: filter 0.3s, opacity 0.3s;
}

.seatbelt-warning .seatbelt-icon-group {
    opacity: 1;
    animation: seatbelt-pulse 1.2s infinite ease-in-out;
}

.seatbelt-buckled .seatbelt-icon-group {
    filter: none;
    opacity: 0.28;
}

/* --------------------------------------------------------------------------
   Engine Status Indicator
   -------------------------------------------------------------------------- */
.engine-icon-group {
    opacity: 0.22;
    transition: filter 0.3s, opacity 0.3s;
}

.engine-on .engine-icon-group {
    opacity: 1;
    filter: drop-shadow(0 0 8px #ff7700) drop-shadow(0 0 16px #ff3d00);
}

.engine-off .engine-icon-group {
    opacity: 0.22;
    filter: none;
}

/* --------------------------------------------------------------------------
   Headlights Status Halo
   -------------------------------------------------------------------------- */
.headlight-halo {
    opacity: 0;
    transition: opacity 0.3s, filter 0.3s, stroke 0.3s;
}

.headlights-on .headlight-halo {
    opacity: 0.85;
    stroke: #00e676;
    filter: drop-shadow(0 0 8px #00e676);
}

.headlights-high .headlight-halo {
    opacity: 1;
    stroke: #00b0ff;
    filter: drop-shadow(0 0 12px #00b0ff) drop-shadow(0 0 22px #0080ff);
}

.headlight-badge-icon {
    opacity: 0.2;
    transition: opacity 0.3s, filter 0.3s;
}

.headlights-on .headlight-badge-icon {
    opacity: 1;
    fill: #00e676;
    filter: drop-shadow(0 0 6px #00e676);
}

.headlights-high .headlight-badge-icon {
    opacity: 1;
    fill: #00b0ff;
    filter: drop-shadow(0 0 8px #00b0ff);
}

/* --------------------------------------------------------------------------
   Warning Pulses (Fuel & Health)
   -------------------------------------------------------------------------- */
@keyframes warning-fuel-pulse {
    0%, 100% { opacity: 0.8; filter: drop-shadow(0 0 3px #ff1744); }
    50% { opacity: 1; filter: drop-shadow(0 0 10px #ff1744); }
}

.fuel-pump-icon.fuel-warning {
    animation: warning-fuel-pulse 1s infinite ease-in-out;
    fill: #ff1744 !important;
}

@keyframes heart-critical-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px #ff1744); }
    50% { transform: scale(1.12); filter: drop-shadow(0 0 16px #ff1744); }
}

#health-heart-group.health-warning {
    transform-origin: 235px 255px;
    animation: heart-critical-pulse 0.9s infinite ease-in-out;
}



/* --------------------------------------------------------------------------
   HELLO KITTY YOUTUBE CAR RADIO & POPUP PLAYER
   Positioned directly above the bottom-left radar minimap
   -------------------------------------------------------------------------- */

/* Compact Floating Launcher Button (Near Speedometer) */
.btn-yt-launcher {
    position: fixed;
    right: max(2vw, 24px);
    bottom: calc(2.5vh + min(38vw, 620px) * 0.58 + 10px);
    width: 44px;
    height: 44px;
    background: linear-gradient(145deg, #ff1a40, #cc0029);
    color: #ffffff;
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(213, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
    z-index: 9999;
    pointer-events: auto;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.22s ease, background 0.2s;
}

.btn-yt-launcher:hover {
    transform: translateY(-2px) scale(1.12);
    box-shadow: 0 10px 24px rgba(255, 26, 64, 0.65), 0 4px 10px rgba(0, 0, 0, 0.45);
    background: linear-gradient(145deg, #ff3358, #b30022);
}

.btn-yt-launcher:active {
    transform: scale(0.94);
}

.btn-yt-launcher.is-playing {
    animation: yt-pulse-glow 2s infinite ease-in-out;
}

@keyframes yt-pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 26, 64, 0.6), 0 6px 18px rgba(213, 0, 0, 0.45);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 26, 64, 0), 0 8px 24px rgba(255, 26, 64, 0.7);
    }
}

.yt-badge-bow {
    position: absolute;
    top: -7px;
    right: -7px;
    font-size: 14px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
    pointer-events: none;
    transform: rotate(12deg);
}

.yt-icon-svg {
    width: 22px;
    height: 22px;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

/* YouTube Modal Overlay */
.yt-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 8, 16, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    transition: opacity 0.2s ease;
}

.yt-modal-overlay.hidden {
    display: none !important;
}

.yt-modal-card {
    background: #ffffff;
    border: 3.5px solid #ff4d79;
    border-radius: 24px;
    width: min(90vw, 440px);
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 77, 121, 0.3);
    font-family: 'Outfit', sans-serif;
    animation: modal-pop 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modal-pop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.yt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.yt-modal-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yt-sync-badge {
    background: rgba(0, 230, 118, 0.18);
    border: 1px solid rgba(0, 230, 118, 0.5);
    color: #00e676;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    user-select: none;
    transition: all 0.2s ease;
}

.yt-sync-badge .sync-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00e676;
    box-shadow: 0 0 6px #00e676;
    display: inline-block;
    animation: sync-pulse 1.8s infinite;
}

.yt-sync-badge.disconnected {
    background: rgba(255, 152, 0, 0.18);
    border-color: rgba(255, 152, 0, 0.5);
    color: #ffb74d;
}

.yt-sync-badge.disconnected .sync-dot {
    background: #ffb74d;
    box-shadow: 0 0 6px #ffb74d;
    animation: none;
}

@keyframes sync-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.65); opacity: 0.45; }
}

.yt-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yt-modal-title-wrap h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
    color: #ea1b3f;
}

.yt-modal-close-btn {
    background: #f1f1f1;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    color: #666;
    transition: background 0.15s, color 0.15s;
}

.yt-modal-close-btn:hover {
    background: #ea1b3f;
    color: #ffffff;
}

.yt-modal-subtitle {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: #777777;
}

.yt-input-group {
    display: flex;
    align-items: center;
    background: #fdf5f8;
    border: 2px solid #ffb8d6;
    border-radius: 12px;
    padding: 3px 8px;
    margin-bottom: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.yt-input-group:focus-within {
    border-color: #ff4d79;
    box-shadow: 0 0 0 3px rgba(255, 77, 121, 0.18);
}

.yt-url-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 6px;
    font-size: 13.5px;
    font-family: inherit;
    color: #222222;
    outline: none;
}

.yt-input-clear-btn {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

.yt-input-clear-btn:hover {
    color: #ea1b3f;
}

.yt-presets-section {
    margin-bottom: 16px;
}

.yt-presets-label {
    display: block;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ff4d79;
    margin-bottom: 7px;
}

.yt-preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.yt-chip {
    background: #fff0f6;
    border: 1.5px solid #ffc2dc;
    color: #c41243;
    padding: 5px 10px;
    border-radius: 16px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.yt-chip:hover {
    background: #ff4d79;
    color: #ffffff;
    border-color: #ff4d79;
    transform: translateY(-1px);
}

.yt-modal-error {
    background: #ffebee;
    color: #d32f2f;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 14px;
}

.yt-modal-error.hidden {
    display: none;
}

.yt-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.yt-btn-secondary {
    background: #f5f5f5;
    border: none;
    padding: 9px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: #666;
    cursor: pointer;
}

.yt-btn-secondary:hover {
    background: #e9e9e9;
    color: #222;
}

.yt-btn-primary {
    background: linear-gradient(135deg, #ff476c, #ea183e);
    color: #ffffff;
    border: none;
    padding: 9px 20px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 14px rgba(234, 24, 62, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.yt-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(234, 24, 62, 0.45);
}

/* --------------------------------------------------------------------------
   YouTube Popup Player Window (Above Left Radar Minimap)
   -------------------------------------------------------------------------- */
.yt-player-popup {
    position: fixed;
    left: max(20px, 1.5vw);
    bottom: clamp(210px, 24vh, 250px);
    width: clamp(290px, 16vw, 320px);
    background: #140d18;
    border: 2.5px solid #ff4d79;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(255, 77, 121, 0.35);
    z-index: 99998;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.25s ease, height 0.25s ease, width 0.25s ease;
    font-family: 'Outfit', sans-serif;
    pointer-events: auto;
}

.yt-player-popup.hidden {
    display: none !important;
}

/* Minimized state: collapses to compact pill widget above the map */
.yt-player-popup.minimized {
    height: 38px !important;
    width: auto !important;
    min-width: 220px;
    border-radius: 20px;
}

.yt-player-popup.minimized .yt-iframe-container {
    height: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.yt-popup-header {
    height: 34px;
    background: linear-gradient(90deg, #ff4f72, #ea183e);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    user-select: none;
    cursor: grab;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.2);
}

.yt-popup-header:active {
    cursor: grabbing;
}

.yt-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.yt-header-bow {
    font-size: 13px;
}

.yt-header-title {
    font-size: 12px;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.yt-live-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00e676;
    box-shadow: 0 0 8px #00e676;
    display: inline-block;
    animation: pulse-live 1.5s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.yt-header-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.yt-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.yt-control-btn:hover {
    background: rgba(255, 255, 255, 0.38);
    transform: scale(1.08);
}

.yt-control-close:hover {
    background: #c60021;
}

.yt-iframe-container {
    width: 100%;
    height: 175px;
    background: #0a040d;
    position: relative;
    transition: height 0.25s ease, opacity 0.25s ease;
}

.yt-iframe-container iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
}

/* --------------------------------------------------------------------------
   Accessibility & Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .hud-needle,
    .kitty-eye,
    #kitty-whiskers-left,
    #kitty-whiskers-right,
    #kitty-bow,
    .char-float-1,
    .char-float-2,
    .char-float-3,
    .indicator-arrow,
    .seatbelt-icon-group,
    #health-heart-group,
    .btn-yt-launcher {
        animation: none !important;
        transition: none !important;
    }
}

