/**
 * FlowMenu Storefront — shared styles for customer-facing surfaces.
 *
 * This file is loaded on all storefront pages (cart, customer portal, order
 * modify, ambassador frontend, fulfillment picker, etc.) and provides a
 * unified design language while letting each operator brand the experience
 * with their own colors.
 *
 * TOKEN ARCHITECTURE:
 *
 *   1. Operator-tunable tokens are set via inline <style> injection at
 *      runtime by FlowMenu_Storefront_UI::inject_tokens(). They include:
 *      --fm-store-primary, --fm-store-secondary
 *
 *   2. Derived variants (primary-2 hover, primary-tint background) are
 *      computed via color-mix() so the operator only sets ONE color and
 *      all variants follow.
 *
 *   3. Fixed system tokens (canvas, ink, rule, status colors, radii, etc.)
 *      are defined in this file under :root and are the same across all
 *      operators.
 *
 * NAMING: All tokens prefixed --fm-store-* and all component classes
 * prefixed .fm-store-* to keep clear separation from the admin .fm-*
 * tokens/classes (admin tokens use a fixed brand palette; storefront
 * tokens are operator-tunable).
 */

/* =====================================================================
   TOKENS
   ===================================================================== */

:root {
    /* === Operator-tunable (defaults; overridden by inline injection) === */
    --fm-store-primary: #1f3a2e;
    --fm-store-secondary: #c8552c;

    /* === Derived variants (computed from operator primary/secondary) === */
    --fm-store-primary-2:    color-mix(in srgb, var(--fm-store-primary) 86%, black);
    --fm-store-primary-tint: color-mix(in srgb, var(--fm-store-primary) 12%, white);
    --fm-store-primary-soft: color-mix(in srgb, var(--fm-store-primary) 25%, white);

    --fm-store-secondary-2:    color-mix(in srgb, var(--fm-store-secondary) 86%, black);
    --fm-store-secondary-tint: color-mix(in srgb, var(--fm-store-secondary) 14%, white);

    /* === Fixed surface palette === */
    --fm-store-canvas:    #ffffff;
    --fm-store-canvas-2:  #fafafa;
    --fm-store-paper:     #ffffff;
    --fm-store-paper-2:   #f6f6f6;

    /* === Ink (text) === */
    --fm-store-ink:       #111111;
    --fm-store-ink-soft:  #333333;
    --fm-store-ink-mute:  #6b7280;

    /* === Rules (borders, dividers) === */
    --fm-store-rule:      #d1d5db;
    --fm-store-rule-soft: #e5e7eb;

    /* === Status colors === */
    --fm-store-success:      #10b981;
    --fm-store-success-tint: #d1fae5;
    --fm-store-success-ink:  #065f46;
    --fm-store-warn:         #f59e0b;
    --fm-store-warn-tint:    #fef3c7;
    --fm-store-warn-ink:     #92400e;
    --fm-store-danger:       #dc2626;
    --fm-store-danger-tint:  #fee2e2;
    --fm-store-danger-ink:   #991b1b;
    --fm-store-info:         #2563eb;
    --fm-store-info-tint:    #eff6ff;

    /* === Radii === */
    --fm-store-r-sm:   8px;
    --fm-store-r:      10px;
    --fm-store-r-lg:   14px;
    --fm-store-r-pill: 999px;

    /* === Shadows === */
    --fm-store-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --fm-store-shadow:    0 2px 8px rgba(0,0,0,0.08);
    --fm-store-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* === Motion === */
    --fm-store-d-1: 90ms;
    --fm-store-d-2: 150ms;
    --fm-store-d-3: 220ms;
    --fm-store-ease: cubic-bezier(0.2, 0, 0, 1);

    /* === Spacing === */
    --fm-store-s-1: 4px;
    --fm-store-s-2: 8px;
    --fm-store-s-3: 12px;
    --fm-store-s-4: 16px;
    --fm-store-s-5: 24px;
    --fm-store-s-6: 32px;

    /* === Fonts (storefront uses system font; not Fraunces — that's admin) === */
    --fm-store-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --fm-store-font-mono: "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* =====================================================================
   BUTTONS
   ===================================================================== */

.fm-store-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--fm-store-r-sm);
    font-family: var(--fm-store-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: all var(--fm-store-d-2) var(--fm-store-ease);
    text-decoration: none;
}

.fm-store-btn--primary {
    background: var(--fm-store-primary);
    color: #fff;
}

.fm-store-btn--primary:hover {
    background: var(--fm-store-primary-2);
}

.fm-store-btn--primary:disabled {
    background: var(--fm-store-rule);
    cursor: not-allowed;
}

.fm-store-btn--secondary {
    background: var(--fm-store-canvas);
    color: var(--fm-store-ink);
    border-color: var(--fm-store-rule);
}

.fm-store-btn--secondary:hover {
    background: var(--fm-store-canvas-2);
    border-color: var(--fm-store-primary);
    color: var(--fm-store-primary);
}

.fm-store-btn--ghost {
    background: transparent;
    color: var(--fm-store-ink-soft);
    border-color: transparent;
}

.fm-store-btn--ghost:hover {
    background: var(--fm-store-canvas-2);
    color: var(--fm-store-ink);
}

