/* ============================================================
   SANOWICH — custom sandwich builder
   ============================================================ */

:root {
  --ink: #594c52;
  --ink-soft: #8a7c82;
  --mint: #8dbfb3;
  --mint-deep: #6ba597;
  --mint-wash: #e6f2ef;
  --paper: #ffffff;
  --line: rgba(89, 76, 82, .14);
  --radius: 18px;
  --shadow-soft: 0 10px 30px rgba(89, 76, 82, .10);
  --shadow-lift: 0 18px 40px rgba(89, 76, 82, .18);
  --stack-ratio: 650 / 360;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #efeeec url("image/theme/back.jpg") center / cover fixed no-repeat;
  -webkit-font-smoothing: antialiased;
}

/* Marble is busy — a soft wash keeps the copy readable. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.42), rgba(255,255,255,.62));
  pointer-events: none;
  z-index: -1;
}

.wrap {
  width: min(680px, 100% - 32px);
  margin-inline: auto;
}

h1, h2, h3, .btn, .cat-title, .marquee-text, .tile-name, .price, .add-slot-label {
  font-family: "Fredoka", "Nunito", sans-serif;
}

img { max-width: 100%; display: block; }

button { font: inherit; color: inherit; }

::selection { background: var(--mint); color: #fff; }

:where(button, input, a):focus-visible {
  outline: 3px solid var(--mint-deep);
  outline-offset: 2px;
}

/* ------------------------------ header ------------------------------ */

.site-header {
  padding: 40px 0 0;
  text-align: center;
}

.brand {
  display: flex;
  justify-content: center;
  margin-block: 0;
}

.brand img {
  width: min(480px, 88%);
  height: auto;
  margin-inline: auto;
}

.marquee {
  margin: 18px 0 26px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 42s linear infinite;
  will-change: transform;
}

.marquee-text {
  margin: 0;
  flex: 0 0 auto;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-size: clamp(15px, 3.6vw, 20px);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--ink);
}

@keyframes marquee {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
  .marquee {
    mask-image: none;
    -webkit-mask-image: none;
  }
  .marquee-track .marquee-text:last-child { display: none; }
  .marquee-text {
    white-space: normal;
    text-align: center;
    padding-inline: 16px;
  }
}

/* ------------------------------ plate ------------------------------ */

/* The plate, its caption and the CTA stay pinned while the ingredient
   grids scroll underneath. Full size at rest, compact once pinned so it
   never eats the whole viewport. */
.stage-sentinel {
  height: 1px;
  margin-bottom: -1px;
}

.stage-dock {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 12px 0;
}

/* -16px matches the smallest gutter .wrap ever leaves, so the backdrop
   bleeds past the content without ever causing horizontal overflow. */
