/* ═══════════════════════════════════════════════════════
   Sci-Word Parser — style.css
   Concept: Chalkboard Laboratory / Periodic Table
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
    --ink: #1e1e2e;
    --chalk: #e8e4dc;
    --board: #2b3a3f;
    --neon-blue: #60a5fa;
    --neon-green: #4ade80;
    --neon-amber: #fbbf24;
    --neon-red: #f87171;
    --paper: #f0ede6;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
}

/* ══════════════════════════════════════
   HERO — Chalkboard
   ══════════════════════════════════════ */
.hero {
    position: relative;
    overflow: hidden;
    background: var(--board);
    /* chalk dust texture */
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(255,255,255,0.02) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 20%, rgba(255,255,255,0.03) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='6' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1' height='1' x='0' y='0' fill='rgba(255,255,255,0.015)'/%3E%3C/svg%3E");
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#heroCanvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: #8b6914;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(139,105,20,0.3);
}

/* chalk tray */
.hero::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 18px;
    background: linear-gradient(180deg, #6b5a28, #8b6914 40%, #a07b1a);
    z-index: 3;
    border-top: 1px solid #a07b1a;
}

.hero-inner {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem 2rem 2.5rem;
}

/* formula label — like a chemistry equation */
.hero-formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.25);
    margin-bottom: 1.2rem;
    text-transform: uppercase;
}
.hero-formula span {
    color: var(--neon-green);
    opacity: 0.6;
}

/* Title — chalk writing */
.hero-title-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: clamp(0.3rem, 1vw, 0.6rem);
    margin-bottom: 0.5rem;
}
.ht-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(2.2rem, 5.5vw, 3.4rem);
    line-height: 1;
    cursor: default;
    transition: all 0.3s;
    text-shadow: 0 0 10px rgba(255,255,255,0.05);
}
.ht-char:hover {
    transform: translateY(-4px) scale(1.06);
    text-shadow: 0 0 20px rgba(255,255,255,0.15);
}
.ht-white {
    color: var(--chalk);
}
.ht-gold {
    color: var(--neon-amber);
    text-shadow: 0 0 12px rgba(251,191,36,0.2);
}
.ht-ghost {
    color: transparent;
    -webkit-text-stroke: 1px rgba(255,255,255,0.12);
}
.ht-ghost:hover {
    -webkit-text-stroke-color: rgba(255,255,255,0.3);
}

.hero-sub {
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255,255,255,0.2);
    letter-spacing: 8px;
    margin-bottom: 0.8rem;
}

.hero-line {
    width: 120px;
    height: 2px;
    margin: 0 auto 0.8rem;
    background: rgba(255,255,255,0.08);
    border-radius: 1px;
    position: relative;
}
.hero-line::after {
    content: '';
    position: absolute;
    left: 30%;
    right: 30%;
    top: 0;
    height: 100%;
    background: var(--neon-amber);
    opacity: 0.4;
    border-radius: 1px;
}

.hero-desc {
    font-size: 0.82rem;
    font-weight: 300;
    color: rgba(255,255,255,0.35);
    line-height: 2;
    max-width: 380px;
    margin: 0 auto;
}
.hero-desc em {
    font-style: normal;
    color: var(--neon-green);
    opacity: 0.7;
}



/* ══════════════════════════════════════
   CONTROLS
   ══════════════════════════════════════ */
.controls {
    max-width: 1100px;
    margin: 1.5rem auto 1rem;
    padding: 0 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.92rem;
    background: #fff;
    transition: all 0.25s;
    font-family: 'Noto Sans KR', sans-serif;
}
.search-box input:focus {
    outline: none;
    border-color: var(--board);
    box-shadow: 0 0 0 3px rgba(43,58,63,0.1);
}
.search-box .icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    opacity: 0.3;
}

.mode-tabs { display: flex; gap: 0.4rem; }
.mode-tab {
    padding: 0.65rem 1.3rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.2s;
    font-family: 'Noto Sans KR', sans-serif;
}
.mode-tab:hover { border-color: var(--board); }
.mode-tab.active {
    background: var(--board);
    color: var(--chalk);
    border-color: var(--board);
}


