/*
  The whole theme, in one file (docs/18 §6, STY-4).

  Re-theming the demo for another prospect is replacing this file and nothing else. Components
  reference tokens only — a hex literal anywhere else is a bug, and STY-1 is the test for it.

  Single dark theme on purpose (docs/18 §6): every colour is declared rather than inherited, so
  the page looks the same whatever the browser or container decides about light and dark.
*/

:root {
    /* ---- Surfaces -------------------------------------------------------- */
    --bg-950: #100416;   /* page */
    --bg-900: #15051d;   /* alternate section */
    --bg-850: #170620;
    --bg-800: #1b0725;   /* card */
    --bg-700: #1e082a;
    --bg-600: #2d0b3e;   /* raised surface */
    --bg-500: #431a54;   /* divider */

    /* ---- Gold: value, and never an action (docs/18 §4) ------------------- */
    --gold-100: #d8b85e;
    --gold-200: #d2af54;
    --gold-300: #c28933;
    --gold-400: #bb812e;
    --gold-500: #9f7c27;
    --gold-bright: #ffe684;   /* the one that clears AA on --bg-600 */
    --gold-amber: #ffc440;
    --gold-warm: #e6b03a;

    --gold-sheen: linear-gradient(103deg, #e6b03a 5.76%, #fffbcc, #e6b03a,
                                  #e4c671 75.12%, #fffbcc 88.99%, #fff 98.24%);

    /* ---- Magenta and violet: actions, and never a value ------------------ */
    --magenta-500: #ee27c3;
    --magenta-600: #d322a9;
    --violet-600: #6b2b9a;
    --violet-700: #64277e;
    --violet-800: #431a54;

    --action-gradient: linear-gradient(250.6deg, #ee27c3, #6b2b9a);

    /* ---- Text and lines -------------------------------------------------- */
    --white: #ffffff;
    --white-10: rgba(255, 255, 255, .1);   /* hairline borders, almost always */
    --text-dim: #e1e0e1;
    --danger: #ff3b3b;

    --section-fade: linear-gradient(180deg, #15051d, #2d0b3e);
    --image-veil-bottom: linear-gradient(180deg, #1b072500, #1b0725f2 75%);
    --image-veil-side: linear-gradient(237deg, #15051d00 22%, #15051df2 70%);
    --warm-metal: linear-gradient(55deg, #431a54 57%, #6e3550 78%, #a05c3c 90%, #cc8532);

    /* ---- Type (docs/18 §2), taken literally from the reference ----------- */
    --f-sans: "General Sans", "Helvetica Neue", Arial, system-ui, sans-serif;

    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-lg: 17px;
    --text-xl: 21px;
    --text-2xl: 24px;
    --text-3xl: 32px;
    --text-4xl: 40px;
    --text-5xl: 46px;
    --text-6xl: 64px;
    --text-7xl: 80px;
    --text-8xl: 100px;

    /* ---- Shape ----------------------------------------------------------- */
    --radius: 8px;
    --radius-pill: 999px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
}

/*
  General Sans, served from the demo itself and never from a CDN (STY-7).

  The woff2 files are not in the repository — they are downloaded from Fontshare, whose licence
  permits commercial use but not redistribution inside somebody else's repo. Drop them into
  wwwroot/fonts and this picks them up; without them the fallback stack above is what renders,
  which is legible and merely less like the reference.
*/
@font-face {
    font-family: "General Sans";
    src: url("fonts/GeneralSans-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "General Sans";
    src: url("fonts/GeneralSans-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

/* ---------------------------------------------------------------- base ---- */

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

body {
    margin: 0;
    background: var(--bg-950);
    color: var(--white);
    font-family: var(--f-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    /* Headings carry slight negative tracking; uppercase labels carry positive (docs/18 §2). */
    letter-spacing: -0.02em;
    font-weight: 700;
    margin: 0;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); }

a {
    color: var(--gold-bright);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

/* Every figure lines up in a column. */
.num {
    font-variant-numeric: tabular-nums;
}

.label {
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    opacity: .65;
}

.dim {
    color: var(--text-dim);
    opacity: .7;
}

/* --------------------------------------------------------------- layout --- */

.shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-5);
}

.stack {
    display: grid;
    gap: var(--space-5);
}

.row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Grids use gap, never per-element margins (docs/18 §6). */
.grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.card {
    background: var(--bg-800);
    border: 1px solid var(--white-10);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.raised {
    background: var(--bg-600);
    border-radius: var(--radius);
}

/* --------------------------------------------------------------- value ---- */

/* Gold means value: levels, points, tokens, prize amounts. Never an action. */
.value {
    color: var(--gold-warm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.value-lg {
    font-size: var(--text-3xl);
}

/* On --bg-600 the ordinary golds miss AA for small text, so this one is used instead. */
.on-raised .value,
.on-raised .value-lg {
    color: var(--gold-bright);
}

.value-sheen {
    background: var(--gold-sheen);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
}

/* -------------------------------------------------------------- actions --- */

/* Magenta to violet means "do something". Never a value. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border: 0;
    border-radius: var(--radius);
    background: var(--action-gradient);
    color: var(--white);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 700;
    cursor: pointer;
}

.btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--white-10);
    color: var(--white);
    font-weight: 400;
}

/* ---------------------------------------------------------------- parts --- */

.pill {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--bg-600);
    font-size: var(--text-xs);
    color: var(--text-dim);
}

.pill-warning {
    background: var(--bg-600);
    color: var(--gold-amber);
}

.pill-danger {
    background: var(--bg-600);
    color: var(--danger);
}

/* Progress: magenta fill on a --bg-600 track (docs/18 §5). */
.progress {
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-600);
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--action-gradient);
    border-radius: var(--radius-pill);
}

/* The level badge: gold ring, image inside. */
.badge {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--gold-400);
    background: var(--bg-700);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/*  A level with no artwork.

    The merchant sets ImageUrl per level and may simply not have. The fallback is not a grey
    box with a number in it: the level's own colour is data the API already returns, so the
    badge is filled with it and still reads as that level. --level-colour is set inline from
    Level.colorHex, which is why there is no literal here (STY-1).                            */
.badge-plain {
    background:
        radial-gradient(circle at 34% 28%,
            color-mix(in srgb, var(--level-colour, var(--gold-400)) 55%, white),
            var(--level-colour, var(--gold-400)) 55%,
            color-mix(in srgb, var(--level-colour, var(--gold-400)) 60%, black));
    border-color: color-mix(in srgb, var(--level-colour, var(--gold-400)) 70%, white);
}

.badge-plain .value {
    color: var(--bg-950);
    font-size: var(--text-lg);
    text-shadow: 0 1px 0 rgb(255 255 255 / .35);
}

/* A level not yet reached: present, clearly not earned (docs/18 §5). */
.badge-future {
    opacity: .3;
    border-color: var(--white-10);
}

.divider {
    height: 1px;
    background: var(--white-10);
    border: 0;
}

/* ------------------------------------------------------------ animation --- */

/*
  The only place with a flourish: reaching a new level (docs/18 §5). Everything else is still,
  which is what makes this read as an event rather than as decoration.
*/
@keyframes level-up {
    0%   { transform: scale(1);    filter: brightness(1); }
    40%  { transform: scale(1.18); filter: brightness(1.8); }
    100% { transform: scale(1);    filter: brightness(1); }
}

.level-up {
    animation: level-up 900ms ease-out;
}

/* STY-6. Somebody who asked for less motion gets none, not less of it. */
@media (prefers-reduced-motion: reduce) {
    .level-up {
        animation: none;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/*
    The reconnection banner.

    Blazor sets exactly one of these classes on #components-reconnect-modal: -show while it is
    retrying, -hide once connected, -failed when the attempts run out, -rejected when the server
    came back but the circuit is gone. Without an element to put them on it says nothing at all,
    and a dead circuit is indistinguishable from a page that is merely slow.

    Hidden by default, including before Blazor has set any class — a banner that blinks during an
    ordinary page load is a banner people learn to ignore.
*/
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 3000;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: var(--bg-800);
    color: var(--white);
    font-size: var(--text-sm);
    border-bottom: 2px solid var(--gold-amber);
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    /* Beats the inline display:none that hides this when the stylesheet does not load. */
    display: flex !important;
}

#components-reconnect-modal p { display: none; margin: 0; }

/* Anchored on the id: the rule above is #id p, and a two-class selector would lose to it. */
#components-reconnect-modal.components-reconnect-show .reconnect-trying,
#components-reconnect-modal.components-reconnect-failed .reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-rejected {
    display: block;
}

#components-reconnect-modal button {
    margin-left: 10px;
    border: 0;
    border-radius: 999px;
    padding: 6px 15px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--gold-amber);
    color: var(--bg-950);
}
