/* =========================================
   LIGHT / DARK THEME
   Light is the default look in style.css / game_player.css.
   Dark mode is applied with <html data-theme="dark">.
========================================= */

/* =========================================
   KIDS DAY / NIGHT SWITCH
   Day: blue sky, smiling sun, clouds.
   Night: starry sky, sleepy moon with craters.
========================================= */

.theme-toggle {
    --tt-w: 56px;
    --tt-h: 28px;
    --tt-pad: 3px;
    --tt-knob: calc(var(--tt-h) - var(--tt-pad) * 2);

    position: relative;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 999px;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
    outline: 3px solid #ffb400;
    outline-offset: 3px;
}

.tt-track {
    position: relative;
    display: block;
    width: var(--tt-w);
    height: var(--tt-h);
    border-radius: 999px;
    overflow: hidden;
    background: linear-gradient(180deg, #5ec8ff 0%, #9be0ff 100%);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.18),
        0 2px 0 rgba(0, 0, 0, 0.08),
        0 0 0 2px #ffffff;
    transition: background 0.6s ease, box-shadow 0.6s ease;
}

/* ---------- Knob (sun / moon) ---------- */

.tt-knob {
    position: absolute;
    top: var(--tt-pad);
    left: var(--tt-pad);
    width: var(--tt-knob);
    height: var(--tt-knob);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff59a 0%, #ffd23f 55%, #ffb400 100%);
    box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
    transition:
        transform 0.7s cubic-bezier(0.68, -0.55, 0.27, 1.55),
        background 0.6s ease,
        box-shadow 0.6s ease;
    z-index: 3;
}

/* sun rays */
.tt-rays {
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background:
        repeating-conic-gradient(from 0deg,
            rgba(255, 200, 40, 0.85) 0deg 12deg,
            transparent 12deg 30deg);
    -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%, #000 70%, transparent 72%);
            mask: radial-gradient(circle, transparent 58%, #000 60%, #000 70%, transparent 72%);
    animation: tt-spin 8s linear infinite;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: -1;
}

/* smiling face */
.tt-face {
    position: absolute;
    inset: 0;
    transition: opacity 0.3s ease;
}

.tt-face i {
    position: absolute;
    display: block;
}

.tt-face .eye {
    top: 36%;
    width: 3px;
    height: 4px;
    border-radius: 50%;
    background: #6b3e00;
    animation: tt-blink 4s infinite;
}

.tt-face .eye.l { left: 32%; }
.tt-face .eye.r { right: 32%; }

.tt-face .smile {
    left: 34%;
    right: 34%;
    top: 52%;
    height: 5px;
    border: 2px solid #6b3e00;
    border-top: none;
    border-radius: 0 0 10px 10px;
}

.tt-face .cheek {
    top: 54%;
    width: 4px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 110, 90, 0.6);
}

.tt-face .cheek.l { left: 18%; }
.tt-face .cheek.r { right: 18%; }

/* moon craters (hidden in the day) */
.tt-crater {
    position: absolute;
    border-radius: 50%;
    background: #c9c3a8;
    box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.4s ease 0.25s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s;
}

.tt-crater.k1 { width: 7px; height: 7px; top: 22%; left: 52%; }
.tt-crater.k2 { width: 5px; height: 5px; top: 58%; left: 26%; }
.tt-crater.k3 { width: 4px; height: 4px; top: 62%; left: 62%; }

/* ---------- Clouds (day) ---------- */

.tt-clouds i {
    position: absolute;
    display: block;
    background: #ffffff;
    border-radius: 999px;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.4s ease;
}

.tt-clouds i::before,
.tt-clouds i::after {
    content: "";
    position: absolute;
    background: #ffffff;
    border-radius: 50%;
}

.tt-clouds .c1 {
    width: 22px; height: 8px;
    right: 8px; bottom: 6px;
    animation: tt-drift 4s ease-in-out infinite;
}
.tt-clouds .c1::before { width: 10px; height: 10px; left: 3px;  top: -6px; }
.tt-clouds .c1::after  { width: 8px;  height: 8px;  left: 10px; top: -4px; }

.tt-clouds .c2 {
    width: 14px; height: 5px;
    right: 20px; top: 7px;
    opacity: 0.85;
    animation: tt-drift 5s ease-in-out -2s infinite;
}
.tt-clouds .c2::before { width: 7px; height: 7px; left: 2px; top: -4px; }
.tt-clouds .c2::after  { width: 5px; height: 5px; left: 7px; top: -2px; }

/* ---------- Stars (night) ---------- */

.tt-stars i {
    position: absolute;
    display: block;
    width: 3px;
    height: 3px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0;
    transform: translateY(-14px) scale(0);
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tt-stars .s1 { left: 10px; top: 7px; }
.tt-stars .s2 { left: 20px; top: 19px; width: 2px; height: 2px; }
.tt-stars .s3 { left: 30px; top: 9px;  width: 4px; height: 4px; }
.tt-stars .s4 { left: 15px; top: 25px; width: 2px; height: 2px; }
.tt-stars .s5 { left: 38px; top: 22px; }

/* little sparkle shape for the bigger star */
.tt-stars .s3 {
    background: none;
}
.tt-stars .s3::before,
.tt-stars .s3::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    background: #fff7c2;
    border-radius: 2px;
    transform: translate(-50%, -50%);
}
.tt-stars .s3::before { width: 8px; height: 2px; }
.tt-stars .s3::after  { width: 2px; height: 8px; }

.tt-shooting {
    position: absolute;
    top: 6px;
    left: 44px;
    width: 14px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), #ffffff);
    opacity: 0;
    transform: rotate(-25deg);
}

