/* ============================================================
   C.I.Tronics website - theme tokens.

   The token architecture is carried over from the Guardian webui:
   every color, shadow, and font this stylesheet reads lives as a
   semantic custom property, so a theme is just a block that
   redefines tokens. Rule bodies carry no hex literals.

   :root holds the default LIGHT theme. site.js sets
   <html data-theme="..."> to one of light | dark | contrast
   (resolving an "auto" choice against prefers-color-scheme), and
   the [data-theme="dark"] / [data-theme="contrast"] blocks below
   override only the tokens that change. These three are the site's
   three visual styles.
   ============================================================ */
:root {
    /* Surfaces */
    --bg-page:      #e8ebf0;  /* body */
    --bg-surface:   #ffffff;  /* cards */
    --bg-header:    #1f2937;  /* blue-slate header / footer band */

    /* Text */
    --text-primary:   #1e2632;
    --text-secondary: #5a6573;
    --text-on-dark:   #ffffff;  /* copy on the dark header / footer band */

    /* Borders */
    --border-default: #dce1e9;
    --border-overlay: rgba(0, 0, 0, 0.2);

    /* Header / footer controls (sit on the always-dark band; constant across themes) */
    --header-ctrl-bg:       rgba(255, 255, 255, 0.12);
    --header-ctrl-bg-hover: rgba(255, 255, 255, 0.22);
    --header-ctrl-border:   rgba(255, 255, 255, 0.30);

    /* Accents */
    --accent:  #2563eb;  /* primary brand blue (links + focus + brand mark) */
    --success: #198754;
    --warning: #ffc107;
    --danger:  #dc3545;

    /* Spacing scale (4px base), radii, shadows */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --radius-sm: 3px;
    --radius:    4px;
    --radius-lg: 8px;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.06);

    /* Fonts */
    --font-body: "Roboto", system-ui, sans-serif;
    --font-mono: "Roboto Mono", ui-monospace, monospace;
}

/* DARK theme - low-glare, blue-tinted slate. */
:root[data-theme="dark"] {
    --bg-page:      #0f1722;
    --bg-surface:   #18212e;
    --bg-header:    #0b121b;

    --text-primary:   #e7ebf1;
    --text-secondary: #9aa6b6;

    --border-default: #2a3747;
    --border-overlay: rgba(255, 255, 255, 0.18);

    --accent:  #4d8dff;  /* lifted for contrast on dark */

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* HIGH-CONTRAST theme - maximum luminance, hard black edges. */
:root[data-theme="contrast"] {
    --bg-page:      #ffffff;
    --bg-surface:   #ffffff;
    --bg-header:    #000000;

    --text-primary:   #000000;
    --text-secondary: #161616;

    --border-default: #000000;
    --border-overlay: rgba(0, 0, 0, 0.65);

    --header-ctrl-bg:       rgba(255, 255, 255, 0.18);
    --header-ctrl-bg-hover: rgba(255, 255, 255, 0.30);
    --header-ctrl-border:   rgba(255, 255, 255, 0.60);

    --accent:  #0b3ea8;
    --success: #0a7d3c;
    --warning: #8a5a00;
    --danger:  #b00018;

    --shadow-card: none;
}
:root[data-theme="contrast"] a { text-decoration: underline; }

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; }
body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-page);
    margin: 0;
    line-height: 1.5;
    /* Sticky footer: header / main / footer stacked, main grows. */
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); }

/* The brand wordmark and the "C.i." mark are SVG silhouettes pulled in via
   CSS mask, so a single asset recolors to any theme token (the band is always
   dark, so the header / footer marks resolve to white). */
.brand-logo {
    display: block;
    background-color: currentColor;
    -webkit-mask: url(../img/logo-citronics.svg) no-repeat center / contain;
    mask: url(../img/logo-citronics.svg) no-repeat center / contain;
    aspect-ratio: 13457 / 2115;  /* native wordmark viewBox ratio */
}

/* ============================================================
   Header / footer - the dark brand band. Markup is injected by
   site.js on every page. The header is a 3-zone grid (brand left,
   optional page-subtitle centered, controls right) mirroring the
   Guardian layout; the band stays dark across all three themes, so
   its copy and marks are always light.
   ============================================================ */
header {
    background-color: var(--bg-header);
    color: var(--text-on-dark);
    padding: var(--space-3) var(--space-5);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-4);
}
.header-brand {
    grid-column: 1;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    color: var(--text-on-dark);
}
.header-brand .brand-logo { height: 26px; }
.page-subtitle {
    grid-column: 2;
    justify-self: center;
    font-size: 1.1em;
    opacity: 0.7;
    white-space: nowrap;
}
.header-right {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Language switch: two equal links, the active one filled. Sits on the dark
   band, so its colors come from the constant --header-ctrl-* tokens. */
.lang-switch {
    display: inline-flex;
    border: 1px solid var(--header-ctrl-border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.85em;
}
.lang-switch a {
    padding: 3px 10px;
    color: var(--text-on-dark);
    text-decoration: none;
    line-height: 1.4;
}
.lang-switch a + a { border-left: 1px solid var(--header-ctrl-border); }
.lang-switch a:hover { background: var(--header-ctrl-bg-hover); }
.lang-switch a.is-active {
    background: var(--header-ctrl-bg);
    font-weight: 700;
    cursor: default;
}

/* Theme toggle: cycles Auto / Light / Dark / High Contrast, persisted in
   localStorage by site.js. */
.theme-toggle {
    background: var(--header-ctrl-bg);
    color: var(--text-on-dark);
    border: 1px solid var(--header-ctrl-border);
    border-radius: var(--radius);
    padding: 3px 10px;
    font-family: var(--font-body);
    font-size: 0.85em;
    line-height: 1.4;
    cursor: pointer;
}
.theme-toggle:hover { background: var(--header-ctrl-bg-hover); }

footer {
    background-color: var(--bg-header);
    color: var(--text-on-dark);
    padding: var(--space-4) var(--space-5);
    margin-top: auto;  /* pin to bottom on short pages */
}
.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.footer-inner .brand-logo { height: 18px; opacity: 0.85; }
.footer-copy {
    font-size: 0.85em;
    opacity: 0.7;
}

/* ============================================================
   Main content
   ============================================================ */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-5);
    flex: 1 0 auto;  /* grow so the footer sits at the bottom */
}

/* Under-construction hero: large brand mark, headline, one line of copy,
   vertically centered in the available space. */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-4);
    padding: clamp(var(--space-8), 12vh, 120px) var(--space-4);
}
.hero-mark {
    width: clamp(120px, 22vw, 200px);
    aspect-ratio: 1 / 1;
    background-color: var(--accent);
    -webkit-mask: url(../img/favicon.svg) no-repeat center / contain;
    mask: url(../img/favicon.svg) no-repeat center / contain;
}
.hero-title {
    margin: 0;
    font-size: clamp(1.8em, 5vw, 2.8em);
    font-weight: 700;
    color: var(--text-primary);
}
.hero-text {
    margin: 0;
    max-width: 38ch;
    font-size: 1.1em;
    color: var(--text-secondary);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 560px) {
    header {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2) var(--space-3);
    }
    .header-brand { flex: 1 0 auto; }
    .page-subtitle { display: none; }
    .header-right { width: 100%; justify-content: flex-end; }
}
