/* ========================================
   Phrasal Verbs Lab — Fill the Gap
   Travel & Navigation Theme
   &copy; Cool English 2026
   All-on-one-page dark grid
   ======================================== */

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

:root {
    --teal-300: #5eead4;
    --teal-400: #2dd4bf;
    --teal-500: #14b8a6;
    --teal-600: #0d9488;
    --teal-700: #0f766e;

    --cyan-400: #22d3ee;
    --cyan-500: #06b6d4;

    --amber-300: #fcd34d;
    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --amber-600: #d97706;

    --emerald-400: #34d399;
    --emerald-500: #10b981;

    --slate-800: #1e293b;
    --slate-900: #0f172a;
}

/* ========================================
   Base — locked viewport on desktop
   ======================================== */
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(ellipse at 10% 20%, rgba(6,182,212,0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(13,148,136,0.15) 0%, transparent 50%),
        linear-gradient(145deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
    background-attachment: fixed;
    color: white;
}

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ========================================
   Header
   ======================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 4px solid transparent;
    border-image: linear-gradient(90deg, #FF6B35, #F59E0B, #22C55E, #06B6D4, #8B5CF6, #EC4899) 1;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.header-left  { display: flex; align-items: center; gap: 0.875rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }

.back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 2.5rem; height: 2.5rem; border-radius: 0.625rem;
    background: rgba(255,255,255,0.08);
    color: white; text-decoration: none;
    border: 2px solid rgba(255,255,255,0.15);
    transition: all 0.2s;
}
.back-btn:hover {
    background: var(--teal-600);
    border-color: var(--teal-500);
    transform: translateX(-3px);
}

.logo {
    width: 2.5rem; height: 2.5rem; border-radius: 0.625rem;
    background: linear-gradient(135deg, var(--teal-600), var(--cyan-500));
    display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0;
    box-shadow: 0 0 20px rgba(6,182,212,0.3);
}

.title-group { display: flex; align-items: center; gap: 0.875rem; }

.main-title {
    font-weight: 800; font-size: 2rem; color: white;
}

.theme-badge {
    background: linear-gradient(135deg, var(--teal-600), var(--cyan-500));
    color: white; font-size: 1rem; font-weight: 700;
    padding: 0.375rem 1.1rem; border-radius: 2rem;
}

/* Score pill */
.score-pill {
    display: flex; flex-direction: column; align-items: center;
    background: linear-gradient(135deg, var(--teal-600), var(--teal-700));
    padding: 0.3rem 1.25rem; border-radius: 0.75rem;
    min-width: 80px;
}
.score-label {
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: rgba(255,255,255,0.75);
}
.score-count { font-size: 1.35rem; font-weight: 900; color: white; }

/* Progress dots */
.progress-dots {
    display: flex; align-items: center; gap: 5px;
    background: rgba(255,255,255,0.06);
    padding: 0.5rem 0.75rem; border-radius: 0.625rem;
    border: 2px solid rgba(255,255,255,0.1);
}
.progress-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: rgba(255,255,255,0.15);
    transition: all 0.3s;
}
.progress-dot.revealed {
    background: linear-gradient(135deg, var(--teal-400), var(--emerald-400));
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(45,212,191,0.5);
}

/* Header buttons */
.header-btn {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1.1rem; border-radius: 0.625rem;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: white;
    font-weight: 700; font-size: 0.9375rem;
    cursor: pointer; transition: all 0.2s;
}
.header-btn:hover { transform: translateY(-2px); }
.word-bank-toggle:hover { background: rgba(251,191,36,0.25); border-color: var(--amber-400); color: var(--amber-300); }
.word-bank-toggle.active { background: rgba(251,191,36,0.25); border-color: var(--amber-400); color: var(--amber-300); }
.reveal-all-btn:hover { background: rgba(20,184,166,0.25); border-color: var(--teal-400); color: var(--teal-300); }
.reveal-all-btn.see-results-mode {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #10b981; color: white;
    animation: seeResultsGlow 1.2s ease-in-out infinite;
}
.reveal-all-btn.see-results-mode:hover { animation: none; transform: scale(1.05); }
@keyframes seeResultsGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(16,185,129,0); transform: translateY(-2px); }
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.875rem 1.5rem 0.5rem;
    overflow: hidden;
    min-height: 0;
}

/* ========================================
   Word Bank
   ======================================== */
