@charset "utf-8";

/* --- 0. ROOT VARIABLES & ACCESSIBILITY PALETTE --- */
:root {
    /* light mode: warm, high contrast, low glare */
    --bg-page: #FAF9F6;         /* "Off White" */
    --bg-content: #FFFFFF;      
    --bg-highlight: #F4F4F4;    /* Slightly darker for better edge visibility */
    
    --text-main: #0a0a0a;       /* Virtually Black - Max Contrast */
    --text-muted: #333333;      /* Darkened for readability (was #454545) */
    
    --border-color: #595959;    /* Darkened from #707070 for visibility */
    --border-focus: #000000;    
    --focus-ring: #ffbf00;      /* High Vis Yellow/Gold for focus halo */

    --primary-color: #004085;   /* Deep Blue (AAA compliant) */
    --link-color: #003366;      
    --link-visited: #551A8B;    
    
    /* ACCESSIBILITY CONSTRAINTS */
    --touch-min: 54px;          /* 65+ Standard: Larger than WCAG 44px */
    --line-height: 1.65;        /* Extra breathing room */
    --border-radius: 8px;
    --content-max-width: 900px; 
    --border-width-control: 3px; /* Thick borders for failing vision */
}

/* DARK MODE: OPTIMIZED FOR CATARACTS/ASTIGMATISM (Halation reduction) */
[data-theme="dark"] {
    --bg-page: #000000;         
    --bg-content: #121212;      
    --bg-highlight: #2A2A2A;    
    
    --text-main: #E0E0E0;       /* slightly dimmed white reduces blur */
    --text-muted: #C0C0C0;
    
    --border-color: #888888;
    --border-focus: #FFFFFF;
    --focus-ring: #0056b3;      /* Blue halo for dark mode */
    
    --primary-color: #90CAF9;   
    --link-color: #64B5F6;      
    --link-visited: #CE93D8;
}

/* --- 1. GLOBAL RESET & BASE --- */
* { box-sizing: border-box; }

html {
    font-size: 100%;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin: 0;
    padding: 0;
    line-height: var(--line-height);
    letter-spacing: 0.01em; /* Helps distinct character recognition */
    
    /* SENIOR DEFAULT SIZE */
    font-size: 21px;        
    -webkit-text-size-adjust: 100%;
}

/* --- CRITICAL: GLOBAL FOCUS STATE --- */
/* This helps users who use keyboard or have shaky mouse hands see where they are */
:focus-visible {
    outline: 4px solid var(--border-focus);
    outline-offset: 4px;
    box-shadow: 0 0 0 8px var(--focus-ring); /* Double ring effect */
    z-index: 10;
}

/* --- 2. LAYOUT CONTAINER --- */
#pap {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    background-color: var(--bg-content);
    padding: 24px 20px 100px 20px;
    min-height: 100vh;
}

@media (min-width: 768px) {
    body { padding: 30px; }
    #pap {
        border: 2px solid var(--border-color); /* Thicker border */
        border-radius: var(--border-radius);
        padding: 50px 60px;
        min-height: auto;
        box-shadow: 0 6px 12px rgba(0,0,0,0.15); /* Stronger shadow for depth */
    }
    body { font-size: 23px; } /* Slightly larger on desktop monitors */
}

/* --- 3. TYPOGRAPHY --- */
h1, h2, h3 {
    color: var(--text-main);
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    line-height: 1.3;
}

h1 { font-size: 2rem; font-weight: 800; text-align: center; }
h3 { font-size: 1.5rem; font-weight: 700; border-bottom: 3px solid var(--border-color); padding-bottom: 0.5rem; }

p { margin-bottom: 1.8rem; max-width: 65ch; } /* 65ch is easier to track for older eyes */

a {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
}
a:hover { 
    color: var(--primary-color); 
    text-decoration-thickness: 4px; 
    background-color: var(--bg-highlight); /* Highlight background on hover */
}

.copyright {
	font-size: 85%;
	margin-top: 1.8rem;
	text-align: center;
}

/* Devotional Specific Styles */
.source {
    display: inline-block;
    background: var(--bg-highlight);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.9em;
    border: 2px solid var(--border-color);
}

