/* The post box: header button, drawer, line list, drop motion. Loaded by the story pages (/shop/post.css) and by every shop page.
   It only uses the story's tokens (var(--…)) and logical properties, so it works unchanged in RTL. */

[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the header button ---------- */
sa-postbox-button { display: inline-flex; width: 44px; height: 44px; flex: none; }
.pb-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--ink); position: relative; }
.pb-btn:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
sa-postbox-button:empty { background: none; }

/* the engraved rural mailbox (glyph-postbox.js): its state is the svg's data-n (0 = empty, 1–5 = letters drawn) */
.pb-glyph { width: 38px; height: 34px; flex: none; overflow: visible; }
.pb-glyph .pbm-paper { fill: var(--stock); }
.pb-glyph .pbm-kraft { fill: color-mix(in srgb, var(--kraft) 75%, var(--stock)); }   /* the older letters in the stack */
.pb-glyph .pbm-seal, .pb-glyph .pbm-pivot { fill: var(--gold); }
.pb-glyph .pbm-brass { stroke: var(--gold); }
.pb-glyph .pbm-plate { fill: var(--s2); }
.pbm-art, .pbm-flag, .pbm-open { transform-box: view-box; }
.pbm-art { transform-origin: 20px 18px; }
[dir=rtl] .pbm-art { transform: scaleX(-1); }   /* the mouth faces the inline start */
.pbm-flag { transform-origin: 16px 12.6px; transform: rotate(90deg); transition: transform .55s cubic-bezier(.34, 1.56, .64, 1); }
.pbm-open { transform-origin: 10px 19.2px; opacity: 0; transform: rotate(62deg); transition: transform .42s var(--ease), opacity .18s linear; }
.pbm-in { opacity: 0; transition: opacity .2s linear; }
.pbm-shut { opacity: 1; transition: opacity .15s linear; }
.pb-glyph:not([data-n="0"]) .pbm-flag { transform: rotate(0deg); }
.pb-glyph:not([data-n="0"]) .pbm-open { opacity: 1; transform: none; }
.pb-glyph:not([data-n="0"]) .pbm-in { opacity: 1; }
.pb-glyph:not([data-n="0"]) .pbm-shut { opacity: 0; }
.pbm-l { transform-box: fill-box; transform-origin: 50% 50%; opacity: 0; transition: opacity .2s linear; }
.pbm-l[data-on] { opacity: 1; }
.pbm-l[data-wait] { opacity: 0; transition: none; }
@media (prefers-reduced-motion: reduce) {
  .pb-glyph .pbm-flag, .pb-glyph .pbm-open, .pb-glyph .pbm-in, .pb-glyph .pbm-shut, .pb-glyph .pbm-l { transition: none; }
}

