/* ============================================================
   Promotions — design system
   Apple-inspired: quiet surfaces, strong typography, soft depth
   ============================================================ */

:root {
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
            "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* warm grocery palette: cream canvas, navy hero/nav, orange & red accents */
    --bg: #f7f0e3;
    --surface: #fffdf8;
    --surface-2: #fbf6ec;
    --text: #202636;
    --text-2: #6d7180;
    --text-3: #a5a8b3;
    --separator: rgba(50, 40, 20, 0.1);
    --accent: #e8590c;
    --accent-hover: #f06a1d;
    --danger: #e12d2d;
    --success: #1e9e50;
    --price: #d92d20;
    --discount-bg: #e8590c;
    --discount-fg: #ffffff;
    /* values the app calculated itself (not stated by the store) */
    --computed: #6d4fc4;
    --navy: #182957;
    --navy-2: #223a77;
    --hero-fg: #ffffff;

    --radius-s: 8px;
    --radius-m: 12px;
    --radius-l: 18px;
    --shadow-s: 0 1px 2px rgba(40, 30, 10, 0.05), 0 2px 8px rgba(40, 30, 10, 0.05);
    --shadow-m: 0 2px 6px rgba(40, 30, 10, 0.06), 0 10px 28px rgba(40, 30, 10, 0.11);
    --nav-bg: #182957;
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1322;
        --surface: #1a2337;
        --surface-2: #151d2f;
        --text: #f0f2f7;
        --text-2: #9aa3b8;
        --text-3: #667089;
        --separator: rgba(255, 255, 255, 0.12);
        --accent: #f0762b;
        --accent-hover: #ff8a3d;
        --price: #ff6b5e;
        --computed: #a68bff;
        --navy: #131f42;
        --navy-2: #1c2f63;
        --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-m: 0 2px 6px rgba(0, 0, 0, 0.5), 0 10px 28px rgba(0, 0, 0, 0.5);
        --nav-bg: #131f42;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    /* stop the page scrolling sideways on mobile */
    overflow-x: hidden;
}

/* Tame the big grey tap-flash on Android and keep taps on-brand. */
* { -webkit-tap-highlight-color: rgba(0, 0, 0, 0.06); }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
a { color: var(--accent); text-decoration: none; }

img { max-width: 100%; }

/* ---------- controls ---------- */
button, input, select {
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    border-radius: 999px;
    padding: 0.5rem 1.1rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-s);
    transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-m); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: transparent; color: var(--danger); box-shadow: none; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--accent); }

.field {
    border: 1px solid var(--separator);
    background: var(--surface);
    border-radius: var(--radius-m);
    padding: 0.55rem 0.9rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 22%, transparent);
}

select.field { cursor: pointer; }

/* segmented control */
.segmented {
    display: inline-flex;
    background: color-mix(in srgb, var(--text) 7%, transparent);
    border-radius: 10px;
    padding: 2px;
    gap: 2px;
}

.segmented button {
    border: none;
    background: transparent;
    padding: 0.35rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-2);
    transition: all 0.15s var(--ease);
}

.segmented button.on {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-s);
    font-weight: 600;
}

/* iOS-style switch */
.switch {
    position: relative;
    width: 46px;
    height: 28px;
    border-radius: 999px;
    border: none;
    background: color-mix(in srgb, var(--text) 16%, transparent);
    cursor: pointer;
    transition: background 0.2s var(--ease);
    flex: 0 0 auto;
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s var(--ease);
}

.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(18px); }

/* ---------- app shell ---------- */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--nav-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.65rem 1.25rem;
}

.app-brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--hero-fg);
}

.app-nav-links {
    display: flex;
    gap: 0.25rem;
}

.app-nav-links a {
    color: rgba(255, 255, 255, 0.72);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}

.app-nav-links a:hover { color: #fff; }

.app-nav-links a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}

.app-nav-status {
    margin-left: auto;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.55);
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 4rem;
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
    .app-nav-inner {
        gap: 0.5rem;
        padding: 0.55rem 0.85rem;
    }

    .app-brand {
        font-size: 0.95rem;
        flex-shrink: 0;
    }

    /* Links become a horizontal scroll strip so all pages stay reachable. */
    .app-nav-links {
        flex: 1;
        overflow-x: auto;
        gap: 0.15rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-mask-image: linear-gradient(to right, transparent 0, #000 8px, #000 calc(100% - 14px), transparent 100%);
                mask-image: linear-gradient(to right, transparent 0, #000 8px, #000 calc(100% - 14px), transparent 100%);
    }

    .app-nav-links::-webkit-scrollbar { display: none; }

    .app-nav-links a {
        padding: 0.3rem 0.65rem;
        white-space: nowrap;
        font-size: 0.9rem;
    }

    /* The status dot isn't useful on phones and steals width. */
    .app-nav-status { display: none; }

    .app-main {
        padding: 1rem 0.85rem 3rem;
    }
}

/* ---------- cards & misc ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-s);
    border: 1px solid var(--separator);
}

.muted { color: var(--text-2); }
.small { font-size: 0.82rem; }

/* modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fade-in 0.18s var(--ease);
}

.modal-panel {
    background: var(--surface);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-m);
    width: min(560px, calc(100vw - 2rem));
    max-height: min(80vh, 700px);
    overflow: auto;
    padding: 1.5rem;
    animation: pop-in 0.22s var(--ease);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } }

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid color-mix(in srgb, var(--text) 12%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* blazor plumbing */
#blazor-error-ui {
    color-scheme: light only;
    background: #fff7d6;
    bottom: 0;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: #1d1d1f;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: var(--radius-m);
}

#components-reconnect-modal { color-scheme: light only; }
