/* ===========================================================================
   The offer dock — a paper tag pinned to the bottom of the window.

   A floating "15% off" button is the least original thing a shop can do, and
   the reference everyone copies is a white card with a drop shadow, which
   belongs to a pop-up ad, not to a shop that prints its own case files.

   So this one is built out of the shop's parts instead: the same warm paper as
   the popup, a 1px ink edge rather than a shadow bloom, an orange asterisk for
   a mark, and a serif number. It reads as a luggage tag left on the counter.

   The dialog follows the same idea one step further — it is drawn as a ticket:
   a body with the offer and the form, then a dashed line, then the stub that
   carries the code. The tear line is decoration; the fact that the code lives
   below it is not. You can see the whole offer without reading a paragraph.

   Prefix: .cd / .cd-modal. Nothing outside this file.
   ------------------------------------------------------------------------ */

.cd {
  --cd-paper: #f8f5ea;
  --cd-ink: #20211d;
  --cd-muted: #6d6f65;
  --cd-line: rgba(32, 33, 29, 0.16);
  --cd-orange: #e8753f;

  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: inline-flex;
  align-items: stretch;
  transform: translateX(-50%);
  background: var(--cd-paper);
  border: 1px solid var(--cd-line);
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 14px 34px -18px rgba(24, 25, 20, 0.55);
  animation: cd-rise 0.42s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

/* `display: inline-flex` beats the UA rule for [hidden], so it has to be said
   again here or the dismiss button would do nothing visible. */
.cd[hidden] {
  display: none;
}

@keyframes cd-rise {
  from {
    opacity: 0;
    transform: translate(-50%, 14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* The dock sits over the page, so the last thing on the page has to end above
   it — but adding that room to <body> paints it in the body colour, which is
   paper, and paper under a dark footer reads as a stray white band running
   across the bottom of the screen. The footer is what actually sits under the
   pill, so the footer grows instead: 22px of its own breathing room plus the
   height of the dock. Nothing shows through, and the pill lands on ink.
   `:has` keeps this off shops with no offer running, and `:not([hidden])` keeps
   a dismissed dock from leaving 86px of empty footer behind. */
body:has(> .cd:not([hidden])) > .footer {
  padding-bottom: calc(22px + 86px);
}

.cd__open {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  padding: 12px 4px 12px 18px;
  border: 0;
  background: transparent;
  color: var(--cd-ink);
  font: inherit;
  cursor: pointer;
  border-radius: 999px 0 0 999px;
  transition: background 0.18s ease;
}

.cd__open:hover,
.cd__open:focus-visible {
  background: rgba(32, 33, 29, 0.045);
}

.cd__open:focus-visible {
  outline: 2px solid var(--cd-orange);
  outline-offset: -2px;
}

.cd__star {
  color: var(--cd-orange);
  font-size: 13px;
  line-height: 1;
  transform: translateY(-1px);
}

.cd__amount {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.cd__what {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cd-muted);
  white-space: nowrap;
}

.cd__what::before {
  content: "—";
  margin-right: 7px;
  color: rgba(32, 33, 29, 0.35);
}

.cd__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  border: 0;
  border-left: 1px solid var(--cd-line);
  background: transparent;
  color: #9a9c91;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  border-radius: 0 999px 999px 0;
  transition: color 0.18s ease, background 0.18s ease;
}

.cd__close:hover,
.cd__close:focus-visible {
  color: var(--cd-ink);
  background: rgba(32, 33, 29, 0.045);
}

/* ------------------------------------------------------------- the ticket */

.cd-modal {
  width: min(468px, calc(100vw - 28px));
  max-height: min(92vh, 720px);
  padding: 0;
  border: 1px solid rgba(32, 33, 29, 0.2);
  border-top: 3px solid var(--cd-orange, #e8753f);
  background: #f8f5ea;
  color: #20211d;
  overflow: hidden;
  box-shadow: 0 50px 100px -50px rgba(20, 21, 17, 0.7);
}

.cd-modal:not([open]) {
  display: none;
}

.cd-modal::backdrop {
  background: rgba(22, 23, 19, 0.54);
}

.cd-modal[open] {
  animation: cd-in 0.3s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes cd-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cd {
    animation: none;
  }
  .cd-modal[open] {
    animation: none;
  }
}

.cd-modal__card {
  position: relative;
  max-height: inherit;
  overflow-y: auto;
}

.cd-modal__x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8b8d82;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.cd-modal__x:hover,
.cd-modal__x:focus-visible {
  color: #20211d;
}

.cd-modal__body {
  padding: 30px 32px 24px;
}

/* The code chip is pushed to the right edge by `margin-left:auto`, which puts
   it directly under the close button. The padding is not decorative: without
   it the × sits on top of the last two characters of the code. */
.cd-modal__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding-right: 36px;
  font-size: 10px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: #8a8c81;
}

.cd-modal__eyebrow span {
  margin-left: auto;
  padding: 2px 7px 3px;
  border: 1px solid rgba(32, 33, 29, 0.16);
  border-radius: 3px;
  letter-spacing: 0.1em;
  color: #5c5f55;
  font-variant-numeric: tabular-nums;
}

.cd-modal__title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(29px, 4.4vw, 38px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.cd-modal__lede {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.65;
  color: #65675f;
}

.cd-modal__form {
  margin-top: 20px;
}

/* One row, the button inside the field's frame — a single object rather than
   a box with a button next to it, which is what makes a two-field signup feel
   like a form and a one-field signup feel like a door. */
.cd-modal__field {
  display: flex;
  border: 1px solid #c6c3b3;
  background: #fffdf8;
}

.cd-modal__field:focus-within {
  border-color: #20211d;
  box-shadow: 0 0 0 1px #20211d;
}

/* site.css ships a legacy `input { border: 1px solid !important; min-height:
   44px }` reset from the WordPress theme. Everything here is a borderless field
   inside its own frame, so those two properties have to be argued down. */
.cd-modal__field input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0 !important;
  padding: 13px 14px;
  border: 0 !important;
  background: transparent !important;
  font: inherit;
  font-size: 14px;
  color: #20211d;
}

.cd-modal__field input:focus {
  outline: none;
}

.cd-modal__field button {
  flex: 0 0 auto;
  padding: 0 18px;
  border: 0;
  background: #20211d;
  color: #f8f5ea;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s ease;
}

.cd-modal__field button:hover,
.cd-modal__field button:focus-visible {
  background: #e8753f;
}

.cd-modal__error {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-left: 2px solid #b4462c;
  background: #f4e6dd;
  font-size: 12.5px;
  line-height: 1.5;
  color: #7a3323;
}

/* ----------------------------------------------------- the follow-up question
   Three rows, no boxes. A shelf is a line of type with a number and a price,
   separated by hairlines — the same grammar as the case-file index elsewhere on
   the site, so the dialog does not suddenly turn into a survey with radio
   buttons. The heavier cut on the right of each row is the offer, because that
   is the part a visitor is actually shopping for. */

.cd-modal__taste {
  margin-top: 20px;
}

.cd-modal__taste-lead {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #65675f;
}

.cd-modal__shelves {
  border-top: 1px solid rgba(32, 33, 29, 0.16);
}

.cd-shelf {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  min-height: 0 !important;
  padding: 13px 2px;
  border: 0 !important;
  border-bottom: 1px solid rgba(32, 33, 29, 0.16) !important;
  background: transparent !important;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, padding-left 0.16s ease;
}

.cd-shelf:hover,
.cd-shelf:focus-visible {
  background: rgba(232, 117, 63, 0.07) !important;
  padding-left: 8px;
}

.cd-shelf:focus-visible {
  outline: 2px solid var(--cd-orange);
  outline-offset: -2px;
}

.cd-shelf[disabled] {
  opacity: 0.45;
  cursor: default;
}

.cd-shelf.is-picking {
  opacity: 1;
  background: rgba(32, 33, 29, 0.05) !important;
}

.cd-shelf__no {
  flex: 0 0 auto;
  width: 18px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: #b3b0a1;
}

.cd-shelf__text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cd-shelf__text strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16.5px;
  font-weight: 400;
  letter-spacing: -0.012em;
  color: #20211d;
}

.cd-shelf__text em {
  font-style: normal;
  font-size: 11.5px;
  line-height: 1.4;
  color: #8a8c81;
}

.cd-shelf__cut {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b4541f;
  white-space: nowrap;
}

.cd-modal__skip {
  margin: 13px 0 0;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  font: inherit;
  font-size: 11px;
  color: #8a8c81;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.cd-modal__skip:hover,
.cd-modal__skip:focus-visible {
  color: #b4462c;
}

.cd-modal__done {
  margin-top: 20px;
}

.cd-modal__done-lead {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #4a4d44;
}

/* The code is the one thing a buyer came for, so it is set as a piece of type
   rather than a form field: large, monospaced, tabular, with the whole block
   acting as the copy button. */
.cd-modal__code {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px dashed rgba(32, 33, 29, 0.32);
  background: #fffdf8;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cd-modal__code span:first-child {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 21px;
  letter-spacing: 0.08em;
  color: #20211d;
}

.cd-modal__copy {
  margin-left: auto;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a8c81;
}

.cd-modal__code:hover .cd-modal__copy {
  color: #e8753f;
}

.cd-modal__note {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: #82847a;
}

/* --------------------------------------------------------------- the stub */

.cd-modal__stub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 32px 13px;
  border-top: 2px dashed rgba(32, 33, 29, 0.22);
  background: #eeeadd;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a8c81;
}

.cd-modal__stub span:first-child {
  color: #5c5f55;
}

.cd-modal__stub span:last-child {
  text-align: right;
}

/* `[hidden]` loses to any rule that sets display. Say it once, loudly. */
.cd-modal [hidden] {
  display: none !important;
}

/* ------------------------------------------------------------- breakpoints */

@media (max-width: 620px) {
  .cd {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 24px);
  }

  .cd__open {
    padding: 11px 2px 11px 15px;
    gap: 8px;
  }

  .cd__amount {
    font-size: 19px;
  }

  .cd__what {
    font-size: 9px;
  }

  .cd__close {
    width: 38px;
  }

  body:has(> .cd:not([hidden])) > .footer {
    padding-bottom: calc(22px + 76px);
  }

  .cd-modal__body {
    padding: 26px 22px 20px;
  }

  .cd-modal__stub {
    padding: 10px 22px 12px;
    font-size: 9px;
  }

  /* On a phone the button goes under the field: a single row would leave the
     address about 150px wide, and an email at 150px is a guess, not a field. */
  .cd-modal__field {
    flex-direction: column;
  }

  .cd-modal__field button {
    padding: 13px 18px;
  }
}

/* ------------------------------------------------------- the code, on the bag
   A coupon is the only figure in the order summary the buyer did not choose, so
   it is drawn as a thing rather than a row: a dashed ticket sitting above the
   subtotal, the code in mono, the money it saved in orange. When one is on, the
   input is gone — there is nothing left to type, only something to remove. */

.cc {
  margin: 0 0 14px;
  padding: 11px 12px 12px;
  border: 1px dashed rgba(32, 33, 29, 0.3);
  background: #fffdf8;
}

.cc--on {
  padding: 10px 12px 8px;
}

.cc__line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cc__drop {
  margin-top: 5px;
}

/* A code that only counts one shelf has to say so on the ticket, not after the
   buyer notices the discount is smaller than the percentage on the code. */
.cc__scope {
  margin: 6px 0 0;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a8c81;
}

.cc__scope::before {
  content: "↳";
  margin-right: 5px;
  color: #b4541f;
}

.cc__no {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a8c81;
}

.cc__code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: #20211d;
}

