/* css/style.css - Styles for the Flashcard App */
/* --- 1. THE FOUNDATION (Total Viewport Control) --- */
:root {
    --color-ocean: #4682b4;
    --color-snow: #f8f8ff;
    --color-ink: #212529;
    --color-smoke: #dee2e6;
    --color-red: #ff5252;
    --color-green: #4caf50;
    --color-neon-green: #81c784;
    --bg-header: lightyellow;
    --bg-footer: plum;
    --bg-prev: lightcoral;
    --bg-next: lightskyblue;
    --bg-card: honeydew;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent the bounce/scroll on mobile completely */
html, body {
    height: 100%;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, system-ui, sans-serif;
    background-color: var(--color-ink);
}

html {
    min-height: -webkit-fill-available;
}

body {
    min-height: -webkit-fill-available;
}

/* --- 2. APP HEADER (Fixed Height) --- */
.app-header {
    height: 4.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    background-color: var(--bg-header);
    border-bottom: 2px solid gold;
    z-index: 100;
}

#card-counter { width: 25%; font-size: 0.9rem; font-weight: bold; color: #444; }
.search-container { flex-grow: 1; padding: 0 0.5rem; }
.search-container input {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 2rem;
    border: 1px solid var(--color-smoke);
    outline: none;
}
#menuBtn { width: 15%; text-align: right; background: none; border: none; font-size: 2rem; cursor: pointer; }

/* --- 3. MIDDLE SECTION (Navigation & Card) --- */
.card-view {
    flex-grow: 1; /* Takes exactly what's left between header and footer */
    min-height: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    background-color: var(--color-ink);
}

.nav-zone {
    width: 12%; /* Slightly narrower for better card space */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}
.nav-zone:active { opacity: 0.7; }
#prevZone { background-color: var(--bg-prev); }
#nextZone {
    background-color: var(--bg-next);
    color: white;
    font-weight: bold;
    line-height: 1;
}
#prevZone::after { content: '<'; font-size: 2.5rem; color: white; font-weight: bold; }
#nextZone.mode-weighted { font-size: 2rem; }
#nextZone.mode-sequential { font-size: 2.5rem; }

/* --- 4. THE CARD (Your Inner Structure) --- */
.card-container {
    flex-grow: 1;
    position: relative;
    background: var(--bg-card);
    perspective: 1000px;
    display: flex;
    flex-direction: column;
}

.card-inner {
    width: 100%;
    flex-grow: 1;
    min-height: 0;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-inner.is-flipped { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    background: white;
}

.card-back { transform: rotateY(180deg); background-color: aliceblue; }

/* Internal Card Grid */
.card-grid {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-header {
    height: 3.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    background: #fafafa;
    border-bottom: 1px solid var(--color-smoke);
}

.label { font-weight: bold; color: #666; font-size: 0.8rem; letter-spacing: 1px; }
.freq-btn { 
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 5px;
    border: transparent;
    background: transparent;
    cursor: pointer;
    font-size: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.card-body {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
}

.phrase { 
    font-size: clamp(1.2rem, 5vh, 3.5rem); 
    font-weight: 500; 
    line-height: 1.2;
    color: var(--color-ink);
    user-select: text;
    -webkit-user-select: text;
}

.audio-btn { font-size: 2rem; border: none; background: none; cursor: pointer; }

.card-controls {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 0.2rem 0.25rem;
    background: #fafafa;
    border-top: 1px solid var(--color-smoke);
}
.card-controls .audio-btn { grid-column: 2; grid-row: 1; justify-self: center; }
.card-controls .freq-down  { grid-column: 1; grid-row: 1 / span 2; align-self: center; justify-self: start; }
.card-controls .freq-up    { grid-column: 3; grid-row: 1 / span 2; align-self: center; justify-self: end; }
.card-score {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.8rem;
    color: #999;
    letter-spacing: 0.5px;
    min-height: 1.1rem;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-score.score-flash {
    color: var(--color-ocean);
    font-weight: bold;
}

/* --- 5. APP FOOTER (Fixed Height) --- */
.app-footer {
    height: 3rem;
    min-height: 3rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background-color: var(--bg-footer);
    color: white;
    font-size: 0.8rem;
}

/* --- 6. MODALS (Retaining the fixes for scrolling and icons) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.85);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.is-visible { display: flex; }

.menu-modal, .settings-modal {
    background-color: var(--color-snow);
    width: 95%;
    max-width: 400px;
    max-height: 85vh;
    border-radius: 1.2rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.menu-modal-header {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--color-smoke);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
    background-color: var(--color-snow);
}

.menu-modal-title {
    font-weight: 600;
    font-size: 1rem;
}

.settings-header, .settings-modal h2 {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--color-smoke);
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* THE FIX: These three lines */
    position: relative; 
    z-index: 100; 
    background-color: var(--color-snow);
}

/* Scroll Containers */
.menu-grid, .settings-content, #categoryList {
    flex-grow: 1;
    overflow-y: auto !important;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Menu Item Alignment Fix */
.menu-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: white;
    border: 1px solid var(--color-smoke);
    border-radius: 0.8rem;
}

.menu-icon { margin-right: 1.2rem; font-size: 1.4rem; width: 2rem; text-align: center; }
.menu-label { font-weight: 500; }

.category-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.8rem;
    background: white;
    margin-bottom: 0.4rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-smoke);
}
.category-item input { margin-right: 1rem; width: 1.2rem; height: 1.2rem; }

.save-btn, .primary-btn {
    width: 100%;
    padding: 1rem;
    background: var(--color-ocean);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: bold;
}

/* Ensure the content area scrolls if the example list is long */
#importMenu .settings-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#importMenu hr {
    border: none;
    border-top: 1px solid var(--color-smoke);
    margin: 0.5rem 0;
}

