/**
 * KOPIAH — customer ordering UI (mobile-first).
 */
:root {
    --k-espresso: #2f211a;
    --k-roast: #6f4e37;
    --k-roast-rgb: 111, 78, 55;
    --k-latte: #c8a27a;
    --k-foam: #efe3d3;
    --k-cream: #faf6f0;
    --k-surface: #ffffff;
    --k-text: #2f211a;
    --k-muted: #8a7768;
    --k-border: #eadfd2;
    --k-success: #2f8f5b;
    --k-danger: #c0392b;
    --k-radius: 18px;
    --k-radius-sm: 12px;
    --k-shadow: 0 6px 24px rgba(47, 33, 26, 0.08);
    --k-nav-height: 64px;
    --k-appbar-height: 60px;

    --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-bg: var(--k-cream);
    --bs-body-color: var(--k-text);
    --bs-link-color: var(--k-roast);
    --bs-link-color-rgb: var(--k-roast-rgb);
    --bs-link-hover-color: var(--k-espresso);
    --bs-border-color: var(--k-border);
    --bs-secondary-color: var(--k-muted);
    --bs-focus-ring-color: rgba(var(--k-roast-rgb), 0.25);
}

body {
    background: var(--k-cream);
    color: var(--k-text);
    padding-bottom: calc(var(--k-nav-height) + env(safe-area-inset-bottom));
    -webkit-font-smoothing: antialiased;
}

body.has-cart-bar {
    padding-bottom: calc(var(--k-nav-height) + 76px + env(safe-area-inset-bottom));
}

@media (min-width: 992px) {
    body,
    body.has-cart-bar {
        padding-bottom: 2rem;
    }
}

h1, h2, h3, .fw-display {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.text-muted-k {
    color: var(--k-muted) !important;
}

.k-container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- App bar ---------- */
.k-appbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--k-appbar-height);
    background: rgba(250, 246, 240, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--k-border);
}

.k-appbar .k-container {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

.k-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--k-espresso);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.k-brand img {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.k-brand small {
    display: block;
    font-weight: 500;
    letter-spacing: 0;
    font-size: 0.72rem;
    color: var(--k-muted);
    line-height: 1.1;
}

.k-appbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.k-desktop-nav a {
    color: var(--k-muted);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 999px;
}

.k-desktop-nav a.active,
.k-desktop-nav a:hover {
    color: var(--k-espresso);
    background: var(--k-foam);
}

.k-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--k-espresso);
    background: var(--k-surface);
    border: 1px solid var(--k-border);
    text-decoration: none;
    font-size: 1.2rem;
}

.k-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--k-roast);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--k-cream);
}

.k-badge:empty,
.k-badge[data-count="0"] {
    display: none;
}

/* ---------- Bottom navigation (mobile) ---------- */
.k-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    height: calc(var(--k-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--k-surface);
    border-top: 1px solid var(--k-border);
    display: flex;
}

.k-bottom-nav a {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--k-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
}

.k-bottom-nav a i {
    font-size: 1.35rem;
}

.k-bottom-nav a.active {
    color: var(--k-roast);
}

.k-bottom-nav a.active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--k-roast);
}

.k-bottom-nav .k-badge {
    top: 6px;
    right: calc(50% - 22px);
}

/* ---------- Sticky cart bar ---------- */
.k-cart-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--k-nav-height) + 10px + env(safe-area-inset-bottom));
    z-index: 1025;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--k-radius);
    background: var(--k-espresso);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 12px 30px rgba(47, 33, 26, 0.3);
}

.k-cart-bar:hover {
    color: #fff;
}

@media (min-width: 992px) {
    .k-cart-bar {
        left: auto;
        right: 24px;
        bottom: 24px;
        width: 360px;
    }
}

/* ---------- Buttons ---------- */
.btn-k {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--k-roast);
    --bs-btn-border-color: var(--k-roast);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--k-espresso);
    --bs-btn-hover-border-color: var(--k-espresso);
    --bs-btn-active-bg: var(--k-espresso);
    --bs-btn-active-border-color: var(--k-espresso);
    --bs-btn-disabled-bg: #b9a796;
    --bs-btn-disabled-border-color: #b9a796;
    --bs-btn-focus-shadow-rgb: var(--k-roast-rgb);
    border-radius: 999px;
    font-weight: 700;
    padding: 0.7rem 1.4rem;
}

