/* Shared styles for the popup, the options page, the Word task pane and the VS Code panel. They
   follow the same art direction as the Certimens web space, whose brand guidelines are the
   reference (docs/developpement.md points at them): Plus Jakarta Sans with heavy headings over a
   medium body, slate as the dominant color, brass gold as the single accent, flat surfaces on a
   hairline.

   Two schemes, and every color goes through a token so that a rule is written once. The dark
   one is not an invention: it is the same ramp read from the other end — slate becomes the
   page, and what was the dominant color becomes the light end that writes on it. Only one
   value genuinely differs, the accent *as text* (--accent-text): dark brass on a light page,
   light brass on a dark one. The accent *as a surface* never changes — gold carrying ink, in
   both schemes. */

@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 400; font-display: swap; src: url('fonts/plus-jakarta-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 600; font-display: swap; src: url('fonts/plus-jakarta-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 700; font-display: swap; src: url('fonts/plus-jakarta-sans-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 800; font-display: swap; src: url('fonts/plus-jakarta-sans-latin-800-normal.woff2') format('woff2'); }

:root {
    /* Tells the browser which scheme its own surfaces belong to: scrollbars, native controls,
       the form widgets we do not paint ourselves. */
    color-scheme: light;

    /* Slate: the dominant color, and what every outlined control is made of. */
    --primary: #1e293b;
    --primary-soft: rgb(30 41 59 / 8%);
    --primary-line: rgb(30 41 59 / 50%);
    /* Brass gold: the single accent — the word mark, highlights, and the one filled button a
       view is allowed. It is never text on a light page (2.46:1); where it has to read as text
       — the links — the dark brass is used (5.7:1). As a surface it carries ink (6.6:1), and
       that pair is the same in both schemes. */
    --accent: #c5a059;
    --accent-hover: #d4ac5f;
    --accent-text: #705e3a;
    --accent-ink: #1a202c;
    --bg: #f8fafc;
    --paper: #fff;
    --text: #1a202c;
    --text-secondary: #54595f;
    --divider: #e5e5e5;
    --border: rgb(0 0 0 / 23%);
    --disabled-text: rgb(0 0 0 / 26%);
    --disabled-bg: rgb(0 0 0 / 12%);
    /* Verdict colors carry meaning rather than brand: they stay outside the guidelines — which
       is what lets them move without the charter moving with them.

       **They were green / orange / red and are no longer, on purpose.** Simulated for the
       commonest color vision deficiencies, that triplet collapsed: the old #137333 and #c5221f
       came out as the same olive under deuteranopia, and the orange confused itself with the
       red. Recoloring inside the family cannot fix it — a dichromat has no red-green axis left,
       only lightness, and lightness is already spent on the 4.5:1 these colors owe their
       background. Hence **blue** for what went well, and a gap bought with lightness between
       the warning and the failure. The Certimens space carries the same three. The cost is
       deliberate: "green = good" is immediate, "blue = good" is learnt once — and the word
       beside the color is what carries the meaning anyway. Both the contrast and the distance
       under each deficiency are measured in tests/theme.test.mjs. */
    --success: #1d4ed8; /* 6.70:1 on paper */
    --success-wash: #e8edfb;
    --success-text: #102b77; /* 10.98:1 on its wash */
    --warning: #b45309; /* 5.02:1 */
    --error: #881337; /* 9.57:1 */
    --error-wash: #f3e7eb;
    --error-text: #4b0a1e; /* 12.81:1 on its wash */
    /* Info states a fact rather than a verdict, so it is not a fourth color: it is the slate,
       which is what --primary already means in either scheme. A cyan here would be the thing a
       blue "it went well" gets confused with, and it belongs to no part of the brand. Written
       as references rather than values, so the dark scheme has nothing to redefine. */
    --info-wash: var(--primary-soft);
    --info-text: var(--primary);
    --radius: 12px;
}

/* The dark scheme, as one block of token values. It is applied by three triggers below, and
   the values are written once here so the three can never drift apart. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        color-scheme: dark;
        --primary: #cbd5e1;
        --primary-soft: rgb(203 213 225 / 12%);
        --primary-line: rgb(203 213 225 / 50%);
        --accent-text: #d4ac5f;
        --bg: #0f172a;
        --paper: #1e293b;
        --text: #f1f5f9;
        --text-secondary: #94a3b8;
        --divider: #334155;
        --border: rgb(255 255 255 / 23%);
        --disabled-text: rgb(255 255 255 / 30%);
        --disabled-bg: rgb(255 255 255 / 12%);
        /* The same three meanings, lightened until they pass on a dark page rather than
           recolored a second time. The wash is 8% and no more: the alert's text is the
           verdict itself here, so whatever the wash lifts the surface by comes straight off
           the reading of it — the failure clears AA at 8% and missed it at 12%. */
        --success: #60a5fa;  /* 5.75:1 on paper */
        --success-wash: rgb(96 165 250 / 8%);
        --success-text: #60a5fa;
        --warning: #fbbf24;  /* 8.76:1 */
        --error: #fb6087;  /* 4.96:1 */
        --error-wash: rgb(251 96 135 / 8%);
        --error-text: #fb6087;
    }
}

