/**
 * NEW MEMORIZATION SYSTEM STYLES
 */

/* ============================================
   BLUR BACKGROUND WHEN PRACTICING
   ============================================ */

/* Apply blur to background when memory practice is active */
body.mem-practice-active #bibleContent,
body.mem-practice-active .floating-header {
    filter: blur(20px);
    pointer-events: none;
}

/* Add dark overlay to blurred content */
body.mem-practice-active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    pointer-events: none;
}

/* ============================================
   OVERLAYS & MODALS
   ============================================ */

.mem-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2000;
}

.mem-level-overlay {
    align-items: flex-end;
    padding: 0;
    justify-content: stretch;
    width: 100%;
}

.mem-modal {
    position: relative;
    background: white;
    border-radius: 16px 16px 0 0;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    animation: memSlideUp 0.3s ease-out;
}

.mem-level-modal {
    border-radius: 0;
    padding: 20px;
    width: 100%;
    background: white;
    max-width: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    /* Mobile: grows upward from keyboard, max 80vh */
    max-height: 80vh;
    min-height: auto;
    overflow-y: auto;
}

@keyframes memSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   MODAL HEADER & BUTTONS
   ============================================ */

.mem-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.mem-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    color: #1f2937;
    font-weight: 700;
}

.mem-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

@media (hover: hover) {
    .mem-close-btn:hover {
        color: #1f2937;
    }
}

/* ============================================
   OPTION BUTTONS
   ============================================ */

.mem-option-btn {
    display: block;
    width: 100%;
    padding: 16px;
    margin-bottom: 12px;
    background: #f3f4f6;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.mem-option-btn:active {
    transform: scale(0.98);
}

@media (hover: hover) {
    .mem-option-btn:hover {
        background: #e5e7eb;
        border-color: #2563eb;
    }
}

.mem-option-title {
    font-weight: 700;
    color: #1f2937;
    font-size: 1em;
    margin-bottom: 4px;
}

.mem-option-desc {
    font-size: 0.85em;
    color: #6b7280;
}

/* ============================================
   LEVEL OPTIONS
   ============================================ */

.mem-level-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mem-level-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.mem-level-btn.locked {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
    cursor: not-allowed;
    opacity: 0.7;
}

.mem-level-btn:disabled {
    cursor: not-allowed;
}

.mem-level-btn:active:not(:disabled) {
    transform: scale(0.98);
}

@media (hover: hover) {
    .mem-level-btn:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
    }
}

.mem-level-num {
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 4px;
}

.mem-level-desc {
    font-size: 0.85em;
    opacity: 0.9;
    margin-bottom: 8px;
}

.mem-level-score,
.mem-level-locked,
.mem-level-status {
    font-size: 0.8em;
    opacity: 0.8;
}

/* ============================================
   VERSE LIST
   ============================================ */

.mem-verse-list {
    max-height: 60vh;
    overflow-y: auto;
}

.mem-verse-option {
    display: block;
    width: 100%;
    padding: 16px;
    margin-bottom: 8px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.mem-verse-option:active {
    transform: scale(0.98);
}

@media (hover: hover) {
    .mem-verse-option:hover {
        background: #f3f4f6;
        border-color: #2563eb;
    }
}

.mem-verse-ref {
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
}

.mem-verse-level {
    font-size: 0.85em;
    color: #6b7280;
}

/* ============================================
   VERSE DISPLAY
   ============================================ */

.mem-verse-display {
    background: #f9fafb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    line-height: 2;
    min-height: 200px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    align-items: flex-start;
}

.mem-verse-text {
    word-wrap: break-word;
    color: #d1d5db;
    transition: color 0.1s;
    width: 100%;
}

.mem-word {
    display: inline;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    transition: color 0.1s;
    cursor: default;
    white-space: pre-wrap;
}

/* Stoplight system for failed attempts */
.mem-wrong-red {
    background: rgba(239, 68, 68, 0.25) !important;
    border-radius: 3px;
    padding: 2px 4px;
}

.mem-wrong-yellow {
    background: rgba(234, 179, 8, 0.25) !important;
    border-radius: 3px;
    padding: 2px 4px;
}

/* Invisible words (for Level 2 & 3 hidden words) */
.mem-hidden-word {
    color: transparent !important;
}

/* Make yellow/red highlights visible even on invisible words */
/* Keep text transparent but show background */
.mem-hidden-word.mem-wrong-red {
    background: rgba(239, 68, 68, 0.5) !important;
    color: transparent !important;
}

.mem-hidden-word.mem-wrong-yellow {
    background: rgba(234, 179, 8, 0.5) !important;
    color: transparent !important;
}

/* When user types and reveals the word correctly (green) */
.mem-hidden-word[style*="color: rgb(34, 197, 94)"],
.mem-hidden-word[style*="color: #22c55e"] {
    color: #22c55e !important;
}

/* When user types and reveals the word incorrectly (red) */
.mem-hidden-word[style*="color: rgb(239, 68, 68)"],
.mem-hidden-word[style*="color: #ef4444"] {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.15);
}

