/*
 * Company theme "moritz behnk": own design on top of the generated /theme/tokens.css (colours and font
 * stacks from theme.json). Served as /theme/theme.css and linked after the app CSS. Restores the brand
 * look of the pre-theming app that the neutral app CSS no longer carries: self-hosted fonts, the zig-zag
 * ornament, the signature radii, navy-tinted shadows and a few brand-coloured components.
 *
 * Assets (theme.json): word mark logo-light.svg (navy + mint, for light surfaces) and logo-dark.svg
 * (mint + lime, for navy/dark surfaces); mark-light.svg = it-mark-navy (the mint mark would vanish on
 * white), mark-dark.svg = it-mark-lime (as the app drew the mark in dark mode); favicon.png = mint mark
 * on a navy tile (brand rule: app icon on navy ground); mail/*.png = light variants for the white mail body.
 * Source of the SVGs: input/mb-design-system.zip (assets/logos/).
 *
 * Specificity: overrides of app component rules are prefixed with :root. The production server links
 * this file last, where equal specificity would already win, but the Vite dev server injects the app CSS
 * as <style> tags AFTER this file, so a plain duplicate selector would lose there. The prefix makes the
 * theme win independently of load order. No !important.
 *
 * Pitfall: only relative url() targets and data: URIs are allowed (the validator rejects @import and
 * other origins); relative URLs resolve against /theme/theme.css, i.e. to this folder.
 */

/* ------------------------------------------------------------------------------------------------ */
/* Fonts: self-hosted woff2 from Fontsource (OFL-1.1, licences in fonts/), no font CDN at runtime.     */
/* Split per subset like the upstream packages: the browser downloads latin-ext only when a page      */
/* contains such characters. Family names match "fonts" in theme.json.                                */
/* ------------------------------------------------------------------------------------------------ */

/* Outfit (variable, weights 100–900; the app uses 300–700) – @fontsource-variable/outfit 5.3.0 */
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/outfit-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/outfit-latin-wght-normal.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;
}

/* JetBrains Mono 400 and 500 (the weights the design system uses) – @fontsource/jetbrains-mono 5.3.0 */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/jetbrains-mono-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/jetbrains-mono-latin-400-normal.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: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/jetbrains-mono-latin-ext-500-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/jetbrains-mono-latin-500-normal.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;
}

/* ------------------------------------------------------------------------------------------------ */
/* Brand constants, radii, shadows                                                                     */
/* ------------------------------------------------------------------------------------------------ */

/*
 * Brand colours that are the same in both modes (unlike the semantic tokens, which switch, e.g. primary
 * is navy in light and mint in dark). Only the components below use them; everything else stays on the
 * semantic tokens from theme.json. Prefixed --mb- so they cannot collide with app tokens.
 */
:root {
  --mb-navy: #1E3C5A;
  --mb-mint: #00F5C8;
  --mb-on-navy-muted: #C9D6E3; /* secondary text on navy surfaces */
}

/*
 * Signature radii 2/4/6 px: the design system pairs them asymmetrically ("6px 2px"). base.css has the same
 * defaults today, but they are stated here so the brand look does not depend on base.css (the standard
 * theme sets 6 px everywhere).
 */
:root {
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
}

/*
 * Shadows: light mode tinted with navy (rgb 30 60 90) instead of base.css's neutral black, as in the
 * pre-theming tokens. Dark mode must be re-declared because :root also matches <html data-theme="dark">;
 * the dark values are the former ones (black, stronger), equal to base.css.
 */
