/* ==========================================================================
   depista — master stylesheet

   This file is the single source of style for all applications:
   - the landing app (public pages)
   - the backoffice app (staff pages)

   Load this file first. Load the app stylesheet after it.
   Do not change the design tokens in an app stylesheet.
   Read STYLEGUIDE.md for the rules.

   Contents:
   1.  Design tokens
   2.  Base
   3.  Typography
   4.  Layout
   5.  Buttons
   6.  Chips
   7.  Badges
   8.  Cards
   9.  Product cards
   10. Rail (side navigation)
   11. Top bar
   12. Forms
   13. Tables and data display
   14. Alerts
   15. Pagination
   16. Dropdowns
   17. Tooltips
   18. Modals
   19. Checkboxes, radios and switches
   20. Skeletons and spinners
   21. Utilities
   22. Responsive
   23. Animations

   The script static/js/depista.js controls the dropdowns, tooltips,
   modals and the "select all" checkboxes.
   ========================================================================== */


/* 1. Design tokens
   ========================================================================== */
:root {
    /* Color: neutrals */
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-surface-muted: #f2f2f3;
    --color-border: #e6e6e8;
    --color-border-strong: #d4d4d8;

    /* Color: text */
    --color-text: #111113;
    --color-text-muted: #5f5f66;
    --color-text-subtle: #9b9ba1;

    /* Color: ink (dark controls) */
    --color-ink: #18181b;
    --color-ink-hover: #000000;
    --color-on-ink: #ffffff;

    /* Color: brand */
    --color-brand: #5b3df5;
    --color-brand-hover: #4a2ee0;
    --color-brand-soft: rgba(91, 61, 245, 0.1);

    /* Color: logo (the blue shopping cart) */
    --color-logo: #2563eb;
    --color-logo-strong: #1d4ed8;
    --color-logo-soft: rgba(37, 99, 235, 0.1);

    /* Color: status */
    --color-sale: #e5322d;
    --color-danger: #d92d20;
    --color-danger-soft: rgba(217, 45, 32, 0.08);
    --color-success: #12a150;
    --color-success-soft: rgba(18, 161, 80, 0.08);
    --color-warning: #c27a00;
    --color-warning-soft: rgba(194, 122, 0, 0.1);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --text-xs: 0.6875rem;   /* 11px: badges */
    --text-sm: 0.8125rem;   /* 13px: product text, meta */
    --text-base: 0.9375rem; /* 15px: body, chips, buttons */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.375rem;    /* 22px: section titles */
    --text-2xl: 1.75rem;    /* 28px: page titles */
    --text-display: clamp(2.25rem, 5vw, 4rem); /* 36-64px: landing hero title */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --leading-tight: 1.25;
    --leading-normal: 1.5;

    /* Spacing (4px scale) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 999px;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(17, 17, 19, 0.04);
    --shadow-md: 0 4px 20px rgba(17, 17, 19, 0.07);
    --shadow-lg: 0 12px 32px rgba(17, 17, 19, 0.1);

    /* Control sizes */
    --control-h: 40px;
    --control-h-sm: 32px;

    /* Layout */
    --content-max: 1680px;
    --rail-w: 184px;
    --shell-gutter: calc(var(--rail-w) + var(--space-12));

    /* Motion */
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --duration: 150ms;
}


/* 2. Base
   ========================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}


/* 3. Typography
   ========================================================================== */
h1, h2, h3, h4 {
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
}
h1, .h1 { font-size: var(--text-2xl); }
h2, .h2 { font-size: var(--text-xl); }
h3, .h3 { font-size: var(--text-lg); }

.section-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-6);
}

.page-head { margin-bottom: var(--space-8); }
.page-head h1 { margin-bottom: var(--space-1); }
.page-head p { color: var(--color-text-muted); }

.eyebrow {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-subtle);
}

.link {
    color: var(--color-brand);
    font-weight: var(--weight-semibold);
}
.link:hover { text-decoration: underline; }


/* 4. Layout
   ========================================================================== */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* App shell: a logo at the top left, a rail on the left, content on the right. */
.shell { min-height: 100vh; }
.shell-logo {
    position: fixed;
    top: var(--space-8);
    left: var(--space-8);
    z-index: 60;
}
.shell-main {
    padding: var(--space-6) var(--space-12) var(--space-16) var(--shell-gutter);
}

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-between { justify-content: space-between; }

.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.section { margin-bottom: var(--space-12); }


