/* Ordering on a guest check: the menu is the cafe's printed form, the check is yours.
   Shared by the coffee order page and the camp store. */

/* ---------- page opener ---------- */

.order-head {
  grid-column: 1;
  grid-row: 1;
  padding: var(--s-6) 0 var(--s-5);
  border-bottom: 3px double var(--rule-strong);
}
.order-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem);
  line-height: 1.05;
  color: var(--cream);
}
.order-lede {
  margin-top: var(--s-2);
  max-width: 44ch;
  font-family: var(--script);
  font-weight: 700;
  font-size: var(--step-2);
  line-height: 1.25;
  color: var(--teal);
}
.field-serial {
  font-size: var(--step-2);
  line-height: 1;
  transform: rotate(-2deg);
  transform-origin: left center;
}

.form-row {
  display: inline-grid;
  grid-template-columns: auto auto auto auto;
  margin-top: var(--s-5);
  border: 1px solid var(--rule-strong);
}
.field-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s-2);
  margin: 0;
  min-width: 0;
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-left: 1px solid var(--rule-strong);
}
.field-box:first-child { border-left: 0; }
.field-box legend { float: left; width: 100%; padding: 0; }
.field-value {
  font-weight: 700;
  font-stretch: 80%;
  font-size: var(--step-1);
  line-height: 1.2;
  white-space: nowrap;
  color: var(--cream);
}

.fulfillment {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: var(--s-4);
  row-gap: var(--s-2);
}
.fulfillment legend { grid-column: 1 / -1; }

/* ---------- the pad: menu + check ---------- */

.pad {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 var(--s-6) var(--s-9);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
  grid-template-rows: auto 1fr;
  gap: 0 var(--s-7);
  align-items: start;
}

.menu { grid-column: 1; grid-row: 2; min-width: 0; outline: none; }

.cat-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--ground);
  border-bottom: 1px solid var(--rule-strong);
}
.cat-nav ul {
  display: flex;
  gap: var(--s-5);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-nav ul::-webkit-scrollbar { display: none; }
.cat-nav a {
  display: block;
  padding: var(--s-4) 0 calc(var(--s-4) - 3px);
  border-bottom: 3px solid transparent;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 700;
  font-stretch: 75%;
  font-size: var(--step-1);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.cat-nav a:hover { color: var(--ink); }
.cat-nav a[aria-current='true'] { color: var(--pink); border-bottom-color: var(--pink); }

.col-heads,
.row-hit {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 112px;
}
.col-heads {
  border-bottom: 3px double var(--rule-strong);
}
.col-heads span {
  padding: var(--s-2) var(--s-3);
  font-size: var(--step--1);
  font-weight: 650;
  font-stretch: 75%;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--print);
}
.col-heads span:first-child { border-right: 1px solid var(--rule-strong); text-align: center; }
.col-heads span:last-child { border-left: 1px solid var(--rule-strong); text-align: right; }

.menu-loading { padding: var(--s-7) 0; color: var(--ink-2); }

.menu-section { scroll-margin-top: 64px; }
.menu-section h2 {
  padding: var(--s-8) 0 var(--s-3) 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: var(--step-3);
  line-height: 1.05;
  color: var(--cream);
  border-bottom: 1px solid var(--rule-strong);
  transition: opacity 240ms var(--ease-out);
}
.menu-section:first-child h2 { padding-top: var(--s-6); }

.rows { margin: 0; padding: 0; list-style: none; }

.row {
  position: relative;
  border-bottom: 1px solid var(--rule);
  transition: opacity 240ms var(--ease-out), background-color 240ms var(--ease-out), box-shadow 240ms var(--ease-out);
}
.row-hit {
  width: 100%;
  min-height: var(--row);
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  align-items: stretch;
}
.row-hit:hover:not(:disabled) { background: var(--hand-soft); }
.row-hit:focus-visible { outline-offset: -2px; }

.cell-add {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--rule);
}
.add-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--pink);
  border-radius: 50%;
  color: var(--pink);
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 200ms var(--ease-out);
}
.row-hit:hover:not(:disabled) .add-mark { background: var(--pink); color: var(--on-action); box-shadow: 0 4px 12px -4px rgb(255 46 154 / 0.8); }
.row.open .add-mark { background: var(--pink); color: var(--on-action); transform: rotate(45deg); }

