/* Sweet Treat Stamps trade catalogue.
   Colours and type follow the brand guidelines (Joyful Creative).
   The brand fills (lilac, purple, blue) are too light for small text, so the text tokens are darker on purpose. */

:root {
  --vanilla: #fff7f1;
  --white: #ffffff;
  --lilac: #ccabd8;
  --purple: #b48ec1;
  --pink-light: #f6b9d5;
  --blue-light: #a5d7d9;
  --blue: #6ec6ca;
  --deep: #271126;

  --text: #271126;
  --text-muted: #5f4863;
  --text-accent: #7b5689;
  --text-ok: #1d6468;
  --line: #eadbe9;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(39, 17, 38, .05), 0 8px 24px rgba(39, 17, 38, .05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--vanilla);
  color: var(--text);
  font: 300 15px/1.7 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .01em;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--text-accent); }
h1, h2, h3 { font-family: Fraunces, Georgia, "Times New Roman", serif; font-weight: 400; line-height: 1.2; margin: 0; }
strong { font-weight: 600; }
:focus-visible { outline: 3px solid var(--text-accent); outline-offset: 2px; }

.eyebrow, .kicker {
  margin: 0;
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-accent);
}
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Masthead: lilac band with the brand pattern and a scalloped edge */
.masthead {
  position: relative;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 34px;
  background-color: var(--lilac);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg stroke='%23fff7f1' stroke-width='2.5' fill-opacity='.7'%3E%3Ccircle cx='34' cy='42' r='13' fill='%23f6b9d5'/%3E%3Cpath d='M168 24l6.5 13 14.5 2-10.5 10 2.5 14.5L168 57l-13 6.5 2.5-14.5-10.5-10 14.5-2z' fill='%23a5d7d9'/%3E%3Cpath d='M78 176c-10-8.5-17-14-17-22.5 0-6.5 4.5-11 10.5-11 3.5 0 6 2 6.5 4.5.5-2.5 3-4.5 6.5-4.5 6 0 10.5 4.5 10.5 11 0 8.5-7 14-17 22.5z' fill='%23b48ec1'/%3E%3Ccircle cx='196' cy='168' r='11' fill='%23a5d7d9'/%3E%3Cpath d='M112 92l5 10 11 1.5-8 7.5 2 11-10-5.5-10 5.5 2-11-8-7.5 11-1.5z' fill='%23f6b9d5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 240px 240px;
}
.masthead::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -13px;
  height: 14px;
  background: radial-gradient(circle at 12px 0, var(--lilac) 12px, transparent 12.5px) 0 0 / 24px 14px repeat-x;
}
.masthead-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand copy basket";
  align-items: center;
  gap: 12px 32px;
}
.brand { grid-area: brand; }
.brand img { width: 128px; height: auto; }
.masthead-copy {
  grid-area: copy;
  max-width: 660px;
  background: rgba(255, 247, 241, .92);
  border-radius: var(--radius);
  padding: 14px 20px 16px;
}
.masthead h1 { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.5rem); color: var(--text-accent); margin: .15em 0 .25em; }
.lede { margin: 0; font-weight: 400; }
.basket-btn {
  grid-area: basket;
  align-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--vanilla);
  padding: 9px 10px 9px 18px;
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.basket-btn .count {
  min-width: 2em;
  height: 2em;
  padding: 0 .5em;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--deep);
  color: var(--vanilla);
  letter-spacing: 0;
}
.basket-btn.bump .count { animation: bump .35s ease; }
@keyframes bump { 50% { transform: scale(1.25); } }
@media (max-width: 720px) {
  .masthead-inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand basket" "copy copy"; }
  .brand img { width: 92px; }
}

/* How ordering works */
.steps {
  list-style: none;
  counter-reset: step;
  max-width: 1280px;
  margin: 34px auto 0;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.steps li {
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px 12px 54px;
  font-size: .9rem;
  font-weight: 400;
  line-height: 1.5;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-light);
  font-weight: 600;
}
@media (max-width: 820px) { .steps { grid-template-columns: minmax(0, 1fr); } }

/* Layout */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 16px 64px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.filters {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 2px 6px 2px 2px;
}
.search input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 400;
}
.type-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px;
}
.type-toggle button {
  flex: 1 1 auto;
  border: 0;
  background: none;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}
.type-toggle button[aria-pressed="true"] { background: var(--deep); color: var(--vanilla); }
.cat-select-wrap { display: none; }
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border: 0;
  background: none;
  border-radius: 10px;
  padding: 5px 10px;
  font-weight: 400;
  font-size: .92rem;
  line-height: 1.4;
  cursor: pointer;
}
.cat span { color: var(--text-muted); font-size: .8rem; }
.cat:hover { background: rgba(204, 171, 216, .25); }
.cat[aria-pressed="true"] { background: var(--lilac); font-weight: 500; }
.cat[aria-pressed="true"] span { color: var(--deep); }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 18px; padding-top: 20px; }
  .filters { position: static; max-height: none; overflow: visible; padding: 0; }
  .cat-list { display: none; }
  .cat-select-wrap { display: block; }
}

