/* Ufalugaa Orders: cart, checkout and confirmation.
   Built from the theme's own tokens (panels, gaps, brand blue, dark mode), so it looks native. */

:root { --ufo-error: #b3261e; --ufo-error-tint: #fbe9e7; }
/* Anything the script hides stays hidden, whatever its layout style. */
[class*="ufo-"][hidden], .ufo-totals [hidden] { display: none !important; }
:root[data-theme="dark"] { --ufo-error: #ff8a80; --ufo-error-tint: #3a1614; }

/* ---------- Header: Cart button ---------- */
.nav__cart { gap: 8px; padding: 0 6px 0 18px; --btn-ink: #0091cc; } /* 6px + 2px border: the count sits 8px from the edge, as above and below */
.nav__count {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 999px; background: var(--blue); color: #fff; font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums; transition: transform 0.3s var(--ease-out);
}
.nav__cart:hover .nav__count { background: #fff; color: var(--ink); }
.nav__count.is-bumped { animation: ufo-bump 0.45s var(--ease-out); }
@keyframes ufo-bump { 40% { transform: scale(1.3); } }
@media (max-width: 860px) {
  .nav__cart { min-height: 44px; padding: 0 6px 0 14px; }
}
@media (max-width: 600px) {
  .nav .nav__cart { width: auto; } /* the theme stretches buttons to full width on phones */
}
/* Narrow phones (360–400px): slightly tighter header spacing, so the header stays on one row
   even with a two-digit cart count. Every item still sits 8px inside the header. */
@media (max-width: 400px) {
  .nav { gap: 8px; }
  .nav__actions { gap: 6px; }
  .nav__cart { gap: 6px; padding: 0 6px 0 12px; }
}

/* ---------- Book page: Add to cart / Buy now ---------- */
.btn--brand-outline {
  --btn-bg: transparent; --btn-ink: var(--title-blue); --fill: var(--title-blue); --fill-ink: #fff;
  border-color: var(--title-blue); font-size: 19px;
}
.ufo-buy__note { margin-top: 14px; font-size: 15px; color: var(--ink-soft); }
[data-add-to-cart].is-added { --btn-bg: var(--ink); }
@media (max-width: 1200px) { .ufo-buy__note { margin-top: 10px; font-size: 14px; } }

/* Quantity on the book page, with the stock status next to it */
.ufo-buy__qty { display: flex; align-items: center; gap: 12px 16px; margin-bottom: 14px; flex-wrap: wrap; }
.ufo-buy__label { font-weight: 700; }
.ufo-buy__qty .ufo-qty { margin-left: auto; }

/* Stock status: a dot that keeps sending out a soft ring, like a signal */
.ufo-stock { --dot: #2f9e5a; display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.ufo-stock--out { --dot: #d6453b; }
:root[data-theme="dark"] .ufo-stock { --dot: #4cc77d; }
:root[data-theme="dark"] .ufo-stock--out { --dot: #ff6b61; }
.ufo-stock__dot { position: relative; width: 10px; height: 10px; border-radius: 999px; background: var(--dot); flex: none; }
.ufo-stock__dot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--dot);
  animation: ufo-signal 1.8s ease-out infinite;
}
@keyframes ufo-signal { from { transform: scale(1); opacity: 0.6; } to { transform: scale(3.2); opacity: 0; } }

/* Sold-out book: the same controls, greyed out and switched off */
.btn--off, .btn--off:hover {
  --btn-bg: var(--surface-2); background: var(--surface-2); color: var(--ink-soft); border-color: var(--surface-2);
  font-size: 19px; cursor: not-allowed;
}
.is-sold-out .ufo-qty { opacity: 0.55; }
.is-sold-out .ufo-qty button { cursor: not-allowed; }
@media (max-width: 1200px) { .ufo-buy__qty { margin-bottom: 10px; } }

/* Book tiles: "Sold out" label on the photo */
.book__badge {
  position: absolute; left: 12px; top: 12px; z-index: 1;
  padding: 5px 11px; border-radius: 999px; background: var(--ufo-error); color: #fff;
  font-size: 12px; font-weight: 800; line-height: 1.2; letter-spacing: 0.01em;
  box-shadow: 0 6px 16px -8px rgb(0 0 0 / 0.45);
}
:root[data-theme="dark"] .book__badge { color: #2a0d0b; }
/* Sale: green "x% off" label (deeper green so the small white text stays readable) */
.book__badge--sale { background: #1d7a43; color: #fff; }
:root[data-theme="dark"] .book__badge--sale { background: #4cc77d; color: #062012; }

/* Sale prices: the normal price, struck through, after the sale price */
.price-was { margin-left: 0.35em; font-size: 0.82em; font-weight: 600; color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1.5px; white-space: nowrap; }
.panel--blue .price-was { color: rgb(255 255 255 / 0.75); }

/* Book tiles: round bag button. It sits over the bottom-right of the (square) photo. */
.ufo-quick { position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 1; pointer-events: none; overflow: hidden; border-radius: var(--r-tile); }
.ufo-quick__btn {
  position: absolute; right: 14px; bottom: 14px; pointer-events: auto;
  display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--title-blue); cursor: pointer; /* brand-blue bag in light mode */
  box-shadow: 0 10px 24px -10px rgb(0 30 50 / 0.55);
  transition: transform 0.45s var(--ease-out), opacity 0.3s, background-color 0.2s, color 0.2s;
}
.ufo-quick__btn svg { width: 24px; height: 24px; }
:root[data-theme="dark"] .ufo-quick__btn { color: var(--ink); } /* dark mode keeps the light bag */
.ufo-quick__btn:hover { background: var(--title-blue); color: #fff; }
.ufo-quick__btn > span { grid-area: 1 / 1; display: grid; place-items: center; transition: opacity 0.2s, transform 0.3s var(--ease-out); }
.ufo-quick__done { opacity: 0; transform: scale(0.5); }
.ufo-quick__btn.is-done { background: var(--title-blue); color: #fff; }
.ufo-quick__btn.is-done .ufo-quick__bag { opacity: 0; transform: scale(0.5); }
.ufo-quick__btn.is-done .ufo-quick__done { opacity: 1; transform: none; }
.ufo-quick__btn:focus-visible { outline-color: #fff; box-shadow: 0 0 0 3px var(--blue-text); }
/* With a mouse, the button rises in from the bottom-right corner when the tile is hovered.
   On touch screens there's no hover, so it simply stays visible. */
@media (hover: hover) {
  .ufo-quick__btn { opacity: 0; transform: translate(24px, 24px) scale(0.6); }
  .book-card:hover .ufo-quick__btn, .ufo-quick__btn:focus-visible, .ufo-quick__btn.is-done { opacity: 1; transform: none; }
}
@media (max-width: 600px) {
  .ufo-quick { border-radius: 16px; }
  .ufo-quick__btn { right: 8px; bottom: 8px; width: 38px; height: 38px; }
  .ufo-quick__btn svg { width: 18px; height: 18px; }
  .book__badge { left: 8px; top: 8px; padding: 4px 9px; font-size: 11px; }
}

/* ---------- Page layout: main panel + summary ---------- */
.ufo-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.ufo-summary { position: sticky; top: calc(var(--gap) * 2 + 60px); display: flex; flex-direction: column; gap: 24px; }
.admin-bar .ufo-summary { top: calc(var(--gap) * 2 + 92px); }
.ufo-title { font-size: clamp(40px, 4.4vw, 64px); letter-spacing: -0.035em; color: var(--title-blue); }
.ufo-lede { margin-top: 14px; font-size: clamp(17px, 1.4vw, 19px); color: var(--ink-soft); max-width: 52ch; }
.ufo-summary__title { font-size: clamp(26px, 2.4vw, 32px); }
.ufo-summary__head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.ufo-summary__head a { font-weight: 700; font-size: 15px; color: var(--title-blue); }
.ufo-wide { width: 100%; }
.ufo-fine { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.ufo-empty { margin-top: 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
.ufo-empty p { font-size: 19px; color: var(--ink-soft); }
.ufo-alert {
  padding: 14px 18px; border-radius: var(--r-small); background: var(--ufo-error-tint); color: var(--ufo-error);
  font-weight: 600; font-size: 15px; line-height: 1.45;
}
@media (max-width: 960px) {
  .ufo-layout { grid-template-columns: minmax(0, 1fr); }
  .ufo-summary { position: static; }
  /* On checkout the order summary comes first on phones, so people see what they're ordering. */
  .ufo-layout--checkout .ufo-summary { order: -1; }
}

/* ---------- Cart list ---------- */
.ufo-items { list-style: none; margin: clamp(24px, 3vw, 40px) 0 0; padding: 0; }
.ufo-item {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 8px 20px;
  padding: 20px 0; border-top: 2px solid var(--line);
}
.ufo-item:last-child { border-bottom: 2px solid var(--line); }
.ufo-item__img { grid-row: span 2; width: 96px; aspect-ratio: 1; border-radius: var(--r-small); overflow: hidden; background: var(--photo); }
.ufo-item__img img { width: 100%; height: 100%; object-fit: cover; filter: var(--photo-dim); }
.ufo-item__name { font-weight: 800; font-size: clamp(19px, 1.6vw, 22px); line-height: 1.2; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.ufo-item__name:hover { color: var(--blue-text); }
.ufo-item__each { font-size: 15px; color: var(--ink-soft); }
.ufo-item__line { grid-column: 3; grid-row: 1; justify-self: end; font-size: 19px; }
.ufo-item__controls { grid-column: 2 / 4; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ufo-item__stock { grid-column: 2 / 4; color: var(--ufo-error); font-weight: 700; font-size: 15px; }
.ufo-item.is-out .ufo-item__img img { opacity: 0.45; }
.ufo-remove { border: 0; background: none; padding: 8px 0; color: var(--ink-soft); font: inherit; font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ufo-remove:hover { color: var(--ufo-error); }

/* Quantity stepper */
.ufo-qty { display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface-2); padding: 4px; }
.ufo-qty button {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 0;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 20px; font-weight: 700; cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.ufo-qty button:hover:not(:disabled) { background: var(--blue); color: #fff; }
.ufo-qty button:disabled { opacity: 0.35; cursor: not-allowed; }
.ufo-qty output { min-width: 40px; text-align: center; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .ufo-item { grid-template-columns: 76px minmax(0, 1fr) auto; column-gap: 14px; }
  .ufo-item__img { width: 76px; }
  .ufo-item__line { font-size: 17px; }
}

/* ---------- Totals ---------- */
.ufo-totals { margin: 0; display: grid; gap: 10px; }
.ufo-totals div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.ufo-totals dt { color: var(--ink-soft); }
.ufo-totals dd { margin: 0; font-weight: 700; }
.ufo-free { color: var(--title-blue); }
.ufo-totals__total { padding-top: 14px; margin-top: 4px; border-top: 2px solid var(--line); }
.ufo-totals__total dt { color: var(--ink); font-weight: 800; font-size: 19px; }
.ufo-totals__total dd { font-size: clamp(24px, 2.2vw, 30px); font-weight: 800; letter-spacing: -0.02em; }

/* Compact list (checkout summary, confirmation) */
.ufo-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.ufo-mini li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.ufo-mini__img { width: 56px; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--photo); }
.ufo-mini__img img { width: 100%; height: 100%; object-fit: cover; filter: var(--photo-dim); }
.ufo-mini__name { font-weight: 700; line-height: 1.25; }
.ufo-mini__qty { display: block; font-size: 14px; color: var(--ink-soft); font-weight: 500; }

/* ---------- Checkout form ---------- */
.ufo-form { display: flex; flex-direction: column; }
.ufo-group { margin: clamp(32px, 4vw, 48px) 0 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 22px; }
.ufo-group > legend { padding: 0; margin-bottom: 22px; font-size: clamp(24px, 2.4vw, 32px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.05; }
.ufo-field { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 8px; }
.ufo-field > label, .ufo-choice > legend { font-weight: 700; font-size: 17px; padding: 0; }
.ufo-choice > legend { margin-bottom: 8px; }
.ufo-hint { font-size: 14px; color: var(--ink-soft); line-height: 1.45; margin-top: -4px; }
.ufo-control { position: relative; }
/* Fields are blocks, so Safari adds no line space under them: the box is exactly the field,
   and things placed inside it (the Apply button, the country flag) line up precisely. */
.ufo-control > input, .ufo-control > select { display: block; }
.ufo-control input, .ufo-control select {
  width: 100%; height: 56px; padding: 0 18px; border-radius: var(--r-small);
  border: 2px solid transparent; background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 17px; font-weight: 500;
  transition: border-color 0.2s, background-color 0.2s;
}
.ufo-control input:hover, .ufo-control select:hover { border-color: var(--line); }
.ufo-control input:focus, .ufo-control select:focus { outline: none; border-color: var(--blue); background: var(--surface); }
.ufo-control--select select { appearance: none; padding-right: 48px; cursor: pointer; }
.ufo-control--select::after {
  content: ""; position: absolute; right: 22px; top: 50%; width: 9px; height: 9px; pointer-events: none;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: translateY(-70%) rotate(45deg);
}
.ufo-control--phone input { padding-right: 190px; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.ufo-country {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); max-width: 175px;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line); pointer-events: none;
  opacity: 0; transition: opacity 0.2s;
}
.ufo-country.is-shown { opacity: 1; }
.ufo-country__flag { font-size: 18px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.ufo-country__name { overflow: hidden; text-overflow: ellipsis; }
.ufo-field.is-invalid input, .ufo-field.is-invalid select { border-color: var(--ufo-error); }
.ufo-error { color: var(--ufo-error); font-size: 14px; font-weight: 600; line-height: 1.4; }
.ufo-error:empty { display: none; }
/* Phones: the country sits on its own line under the number, so long names fit. */
@media (max-width: 600px) {
  .ufo-control--phone { display: grid; gap: 8px; }
  .ufo-control--phone input { padding-right: 18px; }
  .ufo-country { position: static; transform: none; max-width: 100%; justify-self: start; display: none; }
  .ufo-country.is-shown { display: inline-flex; }
}

/* Contact method: three pill choices */
.ufo-segments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ufo-segments label { position: relative; }
.ufo-segments input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.ufo-segments span {
  display: grid; place-items: center; height: 52px; padding: 0 12px; border-radius: 999px; text-align: center;
  border: 2px solid var(--line); color: var(--ink); font-weight: 700; font-size: 16px;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.ufo-segments label:hover span { border-color: var(--blue); }
.ufo-segments input:checked + span { background: var(--title-blue); border-color: var(--title-blue); color: #fff; }
.ufo-segments input:focus-visible + span { outline: 3px solid var(--blue-text); outline-offset: 3px; }
.ufo-segments input:disabled { cursor: not-allowed; }
.ufo-segments input:disabled + span { opacity: 0.4; text-decoration: line-through; border-style: dashed; }
.ufo-choice.is-invalid .ufo-segments span { border-color: var(--ufo-error); }
@media (max-width: 420px) { .ufo-segments span { font-size: 15px; padding: 0 6px; } }

/* Checkbox */
.ufo-check { display: flex; align-items: center; gap: 14px; cursor: pointer; font-weight: 700; font-size: 17px; width: fit-content; }
.ufo-check input {
  appearance: none; flex: none; width: 28px; height: 28px; margin: 0; border-radius: 8px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface-2); display: grid; place-items: center;
  transition: background-color 0.2s, border-color 0.2s;
}
.ufo-check input::after { content: ""; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-2px) rotate(45deg); opacity: 0; }
.ufo-check input:checked { background: var(--title-blue); border-color: var(--title-blue); }
.ufo-check input:checked::after { opacity: 1; }
.ufo-check:hover input { border-color: var(--blue); }
.ufo-check--addon { width: 100%; }
.ufo-check__price { margin-left: auto; font-weight: 700; color: var(--ink-soft); }
.ufo-note { padding: 18px 20px; border-radius: var(--r-tile); background: var(--blue-tint); }
.ufo-note p { font-size: 15px; line-height: 1.55; }
.ufo-recipient { display: grid; gap: 22px; padding: 22px; border-radius: var(--r-tile); background: var(--surface-2); }
.ufo-recipient .ufo-control input { background: var(--surface); }

/* Spam trap: off-screen for people */
.ufo-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.ufo-form .ufo-alert { margin-top: 32px; }
.ufo-submit { margin-top: clamp(32px, 4vw, 48px); min-height: 60px; font-size: 19px; }
.ufo-form .ufo-alert:not([hidden]) + .ufo-submit { margin-top: 16px; }
.ufo-submit[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.ufo-form .ufo-fine { margin-top: 14px; text-align: center; }

/* ---------- Confirmation ---------- */
.ufo-received { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px clamp(32px, 5vw, 80px); padding-block: clamp(40px, 6vw, 88px); }
.ufo-received__top { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.ufo-status {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  background: #fff; color: #0091cc; font-weight: 800; font-size: 15px;
}
.ufo-received [data-save-receipt] { --btn-ink: #0091cc; }
.ufo-status::before { content: ""; width: 9px; height: 9px; border-radius: 999px; background: #f2a20c; }
.ufo-received__title { font-size: clamp(48px, 7.4vw, 108px); line-height: 0.95; letter-spacing: -0.04em; }
.ufo-received__number { font-size: clamp(24px, 2.6vw, 36px); font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ufo-received__text { font-size: clamp(18px, 1.6vw, 22px); font-weight: 600; line-height: 1.45; max-width: 40ch; }
.ufo-received__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btn--on-blue-outline { --btn-bg: transparent; --btn-ink: #fff; --fill: #fff; --fill-ink: #00618b; border-color: #fff; }
@media (max-width: 860px) {
  .ufo-received { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .ufo-received__actions { justify-content: flex-start; }
}
.ufo-receipt { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px clamp(32px, 5vw, 80px); }
.ufo-receipt__col { display: flex; flex-direction: column; gap: 22px; }
.ufo-receipt__col .ufo-receipt__title:not(:first-child) { margin-top: 18px; }
.ufo-receipt__title { font-size: clamp(24px, 2.4vw, 32px); }
.ufo-facts { margin: 0; display: grid; gap: 12px; }
.ufo-facts div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 16px; padding-top: 12px; border-top: 2px solid var(--line); }
.ufo-facts dt { color: var(--ink-soft); font-size: 15px; }
.ufo-facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .ufo-receipt { grid-template-columns: minmax(0, 1fr); }
  .ufo-facts div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* ---------- Discount code at checkout ---------- */
.ufo-optional { font-weight: 500; color: var(--ink-soft); }
/* The Apply button sits inside the field, at its right end, 6px from the edges. */
.ufo-code__row input { height: 56px; padding-right: 112px; text-transform: uppercase; letter-spacing: 0.04em; }
.ufo-code__row input::placeholder { text-transform: none; letter-spacing: 0; }
.ufo-code__apply {
  position: absolute; right: 6px; top: 6px; height: 44px; padding: 0 20px; /* 56px field − 6px above and below */
  border: 0; border-radius: 9px; /* follows the field's 14px corner, 6px further in */
  background: var(--blue-tint); color: var(--title-blue); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.ufo-code__apply:hover { background: var(--title-blue); color: #fff; }
.ufo-code__apply:disabled { opacity: 0.6; cursor: progress; }
.ufo-code__apply:focus-visible { outline-offset: 2px; }
.ufo-code__applied { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 14px 18px; border-radius: var(--r-small); background: var(--blue-tint); font-weight: 600; }
.ufo-discount { color: #1d7a43; }
:root[data-theme="dark"] .ufo-discount { color: #4cc77d; }