/* =========================================
   NIGHT STATE
========================================= */

html[data-theme="dark"] .tt-track {
    background: linear-gradient(180deg, #0b1637 0%, #27306b 100%);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.45),
        0 2px 0 rgba(0, 0, 0, 0.3),
        0 0 0 2px #3a4a7a;
}

html[data-theme="dark"] .tt-knob {
    transform: translateX(calc(var(--tt-w) - var(--tt-knob) - var(--tt-pad) * 2)) rotate(360deg);
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f1edd8 60%, #ddd6b8 100%);
    box-shadow: 0 0 10px 2px rgba(255, 250, 220, 0.45), 0 2px 4px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .tt-rays {
    opacity: 0;
    transform: scale(0.4);
}

html[data-theme="dark"] .tt-face {
    opacity: 0;
}

html[data-theme="dark"] .tt-crater {
    opacity: 1;
    transform: scale(1);
}

html[data-theme="dark"] .tt-clouds i {
    transform: translateY(26px);
    opacity: 0;
}

html[data-theme="dark"] .tt-stars i {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: tt-twinkle 2.4s ease-in-out infinite;
}

html[data-theme="dark"] .tt-stars .s1 { transition-delay: 0.15s; animation-delay: 0.0s; }
html[data-theme="dark"] .tt-stars .s2 { transition-delay: 0.25s; animation-delay: 0.6s; }
html[data-theme="dark"] .tt-stars .s3 { transition-delay: 0.35s; animation-delay: 1.1s; }
html[data-theme="dark"] .tt-stars .s4 { transition-delay: 0.45s; animation-delay: 0.3s; }
html[data-theme="dark"] .tt-stars .s5 { transition-delay: 0.55s; animation-delay: 1.6s; }

html[data-theme="dark"] .tt-shooting {
    animation: tt-shoot 6s ease-in 1.2s infinite;
}

/* =========================================
   HOVER / CLICK FUN
========================================= */

.theme-toggle:hover .tt-knob {
    box-shadow: 0 0 0 5px rgba(255, 210, 63, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25);
}

.theme-toggle:hover .tt-rays {
    animation-duration: 2s;
}

html[data-theme="dark"] .theme-toggle:hover .tt-knob {
    box-shadow: 0 0 14px 4px rgba(255, 250, 220, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.theme-toggle:active .tt-track {
    transform: scale(0.94);
}

.tt-track {
    transition: background 0.6s ease, box-shadow 0.6s ease, transform 0.15s ease;
}

/* a happy bounce right after the click (class added by theme.js) */
.theme-toggle.tt-pop .tt-track {
    animation: tt-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================
   KEYFRAMES
========================================= */

@keyframes tt-spin {
    to { transform: rotate(360deg); }
}

@keyframes tt-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95%           { transform: scaleY(0.1); }
}

@keyframes tt-drift {
    0%, 100% { margin-right: 0; }
    50%      { margin-right: 4px; }
}

@keyframes tt-twinkle {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.6); }
}

@keyframes tt-shoot {
    0%, 85% { opacity: 0; transform: translate(0, 0) rotate(-25deg); }
    88%     { opacity: 1; }
    100%    { opacity: 0; transform: translate(-30px, 14px) rotate(-25deg); }
}

@keyframes tt-pop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.12, 0.9); }
    65%  { transform: scale(0.96, 1.05); }
    100% { transform: scale(1); }
}

/* Respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle *,
    .theme-toggle *::before,
    .theme-toggle *::after {
        animation: none !important;
        transition-duration: 0.01s !important;
        transition-delay: 0s !important;
    }
}

/* =========================================
   PLACEMENT
========================================= */

/* Home page: right side of the header */
.header-inner .theme-toggle {
    position: absolute;
    right: 4%;
    top: 50%;
    transform: translateY(-50%);
}

/* Game page: in the blue header */
.header-right {
    display: flex;
    justify-content: flex-end;
}

.game-header .tt-track {
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.18),
        0 0 0 2px rgba(255, 255, 255, 0.85);
}

@media (max-width: 600px) {

    .theme-toggle {
        --tt-w: 46px;
        --tt-h: 24px;
    }

    .tt-stars .s5,
    .tt-clouds .c2 {
        display: none;
    }

    .header-inner .theme-toggle {
        right: 8px;
    }

    .game-header-container {
        grid-template-columns: 1fr auto auto !important;
        gap: 10px;
    }

    .header-right {
        display: flex !important;
    }
}

