/* The design system's shared building blocks (DESIGN.md sections 6 and 7). Pages compose these classes and the
   matching components in Components/UI; component .razor.css files only hold layout that belongs to one page. */

/* ---- Buttons: 44 to 48px, 10px radius, weight 500. One primary per screen area. ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding-inline: var(--s-6);
  border-radius: var(--r-control);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent), #000 12%); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; }
.btn:disabled, .btn[aria-disabled="true"] { cursor: progress; opacity: 0.8; }

/* Square icon button (menu, close, card add). */
.icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--ink-3); }
.icon-btn-sm { width: 40px; height: 40px; }
.icon-btn-accent { color: var(--accent); }
.icon-btn-accent:hover { border-color: var(--accent); }

/* ---- Links ---- */
.link-accent { color: var(--accent); text-decoration: none; font-weight: 500; }
.link-accent:hover { text-decoration: underline; text-underline-offset: 3px; }

/* A button that looks like a link (Remove, Resend). */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-button.quiet { color: var(--ink-2); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }

/* ---- Page frame ---- */
.page { padding-block-start: var(--s-5); }
.page-title { margin-block-end: var(--s-6); font-size: 26px; letter-spacing: var(--heading-track); }

@media (min-width: 640px) {
  .page { padding-block-start: var(--s-8); }
  .page-title { font-size: 32px; }
}

.section-title { font-size: 22px; letter-spacing: var(--heading-track); }

/* ---- Panel: white card section ---- */
.panel {
  padding: var(--s-4);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
}

@media (min-width: 640px) { .panel { padding: var(--s-5) var(--s-6); } }

