/* ════════════════════════════════════════════════════════════════════════════
   Farmbox — the customer application
   ════════════════════════════════════════════════════════════════════════════ */

.app-body { background: var(--bone); }
.app-who { color: var(--stone); letter-spacing: .05em; }
@media (max-width: 720px) { .app-who { display: none; } }

/* ── Gate ───────────────────────────────────────────────────────────────── */
.gate { min-height: 74vh; display: grid; place-items: center; padding: var(--s7) var(--gutter); }
.gate__card { max-width: 520px; text-align: center; }
.gate__card h2 { margin: 0 0 16px; }

/* ── Week bar ───────────────────────────────────────────────────────────── */
.weekbar { background: var(--forest); color: var(--bone); }
.weekbar__inner {
  display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 64px); align-items: flex-end;
  padding-block: clamp(26px, 3.4vw, 44px);
}
.weekbar .eyebrow { color: var(--leaf); }
.weekbar .label { color: rgba(246,242,233,.74); }
.weekbar__date {
  font-size: clamp(1.7rem, 3.2vw, 2.7rem); color: var(--bone);
  font-variation-settings: 'opsz' 60; letter-spacing: -.022em; line-height: 1;
}
.weekbar__cut, .weekbar__sub { display: flex; flex-direction: column; }
.weekbar__cut strong, .weekbar__sub strong { font-weight: 400; font-size: 1.06rem; color: var(--bone); }
.weekbar__cut .micro, .weekbar__sub .micro { color: rgba(246,242,233,.76); margin-top: 5px; }
.weekbar__sub { margin-left: auto; text-align: right; align-items: flex-end; }
@media (max-width: 760px) { .weekbar__sub { margin-left: 0; text-align: left; align-items: flex-start; } }

/* ── Grid ───────────────────────────────────────────────────────────────── */
.app__grid {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(380px, 42%);
  gap: clamp(24px, 3vw, 56px);
  padding-block: var(--s6) var(--s9);
  align-items: start;
}
@media (max-width: 1140px) { .app__grid { grid-template-columns: minmax(0,1fr) 330px; } }
@media (max-width: 960px)  { .app__grid { grid-template-columns: minmax(0, 1fr); } }

/* ── Category bar ───────────────────────────────────────────────────────── */
.catalogue { min-width: 0; }

.catbar {
  position: sticky; top: 78px; z-index: 30;
  background: color-mix(in srgb, var(--bone) 92%, transparent);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s6);
  padding-block: 12px;
}
.catbar__scroll { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.catbar__scroll::-webkit-scrollbar { display: none; }
.catbar__scroll button {
  flex: none; cursor: pointer; background: transparent; border: 1px solid transparent;
  font-family: var(--sans); font-size: var(--fs-eyebrow); font-weight: 600;
  letter-spacing: .15em; text-transform: uppercase; color: var(--stone);
  padding: 9px 14px; white-space: nowrap;
  transition: all var(--t-fast) var(--ease-out);
}
.catbar__scroll button:hover { color: var(--forest); }
.catbar__scroll button[aria-current='true'] { color: var(--bone); background: var(--forest); border-color: var(--forest); }
.catbar__tools { display: flex; gap: 14px; align-items: center; margin-top: 11px; }
.catbar__search { flex: 1; padding: 9px 13px; font-size: .95rem; }
.catbar__toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  font-family: var(--sans); font-size: var(--fs-micro); letter-spacing: .07em;
  text-transform: uppercase; color: var(--stone);
}
.catbar__toggle input { accent-color: var(--leaf-deep); width: 15px; height: 15px; }

