/* ==========================================================================
   Ngọc Diệp Portal - Custom CSS System
   ========================================================================== */

:root {
    /* Color Palette - Day Mode */
    --day-bg-gradient: linear-gradient(135deg, #FFEBEB 0%, #E8F5FF 100%);
    --day-text: #2C3E50;
    --day-card-bg: rgba(255, 255, 255, 0.8);
    --day-math-theme: linear-gradient(135deg, #FF9F43 0%, #FF6B6B 100%);
    --day-english-theme: linear-gradient(135deg, #1DD1A1 0%, #10AC84 100%);
    --day-footer-text: #7F8C8D;

    /* Color Palette - Night Mode */
    --night-bg-gradient: linear-gradient(135deg, #1E1B29 0%, #0F0C1B 100%);
    --night-text: #ECF0F1;
    --night-card-bg: rgba(30, 27, 47, 0.7);
    --night-math-theme: linear-gradient(135deg, #FF6B6B 0%, #EE5253 100%);
    --night-english-theme: linear-gradient(135deg, #10AC84 0%, #018967 100%);
    --night-footer-text: #95A5A6;

    /* Fonts and Glows */
    --font-rounded: 'Quicksand', sans-serif;
    --glow-shadow-math: 0 10px 30px rgba(255, 107, 107, 0.4);
    --glow-shadow-english: 0 10px 30px rgba(16, 172, 132, 0.4);
}

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

body {
    font-family: var(--font-rounded);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    transition: background 0.8s ease, color 0.8s ease;
    position: relative;
}

/* Color Modes Mapping */
body.day-mode {
    background: var(--day-bg-gradient);
    color: var(--day-text);
}

body.night-mode {
    background: var(--night-bg-gradient);
    color: var(--night-text);
}

/* Portal Wrapper Container */
.portal-container {
    width: 100%;
    max-width: 1200px;
    padding: 40px 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 90vh;
}

/* Header Section */
.portal-header {
    text-align: center;
    margin-bottom: 40px;
}

.header-logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.header-emoji {
    font-size: 3rem;
    animation: bounce 2s infinite ease-in-out;
}

.portal-header h1 {
    font-size: 3rem;
    font-weight: 700;
}

body.day-mode .portal-header h1 {
    color: #2c3e50;
}
body.day-mode .portal-header h1 span {
    color: #ff6b6b;
}

body.night-mode .portal-header h1 {
    color: #ffffff;
}
body.night-mode .portal-header h1 span {
    color: #1dd1a1;
}

.header-subtitle {
    font-size: 1.3rem;
    font-weight: 500;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto 20px auto;
}

/* Theme Toggle Button */
.header-controls {
    display: flex;
    justify-content: center;
}

.theme-toggle-btn {
    font-family: var(--font-rounded);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.day-mode .theme-toggle-btn {
    background: #2c3e50;
    color: #ffffff;
}

body.night-mode .theme-toggle-btn {
    background: #ffffff;
    color: #2c3e50;
}

.theme-toggle-btn:hover, .theme-toggle-btn:focus {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    outline: none;
}

/* Main Cards Area */
.portal-main {
    width: 100%;
    margin-bottom: 40px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 40px;
    width: 100%;
    justify-content: center;
}

/* Subject Card Styles */
.subject-card {
    text-decoration: none;
    color: inherit;
    border-radius: 32px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 420px;
    text-align: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid transparent;
}

body.day-mode .subject-card {
    background: var(--day-card-bg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
}

body.night-mode .subject-card {
    background: var(--night-card-bg);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

/* Card Glow Overlay */
.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 32px;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.card-math .card-glow {
    background: radial-gradient(circle, rgba(255, 107, 107, 0.15) 0%, transparent 70%);
}

.card-english .card-glow {
    background: radial-gradient(circle, rgba(29, 209, 161, 0.15) 0%, transparent 70%);
}

.subject-card:hover .card-glow, .subject-card:focus .card-glow {
    opacity: 1;
}

/* Card Contents styling */
.card-icon {
    font-size: 5.5rem;
    margin-bottom: 20px;
    z-index: 2;
    transition: transform 0.4s ease;
}

.subject-card:hover .card-icon, .subject-card:focus .card-icon {
    transform: scale(1.15) rotate(5deg);
}

.card-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    z-index: 2;
}

.card-math .card-title {
    background: var(--day-math-theme);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-english .card-title {
    background: var(--day-english-theme);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-desc {
    font-size: 1.15rem;
    line-height: 1.6;
    margin-bottom: 30px;
    opacity: 0.85;
    z-index: 2;
    max-width: 320px;
}

/* Card CTA button */
.card-action {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 15px 35px;
    border-radius: 50px;
    color: #ffffff;
    z-index: 2;
    transition: all 0.3s ease;
}

.card-math .card-action {
    background: var(--day-math-theme);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.card-english .card-action {
    background: var(--day-english-theme);
    box-shadow: 0 4px 15px rgba(16, 172, 132, 0.3);
}

/* Floating emojis inside card */
.card-floating-emojis {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.card-floating-emojis span {
    position: absolute;
    font-size: 1.5rem;
    opacity: 0.15;
    transition: transform 0.8s ease, opacity 0.4s ease;
}

.card-floating-emojis span:nth-child(1) { top: 15%; left: 15%; }
.card-floating-emojis span:nth-child(2) { top: 20%; right: 15%; }
.card-floating-emojis span:nth-child(3) { bottom: 25%; left: 10%; }
.card-floating-emojis span:nth-child(4) { bottom: 20%; right: 12%; }

.subject-card:hover .card-floating-emojis span, .subject-card:focus .card-floating-emojis span {
    opacity: 0.6;
}

.subject-card:hover .card-floating-emojis span:nth-child(odd) {
    transform: translateY(-10px) rotate(15deg);
}

.subject-card:hover .card-floating-emojis span:nth-child(even) {
    transform: translateY(-15px) rotate(-15deg);
}

/* HOVER & FOCUS EFFECTS (Magic Remote / TV) */
.subject-card:hover, .subject-card:focus {
    transform: translateY(-10px);
    outline: none;
}

.card-math:hover, .card-math:focus {
    box-shadow: var(--glow-shadow-math);
    border-color: #ff6b6b;
}

.card-english:hover, .card-english:focus {
    box-shadow: var(--glow-shadow-english);
    border-color: #1dd1a1;
}

/* ACTIVE TV FOCUS INDICATOR */
.subject-card.tv-focused {
    transform: scale(1.03) translateY(-10px);
}
.card-math.tv-focused {
    box-shadow: var(--glow-shadow-math);
    border-color: #ff6b6b;
}
.card-english.tv-focused {
    box-shadow: var(--glow-shadow-english);
    border-color: #1dd1a1;
}

/* Footer Section */
.portal-footer {
    text-align: center;
    font-size: 1.05rem;
    line-height: 1.6;
}

body.day-mode .portal-footer { color: var(--day-footer-text); }
body.night-mode .portal-footer { color: var(--night-footer-text); }

.copyright {
    margin-top: 8px;
    font-weight: 700;
    font-size: 0.95rem;
}

/* Decorative Background Bubbles */
.bubble {
    position: absolute;
    pointer-events: none;
    font-size: 2.5rem;
    z-index: 1;
    opacity: 0.15;
    animation: floatBackground 8s infinite ease-in-out;
}

.bubble-1 { top: 10%; left: 8%; animation-delay: 0s; }
.bubble-2 { top: 15%; right: 8%; animation-delay: 2s; }
.bubble-3 { bottom: 15%; left: 6%; animation-delay: 4s; }
.bubble-4 { bottom: 12%; right: 6%; animation-delay: 6s; }
.bubble-5 { top: 50%; left: 45%; animation-delay: 1s; font-size: 3rem; }
.bubble-6 { bottom: 45%; right: 45%; animation-delay: 3s; }

/* Animations */
@keyframes floatBackground {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-25px) rotate(15deg);
    }
}

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

/* Responsive Scaling for smaller screens/TVs */
@media (max-width: 900px) {
    .cards-grid {
        grid-template-columns: 1fr;
        max-width: 500px;
    }
    .subject-card {
        min-height: 380px;
        padding: 30px 20px;
    }
    .portal-header h1 {
        font-size: 2.4rem;
    }
}