.cell-desc {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: var(--s-3) var(--s-4);
}
.item-name {
  font-size: var(--step-1);
  font-weight: 650;
  line-height: 1.25;
}
.item-desc {
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.4;
}
.cell-amt {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--s-3);
  border-left: 1px solid var(--rule);
  font-family: var(--script);
  font-weight: 700;
  font-size: var(--step-1);
  color: var(--teal);
}

.row.soldout .item-name {
  text-decoration: line-through;
  text-decoration-color: var(--print);
  text-decoration-thickness: 2px;
}
.row.soldout .item-name,
.row.soldout .item-desc { color: var(--ink-2); }
.row.soldout .add-mark { border-color: var(--ink-2); color: var(--ink-2); opacity: 0.4; }
.row.soldout .cell-amt {
  color: var(--print);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* One item held at a time: the open row lifts, the rest of the menu dims. */
.menu.focusing .row:not(.open),
.menu.focusing .menu-section h2 { opacity: 0.32; }
.row.open {
  z-index: 2;
  background: var(--night-3);
  box-shadow: var(--sheet-shadow), inset 0 0 0 1px rgb(46 232 212 / 0.35);
  border-bottom-color: transparent;
}

.row-options {
  padding: var(--s-2) var(--s-4) var(--s-5) calc(72px + var(--s-4));
  animation: unfold 320ms var(--ease-out) both;
}
@keyframes unfold {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.opt-group {
  margin: 0 0 var(--s-4);
  padding: 0;
  border: 0;
}
.opt-group legend {
  padding: 0;
  margin-bottom: var(--s-2);
}
.opt-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-5);
}
.opt-choices .tick { font-size: var(--step-0); font-weight: 600; }
.opt-price { color: var(--ink-2); font-weight: 500; }

.opt-note {
  display: block;
  width: 100%;
  max-width: 460px;
  margin: 0 0 var(--s-5);
  padding: var(--s-2) 0;
  border: 0;
  border-bottom: 1px solid var(--rule-strong);
  background: transparent;
  font-family: var(--script);
  font-size: var(--step-1);
  color: var(--hand);
}
.opt-note::placeholder { color: rgb(from var(--hand) r g b / 0.62); }
.opt-note:focus { outline: none; border-bottom: 2px solid var(--hand); margin-bottom: calc(var(--s-5) - 1px); }

.opt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-4);
}
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
}
.stepper button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--hand);
}
.stepper button:hover:not(:disabled) { background: var(--hand-soft); }
.stepper button:disabled { color: var(--ink-2); opacity: 0.4; }
.stepper output {
  min-width: 2.25ch;
  text-align: center;
  font-family: var(--script);
  font-weight: 700;
  font-size: var(--step-2);
  color: var(--hand);
}

/* ---------- the check ---------- */

.check {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  position: sticky;
  top: var(--s-5);
  margin-top: var(--s-5);
}
.check-under {
  position: absolute;
  inset: 8px -7px -7px 8px;
  background: var(--copy);
}
.check-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Fits below the site header on first load, and when stuck to the top. */
  max-height: calc(100dvh - 180px);
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 140px;
  padding: 0 var(--s-5) 0;
  background: var(--sheet);
  scrollbar-width: thin;
}
.check-sheet .perf {
  flex: none;
  margin: 0 calc(-1 * var(--s-5));
}

.check-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-top: var(--s-4);
}
.check-title {
  flex: 1;
  font-size: var(--step-2);
  font-weight: 800;
  font-stretch: 62%;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.check-no { white-space: nowrap; }
.check-no .serial { font-size: var(--step-2); display: inline-block; }
.serial.stamp { animation: stamp 520ms var(--ease-out) both; }
@keyframes stamp {
  0% { transform: scale(1.8) rotate(-6deg); opacity: 0; }
  60% { transform: scale(0.94) rotate(-2deg); opacity: 1; }
  100% { transform: scale(1) rotate(-2deg); opacity: 1; }
}
.sheet-close { display: none; }

.check-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  padding: var(--s-2) 0 var(--s-3);
}
.check-meta .hand { font-size: var(--step-1); }

.check-cols,
.check-line {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 76px;
}
.check-cols {
  border-top: 1px solid var(--rule-strong);
  border-bottom: 3px double var(--rule-strong);
}
.check-cols span {
  padding: 4px 6px;
  font-size: 0.6875rem;
  font-weight: 650;
  font-stretch: 75%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--print);
}
.check-cols span:first-child { border-right: 1px solid var(--rule-strong); text-align: center; }
.check-cols span:last-child { border-left: 1px solid var(--rule-strong); text-align: right; }