/* Same values, chosen rather than inherited. `data-theme` is what a host sets when it knows
   better than the operating system: the VS Code panel follows the editor's theme, not the
   desktop's, and ui.js sets it from the student's own choice where there is one. */
:root[data-theme='dark'] {
    color-scheme: dark;
    --primary: #cbd5e1;
    --primary-soft: rgb(203 213 225 / 12%);
    --primary-line: rgb(203 213 225 / 50%);
    --accent-text: #d4ac5f;
    --bg: #0f172a;
    --paper: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --divider: #334155;
    --border: rgb(255 255 255 / 23%);
    --disabled-text: rgb(255 255 255 / 30%);
    --disabled-bg: rgb(255 255 255 / 12%);
    --success: #60a5fa;
    --success-wash: rgb(96 165 250 / 8%);
    --success-text: #60a5fa;
    --warning: #fbbf24;
    --error: #fb6087;
    --error-wash: rgb(251 96 135 / 8%);
    --error-text: #fb6087;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    /* The weight contrast is the most recognizable trait: body 500, headings 800. */
    font-weight: 500;
    line-height: 1.5;
}

[hidden] { display: none !important; }

h1 { margin: 0; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
p { margin: 0; }

/* Brand block: the gold shield, then the word mark with its second half in gold. */
.brand { display: flex; align-items: center; gap: 8px; }
.brand .mark { width: 28px; height: 28px; }
.brand .mens { color: var(--accent); }
.brand .version { align-self: flex-end; padding-bottom: 3px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Flat surfaces separated by a hairline, as the site's sections are — not floating cards. */
.card {
    background: var(--paper);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 24px;
}

/* MUI's outlined field: label above, border turning to the primary color on focus. */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field input, .field select {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}
.field input:hover, .field select:hover { border-color: var(--text); }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* "Advanced settings": the engine address is the only field of the login form a student never
   has to touch — the default engine is the right one for everyone but an institution hosting its
   own. <details> is the native disclosure widget, so the field stays reachable by keyboard and
   announced by screen readers while costing the form a single line. The marker is drawn here
   rather than left to the browser: the three agents that share this stylesheet (popup, Word task
   pane, VS Code panel) would otherwise each show their host's own triangle. */
.advanced { border-top: 1px solid var(--divider); padding-top: 12px; }
.advanced > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
}
/* stylelint-disable-next-line selector-no-vendor-prefix -- Safari and older WebKit ignore
   list-style on a summary; without this the default triangle is drawn next to ours. */
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentcolor;
    border-bottom: 1.5px solid currentcolor;
    transform: rotate(-45deg);
}
.advanced[open] > summary::before { transform: rotate(45deg); }
.advanced > summary:hover { color: var(--text); }
.advanced > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.advanced > .field { margin-top: 12px; }

/* A filled button is the call to action, and the brand's call to action is a gold surface with
   ink text — the rule the whole product shares (see the charter in the `website` repo). One per
   view, the action the view exists for: the popup shows the login submit or the document action,
   never both. Everything else is .btn.outlined, in slate, because gold outside a surface is
   2.46:1 on white. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 22px;
    min-height: 40px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-ink);
    background: var(--accent);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { color: var(--disabled-text); background: var(--disabled-bg); cursor: default; }
.btn.block { width: 100%; }
label.btn.disabled { opacity: 0.5; pointer-events: none; }
.btn.outlined { color: var(--primary); background: transparent; box-shadow: inset 0 0 0 1px var(--primary-line); }
.btn.outlined:hover { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }

/* Icon-only actions, in the header: they buy back the width a popup does not have. An icon alone
   names nothing, so each one carries an aria-label (what it does) and a title (what happens if
   you press it) — and the state they toggle is never theirs alone to tell: the suspended
   measurement keeps its banner in plain words. 32px is the smallest comfortable target here. */
.icon-actions { display: flex; gap: 2px; margin-left: auto; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--primary-soft); }
/* Keyboard focus stays visible: these are the only controls of the header. */
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Pressed = measurement suspended. The colour seconds the banner, it never replaces it. */
.icon-btn[aria-pressed='true'] { color: var(--error); background: var(--error-wash); }
.icon-btn svg { width: 18px; height: 18px; display: block; }
/* `hidden` is an HTML attribute: the user-agent rule that acts on it does not reach into SVG,
   so the swap between the pause and the play icon is spelled out here. */
.icon-btn svg[hidden] { display: none; }

/* Links read as brass rather than slate, and underline on hover only — the engine's MuiLink. */
.link {
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--accent-text);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}
a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.link:hover, a:hover { text-decoration: underline; }

/* MUI's standard alert. */
.alert { padding: 8px 16px; border-radius: var(--radius); font-weight: 500; }
.alert:empty { display: none; }
.alert.ok { color: var(--success-text); background: var(--success-wash); }
.alert.error { color: var(--error-text); background: var(--error-wash); }
.alert.info { color: var(--info-text); background: var(--info-wash); }

.status { display: flex; flex-direction: column; gap: 4px; }
.status div:first-child { font-weight: 700; }

/* The pairing code: read off this screen and typed into another, by hand. Big, spaced and
   monospaced for the same reason the engine spaces it into two groups — eight characters in a
   row are copied wrong by everybody. `user-select: all` makes one click select the whole code
   rather than a word of it. */
.code {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-align: center;
    user-select: all;
}