:root {
  --shadow-sm: 0 1px 2px rgba(30, 60, 90, 0.08);
  --shadow-md: 0 4px 16px rgba(30, 60, 90, 0.12);
  --shadow-lg: 0 12px 40px rgba(30, 60, 90, 0.18);
}
:root[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/*
 * Scrim behind dialogs and drawers (ds.css --mb-scrim): navy in both modes like before. Light already gets
 * navy through `ink`; dark would otherwise use the page background.
 */
:root[data-theme="dark"] {
  --mb-scrim: var(--mb-navy);
}

/* ------------------------------------------------------------------------------------------------ */
/* Brand components: navy surfaces with mint accents in BOTH modes (the app's neutral rules use        */
/* primary/on-primary, which turn mint/navy in dark mode).                                             */
/* ------------------------------------------------------------------------------------------------ */

/* Brand card (Card tone="brand"): navy card, white text, mint heading, light muted text. */
:root .mb-card-brand { background: var(--mb-navy); border-color: var(--mb-navy); color: #FFFFFF; }
:root .mb-card-brand .mb-heading { color: var(--mb-mint); }
:root .mb-card-brand .mb-text-muted { color: var(--mb-on-navy-muted); }

/* Brand badge: mint on navy. */
:root .mb-badge-brand { background: var(--mb-navy); color: var(--mb-mint); }

/* OAuth consent: client icon tile in navy with mint glyph. */
:root .oauth-client-icon { background: var(--mb-navy); color: var(--mb-mint); }

/*
 * Avatar: mint initials on navy. Edge Case: presence avatars in the repository view colour themselves per
 * user (repo.css, `.repo-presence-avatar .mb-avatar`, background var(--presence)); they are excluded so
 * this rule, which has higher specificity, does not paint every collaborator navy.
 */
:root .mb-avatar:not(.repo-presence-avatar .mb-avatar) { background: var(--mb-navy); color: var(--mb-mint); }

/* ------------------------------------------------------------------------------------------------ */
/* Ornament                                                                                            */
/* ------------------------------------------------------------------------------------------------ */

/*
 * Zig-zag underline (the stroke of the "ı" in the word mark, laid flat) under h1 and, optionally, h2. The
 * app only sets the hook classes (Heading adds `mb-zigzag` to every h1 style, `mb-zigzag-center` for
 * centred headings); the neutral base CSS draws nothing, so the ornament exists only while this theme is
 * active. Colour: the `ornament` token (mint in light, lime in dark). The shape is an inline SVG mask
 * (data: URI, allowed by the validator because it loads nothing).
 *
 * The line spans the full width of the heading's text: the heading shrinks to its text (`fit-content`, still a
 * block, so the layout around it does not change) and the line is one zig (14 × 12, the period of the old 59 px
 * figure) repeated with `round`, which scales the zigs so a whole number fits and the line never ends in a cut
 * stroke. The tile's polyline runs past both edges so the miters at the joins are complete.
 */
.mb-zigzag { width: fit-content; max-width: 100%; }
.mb-zigzag-center { margin-left: auto; margin-right: auto; }
.mb-zigzag::after {
  content: ""; display: block; width: 100%; height: 12px; margin-top: 6px; background: var(--ornament);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 12' preserveAspectRatio='none'%3E%3Cpolyline points='-7,1.5 0,10.5 7,1.5 14,10.5 21,1.5' fill='none' stroke='%23000' stroke-width='3' stroke-linejoin='miter' stroke-miterlimit='10'/%3E%3C/svg%3E") left center / 14px 12px round no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 12' preserveAspectRatio='none'%3E%3Cpolyline points='-7,1.5 0,10.5 7,1.5 14,10.5 21,1.5' fill='none' stroke='%23000' stroke-width='3' stroke-linejoin='miter' stroke-miterlimit='10'/%3E%3C/svg%3E") left center / 14px 12px round no-repeat;
}
.mb-zigzag.h2::after, .mb-zigzag-sm::after { height: 9px; margin-top: 4px; -webkit-mask-size: 10.5px 9px; mask-size: 10.5px 9px; }
.mb-zigzag.display::after { height: 15px; margin-top: 8px; -webkit-mask-size: 17.5px 15px; mask-size: 17.5px 15px; }