/* ══════════════════════════════════════
   CATEGORY CHIPS
   ══════════════════════════════════════ */
.category-bar {
    max-width: 1100px;
    margin: 0.5rem auto 1.2rem;
    padding: 0 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.cat-chip {
    padding: 0.35rem 0.9rem;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid;
    transition: all 0.2s;
}
.cat-chip:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.cat-chip.active { color: #fff !important; }


/* ══════════════════════════════════════
   STATS BAR
   ══════════════════════════════════════ */
.stats-bar {
    max-width: 1100px;
    margin: 0 auto 1rem;
    padding: 0 1.5rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.78rem;
    color: #999;
    font-family: 'JetBrains Mono', monospace;
}
.stat-item { display: flex; align-items: center; gap: 0.3rem; }
.stat-num { font-weight: 700; color: var(--board); }


/* ══════════════════════════════════════
   3-COLUMN GRID
   ══════════════════════════════════════ */
.grid-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 1rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}


/* ══════════════════════════════════════
   GRID CARD — Periodic Table Element
   ══════════════════════════════════════ */
.grid-card {
    background: #fff;
    border-radius: 6px;
    padding: 1rem 1rem 1.2rem;
    border: 2px solid #e8e4dc;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.grid-card:hover {
    border-color: var(--board);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    transform: translateY(-6px);
}

/* top color bar like periodic table element */
.grid-card .gc-badge {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: 0;
    font-size: 0;
    color: transparent;
    overflow: hidden;
}

/* element number style category label */
.grid-card .gc-cat-label {
    align-self: flex-end;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.58rem;
    font-weight: 600;
    color: #aaa;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.grid-card .gc-hanja {
    font-family: 'Noto Serif KR', serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--ink);
    line-height: 1;
    margin-bottom: 0.3rem;
    transition: all 0.3s;
}
.grid-card:hover .gc-hanja {
    color: var(--neon-red);
    transform: scale(1.08);
}

.grid-card .gc-term {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 0.1rem;
    color: var(--ink);
}
.grid-card .gc-hanja-sm {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: #bbb;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.grid-card .gc-meaning {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    background: #f5f3ee;
    color: #888;
    border: 1px solid #e8e4dc;
}


/* ══════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════ */
.pagination {
    max-width: 1100px;
    margin: 1rem auto 3rem;
    padding: 0 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
}
.page-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.page-btn:hover { border-color: var(--board); }
.page-btn.active {
    background: var(--board);
    color: var(--chalk);
    border-color: var(--board);
}
.page-btn.arrow { font-size: 1rem; }
.page-btn:disabled { opacity: 0.2; cursor: not-allowed; pointer-events: none; }


/* ══════════════════════════════════════
   MODAL
   ══════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}
.modal-card {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 30px 100px rgba(0,0,0,0.5);
    transform: translateY(40px) scale(0.96);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.open .modal-card {
    transform: translateY(0) scale(1);
}

/* Modal header — element card style */
.modal-header {
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    position: relative;
    background: var(--board);
    color: var(--chalk);
}
.modal-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.modal-header .mh-hanja {
    font-family: 'Noto Serif KR', serif;
    font-size: 5rem;
    font-weight: 900;
    color: var(--chalk);
    line-height: 1;
    margin-bottom: 0.4rem;
    letter-spacing: 6px;
}
.modal-header .mh-term {
    font-size: 1.3rem;
    font-weight: 900;
    color: #fff;
}
.modal-header .mh-hanja-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    margin-top: 0.2rem;
}
.modal-header .mh-badge {
    display: inline-block;
    margin-top: 0.6rem;
    padding: 0.2rem 0.7rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Modal body */
.modal-body { padding: 1.8rem 2rem 2rem; }

.definition {
    background: #faf8f4;
    border-left: 3px solid var(--neon-amber);
    padding: 1rem 1.2rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 1.1rem;
    font-size: 0.93rem;
    line-height: 1.9;
}

.lore-box {
    background: #f0f4ff;
    border-left: 3px solid var(--neon-blue);
    padding: 1rem 1.2rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 1.1rem;
    font-size: 0.86rem;
    line-height: 1.9;
    color: #1e3a5f;
}
.lore-box .lore-title {
    font-weight: 700;
    color: var(--neon-blue);
    margin-bottom: 0.3rem;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 1px;
}

.sci-note {
    background: #f0faf0;
    border-left: 3px solid var(--neon-green);
    padding: 1rem 1.2rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 1.1rem;
    font-size: 0.84rem;
    line-height: 1.9;
    color: #14532d;
}
.sci-note .sci-title {
    font-weight: 700;
    color: #16a34a;
    margin-bottom: 0.3rem;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 1px;
}

/* Anatomy */
.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--board);
    margin-bottom: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 1px;
}
.anatomy {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.1rem;
    justify-content: center;
}
.atom {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.7rem 0.9rem;
    background: #fff;
    border: 2px solid #e8e4dc;
    border-radius: 6px;
    min-width: 78px;
    transition: all 0.25s;
}
.atom:hover {
    border-color: var(--neon-blue);
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(96,165,250,0.12);
}
.atom .char {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--ink);
}
.atom:hover .char { color: var(--neon-blue); }
.atom .reading {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--ink);
    margin-top: 2px;
}
.atom .meaning-sm {
    font-size: 0.68rem;
    color: #999;
    margin-top: 2px;
}

