/*
 * Shared styles for the public website and the portal: design tokens, base elements,
 * buttons, the logo, language and theme controls, and form fields.
 * site.css and portal.css build their own layouts on top of this file.
 */

/* ---------------------------------------------------------------------
 * Design tokens
 * ------------------------------------------------------------------ */
:root,
[data-theme="dark"] {
    --bg: #0F172A;
    --bg-alt: #0B1220;
    --surface: #111A2E;
    --border: #1E293B;
    --border-strong: #334155;
    --heading: #FFFFFF;
    --text: #F8FAFC;
    --body: #CBD5E1;
    --muted: #94A3B8;
    --nav: #CBD5E1;
    --input-bg: #0B1220;
    --input-border: #64748B;
    --chip-bg: #111A2E;
    --chip-text: #E2E8F0;
    --accent: #22C55E;
    --on-accent: #0B1220;
    --seg-on-bg: #F8FAFC;
    --seg-on-text: #0F172A;
    --error: #FCA5A5;
    --success-bg: rgba(34, 197, 94, .12);
    --error-bg: rgba(248, 113, 113, .12);
    --shadow: 0 24px 60px rgba(2, 6, 23, .5);

    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #FFFFFF;
    --bg-alt: #F6F7F9;
    --surface: #FFFFFF;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --heading: #0F172A;
    --text: #0F172A;
    --body: #334155;
    --muted: #475569;
    --nav: #334155;
    --input-bg: #FFFFFF;
    --chip-bg: #FFFFFF;
    --chip-text: #0F172A;
    --accent: #15803D;
    --on-accent: #FFFFFF;
    --seg-on-bg: #0F172A;
    --seg-on-text: #FFFFFF;
    --error: #B91C1C;
    --success-bg: #F0FDF4;
    --error-bg: #FEF2F2;
    --shadow: 0 24px 60px rgba(15, 23, 42, .16);

    color-scheme: light;
}

:root {
    /* Code window and whoami card stay dark in both themes */
    --code-bg: #0B1220;
    --code-bar: #0E1628;
    --code-term: #070C17;
    --code-border: #1E293B;
    --code-dot: #334155;
    --code-text: #E2E8F0;
    --code-muted: #94A3B8;
    --code-accent: #22C55E;
    --syn-keyword: #F0ABFC;
    --syn-type: #7DD3FC;
    --syn-fn: #93C5FD;
    --syn-var: #FDE68A;
    --syn-const: #FDBA74;

    --focus: #3B82F6;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --gutter: clamp(16px, 4vw, 40px);
    --section-space: clamp(64px, 9vw, 112px);
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
}

a {
    color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

h1,
h2,
h3,
p {
    margin: 0;
}

svg.icon {
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    transform: translateY(-200%);
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding-inline: var(--gutter);
}

/* ---------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .15s ease, border-color .15s ease;
}

.btn:hover {
    opacity: .85;
}

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

.btn--ghost {
    border-color: var(--border-strong);
    /* Also on <button>, which has a grey background of its own */
    background: transparent;
    color: var(--text);
    font-weight: 500;
}

/* ---------------------------------------------------------------------
 * Logo, language switch, theme and menu buttons
 * ------------------------------------------------------------------ */
.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 19px;
    font-weight: 700;
    text-decoration: none;
}

/* Logo: inline SVG (templates/components/logo.html.twig), coloured by the theme */
.brand-logo {
    display: block;
    flex: none;
    width: auto;
    height: 26px;
}

.brand-logo__text {
    fill: var(--heading);
}

.brand-logo__accent {
    fill: var(--accent);
}

.brand-logo__line,
.brand-logo__accent-line {
    fill: none;
    stroke: var(--muted);
    stroke-width: 6;
    stroke-linecap: round;
}

.brand-logo__accent-line {
    stroke: var(--accent);
}

.lang-switch {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
}

.lang-switch a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 7px;
    color: var(--muted);
    text-decoration: none;
    transition: background-color .2s ease, color .2s ease;
}

.lang-switch a:hover {
    color: var(--text);
}

.lang-switch a[aria-current="true"] {
    background: var(--seg-on-bg);
    color: var(--seg-on-text);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s ease;
}

.theme-toggle:hover {
    border-color: var(--input-border);
}

[data-theme="light"] .theme-toggle__sun,
[data-theme="dark"] .theme-toggle__moon {
    display: none;
}

/* Menu button: hidden until a menu controller runs, and then only on small screens
   (see site.css and portal.css). Without JavaScript the navigation simply stays visible. */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.menu-toggle:hover {
    border-color: var(--input-border);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__open,
.menu-toggle[aria-expanded="false"] .menu-toggle__close {
    display: none;
}

/* ---------------------------------------------------------------------
 * Forms and notices
 * ------------------------------------------------------------------ */
.form-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: clamp(24px, 4vw, 36px);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Side-by-side fields wrap below 200px. Only in a row: in the column-direction form,
   a flex-basis would become a minimum height and leave a gap under short fields. */
.field-row > .field {
    flex: 1 1 200px;
}

.field label {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--body);
}

.field__optional {
    color: var(--muted);
}

.input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

textarea.input {
    padding-block: 12px;
    resize: vertical;
}

.input[aria-invalid="true"] {
    border-color: var(--error);
}

.field-error {
    font-size: 14px;
    color: var(--error);
}

.form-card .btn {
    width: 100%;
}

.form-note {
    font-size: 14px;
    color: var(--muted);
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 15px;
}

.notice--success {
    background: var(--success-bg);
    color: var(--text);
}

.notice--success .icon {
    color: var(--accent);
}

.notice--error {
    background: var(--error-bg);
    color: var(--error);
}

/* ---------------------------------------------------------------------
 * Motion
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition: none !important;
    }
}