.word-bank {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(251,191,36,0.35);
    border-radius: 0.875rem;
    padding: 0.5rem 1.1rem;
    margin-bottom: 0.625rem;
    flex-shrink: 0;
    animation: slideDown 0.25s ease;
}
.word-bank.visible { display: flex; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.word-bank-label {
    font-weight: 800; font-size: 1rem;
    color: var(--amber-400);
    text-transform: uppercase; letter-spacing: 0.06em;
    white-space: nowrap;
}
.word-bank-words { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.word-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-weight: 700; font-size: 1.3rem;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.07);
    border: 2px solid rgba(255,255,255,0.15);
    padding: 0.25rem 0.875rem; border-radius: 0.5rem;
    cursor: pointer; transition: all 0.2s; user-select: none;
}
.word-chip svg { color: rgba(255,255,255,0.4); flex-shrink: 0; }
.word-chip:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.word-chip.used {
    background: rgba(20,184,166,0.25);
    border-color: var(--teal-500);
    color: var(--teal-300);
}
.word-chip.used svg { color: var(--teal-400); }

/* ========================================
   Two-column grid
   ======================================== */
.gaps-container {
    flex: 1;
    display: flex;
    gap: 1rem;
    min-height: 0;
    overflow: hidden;
}

.gaps-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    min-height: 0;
    overflow-y: auto;
}

/* ========================================
   Gap Card
   ======================================== */
.gap-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255,255,255,0.05);
    border: 1.5px solid rgba(255,255,255,0.1);
    border-radius: 1rem;
    padding: 0.55rem 1rem 0.55rem 0.75rem;
    position: relative;
    overflow: visible;
    transition: all 0.3s;
    opacity: 0;
    animation: cardIn 0.3s ease forwards;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gap-card.revealed {
    background: rgba(13,148,136,0.12);
    border-color: rgba(20,184,166,0.35);
    box-shadow: 0 4px 20px rgba(20,184,166,0.1);
}

/* Number badge */
.gap-number {
    width: 3rem; height: 3rem; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--teal-600), var(--teal-700));
    color: white; font-weight: 900; font-size: 1.35rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.3s;
    box-shadow: 0 0 15px rgba(13,148,136,0.3);
}
.gap-card.revealed .gap-number {
    background: linear-gradient(135deg, var(--teal-400), var(--emerald-500));
}

/* Sentence text */
.gap-sentence {
    flex: 1;
    font-size: clamp(1.35rem, 2.2vw, 2.75rem);
    font-weight: 700;
    color: rgba(255,255,255,0.92);
    line-height: 1.35;
}

/* ========================================
   Gap Blank — the clickable button
   ======================================== */
.gap-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 9rem;
    padding: 0 0.6rem;
    border-radius: 0.5rem;
    border: 2.5px dashed rgba(45,212,191,0.45);
    background: rgba(45,212,191,0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    vertical-align: baseline;
    position: relative;
}
.gap-blank:hover {
    border-color: var(--teal-400);
    background: rgba(45,212,191,0.15);
    transform: scale(1.05);
}

.blank-placeholder {
    font-weight: 900;
    font-size: clamp(1.2rem, 2vw, 2.5rem);
    color: var(--teal-400);
    transition: opacity 0.2s;
}

.blank-answer {
    font-weight: 900;
    font-size: clamp(1.35rem, 2.2vw, 2.75rem);
    color: white;
    position: absolute;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}