/* Smooth colour change when switching */
html.theme-animate,
html.theme-animate *:not(.theme-toggle):not(.theme-toggle *):not(.cloud-bg):not(.space-bg):not(.sky-wheel):not(.sky-wheel *) {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
}

/* =========================================
   DARK THEME
========================================= */

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] body {
    background: #0f1720;
    color: #e6edf3;
}

/* ---------- Home header ---------- */

html[data-theme="dark"] .header {
    background: #141e28;
    border-bottom-color: #253341;
}

html[data-theme="dark"] .date,
html[data-theme="dark"] .brand-links {
    color: #9aa8b6;
}

html[data-theme="dark"] .logo {
    color: #6cc4f5;
}

html[data-theme="dark"] .brand-links a:hover,
html[data-theme="dark"] .brand-links a:focus-visible {
    color: #6cc4f5;
}

/* ---------- Category menu ---------- */

html[data-theme="dark"] .nav-item {
    background: #17212b;
    border-color: #2a3744;
    color: #e6edf3;
}

html[data-theme="dark"] .nav-item.active,
html[data-theme="dark"] .nav-item:hover {
    background: #1683c4;
    border-color: #1683c4;
    color: #fff;
}

html[data-theme="dark"] .orange-icon { color: #ff9d57; }
html[data-theme="dark"] .green-icon  { color: #4fd1bd; }
html[data-theme="dark"] .blue-icon   { color: #6cc4f5; }

html[data-theme="dark"] .nav-arrow {
    background: #17212b;
    border-color: #2a3744;
    color: #6cc4f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .nav-arrow:hover {
    background: #1683c4;
    color: #fff;
}

html[data-theme="dark"] .nav-scroller::before {
    background: linear-gradient(to right, #0f1720 40%, rgba(15, 23, 32, 0));
}

html[data-theme="dark"] .nav-scroller::after {
    background: linear-gradient(to left, #0f1720 40%, rgba(15, 23, 32, 0));
}

/* ---------- Slider ---------- */

html[data-theme="dark"] .thumbnail-slider-wrapper {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .thumbnail-slide-placeholder {
    background: #1c2834;
    color: #6cc4f5;
}

/* ---------- Section headings ---------- */

html[data-theme="dark"] .heading-icon {
    background: #1683c4;
}

html[data-theme="dark"] .section-heading p,
html[data-theme="dark"] .video-section-header p {
    color: #9aa8b6;
}

/* ---------- Game cards ---------- */

html[data-theme="dark"] .game-card {
    background: #17212b;
    border-color: #2a3744;
    box-shadow: 0 4px 0 #0a1016;
}

html[data-theme="dark"] .game-card:hover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .game-image,
html[data-theme="dark"] .game-placeholder {
    background: #1c2834;
    color: #6cc4f5;
}

html[data-theme="dark"] .game-text h3,
html[data-theme="dark"] #gamesContainer .game-text h3 {
    color: #f1f5f9;
}

html[data-theme="dark"] .game-text p,
html[data-theme="dark"] .game-placeholder span,
html[data-theme="dark"] .no-games-message,
html[data-theme="dark"] .play-unavailable {
    color: #9aa8b6;
}

html[data-theme="dark"] .no-games-message i,
html[data-theme="dark"] .view-all-videos {
    color: #6cc4f5;
}

html[data-theme="dark"] .play-button {
    background: #1683c4;
}

html[data-theme="dark"] .play-button:hover {
    background: #1f9be0;
}

/* ---------- Home footer ---------- */

html[data-theme="dark"] .home-footer {
    background: #0a1118;
    border-top: 1px solid #1c2834;
}

/* ---------- Game page ---------- */

html[data-theme="dark"] .game-header {
    background: #0b3a58;
}

html[data-theme="dark"] .game-player-section,
html[data-theme="dark"] .game-fallback {
    background: #0f1720;
}

html[data-theme="dark"] .game-player-toolbar {
    background: #17212b;
    border-bottom-color: #2a3744;
}

html[data-theme="dark"] .game-player-toolbar h3 {
    color: #e6edf3;
}

html[data-theme="dark"] .game-player-actions button {
    background: #1683c4;
}

html[data-theme="dark"] .game-player-actions button:hover {
    background: #1f9be0;
}

html[data-theme="dark"] #closeGameBtn {
    background: #dc3545;
}

html[data-theme="dark"] .game-fallback a {
    color: #6cc4f5;
}

html[data-theme="dark"] .game-footer {
    background: #0a1118;
}

html[data-theme="dark"] .related-game-card {
    background: #17212b;
}

html[data-theme="dark"] .related-game-card:hover {
    background: #22303d;
}

html[data-theme="dark"] .related-placeholder {
    background: #1c2834;
    color: #6cc4f5;
}

/* Disable full-page blur */

.theme-transition-overlay {
    display: none !important;
}