/* ============================================================
   main.css — Junior Math · หน้าหลัก
   ============================================================ */

/* ── Font ── */
@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'),
        url('../Angsana New/angsana.ttc') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ── Design Tokens (same palette as page.css) ── */
:root {
    --primary: #1a237e;
    --primary-light: #3949ab;
    --secondary: #0097a7;
    --accent: #ff6f00;
    --positive: #2e7d32;
    --negative: #c62828;
    --zero: #6a1b9a;
    --bg: #f0f4ff;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #5c6bc0;
    --border: #c5cae9;
    --shadow: 0 4px 24px rgba(26, 35, 126, .10);
    --radius: 18px;
    --radius-sm: 10px;
}

/* ── Reset ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Angsana New', 'Sarabun', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ══════════════════════════════════════
   HERO HEADER
══════════════════════════════════════ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, var(--secondary) 100%);
    color: #fff;
    padding: 56px 24px 48px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -80px;
    width: 320px;
    height: 320px;
    background: rgba(255, 255, 255, .06);
    border-radius: 50%;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -100px;
    left: -60px;
    width: 380px;
    height: 380px;
    background: rgba(255, 255, 255, .04);
    border-radius: 50%;
}

/* floating math symbols */
.hero-deco {
    position: absolute;
    font-size: 3.5rem;
    opacity: .07;
    user-select: none;
    pointer-events: none;
    animation: floatY 6s ease-in-out infinite;
}

.hero-deco:nth-child(1) {
    top: 12%;
    left: 6%;
    animation-delay: 0s;
}

.hero-deco:nth-child(2) {
    top: 20%;
    right: 8%;
    animation-delay: 1.2s;
}

.hero-deco:nth-child(3) {
    bottom: 18%;
    left: 12%;
    animation-delay: 2.4s;
}

.hero-deco:nth-child(4) {
    bottom: 12%;
    right: 5%;
    animation-delay: .6s;
}

.hero-deco:nth-child(5) {
    top: 50%;
    left: 2%;
    animation-delay: 1.8s;
}

@keyframes floatY {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-14px);
    }
}

.hero-badge {
    display: inline-block;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50px;
    padding: 5px 20px;
    font-size: 16px;
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.hero h1 {
    font-size: clamp(2.2rem, 6vw, 4rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.hero h1 span {
    font-size: .55em;
    opacity: .88;
    display: block;
    font-weight: 400;
}

.hero .subtitle {
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    opacity: .82;
    margin-bottom: 28px;
}

/* ── Search bar ── */
.search-wrap {
    position: relative;
    max-width: 440px;
    margin: 0 auto;
    z-index: 1;
}

.search-wrap input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    border: none;
    border-radius: 50px;
    font-family: 'Angsana New', sans-serif;
    font-size: 1rem;
    background: rgba(255, 255, 255, .92);
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .18);
    outline: none;
    transition: box-shadow .2s;
}

.search-wrap input:focus {
    box-shadow: 0 6px 28px rgba(0, 0, 0, .28);
}

.search-wrap .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* ── Stats Strip ── */
.stats-strip {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    padding: 20px 24px;
    background: rgba(255, 255, 255, .08);
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.stat-item {
    text-align: center;
    color: rgba(255, 255, 255, .9);
}

.stat-num {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: .85rem;
    opacity: .78;
    margin-top: 2px;
}

/* ══════════════════════════════════════
   MAIN CONTAINER
══════════════════════════════════════ */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

/* ── Section heading ── */
.section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.section-heading h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.section-heading .line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, var(--border), transparent);
}

/* ══════════════════════════════════════
   TOPIC GRID
══════════════════════════════════════ */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 22px;
}

/* ── Topic Card ── */
.topic-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .22s, box-shadow .22s;
    cursor: pointer;
    border-top: 4px solid var(--primary-light);
    position: relative;
}

.topic-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(26, 35, 126, .18);
}

.topic-card:hover .card-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* accent-color variants */
.topic-card.c-green {
    border-top-color: var(--positive);
}

.topic-card.c-orange {
    border-top-color: var(--accent);
}

