/* ==========================================================================
   Interactive Reading App Substyle (article.css)
   ========================================================================== */

/* Focus Overlay: Fades background to highlight active definitions */
#focus-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: rgba(250, 250, 250, 0.75); 
    backdrop-filter: blur(1.5px); 
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#focus-overlay.active {
    opacity: 1;
    pointer-events: auto; 
}

/* Dyslexia-Friendly Reading Card Overrides */
.reading-card {
    background-color: #faf9f6; 
    font-family: 'Lexend', 'Comic Sans MS', sans-serif;
    font-size: 1.15rem; 
    line-height: 1.8; 
    letter-spacing: 0.03em; 
    word-spacing: 0.08em; 
    color: #1e293b;
    position: relative;
}

.reading-card p {
    margin-bottom: 1.5em; 
    text-align: left; 
    color: #1e293b;
}

.instructions {
    text-align: center;
    background-color: #dbeafe;
    color: #1e40af;
    font-size: 0.95em;
    font-weight: 500;
    margin-bottom: 30px;
    padding: 12px;
    border-radius: 8px;
    border-left: 5px solid #3b82f6;
    font-family: 'Inter', sans-serif;
}

/* Clickable Word Interactive States */
.clickable-word {
    cursor: pointer;
    padding: 2px 4px;
    margin: 0 -2px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clickable-word:hover { 
    background-color: #bae6fd; 
    color: #0f172a; 
}

.clickable-word.highlighted { 
    background-color: #fde047; 
    color: #0f172a; 
}

.clickable-word.highlighted.defining {
    background-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
    position: relative;
    z-index: 901; /* Layer above the focus overlay */
}

.clickable-word.highlighted.defining:hover { 
    background-color: #ea580c; 
    color: #ffffff; 
}

/* Dynamic Tooltip UI */
#dynamic-tooltip {
    visibility: hidden;
    width: max-content;
    max-width: 280px;
    min-width: 200px;
    background-color: #1e293b;
    color: #f8fafc;
    text-align: left;
    border-radius: 12px;
    padding: 16px 20px;
    position: absolute;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    pointer-events: none; 
}

#dynamic-tooltip.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; 
}

#dynamic-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -7px;
    border-width: 7px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

.loading { 
    color: #94a3b8; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.word-title { 
    color: #fbbf24; 
    font-size: 1.1em; 
    font-weight: 600; 
    display: inline-block; 
    margin-bottom: 4px; 
    text-transform: capitalize; 
    margin-right: 6px; 
}

/* Retry Button */
.retry-btn {
    display: inline-block;
    margin-top: 12px;
    background-color: #334155;
    color: #cbd5e1;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85em;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
}

.retry-btn:hover { 
    background-color: #475569; 
    color: #f8fafc; 
    border-color: #64748b; 
}

.retry-count { 
    float: right; 
    color: #94a3b8; 
    font-size: 0.9em; 
}

/* Word Bank Table Module */
.word-bank-card {
    margin-top: -10px;
    display: none; 
    position: relative;
    z-index: 1; 
}

.word-bank-table { 
    width: 100%; 
    border-collapse: collapse; 
    text-align: left; 
    font-family: 'Inter', sans-serif;
}

.word-bank-table th { 
    padding: 12px 8px; 
    color: #475569; 
    border-bottom: 2px solid #e2e8f0; 
    font-size: 1.05rem; 
}

.word-bank-table td { 
    padding: 14px 8px; 
    border-bottom: 1px solid #f1f5f9; 
    vertical-align: top; 
    color: #333; 
}

/* Video Section Embeds */
.video-section { 
    margin-bottom: 35px; 
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.video-wrapper iframe {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    border: none;
}

.video-caption {
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: #6b7280;
    font-style: italic;
    margin-top: 12px;
}

/* Article image infrastructure */
.article-image-frame {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    background: #eef2f7;
    border: 1px solid #e2e8f0;
}
.article-image-frame::before {
    content: attr(data-placeholder);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    text-align: center;
    color: #64748b;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.45;
}
.article-image-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}
.article-image-frame.has-image img { opacity: 1; }
.article-image-frame.has-image::before { display: none; }
.article-hero {
    margin: 0 0 30px;
}
.article-hero .article-image-frame {
    aspect-ratio: 16 / 9;
}
.article-support-image {
    margin: 28px 0 32px;
}
.article-support-image .article-image-frame {
    aspect-ratio: 16 / 9;
}
.article-support-image figcaption {
    margin-top: 10px;
    color: #64748b;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.55;
}
@media (max-width: 600px) {
    .article-hero { margin-bottom: 22px; }
    .article-support-image { margin: 22px 0 26px; }
}