/* --- Settings Modal Structure --- */

/* Targets the new unified .settings-content wrapper inside the settings modal */
#settingsOverlay .settings-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Style the bottom action area where Save/Reset buttons live */
.settings-actions {
    flex-shrink: 0;
    padding: 1.2rem;
    background: white;
    border-top: 1px solid var(--color-smoke);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Individual Setting Row */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.setting-item label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-ink);
    flex-grow: 1;
}

/* Section headings within settings */
.settings-section h4 {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.voice-setting {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.voice-picker-search {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--color-smoke);
    border-radius: 0.6rem;
    font-size: 0.95rem;
    color: var(--color-ink);
    background: white;
}

.voice-picker-list {
    width: 100%;
    min-height: 10rem;
    padding: 0.3rem;
    border: 1px solid var(--color-smoke);
    border-radius: 0.6rem;
    background: white;
    color: var(--color-ink);
}

.voice-picker-list option {
    padding: 0.55rem 0.65rem;
    border-radius: 0.4rem;
}

.setting-note {
    font-size: 0.82rem;
    color: #666;
    line-height: 1.4;
}

/* Individual Option Blocks */
.import-option {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.import-option h4 {
    color: var(--color-ink);
    font-size: 1rem;
    margin-bottom: 0.25rem;
    /* text-transform: uppercase; */
    letter-spacing: 0.5px;
}

/* Style the buttons (File Picker & Custom URL) */
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    background-color: white;
    border: 2px solid var(--color-ocean);
    border-radius: 0.8rem;
    color: var(--color-ocean);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-btn:active {
    background-color: var(--color-ocean);
    color: white;
}

/* Primary variant for "Select File" */
.menu-btn.primary {
    background-color: var(--color-ocean);
    color: white;
}

/* Hint text styling */
.hint {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
    font-style: italic;
}

/* Mode change toast (long-press on next zone) */
.mode-toast {
    position: fixed;
    left: 50%;
    bottom: 3rem;
    transform: translateX(-50%) translateY(16px);
    background: rgba(12, 26, 39, 0.95);
    color: #fff;
    padding: 0.85rem 1.4rem;
    border-radius: 0.9rem;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.45);
    opacity: 0;
    pointer-events: none;
    z-index: 10000;
    transition: opacity 180ms ease, transform 180ms ease;
}

.mode-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.mode-toast--centered {
    bottom: auto;
    top: 50%;
    transform: translateX(-50%) translateY(calc(-50% + 16px));
    padding: 1.4rem 2.2rem;
    font-size: 1.25rem;
    border-radius: 1.1rem;
    box-shadow: 0 8px 40px rgba(0,0,0,0.55);
    text-align: center;
    max-width: min(90vw, 420px);
    white-space: pre-line;
}

.mode-toast--centered.is-visible {
    transform: translateX(-50%) translateY(-50%);
}

/* GitHub Scanning / Remote List */
/* Container for the GitHub decks */
#remoteExamplesList {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Space between items */
    margin-top: 0.5rem;
}

