/* ===== Font Faces (per Ogma Brand v2.0) ===== */

/* Iosevka SS17 — headings, UI, buttons, brand name */
@font-face {
    font-family: 'Iosevka SS17';
    font-weight: 500;
    font-display: swap;
    src: url('fonts/IosevkaSS17-Medium.woff2') format('woff2');
}
@font-face {
    font-family: 'Iosevka SS17';
    font-weight: 400;
    font-display: swap;
    src: url('fonts/IosevkaSS17-Regular.woff2') format('woff2');
}
@font-face {
    font-family: 'Iosevka SS17';
    font-weight: 100;
    font-display: swap;
    src: url('fonts/IosevkaSS17-Thin.woff2') format('woff2');
}

/* Iosevka Etoile — body text, taglines, editorial */
@font-face {
    font-family: 'Iosevka Etoile';
    font-weight: 500;
    font-display: swap;
    src: url('fonts/IosevkaEtoile-Medium.woff2') format('woff2');
}
@font-face {
    font-family: 'Iosevka Etoile';
    font-weight: 300;
    font-display: swap;
    src: url('fonts/IosevkaEtoile-Light.woff2') format('woff2');
}
@font-face {
    font-family: 'Iosevka Etoile';
    font-weight: 200;
    font-display: swap;
    src: url('fonts/IosevkaEtoile-ExtraLight.woff2') format('woff2');
}

/* ===== OgIntel Theme System ===== */

/* --- Light Theme (default) — Ogma Brand v2.0 (T036) ---
   Values mirror docs/ogma-brand/ogma-tokens.css. The blue ramp is derived in
   OKLab from the EU Azure anchor #003399 by docs/ogma-brand/tools/derive-ramp.py;
   run that script to re-derive, and change both stylesheets together. Token
   *names* here still differ from the kit's (--bg-primary vs --bg); converging
   the vocabulary is deliberately out of scope for T036. */
:root, [data-theme="light"] {
    /* Blue ramp — contrast on white / on #1A1A1A noted per step */
    --blue-900: #001243;   /* 17.99 /  1.03 */
    --blue-800: #001D60;   /* 15.62 /  1.11 */
    --blue-700: #00277A;   /* 13.37 /  1.30 */
    --blue-600: #002F90;   /* 11.61 /  1.50 */
    --blue-500: #003399;   /* 10.86 /  1.60 — EU Azure, the brand anchor */
    --blue-400: #2D5DBC;   /*  6.17 /  2.82 — decorative; fails AA on dark */
    --blue-300: #6891DE;   /*  3.14 /  5.55 — the dark-theme accent */
    --blue-200: #A0BBEC;   /*  1.94 /  8.96 */
    --blue-100: #DFEAFE;   /*  1.21 / 14.37 */

    /* Brand mark — decorative only. Yellow is 1.51:1 on white and green
       3.56:1, so neither may ever carry text. */
    --mark-yellow: #FFCC00;
    --mark-blue: #003399;
    --mark-green: #169B62;
    --mark-ink: #1A1A1A;

    /* Surfaces */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F4F0;
    --bg-tertiary: #EEEDEA;
    --bg-card: #FFFFFF;
    --bg-muted: #EEEDEA;

    /* Text */
    --text-primary: #1A1A1A;
    --text-secondary: #73726C;
    --text-muted: #9C9A92;

    /* Accent (blue-500 primary) */
    --accent: #003399;
    --accent-hover: #00277A;
    --accent-light: #DFEAFE;
    --accent-subtle: #A0BBEC;
    --on-accent: #FFFFFF;

    /* Borders */
    --border: #D8D7D3;
    --border-light: #E5E4E0;
    --color-border: #D8D7D3;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);

    /* Header / Footer */
    --header-bg: rgba(255,255,255,0.92);
    --footer-bg: #001243;
    --footer-text: #A0BBEC;
    --footer-heading: #FFFFFF;

    /* Semantic status — kept separate from the three brand colours by design.
       Every value clears 4.5:1 against its own ground; the v1.0 set did not
       (success 3.39, warning 3.72, error 3.93 on white). */
    --success: #008762;
    --error: #D24443;
    --warning: #A76708;
    --info: #0E7C86;

    --success-bg: #E4F5ED;
    --success-fg: #027B58;
    --warning-bg: #FBEEE1;
    --warning-fg: #9C5E00;
    --error-bg: #FFEBE9;
    --error-fg: #C23737;
    --info-bg: #E5F3F5;
    --info-fg: #057983;

    --focus-ring: 0 0 0 3px rgba(0,51,153,0.3);

    /* Radii & transitions */
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.25s cubic-bezier(0.4,0,0.2,1);

    color-scheme: light;
}