.topic-card.c-teal {
    border-top-color: var(--secondary);
}

.topic-card.c-purple {
    border-top-color: var(--zero);
}

.topic-card.c-red {
    border-top-color: var(--negative);
}

.topic-card.c-blue {
    border-top-color: var(--primary);
}

.card-icon-wrap {
    width: 100%;
    height: 150px;
    /* Adjusted height for text symbols */
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8eaf6 0%, #f5f6ff 100%);
    transition: background .3s;
}

.topic-card.c-blue .card-icon-wrap {
    background: linear-gradient(135deg, #e3f2fd, #e8eaf6);
}

.topic-card.c-green .card-icon-wrap {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
}

.topic-card.c-orange .card-icon-wrap {
    background: linear-gradient(135deg, #fff3e0, #fff8e1);
}

.topic-card.c-teal .card-icon-wrap {
    background: linear-gradient(135deg, #e0f7fa, #e0f2f1);
}

.topic-card.c-purple .card-icon-wrap {
    background: linear-gradient(135deg, #f3e5f5, #ede7f6);
}

.topic-card.c-red .card-icon-wrap {
    background: linear-gradient(135deg, #ffebee, #fce4ec);
}

.card-icon {
    font-size: 3.5rem;
    /* Adjusted size for symbols */
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .28s cubic-bezier(.34, 1.56, .64, 1), filter .28s;
    user-select: none;
    text-align: center;
    color: var(--primary);
    /* Default symbol color */
}

.topic-card.c-green .card-icon {
    color: var(--positive);
}

.topic-card.c-orange .card-icon {
    color: var(--accent);
}

.topic-card.c-teal .card-icon {
    color: var(--secondary);
}

.topic-card.c-purple .card-icon {
    color: var(--zero);
}

.topic-card.c-red .card-icon {
    color: var(--negative);
}


.topic-card:hover .card-icon {
    transform: scale(1.18) translateY(-4px);
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .18));
}


.card-body {
    padding: 18px 20px 20px;
}

.card-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.topic-card.c-green .card-num {
    background: var(--positive);
}

.topic-card.c-orange .card-num {
    background: var(--accent);
}

.topic-card.c-teal .card-num {
    background: var(--secondary);
}

.topic-card.c-purple .card-num {
    background: var(--zero);
}

.topic-card.c-red .card-num {
    background: var(--negative);
}

.card-title-en {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.card-title-th {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-sub-list {
    list-style: none;
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card-sub-list li a {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: .82rem;
    color: var(--text-muted);
    transition: background .18s, color .18s, border-color .18s;
}

.card-sub-list li a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.card-footer {
    padding: 10px 20px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
}

.card-count {
    font-size: .82rem;
    color: var(--text-muted);
}

.card-arrow {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity .22s, transform .22s;
}

.topic-card.c-green .card-arrow {
    background: var(--positive);
}

.topic-card.c-orange .card-arrow {
    background: var(--accent);
}

.topic-card.c-teal .card-arrow {
    background: var(--secondary);
}

.topic-card.c-purple .card-arrow {
    background: var(--zero);
}

.topic-card.c-red .card-arrow {
    background: var(--negative);
}

/* ── hidden card (search filter) ── */
.topic-card.hidden {
    display: none;
}

/* ── No results ── */
#no-results {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

#no-results .no-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
footer {
    background: var(--primary);
    color: rgba(255, 255, 255, .75);
    text-align: center;
    padding: 24px 20px;
    font-size: .9rem;
}

footer strong {
    color: #fff;
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 600px) {
    .stats-strip {
        gap: 24px;
    }

    .topic-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Back Button ── */
.back-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s, transform .2s;
    z-index: 10;
}

.back-btn:hover {
    background: rgba(255, 255, 255, .25);
    transform: translateY(-2px);
}

.back-icon {
    font-size: 1.2rem;
    line-height: 1;
}
/*  Back Button  */
.back-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s, transform .2s;
    z-index: 10;
}

.back-btn:hover {
    background: rgba(255, 255, 255, .25);
    transform: translateY(-2px);
}

.back-icon {
    font-size: 1.2rem;
    line-height: 1;
}