.mem-blank {
    display: inline-block;
    border: none;
    border-bottom: 2px solid #d1d5db;
    border-radius: 0;
    padding: 4px 0;
    margin: 0 2px;
    min-width: 0;
    min-height: 1.2em;
    vertical-align: baseline;
    transition: border-color 0.1s, color 0.1s;
    background: transparent;
    text-align: center;
}

.mem-blank[style*="color: rgb(34, 197, 94)"],
.mem-blank[style*="color: #22c55e"] {
    border-bottom-color: #22c55e;
    background: transparent;
    color: #22c55e;
}

.mem-blank[style*="color: rgb(239, 68, 68)"],
.mem-blank[style*="color: #ef4444"] {
    border-bottom-color: #ef4444;
    background: transparent;
    color: #ef4444;
}

/* Level 1 specific */
.mem-level1 .mem-word {
    color: #d1d5db;
}

/* ============================================
   PROGRESS & INPUT
   ============================================ */

.mem-hidden-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    /* DO NOT use pointer-events: none - it prevents focus and keyboard interaction on Android */
    left: -9999px;
    top: 0;
}

.mem-progress {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: auto;
    padding: 20px 0 0 0;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.mem-progress-info {
    text-align: center;
}

#memProgressText {
    font-size: 1.1em;
    font-weight: 700;
    color: #1f2937;
}

/* ============================================
   LEVEL CLOSE BUTTON
   ============================================ */

.mem-level-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2010;
}

.mem-x-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mem-x-btn:active {
    transform: scale(0.95);
}

