/* ============================================================================
   Voriq Agro — components
   Page-agnostic. Nothing here may reference a page-level class; pages adjust a
   component through a modifier declared here, or by overriding a token on a
   region (e.g. `.footer { --border: var(--border-on-dark) }`).
   ========================================================================= */

/* ---------- buttons ------------------------------------------------------ */
.btn {
    --btn-h: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--btn-h);
    padding: 0 var(--s-5);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    background: var(--olive-600);
    color: var(--ink-on-dark);
    font: 600 16px/1 var(--font-sans);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { background: var(--olive-700); color: var(--ink-on-dark); }
.btn:active { background: var(--olive-800); transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

.btn--ghost {
    background: transparent;
    color: var(--ink-1);
    border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--olive-50); border-color: var(--ink-1); color: var(--ink-1); }

.btn--quiet {
    background: transparent;
    color: var(--olive-600);
    border-color: transparent;
    padding-inline: var(--s-2);
}
.btn--quiet:hover { background: transparent; color: var(--olive-700); text-decoration: underline; text-underline-offset: 4px; }

/* Emphasis. At most one per page — "Place order" earns it, nothing else does. */
.btn--accent { background: var(--terracotta-600); }
.btn--accent:hover { background: var(--terracotta-700); }
.btn--accent:active { background: var(--terracotta-800); }

.btn--danger { background: var(--danger); }
.btn--dark { background: var(--ink-1); }
.btn--dark:hover { background: #000; }

/* On the ink band the solid olive disappears, so it becomes an outline. */
.btn--onink {
    background: transparent;
    color: var(--ink-on-dark);
    border-color: var(--border-on-dark);
}
.btn--onink:hover { background: rgba(240, 234, 221, .1); color: var(--ink-on-dark); }

.btn--sm { --btn-h: 36px; padding-inline: var(--s-4); font-size: 14px; }
.btn--lg { --btn-h: 52px; padding-inline: var(--s-6); font-size: 16px; }
.btn--block { display: flex; width: 100%; }

/* Busy state: a bar crossing the bottom edge, not a spinner. */
.btn.is-busy { position: relative; overflow: hidden; pointer-events: none; }
.btn.is-busy::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    height: 2px; width: 40%;
    background: currentColor;
    opacity: .7;
    animation: btn-sweep 900ms var(--ease-inout) infinite;
}
@keyframes btn-sweep { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-1);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-sunken); }

/* ---------- form fields ---------------------------------------------------- */
.field { margin-bottom: var(--s-5); min-width: 0; }
.field__label {
    display: block;
    font: 600 13px/1.4 var(--font-sans);
    color: var(--ink-2);
    margin-bottom: var(--s-1);
}
.field__label .req { color: var(--terracotta-600); }

.field__input,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
    width: 100%;
    min-height: 48px;
    padding: var(--s-2) var(--s-4);
    background: var(--surface-raised);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 16px;
    color: var(--ink-1);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field select {
    appearance: none;
    padding-right: var(--s-7);
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
    background-position: calc(100% - 21px) 50%, calc(100% - 16px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--olive-600);
    box-shadow: 0 0 0 3px var(--olive-50);
    outline: none;
}
.field textarea { padding: var(--s-3) var(--s-4); min-height: 104px; }

.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--danger); }
.field__error, .error {
    display: block;
    font-size: 13px;
    color: var(--danger);
    margin-top: var(--s-1);
}
.field__error::before, .error::before { content: '! '; font-weight: 700; }
/* Server-rendered error slots are always present and usually empty; an empty one
   must not leave its marker behind. */
.field__error:empty, .error:empty { display: none; }
.field__hint, .hint {
    display: block;
    font-size: 13px;
    color: var(--ink-muted);
    margin-top: var(--s-1);
}

.field--check { display: flex; align-items: flex-start; gap: var(--s-3); min-height: 44px; }
input[type="checkbox"], input[type="radio"] {
    width: 18px; height: 18px;
    accent-color: var(--olive-600);
    flex: none;
    margin-top: 3px;
}

