/* CSS Variables for Accessibility and Apple-like Styling */
:root {
    /* Fonts */
    --font-primary: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    
    /* Layout Sizes */
    --container-width: 1100px;
    --header-height: 48px;
    
    /* Color Palette - Default Light (Apple style) */
    --bg-color: #ffffff;
    --bg-hero: #f5f5f7;
    --bg-card: #f5f5f7;
    --bg-footer: #f5f5f7;
    --text-color: #1d1d1f;
    --text-secondary: #86868b;
    --link-color: #0071e3;
    --link-hover: #00c2ff;
    --border-color: #d2d2d7;
    --accent-color: #0071e3;
    
    /* Focus Ring */
    --focus-ring: 3px solid #0071e3;
    --focus-offset: 2px;
}

/* High Contrast Theme Override */
body.contrast-high {
    --bg-color: #000000;
    --bg-hero: #000000;
    --bg-card: #000000;
    --bg-footer: #000000;
    --text-color: #ffffff;
    --text-secondary: #ffff00;
    --link-color: #ffff00;
    --link-hover: #00ffff;
    --border-color: #ffffff;
    --accent-color: #ffff00;
    --focus-ring: 4px solid #ffff00;
}

/* Dark Mode Override */
body.contrast-dark {
    --bg-color: #1d1d1f;
    --bg-hero: #000000;
    --bg-card: #2d2d2f;
    --bg-footer: #161617;
    --text-color: #f5f5f7;
    --text-secondary: #86868b;
    --link-color: #2997ff;
    --link-hover: #51a8ff;
    --border-color: #424245;
    --accent-color: #2997ff;
    --focus-ring: 3px solid #2997ff;
}

/* Font Size Scales */
body.font-large {
    font-size: 1.25rem;
}
body.font-large h1, body.font-large .hero-title { font-size: 3.5rem; }
body.font-large h2 { font-size: 2.2rem; }
body.font-large h3 { font-size: 1.5rem; }

body.font-xlarge {
    font-size: 1.5rem;
}
body.font-xlarge h1, body.font-xlarge .hero-title { font-size: 4rem; }
body.font-xlarge h2 { font-size: 2.5rem; }
body.font-xlarge h3 { font-size: 1.75rem; }

/* Dyslexic Font Override */
body.dyslexic-font {
    --font-primary: "Comic Sans MS", "Comic Sans", "Courier New", cursive, sans-serif;
    letter-spacing: 0.15em;
    word-spacing: 0.25em;
    line-height: 1.8;
}

/* Reset and Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease, font-size 0.2s ease;
}

/* Focus Indicator for Keyboard Nav (Accessibility) */
*:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    background: var(--accent-color);
    color: #fff;
    padding: 10px 20px;
    z-index: 10000;
    transition: top 0.2s;
    font-weight: bold;
}
.skip-link:focus {
    top: 10px;
    outline: none;
}

/* Screen Reader Only Utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Header & Navigation */
header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    position: sticky;
    top: 0;
    z-index: 999;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    display: flex;
    align-items: center;
    transition: background-color 0.3s, border-color 0.3s;
}

body.contrast-dark header {
    background-color: rgba(29, 29, 31, 0.8);
}
body.contrast-high header {
    background-color: #000;
    border-bottom: 2px solid #fff;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo a {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo a:hover {
    text-decoration: none;
}
.logo-icon {
    font-size: 1.3rem;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 24px;
    align-items: center;
}

nav a {
    color: var(--text-color);
    font-size: 0.85rem;
    opacity: 0.8;
    font-weight: 400;
}
nav a:hover, nav a.active {
    opacity: 1;
    color: var(--link-color);
    text-decoration: none;
}

/* Header Tools: Languages & Accessibility Button */
.header-tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

.lang-selector {
    position: relative;
    display: inline-block;
}

.lang-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lang-dropdown {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-width: 100px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
}

.lang-dropdown a {
    color: var(--text-color);
    padding: 8px 12px;
    display: block;
    font-size: 0.8rem;
    text-align: left;
}
.lang-dropdown a:hover {
    background-color: var(--bg-card);
    text-decoration: none;
}

.lang-selector:hover .lang-dropdown,
.lang-selector:focus-within .lang-dropdown {
    display: block;
}

.accessibility-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--link-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transition: transform 0.2s, background-color 0.2s;
    z-index: 10001;
}
.accessibility-toggle:hover {
    transform: scale(1.1);
    background-color: var(--link-hover);
}
.accessibility-toggle svg {
    fill: currentColor;
    width: 28px;
    height: 28px;
}
body.contrast-high .accessibility-toggle {
    background-color: #000;
    color: #ffff00;
    border: 2px solid #ffff00;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Hero Section */
.hero {
    background-color: var(--bg-hero);
    padding: 80px 0;
    text-align: center;
    transition: background-color 0.3s;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin-bottom: 12px;
    color: var(--text-color);
}

.hero-subtitle {
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 32px auto;
}

.hero-cta {
    display: inline-block;
    background-color: var(--link-color);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 980px;
    font-weight: 500;
    font-size: 1rem;
    transition: background-color 0.2s, transform 0.2s;
}
.hero-cta:hover {
    background-color: var(--link-hover);
    text-decoration: none;
    transform: scale(1.02);
}
body.contrast-high .hero-cta {
    background-color: #000;
    color: #ffff00;
    border: 2px solid #ffff00;
}

/* Mission Section */
.section-mission {
    padding: 80px 0;
    border-bottom: 1px solid var(--border-color);
}
.mission-card {
    background-color: var(--bg-card);
    border-radius: 18px;
    padding: 48px;
    max-width: 850px;
    margin: 0 auto;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    border: 1px solid var(--border-color);
}
body.contrast-high .mission-card {
    border: 2px solid #fff;
}
.section-tag {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--link-color);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
    display: block;
}
.mission-text {
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-color);
    letter-spacing: -0.01em;
}

