/* ==========================================================================
   ANIME-DATABASE MODERN DESIGN TOKENS (style.css)
   ========================================================================== */
:root {
    --bg-dark: #0b1622;
    --bg-card: #152232;
    --bg-input: #1f2d3d;
    --text-main: #edf1f5;
    --text-muted: #8ba0b2;
    --accent-blue: #3db4f2;
    --accent-green: #00ffaa;
    --accent-red: #ff4a6a;
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* --- GLOBAL JAPANESE FONT MAP --- */
    --font-noto: 'Noto Sans JP', sans-serif;
    --font-serif: 'Kaisei Tokumin', serif;
    --font-hina: 'Hina Mincho', serif;
    --font-brush: 'Yuji Syuku', serif;
    --font-yomogi: 'Yomogi', sans-serif;
    --font-hachi: 'Hachi Maru Pop', sans-serif;
    --font-mochiy: 'Mochiy Pop One', sans-serif;
    --font-rounded: 'Zen Maru Gothic', sans-serif;
    --font-pixel: 'DotGothic16', sans-serif;
    --font-carved: 'Chokokutai', sans-serif;
    --font-bomb: 'Cherry Bomb One', sans-serif;
    --font-zoo: 'Zen Tokyo Zoo', sans-serif;
}

/* Base Layout & Ambient Glow */
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    background-image: radial-gradient(circle at 50% -20%, #1e375a 0%, var(--bg-dark) 60%);
}

.app-layout {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Controls Grid Row Layout */
.controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Custom Dropdown Menus */
.selector-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.selector-container label {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-blue);
}

.selector-container select {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 14px 20px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    width: 100%;
}

.selector-container select:hover {
    background-color: var(--bg-input);
    border-color: rgba(61, 180, 242, 0.4);
}

.selector-container optgroup {
    background: var(--bg-card);
    color: var(--accent-blue);
    font-weight: bold;
}

.selector-container option {
    color: var(--text-main);
    font-weight: normal;
}

/* Main UI Frame */
.card {
    background-color: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 40px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Status Indicators */
.status-badge {
    position: absolute;
    top: 0;
    right: 0;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 1px;
    padding: 6px 16px;
    border-bottom-left-radius: 12px;
    background: #2b3a4a;
    color: var(--text-muted);
}
.status-online { background: rgba(0, 255, 170, 0.15); color: var(--accent-green); }
.status-loading { background: rgba(61, 180, 242, 0.15); color: var(--accent-blue); }
.status-offline { background: rgba(255, 74, 106, 0.15); color: var(--accent-red); }

/* Center Display Text */
.word-showcase {
    text-align: center;
    margin-bottom: 35px;
    width: 100%;
}

.kanji {
    font-family: var(--font-body);
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 8px;
    text-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.2s ease-in-out;
    min-height: 5.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.meaning {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Input Typing Box Display */
.romaji-wrapper {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 18px;
    border-radius: 14px;
    font-family: 'Space Grotesk', monospace;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    box-sizing: border-box;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}

.typed {
    color: var(--accent-green);
    text-shadow: 0 0 12px rgba(0, 255, 170, 0.4);
}

.untyped {
    color: rgba(237, 241, 245, 0.15);
}

/* Score Footers */
.score-panel {
    margin-top: 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 25px;
}

.score-panel .label {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.5px;
}

.score-panel .value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-blue);
    font-family: var(--font-heading);
    text-shadow: 0 0 15px rgba(61, 180, 242, 0.3);
}

/* --- DYNAMIC CLASS OVERRIDES FOR FONTS --- */
.kanji.font-modern  { font-family: var(--font-body); font-weight: 800; }
.kanji.font-noto    { font-family: var(--font-noto); font-weight: 700; }
.kanji.font-serif   { font-family: var(--font-serif); font-weight: 700; }
.kanji.font-hina    { font-family: var(--font-hina); font-weight: 400; }
.kanji.font-brush   { font-family: var(--font-brush); font-weight: 400; }
.kanji.font-yomogi  { font-family: var(--font-yomogi); font-weight: 400; }
.kanji.font-hachi   { font-family: var(--font-hachi); font-weight: 400; }
.kanji.font-mochiy  { font-family: var(--font-mochiy); font-weight: 400; }
.kanji.font-rounded { font-family: var(--font-rounded); font-weight: 700; }
.kanji.font-pixel   { font-family: var(--font-pixel); font-weight: 400; font-size: 3.8rem; }
.kanji.font-carved  { font-family: var(--font-carved); font-weight: 400; }
.kanji.font-bomb    { font-family: var(--font-bomb); font-weight: 400; }
.kanji.font-zoo     { font-family: var(--font-zoo); font-weight: 400; font-size: 3.5rem; }

/* ==========================================================================
   DYNAMIC ROMAJI HINT TOGGLE UTILITIES
   ========================================================================== */
.romaji-wrapper {
    position: relative;
    min-height: 76px; /* Prevents card bouncing when toggling contents */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Prompt Layout */
.romaji-prompt {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Actual Typing Containers */
.romaji-text-container {
    opacity: 1;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}

/* 🌟 DYNAMIC HIDDEN TOGGLE STATE CLASSES */
.hidden-romaji .romaji-prompt {
    opacity: 1;
}

.hidden-romaji .romaji-text-container {
    opacity: 0;
}

/* ==========================================================================
   UPDATED CLICK-TO-REVEAL MEANING ENGINE (No layout shifting)
   ========================================================================== */
.meaning-wrapper {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* 🌟 FIX: Lock the frame height so long text never moves elements below it */
    min-height: 40px; 
    width: 100%;
}

.meaning-wrapper:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* 🌟 FIX: Pull the prompt and definitions into absolute positioning 
   layers so they float independently of the document flow */
.meaning-prompt {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent-blue);
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    inset: 0;
    
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease;
}

.meaning-wrapper .meaning {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    inset: 0;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-muted);
    
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: opacity 0.2s ease;
}

/* 🌟 FORCE TOGGLE STATES WITHOUT LAYOUT SHIFT */
.hidden-meaning .meaning-prompt {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.hidden-meaning .meaning {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==========================================================================
   FOOTER ACTIONS & KO-FI INTEGRATION
   ========================================================================== */
.footer-actions {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.kofi-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 12px 24px;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Micro-interaction signature color shift on hover */
.kofi-btn:hover {
    background-color: #ff5e5b; /* Ko-fi Brand Red/Coral */
    color: var(--text-main);
    border-color: #ff5e5b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 94, 91, 0.3);
}

.kofi-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.kofi-btn:hover .kofi-icon {
    transform: rotate(-5deg) scale(1.1);
}