.panel-title { margin-block-end: var(--s-3); font-size: 18px; }
.panel-count { color: var(--ink-3); font-weight: 400; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px var(--s-2);
  border-radius: var(--r-tag);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-sale { background: var(--accent); color: var(--accent-ink); }
.badge-soft { background: var(--accent-soft); color: var(--accent); font-size: 12px; padding: 1px 6px; }
.badge-new { background: var(--new-bg); color: var(--new-ink); }

/* ---- Chips: 32 to 36px; active filter chips carry a × ---- */
.chip {
  min-height: 36px;
  padding-inline: var(--s-3);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover { border-color: var(--ink-3); }
.chip[aria-current="page"], .chip.active { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ---- Notices ---- */
.notice {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  padding: 10px var(--s-3);
  border-radius: var(--r-control);
  font-size: 14px;
  line-height: 20px;
}

.notice a { color: inherit; font-weight: 500; }
.notice-info { background: var(--warning-soft); color: var(--warning-ink); }
.notice-good { background: var(--accent-soft); color: #1F5A30; }
.notice-error { background: #FDECEA; color: var(--danger-ink); }

/* ---- Quantity stepper ---- */
.stepper {
  display: inline-flex;
  align-items: center;
  height: 48px;
  border-radius: var(--r-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.stepper-btn {
  width: 48px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.stepper-btn:disabled { color: var(--ink-3); cursor: default; }

.stepper-value {
  min-width: 40px;
  width: 3.5ch;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.stepper-value::-webkit-inner-spin-button,
.stepper-value::-webkit-outer-spin-button { appearance: none; margin: 0; }

.stepper-sm { height: 40px; }
.stepper-sm .stepper-btn { width: 40px; }
.stepper-sm .stepper-value { min-width: 24px; width: auto; font-size: 15px; font-weight: 400; }

/* ---- Choice card: a radio drawn as a card (delivery, payment) ---- */
.choice-grid {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--s-2);
}

.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-3) 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
}

.choice-card:has(input:checked) { border: 2px solid var(--accent); background: #F3F8F4; padding: 11px 13px; }
.choice-card:has(input:focus-visible) { outline: var(--focus-ring); outline-offset: 2px; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-title { font-weight: 500; }
.choice-note { font-size: 13px; line-height: 18px; color: var(--ink-2); }
/* The price sits at the bottom, so it lines up across cards whose notes differ in length. */
.choice-extra { margin-block-start: auto; padding-block-start: var(--s-1); font-size: 13px; font-weight: 500; color: var(--accent); }

/* ---- Summary list: label and amount rows ---- */
.summary-list { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: var(--s-2) var(--s-4); font-variant-numeric: tabular-nums; }
.summary-list dt { color: var(--ink-2); }
.summary-list dd { margin: 0; text-align: end; }
.summary-list .good { color: var(--accent); }

.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-block-start: var(--s-3);
  border-top: 1px solid var(--line);
  font-size: 16px;
  font-weight: 500;
}

.summary-total .amount { font-size: 28px; font-variant-numeric: tabular-nums; }
.summary-list + .summary-total { margin-block-start: var(--s-4); }

/* ---- Empty state ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-12) var(--s-4);
  text-align: center;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
}

.empty-state h2 { font-size: 20px; }
.empty-state p { max-width: 420px; color: var(--ink-2); }
.empty-state .btn { margin-block-start: var(--s-2); }

/* ---- Fixed bar: phones only, the page's main action at the bottom of the screen ---- */
.fixed-bar { display: none; }

@media (max-width: 639.98px) {
  .fixed-bar {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4) max(var(--s-3), env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: var(--shadow-sticky);
  }

  .fixed-bar .btn { flex: 1; }
  .wide-only { display: none !important; }
}

@media (min-width: 640px) {
  .phone-only { display: none !important; }
}

/* Banner colours: the site banner and its previews in the dashboard. */
.tone-blue { background: #E4F1FB; color: #1D4F7A; }
.tone-green { background: var(--accent-soft); color: #1F5A30; }
.tone-red { background: #FDECEA; color: var(--danger-ink); }
.tone-yellow, .tone-unknown { background: var(--warning-soft); color: var(--warning-ink); }

/* ---- Loading ----
   Both wait 150ms before showing, so quick responses never flash a loader (transitions.js uses the same delay). */

/* Page loads and form posts: a thin bar across the top of the window. transitions.js sets data-state. While loading
   it creeps towards 90% and slows down; when the page arrives it fills and fades. */
.nav-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 80;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
  pointer-events: none;
}

:root[dir="rtl"] .nav-progress { transform-origin: right center; }

.nav-progress[data-state="loading"] {
  opacity: 1;
  transition: opacity 150ms 150ms;
  animation: nav-progress 8s cubic-bezier(0.1, 0.7, 0.3, 1) 150ms both;
}

.nav-progress[data-state="done"] {
  opacity: 0;
  transform: scaleX(1);
  transition: transform 200ms ease-out, opacity 250ms 200ms;
}

@keyframes nav-progress {
  from { transform: scaleX(0.08); }
  to { transform: scaleX(0.9); }
}

/* The button that was pressed: its label gives way to a spinner. aria-busy comes from site.js on form posts and from
   the add-to-cart islands. pointer-events stops a second press posting twice. */
:is(.btn, .icon-btn)[aria-busy="true"] {
  position: relative;
  pointer-events: none;
  animation: busy-hide-label 0s 150ms forwards;
}

:is(.btn, .icon-btn)[aria-busy="true"] > * { animation: busy-hide 0s 150ms forwards; }

:is(.btn, .icon-btn)[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  opacity: 0;
  animation: busy-show 0s 150ms forwards, busy-spin 0.7s linear infinite;
}

@keyframes busy-hide-label { to { -webkit-text-fill-color: transparent; } }
@keyframes busy-hide { to { visibility: hidden; } }
@keyframes busy-show { to { opacity: 1; } }
@keyframes busy-spin { to { rotate: 360deg; } }

/* Photos still downloading (site.js): a soft shimmer fills the photo's box, then the photo fades in. The box keeps
   its size from the width and height attributes, so nothing moves when it arrives. A reused <img> still holds the
   previous photo while the new one loads: moving it out of the box (images clip to their box) leaves only the
   shimmer. */
img[data-img-pending] {
  background: linear-gradient(100deg, var(--raised) 30%, #F8F4ED 50%, var(--raised) 70%) var(--raised);
  background-size: 300% 100%;
  color: transparent;
  object-position: -99999px -99999px;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

img[data-img-loaded] { animation: img-arrive 320ms cubic-bezier(0, 0, 0.2, 1); }

@keyframes skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

@keyframes img-arrive { from { opacity: 0; } }

/* ---- Order placed (js/place-order.js) ----
   The Place order button's floating copy: a spinner while the order is placed, then it grows into a round tick in
   the middle of the screen over a plain backdrop, and both fade to show the order page. */
.page-overlay { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.page-overlay:empty { display: none; }

.order-backdrop { position: absolute; inset: 0; background: var(--bg); opacity: 0; }

.order-ghost {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--accent);
  color: var(--accent-ink);
}

.order-ghost .ghost-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: busy-spin 0.7s linear infinite;
}

.order-ghost .ghost-check { display: none; width: 34px; height: 34px; }
.order-ghost .ghost-check path { stroke-dasharray: 30; stroke-dashoffset: 30; }
.order-ghost[data-state="done"] .ghost-spinner { display: none; }
.order-ghost[data-state="done"] .ghost-check { display: block; }
.order-ghost[data-state="done"] .ghost-check path { animation: draw-check 320ms 300ms cubic-bezier(0.65, 0, 0.35, 1) forwards; }

.order-message {
  position: fixed;
  inset-inline: 0;
  inset-block-start: calc(50% + 56px);
  text-align: center;
  font-size: 20px;
  font-weight: 500;
  opacity: 0;
}

@keyframes draw-check { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .nav-progress[data-state="loading"] { animation: none; transform: scaleX(1); }
  :is(.btn, .icon-btn)[aria-busy="true"]::after { animation: busy-show 0s 150ms forwards, busy-spin 2.4s linear infinite; }
}

/* A download that just finished (site.js, a[data-download]): a tick over the label for a moment. */
.btn[data-done] { position: relative; -webkit-text-fill-color: transparent; }
.btn[data-done] > * { visibility: hidden; }
.btn[data-done]::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 14px;
  height: 8px;
  margin: auto;
  border-inline-start: 2px solid var(--accent);
  border-block-end: 2px solid var(--accent);
  rotate: -45deg;
  translate: 0 -2px;
  animation: download-done 240ms cubic-bezier(0.2, 0, 0, 1);
}

@keyframes download-done { from { opacity: 0; scale: 0.6; } }

/* ---- Pages written in the dashboard: the kind of a post (news, announcement) on its page and its card ---- */
.kind-tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-tag); background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 500; }
