/* ==========================================================================
   Base: design tokens, theme palettes, element defaults and shared controls.
   Components use semantic tokens only; raw palette values live here.

   Visual language follows the existing ministry site: black logo ink on
   white, charcoal title bands, light-grey panels, an orange accent, Roboto
   for headings/navigation and Caudex for long-form reading text.
   ========================================================================== */

/* ---------- Self-hosted fonts (latin subset; SIL Open Font License) ---------- */

@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 300 700; /* variable font */
    font-display: swap;
    src: url("../assets/fonts/roboto-variable.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Roboto";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../assets/fonts/roboto-italic-400.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Caudex";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../assets/fonts/caudex-400.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Caudex";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../assets/fonts/caudex-700.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Raw palette */
    --palette-black: #1a1a1a;
    --palette-grey-700: #555555;
    --palette-grey-500: #8a8a8a;
    --palette-grey-200: #e2e2e2;
    --palette-grey-100: #f7f7f7;
    --palette-white: #ffffff;
    --palette-charcoal: #404040;
    --palette-orange: #ff7707;          /* brand accent: bars, tiles, button fills */
    --palette-orange-hover: #ff8a2a;
    --palette-orange-text: #b34c00;     /* text-safe orange on light surfaces */
    --palette-orange-text-dark: #ff9a4d;/* text-safe orange on dark surfaces */
    --palette-night: #161616;
    --palette-night-raised: #1f1f1f;
    --palette-night-panel: #242424;
    --palette-night-line: #383838;
    --palette-night-band: #2b2b2b;
    --palette-fog: #ececec;
    --palette-fog-muted: #b5b5b5;

    /* Semantic colour tokens — light theme */
    --color-bg: var(--palette-white);
    --color-surface: var(--palette-white);
    --color-surface-alt: var(--palette-grey-100);
    --color-text: var(--palette-black);
    --color-text-muted: var(--palette-grey-700);
    --color-heading: var(--palette-black);
    --color-border: var(--palette-grey-200);
    --color-border-strong: var(--palette-grey-500);
    --color-accent: var(--palette-orange);
    --color-accent-hover: var(--palette-orange-hover);
    --color-on-accent: var(--palette-black);
    --color-accent-text: var(--palette-orange-text);
    --color-link: var(--palette-orange-text);
    --color-link-hover: #8f3d00;
    --color-focus: #1f5fbf;
    --color-error: #a3261b;
    --color-success: #2e6b3a;
    --color-header-bg: var(--palette-white);
    --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 20px rgb(0 0 0 / 0.06);
    --logo-filter: none;

    /* Fixed-colour charcoal title bands (same role in both themes) */
    --color-band-bg: var(--palette-charcoal);
    --color-band-text: var(--palette-white);
    --color-band-muted: #cfcfcf;

    /* Fixed-colour surface for text placed on photography (both themes) */
    --color-photo-text: #ffffff;
    --color-photo-muted: #eeeeee;
    --color-photo-focus: #ffd08a;
    --color-photo-fallback: #2a2f2a;          /* behind the hero until the photo loads */
    --color-photo-hover: rgb(255 255 255 / 0.12);
    --overlay-hero:
        linear-gradient(180deg, rgb(0 0 0 / 0.25) 0%, rgb(0 0 0 / 0.1) 30%, rgb(0 0 0 / 0.45) 100%),
        rgb(25 30 25 / 0.5);
    --overlay-caption: linear-gradient(180deg, rgb(0 0 0 / 0) 0%, rgb(0 0 0 / 0.72) 55%);
    --shadow-on-photo-lg: 0 2px 18px rgb(0 0 0 / 0.35);
    --shadow-on-photo-sm: 0 1px 10px rgb(0 0 0 / 0.45);

    /* Typography */
    --font-body: "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-display: "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Caudex", "Palatino Linotype", Palatino, Georgia, serif;
    --text-sm: 0.9375rem;
    --text-base: 1.0625rem;
    --text-lg: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
    --text-h3: clamp(1.35rem, 1.2rem + 0.6vw, 1.75rem);
    --text-h2: clamp(1.75rem, 1.4rem + 1.6vw, 3rem);
    --text-h1: clamp(2.25rem, 1.5rem + 3.4vw, 4.375rem);
    --leading-body: 1.7;
    --leading-tight: 1.15;
    --tracking-caps: 0.1em;

    /* Spacing */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-section: clamp(3rem, 2.25rem + 3.5vw, 5.5rem);
    --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);

    /* Widths */
    --width-container: 70rem;
    --width-reading: 42rem;

    /* Shape & motion */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --border-width: 1px;
    --duration: 180ms;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    /* Header height drives anchor clearance */
    --header-height: 4.75rem;

    color-scheme: light;
}