/* Pillars Section */
.section-pillars {
    padding: 80px 0;
}

.section-title {
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 48px;
    letter-spacing: -0.01em;
}

.pillars-grid {
    display: grid;
    grid-template-columns: repeat(3, 1px); /* trick for flexbox-like layouts, let's use 1fr */
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.pillar-card {
    background-color: var(--bg-card);
    border-radius: 18px;
    padding: 32px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}
.pillar-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.05);
}
body.contrast-high .pillar-card {
    border: 2px solid #fff;
}
body.contrast-high .pillar-card:hover {
    transform: none;
    box-shadow: none;
}

.pillar-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--link-color);
    margin-bottom: 12px;
}

.pillar-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.3;
}

.pillar-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    flex-grow: 1;
}

/* Contact Page Styles */
.contact-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 48px;
    padding: 60px 0 80px 0;
}

.contact-info h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.contact-info p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.info-item {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    align-items: flex-start;
}

.info-icon {
    font-size: 1.5rem;
    color: var(--link-color);
    line-height: 1;
}

.info-label {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.info-val {
    font-size: 1.05rem;
    color: var(--text-color);
}

.contact-form {
    background-color: var(--bg-card);
    padding: 40px;
    border-radius: 18px;
    border: 1px solid var(--border-color);
}
body.contrast-high .contact-form {
    border: 2px solid #fff;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s, outline 0.2s;
}

.form-control:focus {
    border-color: var(--link-color);
    outline: none;
}

textarea.form-control {
    resize: vertical;
    min-height: 150px;
}

.btn-primary {
    background-color: var(--link-color);
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--link-hover);
}

.btn-primary:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.alert-success {
    background-color: rgba(52, 199, 89, 0.15);
    border: 1px solid #34c759;
    color: #248a3d;
}
body.contrast-dark .alert-success {
    color: #30d158;
}
body.contrast-high .alert-success {
    background-color: #000;
    color: #fff;
    border: 2px solid #fff;
}
.alert-error {
    background-color: rgba(255, 59, 48, 0.15);
    border: 1px solid #ff3b30;
    color: #d72c20;
}
body.contrast-dark .alert-error {
    color: #ff453a;
}
body.contrast-high .alert-error {
    background-color: #000;
    color: #fff;
    border: 2px solid #fff;
}

/* Accessibility Floating Panel */
.accessibility-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 320px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.accessibility-panel.open {
    display: flex;
}
body.contrast-high .accessibility-panel {
    border: 3px solid #fff;
    box-shadow: none;
}

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

.acc-panel-header {
    background-color: var(--bg-card);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.acc-panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}
.acc-close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.acc-panel-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.acc-section {
    margin-bottom: 20px;
}
.acc-section:last-child {
    margin-bottom: 0;
}
.acc-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.acc-btn-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.acc-btn-group-2 {
    grid-template-columns: repeat(2, 1fr);
}

.acc-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    text-align: center;
}
.acc-btn:hover {
    background-color: var(--border-color);
}
.acc-btn.active {
    background-color: var(--link-color);
    color: #fff;
    border-color: var(--link-color);
}
body.contrast-high .acc-btn.active {
    background-color: #000;
    color: #ffff00;
    border-color: #ffff00;
}

.acc-toggle-switch {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}
.acc-toggle-status {
    color: var(--link-color);
    font-weight: 600;
}

.acc-reset-btn {
    width: 100%;
    margin-top: 10px;
    background-color: #ff3b30;
    color: #fff;
    border: none;
}
.acc-reset-btn:hover {
    background-color: #d72c20;
}

/* Footer */
footer {
    background-color: var(--bg-footer);
    padding: 60px 0 40px 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: background-color 0.3s;
}

body.contrast-high footer {
    border-top: 2px solid #fff;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 48px;
    margin-bottom: 40px;
}

.footer-brand h3 {
    color: var(--text-color);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 12px;
}
.footer-brand p {
    line-height: 1.6;
    margin-bottom: 16px;
    max-width: 400px;
}

.footer-title {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.footer-links {
    list-style: none;
}
.footer-links li {
    margin-bottom: 10px;
}
.footer-links a {
    color: var(--text-secondary);
}
.footer-links a:hover {
    color: var(--link-color);
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* TTS Focus indicator */
.tts-hover {
    outline: 2px dashed var(--accent-color) !important;
}

/* Responsive CSS */
@media (max-width: 900px) {
    .pillars-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .contact-container {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }
}

@media (max-width: 600px) {
    :root {
        --header-height: 60px;
    }
    
    header {
        position: relative;
    }
    
    .menu-toggle {
        display: block;
    }
    
    nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        width: 100%;
        background-color: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        padding: 20px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    
    nav.open {
        display: block;
    }
    
    nav ul {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .hero-title {
        font-size: 2.2rem;
    }
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .mission-card {
        padding: 24px;
    }
    .mission-text {
        font-size: 1.25rem;
    }
    
    .accessibility-panel {
        width: calc(100% - 32px);
        left: 16px;
        bottom: 16px;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}
