/* Custom CSS for Spellaroo */

/* Character-by-character spelling diff (lowercase = correct, UPPERCASE = wrong/missing) */
.spell-diff {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 2px;
    color: #212529;
    background: #fff3cd;
    padding: 2px 8px;
    border-radius: 4px;
}
@media (prefers-color-scheme: dark) {
    .spell-diff { color: #f7fafc; background: #4a5568; }
}

/* Word cloud (home page).
   min-height (not height) so the host grows with openTagCloud's packed layout —
   the cloud root sets its own min-height to the packed height, and a fixed host
   height would let absolutely-positioned tags overflow the card. overflow:hidden
   is a safety net during the brief pre-pack measure pass. */
.word-cloud-host {
    min-height: 280px;
    overflow: hidden;
    --otc-hover-color: #495057;
}
.word-cloud-host .otc-cloud {
    width: 100%;
}
.word-cloud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 12px;
    line-height: 1.4;
    padding: 6px 2px;
}
.cloud-word {
    display: inline-block;
    font-weight: 700;
    cursor: default;
    transition: transform 0.15s ease;
    white-space: nowrap;
}
.cloud-word:hover {
    transform: scale(1.15);
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* Kangaroo mascot */
.brand-roo { font-size: 1.3rem; }
.hero-roo {
    font-size: 4rem;
    line-height: 1;
    display: inline-block;
    animation: hop 2.2s ease-in-out infinite;
}
@keyframes hop {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}
@media (prefers-reduced-motion: reduce) {
    .hero-roo { animation: none; }
}

.quiz-container {
    animation: fadeIn 0.5s ease-in;
}

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

.grade-checkbox {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.grade-checkbox:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.word-display {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    animation: wordAppear 0.8s ease-out;
}

@keyframes wordAppear {
    from { 
        opacity: 0; 
        transform: scale(0.8); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

.answer-input {
    transition: all 0.3s ease;
}

.answer-input:focus {
    transform: scale(1.02);
}

.stats-card {
    transition: transform 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-5px);
}

.btn-primary {
    transition: all 0.3s ease;
}

.btn-primary:hover {
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

/* Loading spinner */
.spinner {
    border: 4px solid #e9ecef;
    border-top: 4px solid #495057; /* High contrast color */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* High contrast improvements for alerts and form elements */
.alert-info {
    background-color: #d1ecf1;
    border-color: #0c5460;
    color: #0c5460; /* High contrast dark text */
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #856404;
    color: #856404; /* High contrast dark text */
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #721c24;
    color: #721c24; /* High contrast dark text */
}

.alert-success {
    background-color: #d4edda;
    border-color: #155724;
    color: #155724; /* High contrast dark text */
}

/* Form elements high contrast */
.form-control {
    color: #212529;
    border-color: #6c757d;
}

.form-control:focus {
    color: #212529;
    border-color: #495057;
    box-shadow: 0 0 0 0.2rem rgba(73, 80, 87, 0.25);
}

.form-select {
    color: #212529;
    border-color: #6c757d;
}

.form-select:focus {
    border-color: #495057;
    box-shadow: 0 0 0 0.2rem rgba(73, 80, 87, 0.25);
}

/* Button variants with high contrast */
.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
    border-color: #4e555b;
}

.btn-success {
    background-color: #155724;
    border-color: #155724;
    color: white;
}

.btn-success:hover {
    background-color: #0f4419;
    border-color: #0a3015;
}

.btn-danger {
    background-color: #721c24;
    border-color: #721c24;
    color: white;
}

.btn-danger:hover {
    background-color: #5a161d;
    border-color: #4e1419;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive improvements */
@media (max-width: 768px) {
    .quiz-container {
        margin: 12px 8px;
        padding: 18px 14px;
    }

    .word-display {
        font-size: 2rem;
    }

    .answer-input {
        font-size: 1.5rem;
        padding: 12px;
    }

    .hero-roo {
        font-size: 3rem;
    }

    .display-4 {
        font-size: 2.2rem;
    }

    .spell-diff {
        font-size: 1.2rem;
        letter-spacing: 1px;
        word-break: break-all;
    }

    /* Comfortable tap targets */
    .btn {
        min-height: 44px;
    }

    .grade-checkbox {
        margin: 5px;
        padding: 10px;
    }

    /* Stack quiz action buttons full-width */
    #feedback .btn,
    .quiz-container > .text-center > .btn {
        display: block;
        width: 100%;
        margin: 8px 0 0 0 !important;
    }

    .table {
        font-size: 0.85rem;
    }
}

/* Prevent iOS zoom-on-focus (inputs must be >=16px) */
@media (max-width: 768px) {
    input[type="text"], input[type="email"], input[type="password"], select {
        font-size: 16px;
    }
    .answer-input {
        font-size: 1.5rem; /* keep the big quiz input */
    }
}

/* ============ Dark mode ============
   Two triggers, same styles:
   1. html[data-theme="dark"]  — user chose dark via the navbar toggle
   2. system prefers dark AND no explicit choice (html:not([data-theme="light"]))
   An explicit data-theme="light" always wins over the system preference. */

html[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}
html[data-theme="dark"] .quiz-container {
    background: #2d3748; color: #f7fafc; border: 1px solid #4a5568;
}
html[data-theme="dark"] .stats-card {
    background: #4a5568; color: #f7fafc; border: 1px solid #718096;
}
html[data-theme="dark"] .grade-checkbox { border-color: #718096; color: #f7fafc; }
html[data-theme="dark"] .grade-checkbox:hover { background-color: #4a5568; border-color: #a0aec0; }
html[data-theme="dark"] .grade-checkbox.selected { background-color: #718096; color: #f7fafc; }
html[data-theme="dark"] .answer-input { background: #4a5568; color: #f7fafc; border-color: #718096; }
html[data-theme="dark"] .definition-box { background: #4a5568; color: #f7fafc; border-left-color: #a0aec0; }
html[data-theme="dark"] .spell-diff { color: #f7fafc; background: #4a5568; }
html[data-theme="dark"] .quiz-container h1,
html[data-theme="dark"] .quiz-container h2,
html[data-theme="dark"] .quiz-container h4,
html[data-theme="dark"] .quiz-container h5,
html[data-theme="dark"] .quiz-container .word-display,
html[data-theme="dark"] .quiz-container p,
html[data-theme="dark"] .quiz-container label,
html[data-theme="dark"] .quiz-container li { color: #f7fafc; }
html[data-theme="dark"] .quiz-container .text-muted,
html[data-theme="dark"] .quiz-container small { color: #cbd5e0 !important; }
html[data-theme="dark"] .table { color: #f7fafc; }
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { color: #f7fafc; background-color: rgba(255,255,255,0.05); }
html[data-theme="dark"] .table > :not(caption) > * > * { background-color: transparent; color: #f7fafc; }
html[data-theme="dark"] .card { background: #4a5568; color: #f7fafc; }
html[data-theme="dark"] .card .card-title { color: #ffb3b8; }
html[data-theme="dark"] .form-control, html[data-theme="dark"] .form-select {
    background: #4a5568; color: #f7fafc; border-color: #718096;
}
html[data-theme="dark"] .alert-light { background: #4a5568; color: #f7fafc; border-color: #718096; }
html[data-theme="dark"] .list-group-item { color: #f7fafc; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) body {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    }
    html:not([data-theme="light"]) .quiz-container {
        background: #2d3748; color: #f7fafc; border: 1px solid #4a5568;
    }
    html:not([data-theme="light"]) .stats-card {
        background: #4a5568; color: #f7fafc; border: 1px solid #718096;
    }
    html:not([data-theme="light"]) .grade-checkbox { border-color: #718096; color: #f7fafc; }
    html:not([data-theme="light"]) .grade-checkbox:hover { background-color: #4a5568; border-color: #a0aec0; }
    html:not([data-theme="light"]) .grade-checkbox.selected { background-color: #718096; color: #f7fafc; }
    html:not([data-theme="light"]) .answer-input { background: #4a5568; color: #f7fafc; border-color: #718096; }
    html:not([data-theme="light"]) .definition-box { background: #4a5568; color: #f7fafc; border-left-color: #a0aec0; }
    html:not([data-theme="light"]) .spell-diff { color: #f7fafc; background: #4a5568; }
    html:not([data-theme="light"]) .quiz-container h1,
    html:not([data-theme="light"]) .quiz-container h2,
    html:not([data-theme="light"]) .quiz-container h4,
    html:not([data-theme="light"]) .quiz-container h5,
    html:not([data-theme="light"]) .quiz-container .word-display,
    html:not([data-theme="light"]) .quiz-container p,
    html:not([data-theme="light"]) .quiz-container label,
    html:not([data-theme="light"]) .quiz-container li { color: #f7fafc; }
    html:not([data-theme="light"]) .quiz-container .text-muted,
    html:not([data-theme="light"]) .quiz-container small { color: #cbd5e0 !important; }
    html:not([data-theme="light"]) .table { color: #f7fafc; }
    html:not([data-theme="light"]) .table-striped > tbody > tr:nth-of-type(odd) > * { color: #f7fafc; background-color: rgba(255,255,255,0.05); }
    html:not([data-theme="light"]) .table > :not(caption) > * > * { background-color: transparent; color: #f7fafc; }
    html:not([data-theme="light"]) .card { background: #4a5568; color: #f7fafc; }
    html:not([data-theme="light"]) .card .card-title { color: #ffb3b8; }
    html:not([data-theme="light"]) .form-control, html:not([data-theme="light"]) .form-select {
        background: #4a5568; color: #f7fafc; border-color: #718096;
    }
    html:not([data-theme="light"]) .alert-light { background: #4a5568; color: #f7fafc; border-color: #718096; }
    html:not([data-theme="light"]) .list-group-item { color: #f7fafc; }
}