/* Results */
.results-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin-bottom: 16px; }
.results-head h2 { font-size: 1.9rem; color: var(--text-accent); }
.results-head p { margin: 0; color: var(--text-muted); font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
#sentinel { height: 1px; }
.empty, .error { padding: 48px 0; text-align: center; color: var(--text-muted); }

.card, .item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.card-media { display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0; background: var(--vanilla); }
button.card-media { cursor: pointer; }
.card-media img, .item > img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; background: var(--vanilla); }
.card-body, .item-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { font-size: 1.1rem; }
.item-body h3 { font-size: 1rem; }
.card-body > .btn, .card-body > .add, .item-body > .add { margin-top: auto; }
.code, .sizes { margin: 0; font-size: .75rem; font-weight: 400; color: var(--text-muted); letter-spacing: .03em; line-height: 1.45; }
.in-basket { margin: 0; font-size: .78rem; font-weight: 500; color: var(--text-ok); }
@media (max-width: 560px) {
  .card-body, .item-body { padding: 10px; }
  .card-body h3 { font-size: 1rem; }
}

/* Buttons and quantity */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .12em;
  line-height: 1.2;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--deep);
  cursor: pointer;
}
.btn-primary { background: var(--blue); }
.btn-primary:hover { background: #5cb9bd; }
.btn-secondary { background: transparent; border-color: var(--purple); }
.btn-secondary:hover { background: rgba(204, 171, 216, .3); }
.btn-block { width: 100%; padding-block: 12px; }
.btn:disabled { opacity: .6; cursor: progress; }

.add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.add .btn { flex: 1 1 60px; }
.add .in-basket { flex-basis: 100%; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--vanilla); }
.qty button { width: 32px; height: 34px; border: 0; background: none; border-radius: 999px; font-size: 1.1rem; font-weight: 500; cursor: pointer; }
.qty button:hover { background: rgba(204, 171, 216, .35); }
.qty input { width: 2.9em; padding: 0; border: 0; background: none; text-align: center; font-weight: 500; -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Dialogs */
dialog { border: 0; padding: 0; color: var(--text); background: var(--vanilla); }
dialog::backdrop { background: rgba(39, 17, 38, .5); }
.icon-btn { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--vanilla); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--lilac); }

.sheet { width: min(1000px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 48px); border-radius: 24px; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head {
  flex: none;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.sheet-cover { width: 132px; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: var(--vanilla); }
.sheet-head h2 { font-size: 1.8rem; color: var(--text-accent); margin: .1em 0 .2em; }
.sheet-head p { margin: 0 0 10px; }
.sheet-head .icon-btn { align-self: start; }
.sheet-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
@media (max-width: 560px) {
  .sheet { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .sheet-head { grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px; padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px; }
  .sheet-cover { width: 76px; }
  .sheet-head h2 { font-size: 1.35rem; }
  .sheet-scroll { padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .sheet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

.drawer { width: min(480px, 100vw); max-width: none; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: 24px 0 0 24px; }
.drawer[open] { display: flex; flex-direction: column; }
.drawer-head {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 1.6rem; color: var(--text-accent); }
.drawer-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px calc(28px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 520px) { .drawer { border-radius: 0; } }

.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.line img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; background: var(--vanilla); }
.line-name { margin: 0; font-weight: 500; line-height: 1.3; }
.line .qty { margin-top: 6px; }
.line .icon-btn { width: 34px; height: 34px; font-size: 1.25rem; }
.totals { margin: 12px 2px 0; font-size: .9rem; }

.order-form, .next-step { margin-top: 18px; border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.order-form { background: var(--white); border: 1px solid var(--line); }
.order-form h3, .next-step h3 { font-size: 1.25rem; }
.order-form p, .next-step p { margin: 0; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: .8rem; font-weight: 500; }
.field input { border: 1px solid #d8c3db; border-radius: 10px; padding: 9px 12px; background: var(--vanilla); font-weight: 400; }
.field input[aria-invalid="true"] { border-color: #a8231d; }
.form-error { color: #9b1c1c; font-weight: 500; font-size: .88rem; }
.next-step { background: var(--blue-light); }
.link-btn { margin-top: 16px; padding: 4px 0; border: 0; background: none; color: var(--text-muted); text-decoration: underline; font-size: .85rem; cursor: pointer; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--deep);
  color: var(--vanilla);
  font-size: .9rem;
  font-weight: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Picking mode (local only, ?pick): Craig marks designs to leave out */
.pick {
  align-self: flex-start;
  border: 1px dashed var(--text-accent);
  border-radius: 999px;
  background: var(--white);
  color: var(--text-accent);
  padding: 3px 10px;
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
}
.pick[aria-pressed="true"] { border-style: solid; border-color: var(--deep); background: var(--deep); color: var(--vanilla); }
.is-hidden .card-media, .is-hidden > img, .is-hidden h3, .is-hidden .kicker, .is-hidden .code, .is-hidden .sizes { opacity: .3; }
.pick-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 2px solid var(--deep);
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
  font-size: .9rem;
}
.pick-bar .link-btn { margin: 0; }
body.picking .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
body.picking .site-footer { padding-bottom: 110px; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px)); text-align: center; color: var(--text-muted); font-size: .85rem; }
.site-footer p { margin: 0 0 4px; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  .basket-btn.bump .count { animation: none; }
}