/* --- Dark Theme — Ogma Brand v2.0 (T036) --- */
[data-theme="dark"] {
    /* Surfaces */
    --bg-primary: #1A1A1A;
    --bg-secondary: #222222;
    --bg-tertiary: #2A2A2A;
    --bg-card: #222222;
    --bg-muted: #2A2A2A;

    /* Text */
    --text-primary: #F0EFE8;
    --text-secondary: #9C9A92;
    --text-muted: #73726C;

    /* Accent — blue-300, not blue-400. v1.0 documented blue-400 as the dark
       primary but never implemented it; measured, it is 2.82:1 on #1A1A1A
       and fails AA. blue-300 is 5.55:1 on #1A1A1A and 5.07:1 on #222222. */
    --accent: #6891DE;
    --accent-hover: #A0BBEC;
    --accent-light: #0E2758;
    --accent-subtle: #1B3873;
    --on-accent: #1A1A1A;

    /* Borders */
    --border: #333333;
    --border-light: #2A2A2A;
    --color-border: #333333;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);

    /* Header / Footer */
    --header-bg: rgba(26,26,26,0.95);
    --footer-bg: #111111;
    --footer-text: #9C9A92;
    --footer-heading: #F0EFE8;

    /* Semantic status — v1.0 left these unmapped, so status colours rendered
       identically in both themes. The v1.0 light values live on here, where
       they measure correctly against #1A1A1A. */
    --success: #1D9E75;
    --error: #D85A56;
    --warning: #BA7517;
    --info: #428E96;

    --success-bg: #183026;
    --success-fg: #2DA77E;
    --warning-bg: #362615;
    --warning-fg: #C68129;
    --error-bg: #411F1C;
    --error-fg: #E86662;
    --info-bg: #1A2E30;
    --info-fg: #519DA5;

    --focus-ring: 0 0 0 3px rgba(104,145,222,0.35);

    color-scheme: dark;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Iosevka Etoile', Georgia, serif;
    font-weight: 300;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    margin: 0;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 {
    font-family: 'Iosevka SS17', sans-serif;
    color: var(--text-primary);
    line-height: 1.3;
    margin-top: 0;
}

h1 { font-size: 2.5rem; font-weight: 500; }
h2 { font-size: 2rem; font-weight: 500; }
h3 { font-size: 1.5rem; font-weight: 500; }
h4 { font-size: 1.125rem; font-weight: 500; }

p { color: var(--text-secondary); margin-top: 0; }

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

/* ===== Layout ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

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

.site-main {
    flex: 1;
}

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.site-logo {
    display: flex;
    align-items: center;
    /* The brand's clear-space rule is one chamber radius on all sides. The mark
       renders 46px wide and a chamber radius is 56/368 of that, so ~7px is the
       floor; 12px gives the near-square mark room the old 2.87:1 strip did not
       need at 6px. */
    gap: 12px;
    text-decoration: none;
}
.site-logo img { display: block; }

/* Split-logo layout: mark left, (wordmark / tagline stacked) right.
   T036 replaced the 2.87:1 orbital strip with a near-square mark
   (viewBox 368.34×334, cropped to the drawn extent by sync-to-site.py),
   so the mark can no longer be sized by the same height as the wordmark
   without dwarfing it. It is now set against the *text column* instead:
   wordmark 28 + gap 2 + tagline 12 = 42px, and the mark matches at 42px,
   rendering 46×42. Wordmark and tagline heights are unchanged from v1.0,
   so the header's typographic rhythm is preserved across the redesign. */
.logo-image    { height: 42px; width: auto; }
.logo-text     { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.logo-wordmark { height: 28px; width: auto; }
.logo-tagline  { height: 12px; width: auto; }

/* Theme-aware logo: show light logo by default, dark logo in dark theme */
[data-theme="light"] .logo-dark,
:root:not([data-theme="dark"]) .logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-nav a {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-family: 'Iosevka SS17', sans-serif;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.site-nav a:hover {
    color: var(--accent);
    background: var(--accent-light);
}
.site-nav a.active {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
}

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

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: all var(--transition);
}
.theme-toggle:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.theme-toggle:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    position: relative;
}