/* 5. Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--control-h);
    padding: 0 var(--space-5);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    cursor: pointer;
    transition: background var(--duration) var(--ease),
                border-color var(--duration) var(--ease),
                color var(--duration) var(--ease);
}
.btn:disabled, .btn.is-disabled { opacity: 0.45; pointer-events: none; }

.btn-primary { background: var(--color-ink); color: var(--color-on-ink); }
.btn-primary:hover { background: var(--color-ink-hover); }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-border-strong); background: var(--color-surface-muted); }

.btn-brand { background: var(--color-brand); color: #ffffff; }
.btn-brand:hover { background: var(--color-brand-hover); }

.btn-danger { background: var(--color-danger); color: #ffffff; }
.btn-danger:hover { filter: brightness(0.92); }

.btn-ghost { color: var(--color-text); }
.btn-ghost:hover { background: var(--color-surface-muted); }

.btn-sm { height: var(--control-h-sm); padding: 0 var(--space-4); font-size: var(--text-sm); }
.btn-block { width: 100%; }

/* Round icon button. Example: the filter button before the chip bar. */
.btn-icon {
    width: var(--control-h);
    padding: 0;
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-icon.btn-sm svg { width: 16px; height: 16px; }


/* 6. Chips
   ========================================================================== */
.chip-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--control-h);
    padding: 0 var(--space-4);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    white-space: nowrap;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.chip:hover { border-color: var(--color-border-strong); background: var(--color-surface-muted); }
.chip.is-active { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-on-ink); }

/* Down arrow for chips that open a menu. */
.chip-caret::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-left: 2px;
    margin-top: -3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}


/* 7. Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: 1;
    white-space: nowrap;
    border-radius: var(--radius-pill);
    background: var(--color-surface-muted);
    color: var(--color-text);
}
.badge-sale { background: var(--color-sale); color: #ffffff; }
.badge-brand { background: var(--color-brand-soft); color: var(--color-brand); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-ink { background: var(--color-ink); color: var(--color-on-ink); }


/* 8. Cards
   ========================================================================== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.card-body { padding: var(--space-6); }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
}
.card-head h2, .card-head h3 { font-size: var(--text-base); }

/* Stat card: one number and one label. */
.stat { padding: var(--space-5) var(--space-6); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
.stat-label { font-size: var(--text-sm); color: var(--color-text-muted); }

/* Tile: a card with a full color background. Example: a featured seller. */
.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-lg);
    background: #a99b8d;
    color: #ffffff;
    box-shadow: var(--shadow-md);
}
.tile-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); letter-spacing: -0.02em; }
.tile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-surface);
    object-fit: cover;
}
.tile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    width: 100%;
}
.tile-grid > * {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.25);
    object-fit: cover;
    width: 100%;
}


/* 9. Product cards
   ========================================================================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: var(--space-6) var(--space-8);
}

.product { display: flex; flex-direction: column; min-width: 0; }

.product-media {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-muted);
}
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.product-media .badge {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
}
.product:hover .product-media { border-color: var(--color-border-strong); }

.product-info { padding: var(--space-3) var(--space-1) 0; font-size: var(--text-sm); line-height: 1.35; }
.product-seller { color: var(--color-text); }
.product-title {
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rating { display: flex; align-items: center; gap: var(--space-1); }
.rating-stars { letter-spacing: 1px; font-size: var(--text-sm); }
.rating-count { color: var(--color-text); }

.price { font-weight: var(--weight-semibold); }
.price-old {
    margin-left: var(--space-1);
    color: var(--color-text-subtle);
    font-weight: var(--weight-medium);
    text-decoration: line-through;
}


/* 10. Rail (side navigation)
   ========================================================================== */
.rail {
    position: fixed;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    width: var(--rail-w);
    padding: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.rail-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    text-align: left;
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.rail-link svg { flex: none; width: 20px; height: 20px; color: var(--color-text-subtle); }
.rail-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rail-link:hover { color: var(--color-text); background: var(--color-surface-muted); }
.rail-link:hover svg { color: var(--color-text); }
.rail-link.is-active { color: var(--color-ink); font-weight: 600; background: var(--color-surface-muted); }
.rail-link.is-active svg { color: var(--color-ink); }
.rail-sep { height: 1px; background: var(--color-border); margin: var(--space-1) var(--space-3); }

/* Logo */
.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-logo);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
}
.logo svg { width: 30px; height: 30px; }
.logo-text { color: var(--color-text); font-size: var(--text-lg); }
.logo-sub { color: var(--color-text-subtle); font-weight: var(--weight-medium); }


