/* ============================================================
   The Grammar Index — Corporate Theme
   ============================================================ */

:root {
    --primary: #1B5E9E;
    --primary-dark: #14486F;
    --primary-light: #2980C4;
    --bg: #F5F6FA;
    --bg-card: #FFFFFF;
    --text: #2C3E50;
    --text-muted: #6C7A89;
    --border: #E0E4EB;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-pill: 50px;
    --success: #27AE60;
    --danger: #E74C3C;
    --warning: #F39C12;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
        "Segoe UI Emoji";
}

/* Reset & base */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Loading screen ---- */
.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.loading-content {
    text-align: center;
}

.loading-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---- Blazor error UI ---- */
#blazor-error-ui {
    background: var(--danger);
    color: #fff;
    padding: 0.75rem 1.25rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
    display: none;
    text-align: center;
}

#blazor-error-ui .reload,
#blazor-error-ui .dismiss {
    color: #fff;
    margin-left: 1rem;
    text-decoration: underline;
    cursor: pointer;
}

/* ---- Header ---- */
.app-header {
    background: var(--primary);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.app-header2 {
    background: var(--primary);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}



.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.header-subtitle {
    font-size: 0.82rem;
    opacity: 0.8;
    font-weight: 400;
    margin-left: 0.75rem;
}

/* ---- Footer ---- */
.app-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ---- Main content ---- */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ---- Page title ---- */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.5rem 0;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 0.4rem 0;
}

.page-hint {
    color: var(--primary, #1B5E9E);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0 0 1.5rem 0;
}

/* ---- Search bar ---- */
.search-bar {
    margin-bottom: 1.25rem;
}

.search-bar .dxbl-text-edit {
    border-radius: var(--radius) !important;
}

/* ---- Section chips ---- */
.section-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.section-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    transition: all 0.2s ease;
    user-select: none;
}

.section-chip:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.section-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ---- Custom filter modal ----
   Trial-edition feature showcase: same Custom-topic chip + modal as the
   paid Web / Windows editions. Operates over the 10 trial entries so
   prospective buyers can see how the feature behaves before upgrading. */
.custom-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.custom-modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    max-width: 760px;
    width: 100%;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.custom-modal-header h3 {
    margin: 0;
    color: var(--primary);
    font-size: 1.1rem;
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 0 0.3rem;
}

.custom-modal-close:hover {
    color: var(--primary);
}

.custom-modal-body {
    overflow-y: auto;
    padding: 0.5rem 1.25rem 1rem;
    flex: 1;
}

.custom-modal-intro {
    font-size: 0.88rem;
    color: #555;
    margin: 0.5rem 0 1rem;
}

.custom-modal-section-group {
    margin-bottom: 0.75rem;
}

.custom-modal-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: var(--primary);
    margin: 0.75rem 0 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.custom-modal-section-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    padding: 0.15rem 0.7rem;
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
}

.custom-modal-section-toggle:hover {
    border-color: var(--primary);
}

.custom-modal-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.25rem;
    cursor: pointer;
    border-radius: 4px;
}

.custom-modal-row:hover {
    background: #f5f5fa;
}

.custom-modal-row input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.custom-modal-row .title {
    flex: 1;
    font-size: 0.92rem;
}

.custom-modal-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.custom-modal-count {
    margin-right: auto;
    font-size: 0.88rem;
    color: #555;
    font-weight: 600;
}

.custom-modal-btn {
    border-radius: var(--radius-pill);
    padding: 0.45rem 1.1rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
}

.custom-modal-btn:hover {
    border-color: var(--primary);
}

.custom-modal-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.custom-modal-btn.primary:hover {
    background: var(--primary);
    filter: brightness(1.1);
}

.custom-modal-btn.danger {
    color: #c0392b;
    border-color: #f4caca;
}

/* ---- Card grid ---- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

/* ---- Grammar card ---- */
.grammar-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.grammar-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.grammar-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.grammar-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
}

.grammar-card-definition {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 0.75rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grammar-card-example {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    border-left: 3px solid var(--primary-light);
}

.grammar-card-example-label {
    font-weight: 600;
    color: var(--text);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.grammar-card-more {
    margin-top: 0.6rem;
    color: var(--primary, #1B5E9E);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: right;
}

/* ---- Tag badge ---- */
.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #fff;
    flex-shrink: 0;
}

/* ---- Entry detail page ---- */
.entry-detail {
    max-width: 800px;
    margin: 0 auto;
}

.entry-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.entry-detail-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.entry-detail-definition {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    line-height: 1.7;
    font-size: 1rem;
    color: var(--text);
}

.entry-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    transition: color 0.15s;
}

.entry-back-link:hover {
    color: var(--primary-dark);
}

.entry-section-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ---- Example blocks ---- */
.examples-section {
    margin-top: 1.5rem;
}

.examples-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1rem 0;
}

.example-block {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary-light);
}

.example-block.correct {
    border-left-color: var(--success);
}

.example-block.incorrect {
    border-left-color: var(--danger);
}

.example-block-label {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

.example-block.correct .example-block-label {
    color: var(--success);
}

.example-block.incorrect .example-block-label {
    color: var(--danger);
}

.example-block-sentence {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text);
}