/* Dark palette: applied by the init script via data-theme, and by the system
   preference when JavaScript is unavailable. Keep both blocks identical. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: var(--palette-night);
        --color-surface: var(--palette-night-raised);
        --color-surface-alt: var(--palette-night-panel);
        --color-text: var(--palette-fog);
        --color-text-muted: var(--palette-fog-muted);
        --color-heading: #ffffff;
        --color-border: var(--palette-night-line);
        --color-border-strong: var(--palette-grey-500);
        --color-accent-text: var(--palette-orange-text-dark);
        --color-link: var(--palette-orange-text-dark);
        --color-link-hover: #ffb57d;
        --color-focus: #8fb8ff;
        --color-error: #ff9b8f;
        --color-success: #9fd3a8;
        --color-header-bg: var(--palette-night-raised);
        --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
        --logo-filter: invert(1) brightness(0.95);
        --color-band-bg: var(--palette-night-band);

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --color-bg: var(--palette-night);
    --color-surface: var(--palette-night-raised);
    --color-surface-alt: var(--palette-night-panel);
    --color-text: var(--palette-fog);
    --color-text-muted: var(--palette-fog-muted);
    --color-heading: #ffffff;
    --color-border: var(--palette-night-line);
    --color-border-strong: var(--palette-grey-500);
    --color-accent-text: var(--palette-orange-text-dark);
    --color-link: var(--palette-orange-text-dark);
    --color-link-hover: #ffb57d;
    --color-focus: #8fb8ff;
    --color-error: #ff9b8f;
    --color-success: #9fd3a8;
    --color-header-bg: var(--palette-night-raised);
    --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
    --logo-filter: invert(1) brightness(0.95);
    --color-band-bg: var(--palette-night-band);

    color-scheme: dark;
}

/* ---------- Reset & element defaults ---------- */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-body);
    overflow-wrap: break-word;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    color: var(--color-heading);
    font-family: var(--font-display);
    font-weight: 400;
    line-height: var(--leading-tight);
    text-wrap: balance;
}

h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); font-weight: 500; }

p,
ul,
ol,
blockquote,
figure {
    margin: 0;
}

p + p {
    margin-top: var(--space-md);
}

strong {
    font-weight: 700;
}

/* Links in running text are underlined so they never rely on colour alone. */
a {
    color: var(--color-link);
    text-decoration-line: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--color-link-hover);
    text-decoration-thickness: 0.14em;
}

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

/* Anchor and focus clearance below the sticky header. */
[id],
:focus {
    scroll-margin-top: calc(var(--header-height) + var(--space-md));
}

/* ---------- Utilities ---------- */

.visually-hidden {
    position: absolute !important; /* Accessibility exception: must never be overridden. */
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.container {
    width: 100%;
    max-width: calc(var(--width-container) + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.skip-link {
    position: absolute;
    top: var(--space-xs);
    left: var(--space-xs);
    z-index: 100;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 500;
    border: 2px solid var(--color-focus);
    border-radius: var(--radius-sm);
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* Small uppercase, letter-spaced label in the accent colour. */
.eyebrow {
    margin-bottom: var(--space-xs);
    color: var(--color-accent-text);
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

/* ---------- Buttons ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-height: 3rem;
    padding: 0.625rem 1.75rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: var(--tracking-caps);
    line-height: 1.2;
    text-decoration: none;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.button--primary {
    background: var(--color-accent);
    color: var(--color-on-accent);
}

.button--primary:hover {
    background: var(--color-accent-hover);
    color: var(--color-on-accent);
}

/* Dark solid button, like the existing site's Send button; inverts in dark theme. */
.button--dark {
    background: var(--color-heading);
    color: var(--color-bg);
}

.button--dark:hover {
    background: var(--color-text-muted);
    color: var(--color-bg);
}

.button--outline {
    border-color: currentColor;
    background: transparent;
    color: var(--color-text);
}

.button--outline:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.button[disabled],
.button[aria-disabled="true"] {
    opacity: 0.6;
    cursor: progress;
}

/* ---------- Form controls ---------- */

.field {
    display: grid;
    gap: var(--space-2xs);
    min-width: 0;
}

.field__label {
    font-size: var(--text-sm);
    font-weight: 500;
}

.field__optional {
    color: var(--color-text-muted);
    font-weight: 400;
}

.field__input {
    width: 100%;
    min-height: 2.875rem;
    padding: 0.625rem 0.875rem;
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    line-height: 1.4;
}

.field__input:focus-visible {
    outline-offset: 1px;
    border-color: var(--color-focus);
}

textarea.field__input {
    min-height: 9rem;
    resize: vertical;
}

.field__input[aria-invalid="true"] {
    border-color: var(--color-error);
    border-width: 2px;
}

.field__error {
    color: var(--color-error);
    font-size: var(--text-sm);
    font-weight: 500;
}

.field__error:empty {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important; /* Accessibility exception */
        animation-duration: 0.01ms !important; /* Accessibility exception */
        animation-iteration-count: 1 !important; /* Accessibility exception */
    }
}
