/* Kaser web — hand-written CSS. Brand teal mirrored from apps/mobile/constants/theme.ts.
   Visual system: a deep-teal "price board" band (header + page heroes, echoing the exchange-rate
   boards Syrians read daily) over a light body, and notched price-tag chips for every per-unit
   price — the cheapest store gets the solid green tag. All decoration is CSS-only: no images,
   no extra fonts, so the payload stays friendly to poor connections. */

/* ---- Fonts: IBM Plex Sans Arabic, self-hosted ---- */
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-arabic-400.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-arabic-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-arabic-600.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    src: url('/fonts/ibm-plex-sans-arabic-700.woff2') format('woff2');
}

/* ---- Theme tokens ---- */
:root {
    --bg: #eef3f3;
    --surface: #ffffff;
    --card: #ffffff;
    --border: #dce7e7;

    /* The board: deep teal derived from the brand primary. */
    --band: #0a3f45;
    --band-line: #14525b;
    --band-text: #f2f8f8;
    --band-muted: #a8c9ca;
    --strike: #f4a53d;

    --primary: #0b7a82;
    --primary-strong: #085e65;
    --primary-bg: #dff1f3;
    --text: #10262b;
    --muted: #4f6b70;
    --muted-bg: #e7eeee;
    --win: #0e8a5a;
    --win-bg: #e5f6ec;
    --win-tint: #f2faf6;
    --red: #c0233d;
    --red-bg: #fbeaed;
    --amber: #b45309;
    --amber-bg: #fef3c7;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(10, 63, 69, 0.06);
    --shadow-md: 0 4px 14px rgba(10, 63, 69, 0.08);

    --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
    --shell-max: 640px;
    --main-pad-top: 20px;
    --tab-bar-h: 62px;
}

/* ---- Reset-ish ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    padding: 0;
}
body {
    font-family: var(--font);
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    /* Full-bleed bands use 50vw margins; clip the scrollbar-width overflow they cause. */
    overflow-x: hidden;
}
a {
    color: var(--primary);
    text-decoration: none;
}
button {
    font-family: inherit;
}
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.app-header :focus-visible,
.page-band :focus-visible {
    outline-color: var(--band-text);
}

/* ---- App header: the board starts here ---- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--band);
}
.app-header__inner,
.app-main {
    max-width: var(--shell-max);
    margin-inline: auto;
    padding-inline: 16px;
}
.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 56px;
}
.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--band-text);
    white-space: nowrap;
}
/* «الأسعار» struck through — the crossed-out-old-price mark discount shops paint on banners. */
.brand__break {
    position: relative;
    display: inline-block;
}
.brand__break::after {
    content: '';
    position: absolute;
    inset-inline: -3px;
    top: 50%;
    height: 2px;
    border-radius: 2px;
    background: var(--strike);
    transform: rotate(-5deg);
    pointer-events: none;
}
.app-nav {
    display: flex;
    gap: 4px;
}
.app-nav a {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    color: var(--band-muted);
    font-weight: 500;
    font-size: 0.95rem;
}
.app-nav a.is-active,
.app-nav a:hover {
    background: var(--band-line);
    color: var(--band-text);
}
.app-main {
    padding-block: var(--main-pad-top) 40px;
}

/* ---- Bottom tab bar (mobile) ---- */
.tab-bar {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 10;
    display: none;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: var(--tab-bar-h);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
}
.tab__icon {
    width: 22px;
    height: 22px;
}
.tab.is-active {
    color: var(--primary-strong);
    font-weight: 600;
}
.tab__icon--add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-top: -6px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.tab__icon--add svg {
    width: 16px;
    height: 16px;
}
@media (max-width: 719px) {
    .app-nav {
        display: none;
    }
    .tab-bar {
        display: flex;
    }
    body {
        padding-bottom: calc(var(--tab-bar-h) + env(safe-area-inset-bottom));
    }
}

/* ---- Page band: full-bleed board section (home hero, search, product identity) ---- */
.page-band {
    background: var(--band);
    /* Faint awning stripes — market-stall texture, zero payload. */
    background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 16px);
    color: var(--band-text);
    margin: calc(-1 * var(--main-pad-top)) calc(50% - 50vw) 20px;
}
.page-band__inner {
    max-width: var(--shell-max);
    margin-inline: auto;
    padding: 24px 16px 28px;
}
.band-eyebrow {
    margin: 0 0 2px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--band-muted);
}
.band-title {
    margin: 0;
    font-size: clamp(1.5rem, 6vw, 1.9rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--band-text);
}
.band-sub {
    margin: 6px 0 0;
    font-size: 0.95rem;
    color: var(--band-muted);
    line-height: 1.7;
}
.band-search {
    margin-top: 16px;
}
.input--band {
    border: none;
    padding: 14px 16px;
    font-size: 1.05rem;
    box-shadow: var(--shadow-md);
}
.search-results-slot:not(:empty) {
    margin-bottom: 24px;
}

/* ---- Cards & primitives ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 4px;
}
.page-subtitle {
    color: var(--muted);
    margin: 0 0 20px;
}
.muted {
    color: var(--muted);
}
.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    margin: 26px 0 12px;
}
.section-title::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--primary);
    flex: none;
}
.list-hint {
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
}

/* ---- Forms ---- */
.field {
    margin-bottom: 14px;
}
.field label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
}
.input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font: inherit;
    color: var(--text);
}
.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.btn:hover {
    background: var(--primary-strong);
}
.btn:active {
    transform: translateY(1px);
}
.btn--block {
    width: 100%;
}
.btn--ghost {
    background: var(--muted-bg);
    color: var(--text);
    box-shadow: none;
}
.btn--ghost:hover {
    background: var(--border);
}
.btn--sm {
    padding: 7px 12px;
    font-size: 0.9rem;
}
.link-btn {
    border: none;
    background: none;
    padding: 4px 0;
    color: var(--muted);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}
.link-btn:hover {
    color: var(--primary);
}
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 14px;
    font-size: 0.95rem;
    cursor: pointer;
}

/* ---- The price tag: notched market-tag chip with a punched hole (signature element).
        Points toward the inline-end (physical left in RTL), where it hangs off the row. ---- */
.tag {
    --notch: 10px;
    --tag-hole: var(--card);
    position: relative;
    display: inline-block;
    padding-block: 3px;
    padding-inline: 12px 18px;
    font-weight: 700;
    font-size: 1.02rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--primary-strong);
    background: var(--primary-bg);
    border-radius: 0 8px 8px 0;
    clip-path: polygon(var(--notch) 0, 100% 0, 100% 100%, var(--notch) 100%, 0 50%);
}
.tag::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--tag-hole);
    transform: translateY(-50%);
}
.tag--win {
    color: #fff;
    background: var(--win);
}
.tag--sm {
    font-size: 0.9rem;
    padding-block: 2px;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
}
.badge--cheapest {
    background: var(--win-bg);
    color: var(--win);
}
.badge--offer {
    background: var(--amber-bg);
    color: var(--amber);
}

/* ---- States ---- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    margin-bottom: 14px;
}
.alert--error {
    background: var(--red-bg);
    color: var(--red);
}
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 16px;
    border-style: dashed;
    background: transparent;
}

/* ---- Search box (search page fallback) ---- */
.search-box {
    margin-bottom: 8px;
}
.search-box .input {
    font-size: 1.05rem;
}

/* ---- Product cards (home popular, search results) ---- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.product-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.product-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}
.product-card__name {
    font-weight: 600;
    color: var(--text);
}
.product-card__sub {
    font-size: 0.82rem;
    color: var(--muted);
}

/* ---- Recent prices list (home): board rows, product + store on the start side,
        the price tag hanging off the end. ---- */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.recent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.recent-row:hover {
    border-color: var(--primary);
}
.recent-row__main {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.recent-row__product {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recent-row__store {
    color: var(--muted);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recent-row .tag {
    flex: none;
}

/* ---- Product comparison page ---- */
.price-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.price-row {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}
.price-row--cheapest {
    --tag-hole: var(--win-tint);
    border-color: var(--win);
    background: var(--win-tint);
}
.price-row__body {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.price-row__store {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.store-name {
    font-weight: 600;
}
.store-sub {
    display: flex;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--muted);
}
.store-distance {
    color: var(--primary);
}
.price-row__prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    text-align: end;
    flex: none;
}
.per-unit {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.raw-price {
    font-size: 0.82rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.price-row__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.price-row--cheapest .price-row__foot {
    border-top-color: var(--win-bg);
}
.price-row__tags {
    display: flex;
    align-items: center;
    gap: 8px;
}
.freshness {
    font-size: 0.8rem;
    color: var(--muted);
}
.price-row__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.vote-btns {
    display: flex;
    gap: 6px;
}
.vote-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    font: inherit;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    cursor: pointer;
}
.vote-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.vote-btn--up.is-active {
    border-color: var(--win);
    background: var(--win-bg);
    color: var(--win);
}
.vote-btn--down.is-active {
    border-color: var(--red);
    background: var(--red-bg);
    color: var(--red);
}
.report-slot:not(:empty) {
    margin-top: 12px;
}

/* ---- Report form ---- */
.report-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.report-form__actions {
    display: flex;
    gap: 12px;
    align-items: center;
}
.report-msg {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}
.report-msg--ok {
    background: var(--win-bg);
    color: var(--win);
}
.report-msg--error {
    background: var(--red-bg);
    color: var(--red);
}

/* ---- Add-price flow ---- */
.add-step__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 14px;
}
.add-step__actions {
    margin-top: 8px;
}
.add-row {
    display: flex;
    gap: 12px;
}
.add-row .field {
    flex: 1;
}
.add-row--store {
    align-items: flex-start;
}
.add-row--store .input {
    flex: 1;
}
.option-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.option-list:not(:empty) {
    margin-top: 4px;
}
.option {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    text-align: start;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font: inherit;
    color: var(--text);
    cursor: pointer;
}
.option:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}
.option--new {
    color: var(--primary);
    font-weight: 600;
}
.option__sub {
    font-size: 0.82rem;
    color: var(--muted);
}
.store-new {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.store-map {
    height: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 12px;
    z-index: 0;
}
.add-done__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

/* ---- HTMX loading / fragment states ---- */
.htmx-indicator {
    opacity: 0;
    transition: opacity 150ms ease;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}
[aria-busy='true'] {
    cursor: progress;
}
.htmx-request.app-main,
.htmx-settling.app-main {
    opacity: 0.6;
}

/* ---- Motion (opt-in; reduced-motion users get instant swaps) ---- */
@media (prefers-reduced-motion: no-preference) {
    .btn,
    .product-card,
    .recent-row,
    .option,
    .vote-btn,
    .app-nav a {
        transition:
            background-color 120ms ease,
            border-color 120ms ease,
            box-shadow 120ms ease,
            color 120ms ease;
    }
    .product-card:hover,
    .recent-row:hover {
        transform: translateY(-1px);
        transition:
            transform 120ms ease,
            border-color 120ms ease,
            box-shadow 120ms ease;
    }
    @keyframes kaser-fade-in {
        from {
            opacity: 0;
            transform: translateY(3px);
        }
    }
    .search-results-slot.htmx-settling > *,
    #search-results.htmx-settling > *,
    .report-slot.htmx-settling > * {
        animation: kaser-fade-in 180ms ease;
    }
    /* App-like navigation. Cross-document transitions cover plain full loads; hx-boost swaps get
       the same effect via the htmx-config `globalViewTransitions` meta in layout.eta. */
    @view-transition {
        navigation: auto;
    }
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.18s;
        animation-timing-function: ease;
    }
}
