/* Shared site chrome: reset, color/font tokens, page-loader, header/nav,
   theme + font toggles, footer, focus outline, reduced-motion. Loaded on
   every page except legal/*.html (which has its own css/legal.css with a
   deliberately reduced token set and no header/nav chrome) and admin.html
   (separate dashboard header with no theme/font/menu-toggle buttons). */

@font-face {
    font-family: 'OpenDyslexic';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/fontsource/fonts/opendyslexic@5.3.0/latin-400-normal.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/fontsource/fonts/opendyslexic@5.3.0/latin-400-normal.woff') format('woff');
}

@font-face {
    font-family: 'OpenDyslexic';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/fontsource/fonts/opendyslexic@5.3.0/latin-700-normal.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/fontsource/fonts/opendyslexic@5.3.0/latin-700-normal.woff') format('woff');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --midnight: #0B1320;
    --deep-plum: #4A2B5A;
    --storm-teal: #1E5B5A;
    --antique-gold: #C9972B;
    --fox-copper: #C76B2A;
    --aged-parchment: #F2EBD6;
    --text-dark: #2B2B2B;
    --text-light: #F9F7F2;

    --bg-page: var(--aged-parchment);
    --bg-surface: rgba(255, 255, 255, 0.5);
    --border-subtle: #d0c8b8;
    --border-ui: #e0e0e0;
    --shadow-ui: rgba(0, 0, 0, 0.12);
    --text-body: var(--text-dark);
    --text-heading: var(--midnight);
    --accent: var(--deep-plum);
    --link-hover-bg: rgba(74, 43, 90, 0.06);
    --icon-tone: var(--midnight);
    --cta-hover: var(--midnight);
    --good: #2f7a4a;
    --warn: #b3651a;

    --font-display: 'Cormorant Garamond', serif;
    --font-ui: 'League Spartan', sans-serif;
    --font-body: 'Lora', serif;
}

:root[data-theme="dark"] {
    --bg-page: #10161f;
    --bg-surface: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.14);
    --border-ui: rgba(255, 255, 255, 0.12);
    --shadow-ui: rgba(0, 0, 0, 0.5);
    --text-body: var(--text-light);
    --text-heading: var(--text-light);
    --accent: var(--antique-gold);
    --link-hover-bg: rgba(249, 247, 242, 0.08);
    --icon-tone: var(--text-light);
    --cta-hover: var(--fox-copper);
    --good: #5cbf82;
    --warn: #e0954a;
}

:root[data-font="dyslexic"] {
    --font-display: 'OpenDyslexic', sans-serif;
    --font-ui: 'OpenDyslexic', sans-serif;
    --font-body: 'OpenDyslexic', sans-serif;
}

body {
    font-family: var(--font-body);
    color: var(--text-body);
    line-height: 1.6;
    background-color: var(--bg-page);
    opacity: 0;
    transition: opacity 0.4s ease, background-color 0.3s ease, color 0.3s ease;
}

body.loaded {
    opacity: 1;
}

/* Page Loader */
.page-loader {
    position: fixed;
    inset: 0;
    background-color: var(--bg-page);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

@keyframes loader-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Header */
header {
    background-color: var(--bg-page);
    padding: 0.5rem 2rem;
    border-bottom: 1px solid var(--border-ui);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    color: var(--text-heading);
}

.logo-banner {
    height: 80px;
    width: auto;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    margin-left: auto;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-ui);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--text-heading);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: var(--link-hover-bg);
}

.theme-icon {
    width: 18px;
    height: 18px;
}

.theme-icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
    display: block;
}

:root[data-theme="dark"] .theme-icon-moon {
    display: none;
}

.theme-light-only,
.theme-dark-only {
    display: none;
}

:root[data-theme="light"] .theme-light-only {
    display: block;
}

:root[data-theme="dark"] .theme-light-only {
    display: none;
}

:root[data-theme="dark"] .theme-dark-only {
    display: block;
}

:root[data-theme="light"] .theme-dark-only {
    display: none;
}

.font-toggle {
    background: none;
    border: 1px solid var(--border-ui);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--text-heading);
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 700;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    flex-shrink: 0;
}

.font-toggle:hover {
    background-color: var(--link-hover-bg);
}

.font-toggle[aria-pressed="true"] {
    background-color: var(--deep-plum);
    color: white;
    border-color: var(--deep-plum);
}

:root[data-theme="dark"] .font-toggle[aria-pressed="true"] {
    background-color: var(--antique-gold);
    color: var(--midnight);
    border-color: var(--antique-gold);
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0.4rem;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--icon-tone);
    transition: all 0.3s ease;
}

.menu-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 1rem);
    right: 0;
    background-color: var(--bg-page);
    border: 1px solid var(--border-ui);
    border-radius: 8px;
    padding: 0.75rem 0;
    min-width: 220px;
    box-shadow: 0 8px 24px var(--shadow-ui);
    z-index: 200;
}

nav.open {
    display: flex;
}

nav a {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-body);
    text-decoration: none;
    transition: color 0.3s ease, background-color 0.3s ease;
    white-space: nowrap;
    padding: 0.7rem 1.5rem;
}

nav a:hover {
    color: var(--accent);
    background-color: var(--link-hover-bg);
}

.nav-cta {
    background-color: var(--deep-plum);
    color: white;
    padding: 0.6rem 1.2rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-family: var(--font-ui);
    display: inline-block;
    text-decoration: none;
}

.nav-cta:hover {
    background-color: var(--cta-hover);
}

/* Footer */
footer {
    background-color: var(--midnight);
    color: white;
    padding: 2rem;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

footer p {
    margin-bottom: 0.5rem;
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Native hidden-attribute visibility toggle — always wins over an
   element's own display:flex/block rule regardless of source order, so
   JS can toggle visibility via el.hidden instead of el.style.display. */
[hidden] {
    display: none !important;
}