.btn-k-outline {
    --bs-btn-color: var(--k-roast);
    --bs-btn-border-color: var(--k-border);
    --bs-btn-bg: var(--k-surface);
    --bs-btn-hover-color: var(--k-espresso);
    --bs-btn-hover-bg: var(--k-foam);
    --bs-btn-hover-border-color: var(--k-latte);
    border-radius: 999px;
    font-weight: 600;
}

/* ---------- Hero ---------- */
.k-hero {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    padding: 28px 22px;
    color: #fff;
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(200, 162, 122, 0.45) 0%, rgba(200, 162, 122, 0) 55%),
        linear-gradient(140deg, #3b2a20 0%, #6f4e37 100%);
    box-shadow: var(--k-shadow);
}

.k-hero::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 28px solid rgba(255, 255, 255, 0.06);
}

.k-hero h1 {
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    line-height: 1.1;
}

.k-hero .k-chip {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: transparent;
}

/* ---------- Chips ---------- */
.k-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--k-border);
    background: var(--k-surface);
    color: var(--k-espresso);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.k-chip.active,
a.k-chip:hover {
    background: var(--k-espresso);
    border-color: var(--k-espresso);
    color: #fff;
}

.k-chip-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 16px;
    margin: 0 -16px;
    scroll-snap-type: x proximity;
}

.k-chip-scroll::-webkit-scrollbar {
    display: none;
}

.k-chip-scroll > * {
    scroll-snap-align: start;
}

.k-sticky-tabs {
    position: sticky;
    top: var(--k-appbar-height);
    z-index: 1010;
    background: var(--k-cream);
    padding: 10px 0;
}

/* ---------- Product card ---------- */
.k-product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (min-width: 768px) {
    .k-product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .k-product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.k-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--k-surface);
    border-radius: var(--k-radius);
    border: 1px solid var(--k-border);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.k-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--k-shadow);
    color: inherit;
}

.k-card-img {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--k-foam);
}

.k-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.k-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    flex: 1;
}

.k-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.25;
}

.k-card-desc {
    color: var(--k-muted);
    font-size: 0.78rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.k-price {
    font-weight: 800;
    color: var(--k-roast);
}

.k-card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
}

.k-add-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--k-roast);
    color: #fff;
    font-size: 1.1rem;
}

.k-soldout {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(250, 246, 240, 0.72);
    font-weight: 800;
    color: var(--k-espresso);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.k-card.is-soldout .k-add-dot {
    background: #c9bbae;
}

/* ---------- Section ---------- */
.k-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 28px 0 14px;
}

.k-section-title h2 {
    font-size: 1.2rem;
    margin: 0;
}

.k-anchor {
    scroll-margin-top: calc(var(--k-appbar-height) + 64px);
}

/* ---------- Product detail ---------- */
.k-detail-img {
    border-radius: 24px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: var(--k-foam);
}

.k-detail-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.k-option-group {
    background: var(--k-surface);
    border: 1px solid var(--k-border);
    border-radius: var(--k-radius);
    padding: 16px;
    margin-bottom: 14px;
}

.k-option-group h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
}

.k-option-group h3 small {
    font-weight: 500;
    color: var(--k-muted);
}

.k-segment {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.k-segment input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.k-segment label {
    flex: 1 1 0;
    min-width: 90px;
    text-align: center;
    padding: 10px 12px;
    border-radius: var(--k-radius-sm);
    border: 1.5px solid var(--k-border);
    background: var(--k-cream);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    line-height: 1.2;
}

.k-segment label small {
    display: block;
    font-weight: 500;
    color: var(--k-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

.k-segment input:checked + label {
    border-color: var(--k-roast);
    background: rgba(var(--k-roast-rgb), 0.08);
    color: var(--k-espresso);
}

.k-segment input:focus-visible + label {
    outline: 3px solid rgba(var(--k-roast-rgb), 0.35);
    outline-offset: 2px;
}

.k-segment input:disabled + label {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.k-check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--k-border);
    cursor: pointer;
    margin: 0;
}

.k-check-row:last-child {
    border-bottom: 0;
}

.k-check-row .form-check-input {
    margin: 0;
    width: 1.25em;
    height: 1.25em;
}

.form-check-input:checked {
    background-color: var(--k-roast);
    border-color: var(--k-roast);
}

.k-stepper {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid var(--k-border);
    border-radius: 999px;
    background: var(--k-surface);
}

.k-stepper button {
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    font-size: 1.1rem;
    color: var(--k-espresso);
    border-radius: 50%;
}

.k-stepper button:disabled {
    color: #c9bbae;
}

.k-stepper output,
.k-stepper input {
    min-width: 32px;
    text-align: center;
    font-weight: 700;
    border: 0;
    background: transparent;
}

.k-stepper-sm button {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
}

.k-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--k-nav-height) + env(safe-area-inset-bottom));
    z-index: 1025;
    background: var(--k-surface);
    border-top: 1px solid var(--k-border);
    padding: 12px 0;
}

