@font-face { font-family: 'Kessler Display'; src: url('../assets/fonts/KesslerDisplay-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: 'Kessler Display'; src: url('../assets/fonts/KesslerDisplay-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: 'Kessler Text'; src: url('../assets/fonts/KesslerText-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: block; }
@font-face { font-family: 'Kessler Text'; src: url('../assets/fonts/KesslerText-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: 'Kessler Text'; src: url('../assets/fonts/KesslerText-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: 'Kessler Text'; src: url('../assets/fonts/KesslerText-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: block; }

:root {
  --ink: #000;
  --paper: #fff;
  --grey: #767676;
  --line: #d9d9d9;
  --soft: #f4f4f4;
  --display: 'Kessler Display', 'Times New Roman', serif;
  --text: 'Kessler Text', Georgia, serif;
  --pad: clamp(16px, 2.6vw, 32px);
  --topbar: 76px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input { -webkit-user-select: text; user-select: text; }
img { display: block; }

/* ---------- type ---------- */
.eyebrow, .label, .field__label, .steps, .btn, .summary dt, .progress__text, .thanks__ref {
  font-family: var(--text);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.eyebrow { margin: 0 0 14px; color: var(--grey); }
.label { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: -.01em; }
em { font-style: italic; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  min-height: 52px;
  padding: 0 22px;
  border-radius: 0;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease), opacity .2s;
}
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 11px; }
.btn--lg { min-height: 64px; padding: 0 48px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--grow { flex: 1; }
.btn--link { border: 0; background: none; padding: 0; min-height: 44px; text-align: left; }
.btn:active { opacity: .7; }
.btn:disabled { border-color: var(--line); color: #b3b3b3; background: var(--paper); cursor: default; opacity: 1; }
.btn--solid:disabled, .btn--solid.is-disabled { background: var(--soft); border-color: var(--soft); color: #8c8c8c; }

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity .45s var(--ease), visibility 0s linear .45s;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.is-active { opacity: 1; visibility: visible; transition: opacity .45s var(--ease); }

.topbar {
  flex: none;
  height: var(--topbar);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--ink);
}
.topbar__logo { height: 26px; width: auto; }
.topbar .btn { justify-self: end; }
.steps { display: flex; gap: 36px; list-style: none; margin: 0; padding: 0; color: #b3b3b3; }
.steps__item span { margin-right: 6px; }
.steps__item.is-current { color: var(--ink); }
.steps__item.is-done { color: var(--grey); }

/* ---------- welcome ---------- */
.screen--welcome { align-items: center; justify-content: center; overflow: hidden; }
.welcome { position: relative; z-index: 1; text-align: center; max-width: 560px; padding: var(--pad); }
.welcome__logo { height: 64px; width: auto; margin: 0 auto 36px; }
.welcome__title { font-size: clamp(56px, 8vw, 96px); line-height: .95; margin-bottom: 28px; }
.welcome__lede { font-size: 18px; line-height: 1.55; font-weight: 300; margin: 0 auto 44px; max-width: 440px; }
.welcome__mark {
  position: absolute;
  width: min(135vh, 135vw);
  height: min(135vh, 135vw);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.welcome__mark path { fill: none; stroke: var(--ink); stroke-width: 1; opacity: .08; vector-effect: non-scaling-stroke; }
.welcome__mark .hex { opacity: .12; }

/* ---------- design ---------- */
.design {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
}
.stage {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px var(--pad) 12px;
}
.tray { width: 100%; height: 100%; max-height: 100%; min-height: 0; flex: 1; display: block; overflow: visible; }
.stage__hint { flex: none; margin: 10px 0 0; font-size: 14px; font-style: italic; color: var(--grey); text-align: center; }

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--ink);
  overflow: hidden;
}
#mithai-groups { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel__group { padding: 14px var(--pad) 12px; border-bottom: 1px solid var(--line); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.panel__head > div { display: flex; align-items: baseline; gap: 10px; }
.panel__head .count { font-family: var(--text); font-size: 13px; color: var(--grey); font-variant-numeric: tabular-nums; }
.panel__head .count.is-full { color: var(--ink); }
.panel__head .count.is-full::after { content: ' ✓'; }
.mithai-name { font-family: var(--display); font-size: 26px; line-height: 1; }
.mithai-name small { display: block; margin-top: 6px; font-family: var(--text); font-size: 12px; color: var(--grey); letter-spacing: .02em; }

.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  appearance: none;
  border: 0;
  background: none;
  padding: 6px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: grab;
  touch-action: none;
  position: relative;
  color: var(--ink);
  font-family: var(--text);
  font-size: 12px;
}
.swatch svg { width: 42px; height: 42px; overflow: visible; transition: transform .2s var(--ease); }
.swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  transition: border-color .2s;
}
.swatch.is-selected::after { border-color: var(--ink); }
.swatch:active svg { transform: scale(.92); }
.fill-all { font-family: var(--text); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 500; border: 0; background: none; padding: 10px 0; min-height: 40px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.fill-all:disabled { color: #b3b3b3; text-decoration: none; }

.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.box-option {
  appearance: none;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 10px 12px;
  min-height: 50px;
  font-family: var(--text);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}
.box-option svg { width: 30px; height: 34px; flex: none; }
.box-option.is-selected { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.panel__footer { flex: none; padding: 14px var(--pad) 16px; border-top: 1px solid var(--ink); }
.progress { margin-bottom: 12px; }
.progress__bar { height: 2px; background: var(--line); overflow: hidden; }
.progress__bar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .35s var(--ease); }
.progress__text { margin: 10px 0 0; color: var(--grey); }
.progress__text strong { color: var(--ink); font-weight: 500; }
.panel__actions { display: flex; gap: 8px; }

/* tray svg */
.tray--interactive { touch-action: none; }
.slot { cursor: pointer; transition: opacity .2s var(--ease); }
.slot__base { stroke: rgba(255,255,255,.22); stroke-width: 1.5; transition: fill .25s var(--ease); }
.slot__shade { pointer-events: none; opacity: 0; transition: opacity .25s; }
.slot.is-filled .slot__base { stroke: rgba(0,0,0,.18); }
.slot.is-filled .slot__shade { opacity: 1; }
.tray.is-targeting .slot:not(.is-target) { opacity: .28; }
.slot.is-target .slot__base { stroke: #fff; stroke-width: 3; stroke-dasharray: 8 6; }
.slot.is-filled.is-target .slot__base { stroke-dasharray: none; stroke-width: 2.5; }
.slot.is-hover .slot__base { stroke-width: 6; stroke-dasharray: none; }
.slot.pop { animation: pop .35s var(--ease); transform-box: fill-box; transform-origin: center; }
.slot.shake { animation: shake .4s; transform-box: fill-box; transform-origin: center; }
@keyframes pop { 0% { transform: scale(.82); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 72px;
  height: 72px;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transform: translate(-100px, -100px);
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.25));
}
.drag-ghost.is-on { opacity: 1; }
.drag-ghost svg { width: 100%; height: 100%; overflow: visible; }

/* ---------- details ---------- */
.details {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
}
.preview {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px var(--pad);
  gap: 18px;
}
.preview__art {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}
/* Tray + lid as one fixed composition that scales as a unit, so the lid
   always peeks out by the same amount whatever the screen size. */
.preview__stage {
  position: relative;
  aspect-ratio: 1.4;
  width: min(100cqw, 140cqh);
}
.tray--preview {
  position: absolute;
  z-index: 1;
  left: 0;
  bottom: 0;
  width: 71.4%; /* = full stage height: a square tray */
  height: 100%;
  max-width: none;
}
.preview__lid {
  position: absolute;
  z-index: 0;
  right: 1%;
  top: 2%;
  height: 76%;
  width: auto;
  transform: rotate(12deg);
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.18));
}
.summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; margin: 0; }
.summary div { text-align: center; }
.summary dt { color: var(--grey); margin-bottom: 6px; }
.summary dd { margin: 0; display: flex; gap: 10px; justify-content: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.summary dd span { display: inline-flex; align-items: center; gap: 5px; }
.summary dd i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.form {
  border-left: 1px solid var(--ink);
  padding: 28px var(--pad) 40px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.form__title { font-size: 38px; line-height: 1.05; margin-bottom: 26px; }
.field { display: block; margin-bottom: 14px; }
.field__label { display: block; margin-bottom: 6px; }
.field__label em { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--grey); margin-left: 4px; }
.field input {
  width: 100%;
  height: 50px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--text);
  font-size: 18px;
  color: var(--ink);
  padding: 0 2px;
  outline: none;
  -webkit-appearance: none;
}
.field input::placeholder { color: #a8a8a8; font-style: italic; }
.field input:focus { border-bottom-width: 2px; }
.field.is-invalid input { border-bottom-color: var(--ink); border-bottom-style: dashed; }
.field.is-invalid .field__label::after { content: ' · required'; text-transform: none; letter-spacing: 0; font-weight: 400; font-style: italic; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* quantity + price (details screen) */
.order-box { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 0 0 18px; margin: 0 0 18px; border-bottom: 1px solid var(--ink); }
.qty__control { display: flex; align-items: center; border: 1px solid var(--ink); width: max-content; }
.qty__btn { width: 52px; height: 48px; border: 0; background: var(--paper); color: var(--ink); font-family: var(--text); font-size: 24px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.qty__btn:active { background: var(--soft); }
.qty__btn:disabled { color: #c4c4c4; cursor: default; }
.qty__value { min-width: 56px; text-align: center; font-family: var(--display); font-size: 28px; border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); line-height: 48px; font-variant-numeric: tabular-nums; }
.order-box__meta { margin: 0; text-align: right; font-size: 15px; line-height: 1.5; color: var(--grey); }
.order-box__meta strong { font-family: var(--display); font-weight: 400; font-size: 24px; color: var(--ink); }
.no-payments .steps__item--pay { display: none; }

.total { margin: 22px 0 0; border-top: 1px solid var(--ink); }
.total div { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
.total dt { font-family: var(--text); font-weight: 500; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--grey); }
.total dd { margin: 0; font-size: 17px; }
.total div:first-child dd { font-family: var(--display); font-size: 26px; }
.form__note { font-size: 13px; color: var(--grey); line-height: 1.5; margin: 18px 0 14px; }
.form__error { min-height: 1em; font-size: 14px; margin: 0 0 12px; font-style: italic; }

/* ---------- thanks ---------- */
.screen--thanks { align-items: center; justify-content: center; }
.thanks { text-align: center; max-width: 560px; padding: var(--pad); }
.tray--thanks { width: 260px; height: 260px; margin: 0 auto 28px; flex: none; }
.thanks__title { font-size: clamp(44px, 6vw, 68px); line-height: 1; margin-bottom: 18px; }
.thanks__lede { font-size: 18px; font-weight: 300; line-height: 1.55; margin: 0 0 22px; }
.thanks__ref { margin: 0 0 32px; color: var(--grey); }
.thanks__ref strong { color: var(--ink); margin-left: 8px; letter-spacing: .12em; }
.thanks__timer { font-size: 13px; color: var(--grey); margin-top: 20px; font-style: italic; }

/* ---------- ByteBlock credit (welcome + thank-you screens) ---------- */
.credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  font-family: var(--text);
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--grey);
}
.credit img { width: 17px; height: auto; }
.credit strong { font-weight: 500; color: var(--ink); }
.credit__phone { font-variant-numeric: tabular-nums; color: var(--ink); }
.credit__sep { color: #c4c4c4; }

/* ---------- "Powered by ByteBlock" badge (welcome, design, details) ---------- */
.powered {
  position: absolute;
  left: calc(var(--pad) + env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 11px 6px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-family: var(--text);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--grey);
  pointer-events: none;
}
.powered img { width: 14px; height: auto; }
.powered strong { font-weight: 500; color: var(--ink); }
/* policy links (welcome screen, bottom right) */
.legal {
  position: absolute;
  right: calc(var(--pad) + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 16px;
  max-width: 60vw;
  font-family: var(--text);
  font-size: 12px;
}
.legal a, .form__note a { color: var(--grey); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line); }
.legal a { padding: 6px 0; }

/* keep the design hint clear of the badge */
.stage { padding-bottom: 52px; }

/* ---------- modal / toast ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal[hidden] { display: none; }
.modal__card { background: var(--paper); border: 1px solid var(--ink); padding: 36px; width: min(420px, 90vw); text-align: center; }
.modal__card--wide { width: min(560px, 92vw); text-align: left; }
.modal__title { font-size: 34px; margin-bottom: 12px; }
.modal__card p { font-size: 17px; margin: 0 0 24px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0 20px; }
.admin-stats div { border: 1px solid var(--line); padding: 12px; }
.admin-stats dt { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--grey); }
.admin-stats dd { margin: 6px 0 0; font-family: var(--display); font-size: 30px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  padding: 14px 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
  max-width: 90vw;
  text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- portrait iPad ---------- */
@media (orientation: portrait), (max-width: 900px) {
  .design { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .stage { padding-top: 16px; }
  .panel { border-left: 0; border-top: 1px solid var(--ink); max-height: 52vh; }
  #mithai-groups { display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; flex: none; }
  #mithai-groups .panel__group { border-right: 1px solid var(--line); padding: 14px 14px 12px; }
  #mithai-groups .panel__group:last-child { border-right: 0; }
  .swatches { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .swatch svg { width: 42px; height: 42px; }
  .mithai-name { font-size: 22px; white-space: nowrap; }
  #mithai-groups .panel__head { flex-direction: column; align-items: flex-start; gap: 0; margin-bottom: 2px; }
  #mithai-groups .fill-all { min-height: 32px; padding: 6px 0; }
  .panel > .panel__group { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
  .panel > .panel__group .panel__head { margin: 0; }
  .details { grid-template-columns: 1fr; grid-template-rows: minmax(0, 42%) minmax(0, 1fr); }
  .form { border-left: 0; border-top: 1px solid var(--ink); }
  .preview { padding: 16px var(--pad); gap: 10px; }
  /* the panel/form fill the bottom edge in portrait, so the badge would cover buttons */
  .screen--design .powered, .screen--details .powered { display: none; }
  .stage { padding-bottom: 12px; }
}

/* ---------- short landscape screens (iPad mini, or Safari with its toolbar) ---------- */
@media (orientation: landscape) and (max-height: 760px) {
  :root { --topbar: 60px; }
  .topbar__logo { height: 22px; }
  .panel > .panel__group { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
  .panel > .panel__group .panel__head { margin: 0; }
  .box-option { min-height: 44px; padding: 6px 10px; }
  .panel__group { padding-top: 10px; padding-bottom: 8px; }
  .mithai-name { font-size: 23px; }
  .fill-all { min-height: 34px; padding: 6px 0; }
  .swatch { padding: 4px 0 2px; gap: 4px; }
  .swatch svg { width: 38px; height: 38px; }
  .panel__footer { padding-top: 10px; padding-bottom: 12px; }
  .progress { margin-bottom: 10px; }
  .progress__text { margin-top: 6px; }
  .btn { min-height: 46px; }
  .stage { padding-top: 12px; }
  .form { padding-top: 20px; }
  .form__title { font-size: 32px; margin-bottom: 16px; }
  .field { margin-bottom: 10px; }
  .field input { height: 44px; }
}