.check-lines { margin: 0; padding: 0; list-style: none; }
.check-line {
  min-height: var(--row);
  border-bottom: 1px solid var(--rule);
}
.check-line > * { padding: 6px; }
.line-qty {
  display: grid;
  place-items: start center;
  padding-top: 8px;
  border-right: 1px solid var(--rule);
  font-family: var(--script);
  font-weight: 700;
  font-size: var(--step-2);
  line-height: 1.2;
  color: var(--hand);
}
.line-item { min-width: 0; padding-top: 10px; padding-left: 10px; }
.line-name {
  font-family: var(--script);
  font-size: var(--step-1);
  line-height: 1.2;
  color: var(--hand);
}
.line-mods {
  margin-top: 2px;
  font-family: var(--script);
  font-size: 0.9375rem;
  line-height: 1.3;
  color: rgb(from var(--hand) r g b / 0.82);
}
.line-tools {
  display: flex;
  gap: 2px;
  margin: 2px 0 0 -10px;
}
.line-tools button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 36px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-2);
}
.line-tools button:hover { background: var(--hand-soft); color: var(--hand); }
.line-tools .icon { width: 1.05em; height: 1.05em; }
.line-amt {
  padding-top: 10px;
  border-left: 1px solid var(--rule);
  text-align: right;
  font-family: var(--script);
  font-size: var(--step-1);
  line-height: 1.2;
  color: var(--hand);
}
.line-new .line-qty,
.line-new .line-name,
.line-new .line-mods,
.line-new .line-amt { animation: write 640ms var(--ease-out) both; }
.line-new .line-mods { animation-delay: 140ms; }
.line-new .line-amt { animation-delay: 220ms; }
@keyframes write {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.check-line.empty .line-item { color: var(--hand); }

.check-totals {
  display: grid;
  grid-template-columns: 1fr 96px;
  align-items: baseline;
  row-gap: 2px;
  padding: var(--s-3) 0 var(--s-2);
}
.check-totals:empty { display: none; }
.check-totals .form-label { text-align: right; padding-right: var(--s-3); }
.check-totals .hand { text-align: right; font-size: var(--step-1); }
.total-row { margin-top: var(--s-2); }
.total-figure {
  position: relative;
  display: inline-block;
  font-family: var(--script);
  font-weight: 700;
  font-size: var(--step-2);
  color: var(--hand);
}
.total-figure svg {
  position: absolute;
  left: -18px;
  top: -10px;
  width: calc(100% + 34px);
  height: calc(100% + 18px);
  color: var(--hand);
  overflow: visible;
}
.total-figure svg use { stroke-dasharray: 420; stroke-dashoffset: 0; animation: loop 700ms 120ms var(--ease-out) both; }
@keyframes loop { from { stroke-dashoffset: 420; } }
.totals-note {
  grid-column: 1 / -1;
  padding-top: var(--s-2);
  font-size: var(--step--1);
  color: var(--ink-2);
  text-align: right;
}

/* details, still on the same sheet */
.check-form { padding-top: var(--s-3); border-top: 3px double var(--rule-strong); }
.form-title {
  margin: var(--s-2) 0 var(--s-2);
  font-size: var(--step-1);
  font-weight: 800;
  font-stretch: 70%;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.ruled-field { display: flex; flex-direction: column; padding-top: var(--s-3); }
/* Keep a focused field and its error clear of the sticky send button. */
.ruled-field > * { scroll-margin-bottom: 140px; }
.ruled-field input,
.ruled-field select,
.ruled-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid var(--rule-strong);
  border-radius: 0;
  background: transparent;
  font-family: var(--script);
  font-size: var(--step-1);
  color: var(--hand);
}
.ruled-field textarea { resize: vertical; min-height: 64px; line-height: 1.4; }
.ruled-field select {
  appearance: none;
  padding-right: 32px;
  background: url('/icons/chevron-down.svg') right 4px center / 18px no-repeat;
  cursor: pointer;
}
.ruled-field input:focus,
.ruled-field select:focus,
.ruled-field textarea:focus {
  outline: none;
  border-bottom: 2px solid var(--hand);
  background-color: var(--hand-soft);
}
.ruled-field [aria-invalid='true'] { border-bottom: 2px solid var(--print); }
.field-error {
  padding-top: 4px;
  color: var(--print);
  font-size: var(--step--1);
  font-weight: 600;
}
.optional {
  color: var(--ink-2);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.ruled-split { display: grid; grid-template-columns: 1fr 112px; gap: var(--s-4); }
.address { margin: 0; padding: 0; border: 0; min-width: 0; }
.field-note { padding-top: var(--s-2); font-size: var(--step--1); color: var(--ink-2); }
.pay-box {
  margin-top: var(--s-5);
  padding: var(--s-3);
  border: 1px dashed var(--rule-strong);
}
.pay-box p { margin-top: 4px; font-size: 0.875rem; color: var(--ink-2); }

.check-error {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding: var(--s-3);
  background: rgb(192 19 111 / 0.09);
  color: var(--print);
  font-weight: 600;
  font-size: 0.9375rem;
}

.check-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s-1);
  margin: var(--s-3) calc(-1 * var(--s-5)) 0;
  padding: var(--s-3) var(--s-5) var(--s-5);
  background: linear-gradient(to bottom, rgb(246 238 220 / 0), var(--sheet) 14px);
}
.btn-send { min-height: 56px; }
.btn-send .sum { font-family: var(--script); font-weight: 700; font-stretch: 100%; }

