/* =========================================
   Walk-in self-order — public /order page (self-order.js) and its printable poster
   Phone first: 2-column product grid, sticky search, a cart bar at the bottom.
   ========================================= */

.so-body { min-height: 100vh; background: var(--bg); color: var(--text-primary); }
.so-body[data-step="pick"] { padding-bottom: 104px; }
.so-main { max-width: 960px; margin: 0 auto; padding: 16px; }
.so-narrow { max-width: 560px; }
.so-main[hidden], .so-bar[hidden] { display: none; }

/* ——— Header and steps ——— */
.so-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.so-header-row { display: flex; align-items: center; gap: 12px; max-width: 960px; margin: 0 auto; padding: 12px 16px 8px; }
.so-logo { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.so-brand { font-weight: 800; font-size: 1rem; line-height: 1.2; }
.so-tagline { font-size: 0.78rem; font-weight: 600; color: var(--primary); }
.so-steps { display: flex; gap: 4px; max-width: 960px; margin: 0 auto; padding: 0 16px 12px; counter-reset: none; }
.so-steps li { flex: 1; display: flex; align-items: center; gap: 6px; padding-top: 8px; border-top: 3px solid var(--border); font-size: 0.72rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.so-steps li span { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--border); color: var(--text-secondary); font-size: 0.68rem; font-weight: 800; }
.so-steps li.is-done { border-top-color: var(--primary); color: var(--text-secondary); }
.so-steps li.is-done span { background: var(--primary-light); color: var(--primary); }
.so-steps li.is-current { border-top-color: var(--primary); color: var(--primary); }
.so-steps li.is-current span { background: var(--primary); color: #fff; }

/* ——— Step 1: browse ——— */
.so-intro { padding: 4px 2px 14px; }
.so-intro h1 { font-size: 1.45rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.so-intro p { margin-top: 4px; font-size: 0.88rem; color: var(--text-secondary); }

.so-toolbar { position: sticky; top: 0; z-index: 4; margin: 0 -16px 4px; padding: 10px 16px 0; background: var(--bg); }
.so-toolbar .pd-search { max-width: none; }
.so-toolbar .pd-search .form-input { font-size: 16px; }
.so-toolbar .pd-chips { margin-bottom: 10px; }
/* Cards are the shop's (.pd-card .cs-card); the image isn't a link here */
.so-body .cs-card .pd-media-wrap { cursor: default; }
.so-body .cs-card .pc-qty { flex: none; }
.so-body .cs-card.bump { animation: soBump 0.3s ease; }
@keyframes soBump { 50% { transform: scale(1.03); } }
.so-empty { grid-column: 1 / -1; padding: 48px 16px; text-align: center; color: var(--text-secondary); font-size: 0.9rem; }
.so-empty strong { display: block; margin-bottom: 4px; color: var(--text-primary); font-size: 1rem; }
.so-empty .btn { margin-top: 12px; }

/* Quantity stepper on the review list */
.so-stepper { display: flex; align-items: center; height: 40px; border-radius: var(--radius); background: var(--primary); color: #fff; overflow: hidden; }
.so-stepper button { flex: none; display: flex; align-items: center; justify-content: center; width: 40px; height: 100%; border: none; background: transparent; color: inherit; cursor: pointer; }
.so-stepper button:active { background: rgba(0, 0, 0, 0.12); }
.so-stepper label { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 2px; min-width: 0; font-weight: 700; }
.so-stepper input { width: 3.2em; min-width: 1.4ch; field-sizing: content; height: 30px; padding: 0; border: none; border-radius: var(--radius-sm); background: transparent; color: inherit; text-align: right; font: inherit; font-size: 16px; font-weight: 800; -moz-appearance: textfield; appearance: textfield; }
.so-stepper input:focus { outline: 2px solid rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.15); }
.so-stepper input::-webkit-outer-spin-button, .so-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.so-stepper small { font-size: 0.75rem; font-weight: 600; opacity: 0.85; }

/* Placeholder cards while the catalog loads */
.so-skeleton { animation: soPulse 1.2s ease-in-out infinite; }
.so-skeleton .pd-media-wrap { background: var(--surface-2); }
.so-skeleton .pd-body span { display: block; height: 12px; margin-top: 6px; border-radius: 6px; background: var(--surface-2); }
.so-skeleton .pd-body span:last-child { width: 50%; }
@keyframes soPulse { 50% { opacity: 0.55; } }

/* ——— Cart bar ——— */
.so-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); animation: soUp 0.2s ease; }
@keyframes soUp { from { transform: translateY(100%); } }
.so-bar-btn { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 560px; margin: 0 auto; padding: 8px 8px 8px 12px; border: none; border-radius: var(--radius-lg); background: var(--primary); color: #fff; font: inherit; text-align: left; cursor: pointer; }
.so-bar-cart { position: relative; display: flex; }
.so-bar-count { position: absolute; top: -8px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #fff; color: var(--primary); font-size: 0.7rem; font-weight: 800; line-height: 18px; text-align: center; }
.so-bar-info { flex: 1; display: flex; flex-direction: column; min-width: 0; padding-left: 4px; font-size: 0.75rem; opacity: 0.95; }
.so-bar-info strong { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.so-bar-go { display: flex; align-items: center; gap: 2px; padding: 10px 12px 10px 16px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.18); font-weight: 700; }

/* ——— Step 2: review ——— */
.so-back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 8px -4px; padding: 6px 4px; border: none; background: none; color: var(--primary); font: inherit; font-weight: 700; cursor: pointer; }
.so-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 12px; }
.so-panel { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.so-review-line { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--border); }
.so-review-line:last-child { border-bottom: none; }
.so-thumb { --cat: var(--primary); position: relative; width: 52px; height: 52px; overflow: hidden; border-radius: var(--radius); background: color-mix(in srgb, var(--cat) 14%, var(--surface)); }
.so-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.so-thumb .pd-placeholder svg { width: 22px; height: 22px; }
.so-review-name { font-weight: 700; font-size: 0.9rem; line-height: 1.25; }
.so-review-sub { font-size: 0.75rem; color: var(--text-secondary); }
.so-review-amt { margin-top: 2px; font-weight: 800; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.so-review-ctrl { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.so-review-ctrl .so-stepper { width: 132px; height: 36px; }
.so-review-ctrl .so-stepper button { width: 36px; }
.so-remove { padding: 2px 0; border: none; background: none; color: var(--danger); font: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.so-summary { padding: 14px 4px 4px; }
.so-summary-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-size: 0.88rem; color: var(--text-secondary); }
.so-summary-total { color: var(--text-primary); font-weight: 700; font-size: 0.95rem; }
.so-summary-total strong { font-size: 1.3rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.so-fine { margin-top: 6px; font-size: 0.78rem; color: var(--text-secondary); }
.so-fine a { color: var(--primary); text-decoration: underline; }
.so-form { margin-top: 16px; padding: 16px; }
.so-form .form-input { height: 46px; font-size: 16px; }
.so-optional { margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); font-size: 0.68rem; font-weight: 600; color: var(--text-secondary); }
.so-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.so-error { min-height: 18px; margin-top: 10px; font-size: 0.85rem; color: var(--danger); }
.so-submit { width: 100%; height: 50px; justify-content: center; margin-top: 2px; font-size: 1rem; font-weight: 700; border-radius: var(--radius-lg); }
.so-legal { text-align: center; }

/* ——— Step 3: ticket ——— */
.so-ticket { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.so-ticket-top { padding: 22px 18px 18px; }
.so-status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; }
.so-status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.so-status.waiting { background: var(--warning-light); color: #92400e; }
.so-status.waiting .so-status-dot { animation: soBlink 1.4s ease-in-out infinite; }
@keyframes soBlink { 50% { opacity: 0.25; } }
.so-status.serving { background: var(--primary-light); color: var(--primary-dark); }
.so-status.done { background: var(--success-light); color: #166534; }
.so-status.ended { background: var(--danger-light); color: #991b1b; }
.so-ticket-lead { margin-top: 14px; font-weight: 700; font-size: 1rem; }
.so-qr { width: min(240px, 70vw); aspect-ratio: 1; margin: 12px auto 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }
.so-qr svg { display: block; width: 100%; height: 100%; }
.so-ticket-or { font-size: 0.8rem; color: var(--text-secondary); }
.so-code { display: flex; justify-content: center; gap: 8px; margin: 8px 0 4px; }
.so-code span { display: flex; align-items: center; justify-content: center; width: 52px; height: 62px; border-radius: var(--radius); background: var(--primary-lighter); border: 1.5px solid var(--primary-light); color: var(--primary-dark); font-size: 2rem; font-weight: 800; }
.so-ticket.is-ended .so-qr, .so-ticket.is-ended .so-code { opacity: 0.25; }
.so-ticket-name { margin-top: 8px; font-weight: 700; color: var(--text-secondary); }
.so-ticket-name:empty { display: none; }
.so-ticket-cut { position: relative; height: 0; margin: 0 18px; border-top: 2px dashed var(--border); }
.so-ticket-cut::before, .so-ticket-cut::after { content: ''; position: absolute; top: -12px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); }
.so-ticket-cut::before { left: -30px; }
.so-ticket-cut::after { right: -30px; }
.so-ticket-bottom { padding: 14px 18px 18px; text-align: left; }
.so-ticket-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 0.88rem; }
.so-ticket-line span { min-width: 0; }
.so-ticket-line small { color: var(--text-secondary); }
.so-ticket-line strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.so-ticket-bottom .so-summary-total { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.so-tips { margin: 16px 4px 0; padding-left: 18px; list-style: disc; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }
.so-tips li + li { margin-top: 4px; }
.so-new { display: flex; width: 100%; height: 46px; justify-content: center; margin-top: 16px; }

/* Small "Added" message */
.so-toast { position: fixed; left: 50%; bottom: 100px; z-index: 8; transform: translate(-50%, 12px); max-width: calc(100% - 32px); padding: 9px 16px; border-radius: 999px; background: var(--text-primary); color: #fff; font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ——— Store poster (/order/poster) ——— */
.so-poster { max-width: 520px; margin: 32px auto; padding: 40px 32px; border: 2px solid var(--primary); border-radius: var(--radius-xl); background: #fff; color: #0F1B2E; text-align: center; }
.so-poster h1 { font-size: 2rem; font-weight: 800; margin: 12px 0 4px; }
.so-poster p { color: #5A6B82; }
.so-poster-qr { width: 300px; height: 300px; margin: 24px auto; }
.so-poster-qr svg { display: block; width: 100%; height: 100%; }
.so-poster ol { display: inline-block; text-align: left; margin: 0 auto; padding-left: 20px; list-style: decimal; color: #0F1B2E; font-size: 1rem; line-height: 1.8; }
.so-poster-url { margin-top: 16px; font-size: 0.85rem; word-break: break-all; }
.so-poster-actions { display: flex; justify-content: center; gap: 8px; margin: 16px auto; }
@media print {
  .so-poster-actions { display: none; }
  .so-poster { margin: 0 auto; border-width: 3px; }
}