.stage-dock::before {
  content: "";
  position: absolute;
  inset: 0 -16px;
  border-radius: 0 0 28px 28px;
  background: linear-gradient(rgba(247, 246, 245, .9) 78%, rgba(247, 246, 245, 0));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  mask-image: linear-gradient(#000 78%, transparent);
  -webkit-mask-image: linear-gradient(#000 78%, transparent);
  opacity: 0;
  transition: opacity .16s ease;
  pointer-events: none;
}

/* Instant on the way in so nothing shows through while the plate shrinks,
   soft on the way out. */
.stage-dock.is-stuck::before {
  opacity: 1;
  transition: none;
}

.stage-dock > * { position: relative; }

.stage {
  width: 100%;
  margin-inline: auto;
  scroll-margin-top: 18px;
  transition: width .3s cubic-bezier(.3, .8, .35, 1);
}

.stage-dock.is-stuck .stage { width: min(300px, 52%); }

.stage-dock.is-stuck .stage-caption {
  margin-top: 8px;
  font-size: 13px;
}

.stage-dock.is-stuck .stage-actions { margin: 10px 0 14px; }

.stage-dock.is-stuck .btn-primary {
  padding: 11px 24px;
  font-size: 14px;
}

.plate {
  position: relative;
  width: 100%;
  aspect-ratio: 533 / 384;
  filter: drop-shadow(0 16px 26px rgba(70, 50, 40, .28));
  transform-origin: 50% 60%;
}

.plate.is-landing { animation: plate-bump .42s ease-out; }

@keyframes plate-bump {
  0%   { transform: scale(1) rotate(0deg); }
  32%  { transform: scale(.985) rotate(-.25deg); }
  66%  { transform: scale(1.007) rotate(.18deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.plate-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sandwich {
  --fill: 1;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 94%;
  aspect-ratio: var(--stack-ratio);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.plate-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(17px, 4.4vw, 22px);
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 2px 10px rgba(60, 38, 24, .55);
  transition: opacity .35s ease;
  pointer-events: none;
}

.plate-hint span { opacity: .75; font-size: .82em; }

.plate-hint[hidden] { display: block; opacity: 0; }

/* stacked ingredient layers ------------------------------------------- */

.layer {
  position: absolute;
  inset: 0;
  transform-origin: 50% 60%;
  opacity: 0.9;
}

.layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 50% 55%;
  transform: scale(var(--fill));
}

/* the bread defines the footprint, so it is never rescaled */
.layer[data-cat="pan"] img { transform: none; }

.layer[data-amount="poco"] img { transform: scale(calc(var(--fill) * .78)); }

.layer[data-amount="mucho"] img:nth-child(1) { transform: translateY(1.5%) scale(calc(var(--fill) * 1.02)); }
.layer[data-amount="mucho"] img:nth-child(2) { transform: translateY(-3.5%) scale(calc(var(--fill) * 1.03)) rotate(-1.1deg); }

/* Drop animates transform only — opacity stays on .layer so it can't get stuck at 1 or 0 */
.layer.is-dropping {
  z-index: 900 !important;
  animation: drop-in .58s cubic-bezier(.22, .9, .28, 1) both;
}

@keyframes drop-in {
  0%   { transform: scale(2.1) translateY(-11%); filter: blur(2px); }
  72%  { transform: scale(.965) translateY(1.2%); filter: blur(0); }
  88%  { transform: scale(1.012) translateY(-.4%); }
  100% { transform: scale(1) translateY(0); filter: blur(0); }
}

.layer.is-pending { opacity: 0; }

.layer.is-leaving {
  animation: lift-out .32s ease-in forwards;
  pointer-events: none;
}

@keyframes lift-out {
  to { opacity: 0; transform: scale(1.35) translateY(-8%); }
}

.layer.is-pulsing { animation: pulse .3s ease-out; }

@keyframes pulse {
  50% { transform: scale(1.035); }
}

.stage-caption {
  margin: 14px 0 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.5;
  min-height: 21px;
}

.stage-caption em {
  font-style: normal;
  font-size: .88em;
  opacity: .72;
}

.stage-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 18px 0 34px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover { color: var(--ink); }

/* ------------------------------ buttons ------------------------------ */

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 16px 34px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .05em;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, opacity .16s ease;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lift);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-2px); background: #4a3f44; }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-primary:disabled {
  background: rgba(89, 76, 82, .28);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
}

.btn-ghost:hover { background: var(--ink); color: #fff; }

/* ------------------------------ categories ------------------------------ */

.categories { padding-bottom: 10px; }

.cat { margin-bottom: 34px; }

.cat-title,
.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.cat-title::after,
.section-title::after {
  content: "";
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--mint);
  opacity: .55;
}

.cat-hint {
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: none;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.tile {
  position: relative;
  border-radius: 14px;
  padding: 6px 4px 8px;
  background: transparent;
  transition: background-color .22s ease;
}

.tile-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 12px;
}

.tile-thumb {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.tile-frame {
  position: absolute;
  inset: 0;
  transform-origin: 50% 52%;
  transition: transform .22s cubic-bezier(.2, .8, .3, 1);
}

.tile-frame img {
  position: absolute;
  max-width: none;
  height: auto;
  filter: drop-shadow(0 5px 8px rgba(70, 50, 40, .22));
}

.tile-btn:hover .tile-frame { transform: scale(1.08) rotate(-1.5deg); }
.tile-btn:active .tile-frame { transform: scale(.96); }

.tile-name {
  display: block;
  margin-top: 2px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink);
  transition: color .2s ease;
}

.tile.is-selected {
  background: var(--mint);
  box-shadow: 0 8px 18px rgba(109, 165, 151, .35);
}

.tile.is-selected .tile-name { color: #fff; }

.tile-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--mint-deep);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .18);
}

.tile.is-selected .tile-check { display: grid; }

/* amount picker (poco / medio / mucho) */

/* Always laid out, only revealed once selected — otherwise picking an
   ingredient would push the rest of the grid down. */
.amounts {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .34);
  visibility: hidden;
  opacity: 0;
  transition: opacity .2s ease;
}

.tile.is-selected .amounts { visibility: visible; opacity: 1; }