/* Sending: the top copy tears away along the perforation. */
.check-sheet.torn {
  transform-origin: 8% 0;
  animation: tear 900ms cubic-bezier(0.55, 0, 0.75, 0.2) 420ms forwards;
}
@keyframes tear {
  0% { transform: none; }
  22% { transform: rotate(-2.2deg) translateY(-4px); }
  100% { transform: translate(-40px, -130vh) rotate(-10deg); }
}

/* ---------- mobile: the check docks and tears up ---------- */

.check-dock, .scrim { display: none; }

@media (max-width: 960px) {
  .order-head { padding: var(--s-4) 0 var(--s-5); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .field-value { white-space: normal; }
  .fulfillment { grid-column: 1 / -1; border-bottom: 1px solid var(--rule-strong); }
  /* On phones the serial lives on the check sheet only. */
  .form-row .field-box:nth-child(2) { display: none; }
  .form-row .field-box:nth-child(3) { border-left: 0; }

  .pad {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 var(--s-4) 120px;
    gap: 0;
  }
  .col-heads, .row-hit { grid-template-columns: 56px minmax(0, 1fr) 84px; }
  .row-options { padding-left: var(--s-4); }
  .cell-desc { padding: var(--s-3); }
  .menu-section h2 { padding-top: var(--s-7); }

  .check {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    margin: 0;
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 420ms var(--ease-out), visibility 0s 420ms;
  }
  .check.open {
    transform: none;
    visibility: visible;
    transition: transform 420ms var(--ease-out), visibility 0s;
  }
  .check-under { display: none; }
  .check-sheet {
    max-height: 90dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: -8px -10px 0 0;
    border: 0;
    background: transparent;
    color: var(--ink);
  }

  .check-dock:not([hidden]) {
    position: fixed;
    left: var(--s-3);
    right: var(--s-3);
    bottom: calc(var(--s-3) + env(safe-area-inset-bottom));
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 60px;
    padding: 0 var(--s-4);
    border: 0;
    border-radius: 4px;
    background: var(--pink);
    color: var(--on-action);
    box-shadow: 0 10px 30px -8px rgb(0 0 0 / 0.6), 0 8px 24px -8px rgb(255 46 154 / 0.7);
    font-weight: 700;
    font-stretch: 85%;
  }
  .dock-count { text-align: left; font-weight: 500; }
  .dock-cta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--step-1); }
  .dock-total { text-align: right; font-family: var(--script); font-size: var(--step-1); }
  .dock-bump { animation: bump 420ms var(--ease-out); }
  @keyframes bump { 40% { transform: translateY(-6px); } }

  .scrim:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(10 4 14 / 0.6);
    animation: fade 300ms var(--ease-out) both;
  }
  @keyframes fade { from { opacity: 0; } }
}

@media (max-width: 420px) {
  .field-value { font-size: var(--step-0); }
  .col-heads, .row-hit { grid-template-columns: 52px minmax(0, 1fr) 76px; }
  .cell-amt { padding: var(--s-3) var(--s-2); }
}
