/* Storefront pages: /store, /store/:slug, /account.
   Colours come from the UX SDK tokens (ux.css). ux.css is dark only, so the light scheme redefines
   the same token names below; the SDK web components read them through var(--token, fallback). */

:root { color-scheme: dark light; }

@media (prefers-color-scheme: light) {
    :root {
        --dark: #f5f6fa;
        --mid: #eceef5;
        --card: #ffffff;
        --border: #d5d9e6;
        --text: #1b2030;
        --muted: #5a6280;
        --accent: #2f6fe0;
        --green: #1d8a5a;
        --gold: #8f6a12;
        --red: #c23b3b;
    }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--dark);
    color: var(--text);
    font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
    line-height: 1.55;
}

a { color: var(--accent); }

button, input, select { font: inherit; color: inherit; }

/* ── Header ────────────────────────────────────────────────────────────── */

.st-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    padding: 8px 16px;
    background: var(--mid);
    border-bottom: 1px solid var(--border);
}

.st-brand { color: var(--text); font-weight: 600; font-size: 1.1rem; text-decoration: none; white-space: nowrap; }
.st-brand em { color: var(--accent); font-style: normal; }

.st-nav { display: flex; gap: 14px; }
.st-nav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: 6px 2px; }
.st-nav a:hover, .st-nav a[aria-current="page"] { color: var(--text); }
.st-nav a[aria-current="page"] { border-bottom: 2px solid var(--accent); }

.st-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ── Layout ────────────────────────────────────────────────────────────── */

.st-main { max-width: 1000px; margin: 0 auto; padding: 24px 16px 64px; }

.st-muted { color: var(--muted); margin: 0 0 12px; }
.st-error { color: var(--red); margin: 8px 0; }
.st-status { color: var(--accent); margin: 8px 0; }
.st-note { color: var(--muted); font-size: .82rem; margin: 2px 0 0; }
.st-headline { font-size: 1.05rem; font-weight: 500; margin: 4px 0 8px; }
.st-price { font-weight: 600; margin: 4px 0; }
.st-section-title { font-size: 1.1rem; margin: 28px 0 10px; }

.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── Audience switch (Dealers | Publishers) ────────────────────────────── */

.st-audience { display: inline-flex; gap: 4px; padding: 4px; margin: 4px 0 8px; background: var(--mid); border: 1px solid var(--border); border-radius: 999px; }
.st-audience-tab { border: 0; background: none; color: var(--muted); padding: 6px 16px; border-radius: 999px; cursor: pointer; font-size: .9rem; }
.st-audience-tab:hover { color: var(--text); }
.st-audience-tab[aria-selected="true"] { background: var(--accent); color: #ffffff; font-weight: 600; }
.st-audience-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Banner at the top of the catalogue: slim, with a picture that follows the audience switch ── */

.st-banner { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0 0 20px; padding: 20px 24px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg, 12px); background: linear-gradient(135deg, var(--mid), var(--card)); }
.st-banner-copy { flex: 1; min-width: 0; }
.st-banner-eyebrow { margin: 0 0 6px; font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.st-banner-title { margin: 0 0 6px; font-size: clamp(1.35rem, 3vw, 1.9rem); line-height: 1.2; }
.st-banner-line { margin: 0; color: var(--muted); max-width: 520px; }
.st-banner-img { flex: none; display: block; height: 150px; width: auto; aspect-ratio: 16 / 9; border-radius: var(--radius-lg, 10px); border: 1px solid var(--border); animation: st-banner-in .25s ease-out; }
@keyframes st-banner-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .st-banner-img { animation: none; } }
@media (max-width: 640px) {
    .st-banner { padding: 16px; }
    .st-banner-img { display: none; }
}

/* ── Category filter (under the audience switch) and the category label on a card ── */

.st-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.st-cat-btn { border: 1px solid var(--border); background: transparent; color: var(--muted); padding: 5px 14px; border-radius: 999px; cursor: pointer; font-size: .85rem; }
.st-cat-btn:hover { color: var(--text); border-color: var(--accent); }
.st-cat-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--mid); font-weight: 600; }
.st-cat-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.st-card-cat { margin: 0 0 6px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }

/* ── Cards, chips, buttons ─────────────────────────────────────────────── */

/* A card image runs to the card's edges; the fixed ratio keeps a grid row level whatever the file's size. */
.st-card-hero { display: block; width: calc(100% + 36px); max-width: none; margin: -18px -18px 12px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-lg, 10px) var(--radius-lg, 10px) 0 0; background: var(--mid); }

.st-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 10px);
    padding: 18px;
    margin: 0 0 16px;
}

.st-grid .st-card { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.st-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.st-card-title { margin: 0; font-size: 1.05rem; }
.st-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; }

.st-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--muted);
    border: 1px solid var(--border);
}

