/* Froggy design tokens: fonts, colours, the pixel unit and the type scale. Every other stylesheet (and the
   Pelican panel theme) builds on these; change a colour or size here, not in the component CSS.
   Light values are on :root; dark values on body.dark-mode (the site) and .dark (the panel, Filament). */

/* --- Fonts (self-hosted, SIL OFL; licences in fonts/) --- */
/* Pixelify Sans: body and headings. Variable 400-700, so bold is a real weight, not a smeared one. */
@font-face {
    font-family: 'Pixelify Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/pixelify-sans-latin-ext.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: 'Pixelify Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/pixelify-sans-latin.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;
}
/* Pixelify Sans draws (c) and (R) as tiny superscripts; these faces, declared later, win for those characters.
   (c): our own wide 9 x 9 pixel glyph at cap height (scripts/fonts/make-copyright-glyph.py). (R): VT323's. */
@font-face {
    font-family: 'Pixelify Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/vt323-latin.woff2) format('woff2');
    unicode-range: U+00AE;
}
@font-face {
    font-family: 'Pixelify Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/froggy-copyright.woff2) format('woff2');
    unicode-range: U+00A9;
}
/* Silkscreen: buttons, table headers, badges (capitals only). Drawn on an 8px-per-em grid: use 8/16/24/32px. */
@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(../fonts/silkscreen-400-latin-ext.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: 'Silkscreen';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(../fonts/silkscreen-400-latin.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: 'Silkscreen';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(../fonts/silkscreen-700-latin-ext.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: 'Silkscreen';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(../fonts/silkscreen-700-latin.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;
}
/* VT323: monospace data (addresses, ports, figures) and the panel console. One weight: never bold it. */
@font-face {
    font-family: 'VT323';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(../fonts/vt323-latin-ext.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: 'VT323';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(../fonts/vt323-latin.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;
}

:root {
    /* --- Palette: the only raw colours. Everything below points at these. --- */
    --navy: #090335;
    --navy-fill: #181043;             /* dark boxes' inside, a shade lighter than their navy border */
    --cream: #fbf6cf;
    --peach: #f7a885;
    --peach-light: #f7b585;
    --lilac: #ede1e5;
    --pink: #f0797f;
    --pink-light: #f48f94;
    --raspberry: #b8324a;   /* pink dark enough for text on cream (5.3:1) */
    --gold: #ffc965;
    --gold-dark: #ffbe44;
    --red: #f66068;
    --red-light: #ff4f59;
    --plum-grey: #574f6b;   /* secondary text (5.9:1 on lilac) */
    --stone: #6c757d;
    --stone-dark: #5a6268;
    --mist: #9d9792;
    --green: #77d57c;
    --sky: #79b9ec;
    --amber: #e1a44a;
    --coral: #fb8c84;
    --silver: #bfbfbf;
    --white: #ffffff;

    /* --- Surfaces --- */
    --bg-main: var(--peach);          /* page background (dithered with --bg-secondary) */
    --bg-secondary: var(--peach-light);
    --bg-light: var(--cream);         /* the content column */
    --bg-modal: var(--lilac);         /* boxes, panels, modals */
    --bg-hover: #f5f5f5;
    --bg-stripe: rgb(255 255 255 / 0.5); /* every other table row: see-through, lightening (dark mode: darkening) whatever is behind */
    --bg-input: var(--white);
    --chrome-bg: var(--navy);         /* navbar, footer, theme toggle: navy in both themes */
    --chrome-text: var(--cream);

    /* --- Text --- */
    --text-primary: var(--navy);
    --text-secondary: var(--plum-grey);
    --text-white: var(--white);
    --text-on-accent: var(--navy);    /* text on buttons, badges and pink/gold headers */
    --money: #236c2b;                 /* currency symbols and discount text (dark green: 5:1 on the light surfaces) */
    --money-fill: #acf5a8;            /* the chosen € / $ and the sale badge (#7ff079, triadic with the secondary, washed out) */
    --text-on-money: var(--navy);
    --text-input: var(--navy);        /* inputs stay light in both themes */
    --link: var(--raspberry);

    /* --- Borders --- */
    --border-primary: var(--navy);

    /* --- Buttons and accents --- */
    --btn-primary: var(--pink);
    --btn-primary-hover: var(--pink-light);
    --btn-danger: var(--red);
    --btn-danger-hover: var(--red-light);
    --btn-warning: var(--gold);
    --btn-warning-hover: var(--gold-dark);
    --btn-cancel: var(--stone);
    --btn-cancel-hover: var(--stone-dark);
    --btn-cancel-text: var(--white);
    --btn-secondary: #c3a3e0;              /* other actions that do not finish the task: a dusty lilac, warm enough for the cream and pink */
    --header-bg: var(--btn-secondary); /* table headers, modal title bars: the secondary colour; primary is kept for what must stand out */

    /* --- Status (server state dots, admin badges, usage bars) --- */
    --status-running: var(--green);
    --status-offline: var(--silver);
    --status-suspended: var(--amber);
    --status-processing: var(--sky);
    --status-failed: var(--coral);
    --status-premium: #ffd700;
    --status-admin: var(--red);

    /* --- Alerts: tinted box, primary text, coloured edge --- */
    --alert-info-bg: var(--bg-modal);
    --alert-info-edge: var(--border-primary);
    --alert-success-bg: #d8f3d9;
    --alert-success-edge: #3e9b45;
    --alert-warning-bg: #ffefcc;
    --alert-warning-edge: #d98a00;
    --alert-error-bg: #ffd6d4;
    --alert-error-edge: #d6343e;
    --alert-error: #b0232c;           /* inline error text (5.6:1 on cream) */

    /* --- Effects --- */
    --overlay-dark: rgba(9, 3, 53, 0.8);
    --shadow-soft: rgba(0, 0, 0, 0.2);
    --shadow-hard: rgba(0, 0, 0, 0.1);
    --shadow-inset-light: rgba(255, 255, 255, 0.55);   /* the highlight on the top and left edge of buttons and boxes */
    --focus-ring: rgba(184, 50, 74, 0.55);

    /* --- Pixel unit: every border, outline and shadow is a multiple of it, in px so it stays crisp
       whatever the font size. --- */
    --px: 3px;
    --bg-px: 6px;   /* one pixel of the page background's patterns (js/background.js): twice --px */
    --border: var(--px) solid var(--border-primary);
    --pixel-outline:
        calc(var(--px) * -1) 0 0 0 var(--border-primary),
        var(--px) 0 0 0 var(--border-primary),
        0 calc(var(--px) * -1) 0 0 var(--border-primary),
        0 var(--px) 0 0 var(--border-primary);
    --pixel-shadow:
        var(--pixel-outline),
        var(--px) calc(var(--px) * 2) 0 0 var(--shadow-soft),
        calc(var(--px) * 2) var(--px) 0 0 var(--shadow-soft);
    --pixel-shadow-inset:
        inset var(--px) var(--px) 0 0 var(--shadow-inset-light),
        inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 var(--shadow-hard);
    --input-inset: inset var(--px) var(--px) 0 0 var(--shadow-hard);
    /* A pixel-art circle on a 7 x 7 grid (switch knobs), as masks so colours stay tokens: the whole disc, and the
       disc one pixel smaller (its fill inside a 1-pixel rim). Drawn at 7 x --px, its rim is as thick as every
       other border. */
    --pixel-circle: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges'><path d='M2 0h3v1h1v1h1v3h-1v1h-1v1h-3v-1h-1v-1h-1v-3h1v-1h1z'/></svg>");
    --pixel-circle-inner: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 7' shape-rendering='crispEdges'><path d='M2 1h3v1h1v3h-1v1h-3v-1h-1v-3h1z'/></svg>");
    /* The required-field star (style.css .asterisk): 5 x 5 pixels */
    --pixel-asterisk: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'><path d='M0 0h1v1H0zM2 0h1v1H2zM4 0h1v1H4zM1 1h3v1H1zM0 2h5v1H0zM1 3h3v1H1zM0 4h1v1H0zM2 4h1v1H2zM4 4h1v1H4z'/></svg>");
    /* The site's switch knob (style.css .switch): an 11 x 11 pixel circle and its inside, a 1-pixel rim */
    --pixel-knob: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11' shape-rendering='crispEdges'><path d='M4 0h3v1h2v1h1v2h1v3h-1v2h-1v1h-2v1h-3v-1h-2v-1h-1v-2h-1v-3h1v-2h1v-1h2z'/></svg>");
    --pixel-knob-inner: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11' shape-rendering='crispEdges'><path d='M4 1h3v1h2v2h1v3h-1v2h-2v1h-3v-1h-2v-2h-1v-3h1v-2h2z'/></svg>");
    /* The checkbox tick (style.css .checkbox), a mask on a 12 x 12 grid of half pixels, drawn at 6 x --px */
    --pixel-tick: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'><path d='M9 2h2v1H9zM8 3h3v1H8zM7 4h3v1H7zM1 5h2v1H1zM6 5h3v1H6zM1 6h3v1H1zM5 6h3v1H5zM2 7h5v1H2zM3 8h3v1H3zM4 9h1v1H4z'/></svg>");
    /* The dropdown arrow (select, the egg picker): 5 x 3 pixels, drawn at --px. A background, not a mask (a select
       has no ::after), so it is navy, the text colour of inputs in both themes. */
    /* The tick in navy, for checkboxes that can only take a background image (the panel's) */
    --pixel-tick-navy: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' shape-rendering='crispEdges'><path fill='%23090335' d='M9 2h2v1H9zM8 3h3v1H8zM7 4h3v1H7zM1 5h2v1H1zM6 5h3v1H6zM1 6h3v1H1zM5 6h3v1H5zM2 7h5v1H2zM3 8h3v1H3zM4 9h1v1H4z'/></svg>");
    --pixel-warning: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9' shape-rendering='crispEdges'><path fill='%23ffc965' d='M4 1h1v1H4zM3 2h3v2H3zM2 4h5v2H2zM1 6h7v2H1z'/><path fill='%23090335' d='M4 0h1v1H4zM3 1h1v1H3zM5 1h1v1H5zM2 2h1v2H2zM6 2h1v2H6zM1 4h1v2H1zM7 4h1v2H7zM0 6h1v2H0zM8 6h1v2H8zM0 8h9v1H0zM4 2h1v3H4zM4 6h1v1H4z'/></svg>");
    --pixel-arrow-down: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 3' shape-rendering='crispEdges'><path fill='%23090335' d='M0 0h5v1H0zM1 1h3v1H1zM2 2h1v1H2z'/></svg>");
    --focus-outline: 0 0 0 var(--px) var(--focus-ring);

    /* --- Fonts --- */
    --f-main: 'Pixelify Sans', system-ui, sans-serif;
    --f-pixel: 'Silkscreen', monospace;
    --f-mono: 'VT323', ui-monospace, monospace;

    /* --- Type scale (Pixelify Sans unless noted). Use these, not one-off sizes. --- */
    --fs-xs: 0.875rem;     /* 14px: fine print, rack details */
    --fs-sm: 1rem;         /* 16px: notes, labels, table cells */
    --fs-md: 1.125rem;     /* 18px: body text, inputs */
    --fs-lg: 1.25rem;      /* 20px: form fields, lead text */
    --fs-xl: 1.5rem;       /* 24px: h4, navbar, big numbers */
    --fs-2xl: 1.875rem;    /* 30px: h3, modal titles */
    --fs-3xl: 2.25rem;     /* 36px: h2, page titles */
    --fs-4xl: 2.75rem;     /* 44px: h1 */
    --fs-pixel-sm: 0.5rem; /* Silkscreen 8px (1px pixels) */
    --fs-pixel: 1rem;      /* Silkscreen 16px (2px pixels) */
    --fs-pixel-lg: 1.5rem; /* Silkscreen 24px */
    --fs-mono: 1.375rem;   /* VT323 22px, sits with --fs-md text */
    --lh-body: 1.4;
    --lh-tight: 1.15;
}

/* Pixel font off (the theme menu; the panel follows the same cookie): the system's fonts, same sizes. Buttons,
   table headers and badges (--f-pixel) get the system font's semibold face whatever weight their rule asks for, so
   they keep Silkscreen's weight instead of looking thin. */
@font-face {
    font-family: 'Froggy Plain Strong';
    font-weight: 100 900;
    src: local('Segoe UI Semibold'), local('SegoeUI-Semibold'), local('Roboto Medium'), local('Roboto-Medium'),
         local('Helvetica Neue Medium'), local('HelveticaNeue-Medium'), local('Arial Bold'), local('Arial-BoldMT');
}
body.plain-font,
.plain-font {
    --f-main: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --f-pixel: 'Froggy Plain Strong', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --f-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --fs-mono: var(--fs-sm); /* VT323 is drawn small for its size; a normal monospace is wider */
}

body.dark-mode,
.dark {
    --money: #b4ffe6;                 /* currency symbols and discount text: a lighter mint than the fill, for reading on purple */
    --money-fill: #7fd9c6;            /* #65ffc9 (triadic with the gold), washed out toward the grey-lilac */
    --text-on-money: var(--navy);
    /* Surfaces: peach -> deep blue page, cream -> purple content */
    --bg-main: var(--navy);
    --bg-secondary: #0f0640;          /* dither: as subtle as the light one (OKLab difference 0.028 vs 0.033) */
    --bg-light: #6149a7;
    --bg-modal: #4d3a8a;
    --bg-hover: #3d2d6a;
    --bg-stripe: rgb(9 3 53 / 0.14);
    --bg-input: var(--cream);

    /* Text: navy -> cream */
    --text-primary: var(--cream);
    --text-secondary: #d6cfee;        /* 4.6:1 on the purple content */
    --text-white: var(--cream);
    --link: var(--gold);

    /* Accent: pink -> gold */
    --btn-primary: var(--gold);
    --btn-primary-hover: #ffd88f;
    --btn-cancel: #a7a1c2;
    --btn-cancel-hover: #bcb7d4;
    --btn-cancel-text: var(--navy);
    --btn-secondary: #bb7de7;              /* #c965ff (triadic with the gold and mint), washed out toward the grey-lilac */
    --header-bg: var(--btn-secondary);

    /* Alerts: dark tints, cream text */
    --alert-info-bg: #3d2d6a;
    --alert-info-edge: var(--cream);
    --alert-success-bg: #24474a;
    --alert-success-edge: var(--green);
    --alert-warning-bg: #4f3d33;
    --alert-warning-edge: var(--gold);
    --alert-error-bg: #4f2547;
    --alert-error-edge: var(--coral);
    --alert-error: #ffc2bd;

    --focus-ring: rgba(255, 201, 101, 0.7);
}

/* --- Edge highlights: the light top-left edge of buttons and boxes (--pixel-shadow-inset) is the element's
   own colour made a fixed step lighter in OKLCH, so it is equally noticeable on dark and light surfaces.
   Each element works it out from its own --surface: the box colour by default, set by the components that
   are another colour (buttons, table headers, popup title bars, light cards...). Browsers without relative
   colours keep the plain white edge (--shadow-inset-light). --- */
@supports (color: oklch(from red l c h)) {
    * {
        --surface: var(--bg-modal);
        --pixel-shadow-inset:
            inset var(--px) var(--px) 0 0 oklch(from var(--surface) calc(l + 0.25) c h),
            inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 var(--shadow-hard);
    }
}