.gap-blank.revealed {
    border-style: solid;
    border-color: var(--teal-600);
    background: linear-gradient(135deg, var(--teal-600), var(--teal-700));
    min-width: auto;
    padding: 0.1rem 0.875rem;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(13,148,136,0.45);
}
.gap-blank.revealed:hover {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    transform: scale(1.04);
    box-shadow: 0 4px 18px rgba(13,148,136,0.55);
}
.gap-blank.revealed .blank-placeholder { display: none; }
.gap-blank.revealed .blank-answer {
    opacity: 1;
    position: relative;
    transform: scale(1);
    color: white;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ========================================
   Hint Button
   ======================================== */
.hint-btn {
    width: 2.4rem; height: 2.4rem; border-radius: 50%; flex-shrink: 0;
    border: 2px solid rgba(251,191,36,0.4);
    background: rgba(251,191,36,0.08);
    color: var(--amber-400);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.hint-btn:hover { background: var(--amber-500); border-color: var(--amber-500); color: white; transform: scale(1.1); }
.hint-btn.active { background: var(--amber-500); border-color: var(--amber-500); color: white; }

/* ========================================
   Hint Text — floats inside the card
   ======================================== */
.hint-text {
    display: none;
    position: absolute;
    bottom: 0.35rem;
    right: 3.5rem;
    background: rgba(30,20,0,0.92);
    border: 2px solid var(--amber-500);
    border-radius: 0.625rem;
    padding: 0.3rem 0.875rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--amber-300);
    white-space: nowrap;
    z-index: 20;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: hintPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hint-text.visible { display: block; }

@keyframes hintPop {
    from { opacity: 0; transform: translateY(-4px) scale(0.92); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========================================
   Completion Overlay
   ======================================== */
.completion-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
}
.completion-overlay.active { display: flex; }

.completion-content {
    background: white; border-radius: 1.5rem;
    padding: 2.5rem 3rem; text-align: center;
    max-width: 480px; width: 90%;
    box-shadow: 0 25px 50px rgba(0,0,0,0.35);
    animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bounceIn {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.completion-emoji { font-size: 3.5rem; margin-bottom: 0.75rem; }
.completion-title { font-weight: 900; font-size: 2rem; color: #1e293b; margin-bottom: 0.25rem; }
.completion-subtitle { font-weight: 600; font-size: 1.1rem; color: #64748b; margin-bottom: 1.5rem; }
.completion-buttons { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.completion-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem; border-radius: 0.75rem;
    font-weight: 700; font-size: 1rem;
    cursor: pointer; text-decoration: none; border: none; transition: all 0.2s;
}
.btn-restart { background: linear-gradient(135deg, var(--teal-500), var(--teal-700)); color: white; }
.btn-restart:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(13,148,136,0.35); }
.btn-menu { background: #f1f5f9; color: #334155; }
.btn-menu:hover { background: #e2e8f0; transform: translateY(-2px); }

/* ========================================
   Footer
   ======================================== */
.footer {
    padding: 0.375rem;
    background: rgba(15,23,42,0.8);
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center;
    flex-shrink: 0;
}
.footer p { font-size: 0.875rem; color: rgba(255,255,255,0.3); font-weight: 600; }

/* ========================================
   Responsive — 1400px
   ======================================== */
@media (max-width: 1400px) {
    .gap-sentence  { font-size: clamp(1.2rem, 1.9vw, 2.4rem); }
    .gap-blank     { min-width: 8rem; }
    .gap-number    { width: 2.75rem; height: 2.75rem; font-size: 1.2rem; }
}

/* ========================================
   Responsive — 1200px
   ======================================== */
@media (max-width: 1200px) {
    .btn-label   { display: none; }
    .main-title  { font-size: 1.5rem; }
    .theme-badge { font-size: 0.8rem; }
    .gap-sentence { font-size: clamp(1.1rem, 1.7vw, 2rem); }
    .gap-blank    { min-width: 7rem; }
    .gap-number   { width: 2.5rem; height: 2.5rem; font-size: 1.1rem; }
}

/* ========================================
   Responsive — 1024px
   ======================================== */
@media (max-width: 1024px) {
    .header     { padding: 0.4rem 1rem; }
    .main-title { font-size: 1.25rem; }
    .theme-badge{ display: none; }
    .main-content { padding: 0.75rem 1rem 0.5rem; }
    .gap-sentence { font-size: clamp(1rem, 1.5vw, 1.75rem); }
    .gap-blank    { min-width: 6rem; }
    .gap-number   { width: 2.25rem; height: 2.25rem; font-size: 1rem; }
}

/* ========================================
   Responsive — 768px (single column + scroll)
   ======================================== */
@media (max-width: 768px) {
    html, body { height: auto; overflow-y: auto; }
    .app { height: auto; min-height: 100dvh; overflow: visible; }

    .header { padding: 0.4rem 0.75rem; gap: 0.35rem; }
    .header-left { gap: 0.4rem; }
    .header-right { gap: 0.35rem; }

    .back-btn { width: 2.25rem; height: 2.25rem; border-radius: 0.5rem; }
    .back-btn svg { width: 18px; height: 18px; }
    .logo { width: 2.25rem; height: 2.25rem; border-radius: 0.5rem; }
    .logo svg { width: 16px; height: 16px; }
    .main-title { font-size: 1rem; }
    .theme-badge { display: none; }

    .score-pill { padding: 0.25rem 0.65rem; min-width: unset; flex-direction: row; gap: 0.3rem; border-radius: 0.5rem; }
    .score-label { display: none; }
    .score-count { font-size: 1rem; }

    .progress-dots { display: none; }
    .btn-label { display: none; }
    .header-btn { padding: 0.4rem 0.5rem; min-width: 2.25rem; min-height: 2.25rem; border-radius: 0.5rem; }

    .main-content { padding: 0.625rem 0.625rem 1rem; }

    .gaps-container { flex-direction: column; gap: 0; }
    .gaps-column { flex: none; gap: 0.625rem; }
    .gaps-column + .gaps-column { margin-top: 0.625rem; }

    .gap-card {
        flex: none;
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 0.6rem 0.75rem;
        gap: 0.4rem 0.5rem;
    }
    .gap-number { width: 2rem; height: 2rem; font-size: 0.875rem; margin-top: 0.1rem; }
    .gap-sentence { font-size: 1.1rem; align-self: center; }
    .gap-blank { min-width: 5rem; }
    .hint-btn { width: 2rem; height: 2rem; align-self: center; }
    .hint-btn svg { width: 14px; height: 14px; }

    /* Hint wraps to full-width row on mobile */
    .hint-text {
        position: static;
        display: none;
        order: 10;
        flex-basis: 100%;
        white-space: normal;
        font-size: 0.875rem;
        padding: 0.3rem 0.65rem;
        border-radius: 0.5rem;
        box-shadow: none;
    }
    .hint-text.visible { display: block; }

    .word-bank { padding: 0.4rem 0.75rem; }
    .word-bank-label { font-size: 0.75rem; }
    .word-chip { font-size: 0.875rem; padding: 0.15rem 0.5rem; }
    .word-chip svg { width: 11px; height: 11px; }
}

/* ========================================
   Responsive — 480px
   ======================================== */
@media (max-width: 480px) {
    .gap-sentence { font-size: 1rem; }
    .gap-blank { min-width: 4.5rem; }
    .gaps-column { gap: 0.5rem; }
    .word-chip { font-size: 0.8rem; padding: 0.1rem 0.4rem; }
}

/* ========================================
   V4 RESPONSIVE CLIP/SCROLL SAFETY PATCH
   Same principle as Definitions V4:
   shrink first, then scroll the real content area instead of clipping.
   This patch is intentionally last so it wins the cascade.
   ======================================== */
@media (min-width: 900px) {
    html,
    body,
    .app {
        height: 100dvh;
        overflow: hidden;
    }

    .main-content {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-gutter: stable;
        overscroll-behavior: contain;
    }

    .gaps-container {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-gutter: stable;
    }

    .gaps-column {
        min-height: 0;
        overflow-y: auto;
    }

    .word-bank,
    .footer,
    .header {
        flex-shrink: 0;
    }
}

@media (min-width: 900px) and (max-height: 1100px) {
    .header {
        padding-top: clamp(0.35rem, 0.7vh, 0.5rem);
        padding-bottom: clamp(0.35rem, 0.7vh, 0.5rem);
    }

    .main-content {
        padding-top: clamp(0.45rem, 0.8vh, 0.75rem);
        padding-bottom: clamp(0.3rem, 0.65vh, 0.5rem);
    }

    .gaps-container {
        gap: clamp(0.6rem, 1vw, 1rem);
    }

    .gaps-column {
        gap: clamp(0.45rem, 0.8vh, 0.7rem);
    }

    .gap-card {
        padding-top: clamp(0.55rem, 1vh, 0.85rem);
        padding-bottom: clamp(0.55rem, 1vh, 0.85rem);
    }

    .gap-sentence {
        font-size: clamp(1.35rem, 2.9vh, 2rem);
        line-height: 1.3;
    }

    .word-bank {
        padding-top: clamp(0.35rem, 0.6vh, 0.5rem);
        padding-bottom: clamp(0.35rem, 0.6vh, 0.5rem);
        margin-bottom: clamp(0.35rem, 0.6vh, 0.625rem);
    }

    .word-chip {
        font-size: clamp(0.95rem, 1.75vh, 1.25rem);
        padding-top: clamp(0.2rem, 0.5vh, 0.35rem);
        padding-bottom: clamp(0.2rem, 0.5vh, 0.35rem);
    }
}

@media (min-width: 900px) and (max-height: 820px) {
    .main-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .gap-sentence {
        font-size: clamp(1.15rem, 3vh, 1.55rem);
    }

    .gap-card {
        border-radius: 0.8rem;
    }

    .footer {
        padding-top: 0.2rem;
        padding-bottom: 0.2rem;
    }
}

@media (min-width: 900px) and (max-height: 720px) {
    .gap-sentence {
        font-size: 1.1rem;
        line-height: 1.25;
    }

    .word-chip {
        font-size: 0.9rem;
    }

    .gaps-column {
        gap: 0.4rem;
    }
}