/* 11. Top bar
   ========================================================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 64px;
    margin-bottom: var(--space-6);
}
.topbar-user { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text-muted); font-size: var(--text-sm); }

/* Simple header for pages without the app shell. */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: 72px;
}


/* 12. Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.label { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.help { font-size: var(--text-sm); color: var(--color-text-muted); }
.error-text { font-size: var(--text-sm); color: var(--color-danger); }

.input, .select, .textarea {
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--space-4);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: var(--space-3) var(--space-4); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--color-text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--color-border-strong); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--color-ink);
    box-shadow: 0 0 0 3px rgba(17, 17, 19, 0.08);
}
.input.is-invalid { border-color: var(--color-danger); }

/* Search: a pill input. */
.search { border-radius: var(--radius-pill); padding: 0 var(--space-5); }

.select {
    appearance: none;
    padding-right: var(--space-10);
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}


/* 13. Tables and data display
   ========================================================================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: var(--space-3) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table td {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-bg); }

.empty {
    padding: var(--space-12) var(--space-6);
    text-align: center;
    color: var(--color-text-muted);
}

/* Numbers in a table column: align them at the right. */
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Monospace text (ids, handles, SKUs). */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95em; }

/* Thumbnail: a small square image (for example, in a table row). */
.thumb {
    width: 40px;
    height: 40px;
    flex: none;
    object-fit: cover;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-muted);
}
.thumb-lg { width: 96px; height: 96px; border-radius: var(--radius-md); }

/* Key-value list: <dl class="kv"><dt>Key</dt><dd>Value</dd>…</dl> */
.kv {
    display: grid;
    grid-template-columns: minmax(120px, max-content) 1fr;
    gap: var(--space-3) var(--space-6);
    font-size: var(--text-sm);
}
.kv dt { color: var(--color-text-muted); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* Code block: raw data (for example, JSON). The block scrolls. */
.code-block {
    max-height: 560px;
    overflow: auto;
    padding: var(--space-4) var(--space-5);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
    white-space: pre;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

/* Breadcrumb: the path to the current page. */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.breadcrumb a:hover { color: var(--color-text); }
.breadcrumb-sep { color: var(--color-text-subtle); }

/* Toolbar: a row of filters above a table. */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 360px; }


/* 14. Alerts
   ========================================================================== */
.alert {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    margin-bottom: var(--space-4);
}
.alert-danger { background: var(--color-danger-soft); border-color: rgba(217, 45, 32, 0.3); color: var(--color-danger); }
.alert-success { background: var(--color-success-soft); border-color: rgba(18, 161, 80, 0.3); color: var(--color-success); }
.alert-warning { background: var(--color-warning-soft); border-color: rgba(194, 122, 0, 0.3); color: var(--color-warning); }


/* 15. Pagination
   ========================================================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-6);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}


/* 16. Dropdowns
   ==========================================================================
   Markup: .dropdown[data-dropdown] > [data-dropdown-toggle] + .dropdown-menu[data-dropdown-menu]
   The script puts the menu in a fixed position. Thus a parent with
   "overflow: hidden" or "overflow: auto" does not cut the menu. */
.dropdown { position: relative; display: inline-flex; }

.dropdown-menu {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    display: none;
    min-width: 200px;
    max-width: min(360px, calc(100vw - var(--space-4)));
    max-height: min(440px, calc(100vh - var(--space-4)));
    overflow-y: auto;
    padding: var(--space-2);
    text-align: left;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}
.dropdown.is-open > .dropdown-menu { display: block; animation: depista-pop var(--duration) var(--ease); }
.dropdown-menu-wide { min-width: 300px; }
.dropdown-menu-flush { padding: 0; }

/* The toggle of an open dropdown. */
.dropdown.is-open > .chip { background: var(--color-surface-muted); border-color: var(--color-border-strong); }
.dropdown.is-open > .chip-caret::after { margin-top: 3px; transform: rotate(-135deg); }

/* A dropdown in a menu (a submenu) fills the row. */
.dropdown-menu .dropdown { display: flex; width: 100%; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    min-height: 36px;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    text-align: left;
    white-space: nowrap;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.dropdown-item:hover,
.dropdown-item:focus-visible,
.dropdown.is-open > .dropdown-item { background: var(--color-surface-muted); outline: none; }
.dropdown-item svg { width: 16px; height: 16px; flex: none; color: var(--color-text-subtle); }
.dropdown-item.is-danger, .dropdown-item.is-danger svg { color: var(--color-danger); }
.dropdown-item:disabled, .dropdown-item.is-disabled { opacity: 0.45; pointer-events: none; }

/* Single selection: the script adds .is-selected to the selected item. */
.dropdown-item.is-selected { font-weight: var(--weight-semibold); }
.dropdown-item.is-selected::after {
    content: '';
    width: 10px;
    height: 6px;
    margin-left: auto;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(-45deg);
}

/* An item that opens a submenu. */
.dropdown-item-sub::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-left: auto;
    border-top: 2px solid var(--color-text-subtle);
    border-right: 2px solid var(--color-text-subtle);
    transform: rotate(45deg);
}

.dropdown-item-meta { margin-left: auto; font-size: var(--text-xs); color: var(--color-text-subtle); }
.dropdown-label {
    padding: var(--space-2) var(--space-3) var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-subtle);
}
.dropdown-sep { height: 1px; margin: var(--space-2) calc(var(--space-2) * -1); background: var(--color-border); }
.dropdown-section { padding: var(--space-2) var(--space-3); }
.dropdown-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin: var(--space-2) calc(var(--space-2) * -1) calc(var(--space-2) * -1);
    padding: var(--space-3);
    border-top: 1px solid var(--color-border);
}