.fm-store-btn--block {
    width: 100%;
}

.fm-store-btn--lg {
    padding: 14px 22px;
    font-size: 15px;
}

/* =====================================================================
   INPUTS / FORMS
   ===================================================================== */

.fm-store-input,
.fm-store-select,
.fm-store-textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--fm-store-rule);
    border-radius: var(--fm-store-r-sm);
    font-family: var(--fm-store-font);
    font-size: 14px;
    color: var(--fm-store-ink);
    background: var(--fm-store-paper);
    box-sizing: border-box;
    transition: border-color var(--fm-store-d-2) var(--fm-store-ease),
                box-shadow var(--fm-store-d-2) var(--fm-store-ease);
}

.fm-store-input:focus,
.fm-store-select:focus,
.fm-store-textarea:focus {
    outline: none;
    border-color: var(--fm-store-primary);
    box-shadow: 0 0 0 3px var(--fm-store-primary-tint);
}

.fm-store-textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.fm-store-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--fm-store-ink);
    margin-bottom: 4px;
}

/* =====================================================================
   CARDS
   ===================================================================== */

.fm-store-card {
    background: var(--fm-store-paper);
    border: 1px solid var(--fm-store-rule-soft);
    border-radius: var(--fm-store-r);
    padding: var(--fm-store-s-4);
    box-shadow: var(--fm-store-shadow-sm);
}

/* =====================================================================
   PILLS / BADGES
   ===================================================================== */

.fm-store-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--fm-store-r-pill);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    background: var(--fm-store-canvas-2);
    color: var(--fm-store-ink-soft);
    border: 1px solid var(--fm-store-rule-soft);
}

.fm-store-pill--success { background: var(--fm-store-success-tint); color: var(--fm-store-success-ink); border-color: transparent; }
.fm-store-pill--warn    { background: var(--fm-store-warn-tint);    color: var(--fm-store-warn-ink);    border-color: transparent; }
.fm-store-pill--danger  { background: var(--fm-store-danger-tint);  color: var(--fm-store-danger-ink);  border-color: transparent; }
.fm-store-pill--info    { background: var(--fm-store-info-tint);    color: var(--fm-store-info);        border-color: transparent; }
.fm-store-pill--brand   { background: var(--fm-store-primary-tint); color: var(--fm-store-primary-2);   border-color: transparent; }

/* =====================================================================
   MODAL
   ===================================================================== */

.fm-store-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.fm-store-modal.is-open {
    display: flex;
    animation: fmStoreModalFade var(--fm-store-d-2) var(--fm-store-ease);
}

.fm-store-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 17, 0.55);
}

.fm-store-modal__dialog {
    position: relative;
    background: var(--fm-store-paper);
    border-radius: var(--fm-store-r-lg);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: var(--fm-store-shadow-lg);
    animation: fmStoreModalLift var(--fm-store-d-3) var(--fm-store-ease);
}

.fm-store-modal__dialog--md { max-width: 560px; }
.fm-store-modal__dialog--lg { max-width: 720px; }

.fm-store-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
}

.fm-store-modal__title {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    color: var(--fm-store-ink);
    line-height: 1.2;
}

.fm-store-modal__close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--fm-store-ink-mute);
    padding: 4px;
    border-radius: var(--fm-store-r-sm);
    transition: all var(--fm-store-d-2) var(--fm-store-ease);
}

.fm-store-modal__close:hover {
    background: var(--fm-store-canvas-2);
    color: var(--fm-store-ink);
}

.fm-store-modal__body {
    padding: 16px 24px 0;
}

.fm-store-modal__footer {
    padding: 16px 24px 20px;
    margin-top: 16px;
}

/* On phones, slide modals up from the bottom (sheet style) */
@media (max-width: 480px) {
    .fm-store-modal__dialog {
        border-radius: var(--fm-store-r-lg) var(--fm-store-r-lg) 0 0;
        position: fixed;
        bottom: 0;
        max-height: 88vh;
        width: 100%;
        animation: fmStoreModalSheet var(--fm-store-d-3) var(--fm-store-ease);
    }
}

@keyframes fmStoreModalFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fmStoreModalLift {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fmStoreModalSheet {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

body.fm-store-modal-open {
    overflow: hidden;
}

/* =====================================================================
   EMPTY STATE
   ===================================================================== */

.fm-store-empty {
    text-align: center;
    padding: 48px 24px;
}

.fm-store-empty__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--fm-store-ink-mute);
    opacity: 0.6;
}

.fm-store-empty__icon svg { width: 100%; height: 100%; }

.fm-store-empty__title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--fm-store-ink);
}

.fm-store-empty__body {
    margin: 0 auto 16px;
    max-width: 340px;
    color: var(--fm-store-ink-mute);
    font-size: 14px;
    line-height: 1.5;
}

/* =====================================================================
   UTILITIES
   ===================================================================== */

.fm-store-eyebrow {
    display: inline-block;
    font-family: var(--fm-store-font-mono);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fm-store-ink-mute);
}

.fm-store-num {
    font-family: var(--fm-store-font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--fm-store-ink);
}

.fm-store-divider {
    height: 1px;
    background: var(--fm-store-rule-soft);
    margin: var(--fm-store-s-4) 0;
    border: 0;
}