@media (min-width: 992px) {
    .k-action-bar {
        position: sticky;
        bottom: 16px;
        border: 1px solid var(--k-border);
        border-radius: var(--k-radius);
        box-shadow: var(--k-shadow);
        margin-top: 16px;
    }
}

.k-form-control {
    border-radius: var(--k-radius-sm);
    border-color: var(--k-border);
    background: var(--k-cream);
}

.k-form-control:focus {
    border-color: var(--k-latte);
    box-shadow: 0 0 0 0.2rem rgba(var(--k-roast-rgb), 0.15);
}

/* ---------- Cart ---------- */
.k-cart-line {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--k-surface);
    border: 1px solid var(--k-border);
    border-radius: var(--k-radius);
}

.k-cart-line + .k-cart-line {
    margin-top: 10px;
}

.k-cart-line img {
    width: 72px;
    height: 72px;
    border-radius: var(--k-radius-sm);
    object-fit: cover;
    background: var(--k-foam);
    flex-shrink: 0;
}

.k-cart-meta {
    font-size: 0.8rem;
    color: var(--k-muted);
}

.k-summary {
    background: var(--k-surface);
    border: 1px solid var(--k-border);
    border-radius: var(--k-radius);
    padding: 18px;
}

.k-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.k-summary-total {
    border-top: 1px dashed var(--k-border);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 800;
    font-size: 1.1rem;
}

.k-empty {
    text-align: center;
    padding: 56px 16px;
    color: var(--k-muted);
}

.k-empty i {
    font-size: 3.5rem;
    color: var(--k-latte);
}

/* ---------- Toast ---------- */
.k-toast-stack {
    position: fixed;
    top: calc(var(--k-appbar-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1090;
    width: min(92vw, 420px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.k-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--k-espresso);
    color: #fff;
    box-shadow: 0 12px 30px rgba(47, 33, 26, 0.25);
    font-size: 0.9rem;
    animation: k-toast-in 0.2s ease-out;
}

.k-toast.is-error {
    background: var(--k-danger);
}

.k-toast a {
    color: var(--k-latte);
    font-weight: 700;
    margin-left: auto;
    white-space: nowrap;
}

@keyframes k-toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .k-toast,
    a.k-card {
        animation: none;
        transition: none;
    }
}

/* ---------- Footer ---------- */
.k-footer {
    color: var(--k-muted);
    font-size: 0.82rem;
    padding: 32px 0 16px;
    text-align: center;
}

/* ---------- Order progress ---------- */
.k-steps {
    list-style: none;
    margin: 0 0 16px;
    padding: 18px 18px 6px;
    background: var(--k-surface);
    border: 1px solid var(--k-border);
    border-radius: var(--k-radius);
}

.k-steps li {
    position: relative;
    padding: 0 0 16px 34px;
    color: var(--k-muted);
    font-weight: 600;
}

.k-steps li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--k-border);
    background: var(--k-surface);
}

.k-steps li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 24px;
    bottom: 2px;
    width: 2px;
    background: var(--k-border);
}

.k-steps li.is-done {
    color: var(--k-espresso);
}

.k-steps li.is-done::before {
    border-color: var(--k-success);
    background: var(--k-success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M13.5 4.5 6 12 2.5 8.5l1-1L6 10l6.5-6.5z'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.k-steps li.is-done::after {
    background: var(--k-success);
}

.k-steps li.is-current {
    color: var(--k-roast);
}

.k-steps li.is-current::before {
    border-color: var(--k-roast);
    box-shadow: 0 0 0 4px rgba(var(--k-roast-rgb), 0.15);
    animation: k-pulse 1.6s ease-in-out infinite;
}

@keyframes k-pulse {
    50% {
        box-shadow: 0 0 0 8px rgba(var(--k-roast-rgb), 0.05);
    }
}

@media (prefers-reduced-motion: reduce) {
    .k-steps li.is-current::before {
        animation: none;
    }
}