/* ── Catalogue sections ─────────────────────────────────────────────────── */
.catsec { margin-bottom: var(--s8); scroll-margin-top: 170px; }
.catsec__head { display: flex; align-items: baseline; gap: 16px; margin-bottom: var(--s5); padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.catsec__head h2 { font-size: clamp(1.4rem, 2vw, 1.8rem); }
.catsec__head p { font-size: var(--fs-small); color: var(--stone-2); margin: 0; flex: 1; max-width: none; }
/* The count sits in the same column in every section rather than wherever the
   blurb happens to end. */
.catsec__head .micro { flex: none; width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: clamp(12px, 1.4vw, 20px); }

.item {
  position: relative; background: var(--paper); border: 1px solid var(--rule);
  display: flex; flex-direction: column;
  transition: border-color var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out), box-shadow var(--t-mid) var(--ease-out);
}
.item:hover { border-color: var(--stone-2); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.item.is-in-box { border-color: var(--leaf-deep); }
/* A line you cannot take is quieter, not unreadable: the photograph recedes,
   the words stay at full contrast. */
.item.is-blocked { background: var(--bone); }
.item.is-blocked .item__media { opacity: .42; }
.item.is-blocked:hover { transform: none; box-shadow: none; border-color: var(--rule); }

.item__media { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--sand); }
.item__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease-out); }
.item:hover .item__media img { transform: scale(1.045); }
.item__slots {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--sans); font-size: 9.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; background: rgba(16,20,16,.72); color: var(--bone);
  padding: 4px 8px 3px; backdrop-filter: blur(6px);
}
.item__flag {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--sans); font-size: 9px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; padding: 4px 8px 3px;
  background: var(--terracotta); color: #fff;
}
.item__flag--season { background: var(--clay-deep); }
.item__flag--out { background: var(--ink); }

.item__body { padding: 13px 14px 14px; display: flex; flex-direction: column; flex: 1; gap: 4px; }
.item__name { font-size: 1.03rem; line-height: 1.24; font-variation-settings: 'opsz' 24; }
.item__portion { font-family: var(--sans); font-size: var(--fs-micro); letter-spacing: .05em; color: var(--stone-2); }
.item__actions { display: flex; align-items: center; gap: 8px; margin-top: 11px; }

.qty { display: inline-flex; align-items: stretch; border: 1px solid var(--rule); }
.qty button {
  min-width: 34px; min-height: 34px; border: 0; background: transparent; cursor: pointer; color: var(--forest);
  font-family: var(--sans); font-size: 15px; line-height: 1;
  transition: background var(--t-fast) var(--ease-out);
}
.qty button:hover { background: var(--sand); }
.qty button[disabled] { opacity: .3; cursor: default; background: transparent; }
.qty span { min-width: 26px; display: grid; place-items: center; font-family: var(--sans); font-size: .82rem; font-weight: 600; border-inline: 1px solid var(--rule); }

.item__add {
  flex: 1; cursor: pointer; border: 1px solid var(--forest); background: var(--forest); color: var(--bone);
  font-family: var(--sans); font-size: 10px; font-weight: 600; letter-spacing: .17em; text-transform: uppercase;
  padding: 9px 10px;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.item__add:hover:not([disabled]) { background: var(--leaf); border-color: var(--leaf); color: var(--forest); }
.item__add[disabled] { background: transparent; color: var(--stone-2); border-color: var(--rule); cursor: default; }
.item__blurb { display: none; }

/* ── The box panel ──────────────────────────────────────────────────────── */
.boxpanel { position: sticky; top: 94px; }
@media (max-width: 960px) {
  .boxpanel {
    position: fixed; inset: auto 0 0 0; top: auto; z-index: 70;
    transform: translateY(100%); transition: transform 420ms var(--ease-out);
    max-height: 88svh; overflow: auto;
    box-shadow: 0 -20px 60px -20px rgba(16,20,16,.4);
  }
  .boxpanel.is-open { transform: none; }
}
.boxpanel__inner { background: var(--paper); border: 1px solid var(--rule); padding: clamp(18px, 2vw, 24px); }
.boxpanel__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.boxpanel__tier { font-family: var(--serif); font-size: 1.3rem; font-weight: 400; font-variation-settings: 'opsz' 36; }
.boxpanel__clear { background: none; border: 0; cursor: pointer; color: var(--stone); text-decoration: underline; text-underline-offset: 3px; padding: 8px 2px; min-height: 32px; }
.boxpanel__clear:hover { color: var(--terracotta); }

/* the crate visual */
.crate {
  position: relative; height: clamp(280px, 28vw, 370px); overflow: hidden;
  background: radial-gradient(ellipse at 50% 25%, #f5f0e6, #ded6c6);
  color: rgba(246,242,233,.34);
  display: grid; place-items: center; margin-bottom: 0;
}
.crate canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* The gauge sits over the scene, so it needs its own legibility. */
.crate .crate__gauge {
  position: absolute; left: 16px; bottom: 10px; text-align: left;
  color: var(--forest); text-shadow: 0 1px 8px #f5f0e6;
  pointer-events: none;
}
.crate--flat { height: auto; background: none; }
.crate__gauge { position: relative; text-align: center; color: var(--bone); }
.crate__gauge b { font-family: var(--serif); font-size: 2.9rem; font-variation-settings: 'opsz' 72; line-height: 1; letter-spacing: -.03em; }
.crate__gauge span { font-family: var(--serif); font-size: 1.2rem; opacity: .58; margin-left: 4px; }
.crate__gauge em { display: block; font-family: var(--sans); font-style: normal; font-size: 9.5px; letter-spacing: .26em; text-transform: uppercase; opacity: .82; margin-top: 8px; }
.crate.is-bump { animation: crateBump 420ms var(--ease-out); }
@keyframes crateBump { 0%,100% { transform: none; } 34% { transform: translateY(3px) scale(.992); } }

.meters { display: grid; gap: 12px; margin-bottom: 18px; }
.meter__row { display: flex; justify-content: space-between; font-family: var(--sans); font-size: var(--fs-micro); letter-spacing: .1em; text-transform: uppercase; color: var(--stone); margin-bottom: 6px; }
.meter__row b { color: var(--forest); font-weight: 600; }
.meter__track { height: 3px; background: var(--sand); overflow: hidden; }
.meter__track i { display: block; height: 100%; width: 0; background: var(--leaf-deep); transition: width 560ms var(--ease-out); }
.meter__track--clay i { background: var(--clay); }
.meter__track i.is-max { background: var(--terracotta); }

.valuebar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  border-block: 1px solid var(--rule); padding: 14px 0; margin-bottom: 16px;
}
.valuebar .label { margin-bottom: 5px; }
.valuebar b { font-family: var(--serif); font-size: 1.28rem; font-weight: 400; font-variation-settings: 'opsz' 32; display: block; }
.valuebar__per {
  display: block; font-style: normal; font-family: var(--sans); font-size: 10px;
  letter-spacing: .09em; color: var(--stone-2); margin-top: 5px; line-height: 1.4;
}
.valuebar__note { margin: -4px 0 16px; color: var(--stone); line-height: 1.5; }
.valuebar__note.is-nudge { color: var(--clay-deep); }
.valuebar__note.is-good { color: var(--leaf-deep); }
.valuebar div:first-child b { color: var(--stone); text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--stone) 45%, transparent); }
.valuebar div:last-child b { color: var(--leaf-deep); }