/* ---------- badges and tags ---------------------------------------------- */
.tag, .pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    padding: 3px 8px;
    border-radius: var(--r-xs);
    background: var(--surface-sunken-2);
    color: var(--ink-2);
    font: 700 11.5px/1.4 var(--font-sans);
}
.tag--olive { background: var(--olive-100); color: var(--olive-800); }
.tag--terracotta { background: var(--terracotta-100); color: var(--terracotta-800); }
.tag--out { background: var(--surface-sunken-2); color: var(--ink-muted); }
/* Order status: the square carries the state as shape, so colour is never alone. */
.tag--status::before {
    content: '';
    width: 6px; height: 6px;
    background: currentColor;
}

/* The FSSAI-style veg / non-veg mark. */
.foodmark {
    display: inline-block;
    width: 13px; height: 13px;
    margin-right: var(--s-2);
    border: 1.5px solid var(--success);
    position: relative;
    vertical-align: -1px;
}
.foodmark::after {
    content: '';
    position: absolute;
    inset: 2.5px;
    border-radius: 50%;
    background: var(--success);
}
.foodmark--non-veg { border-color: #7A3B12; }
.foodmark--non-veg::after { background: #7A3B12; }

/* ---------- star rating --------------------------------------------------- */
.stars { display: inline-flex; gap: 2px; color: var(--terracotta-600); }
.stars svg { width: 16px; height: 16px; }

/* ---------- quantity stepper ---------------------------------------------- */
.qty {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-raised);
    overflow: hidden;
}
.qty button {
    width: 40px;
    border: 0;
    background: transparent;
    color: var(--ink-1);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.qty button:hover { background: var(--surface-sunken); }
.qty button[disabled] { opacity: .35; cursor: not-allowed; }
.qty input {
    width: 48px;
    min-height: 42px;
    border: 0;
    border-inline: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ---------- filter chips --------------------------------------------------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 34px;
    padding: 0 var(--s-3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-1);
    font: 600 14px/1 var(--font-sans);
    text-decoration: none;
}
.chip:hover { background: var(--surface-sunken); color: var(--ink-1); }
.chip--on { background: var(--olive-600); border-color: var(--olive-600); color: var(--ink-on-dark); }
.chip--on:hover { background: var(--olive-700); color: var(--ink-on-dark); }
.chip__x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    margin-right: -10px;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
}

/* ---------- segmented control (shop sort) ---------------------------------- */
.segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.segmented a, .segmented button {
    padding: 0 var(--s-4);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    border: 0;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--ink-2);
    font: 500 14px/1 var(--font-sans);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.segmented > :first-child { border-left: 0; }
.segmented a:hover { background: var(--surface-sunken); color: var(--ink-1); }
.segmented [aria-current="true"], .segmented .is-on {
    background: var(--olive-600);
    color: var(--ink-on-dark);
    font-weight: 600;
}

/* ---------- pagination ----------------------------------------------------- */
.pagination, .pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    margin: var(--s-7) 0 0;
    padding: 0;
    list-style: none;
}
.pagination a, .pagination span, .pager a, .pager span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 var(--s-3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--ink-1);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}
.pagination a:hover, .pager a:hover { background: var(--surface-sunken); }
.pagination [aria-current], .pager [aria-current] {
    background: var(--ink-1);
    border-color: var(--ink-1);
    color: var(--surface-page);
    font-weight: 600;
}
.pagination .disabled, .pager .disabled { opacity: .4; }

/* ---------- alerts --------------------------------------------------------- */
.alert, .notice {
    border-left: 4px solid var(--ink-muted);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--surface-sunken);
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-5);
    font-size: var(--fs-small);
}
.alert ul { margin: var(--s-2) 0 0; }
.alert--success { border-left-color: var(--success); background: var(--success-bg); }
.alert--warning { border-left-color: var(--warning); background: var(--warning-bg); }
.alert--error   { border-left-color: var(--danger);  background: var(--danger-bg); }
.alert--info    { border-left-color: var(--info);    background: var(--info-bg); }

/* ---------- panels --------------------------------------------------------- */
.panel {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    padding: var(--s-5);
    margin-bottom: var(--s-5);
}
.panel--sunken { background: var(--surface-sunken); border-color: transparent; }
.panel--bare { background: transparent; border: 0; border-top: 1px solid var(--border-subtle); border-radius: 0; padding-inline: 0; }

/* ---------- dropdown ------------------------------------------------------- */
.dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 60;
    min-width: 220px;
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    box-shadow: var(--e-2);
    padding: var(--s-2);
}
.dropdown a, .dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--s-2) var(--s-3);
    border: 0;
    background: none;
    color: var(--ink-1);
    text-decoration: none;
    font-size: var(--fs-small);
    border-radius: var(--r-sm);
    cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-sunken); }