/* the count: a small perforated postage stamp on the mailbox's back corner (holes punched by the mask) */
.pb-count, .fe-count {
  --r: 1.05px; --stamp-bg: var(--postmark);
  position: absolute; top: -3px; inset-inline-end: -4px; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  min-width: 17px; height: 19px; padding: 0 4px;
  font: 600 11px/1 var(--sans); font-variant-numeric: tabular-nums lining-nums; letter-spacing: 0; color: var(--stock);
  background: var(--stamp-bg); rotate: -4deg; transform-origin: 50% 50%;
  box-shadow: inset 0 0 0 2.2px var(--stamp-bg), inset 0 0 0 2.9px var(--gold);
  -webkit-mask: radial-gradient(var(--r), #0000 98%, #000) round calc(-1.5 * var(--r)) calc(-1.5 * var(--r)) / calc(3 * var(--r)) calc(3 * var(--r)),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - 3 * var(--r)) calc(100% - 3 * var(--r));
          mask: radial-gradient(var(--r), #0000 98%, #000) round calc(-1.5 * var(--r)) calc(-1.5 * var(--r)) / calc(3 * var(--r)) calc(3 * var(--r)),
    linear-gradient(#000 0 0) no-repeat 50% / calc(100% - 3 * var(--r)) calc(100% - 3 * var(--r));
}
.fe-count:empty { display: none; }
/* the letter page's night header (light ink on a dark sky): a cream perforated margin, like a real stamp's, keeps its shape readable */
.shop-header[data-night]:not([data-paper]) .pb-count { box-shadow: inset 0 0 0 2.2px var(--stock), inset 0 0 0 2.9px var(--gold); }

/* ---------- the floating post box on story phones (#floatEnv) ---------- */
@media (max-width: 820px) {
  .float-env.is-postbox { display: flex; align-items: center; justify-content: center; width: 64px; height: 48px; color: var(--ink); }
  .float-env.is-postbox .pb-glyph { width: 40px; height: 36px; }
  .float-env.is-postbox .fe-box { display: inline-flex; }
  .float-env.is-postbox .fe-count { top: -7px; inset-inline-end: -7px; }
}

/* ---------- the drawer ---------- */
dialog.pb-drawer {
  margin: 0; margin-inline-start: auto; inset-block: 0; inset-inline-start: auto; inset-inline-end: 0;
  width: min(460px, 100vw); max-width: 100vw; height: 100%; max-height: 100%;
  padding: 18px 22px 28px; border: 0; background: var(--paper); color: var(--ink);
  box-shadow: -18px 0 40px -20px rgba(22,21,19,.5); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(104%); transition: transform .28s var(--ease);
}
[dir=rtl] dialog.pb-drawer { transform: translateX(-104%); box-shadow: 18px 0 40px -20px rgba(22,21,19,.5); }
dialog.pb-drawer.open { transform: none; }
dialog.pb-drawer::backdrop { background: rgba(22,21,19,.42); }
.pb-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.pb-head-box { display: inline-flex; color: var(--ink); padding-top: 6px; }
.pb-head-box .pb-glyph { width: 64px; height: 58px; }
.pb-head .pb-close { margin-inline-start: auto; }
.pb-close { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 6px; font: 500 15px/1 var(--sans); letter-spacing: .08em; color: var(--ink); }
.pb-close:focus-visible, .pbl-step:focus-visible, .pbl-remove:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
dialog.pb-drawer h2, .pb-h { font: 300 34px/1.15 var(--serif); margin: 18px 0 2px; color: var(--ink); }
html[lang=ar] dialog.pb-drawer h2, html[lang=ar] .pb-h { font: 400 30px/1.4 var(--ar-serif); }
.pb-label { font: 500 13px/1.5 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 14px; }
html[lang=ar] .pb-label { letter-spacing: 0; text-transform: none; font-size: 15px; }
dialog.pb-drawer sa-envelope .envelope { box-shadow: 0 14px 28px -20px rgba(22,21,19,.5), 0 1px 2px rgba(22,21,19,.12); }
@media (prefers-reduced-motion: reduce) { dialog.pb-drawer { transition: none; } }

/* ---------- the envelope, small and plain variants ---------- */
.envelope.env-sm { aspect-ratio: 2.4; }
.envelope.env-sm .byair { top: 16px; inset-inline-start: 22px; height: 20px; font-size: 8px; padding: 0 8px; }
.envelope.env-sm .env-to { bottom: 14px; inset-inline-end: 22px; font-size: 9px; line-height: 1.5; }
.envelope.env-sm .air-border { inset: 6px; }
.sa-env .env-to { font-size: 11px; }
.env-pm { position: absolute; z-index: 2; top: 14px; inset-inline-end: 18px; width: 96px; height: 96px; pointer-events: none; opacity: .92; }
.env-pm .pm-svg { width: 100%; height: 100%; }
.envelope .seal { transition: opacity .5s ease, transform .5s var(--ease); }
.sealed .seal { opacity: 1; }
.stamp-svg, .pm-svg, .ring-svg, .seal-svg { direction: ltr; }
.stamp-svg { display: block; }

/* ---------- the line list (drawer and /post-box) ---------- */
sa-postbox-list { display: block; }
.pbl-lines { list-style: none; margin: 0; padding: 0; border-block-start: 1px solid rgba(22,21,19,.18); }
.pbl-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding: 14px 0; border-block-end: 1px solid rgba(22,21,19,.14); }
.pbl-stamp { grid-row: 1 / span 2; align-self: start; padding-block-start: 4px; }
.pbl-stamp .stamp-svg { width: 23px; height: 28px; filter: drop-shadow(0 1px 1px rgba(22,21,19,.14)); }
.pbl-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pbl-no { font: 500 12px/1.4 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-ink); }
html[lang=ar] .pbl-no { letter-spacing: 0; text-transform: none; font-size: 14px; }
.pbl-no:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
.pbl-name { font: 400 22px/1.2 var(--serif); color: var(--ink); }
html[lang=ar] .pbl-name { font: 400 21px/1.4 var(--ar-serif); }
.pbl-size { font: 300 14px/1.4 var(--sans); color: var(--ink-2); }
.pbl-price { font: 400 16px/1.3 var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; justify-self: end; }
.pbl-qty { grid-column: 2; display: inline-flex; align-items: center; border: 1px solid var(--ink); width: max-content; background: var(--stock); }
.pbl-step { width: 44px; height: 44px; display: grid; place-items: center; font: 400 22px/1 var(--sans); color: var(--ink); }
.pbl-step[disabled] { opacity: .35; cursor: not-allowed; }
.pbl-q { min-width: 34px; text-align: center; font: 500 17px/1 var(--sans); font-variant-numeric: tabular-nums; }
.pbl-remove { grid-column: 3; justify-self: end; min-height: 44px; min-width: 44px; padding: 0 4px; font: 400 15px/1 var(--sans); color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.pbl-gift { border: 0; margin: 18px 0 6px; display: flex; gap: 8px 26px; flex-wrap: wrap; }
.pbl-gift label { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font: 400 17px/1.2 var(--sans); cursor: pointer; }
.pbl-gift input { position: absolute; inset-inline-start: 0; top: 0; width: 44px; height: 44px; margin: 0; opacity: 0; cursor: pointer; }
.pbl-radio { width: 20px; height: 20px; border: 1px solid var(--ink); border-radius: 50%; display: grid; place-items: center; background: var(--stock); flex: none; }
.pbl-gift input:checked + .pbl-radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.pbl-gift input:focus-visible + .pbl-radio { outline: 2px solid var(--gold-ink); outline-offset: 3px; }
.pbl-foot { margin-block-start: 16px; display: grid; gap: 10px; }
.pbl-sub { display: flex; justify-content: space-between; align-items: baseline; font: 500 17px/1.3 var(--sans); }
.pbl-sub-v { font-variant-numeric: tabular-nums; }
.pbl-note { font: 300 15px/1.5 var(--sans); color: var(--ink-2); }
.pbl-foot .btn, .pbl-empty .btn { width: 100%; justify-content: center; text-align: center; }
.pbl-view { justify-self: center; min-height: 44px; display: inline-flex; align-items: center; font: 400 16px/1 var(--sans); text-decoration: underline; text-underline-offset: 4px; }
.pbl-empty { display: grid; gap: 14px; padding-block: 12px; }
.pbl-empty p { font: italic 400 22px/1.4 var(--serif); color: var(--ink); }
html[lang=ar] .pbl-empty p { font: 400 20px/1.7 var(--ar-serif); font-style: normal; }
.btn:focus-visible, .pbl-view:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 3px; }

/* ---------- Add to cart: the small envelope that flies into the mailbox ---------- */
.drop-env { background: var(--stock); border: 1px solid var(--ink); box-shadow: 0 10px 20px -10px rgba(22,21,19,.5); will-change: transform; }
.drop-env .de-flap { position: absolute; inset: 0; background:
  linear-gradient(to top right, transparent calc(50% - .5px), var(--ink) 50%, transparent calc(50% + .5px)) 0 0 / 50% 55% no-repeat,
  linear-gradient(to top left, transparent calc(50% - .5px), var(--ink) 50%, transparent calc(50% + .5px)) 100% 0 / 50% 55% no-repeat; }
.drop-env .stamp-svg { position: absolute; top: 6px; inset-inline-end: 6px; width: 23px; height: 28px; }

/* ---------- the story: the quiet WhatsApp line under Write back ---------- */
.reply-cta:has(.reply-wa:not([hidden])) { flex-direction: column; align-items: center; gap: 14px; }
.reply-wa { font: 300 var(--fs-small, 17px)/1.4 var(--sans); text-align: center; }
.reply-wa a { border-bottom: 1px solid var(--gold); padding-block: 8px; display: inline-block; }
.reply-wa a:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 3px; }