.cc__cut {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: #b4541f;
  font-variant-numeric: tabular-nums;
}

.cc__x {
  min-height: 0;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  color: #9a9c91;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.cc__x:hover,
.cc__x:focus-visible {
  color: #b4462c;
}

.cc__label {
  display: block;
  margin-bottom: 7px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8c81;
}

.cc__row {
  display: flex;
  border: 1px solid #c6c3b3;
  background: #fffdf8;
}

.cc__row:focus-within {
  border-color: #20211d;
  box-shadow: 0 0 0 1px #20211d;
}

.cc__row input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0 !important;
  padding: 9px 10px;
  border: 0 !important;
  background: transparent !important;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #20211d;
}

.cc__row input:focus {
  outline: none;
}

.cc__row input::placeholder {
  text-transform: none;
  letter-spacing: 0;
  color: #9a9c91;
}

.cc__row button {
  flex: 0 0 auto;
  padding: 0 14px;
  border: 0;
  background: #20211d;
  color: #f8f5ea;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s ease;
}

.cc__row button:hover,
.cc__row button:focus-visible {
  background: #e8753f;
}

.cc__why {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: #8f3a26;
}

/* The totals row for the code. Not red — this shop's price cuts are the same
   orange as every other mark it makes. */
.pi-discount strong {
  color: #b4541f;
}