.example-block-sentence .hl {
    background: rgba(27, 94, 158, 0.12);
    padding: 0.1em 0.25em;
    border-radius: 3px;
    font-weight: 600;
    color: var(--primary);
}

.example-block.correct .example-block-sentence .hl {
    background: rgba(39, 174, 96, 0.12);
    color: var(--success);
}

.example-block.incorrect .example-block-sentence .hl {
    background: rgba(231, 76, 60, 0.12);
    color: var(--danger);
    text-decoration: line-through;
}

.example-block-note {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ---- No results ---- */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.no-results-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.no-results-hint {
    font-size: 0.9rem;
}

/* ---- Back to top ---- */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 50;
}

.back-to-top:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .header-subtitle {
        margin-left: 0;
    }

    .main-content {
        padding: 1rem;
    }

    .entry-detail-title {
        font-size: 1.4rem;
    }

    .activation-card {
        padding: 1.5rem;
    }

    .entry-detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .section-chips {
        gap: 0.35rem;
    }

    .section-chip {
        padding: 0.25rem 0.65rem;
        font-size: 0.75rem;
    }
}

/* Free tier banner */
.free-tier-banner {
    background: linear-gradient(135deg, #E3EEF8 0%, #F0F4FF 100%);
    border: 1px solid #B3D4F0;
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 24px;
    text-align: center;
    font-size: 15px;
    color: var(--text);
}
.free-tier-banner a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ===== Quiz feature ===== */
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.header-title-link { text-decoration: none; color: inherit; }
.header-title-link:hover { opacity: 0.85; }

.header-nav { display: flex; gap: 0.5rem; align-items: center; }
.header-nav-link {
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border);
    transition: background 0.15s, transform 0.15s;
}
.header-nav-link:hover { background: rgba(255, 255, 255, 0.9); transform: translateY(-1px); }
.header-nav-link-accent { background: var(--primary); color: #fff; border-color: var(--primary); }
.header-nav-link-accent:hover { opacity: 0.92; color: #fff; }

.quiz-cta { margin: 1.25rem 0 2rem; }
.quiz-cta-button {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 1.4rem;
    background: linear-gradient(135deg, var(--primary), #2C7EBA);
    color: #fff; border-radius: var(--radius); text-decoration: none;
    box-shadow: 0 4px 12px rgba(27, 94, 158, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
}
.quiz-cta-button:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(27, 94, 158, 0.35); color: #fff; }
.quiz-cta-icon { font-size: 1.8rem; }
.quiz-cta-text { display: flex; flex-direction: column; }
.quiz-cta-text strong { font-size: 1.1rem; margin-bottom: 0.15rem; }
.quiz-cta-hint { font-size: 0.85rem; opacity: 0.92; }

.quiz-pool-note {
    background: rgba(27, 94, 158, 0.08);
    border-left: 3px solid var(--primary);
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1.5rem 0;
}

.quiz-question {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.quiz-question.quiz-q-right { border-left-color: var(--success); }
.quiz-question.quiz-q-wrong { border-left-color: var(--danger); }
.quiz-question-num {
    font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.5rem;
}
.quiz-question-sentence { font-size: 1.05rem; line-height: 1.6; margin-bottom: 0.5rem; }
.quiz-question-sentence .hl {
    background: rgba(27, 94, 158, 0.12);
    padding: 0.1em 0.3em; border-radius: 3px;
    font-weight: 600; color: var(--primary);
    text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.quiz-question-prompt { font-size: 0.95rem; font-weight: 600; margin: 0.7rem 0 0.6rem; color: var(--text); }

.quiz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.5rem; }
.quiz-option {
    padding: 0.65rem 0.9rem;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem; font-weight: 500;
    cursor: pointer; transition: background 0.12s, border-color 0.12s;
    text-align: left; color: var(--text);
}
.quiz-option:hover:not(:disabled) { border-color: var(--primary); background: rgba(27, 94, 158, 0.05); }
.quiz-option.selected { background: rgba(27, 94, 158, 0.12); border-color: var(--primary); color: var(--primary); }
.quiz-option.correct { background: rgba(39, 174, 96, 0.15); border-color: var(--success); color: var(--success); }
.quiz-option.wrong { background: rgba(231, 76, 60, 0.12); border-color: var(--danger); color: var(--danger); text-decoration: line-through; }
.quiz-option:disabled { cursor: default; }

.quiz-answer-reveal { margin-top: 0.6rem; font-size: 0.9rem; color: var(--text-muted); font-style: italic; }

.quiz-submit {
    display: block; width: 100%; margin-top: 1rem;
    padding: 0.9rem 1.2rem; font-size: 1rem; font-weight: 700;
    color: #fff; background: var(--primary); border: none; border-radius: var(--radius);
    cursor: pointer; transition: background 0.15s;
}
.quiz-submit:hover:not(:disabled) { background: #1A507F; }
.quiz-submit:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

.quiz-result {
    margin-top: 1.25rem; padding: 1.25rem 1.4rem;
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.12), rgba(27, 94, 158, 0.08));
    border: 1px solid rgba(39, 174, 96, 0.25);
    border-radius: var(--radius); text-align: center;
}
.quiz-result-score { font-size: 1.6rem; font-weight: 800; color: var(--success); margin-bottom: 0.35rem; }
.quiz-result-message { font-size: 1rem; color: var(--text); margin-bottom: 1rem; }