/* ---------- Phase 3: what stands in for checkout while the shop is not open ---------- */
.pbl-mode { font: 400 17px/1.5 var(--serif); color: var(--ink); margin-block: 14px 6px; }
html[lang=ar] .pbl-mode { font-family: var(--ar-serif); font-size: 19px; }
.pbl-rsvp { display: grid; gap: 10px; margin-block-start: 6px; position: relative; }
.pbl-rsvp label { font: 400 17px/1.5 var(--serif); color: var(--ink-2); }
html[lang=ar] .pbl-rsvp label { font-family: var(--ar-serif); font-size: 19px; }
.pbl-rsvp-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pbl-rsvp-row input { flex: 1 1 180px; min-height: 48px; padding: 0 12px; background: var(--stock); border: 1px solid var(--ink); border-radius: 0; }
.pbl-rsvp-row .btn { min-height: 48px; padding-inline: 18px; }
.pbl-rsvp-msg { color: #8a2a1d; font: 400 14px/1.4 var(--sans); min-height: 0; }
.pbl-rsvp-done { font: 400 18px/1.5 var(--serif); }
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.closed-band.in-drawer { border: 1px solid var(--gold); background: var(--stock); padding: 12px 14px; font: 400 17px/1.55 var(--serif); margin-block: 10px; }
html[lang=ar] .closed-band.in-drawer { font-family: var(--ar-serif); font-size: 19px; }
/* on a solemn day the story shows no product button and no write-back form: only the plain line (story-post.js adds it) */
html.closed-day [data-k="order"], html.closed-day #replyBtn, html.closed-day #reply { display: none !important; }
.closed-band.top { background: var(--stock); border-block-end: 1px solid var(--gold); padding: 14px var(--pad, 16px); font: 400 18px/1.6 var(--serif); text-align: center; position: relative; z-index: 5; }
html[lang=ar] .closed-band.top { font-family: var(--ar-serif); font-size: 20px; }
.mode-line { font: 400 16px/1.5 var(--serif); color: var(--ink-2); margin-block: 8px; }
html[lang=ar] .mode-line { font-family: var(--ar-serif); font-size: 18px; }

/* ---------- the cookie slip (spec 14.4): a small paper slip at the bottom, not a modal, no motif ---------- */
:root { --slip-h: 0px; }
sa-cookie-slip { display: contents; }
sa-cookie-slip[hidden] { display: none !important; }
.cookie-slip { position: fixed; inset-inline: 0; bottom: 0; z-index: 70; background: var(--stock); color: var(--ink); border-block-start: 1px solid var(--ink);
  padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 10px; box-shadow: 0 -10px 24px -18px rgba(22,21,19,.5); }
.cookie-text { font: 400 15px/1.5 var(--sans); max-width: 70ch; }
html[lang=ar] .cookie-text { font-family: var(--ar-body); font-size: 16px; line-height: 1.8; }
.cookie-link { border-block-end: 1px solid var(--gold); white-space: nowrap; }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 10px; }
/* equal weight: the same size, the same outline, neither one filled */
.cookie-btn { flex: 1 1 160px; min-height: 44px; padding: 0 16px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font: 500 15px/1.2 var(--sans); cursor: pointer; }
html[lang=ar] .cookie-btn { font-family: var(--ar-body); }
.cookie-btn:hover { background: rgba(22,21,19,.06); }
.cookie-btn:focus-visible, .cookie-link:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
@media (min-width: 700px) { .cookie-slip { grid-template-columns: 1fr auto; align-items: center; } .cookie-btn { flex: 0 0 auto; } }
/* while it is open, the one floating element and the buy/submit bars sit above it (the story's layout is never changed by it) */
/* only a FIXED bar rides up with the slip (--lift:1, the default). A bar that sits in the page flow sets --lift:0, or the lift would pull it over the text above it */
html.slip-open #floatEnv, html.slip-open [data-lift] { transform: translateY(calc(var(--slip-h, 0px) * var(--lift, 1) * -1)); }
@media (prefers-reduced-motion: no-preference) { #floatEnv, [data-lift] { transition: transform .2s var(--ease); } }

/* ---------- the confirmation slip after "Add to cart" (<sa-added-slip>): a paper slip under the header, not a modal ---------- */
sa-added-slip { display: contents; }
.added-slip { position: fixed; z-index: 80; top: var(--as-top, 80px); inset-inline: 12px; max-width: 460px; margin-inline: auto;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "stamp text close" "actions actions actions"; gap: 10px 12px; align-items: start;
  background: var(--stock); color: var(--ink); border: 1px solid var(--ink); padding: 14px 8px 14px 14px;
  box-shadow: inset 0 0 0 3px var(--stock), inset 0 0 0 4px rgba(184,145,63,.55), 0 18px 30px -16px rgba(22,21,19,.55);
  opacity: 0; visibility: hidden; transform: translateY(-10px); pointer-events: none; }
.added-slip[data-open="true"] { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
@media (prefers-reduced-motion: no-preference) {
  .added-slip { transition: opacity .22s var(--ease), transform .22s var(--ease), visibility 0s linear .22s; }
  .added-slip[data-open="true"] { transition-delay: 0s; }
}
.as-stamp { grid-area: stamp; padding-block-start: 2px; }
.as-stamp .stamp-svg { width: 23px; height: 28px; }
.as-text { grid-area: text; display: grid; gap: 4px; min-width: 0; padding-block-start: 1px; }
.as-line { font: 400 19px/1.3 var(--serif); font-variant-numeric: lining-nums; }
html[lang=ar] .as-line { font: 400 19px/1.65 var(--ar-serif); font-variant-numeric: lining-nums; }
.as-count { font: 500 11px/1.4 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); }
html[lang=ar] .as-count { letter-spacing: 0; text-transform: none; font: 400 14px/1.5 var(--ar-body); }
.as-close { grid-area: close; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; margin: -8px 0 0; color: var(--ink-2); cursor: pointer; background: none; border: 0; }
.as-close:hover { color: var(--ink); }
.as-actions { grid-area: actions; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; padding-inline-end: 6px; }
.as-view { display: inline-flex; align-items: center; min-height: 44px; font: 400 17px/1.2 var(--sans); border-bottom: 1px solid var(--gold); }
html[lang=ar] .as-view { font-family: var(--ar-body); }
.as-view:hover { border-bottom-color: var(--ink); }
.added-slip .as-seal { width: auto; height: 44px; min-width: 0; padding: 0 20px; font-size: 12px; }
.added-slip a:focus-visible, .added-slip button:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 3px; }
@media (min-width: 640px) {
  .added-slip { inset-inline-start: auto; inset-inline-end: max(var(--pad, 24px), 16px); width: 440px; margin-inline: 0; }
}
/* the post box icon, a moment after a letter landed in it (the nudge itself is in drop.js; this cue also shows with reduced motion) */
sa-postbox-button[data-hit] .pb-btn, #floatEnv[data-hit] { color: var(--gold-ink); }
sa-postbox-button[data-hit] .pb-count, #floatEnv[data-hit] .fe-count { --stamp-bg: var(--s2); }
