/* ============================
   Fonts
   ============================ */

@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("/scripts/fonts/AtkinsonHyperlegibleNext-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("/scripts/fonts/AtkinsonHyperlegibleNext-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("/scripts/fonts/AtkinsonHyperlegibleNext-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ============================
   Root + base
   ============================ */

:root {
    --color-primary: #4b2e83; /* main purple */
    --color-primary-dark: #3a2366;
    --color-primary-light: #6b48aa;

    --color-bg-default: #f4f4f4;
    --color-text-default: #111111;

    --shadow-soft: 0 2px 4px rgba(0, 0, 0, 0.12);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.18);
    --radius-large: 0.75rem;

    --focus-color: #ffbf47; /* amber, good contrast */
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 18px;
    line-height: 1.6;
    background-color: var(--color-bg-default);
    color: var(--color-text-default);
}

/* ============================
   High contrast themes
   ============================ */

/* default theme */
body[data-theme="default"] {
    background-color: var(--color-bg-default);
    color: var(--color-text-default);
}

/* white text on black */
body[data-theme="white-on-black"] {
    background-color: #000000;
    color: #ffffff;
}

body[data-theme="white-on-black"] a {
    color: #9ecbff;
}

/* yellow text on black */
body[data-theme="yellow-on-black"] {
    background-color: #000000;
    color: #ffd800;
}

body[data-theme="yellow-on-black"] a {
    color: #ffd800;
    text-decoration: underline;
}

/* black text on gray */
body[data-theme="black-on-gray"] {
    background-color: #dcdcdc;
    color: #000000;
}

body[data-theme="black-on-gray"] a {
    color: #1a3d7c;
}

/* Article panels adjust for themes */
body[data-theme="white-on-black"] .content-article,
body[data-theme="yellow-on-black"] .content-article {
    background-color: transparent;
    border-color: currentColor;
}

body[data-theme="black-on-gray"] .content-article {
    background-color: #f5f5f5;
    border-color: #666666;
}

/* ============================
   Links & focus
   ============================ */

a {
    color: #333365;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
}

/* ============================
   Layout
   ============================ */

.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
}

/* Skip link */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 0.5rem 1rem;
    background: #ffffff;
    color: #000000;
    z-index: 999;
}

.skip-link:focus {
    left: 0.5rem;
    top: 0.5rem;
    box-shadow: var(--shadow-medium);
    border-radius: 0.25rem;
}

/* Screen-reader-only text */

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
}

/* ============================
   Theme controls bar
   ============================ */