/* Individual deck items inside the list */
.remote-deck-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    background-color: white;
    border: 1px solid var(--color-smoke);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    color: var(--color-ocean);
    cursor: pointer;
    transition: background 0.2s;
}

/* Hover/Touch effect */
.remote-deck-item:active {
    background-color: #f0f7ff;
}

/* Optional: Add a small bullet or icon before the name */
.remote-deck-item::before {
    content: "•";
    margin-right: 0.75rem;
    font-weight: bold;
    color: var(--color-smoke);
}

/* Styling for the Remote Browser */
.remote-deck-item {
    justify-content: flex-start; /* Align text to left */
    font-weight: 500;
}

/* Specific color for folders to distinguish them */
.remote-deck-item.dir-item {
    color: var(--color-ink);
    border-left: 4px solid #ffd700; /* Gold folder accent */
}

/* Specific style for the Back button */
.remote-deck-item.back-btn {
    background-color: var(--color-smoke);
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.remote-deck-item.file-item {
    color: var(--color-ocean);
}

#closeImport, #closeSettings, #closeDeck, #closeSelect, #closeHelp, #closeMenuBtn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--color-ink);
    line-height: 1;
}

/* The container for [ < ] [ 1.0 ] [ > ] */
.input-group {
    display: flex;
    align-items: center;
    background: #f1f3f5;
    border-radius: 0.6rem;
    padding: 0.2rem;
    border: 1px solid var(--color-smoke);
}

/* Numeric input in the center */
.setting-item input[type="number"] {
    width: 3.5rem;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--color-ocean);
    appearance: textfield; /* Hides default browser arrows */
}

/* Standalone number inputs (not inside .input-group) get a visible box */
#sessionSize, #historySize {
    border: 2px solid var(--color-smoke) !important;
    border-radius: 0.5rem;
    padding: 0.25rem 0.4rem;
    background: white !important;
    transition: border-color 120ms ease;
}

#sessionSize:focus, #historySize:focus {
    outline: none;
    border-color: var(--color-ocean) !important;
}

/* Hide webkit spinners */
.setting-item input::-webkit-inner-spin-button,
.setting-item input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Stepper Adjustment Buttons */
.adj-btn {
    width: 2.8rem;
    height: 2.5rem;
    background: white;
    border: 1px solid var(--color-smoke);
    border-radius: 0.4rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--color-ocean);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.adj-btn:active {
    background-color: var(--color-ocean);
    color: white;
}

/* Help Modal Specifics */
.help-container {
    color: var(--color-ink);
    line-height: 1.5;
}

.help-header h2 {
    color: var(--color-ocean);
    margin-bottom: 0.2rem;
}

.help-grid {
    display: grid;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.help-card h3 {
    font-size: 1rem;
    border-bottom: 2px solid var(--color-smoke);
    padding-bottom: 0.3rem;
    margin-bottom: 0.5rem;
}

.help-card ul {
    padding-left: 1.2rem;
    margin: 0;
}

.help-card li {
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.help-footer {
    border-top: 1px dashed var(--color-smoke);
    padding-top: 1rem;
    font-style: italic;
}

/* Structural Modal Styles */
#helpOverlay.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Darkens the background */
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's above the menu (usually 1000) */
    backdrop-filter: blur(4px); /* Professional touch */
}

#helpOverlay.is-visible {
    display: flex; /* Shows it when logic calls toggleHelpModal(true) */
}

/* The actual white box containing the help text */
#helpOverlay .modal-content {
    background-color: #ffffff; /* CRITICAL: This makes it readable */
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: 12px;
    padding: 2rem;
    overflow-y: auto; /* Allows scrolling if help text is long */
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    color: var(--color-ink); /* Uses your variable for text color */
}