.amount {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 4px 0;
  background: transparent;
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}

.amount:hover { background: rgba(255, 255, 255, .3); }

.amount[aria-pressed="true"] {
  background: #fff;
  color: var(--mint-deep);
}

/* ------------------------------ cart ------------------------------ */

.order { padding-bottom: 20px; }

.section-title { margin-top: 34px; }

.cart-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 12px;
}

.cart-item {
  display: grid;
  grid-template-columns: 116px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 12px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow-soft);
  animation: card-in .35s ease both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
}

.cart-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: var(--stack-ratio);
  filter: drop-shadow(0 4px 8px rgba(70, 50, 40, .18));
}

.cart-thumb .sandwich {
  position: absolute;
  inset: 0;
  width: 100%;
  left: auto;
  top: auto;
  transform: none;
}

.cart-body { min-width: 0; }

.cart-name {
  margin: 0 0 4px;
  font-family: "Fredoka", sans-serif;
  font-size: 17px;
  font-weight: 600;
}

.cart-ingredients {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.cart-ingredients em {
  font-style: normal;
  opacity: .72;
  font-size: .92em;
}

.cart-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.price {
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
}

.cart-actions { display: flex; gap: 4px; }

.icon-btn {
  border: 0;
  background: rgba(89, 76, 82, .08);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}

.icon-btn:hover { background: var(--ink); color: #fff; }
.icon-btn.danger:hover { background: #c2596a; }

.add-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 20px;
  border: 2px dashed var(--mint);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .42);
  color: var(--mint-deep);
  cursor: pointer;
  transition: background-color .2s ease, transform .16s ease, border-color .2s ease;
}

.add-slot:hover {
  background: var(--mint-wash);
  border-color: var(--mint-deep);
  transform: translateY(-2px);
}

.add-slot-plus {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mint);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding-bottom: 2px;
}

.add-slot-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .06em;
}

.totals {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow-soft);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
}

.totals-row--muted { color: var(--ink-soft); }

.totals-row--muted .free {
  font-weight: 800;
  color: var(--mint-deep);
  letter-spacing: .04em;
}

.totals-row--total {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: "Fredoka", sans-serif;
  font-size: 22px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ------------------------------ form ------------------------------ */

.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }

.field label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.optional { text-transform: none; letter-spacing: 0; font-weight: 600; opacity: .8; }

.field input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-soft);
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  transition: border-color .18s ease;
}

.field input::placeholder { color: rgba(89, 76, 82, .42); }
.field input:focus { outline: none; border-color: var(--mint); }
.field input.has-error { border-color: #d0798a; }

.error {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #b8556a;
}

/* address predictor */

.autocomplete { position: relative; }

.ac-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 268px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(89, 76, 82, .22);
}

.ac-item {
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1.3;
}

.ac-item strong { display: block; font-size: 15px; font-weight: 700; }
.ac-item span { font-size: 12.5px; color: var(--ink-soft); }

.ac-item:hover,
.ac-item.is-active { background: var(--mint-wash); }

.ac-empty { padding: 12px; font-size: 14px; color: var(--ink-soft); text-align: center; }

.ac-spinner {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 17px;
  height: 17px;
  margin-top: -9px;
  border: 2.5px solid rgba(89, 76, 82, .18);
  border-top-color: var(--mint-deep);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ success ------------------------------ */

.success { padding: 20px 0 10px; }

.success-card {
  padding: 34px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-lift);
  text-align: center;
  animation: card-in .4s ease both;
}

.success-check {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
}

.success-check svg { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }

.success-card h2 {
  margin: 0 0 8px;
  font-size: 27px;
  font-weight: 600;
}

.success-lead { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.5; }

.success-detail {
  margin: 0 0 24px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: 14.5px;
}

.success-detail div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
}

.success-detail dt { color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.success-detail dd { margin: 0; text-align: right; font-weight: 600; }

/* ------------------------------ footer ------------------------------ */

.site-footer {
  padding: 30px 0 40px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(89, 76, 82, .45);
}

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
  .tile-name { font-size: 13px; }
  .cart-item { grid-template-columns: 92px 1fr; grid-template-areas: "img body" "side side"; padding: 12px; }
  .cart-item .cart-thumb { grid-area: img; }
  .cart-body { grid-area: body; }
  .cart-side { grid-area: side; flex-direction: row; align-items: center; justify-content: space-between; margin-top: 4px; }
  .btn { padding: 15px 24px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