.hamburger, .hamburger::before, .hamburger::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.3s;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.hamburger { top: 50%; margin-top: -1px; }
.hamburger::before { content: ''; top: -6px; left: 0; transform: none; }
.hamburger::after { content: ''; top: 6px; left: 0; transform: none; }
.hamburger.open { background: transparent; }
.hamburger.open::before { top: 0; transform: rotate(45deg); }
.hamburger.open::after { top: 0; transform: rotate(-45deg); }

/* ===== Footer ===== */
.site-footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding-top: 3rem;
    margin-top: 4rem;
}

.footer-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    padding-bottom: 2rem;
}

.footer-col h4 {
    font-family: 'Iosevka SS17', sans-serif;
    color: var(--footer-heading);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.footer-col p {
    color: var(--footer-text);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.footer-col nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.footer-col nav a {
    color: var(--footer-text);
    font-size: 0.875rem;
    transition: color var(--transition);
}
.footer-col nav a:hover { color: #ffffff; }

.footer-col a {
    color: var(--footer-text);
}
.footer-col a:hover { color: #ffffff; }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 1.25rem 0;
    text-align: center;
}
.footer-bottom p {
    color: var(--footer-text);
    font-size: 0.8rem;
    margin: 0;
}

/* ===== Page Sections ===== */
.page-hero {
    padding: 5rem 0 4rem;
    text-align: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.page-hero h1 {
    margin-bottom: 1rem;
    font-size: 2.75rem;
    letter-spacing: -0.03em;
    outline: none;
}

.page-hero .lead {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto;
}

.section {
    padding: 4rem 0;
}

.section-alt {
    background: var(--bg-secondary);
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title h2 {
    margin-bottom: 0.75rem;
}

.section-title p {
    max-width: 600px;
    margin: 0 auto;
}

/* ===== Cards ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    transition: all var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.card .card-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius);
    font-family: 'Iosevka SS17', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}
.btn:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

/* Text on the accent must follow the accent. In dark theme --accent is
   --blue-300 #6891DE, where white measures 3.14:1 and fails AA; --on-accent
   flips to #1A1A1A there, which measures 5.55:1. Hardcoding #ffffff here was
   invisible while both themes shared one accent. */
.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--on-accent);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}
.btn-outline:hover {
    background: var(--accent);
    color: var(--on-accent);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-family: 'Iosevka SS17', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Iosevka Etoile', Georgia, serif;
    font-weight: 300;
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
    outline: none;
}

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

.validation-message {
    color: var(--error);
    font-size: 0.825rem;
    margin-top: 0.25rem;
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--success);
}

.invalid {
    border-color: var(--error);
}

/* Honeypot */
.hp-field { position: absolute; left: -9999px; opacity: 0; height: 0; }

/* ===== CAPTCHA Widget ===== */
.captcha-widget {
    margin: 0.75rem 0;
}
.captcha-image-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.captcha-image-row img {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    user-select: none;
    -webkit-user-drag: none;
}
.captcha-refresh {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    line-height: 1;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
}
.captcha-refresh:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}
.captcha-input-row {
    max-width: 280px;
}
.captcha-input-row label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: block;
}

/* ===== Alert ===== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}
/* Grounds and text come from the semantic token pairs, which are themed and
   contrast-checked. The v1.0 rules mixed rgba() literals (#22863A, #D32F2F,
   #C89600) with token text colours, so the ground and the text were drawn
   from different palettes and only the text ever followed the theme. */
.alert-success {
    background: var(--success-bg);
    color: var(--success-fg);
    border: 1px solid var(--success);
}
.alert-error {
    background: var(--error-bg);
    color: var(--error-fg);
    border: 1px solid var(--error);
}
.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-fg);
    border: 1px solid var(--warning);
}
.alert-info {
    background: var(--info-bg);
    color: var(--info-fg);
    border: 1px solid var(--info);
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }

/* ===== Blazor Error ===== */
.blazor-error-boundary {
    background: var(--error-bg);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--error-fg);
    border-radius: var(--radius);
}
.blazor-error-boundary::after {
    content: "An error has occurred.";
}

#blazor-error-ui {
    background: var(--error-bg);
    color: var(--error-fg);
    padding: 0.75rem 1.5rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
    text-align: center;
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }

    .site-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow-lg);
    }
    .site-nav.open { display: flex; }

    .page-hero { padding: 3rem 0 2.5rem; }
    .page-hero h1 { font-size: 2rem; }

    .footer-inner {
        grid-template-columns: 1fr 1fr;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .footer-inner {
        grid-template-columns: 1fr;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
}