/* Pills */
.example-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.9rem;
}
.pill {
    padding: 0.25rem 0.7rem;
    background: #f5f3ee;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #555;
    transition: all 0.2s;
    border: 1px solid #e8e4dc;
}
.pill:hover { background: #ece8df; border-color: #d5d0c5; }

/* Similar */
.similar-section {
    border-top: 1px solid #eee;
    padding-top: 0.8rem;
    margin-top: 0.6rem;
}
.similar-card {
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
}
.similar-card h4 { font-size: 0.88rem; font-weight: 700; margin-bottom: 0.15rem; color: var(--neon-red); }
.similar-card p { font-size: 0.78rem; color: #888; line-height: 1.6; }


/* ══════════════════════════════════════
   QUIZ
   ══════════════════════════════════════ */
.quiz-container { max-width: 600px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.quiz-card {
    background: #fff;
    border-radius: 8px;
    padding: 3rem 2rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    text-align: center;
    border: 2px solid #e8e4dc;
}
.quiz-hanja {
    font-family: 'Noto Serif KR', serif;
    font-size: 4.5rem;
    font-weight: 900;
    color: var(--ink);
    margin-bottom: 0.5rem;
}
.quiz-prompt { font-size: 1rem; color: #888; margin-bottom: 2rem; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.quiz-option {
    padding: 1rem;
    border: 2px solid #e8e4dc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.2s;
    background: #fff;
}
.quiz-option:hover { border-color: var(--board); }
.quiz-option.correct { border-color: var(--neon-green); background: #f0fdf4; color: #166534; }
.quiz-option.wrong { border-color: var(--neon-red); background: #fef2f2; color: #991b1b; }
.quiz-score { display: flex; justify-content: center; gap: 2rem; margin-top: 1.5rem; font-size: 0.85rem; color: #888; }
.quiz-score span { font-weight: 700; font-size: 1.2rem; }
.quiz-next {
    margin-top: 1.5rem;
    padding: 0.8rem 2.5rem;
    background: var(--board);
    color: var(--chalk);
    border: none;
    border-radius: 6px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.quiz-next:hover { background: #1e2a2e; }


/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 900px) {
    .grid-container { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 580px) {
    .grid-container { grid-template-columns: 1fr; }
    .controls { flex-direction: column; }
    .mode-tabs { width: 100%; justify-content: center; }
    .quiz-options { grid-template-columns: 1fr; }
    .modal-body { padding: 1.2rem 1.2rem 1.5rem; }
    .modal-header { padding: 1.5rem 1.2rem 1.2rem; }
    .modal-header .mh-hanja { font-size: 3.5rem; }
}


/* ══════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.grid-card {
    animation: fadeUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
}
.hidden { display: none !important; }

.modal-card::-webkit-scrollbar { width: 4px; }
.modal-card::-webkit-scrollbar-track { background: transparent; }
.modal-card::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }
