/* =========================================================
   WARKOP LUMINA — UX & ACCESSIBILITY LAYER
   Ditambahkan 2026-11-05.
   Lapisan tambahan: tidak mengubah identitas visual,
   hanya ukuran target sentuh, kontras, fokus keyboard,
   ruang aman layar, dan state komponen.
   File ini dimuat SETELAH style.css.
   Hapus <link> ke file ini untuk membatalkan semuanya.
   ========================================================= */

:root {
    --tap-min: 44px;
}

/* ---------- KONTRAS TEKS KECIL ---------- */
/* --text-muted lama (#666 di atas #0a0a0a / #888 di atas #f5f5f5)
   hanya ~3:1, gagal WCAG AA untuk teks kecil. */
:root,
[data-theme="dark"] {
    --text-muted: #9a9a9a;
}

[data-theme="light"] {
    --text-muted: #6b6b6b;
    --price-color: #146c3c;
}

/* Harga pakai aksen kuning; di tema terang kuning #d4a830 di atas
   putih hanya ~2,4:1. Di tema terang pakai hijau tua. */
[data-theme="light"] .product-card .product-price,
[data-theme="light"] .cart-item-subtotal,
[data-theme="light"] .cart-summary .total,
[data-theme="light"] .history-total,
[data-theme="light"] .change-box .change-value {
    color: #146c3c;
}

/* ---------- TARGET SENTUH MINIMUM ---------- */
.header-cart,
.header-history,
.theme-toggle {
    width: var(--tap-min);
    height: var(--tap-min);
    font-size: 18px;
}

.page-header .back-btn {
    width: var(--tap-min);
    height: var(--tap-min);
    font-size: 18px;
}

.product-btn {
    min-height: var(--tap-min);
    font-size: 13px;
    padding: 10px 8px;
}

.cart-qty a,
.cart-qty .qty-value {
    width: 40px;
    height: 40px;
    font-size: 16px;
}

.cart-qty a.remove-btn {
    margin-left: 8px;
}

.header-cart .badge,
.header-history .badge,
#floating-cart #cart-count-fab {
    font-size: 10px;
    min-width: 18px;
    height: 18px;
}

/* ---------- FOKUS KEYBOARD ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.cat-item:focus-visible {
    outline: 2px solid #a9821f;
    outline-offset: 2px;
    border-radius: 10px;
}

[data-theme="dark"] a:focus-visible,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] summary:focus-visible,
[data-theme="dark"] .cat-item:focus-visible {
    outline-color: #f5c542;
}

/* ---------- SKIP LINK ---------- */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 100000;
    transform: translateY(-200%);
    background: #f5c542;
    color: #1a1400;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

/* ---------- RUANG AMAN (iPhone notch / gesture bar) ---------- */
.bottom-bar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

#floating-cart {
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

.has-bottom-bar {
    padding-bottom: 96px;
}

/* ---------- HEADER ---------- */
.app-header .brand {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Tombol header sudah 44px; di layar sempit status teks disembunyikan
   supaya brand tidak terpotong. */
@media (max-width: 380px) {
    .app-header > .status-open {
        display: none;
    }
}

/* ---------- KATEGORI & PRODUK ---------- */
.cat-item {
    min-height: 68px;
}

.product-btn.added {
    background: #146c3c;
    color: #ffffff;
    border-color: #146c3c;
}

[data-theme="dark"] .product-btn.added {
    background: #2f9e63;
    color: #06130c;
}

.product-btn[disabled] {
    cursor: progress;
}

/* ---------- TOAST ---------- */
.toast-msg {
    position: fixed;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(8px);
    background: #1f1f1f;
    color: #ffffff;
    padding: 11px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    max-width: calc(100% - 32px);
    text-align: center;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-msg.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 42px;
    opacity: 0.55;
    margin-bottom: 10px;
}

.empty-state .empty-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.empty-state .empty-text {
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---------- KERANJANG ---------- */
.cart-summary .label .count {
    color: var(--text-muted);
    font-weight: 500;
}

.qty-value {
    font-variant-numeric: tabular-nums;
}

/* ---------- CHECKOUT ---------- */
.order-summary {
    margin: 0 12px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.order-summary > summary {
    padding: 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    list-style: none;
}

.order-summary > summary::-webkit-details-marker {
    display: none;
}

.order-summary > summary .chev {
    color: var(--text-muted);
    font-size: 12px;
}

.order-summary[open] > summary .chev {
    transform: rotate(180deg);
}

.order-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    font-size: 12.5px;
    border-top: 1px dashed var(--border);
    color: var(--text-secondary);
}

.order-line .qty {
    color: var(--text-muted);
}

.order-summary .order-total {
    display: flex;
    justify-content: space-between;
    padding: 11px 14px;
    border-top: 1px solid var(--border);
    font-weight: 700;
    font-size: 13px;
}

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 5px;
}

.field-error {
    font-size: 11.5px;
    color: var(--danger);
    margin-top: 5px;
    display: none;
}

.field-error.is-visible {
    display: block;
}

input[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.12);
}

.btn-primary[disabled] {
    opacity: 0.75;
    cursor: progress;
}

/* ---------- KHUSUS PEMBACA LAYAR ---------- */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- HORMATI PREFERENSI GERAK MINIMUM ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    html {
        scroll-behavior: auto !important;
    }
}

/* ---------- LAYAR SANGAT KECIL ---------- */
@media (max-width: 360px) {
    .category-grid {
        gap: 8px;
    }

    .product-grid {
        gap: 8px;
    }
}