.theme-controls {
    max-width: 1200px;
    margin: 0.5rem auto 0;
    padding: 0.5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.theme-controls label {
    font-weight: 500;
}

.theme-controls select,
.theme-controls button {
    font: inherit;
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    border: 1px solid #b3b3b3;
    background-color: #ffffff;
}

.theme-controls button {
    background-color: var(--color-primary);
    border-color: var(--color-primary-dark);
    color: #ffffff;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
}

.theme-controls button:hover,
.theme-controls button:focus-visible {
    background-color: var(--color-primary-dark);
}

/* ============================
   Header & navigation
   ============================ */

.site-header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #ffffff;
    box-shadow: var(--shadow-medium);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Logo + title */

.site-logo-link {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.site-logo {
    width: 56px;
    height: auto;
    display: block;
}

.site-title {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Nav + utility */

.header-spacer {
    flex: 1;
}

.site-nav {
    display: none;
}

.menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-desktop {
    display: flex;
    gap: 0.75rem;
}

.menu-desktop a {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
    color: #ffffff;
}

.menu-desktop a:hover,
.menu-desktop a:focus-visible {
    background-color: var(--color-primary-light);
    text-decoration: none;
}

/* Header buttons */

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-menu-toggle,
.search-toggle {
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: transparent;
    color: #ffffff;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    font: inherit;
    cursor: pointer;
}

.mobile-menu-toggle span.icon {
    font-size: 1.2rem;
}

.mobile-menu-toggle:hover,
.search-toggle:hover,
.mobile-menu-toggle:focus-visible,
.search-toggle:focus-visible {
    background-color: rgba(0, 0, 0, 0.15);
}

/* Desktop breakpoint */

@media (min-width: 900px) {
    .site-nav {
        display: block;
    }

    .mobile-menu-toggle {
        display: none;
    }
}

/* ============================
   Mobile nav dialog
   ============================ */

.nav-dialog {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 998;
}

.nav-dialog-inner {
    position: absolute;
    right: 0;
    top: 0;
    width: min(320px, 80vw);
    height: 100%;
    background-color: #ffffff;
    color: #000000;
    box-shadow: var(--shadow-medium);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-dialog header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-dialog-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
}

.menu-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-mobile a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background-color: #f4f4f4;
}

.menu-mobile a:hover,
.menu-mobile a:focus-visible {
    background-color: #e0e0e0;
}

/* hide mobile overlay on desktop */

@media (min-width: 900px) {
    .nav-dialog {
        display: none !important;
    }
}

/* ============================
   Search dialog
   ============================ */

.search-dialog {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

.search-dialog-inner {
    max-width: 480px;
    margin: 10vh auto;
    background-color: #ffffff;
    color: #000000;
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-medium);
    padding: 1.25rem 1.5rem 1.5rem;
}

.search-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.search-dialog-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
}

.search-dialog h2 {
    margin: 0;
}

/* Search form */
.search-dialog form {
    margin-top: 1rem;
    display: grid;
    gap: 0.5rem;
}

.search-dialog label {
    font-weight: 500;
}

.search-dialog input[type="search"] {
    font: inherit;
    padding: 0.4rem 0.5rem;
    border-radius: 0.35rem;
    border: 1px solid #b3b3b3;
}

.search-dialog button[type="submit"] {
    margin-top: 0.25rem;
    font: inherit;
    padding: 0.45rem 0.8rem;
    border-radius: 0.4rem;
    border: 1px solid var(--color-primary-dark);
    background-color: var(--color-primary);
    color: #ffffff;
    cursor: pointer;
}

.search-dialog button[type="submit"]:hover,
.search-dialog button[type="submit"]:focus-visible {
    background-color: var(--color-primary-dark);
}

/* ============================
   Headings
   ============================ */

h1,
h2,
h3,
h4 {
    color: var(--color-primary-dark);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.1rem;
}

/* ============================
   Article layout block
   ============================ */

.content-article {
    display: flex;
    flex-direction: column; /* stacked by default (mobile-first) */
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1rem;
    border-radius: var(--radius-large);
    border: 1px solid #cccccc;
    background-color: #ffffff;
    box-shadow: var(--shadow-soft);
}

.content-article > h2 {
    order: 0;
    margin-top: 0;
}

.article-media {
    order: 1;
    width: 100%;
}

.article-media img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

.article-body {
    order: 2;
    width: 100%;
}

.article-body p {
    margin-top: 0;
}

.article-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Desktop layout */
@media (min-width: 768px) {
    .content-article {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    .content-article > h2 {
        flex-basis: 100%;
        order: 0;
        margin-bottom: 0.25rem;
    }

    .article-media {
        flex: 0 0 30%;
        max-width: 30%;
        order: 1;
    }

    .article-body {
        flex: 1 0 70%;
        max-width: 70%;
        order: 2;
    }
}

/* ============================
   Font Size Modes
   ============================ */

body[data-font-size="default"] {
    font-size: 18px;
}

body[data-font-size="large"] {
    font-size: 20px;
}

body[data-font-size="xlarge"] {
    font-size: 22px;
}

body[data-font-size="large"] h1 { font-size: 2.3rem; }
body[data-font-size="large"] h2 { font-size: 1.8rem; }
body[data-font-size="large"] h3 { font-size: 1.5rem; }
body[data-font-size="large"] h4 { font-size: 1.3rem; }

body[data-font-size="xlarge"] h1 { font-size: 2.6rem; }
body[data-font-size="xlarge"] h2 { font-size: 2rem; }
body[data-font-size="xlarge"] h3 { font-size: 1.7rem; }
body[data-font-size="xlarge"] h4 { font-size: 1.4rem; }

/* ============================
   Footer
   ============================ */

.site-footer {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    color: #ffffff;
    margin-top: auto;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem 1.25rem;
}

.site-footer h4 {
    margin: 0 0 0.5rem;
    color: #ffffff;
}

.footer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.footer-menu a {
    color: #ffffff;
    text-decoration: none;
}

.footer-menu a:hover,
.footer-menu a:focus-visible {
    text-decoration: underline;
}