.boxlist { list-style: none; margin: 0 0 16px; padding: 0; max-height: 40svh; overflow: auto; }
@media (max-width: 960px) { .boxlist { max-height: none; } }
.boxlist li {
  display: flex; align-items: center; gap: 11px; padding: 8px 0;
  border-bottom: 1px solid var(--rule-soft);
  animation: lineIn 460ms var(--ease-out) both;
}
@keyframes lineIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.boxlist li.is-going { animation: lineOut 280ms var(--ease-out) both; }
@keyframes lineOut { to { opacity: 0; transform: translateX(14px); height: 0; padding: 0; } }
.boxlist img { width: 40px; height: 40px; object-fit: cover; flex: none; }
.boxlist__t { flex: 1; min-width: 0; }
.boxlist__t b { display: block; font-weight: 400; font-size: .95rem; line-height: 1.24; }
.boxlist__t span { font-family: var(--sans); font-size: 10.5px; letter-spacing: .05em; color: var(--stone-2); }
.boxlist__x {
  border: 0; background: none; cursor: pointer; color: var(--stone);
  font-size: 17px; line-height: 1; min-width: 32px; min-height: 32px;
  display: grid; place-items: center; flex: none;
}
.boxlist__x:hover { color: var(--terracotta); }
.boxpanel__empty { padding: 6px 0 18px; }
.boxpanel__foot { border-top: 1px solid var(--rule); padding-top: 16px; }
.boxpanel__foot .micro { margin-top: 10px; color: var(--stone-2); line-height: 1.5; }

/* ── Fly-to-box animation ───────────────────────────────────────────────── */


/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 26px);
  background: var(--forest); color: var(--bone);
  font-family: var(--sans); font-size: var(--fs-small); letter-spacing: .02em;
  padding: 13px 20px; max-width: min(560px, calc(100vw - 32px));
  opacity: 0; pointer-events: none; z-index: 220;
  transition: opacity var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out);
  border-left: 3px solid var(--leaf);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-warn { border-left-color: var(--clay); }
.toast.is-bad { border-left-color: var(--terracotta); }
@media (max-width: 960px) { .toast { bottom: 92px; } }