.topic {
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.08em;
    background: var(--bg-highlight);
    padding: 2px 6px;
    border: 1px solid var(--border-color); /* Added border for definition */
}

.sc { font-variant: small-caps; letter-spacing: 0.05em; }

/* --- 4. NAVIGATION & CONTROLS --- */
.content-header {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 25px;
    border-bottom: 3px solid var(--border-color);
}

.header-right-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

/* Common Control Styles */
.back-link, .icon-btn, .tree-controls button, .nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-min); /* 54px */
    padding: 0 20px;
    background-color: var(--bg-highlight);
    border: var(--border-width-control) solid var(--border-color); /* 3px border */
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.1s; /* Feedback on click */
}

.back-link:active, .icon-btn:active, .nav-btn:active {
    transform: scale(0.98);
    background-color: var(--border-color);
    color: var(--bg-page);
}

/* Theme Switcher */
.theme-switch-wrapper { display: flex; align-items: center; }
.theme-switch {
    position: relative;
    width: 64px;
    height: 38px;
}
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color); /* High contrast track */
    transition: .4s;
    border-radius: 38px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 30px; width: 30px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3); /* Shadow helps visibility */
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(26px); }

/* --- 5. TREE / ACCORDION --- */
.tree-controls { display: flex; gap: 12px; margin-bottom: 25px; }
.tree-controls button { flex: 1; text-align: center; }

.tree details { margin-bottom: 12px; }

.tree summary {
    cursor: pointer;
    list-style: none;
    padding: 16px 14px;
    background-color: var(--bg-highlight);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-weight: 700;
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tree summary::-webkit-details-marker { display: none; }

.tree summary::after {
    content: '+';
    font-size: 1.8rem;
    font-weight: 900;
    margin-left: 15px;
    /* Ensure the icon is large and high contrast */
    color: var(--text-main); 
}
.tree details[open] > summary::after { content: '−'; }

.tree ul {
    list-style: none;
    margin: 0;
    padding-left: 15px;
    border-left: 6px solid var(--border-color); /* Thicker guide line */
}

.tree li a {
    display: flex;
    align-items: center;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    min-height: var(--touch-min);
}

.top-level { 
    background-color: var(--primary-color) !important; 
    color: #ffffff !important;
    border-color: #000 !important;
}

/* --- 6. FOOTER NAV --- */
.trail-navigation {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 50px;
    border-top: 3px solid var(--border-color);
    padding-top: 30px;
}
.nav-btn {
    min-height: 64px; 
    font-size: 1.2em;
    width: 100%;
}
/* DESKTOP OPTIMIZATIONS */
@media (min-width: 768px) { 
    .trail-navigation { 
        flex-direction: row; 
        gap: 15px;
    } 

    .nav-btn {
        min-height: 50px; /* Reduced from 64px for cleaner desktop look */
        font-size: 1rem;  /* Reduced from 1.2em */
        width: auto;      /* Stop full width */
        flex: 1;          /* Distribute space evenly */
        padding: 0 15px;
    }
}

/* --- 7. UTILITIES --- */
.content-closing {
    margin-top: 40px;
    padding: 25px;
    background-color: var(--bg-highlight);
    border-radius: var(--border-radius);
    border-left: 8px solid var(--primary-color);
    font-style: italic;
}

#scrollTopBtn {
    display: none;
    position: fixed;
    bottom: 30px; right: 30px;
    z-index: 99;
    font-size: 2.5rem; /* Larger icon */
    background-color: var(--primary-color);
    color: white;
    border: 3px solid #fff; /* White border helps it pop off page */
    border-radius: 50%;
    width: 70px; /* Larger target */
    height: 70px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}
#scrollTopBtn.show { display: block; }

/* ZOOM SUPPORT */
html.large-text { font-size: 135%; }

/* --- 8. PRINT --- */
@media print {
    body { background: #fff; color: #000; padding: 0; font-size: 16pt; }
    #pap { border: none; padding: 0; box-shadow: none; max-width: 100%; }
    .nav-btn, .header-right-controls, #scrollTopBtn, .tree-controls { display: none; }
    a { text-decoration: underline; color: #000; }
}