/* 17. Tooltips
   ==========================================================================
   Markup: any element with data-tooltip="Text".
   Optional: data-tooltip-placement="top|bottom|left|right" (default: top).
   The script makes one .tooltip element and puts it next to the element. */
.tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    max-width: 260px;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: 1.35;
    color: var(--color-on-ink);
    background: var(--color-ink);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}
.tooltip.is-visible { opacity: 1; }


/* 18. Modals
   ==========================================================================
   Markup: <dialog class="modal"> > .modal-head + .modal-body + .modal-foot */
.modal {
    width: min(560px, calc(100vw - var(--space-8)));
    max-width: none;
    max-height: calc(100vh - var(--space-16));
    margin: auto;
    padding: 0;
    overflow: hidden;
    color: var(--color-text);
    background: var(--color-surface);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal[open] { display: flex; flex-direction: column; animation: depista-modal 180ms var(--ease); }
.modal::backdrop { background: rgba(17, 17, 19, 0.4); backdrop-filter: blur(2px); animation: depista-fade 180ms var(--ease); }
.modal > form { display: contents; }
.modal-sm { width: min(420px, calc(100vw - var(--space-8))); }
.modal-lg { width: min(820px, calc(100vw - var(--space-8))); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6) 0;
}
.modal-head h2 { font-size: var(--text-lg); }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--space-6); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6) var(--space-5); }
.modal-foot-split { justify-content: space-between; }

/* The page does not scroll when a modal is open. */
html:has(.modal[open]) { overflow: hidden; }


/* 19. Checkboxes, radios and switches
   ========================================================================== */
.checkbox, .radio, .switch {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    margin: 0;
    cursor: pointer;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.checkbox, .radio {
    display: inline-grid;
    place-content: center;
    width: 18px;
    height: 18px;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border-strong);
    border-radius: 5px;
}
.radio { border-radius: 50%; }
.checkbox:hover, .radio:hover { border-color: var(--color-text-subtle); }

.checkbox::before, .radio::before {
    content: '';
    background: var(--color-on-ink);
    transform: scale(0);
    transition: transform var(--duration) var(--ease);
}
.checkbox::before {
    width: 10px;
    height: 10px;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.radio::before { width: 8px; height: 8px; border-radius: 50%; }

.checkbox:checked, .checkbox:indeterminate, .radio:checked { background: var(--color-ink); border-color: var(--color-ink); }
.checkbox:checked::before, .radio:checked::before { transform: scale(1); }
.checkbox:indeterminate::before { clip-path: inset(40% 0 40% 0 round 1px); transform: scale(1); }
.checkbox.is-invalid, .radio.is-invalid { border-color: var(--color-danger); }

.switch {
    position: relative;
    width: 34px;
    height: 20px;
    background: var(--color-border-strong);
    border-radius: var(--radius-pill);
}
.switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--color-surface);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration) var(--ease);
}
.switch:checked { background: var(--color-ink); }
.switch:checked::before { transform: translateX(14px); }

.checkbox:disabled, .radio:disabled, .switch:disabled { opacity: 0.45; cursor: not-allowed; }