/* ── Mobile dock ────────────────────────────────────────────────────────── */
.boxdock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 65;
  display: none; align-items: center; gap: 14px;
  background: var(--forest); color: var(--bone); border: 0; cursor: pointer;
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  font-family: var(--sans); font-size: var(--fs-small);
}
@media (max-width: 960px) { .boxdock:not([hidden]) { display: flex; } }
.boxdock__meter { flex: none; width: 54px; height: 3px; background: rgba(246,242,233,.24); }
.boxdock__meter i { display: block; height: 100%; width: 0; background: var(--leaf); transition: width 480ms var(--ease-out); }
.boxdock__text { flex: 1; text-align: left; }
.boxdock__cta { font-size: var(--fs-eyebrow); font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--leaf); }

.scrim { position: fixed; inset: 0; background: rgba(16,20,16,.5); z-index: 68; opacity: 0; pointer-events: none; transition: opacity var(--t-mid); }
.scrim.is-on { opacity: 1; pointer-events: auto; }

/* The rail wraps rather than hiding tabs; the fade is only for the case where
   it genuinely cannot fit on one line. */
.catbar__scroll { position: relative; flex-wrap: wrap; overflow-x: visible; }
@media (max-width: 720px) {
  .catbar__scroll { flex-wrap: nowrap; overflow-x: auto; }
  .catbar__scroll[data-scrollable='true'] {
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 34px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 34px), transparent 100%);
  }
}

.valuebar--one { grid-template-columns: 1fr; }
.valuebar--one div:last-child b { color: var(--forest); text-decoration: none; }

/* Imported, but it reaches us at the market, so it costs no allowance. */
.item__flag--free { background: var(--stone); }

/* The live box stays in view while shopping, including on a phone. */
.boxpanel__inner { max-height: calc(100svh - 112px); overflow-y: auto; scrollbar-width: thin; }
.shopping-stage { margin-bottom: 20px; background: var(--forest); }
.crate canvas { cursor: grab; touch-action: pan-y; }
.crate canvas:active { cursor: grabbing; }
.crate__caption { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px 13px; color: var(--bone); font: 11px/1.5 var(--sans); }
.crate__hint { flex-shrink: 0; opacity: .65; }
.crate .crate__gauge { left: 14px; bottom: 12px; }
.crate__gauge b { font-size: 2.1rem; }
.crate__gauge em { font-size: 8px; margin-top: 4px; }
.boxpanel__controls { display: flex; gap: 14px; align-items: center; }
.boxpanel__close { display: none; background: transparent; border: 1px solid var(--rule); padding: 8px 12px; cursor: pointer; color: var(--forest); }
.item__subtitle { color: var(--stone); font: 12px/1.4 var(--sans); }
@media (max-width: 960px) {
  .mobile-stage { position: sticky; top: 78px; z-index: 32; background: var(--bone); }
  .mobile-stage .shopping-stage { margin: 0; }
  .mobile-stage .crate { height: 224px; }
  .mobile-stage .crate__caption { padding-block: 6px 8px; min-height: 38px; }
  .mobile-stage .crate__gauge b { font-size: 1.7rem; }
  .catbar { top: 340px; }
  .boxpanel__inner { max-height: none; }
  .boxpanel__close { display: block; }
  .boxpanel .crate { height: 240px; }
  .catsec { scroll-margin-top: 450px; }
}
@media (max-width: 560px) {
  .app__grid { padding-top: 16px; }
  .items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item__body { padding: 10px; }
  .item__name { font-size: .95rem; }
  .item__actions { flex-wrap: wrap; }
  .item__add { letter-spacing: .07em; font-size: 9px; min-height: 36px; }
  .catbar__tools { gap: 8px; }
  .catbar__toggle { font-size: 9px; letter-spacing: 0; }
  .catsec__head p { display: none; }
  .item__flag { top: auto; bottom: 6px; left: 6px; right: auto; font-size: 8px; letter-spacing: .03em; }
}

.item__photo-note { font: 10px/1.4 var(--sans); color: var(--stone); }
.item__limit { margin: 6px 0 0; font: 12px/1.5 var(--sans); color: var(--forest); }
.limit-status { max-width: none; margin: 0 0 28px; padding: 14px 16px; border-left: 3px solid var(--leaf-deep); background: var(--sand); color: var(--forest); font: 13px/1.6 var(--sans); }
.limit-status.is-limited { border-left-color: var(--clay-deep); }
.crate--flat .crate__gauge { position: relative; left: auto; bottom: auto; padding: 24px; }
.shopping-stage:has(.crate--flat) .crate__hint { display: none; }
