@import url('https://fonts.cdnfonts.com/css/opendyslexic');

:root {
    --bg-color: #f4f4f9;
    --text-color: #333333;
    --sidebar-bg: #ffffff;
    --highlight-bg: #e0e0e0;
}

body.dark-mode {
    --bg-color: #121212;
    --text-color: #ffeb3b;
    --sidebar-bg: #1e1e1e;
    --highlight-bg: #333333;
}

body {
    margin: 0;
    font-family: system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background 0.3s, color 0.3s;
}

body.dyslexic-font {
    font-family: 'OpenDyslexic', sans-serif;
}

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.how-to-use {
    margin-top: 30px;
    background: var(--highlight-bg);
    border-radius: 5px;
    padding: 10px;
    font-size: 0.9em;
}

.how-to-use summary {
    font-weight: bold;
    cursor: pointer;
    outline: none;
    padding: 5px 0;
}

.how-to-use summary:hover {
    opacity: 0.8;
}

.how-to-use ol {
    margin: 10px 0 0 0;
    padding-left: 20px;
    line-height: 1.5;
}

.how-to-use li {
    margin-bottom: 8px;
}

.feedback-section {
    margin-top: 20px;
    text-align: center;
}

.feedback-text {
    font-size: 0.85em;
    margin-bottom: 10px;
    color: var(--text-color);
    opacity: 0.8;
}

.feedback-btn {
    display: block;
    padding: 10px;
    background: transparent;
    color: var(--text-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9em;
    border: 2px solid #ccc;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.feedback-btn:hover {
    background: #ccc;
    color: #333;
}

body.dark-mode .feedback-btn {
    border-color: #555;
}

body.dark-mode .feedback-btn:hover {
    background: #555;
    color: #ffeb3b; 
}

.controls { 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    margin-top: 20px;
}

button { 
    padding: 12px; 
    cursor: pointer; 
    background: #0056b3; 
    color: white; 
    font-weight: bold;
    border: none; 
    border-radius: 5px; 
}

.content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

textarea {
    width: 100%;
    height: 300px;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #ccc;
    border-radius: 5px;
    resize: vertical;
}

#reader-output {
    font-size: 1.3rem;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto;
    text-align: justify;
    overflow-wrap: break-word;
}
.hidden { 
    display: none; 
}

#reader-output p {
    display: block;
    margin-top: 0;
    margin-bottom: 1.5em !important; 
    line-height: 1.8;
}

.upload-btn {
    padding: 12px;
    cursor: pointer;
    background: #28a745;
    color: white;
    font-weight: bold;
    text-align: center;
    border-radius: 5px;
    display: block;
    transition: background 0.2s;
}

.upload-btn:hover {
    background: #218838;
}

.hidden { 
    display: none !important; 
}
/* =========================================
   LINE FOCUS LOGIC (Desktop & Mobile)
   ========================================= */

/* 1. Base State: Normal, sharp text with smooth transitions */
#reader-output.focus-active .sentence {
    padding: 5px;
    margin: -5px;
    border-radius: 6px;
    transition: opacity 0.15s ease, filter 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

/* 2. DESKTOP ONLY (Devices with a physical mouse) */
@media (hover: hover) and (pointer: fine) {
    #reader-output.focus-active:has(.sentence:hover) .sentence:not(:hover) {
        opacity: 0.35;
        filter: blur(3px);
    } 
    #reader-output.focus-active:has(.sentence:hover) .sentence:has(+ .sentence:hover):not(:hover),
    #reader-output.focus-active:has(.sentence:hover) .sentence:hover + .sentence,
    
    #reader-output.focus-active p:has(+ p .sentence:hover:first-child) .sentence:last-child,
    #reader-output.focus-active p:has(.sentence:hover:last-child) + p .sentence:first-child,

    #reader-output.focus-active p:has(+ .spacer + p .sentence:hover:first-child) .sentence:last-child,
    #reader-output.focus-active p:has(.sentence:hover:last-child) + .spacer + p .sentence:first-child {
        opacity: 0.70; 
        filter: blur(1.2px); 
    }

    #reader-output.focus-active .sentence:hover {
        opacity: 1;
        filter: blur(0px); 
        background-color: var(--highlight-bg);
        font-size: 1.15em;
        box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.15);
        position: relative;
        z-index: 2;
    }
}
/* 3. MOBILE ONLY (Touch screens without a mouse) */
@media (hover: none) and (pointer: coarse) {
    #reader-output.focus-active .sentence {
        pointer-events: none;
    }

    #reader-output.focus-active:has(.mobile-focus) .sentence {
        opacity: 0.35;
        filter: blur(3px);
    }

    #reader-output.focus-active .sentence.mobile-focus {
        opacity: 1;
        filter: blur(0px);
        background-color: var(--highlight-bg);
        font-size: 1.1em;
        box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.15);
        position: relative; 
        z-index: 2;
    }
}

/* --- Mobile Responsiveness --- */
@media screen and (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%; 
        padding: 15px;
        box-sizing: border-box; 
        box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    }

    .content {
        padding: 20px 15px;
        width: 100%;
        box-sizing: border-box;
    }

    textarea {
        height: 200px;
    }
 
    button, .upload-btn, .feedback-btn {
        padding: 14px; 
        font-size: 1.05em;
    }
    #reader-output {
        text-align: justify;
        hyphens: auto; 
        -webkit-hyphens: auto;
        width: 100%;
        box-sizing: border-box;
        padding-bottom: 50vh;
    }
    body, html {
        overflow-x: hidden;
    }

}