@media (hover: hover) {
    .mem-x-btn:hover {
        background: white;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* ============================================
   RESULTS MODAL
   ============================================ */

.mem-results-modal {
    max-width: 400px;
}

.mem-results-content {
    text-align: center;
    padding: 20px 0;
}

.mem-progress-ring-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 30px;
}

.mem-progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.mem-progress-bg {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 8;
}

.mem-progress-fill {
    fill: none;
    stroke: url(#memProgressGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 314;
    transition: stroke-dashoffset 1s ease-out;
}

.mem-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    font-weight: 700;
    color: #1f2937;
}

.mem-results-modal h3 {
    font-size: 1.5em;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.mem-results-modal p {
    color: #6b7280;
    margin: 0 0 24px 0;
}

.mem-results-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================
   BUTTONS
   ============================================ */

.mem-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
}

.mem-btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.mem-btn-retry {
    background: #f3f4f6;
    color: #1f2937;
}

.mem-btn-next {
    background: #22c55e;
    color: white;
}

.mem-btn-close {
    background: transparent;
    color: #6b7280;
    border: 2px solid #e5e7eb;
}

.mem-btn:active {
    transform: scale(0.98);
}

@media (hover: hover) {
    .mem-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .mem-btn-primary:hover {
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    }

    .mem-btn-next:hover {
        box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
    }
}

/* ============================================
   INSTRUCTIONS MODAL
   ============================================ */

.mem-instructions-modal {
    max-width: 500px;
}

.mem-modal-content {
    padding: 16px 0;
}

.mem-instruction-item {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.mem-instruction-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.mem-instruction-item h4 {
    margin: 0 0 8px 0;
    color: #1f2937;
    font-weight: 700;
    font-size: 1em;
}

.mem-instruction-item p {
    margin: 0;
    color: #6b7280;
    font-size: 0.9em;
    line-height: 1.6;
}

/* ============================================
   DARK MODE
   ============================================ */

body.night-mode .mem-modal,
body.night-mode .mem-level-modal {
    background: #1f2937;
    color: #f3f4f6;
}

body.night-mode .mem-modal-header h3 {
    color: #f3f4f6;
}

body.night-mode .mem-close-btn {
    color: #9ca3af;
}

body.night-mode .mem-close-btn:hover {
    color: #f3f4f6;
}

body.night-mode .mem-option-btn {
    background: #374151;
    color: #f3f4f6;
}

body.night-mode .mem-option-btn:hover {
    background: #4b5563;
    border-color: #3b82f6;
}

body.night-mode .mem-option-title {
    color: #f3f4f6;
}

body.night-mode .mem-option-desc {
    color: #d1d5db;
}

body.night-mode .mem-verse-display {
    background: #374151;
}

body.night-mode .mem-verse-text {
    color: #9ca3af;
}

body.night-mode .mem-blank {
    border-bottom-color: #4b5563;
}

/* Dark mode stoplight colors */
body.night-mode .mem-wrong-red {
    background: rgba(239, 68, 68, 0.3);
}

body.night-mode .mem-wrong-yellow {
    background: rgba(234, 179, 8, 0.3);
}

body.night-mode .mem-x-btn {
    background: rgba(31, 41, 55, 0.9);
}

body.night-mode .mem-x-btn:hover {
    background: rgba(31, 41, 55, 1);
}

body.night-mode .mem-results-content h3 {
    color: #f3f4f6;
}

body.night-mode .mem-results-content p {
    color: #d1d5db;
}

body.night-mode .mem-progress-text {
    color: #f3f4f6;
}

body.night-mode .mem-btn-retry {
    background: #374151;
    color: #f3f4f6;
}

body.night-mode .mem-btn-close {
    color: #9ca3af;
    border-color: #4b5563;
}

body.night-mode .mem-instruction-item {
    border-bottom-color: #4b5563;
}

body.night-mode .mem-instruction-item h4 {
    color: #f3f4f6;
}

body.night-mode .mem-instruction-item p {
    color: #d1d5db;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .mem-modal,
    .mem-level-modal {
        border-radius: 12px;
        margin: 16px;
    }

    .mem-verse-display {
        min-height: 150px;
    }

    .mem-progress-ring-container {
        width: 120px;
        height: 120px;
    }

    .mem-progress-text {
        font-size: 1.5em;
    }

    .mem-results-buttons {
        gap: 8px;
    }

    .mem-btn {
        padding: 10px 16px;
        font-size: 0.9em;
        flex: 1;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .mem-modal {
        max-height: 90vh;
        border-radius: 12px;
        margin: 8px;
        padding: 16px;
    }

    .mem-modal-header h3 {
        font-size: 1.1em;
    }

    .mem-verse-display {
        padding: 16px;
        min-height: 120px;
        font-size: 0.95em;
    }

    .mem-progress-ring-container {
        width: 100px;
        height: 100px;
        margin-bottom: 20px;
    }

    .mem-progress-text {
        font-size: 1.3em;
    }

    .mem-results-modal {
        max-width: 90%;
    }

    .mem-btn {
        padding: 10px 12px;
        font-size: 0.85em;
    }
}

/* ============================================
   DESKTOP/WEBSITE LAYOUT
   ============================================ */

/* For larger screens (desktop/website), use smaller modal centered on screen */
@media (min-width: 1024px) {
    .mem-level-overlay {
        align-items: center;
        justify-content: center;
    }

    .mem-level-modal {
        width: 50vw;
        height: 50vh;
        max-width: 900px;
        max-height: 700px;
        border-radius: 16px;
        border: 1px solid #e5e7eb;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }

    .mem-verse-display {
        margin-bottom: 20px;
    }

    .mem-level-close {
        position: absolute;
        top: 20px;
        right: 20px;
        z-index: 2010;
    }
}