.st-chip--available, .st-chip--status-trialing { color: var(--accent); border-color: var(--accent); }
.st-chip--included, .st-chip--status-active { color: var(--green); border-color: var(--green); }
.st-chip--comingSoon, .st-chip--status-paused, .st-chip--status-unknown { color: var(--muted); }
.st-chip--status-past_due, .st-chip--status-cancelling { color: var(--gold); border-color: var(--gold); }
.st-chip--status-expired { color: var(--red); border-color: var(--red); }
.st-chip--quiet { font-weight: 500; }
.st-chip--requested { color: var(--green); border-color: var(--green); }
.st-beta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.st-beta .st-note, .st-beta .st-error { flex-basis: 100%; margin: 0; }

.st-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 18px;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
}

.st-btn:hover { border-color: var(--accent); }
.st-btn:focus-visible, .st-header a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.st-btn--primary:hover { filter: brightness(1.08); }
.st-btn--quiet { color: var(--accent); }
.st-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.st-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.st-field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; font-size: .9rem; width: 100%; }
.st-form .st-field { margin: 0; }

.st-field input, .st-field select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    background: var(--mid);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
}

.st-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.st-terms { display: inline-block; margin-top: 12px; font-size: .8rem; }

/* ── Banners and notices ───────────────────────────────────────────────── */

.st-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 14px;
    margin: 0 0 16px;
    border-radius: var(--radius, 8px);
    border: 1px solid var(--border);
}

.st-banner--acting { border-color: var(--gold); background: rgba(200, 164, 90, .14); }
.st-banner-text { flex: 1 1 240px; font-weight: 500; }
.st-banner-error { color: var(--red); width: 100%; }

/* Secondary nav under the header: the persistent "create your organisation" prompt. Full width, like the header. */
.st-subnav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 16px;
    padding: 10px 16px;
    background: rgba(86, 130, 220, .14);
    border-bottom: 1px solid var(--accent);
}

.st-subnav-text { font-weight: 500; }

.st-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    margin: 0 0 16px;
    border: 1px solid var(--green);
    border-radius: var(--radius, 8px);
    background: rgba(76, 175, 130, .12);
}

.st-orgline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.st-org-title { margin: 0 0 4px; }

/* ── Product page ──────────────────────────────────────────────────────── */

.st-product { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.st-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg, 10px); padding: 18px; position: sticky; top: 72px; }
.st-panel-title { margin: 0 0 12px; font-size: 1.1rem; }
.st-panel-foot { margin: 16px 0 0; }
.st-section { margin: 24px 0 0; }
.st-section h3 { margin: 0 0 8px; }
.st-product-hero { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-lg, 10px); background: var(--mid); margin: 0 0 16px; }

/* Long description sections: text beside an image (left or right), or text alone (full). */
.st-story { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: center; margin: 28px 0 0; }
.st-story--full { grid-template-columns: minmax(0, 1fr); }
.st-story--left .st-story-image { order: -1; }
.st-story-title { margin: 0 0 8px; font-size: 1.15rem; }
.st-story-text p { margin: 0 0 10px; }
.st-story-image { display: block; width: 100%; height: auto; border-radius: var(--radius-lg, 10px); border: 1px solid var(--border); }

.st-list { margin: 0; padding-left: 20px; }
.st-list li { margin: 0 0 6px; }

.st-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.st-row-main { flex: 1 1 160px; min-width: 0; }
.st-row-main .st-price { display: block; margin: 2px 0 0; }
.st-row-action { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ── Dialog ────────────────────────────────────────────────────────────── */

.st-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 22px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}

.st-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.st-dialog h3 { margin: 0 0 6px; }
/* The org form is a card on /account; inside a dialog the dialog is the frame. */
.st-dialog .st-org { border: 0; padding: 0; background: none; margin: 0 0 12px; }

/* ── Account page ──────────────────────────────────────────────────────── */

.st-group { margin: 0 0 20px; }
.st-group--l1 { margin-left: 16px; padding-left: 14px; border-left: 2px solid var(--border); }
.st-group-title { margin: 16px 0 6px; font-size: 1rem; }
.st-family-title { margin: 10px 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.st-sublist { list-style: none; margin: 0; padding: 0; }

.st-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 10px 14px;
    margin: 0 0 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
}

.st-sub-main { display: flex; align-items: center; gap: 10px; flex: 1 1 200px; }
.st-sub-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.st-footer-links { margin: 32px 0 0; display: flex; gap: 16px; flex-wrap: wrap; }

/* ── Narrow screens: stack the purchase panel and the grid ─────────────── */

@media (max-width: 860px) {
    .st-story { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .st-story--left .st-story-image { order: 0; }
    .st-product { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .st-panel { position: static; order: -1; }
}

@media (max-width: 640px) {
    .st-header { flex-wrap: wrap; }
    .st-grid { grid-template-columns: minmax(0, 1fr); }
    .st-group--l1 { margin-left: 8px; padding-left: 10px; }
}
