/* ===== CSS Variables ===== */
:root {
    --bg-primary: #f9f9f9;
    --bg-secondary: #ffffff;
    --bg-hover: #f0f0f0;
    --text-primary: #0f0f0f;
    --text-secondary: #606060;
    --accent: #ff0000;
    --accent-hover: #cc0000;
    --border-color: #e5e5e5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --gap: 16px;
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 24px;
    text-align: center;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
}

/* ===== Page Management ===== */
.page {
    min-height: 100vh;
    width: 100%;
}

.page.hidden {
    display: none;
}

/* ===== Orientation Lock Overlay ===== */
#orientation-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

#orientation-overlay h2 {
    font-size: 2rem;
    margin-bottom: 12px;
}

#orientation-overlay p {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

@media (orientation: portrait) {
    #orientation-overlay {
        display: flex !important;
    }

    .page {
        display: none !important;
    }
}

/* ===== Tags Grid (Page 1) ===== */
.tags-grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    padding: 20px;
}

.tag-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    font-size: 1.5rem;
    font-weight: 600;
    background: radial-gradient(ellipse at 15% 80%, color-mix(in srgb, var(--bg-secondary, #ffffff) 70%, white) 0%, var(--bg-secondary, #ffffff) 70%);
    color: #ffffff;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tag-btn:active {
    opacity: 0.9;
}

.tag-icon {
    width: 48px;
    height: 48px;
    stroke-width: 2;
    color: #ffffff;
}

.tag-label {
    color: #ffffff;
    text-align: center;
    line-height: 1.3;
}

/* ===== Videos Display (Page 2) ===== */
#videos-container {
    display: grid;
    gap: var(--gap);
    padding: 20px;
}

#videos-container.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

#videos-container.list-view {
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
}

.video-item {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.video-item:active {
    opacity: 0.9;
}

/* Grid View (Kids) */
.video-item.grid-item {
    display: flex;
    flex-direction: column;
    padding: 6px;
    gap: 6px;
    background: radial-gradient(ellipse at 15% 80%, color-mix(in srgb, var(--item-color, #6b7280) 70%, white) 0%, var(--item-color, #6b7280) 70%);
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.video-info {
    padding: 0 4px 4px 4px;
}

.video-title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    color: #ffffff;
}

/* List View (Regular) */
.video-item.list-item {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.video-item.list-item .video-title {
    font-size: 1.2rem;
    color: #ffffff;
}

/* ===== Back Buttons ===== */
.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    font-size: 2rem;
    font-weight: 200;
    font-family: Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    line-height: 0.9;
    padding: 0;
    text-align: center;
}

.back-btn:active {
    opacity: 0.8;
}

/* ===== Video Player (Page 3) ===== */
#page-player {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    z-index: 1000;
}

#player-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#youtube-player {
    width: 100%;
    height: 100%;
}

#youtube-player iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.back-btn-player {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    font-size: 2.5rem;
    font-weight: 200;
    font-family: Arial, sans-serif;
    background-color: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    transition: opacity 0.3s ease;
    opacity: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    line-height: 0.9;
    padding: 0;
    text-align: center;
}

.back-btn-player:active {
    opacity: 0.7;
}

.back-btn-player.playing {
    opacity: 0.2;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    .tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        padding: 16px;
    }

    #videos-container {
        padding: 16px;
    }

    #videos-container.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .tag-btn {
        padding: 40px 20px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }

    .tag-btn {
        padding: 32px 16px;
        font-size: 1.2rem;
    }

    #videos-container.grid-view {
        grid-template-columns: 1fr;
    }
}
