/* ============================================================
   exc.css — Math Exercise Hub (v5)
   "The Mathematical Nexus"
   ============================================================ */

/* ── Fonts ── */
@font-face {
    font-family: 'Angsana New';
    src: url('../Angsana New/Angsana New.woff2') format('woff2'),
        url('../Angsana New/Angsana New.woff') format('woff'),
        url('../Angsana New/Angsana New.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary-h: 158;
    --primary-s: 64%;
    --primary-l: 45%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-glow: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.2);
    
    --accent-h: 84;
    --accent-s: 81%;
    --accent-l: 44%;
    --accent: hsl(var(--accent-h), var(--accent-s), var(--accent-l));
    
    --bg-light: #f0fdf4; /* Very light mint */
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(16, 185, 129, 0.2);
    --text-bright: #064e3b; /* Deep emerald */
    --text-dim: #374151;
    
    --radius-xl: 40px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-deep: 0 10px 30px rgba(6, 78, 59, 0.08);
}

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

body {
    font-family: 'Angsana New', 'Sarabun', sans-serif;
    background: var(--bg-light);
    color: var(--text-bright);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    perspective: 1200px;
}

/* ── Animated Math Background ── */
.math-nexus-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: 
        radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(56, 189, 248, 0.1) 0%, transparent 40%);
    overflow: hidden;
}

.floating-symbol {
    position: absolute;
    font-size: 5rem;
    font-weight: 900;
    color: rgba(16, 185, 129, 0.05); /* Soft green icons */
    user-select: none;
    pointer-events: none;
    animation: drift 20s infinite linear;
}

@keyframes drift {
    from { transform: translate(0, 0) rotate(0deg); }
    to { transform: translate(100px, 100px) rotate(360deg); }
}

/* ── Header ── */
.nexus-header {
    padding: 40px 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(240, 253, 244, 0.8), transparent);
    backdrop-filter: blur(5px);
    z-index: 100;
}

.brand-nexus {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-icon {
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

.brand-text h1 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
}

.brand-text p {
    font-size: 1.1rem;
    color: var(--text-dim);
}

.nav-actions {
    display: flex;
    gap: 20px;
}

.action-btn {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 12px 24px;
    border-radius: 50px;
    color: var(--text-bright);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
    transform: translateY(-2px);
}

/* ── Main Dashboard ── */
.dashboard-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px 60px 100px;
    width: 100%;
}

.welcome-banner {
    margin-bottom: 60px;
    text-align: center;
}

.welcome-banner h2 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 15px;
}

.search-nexus {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 20px 30px;
    border-radius: 50px;
    color: #fff;
    font-family: inherit;
    font-size: 1.2rem;
    outline: none;
    transition: all 0.3s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
}

/* ── Topic Grid ── */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 40px;
}

.card-perspective {
    perspective: 1000px; /* Individual perspective for tilt */
}

.topic-card {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    height: 100%;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s ease-out, box-shadow 0.3s;
    transform-style: preserve-3d;
    box-shadow: var(--shadow-deep);
}

.topic-card:hover {
    box-shadow: 0 20px 40px rgba(6, 78, 59, 0.1), 0 0 30px rgba(16, 185, 129, 0.1);
}

/* ── Special Card: Math Game ── */
.topic-card.game-card {
    border: 2px solid rgba(245, 158, 11, 0.4);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 251, 235, 0.8));
    overflow: hidden;
}

.topic-card.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.1), transparent);
    pointer-events: none;
}

.topic-card.game-card:hover {
    box-shadow: 0 20px 40px rgba(245, 158, 11, 0.2), 0 0 30px rgba(245, 158, 11, 0.3);
    transform: rotateX(2deg) rotateY(2deg) translateY(-15px) !important;
}

.topic-card.game-card .card-tag {
    background: #f59e0b;
    color: white;
}

.card-tag {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
}

.topic-card h3 {
    font-size: 2.22rem;
    font-weight: 800;
    margin-bottom: 5px;
    letter-spacing: -0.02em;
    transform: translateZ(20px); /* 3D pop */
}

.topic-card p {
    font-size: 1.35rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 30px;
    line-height: 1.2;
    transform: translateZ(10px);
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-group {
    display: flex;
    gap: 15px;
    color: var(--text-dim);
    font-size: 1rem;
}

.enter-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.topic-card:hover .enter-icon {
    background: var(--primary);
    transform: scale(1.1) rotate(45deg);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* ── HUD / Tooltip ── */
.nexus-hud {
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 1000;
}

.hud-bubble {
    background: var(--primary);
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 800;
    box-shadow: 0 10px 30px var(--primary-glow);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .nexus-header { padding: 30px; }
    .dashboard-container { padding: 20px 30px 100px; }
    .topic-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ── */
.hidden { display: none !important; }
.text-accent { color: var(--accent); }

/* ── Breadcrumbs ── */
.nexus-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dim);
}

.breadcrumb-item {
    cursor: pointer;
    transition: color 0.3s;
}

.breadcrumb-item:hover { color: var(--text-bright); }
.breadcrumb-separator { color: var(--primary); opacity: 0.5; }
.breadcrumb-current { color: var(--primary); }

/* ── Sub-topic View ── */
.subtopic-view {
    animation: slideIn 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.subtopic-header {
    margin-bottom: 40px;
    display: flex;
    align-items: baseline;
    gap: 20px;
}

.subtopic-header h2 {
    font-size: 3rem;
    font-weight: 900;
}

.sub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.sub-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s;
}

.sub-card:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    transform: translateX(10px);
}

.sub-card-info h4 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.sub-card-info span {
    font-size: 1rem;
    color: var(--text-dim);
}

/* ── Animations ── */
@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

.view-exit { animation: fadeOut 0.3s ease forwards; }