.dropdown__head {
    padding: var(--s-2) var(--s-3);
    margin: 0 0 var(--s-1);
    font-weight: 600;
    border-bottom: 1px solid var(--border-subtle);
}

/* ---------- dialog: centred on desktop, a sheet on phones ------------------ */
dialog {
    border: 0;
    border-radius: var(--r-md);
    background: var(--surface-raised);
    color: var(--ink-1);
    box-shadow: var(--e-3);
    padding: var(--s-6);
    max-width: 520px;
    width: calc(100% - 2 * var(--gutter));
}
dialog::backdrop { background: rgba(35, 39, 31, .5); }
@media (max-width: 700px) {
    dialog {
        margin: auto auto 0;
        width: 100%;
        max-width: none;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
    }
}

/* ---------- tables that become blocks on phones ---------------------------- */
.table { width: 100%; font-size: var(--fs-small); }
.table th {
    text-align: left;
    font: 700 11.5px/1.4 var(--font-sans);
    color: var(--ink-muted);
    padding: var(--s-3) var(--s-3) var(--s-2);
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: var(--s-3);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}
.table td.u-tnum, .table th.u-tnum { text-align: right; font-variant-numeric: tabular-nums; }
.table__thumb { width: 44px; height: 44px; object-fit: contain; background: var(--surface-sunken); border-radius: var(--r-sm); }

@media (max-width: 700px) {
    /* Rows become ruled blocks on cream — no bordered cards, no radius. */
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table thead { display: none; }
    .table tr {
        border-top: 1px solid var(--border);
        padding: var(--s-3) 0;
    }
    .table td {
        display: grid;
        grid-template-columns: minmax(0, 8em) minmax(0, 1fr);
        gap: var(--s-3);
        border: 0;
        padding: var(--s-1) 0;
    }
    .table td::before {
        content: attr(data-label);
        font: 700 11.5px/1.6 var(--font-sans);
        color: var(--ink-muted);
    }
    .table td.u-tnum { text-align: left; }
}

/* ---------- breadcrumbs ----------------------------------------------------- */
.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-caption);
    color: var(--ink-muted);
    margin-bottom: var(--s-4);
}
.crumbs a { color: var(--ink-muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink-1); text-decoration: underline; }
.crumbs__sep { color: var(--border-strong); }
.crumbs [aria-current="page"] { color: var(--ink-1); }
@media (max-width: 480px) {
    /* Middle levels are noise at 320px; only the way back matters. */
    .crumbs > *:not(.crumbs__back) { display: none; }
    .crumbs__back { display: inline; }
}

/* ---------- empty states ------------------------------------------------------ */
.empty, .blank {
    max-width: 44ch;
    margin: 0 auto;
    padding: var(--s-8) var(--s-4);
    text-align: center;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
.empty svg, .blank svg { width: 88px; height: 88px; margin: 0 auto var(--s-4); color: var(--olive-400); }
.empty h2, .blank h2 { font-size: var(--fs-h3); }

/* ---------- skeletons ----------------------------------------------------------- */
.skel {
    background: var(--surface-sunken);
    border-radius: var(--r-sm);
    position: relative;
    overflow: hidden;
}
.skel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 253, 249, .6), transparent);
    animation: skel 1.6s var(--ease-inout) infinite;
}
@keyframes skel { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skel--shot { aspect-ratio: 5 / 4; }
.skel--line { height: 1em; margin-bottom: var(--s-2); }

/* ---------- toast ------------------------------------------------------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 120;
    background: var(--surface-ink);
    color: var(--ink-on-dark);
    padding: var(--s-3) var(--s-5);
    border-radius: var(--r-sm);
    box-shadow: var(--e-3);
    font-size: var(--fs-small);
}

/* ---------- price ------------------------------------------------------------- */
.price { font-variant-numeric: tabular-nums; font-weight: 700; font-variation-settings: 'wdth' var(--wdth-chit); color: var(--ink-1); }
.price .rupee { font-size: .78em; font-weight: 500; margin-right: 1px; }
.price__was { color: var(--ink-muted); font-weight: 400; font-size: .8em; margin-right: var(--s-2); }
.price__save { color: var(--terracotta-600); font-weight: 600; font-size: .8em; }