/* A label with a control and a text. */
.check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-base);
    cursor: pointer;
    user-select: none;
}
.check:has(input:disabled) { color: var(--color-text-subtle); cursor: not-allowed; }
.check-block { display: flex; align-items: flex-start; }
.check-block > input { margin-top: 2px; }
.check-title { display: block; font-weight: var(--weight-medium); }
.check-desc { display: block; font-size: var(--text-sm); color: var(--color-text-muted); }
.check-group { display: flex; flex-direction: column; gap: var(--space-3); }


/* 20. Skeletons and spinners
   ========================================================================== */
.skeleton {
    position: relative;
    display: block;
    overflow: hidden;
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    transform: translateX(-100%);
    animation: depista-shimmer 1.4s ease-in-out infinite;
}
.skeleton-text { height: 0.75em; margin: 0.45em 0; border-radius: var(--radius-pill); }
.skeleton-title { width: 50%; height: 1.1em; margin-bottom: 0.6em; border-radius: var(--radius-pill); }
.skeleton-circle { width: 40px; height: 40px; flex: none; border-radius: 50%; }
.skeleton-media { aspect-ratio: 1; border-radius: var(--radius-lg); }
.skeleton-btn { width: 120px; height: var(--control-h); border-radius: var(--radius-pill); }
.skeleton-w-25 { width: 25%; }
.skeleton-w-40 { width: 40%; }
.skeleton-w-60 { width: 60%; }
.skeleton-w-80 { width: 80%; }

/* Show a skeleton while htmx loads the content.
   Markup: .skeleton-swap > .skeleton-swap-placeholder + .skeleton-swap-content
   Set hx-indicator to the .skeleton-swap element or to a parent element. */
.skeleton-swap > .skeleton-swap-placeholder { display: none; }
.skeleton-swap.htmx-request > .skeleton-swap-placeholder,
.htmx-request .skeleton-swap > .skeleton-swap-placeholder { display: block; }
.skeleton-swap.htmx-request > .skeleton-swap-content,
.htmx-request .skeleton-swap > .skeleton-swap-content { display: none; }

/* Before the first response, the content is empty. Show the skeleton. */
.skeleton-swap > .skeleton-swap-content:empty { display: none; }
.skeleton-swap:has(> .skeleton-swap-content:empty) > .skeleton-swap-placeholder { display: block; }

/* A skeleton product card. */
.skeleton-product .skeleton-media { margin-bottom: var(--space-3); }

.spinner {
    display: inline-block;
    flex: none;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: depista-spin 0.7s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

/* A spinner in a button shows only while htmx sends a request. */
.btn .htmx-indicator { display: none; }
.btn.htmx-request .htmx-indicator,
.htmx-request .btn .htmx-indicator { display: inline-block; }


/* 21. Utilities
   ========================================================================== */
.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-sm { font-size: var(--text-sm); }
.text-bold { font-weight: var(--weight-bold); }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: var(--space-4); }
.mb-0 { margin-bottom: 0; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}


/* 22. Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    :root { --shell-gutter: var(--space-4); }

    .shell-logo { position: static; padding: var(--space-4) var(--space-4) 0; }
    .shell-main { padding: var(--space-4) var(--space-4) 96px; }

    /* The rail moves to the bottom of the screen. */
    .rail {
        top: auto;
        bottom: var(--space-3);
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        align-items: center;
        width: auto;
        padding: 0 var(--space-3);
        height: 56px;
        border-radius: var(--radius-pill);
    }
    /* On small screens, the rail shows only the icons. The label stays for screen readers. */
    .rail-link { justify-content: center; width: 40px; padding: 0; }
    .rail-link svg { width: 22px; height: 22px; }
    .rail-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .rail-sep { width: 1px; height: 24px; margin: 0 var(--space-1); }

    .chip-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .chip-bar::-webkit-scrollbar { display: none; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-3); }
    h1, .h1 { font-size: var(--text-xl); }

    /* The modal is a sheet at the bottom of the screen. */
    .modal, .modal-sm, .modal-lg {
        width: 100vw;
        max-height: calc(100vh - var(--space-10));
        margin: auto 0 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}


/* 23. Animations
   ========================================================================== */
/* Opacity only: a transform on a menu breaks the fixed position of a submenu. */
@keyframes depista-pop { from { opacity: 0; } }
@keyframes depista-modal { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes depista-fade { from { opacity: 0; } }
@keyframes depista-spin { to { transform: rotate(360deg); } }
@keyframes depista-shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
    .dropdown.is-open > .dropdown-menu,
    .modal[open],
    .modal::backdrop { animation: none; }
    .skeleton::after { animation: none; }
}