/* .updateBadge {
    cursor: pointer;
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent;
    z-index: 9999;
} */
/* 1. Define the "Loud" Animation */
@keyframes loud-wobble {
    0% { transform: translateX(0) scale(1); background-color: #ffff00; }
    25% { transform: translateX(-5px) rotate(-5deg) scale(1.1); background-color: #ff0000; color: white; }
    50% { transform: translateX(5px) rotate(5deg) scale(1.1); background-color: #ffff00; color: black; }
    75% { transform: translateX(-5px) rotate(-5deg) scale(1.1); background-color: #ff0000; color: white; }
    100% { transform: translateX(0) scale(1); background-color: #ffff00; color: black; }
}



/* The Pulse Animation */
@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(255, 82, 82, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 82, 82, 0);
    }
}

.version-info {
    display: flex !important;       /* Forces children into a single row */
    flex-direction: row !important;  
    align-items: center !important;  /* Vertically centers the text and badge */
    justify-content: center;         /* Centers the whole group in the footer */
    gap: 10px;                      /* Adds a nice 10px space between Version and UPDATE */
    white-space: nowrap;            /* Prevents the badge from jumping to a new line if the screen is narrow */
}

@keyframes text-glow {
    0% {
        opacity: 0.6;
        text-shadow: 0 0 0px rgba(255, 82, 82, 0);
        transform: scale(1);
    }
    50% {
        opacity: 1;
        /* Increased blur radius (20px) to make it more visible */
        text-shadow: 0 0 10px rgb(82, 255, 157), 0 0 20px rgba(255, 82, 82, 0.6);
        transform: scale(1.1); 
    }
    100% {
        opacity: 0.6;
        text-shadow: 0 0 0px rgba(255, 82, 82, 0);
        transform: scale(1);
    }
}

@keyframes text-glow-green {
    0% {
        opacity: 0.6;
        text-shadow: 0 0 0px var(--color-neon-green);
        transform: scale(1);
    }
    50% {
        opacity: 1;
        /* Using your palette green with the neon variable for the aura */
        text-shadow: 0 0 8px var(--color-green), 0 0 15px var(--color-neon-green);
        transform: scale(1.05); 
    }
    100% {
        opacity: 0.6;
        text-shadow: 0 0 0px var(--color-neon-green);
        transform: scale(1);
    }
}

#updateBadge {
    display: none;
    cursor: pointer !important;
    background: transparent !important;
    border: none !important;

    /* Using your palette variable */
    color: var(--color-green) !important;

    font-weight: 900 !important;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;

    animation: text-glow-green 2s ease-in-out infinite !important;

    line-height: 1;
    vertical-align: middle;
}

#updateBadge:hover {
    color: var(--color-neon-green) !important;
    transition: color 0.3s ease;
}

/* Version tag base styling */
#versionTag {
    color: #666; /* Dark grey text */
    background-color: transparent;
    padding: 0.25rem 0.5rem; /* Small padding for pulsating background effect */
    border-radius: 0.3rem;
    transition: all 0.2s ease;
}

/* Pulsating background animation - white to fluorescent green */
@keyframes version-pulse {
    0% {
        background-color: transparent;
        color: #666;
    }
    50% {
        background-color: var(--color-neon-green); /* Fluorescent green */
        color: var(--color-ink); /* Dark text on green background */
    }
    100% {
        background-color: transparent;
        color: #666;
    }
}

/* Version tag update indicator - replaces separate UPDATE badge */
#versionTag.is-update-available {
    cursor: pointer;
    /* Adjustable parameters below: */
    /* animation: version-pulse 8s ease-in-out infinite; Change 2s to speed up/slow down */
    animation: version-pulse 4s ease-in-out infinite;
    /* animation: version-pulse 1s ease-in-out infinite;   <- FASTER (1 second) */
    /* animation: version-pulse 3s ease-in-out infinite;   <- SLOWER (3 seconds) */
    /* animation: version-pulse 2s linear infinite;        <- LINEAR (no easing, constant pace) */
    /* animation: version-pulse 2s ease-in infinite;       <- EASE-IN (speeds up) */
}

#versionTag.is-update-available:hover {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}
/* Apply it to your badge */
/* #updateBadge {
    display: none; 
    background-color: var(--color-red);
    color: var(--color-snow);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    font-size:0.8rem;
    animation: pulse-red 2s infinite;
    z-index: 9999;
} */

/* END css/styles.css */

