/*
 * Metal Price Portal design system.
 *
 * The one global stylesheet. It holds the tokens, resets and shared primitives only;
 * component styles live in scoped CSS (Component.razor.css) and reference these
 * tokens. No colour, radius or spacing value is written anywhere else - add a token
 * here instead.
 *
 * Breakpoints cannot be custom properties inside @media, so they are a convention:
 *   desktop  > 800px
 *   tablet  <= 800px   sidebar becomes a horizontal scrollable nav
 *   phone   <= 480px   single column, tables as stacked cards, full-width controls,
 *                      the sidebar folds behind a Menu button
 */

/* Inter, served from the portal itself so every device draws the same type. One
   variable file covers weights 400-800; it is the Latin subset, which includes the
   arrows and dashes of the price changes. OFL licence beside it. */
@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-variable.woff2") format("woff2");
}

:root {
    /* Colour - the CLAUDE.md design-system table. */
    --green: #16834a;        /* primary / main action / price fall */
    --green2: #e8f5ed;       /* accent background / pill / badge */
    --green-dark: #10241c;   /* sidebar / nav background */
    --ink: #18221d;          /* primary text */
    --muted: #68736d;        /* secondary text / label / no change */
    --line: #dfe6e1;         /* border / divider */
    --bg: #f6f8f7;           /* page background */
    --white: #ffffff;        /* surface / card */
    --price-down: #b42318;   /* price rise / danger */

    /* Colour - supporting shades taken from the mockup. */
    --green-hover: #1e5d3d;     /* nav item hover and active, primary hover */
    --green-border: #cce8d6;    /* border of a green2 surface */
    --nav-text: #c8d4ce;        /* inactive nav item text on green-dark */
    --nav-label: #9fb0a7;       /* section label above the nav items */
    --line-strong: #ccd6d0;     /* form control border */
    --line-soft: #edf1ee;       /* table row divider */
    --surface-muted: #f3f6f4;   /* note / inset panel background */
    --neutral2: #f0f2f1;        /* "no change" pill and neutral badge background */
    --price-down2: #fdecec;     /* failure and danger background */

    /* Colour - a price's move on Review, as the client asked on 2026-11-03: a rise is
       green and a fall red (reversing their 2026-10-28 request). */
    --price-rise: var(--green);
    --price-fall: var(--price-down);
    --warning: #93370d;         /* text, border and icon of a warning that does not stop anything */
    --warning2: #fef6e7;        /* warning background */
    --line-emphasis: #8a918d;   /* border of the "Sign in with Microsoft" button */

    /* Colour - the Microsoft logo, fixed by Microsoft brand guidelines. */
    --microsoft-red: #f25022;
    --microsoft-green: #7fba00;
    --microsoft-blue: #00a4ef;
    --microsoft-yellow: #ffb900;

    /* Overlays and elevation. */
    --overlay: rgba(16, 36, 28, 0.45);
    --shadow-raised: 0 18px 45px rgba(16, 36, 28, 0.1);
    --shadow-modal: 0 20px 50px rgba(16, 36, 28, 0.25);
    --shadow-sticky-bottom: 0 -8px 20px rgba(16, 36, 28, 0.08); /* a bar held at the bottom of the screen */
    --opacity-disabled: 0.55;  /* a control that cannot be used right now */
    --spinner-size: 1em;       /* a busy indicator, sized to the text beside it */
    --spinner-stroke: 2px;
    --spinner-duration: 0.8s;  /* one turn of a busy indicator */
    --loading-reveal-delay: 0.3s; /* how long a table waits before it says it is loading */
    --z-dialog: 90;          /* a dialog and its overlay, above the page */
    --z-toast: 100;          /* above the page and a dialog, below the error bar (1000) */
    --dialog-max-width: 640px;
    --dialog-max-width-wide: 1120px; /* a dialog with two columns, such as an editor and its preview */

    /* Typography. */
    --font-family: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-size-xs: 11px;    /* table headers, pills */
    --font-size-sm: 13px;    /* fine print, compact nav */
    --font-size-md: 14px;    /* body copy in cards and tables */
    --font-size-input: 16px; /* form controls: below this, mobile browsers zoom on focus */
    --font-size-h3: 15px;
    --font-size-h2: 20px;
    --font-size-h1: 27px;
    --font-size-h2-compact: 19px; /* tablet and below */
    --font-size-h1-compact: 23px; /* tablet and below */
    --font-size-stat: 25px;
    --font-size-stat-compact: 23px; /* tablet and below */
    --font-size-wordmark: 22px;
    --font-size-sidebar-wordmark: 19px;         /* the sidebar wordmark */
    --font-size-sidebar-wordmark-compact: 17px; /* the sidebar wordmark, tablet and below */
    --font-weight-semibold: 600; /* emphasis short of a heading or a label */
    --font-weight-bold: 700;
    --font-weight-heavy: 800;
    --line-height: 1.5;
    --letter-spacing-label: 0.06em; /* uppercase section labels */

    /* Radius. */
    --radius-card: 13px;
    --radius-control: 8px;
    --radius-pill: 999px;

    /* Spacing scale. Pick from it; do not invent per-component paddings. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 28px;

    /* Sizing. */
    --touch-target: 44px;    /* minimum height of anything tappable */
    --sidebar-width: 230px;
    --menu-icon-width: 18px;  /* the three bars of the phone's Menu button */
    --menu-icon-bar: 2px;
    --topbar-height: 68px;
    --content-max-width: 1200px;
    --auth-card-width: 430px;
    --rich-text-min-height: 240px;     /* the writing area of a rich-text editor */
    --email-preview-min-height: 480px; /* an email shown as its recipient will see it */
}

/* Resets. */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-family);
    line-height: var(--line-height);
}

/* The page behind an open AppDialog does not scroll; here because scoped CSS cannot
   reach the body. */
body:has(.app-dialog-overlay) {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

/* Below 16px, mobile browsers zoom the page when a control takes focus. */
input,
select,
textarea {
    font-size: var(--font-size-input);
}

img,
svg {
    display: block;
    max-width: 100%;
}

/* Shared primitives. */

h1,
h2,
h3 {
    margin: 0 0 var(--space-1);
    line-height: 1.25;
}

h1 {
    font-size: var(--font-size-h1);
}

h2 {
    font-size: var(--font-size-h2);
}

h3 {
    font-size: var(--font-size-h3);
    margin-bottom: var(--space-3);
}

/* Blazor moves focus to the page heading on navigation; that is for screen
   readers, not a visible outline. */
h1:focus {
    outline: none;
}

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

.muted {
    color: var(--muted);
    font-size: var(--font-size-md);
}

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

/* Blazor form validation. */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--green);
}

.invalid {
    outline: 1px solid var(--price-down);
}

.validation-message {
    color: var(--price-down);
    font-size: var(--font-size-sm);
}

/* Rendered by Blazor's ErrorBoundary when a component throws. */
.blazor-error-boundary {
    background: var(--price-down);
    color: var(--white);
    padding: var(--space-4);
    border-radius: var(--radius-control);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

@media (max-width: 800px) {
    h1 {
        font-size: var(--font-size-h1-compact);
    }

    h2 {
        font-size: var(--font-size-h2-compact);
    }
}
