/*
 * Baseline stylesheet.
 *
 * Component styles do NOT live here — they will live in the `style` table and be
 * assembled per request. That engine is not built yet; see docs/ROADMAP.md.
 * This file is the ground the site stands on: reset, typography, the handful of
 * rules the seed components use, and the admin panel (docs/ADMIN.md).
 */

:root {
  --ink: #14161a;
  --muted: #5c6470;
  --line: #e3e6ea;
  --bg: #ffffff;
  --accent: #2b5cff;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eaee;
    --muted: #9aa3b0;
    --line: #262b33;
    --bg: #101317;
    --accent: #7d9bff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.layout { max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; }

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
.site-header .brand { font-weight: 650; font-size: 1.15rem; text-decoration: none; color: var(--ink); }
.site-header nav { display: flex; gap: 1rem; }

main { padding: 2rem 0 3rem; }

.site-footer { padding: 1.5rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.35rem; }

.hero p { color: var(--muted); max-width: 42rem; }

.button {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.products { display: grid; gap: 1rem; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.card h2 a { text-decoration: none; }
.card .summary { color: var(--muted); margin: 0.25rem 0 0.5rem; }
.price { font-variant-numeric: tabular-nums; margin: 0 0 0.5rem; }

.badge { font-size: 0.8rem; padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); }
.badge.in { color: #1a7f4b; }
.badge.out { color: #a13b3b; }

.notice, .empty { color: var(--muted); }

.is-highlighted { color: var(--accent); }


/* ===========================================================================
 * Admin panel.
 *
 * Here rather than in the `style` table for one reason: the admin has to be
 * usable while the style engine does not exist, and it has to keep working if
 * someone breaks their own styles. It is the tool you fix the site with.
 * =========================================================================== */

.admin { display: flex; flex-direction: column; min-height: 100vh; }

.admin-bar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.6rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, var(--ink));
}
.admin-brand { font-weight: 600; text-decoration: none; color: var(--ink); }
.admin-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.admin-nav a { color: var(--muted); text-decoration: none; }
.admin-nav a:hover { color: var(--accent); }
.admin-signout { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.admin-who { color: var(--muted); font-size: 0.85rem; }
.admin-who em { font-style: normal; padding: 0.1rem 0.4rem; border: 1px solid var(--line); border-radius: 999px; }
.admin-main { flex: 1; padding: 1.5rem 1.2rem; max-width: 68rem; width: 100%; margin: 0 auto; }
.admin-foot { padding: 1rem 1.2rem; border-top: 1px solid var(--line); color: var(--muted); }

.admin-login { max-width: 22rem; margin: 6rem auto; padding: 0 1rem; }

.page-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; flex: 1; }

.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.15rem; margin-bottom: 1.25rem;
}
.panel h2 { margin-top: 0; font-size: 1.05rem; }
.panel h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 1rem 0 0.4rem; }
.panel.warn { border-color: #d9a441; }
.panel.notice { color: var(--muted); }

/* The component preview: one component, on its own, editable by clicking.
   Resizable rather than tall-by-guess — a nav bar and a landing page are not
   the same shape, and the frame has no way to know which it is holding. */
.preview-frame {
  width: 100%; height: 32rem; min-height: 8rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); resize: vertical; overflow: auto; display: block;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.9rem; }
.stat b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85rem; }

/* Forms ------------------------------------------------------------------ */

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 500; margin-bottom: 0.3rem; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="date"], .field select, .field textarea {
  width: 100%; padding: 0.5rem 0.6rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.field input[type="checkbox"] { width: auto; }
.field .req { color: #a13b3b; }
.help { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0; }

.mono, textarea.mono, input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
textarea[data-editor] { min-height: 24rem; line-height: 1.45; tab-size: 2; }

.actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
button { font: inherit; padding: 0.5rem 1rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
/* Two different disabled states, and they had one appearance between them.
   `opacity: 0.6` was written for the second or so a form spends in flight; on an
   order that ALREADY has a waybill it left ПОДГОТВИ looking very much like a
   button somebody should press. A permanently disabled control is drawn flat and
   grey so that "there is nothing to do here" is legible across a room. */
button:disabled { background: none; border-color: var(--line); color: var(--muted); cursor: not-allowed; }
form.is-busy button:disabled:not(.link) {
  background: var(--accent); border-color: var(--accent); color: #fff;
  opacity: 0.6; cursor: progress;
}
button.link, button.link-danger { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; }
button.link-danger { color: #a13b3b; }
form.inline { display: inline-block; margin-right: 0.75rem; }
form.danger { margin-top: 1.5rem; }

/* Messages painted by app/functions/admin-form.js ------------------------- */

.form-message { padding: 0.55rem 0.8rem; border-radius: 6px; margin: 0 0 1rem; }
.form-message.ok { background: color-mix(in srgb, #1a7f4b 12%, transparent); color: #1a7f4b; }
.form-message.error { background: color-mix(in srgb, #a13b3b 12%, transparent); color: #a13b3b; }
.field-error { color: #a13b3b; font-size: 0.85rem; margin: 0.3rem 0 0; }
.has-error { border-color: #a13b3b !important; }
.template-errors { margin-top: 0.5rem; color: #a13b3b; font-size: 0.85rem; }
.template-errors ul { margin: 0; padding-left: 1.1rem; }
.is-dirty .actions::after { content: "unsaved"; color: var(--muted); font-size: 0.85rem; align-self: center; }

/* Tables ----------------------------------------------------------------- */

.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.grid td.num, .grid td.right { text-align: right; font-variant-numeric: tabular-nums; }
.grid form { display: inline; }

.tag { font-size: 0.75rem; padding: 0.1rem 0.45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.published { color: #1a7f4b; }
.tag.draft { color: var(--muted); }
.tag.error { color: #a13b3b; }
.chip { display: inline-block; font-size: 0.85rem; padding: 0.15rem 0.5rem; margin: 0 0.3rem 0.3rem 0; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: inherit; }

.muted { color: var(--muted); }
.list { margin: 0; padding-left: 1.1rem; }
.log { margin: 0.3rem 0; font-size: 0.9rem; }
.pager { color: var(--muted); font-size: 0.9rem; }
.row-card h2 { margin: 0 0 0.2rem; font-size: 1rem; }


/* ===========================================================================
 * The paper order admin (docs/PAPER-ADMIN.md).
 *
 * Here rather than in the `style` table for the same reason the admin panel is:
 * it is a tool people use to move money and book couriers, and it has to keep
 * working while the style engine does not exist and if someone breaks their own
 * styles. Built on the same variables as everything above, so it follows the
 * light and dark palettes without a second definition.
 * =========================================================================== */

.paper { display: flex; flex-direction: column; min-height: 100vh; }

.paper-bar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.6rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, var(--ink));
  position: sticky; top: 0; z-index: 5;
}
.paper-brand { font-weight: 650; text-decoration: none; color: var(--ink); }
.paper-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.paper-nav a { color: var(--muted); text-decoration: none; }
.paper-nav a:hover { color: var(--accent); }
.paper-who { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.paper-who em { font-style: normal; padding: 0.1rem 0.4rem; border: 1px solid var(--line); border-radius: 999px; }
.paper-main { flex: 1; width: 100%; max-width: 78rem; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }

.page-head .head-side { display: flex; align-items: center; gap: 0.75rem; }

/* Filters ------------------------------------------------------------------ */

.filters { padding: 0.75rem 1rem; }
.filter-row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.filter-row label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.filter-row input[type="text"], .filter-row select {
  padding: 0.4rem 0.55rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--ink); font: inherit; min-width: 11rem;
}
.filter-row .chip { align-self: center; }

/* One order ---------------------------------------------------------------- */

.orders { display: flex; flex-direction: column; gap: 0.9rem; margin: 0.5rem 0 1.5rem; }

.order {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 97%, var(--ink));
  overflow: hidden;
}
.order.odd { background: var(--bg); }

.order-head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.1rem 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.order-cell { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; font-size: 0.92rem; }
.order-cell > div { overflow-wrap: anywhere; }
.order-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
}
.order-where { grid-column: span 2; }

/* Each delivery line says which of the three it is. The marker is the quiet
   half — the operator is scanning for the value, and having to work out whether
   a middle line is an office or a street is what the label removes. */
.order-field { display: flex; gap: 0.35rem; align-items: baseline; }
.order-field .mark { flex: 0 0 auto; color: var(--muted); }
.order-field .value { min-width: 0; overflow-wrap: anywhere; }

.order .legacy { margin: 0; padding: 0.4rem 1rem; font-size: 0.8rem; border-bottom: 1px solid var(--line); }

.order-products { list-style: none; margin: 0; padding: 0.5rem 1rem; }
.order-product { display: flex; gap: 0.75rem; align-items: baseline; padding: 0.15rem 0; }
.order-product .qty { color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.order-product .title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
/* A product whose page is known is an <a class="title">, one whose page is not
   is a <span class="title">. Both keep the row's layout because the selector
   above is a class; only the link takes the underline, and only on hover, so a
   long order does not read as a wall of blue. */
a.title { color: inherit; text-decoration: none; }
a.title:hover, a.title:focus-visible { text-decoration: underline; color: var(--link, #0645ad); }
.order-product.empty { color: var(--muted); font-size: 0.9rem; }
.order-product .money { text-align: right; }

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The lev amount, under the euro one. Second, smaller and grey, because it is
   there to be checked against rather than read: euro is what the customer pays
   and what the courier is told to collect. */
.money-alt {
  display: block; font-size: 0.78rem; font-weight: 400;
  color: var(--muted); white-space: nowrap;
}
td.money, th.money { text-align: right; }

.order-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.5rem 1rem; border-top: 1px solid var(--line);
  font-weight: 600;
}

.order-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap; padding: 0.6rem 1rem; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, var(--ink));
}
.order-speditor { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.order-speditor .tracking { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.order-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.order-actions form { margin: 0; }
.order-actions button { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.order .form-message { margin: 0.4rem 1rem; }

/* The shipment accordion.
   `<details>` does the opening and closing, so there is no state to style around
   and no script to load — only the marker, which browsers draw differently
   enough to be worth replacing. */
.order-shipment { border-top: 1px solid var(--line); }
.order-shipment > summary {
  display: flex; align-items: baseline; gap: 0.5rem; cursor: pointer;
  padding: 0.55rem 1rem; font-size: 0.9rem; list-style: none;
  background: color-mix(in srgb, var(--bg) 94%, var(--ink));
}
.order-shipment > summary::-webkit-details-marker { display: none; }
.order-shipment > summary::before {
  content: "▸"; color: var(--muted); font-size: 0.8rem;
  transition: transform 0.12s ease; display: inline-block;
}
.order-shipment[open] > summary::before { transform: rotate(90deg); }
.order-shipment > summary:hover { background: color-mix(in srgb, var(--bg) 86%, var(--ink)); }
.order-shipment .shipment-title { font-weight: 600; }

.shipment-form { padding: 0.8rem 1rem 1rem; }
.shipment-form .notice { margin: 0 0 0.8rem; }
.shipment-grid {
  display: grid; gap: 0.7rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.shipment-grid .field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0; }
.shipment-grid .field > span { font-size: 0.8rem; color: var(--muted); }
.shipment-grid .field small { font-size: 0.75rem; }
/* An address is longer than a name; giving it the whole row stops it being the
   one field nobody can read what they typed into. */
.shipment-grid .wide { grid-column: 1 / -1; }
.shipment-form .actions { margin-top: 0.9rem; }

/* The two place fields: a search box, and the courier's own list under it. The
   SELECT is the answer — it holds the ids a shipment is actually made with — so
   it is the emphasised control, and the search box above it reads as the way to
   reach it rather than as a competing field. Nothing typed into the search box
   is submitted or stored; see app/functions/paper-orders.js. */
.shipment-grid .field.place select {
  border-color: color-mix(in srgb, var(--line) 40%, var(--accent));
}
.shipment-grid .field.place .place-search {
  font-size: 0.85rem;
  background: color-mix(in srgb, var(--bg) 94%, var(--ink));
}
/* The office dropdown and the address box are alternatives, and the toggle above
   them says which one this parcel uses. `display: flex` on .field is what makes
   the `hidden` attribute need saying again here: without this the browser's own
   `[hidden] { display: none }` loses to the rule above it, and both controls stay
   on screen. Set only by the FUNCTION — with no JavaScript neither is hidden and
   the form is the one migration 012 shipped, with both fields visible. */
.shipment-grid .field[hidden] { display: none; }
/* A delivery to an address has no office to choose. The dimming stays for the
   moment between the toggle changing and the field being hidden, and for a form
   whose office field is on screen but not usable. */
.shipment-grid .field.place.is-address select,
.shipment-grid .field.place.is-address .combo-button,
.shipment-grid .field.place.is-address .place-search { opacity: 0.45; }

/* The office/address toggle: two radios drawn as one segmented control. Real
   radios, because this is the control that decides where a parcel goes and it
   has to work in a form that is submitted without JavaScript — the appearance is
   CSS over the inputs, never a div pretending to be one. */
.shipment-grid .field.dest .toggle {
  display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
}
.shipment-grid .field.dest .toggle label {
  flex: 1; margin: 0; text-align: center; cursor: pointer;
  padding: 0.35rem 0.5rem; font-size: 0.9rem;
  background: color-mix(in srgb, var(--bg) 94%, var(--ink));
}
.shipment-grid .field.dest .toggle label + label { border-left: 1px solid var(--line); }
/* The input itself is off-screen rather than `display: none`, so it keeps its
   place in the tab order and can still be reached from the keyboard. */
.shipment-grid .field.dest .toggle input {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.shipment-grid .field.dest .toggle label:has(input:checked) {
  background: var(--accent); color: var(--bg); font-weight: 500;
}
.shipment-grid .field.dest .toggle label:has(input:focus-visible) {
  outline: 2px solid var(--accent); outline-offset: -2px;
}

/* A place field is one control: its search box is moved inside the list it
   searches (migrations 015 and 016, app/functions/paper-orders.js). Both fields,
   both forms. The <select> is still the control that is submitted — it is hidden,
   not removed, and only once the JavaScript that replaces it has actually run and
   added `has-combo`. Without that class, and so without JavaScript, everything
   below is inert and the field is the plain box-above-a-dropdown it has always
   been. */
.shipment-grid .field.place.has-combo > select { display: none; }
.shipment-grid .field.place .combo { position: relative; }
.shipment-grid .field.place .combo-button {
  width: 100%; text-align: left; padding: 0.35rem 1.6rem 0.35rem 0.5rem;
  background: var(--bg); color: var(--ink); font: inherit; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--line) 40%, var(--accent));
  border-radius: 4px;
  /* One line, ellipsised. A town with its disambiguator is long, and a control
     that grows to fit reflows the whole grid. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* The caret, so a closed combobox reads as something that opens. */
.shipment-grid .field.place .combo::after {
  content: "▾"; position: absolute; right: 0.5rem; top: 0.4rem;
  pointer-events: none; color: var(--muted); font-size: 0.8rem;
}
/* Nothing chosen: the placeholder — or, on an order with no waybill, the
   customer's own words — is greyed, because it is a thing to match and not a
   thing that was matched. */
.shipment-grid .field.place .combo.is-empty .combo-button { color: var(--muted); }
/* An address delivery has no office to choose. */
.shipment-grid .field.place .combo-button[disabled] { cursor: default; }

.shipment-grid .field.place .combo-panel {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px);
  display: flex; flex-direction: column; gap: 0.3rem; padding: 0.4rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 18%);
}
/* `display` beats the `hidden` attribute, so a closed panel needs saying twice.
   Without this line the panel is open from the moment the page renders. */
.shipment-grid .field.place .combo-panel[hidden] { display: none; }
.shipment-grid .field.place .combo-panel .place-search { width: 100%; }
.shipment-grid .field.place .combo-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 14rem; overflow-y: auto;
}
.shipment-grid .field.place .combo-option {
  padding: 0.25rem 0.4rem; border-radius: 3px; cursor: pointer;
  font-size: 0.9rem;
}
.shipment-grid .field.place .combo-option:hover,
.shipment-grid .field.place .combo-option.is-active {
  background: color-mix(in srgb, var(--bg) 88%, var(--accent));
}
.shipment-grid .field.place .combo-option.is-chosen { font-weight: 600; }
.shipment-grid .field.place .combo-empty {
  list-style: none; padding: 0.35rem 0.4rem;
  color: var(--muted); font-size: 0.8rem;
}

/* Nothing has been edited, so there is nothing to send to a courier about a
   parcel that already exists. The hint says which of the two it is, because a
   disabled button with no reason next to it reads as broken. */
.shipment-form .actions { display: flex; align-items: center; gap: 0.7rem; }
.shipment-form.is-unchanged button[type="submit"] { opacity: 0.55; cursor: not-allowed; }

.pager-nav { display: flex; align-items: center; gap: 1rem; justify-content: center; }

/* Payouts ------------------------------------------------------------------ */

.payout-run { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.payout-run .confirm {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.75rem 0.9rem; border: 1px solid #d9a441; border-radius: var(--radius);
  background: color-mix(in srgb, #d9a441 8%, transparent);
}
.payout-run .confirm input { margin-top: 0.25rem; }
.payout-run .actions { margin-top: 0.75rem; }

@media (max-width: 720px) {
  .order-head { grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); }
  .order-where { grid-column: 1 / -1; }
  .order-foot { flex-direction: column; align-items: stretch; }
  .order-actions { margin-left: 0; }
}

/* The storefront -----------------------------------------------------------
 *
 * The customer-facing shop (docs/PAPER-SHOP.md). Here rather than in the `style`
 * table for the same reason as everything above it: that engine is not built
 * (docs/ROADMAP.md), and a product page with no stylesheet is not a page
 * anybody can be shown.
 *
 * ## The colours are the shop's own
 *
 * Every value below comes from the Angular app's `src/scss/variables.scss` —
 * #00c6cf, #3B3B3B, #FF2929, #E3E0F3, a 68.75rem measure and a 0.2rem radius —
 * read out of the project rather than sampled off a screenshot. See D76.
 *
 * ## Why it declares its own tokens
 *
 * The stylesheet above has a `prefers-color-scheme: dark` block, and the shop
 * must not follow it. This is not a themeable surface: its dark bands are dark
 * BECAUSE the page around them is white, and a viewer whose laptop is in dark
 * mode would otherwise get a dark band on a dark page, which is no band at all.
 * So `.shop` sets what it needs and inherits no colour. The admin panel and the
 * framework's own pages are untouched and still follow the system.
 */

.shop {
  --teal: #00c6cf;
  --dark: #3b3b3b;
  --light: #e3e0f3;
  --red: #ff2929;
  --paper: #ffffff;
  --measure: 68.75rem;
  --r: 0.2rem;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 30%);
  --shadow-lg: 0 4px 12px 0 rgb(0 0 0 / 70%);

  /* Named but never loaded upstream either — the live site falls back to the
     system faces, so naming them first and a generic second is the same result
     there and a better one on a machine that happens to have them. Loading a
     web font would mean a second origin in the CSP and a request the framework
     does not otherwise make. See D76. */
  --sans: 'Open Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --serif: 'Playfair Display', 'Noto Serif', Georgia, 'Times New Roman', serif;

  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--paper);
  color: var(--dark);
  font-family: var(--sans);
}

.shop a { color: inherit; }

/* The bar ------------------------------------------------------------------ */

.shop-bar {
  display: flex; align-items: center; gap: 1.2rem;
  padding: 0.55rem 1.2rem;
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.shop-brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font: 700 1.6rem/1 var(--sans);
  color: var(--teal);
  text-decoration: none;
}

/* The wordmark's triangle, as a shape rather than an image: one less request,
   and it cannot 404. */
.shop-mark {
  width: 1.15rem; height: 1.15rem;
  background: var(--dark);
  clip-path: polygon(0 100%, 100% 100%, 100% 0);
}

.shop-nav { display: flex; gap: 1.1rem; margin-right: auto; }
.shop-nav a {
  color: var(--dark); text-decoration: none;
  font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.shop-nav a:hover { color: var(--teal); }

.shop-cart-open {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: none; border: 0; cursor: pointer; padding: 0.3rem;
  color: var(--teal);
}

/* A cart drawn in CSS, for the same reason as the wordmark's triangle. */
.cart-glyph {
  width: 1.7rem; height: 1.35rem; position: relative; display: inline-block;
}
.cart-glyph::before {
  content: ''; position: absolute; inset: 0 0 0.4rem 0;
  border: 0.19rem solid currentColor; border-top-width: 0;
  border-radius: 0 0 var(--r) var(--r);
}
.cart-glyph::after {
  content: ''; position: absolute; left: 0.28rem; right: 0.28rem; bottom: 0;
  height: 0.34rem; border-radius: 50%;
  box-shadow: -0.28rem 0 0 currentColor, 0.28rem 0 0 currentColor;
}

/* The badge is `hidden` until there is something in the basket, so an empty
   cart shows no number at all rather than a nought. */
.cart-badge {
  min-width: 1.25rem; height: 1.25rem; padding: 0 0.3rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--red); color: #fff;
  font: 700 0.75rem/1 var(--sans);
}

/* `display: inline-flex` above beats the `hidden` attribute's `display: none` —
   same specificity, and this rule comes later. Without it an emptied basket
   leaves a red dot with no number in it, which is what the header looked like
   the first time checkout cleared the cart. The same trap as `.cart-panel`. */
.cart-badge[hidden] { display: none; }

.shop-main { flex: 1 1 auto; }

.shop-foot {
  background: var(--dark); color: #fff;
  padding: 2rem 1.2rem; text-align: center;
  font-family: var(--serif);
}

.shop-foot .help { margin: 0.6rem 0 0; }
.shop-foot .link { color: #fff; opacity: 0.75; }

/* The consent banner --------------------------------------------------------
 *
 * Shown by app/functions/paper-shop-shell.js, and only when there is a pixel
 * configured and nobody has answered yet.
 *
 * A bar along the bottom rather than a modal over the middle: nothing behind it
 * is blocked, so a visitor who wants to read about a book before deciding about
 * cookies can. Above the cart panel's z-index would be wrong for the same
 * reason — the panel is what somebody pressed a button to open, and this is not.
 */
.consent {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: center; justify-content: center;
  padding: 1rem 1.2rem;
  background: var(--dark); color: #fff;
  font: 0.85rem/1.5 var(--sans);
  box-shadow: var(--shadow-lg);
}

/* `display: flex` above beats the `hidden` attribute's `display: none` — same
   specificity, later rule. The same trap as `.cart-panel` and `.cart-badge`,
   and the third time is why it is worth a comment on each of them. */
.consent[hidden] { display: none; }

.consent-text { margin: 0; max-width: 46rem; }

.consent-actions { display: flex; gap: 0.6rem; flex: 0 0 auto; }

.consent .buy { padding: 0.55rem 1.4rem; font-size: 0.8rem; }

.consent-deny {
  padding: 0.55rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 2px;
  background: none; color: #fff; cursor: pointer;
  font: 700 0.8rem/1 var(--sans); text-transform: uppercase;
}

.consent-deny:hover { border-color: #fff; }

/* The measure -------------------------------------------------------------- */

.book-list-head,
.product-main,
.product-features,
.product-tiers,
.product-gallery,
.product-signed,
.product-author,
.product-testimonials,
.books {
  width: var(--measure); max-width: 100%;
  margin-inline: auto;
  padding-inline: 1.2rem;
}

/* The buy bar --------------------------------------------------------------
 *
 * The shop's signature: one red band carrying the call to action and the price
 * together. `39⁰⁰лв` is three spans from `price_parts`, split in the resolver
 * because a template has no expressions (D2).
 */

.buy-bar {
  display: flex; align-items: stretch; justify-content: center;
  gap: 0; margin: 2rem 0;
  background: var(--red); color: #fff;
  text-decoration: none;
  border-radius: var(--r);
  overflow: hidden;
}

.buy-bar .buy {
  display: flex; align-items: center; justify-content: center;
  flex: 0 1 22rem;
  padding: 1.1rem 1.5rem;
  background: none; border: 0; color: inherit; cursor: pointer;
  font: 700 1.35rem/1.1 var(--sans);
  text-transform: uppercase; letter-spacing: 0.03em;
  text-align: center;
}
/* The pressable half is the half that lights up. On the product page and on a
   catalogue card the bar is a <div> holding a button and a price, so brightening
   the whole band would offer a press on the price tag that does not exist. The
   unpriced card's bar IS a link, and keeps the whole-bar hover. */
.buy-bar .buy:hover { filter: brightness(1.08); }
a.buy-bar:hover { filter: brightness(1.08); }

.buy-bar .price-tag {
  display: flex; align-items: center; gap: 0.9rem;
  margin: 0; padding: 0.75rem 1.5rem;
  border-left: 2px solid rgb(255 255 255 / 45%);
}

/* A large whole number with the stotinki raised beside it and the unit under
   them. `align-items: flex-start` on the fraction is what stacks the two
   without either of them moving the baseline of the whole. */
.price-tag .amount {
  display: inline-flex; align-items: flex-start;
  font: 700 2.1rem/1 var(--sans);
}
.price-tag .amount.second { font-size: 1.55rem; opacity: 0.92; }
.price-tag .frac {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  margin-left: 0.1em;
  font-size: 0.44em; line-height: 1.05; font-weight: 700;
}
.price-tag .unit { text-transform: lowercase; }

/* The catalogue ------------------------------------------------------------
 *
 * Dark, as upstream sets it: the covers are the page, and a dark ground is what
 * lets a hundred of them sit together without every white cover fighting the
 * one beside it.
 */

.book-list { background: var(--dark); color: #fff; padding-bottom: 3rem; }

.book-list-head { padding-block: 2.5rem 1.5rem; text-align: center; }
.book-list-head h1 {
  margin: 0; font: 400 2.6rem/1.15 var(--serif); color: #fff;
}
.book-list-head .muted { color: var(--light); opacity: 0.75; }

/* Four across on a wide screen rather than upstream's two.
 *
 * Upstream shows two enormous cards, which is right for a landing page showing
 * a handful of titles and wrong for a hundred and two: it turns the catalogue
 * into fifty screens of scrolling. The card keeps its proportions and the grid
 * decides how many fit. See D76. */
.books {
  display: grid; gap: 2.5rem 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  padding-top: 1rem;
}

.book-card { display: flex; flex-direction: column; text-align: center; }

.book-card-title { margin: 0 0 0.15rem; font: 400 1.25rem/1.25 var(--serif); }
.book-card-title a { text-decoration: none; }
.book-card-title a:hover { color: var(--teal); }
.book-card-sub { margin: 0 0 0.5rem; font: 400 0.95rem/1.3 var(--serif); color: var(--light); opacity: 0.8; }

.book-card-cover {
  display: block; margin: 0.6rem 0 0.9rem;
}
/* A fixed ratio, because the covers are not one shape: they are somebody
   else's photographs of somebody else's mockups, and a grid whose rows are as
   tall as their tallest picture reads as an accident. `contain` letterboxes
   rather than crops — cutting the top off a book cover is worse than a margin. */
.book-card-cover img {
  width: 100%; height: auto; display: block;
  aspect-ratio: 3 / 4; object-fit: contain;
  filter: drop-shadow(var(--shadow-lg));
  transition: transform 0.18s ease;
}
.book-card-cover:hover img { transform: translateY(-4px); }

.book-card-author {
  margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--light);
  text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.75;
}

/* The card's bar is smaller than the product page's, and pinned to the bottom so
   a row of cards with titles of different lengths still lines its bars up. */
.book-card .buy-bar { margin: auto 0 0; }
.book-card .buy-bar .buy { flex: 1 1 auto; padding: 0.7rem 0.6rem; font-size: 0.9rem; }
.book-card .buy-bar .price-tag { padding: 0.45rem 0.7rem; gap: 0.55rem; }
.book-card .price-tag .amount { font-size: 1.3rem; }
.book-card .price-tag .amount.second { font-size: 1rem; }
.book-card .buy-bar.quiet { background: var(--light); color: var(--dark); }

.book-card-was { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--light); }
.book-card-was s { opacity: 0.7; }

/* The product page --------------------------------------------------------- */

.product-head { text-align: center; }

/* The tagline strip: teal, full bleed, the line the book is sold on. */
.product-eyebrow {
  margin: 0; padding: 0.7rem 1.2rem;
  background: var(--teal); color: #fff;
  font: 400 1.35rem/1.3 var(--serif);
}
.product-eyebrow:empty { display: none; }

/* The title band. */
.product-head h1 {
  margin: 0; padding: 1.4rem 1.2rem;
  background: var(--dark); color: #fff;
  font: 700 2.6rem/1.15 var(--sans);
}
.product-sub {
  margin: 0; padding: 0 1.2rem 1.4rem;
  background: var(--dark); color: var(--light);
  font: 400 1.15rem/1.4 var(--serif);
}
.product-sub:empty { display: none; }

.product-main {
  display: grid; gap: 2.5rem;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding-block: 3rem;
}

/* The cover is second in the DOM's source order because the page is about the
   book before it is about the picture; on a wide screen it belongs on the right,
   which is what `order` is for. */
.product-cover { margin: 0; order: 2; }
.product-cover img {
  width: 100%; height: auto; display: block;
  filter: drop-shadow(var(--shadow-lg));
}

.product-buy { order: 1; }

/* The pitch: the argument for the book, set as upstream sets it — teal,
   uppercase, centred, and the largest thing in the column. */
.product-pitch { margin: 0 0 1.75rem; text-align: center; }
.product-pitch p {
  margin: 0; color: var(--teal);
  font: 700 1.85rem/1.25 var(--sans);
  text-transform: uppercase;
}

/* The prose, with the shop's red square instead of a bullet. */
.product-points { margin: 0; padding: 0; list-style: none; }
.product-points li {
  position: relative; padding-left: 1.6rem; margin-bottom: 1.1rem;
  font: 400 1.15rem/1.5 var(--serif);
}
.product-points li::before {
  content: ''; position: absolute; left: 0; top: 0.45em;
  width: 0.7rem; height: 0.7rem; background: var(--red);
}

/* The call to action, spanning the measure below both columns: the argument is
   made first, and then the price is asked for. */
.product-cta {
  width: var(--measure); max-width: 100%;
  margin-inline: auto; padding-inline: 1.2rem;
  text-align: center;
}
.product-cta .buy-bar { margin-block: 0.75rem; }

.product-was { margin: 0; font-size: 1rem; }
.product-was .price-was { color: var(--dark); opacity: 0.6; }

.product-price { font: 700 1.6rem/1 var(--sans); margin: 1rem 0; }
.product-pages { margin: 0 0 1rem; }

/* The reassurance row ------------------------------------------------------ */

.product-features {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  padding-block: 1rem 3rem;
  text-align: center;
}
.feature { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.feature-icon {
  width: 3.2rem; height: 3.2rem; border-radius: 50%;
  background: var(--teal);
}
.feature p {
  margin: 0; color: var(--teal);
  font: 700 0.95rem/1.35 var(--sans);
  text-transform: uppercase; letter-spacing: 0.03em;
}

/* The bundles -------------------------------------------------------------- */

.product-tiers { padding-block: 2.5rem; }
.product-tiers h2 {
  margin: 0 0 1.5rem; text-align: center;
  font: 400 2rem/1.2 var(--serif);
}
.tiers {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
.tier {
  border: 2px solid var(--light); border-radius: var(--r);
  padding: 1.5rem 1rem; text-align: center; background: var(--paper);
}
.tier-qty {
  margin: 0 0 0.5rem; color: var(--teal);
  font: 700 1.1rem/1 var(--sans); text-transform: uppercase;
}
.tier-total { margin: 0 0 0.35rem; font: 700 1.7rem/1 var(--sans); }
.tier-total .price-eur { font-size: 1rem; font-weight: 400; opacity: 0.7; }
.tier .muted { font-size: 0.9rem; }
.tier button {
  margin-top: 1rem; width: 100%;
  padding: 0.75rem 1rem; border: 0; border-radius: var(--r); cursor: pointer;
  background: var(--red); color: #fff;
  font: 700 1rem/1 var(--sans); text-transform: uppercase;
}
.tier button:hover { filter: brightness(1.08); }

/* The prose and the pictures ----------------------------------------------- */

.product-gallery, .product-signed { padding-block: 2.5rem; }
.product-gallery h2, .product-signed h2, .product-testimonials h2 {
  margin: 0 0 0.5rem; text-align: center;
  font: 400 2rem/1.2 var(--serif);
}
.product-gallery .help { text-align: center; margin-bottom: 1.5rem; }

.gallery {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}
.gallery img {
  width: 100%; height: auto; display: block;
  border-radius: var(--r); box-shadow: var(--shadow);
}

.product-author {
  display: flex; gap: 1.5rem; align-items: flex-start;
  padding: 2rem 1.2rem; margin-block: 2.5rem;
  background: var(--light); border-radius: var(--r);
}
.product-author h2 { margin: 0 0 0.75rem; font: 400 1.7rem/1.2 var(--serif); }
.product-author p { margin: 0 0 0.75rem; font: 400 1.05rem/1.55 var(--serif); }
.author-image {
  width: 9rem; height: 9rem; border-radius: 50%; object-fit: cover;
  flex: 0 0 auto; box-shadow: var(--shadow);
}

.product-testimonials { padding-block: 2.5rem 3.5rem; }
.product-testimonials blockquote {
  margin: 0 0 1.5rem; padding: 1.5rem;
  border-left: 4px solid var(--teal); background: #fafafa;
  border-radius: 0 var(--r) var(--r) 0;
}
.product-testimonials blockquote p { margin: 0 0 0.75rem; font: 400 1.05rem/1.55 var(--serif); }
.product-testimonials blockquote img {
  width: 3rem; height: 3rem; border-radius: 50%; object-fit: cover; float: left;
  margin: 0 1rem 0.5rem 0;
}

/* The cart panel -----------------------------------------------------------
 *
 * Drawn by app/functions/paper-shop-shell.js; the frame is in the component.
 */
.cart-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 30;
  width: min(24rem, 100%);
  display: flex; flex-direction: column;
  background: var(--paper); color: var(--dark);
  box-shadow: var(--shadow-lg);
  font-family: var(--sans);
}

/* `display: flex` above beats the `hidden` attribute's `display: none` — same
   specificity, and this rule comes later — so without this line the panel is
   open on every page, which is exactly how it shipped in BP-19. Same trap the
   comment at `.shipment-grid .field[hidden]` warns about. */
.cart-panel[hidden] { display: none; }

.cart-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; background: var(--teal); color: #fff;
}
.cart-panel-head h2 { margin: 0; font: 700 1.15rem/1 var(--sans); text-transform: uppercase; }
.cart-close {
  background: none; border: 0; color: #fff; cursor: pointer;
  font-size: 1.6rem; line-height: 1; padding: 0 0.25rem;
}

.cart-empty { padding: 2rem 1.2rem; text-align: center; }
.cart-lines { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; }

.cart-line {
  display: flex; gap: 0.75rem; align-items: center;
  padding: 0.75rem 1.2rem; border-bottom: 1px solid var(--light);
}
.cart-line-cover { width: 3rem; height: auto; flex: 0 0 auto; }
.cart-line-body { flex: 1 1 auto; min-width: 0; }
.cart-line-title { margin: 0 0 0.15rem; font-size: 0.9rem; font-weight: 600; }
.cart-line-price { margin: 0; font-size: 0.85rem; color: var(--teal); font-weight: 700; }
.cart-line-controls { display: flex; align-items: center; gap: 0.3rem; flex: 0 0 auto; }
.cart-line-qty { min-width: 1.5rem; text-align: center; font-weight: 700; }

.cart-step {
  width: 1.7rem; height: 1.7rem; padding: 0;
  border: 1px solid var(--light); border-radius: var(--r);
  background: var(--paper); color: var(--dark); cursor: pointer;
  font-size: 0.95rem; line-height: 1;
}
.cart-step:hover { border-color: var(--teal); color: var(--teal); }
.cart-step-remove:hover { border-color: var(--red); color: var(--red); }

.cart-panel-foot { padding: 1.2rem; border-top: 1px solid var(--light); }
.cart-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 0.75rem; font-size: 0.95rem;
}
.cart-total strong { font: 700 1.4rem/1 var(--sans); }

.cart-panel-foot .buy {
  width: 100%; padding: 0.9rem 1rem;
  background: var(--red); color: #fff; border: 0; border-radius: var(--r);
  font: 700 1.05rem/1 var(--sans); text-transform: uppercase; cursor: pointer;
}
.cart-panel-foot .buy[disabled] {
  background: var(--light); color: #fff; cursor: not-allowed;
}
.cart-panel-foot .help { margin: 0.6rem 0 0; font-size: 0.8rem; text-align: center; }


/* Checkout and the receipt --------------------------------------------------
 *
 * Two pages that are almost all form and almost no brand, so they take the
 * shop's colours and none of its drama: the red bar is reserved for the one
 * button on each page that commits to something.
 *
 * `.panel` and `.grid` already exist for the admin, higher up this file and in
 * the admin's palette. These rules re-state background and border inside
 * `.shop` rather than inheriting them, for the same reason `.shop` declares its
 * own tokens: the baseline follows `prefers-color-scheme` and this design's
 * white ground is not a preference (D76).
 */
.checkout, .receipt {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 2rem 1.2rem 3.5rem;
  font-family: var(--sans);
}

.checkout-head, .receipt-head { text-align: center; margin-bottom: 2rem; }
.checkout-head h1, .receipt-head h1 {
  margin: 0 0 0.5rem;
  font: 400 2.4rem/1.15 var(--serif);
  color: var(--dark);
}
.receipt-eyebrow {
  margin: 0 0 0.5rem;
  font: 700 1.1rem/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal);
}

.shop .panel {
  background: var(--paper);
  color: var(--dark);
  border: 1px solid var(--light);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.checkout-empty { text-align: center; padding: 3rem 0; }
.checkout-empty[hidden], .checkout-body[hidden] { display: none; }

/* The form leads and the summary follows it, because on a phone the summary is
   what somebody has just come from and the form is what they came here to do. */
.checkout-body {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.checkout-form label {
  display: block;
  margin-bottom: 1rem;
  font: 600 0.85rem/1.4 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--dark);
}
.checkout-form input,
.checkout-form select,
.checkout-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  font: 400 1rem/1.3 var(--sans);
  color: var(--dark);
  background: var(--paper);
  border: 1px solid var(--light);
  border-radius: var(--r);
  text-transform: none;
  letter-spacing: normal;
}
.checkout-form input:focus-visible,
.checkout-form select:focus-visible,
.checkout-form textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}
.checkout-form textarea { resize: vertical; }

/* The commit. Full width and red, the same signature as the product page's buy
   bar, so the last press looks like the first one. */
.checkout-form .buy,
.checkout-empty .buy {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.9rem 1rem;
  font: 700 1.05rem/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--paper);
  background: var(--red);
  border: 0;
  border-radius: var(--r);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.checkout-empty .buy { max-width: 16rem; margin-inline: auto; }
.checkout-form.is-busy .buy { opacity: 0.6; }

.checkout-summary h2 {
  margin: 0 0 1rem;
  font: 700 1rem/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.checkout-lines { list-style: none; margin: 0 0 1rem; padding: 0; }
.checkout-lines li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--light);
  font-size: 0.95rem;
}
.checkout-line-title { flex: 1 1 auto; min-width: 0; }
.checkout-line-count { flex: 0 0 auto; color: var(--dark); opacity: 0.6; }
.checkout-line-price { flex: 0 0 auto; font-weight: 700; color: var(--teal); }
.checkout-lines .checkout-line-total {
  border-bottom: 0;
  justify-content: space-between;
  padding-top: 0.9rem;
  font: 700 1.1rem/1 var(--sans);
  text-transform: uppercase;
}

/* The receipt --------------------------------------------------------------- */

.receipt .grid { width: 100%; border-collapse: collapse; }
.receipt .grid td, .receipt .grid th {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--light);
  text-align: left;
}
.receipt .grid .num { text-align: right; white-space: nowrap; }
.receipt .grid tfoot th {
  border-bottom: 0;
  border-top: 2px solid var(--dark);
  font: 700 1.1rem/1.2 var(--sans);
  /* The admin's `.grid th` is a muted heading colour; here the sum is the point
     of the page, so both halves of the row take the shop's ink. */
  color: var(--dark);
}
.receipt .price-eur { font-size: 0.85em; opacity: 0.65; font-weight: 400; }
.receipt-where h2 {
  margin: 0 0 0.75rem;
  font: 700 1rem/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.receipt-where p { margin: 0 0 0.4rem; }
.receipt .link { color: var(--teal); font-weight: 600; }

/* The form's own messages, painted by app/functions/admin-form.js. Styled here
   because they appear in the shop and the admin's versions are the admin's
   colours. */
.checkout .form-message {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r);
  font-size: 0.95rem;
}
.checkout .form-message.error { background: var(--red); color: var(--paper); }
.checkout .form-message.ok { background: var(--light); color: var(--dark); }
.checkout .field-error { margin: 0.3rem 0 0; color: var(--red); font-size: 0.85rem; }
.checkout .has-error { border-color: var(--red); }

/* Paying --------------------------------------------------------------------
 *
 * Two ways to pay, both visible without opening anything. A <select> would hide
 * the choice that decides whether the next page is a receipt or a card form.
 */

.pay-choice {
  margin: 1.25rem 0; padding: 0; border: 0;
  display: grid; gap: 0.6rem;
}
.pay-choice legend {
  padding: 0; margin-bottom: 0.5rem;
  font: 600 0.85rem/1 var(--sans);
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--light);
}

.pay-option {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgb(0 0 0 / 12%); border-radius: var(--r);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pay-option:hover { border-color: rgb(0 0 0 / 28%); }
.pay-option input { margin-top: 0.25rem; accent-color: var(--red); }
.pay-option span { display: flex; flex-direction: column; gap: 0.15rem; }
.pay-option strong { font: 600 1rem/1.2 var(--sans); }
.pay-option small { font-size: 0.85rem; color: var(--light); line-height: 1.4; }

/* `:has` rather than a class toggled by script: the state IS the radio, and a
   second copy of it in a class attribute is a second thing that can be wrong. */
.pay-option:has(input:checked) {
  border-color: var(--red); background: rgb(214 40 40 / 5%);
}

/* The receipt's payment banner. Three states, and the colour is the fastest
   part of it to read — somebody who has just typed a card number is looking for
   green before they are reading Bulgarian. */
.pay-state {
  margin: 0 0 1.25rem; padding: 0.8rem 1rem;
  border-radius: var(--r); border-left: 4px solid var(--light);
  background: rgb(0 0 0 / 4%); font-size: 0.95rem; line-height: 1.5;
}
.pay-state[data-pay="paid"] { border-left-color: #2f7d4f; background: rgb(47 125 79 / 8%); }
.pay-state[data-pay="awaiting"] { border-left-color: #b8860b; background: rgb(184 134 11 / 8%); }
.pay-state[data-pay="abandoned"] { border-left-color: var(--red); background: rgb(214 40 40 / 7%); }

/* An epay request past the date it was issued with. Not a value of
   `payment_status` — the column still says `awaiting` until epay says otherwise
   — but it must not be amber, because amber here reads as "still fine" and this
   one is not (app/resolvers/paper-sale.js, migration 057). */
.pay-state[data-pay="expired"] { border-left-color: var(--red); background: rgb(214 40 40 / 7%); }

/* Narrow ------------------------------------------------------------------- */

@media (max-width: 60rem) {
  .checkout-body { grid-template-columns: 1fr; }
  /* Source order: the summary is what the visitor has just come from, and the
     form is what they came here to do, so on one column the form leads. */
  .checkout-form { order: 1; }
  .checkout-summary { order: 2; }

  .product-main { grid-template-columns: 1fr; }
  /* Source order again: on one column the cover comes first, because a book is
     recognised before it is read about. */
  .product-cover { order: 1; max-width: 24rem; margin-inline: auto; }
  .product-buy { order: 2; }
  .product-head h1 { font-size: 2rem; }
  .product-eyebrow { font-size: 1.1rem; }
}

@media (max-width: 40rem) {
  .checkout, .receipt { padding: 1.5rem 0.8rem 2.5rem; }
  .checkout-head h1, .receipt-head h1 { font-size: 1.8rem; }
  .shop .panel { padding: 1rem; }

  .shop-bar { gap: 0.75rem; padding: 0.5rem 0.8rem; }
  .shop-brand { font-size: 1.25rem; }
  .shop-nav { gap: 0.6rem; }
  .shop-nav a { font-size: 0.8rem; }

  .books { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 1.75rem 1rem; }
  .book-list-head h1 { font-size: 2rem; }

  /* The bar stacks rather than shrinking: a call to action and a price squeezed
     onto one line on a phone are two things nobody can read. */
  .buy-bar { flex-direction: column; }
  .buy-bar .price-tag {
    border-left: 0; border-top: 2px solid rgb(255 255 255 / 45%);
    justify-content: center;
  }
  .book-card .buy-bar .buy { font-size: 0.8rem; padding: 0.55rem 0.4rem; }
  .book-card .price-tag .amount { font-size: 1.05rem; }
  .book-card .price-tag .amount.second { font-size: 0.85rem; }

  .product-head h1 { font-size: 1.6rem; padding: 1rem 0.8rem; }
  .product-author { flex-direction: column; align-items: center; text-align: center; }
}

/* ---------------------------------------------------------------------------
   The ebook reader (docs/PAPER-DIGITAL.md)

   The stage is a positioning context with three stacked layers: the
   illustration, the tint over it, and the grid of tiles on top. All three are
   created by `app/functions/paper-ebook.js`; the classes are here because a
   layer with no rules is an invisible bug.
   --------------------------------------------------------------------------- */

.ebook { max-width: 70rem; margin: 0 auto; padding: 1rem; }
.ebook-head h1 { margin: 0 0 0.25rem; font: 400 1.8rem/1.2 var(--serif); }

.ebook-bar {
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  padding: 0.75rem 0;
}
.ebook-turn {
  padding: 0.5rem 1.1rem; border: 1px solid rgb(0 0 0 / 18%);
  border-radius: 0.5rem; background: #fff; cursor: pointer; font: inherit;
}
.ebook-turn[disabled] { opacity: 0.45; cursor: default; }
.ebook-count { font-variant-numeric: tabular-nums; min-width: 5rem; text-align: center; }

/* Reserves its line whether or not it says anything, so the page does not jump
   when a load starts. */
.ebook-status { min-height: 1.5rem; margin: 0; text-align: center; color: #666; }

.ebook-reveal { display: flex; justify-content: center; padding: 1rem 0; }
.ebook-open {
  padding: 1rem 2rem; border: 0; border-radius: 1rem; cursor: pointer;
  font: 700 1.25rem/1 inherit; color: #fff; background: #b3121b;
}

.ebook-stage { position: relative; display: flex; overflow: hidden; }
.ebook-image {
  position: absolute; inset: 0;
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
.ebook-tint { position: absolute; inset: 0; }
.ebook-grid { position: relative; z-index: 2; display: flex; width: 100%; }
.ebook-column { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }

/* Load-bearing rather than cosmetic. An inline SVG is `display: inline`, which
   gives every tile a text baseline and a few pixels of descender gap; eighty-four
   of those down a column and the page is visibly striped. */
.ebook-grid svg { display: block; width: 100%; height: auto; }

@media (max-width: 40rem) {
  .ebook { padding: 0.5rem; }
  .ebook-head h1 { font-size: 1.4rem; }
  .ebook-open { padding: 0.85rem 1.4rem; font-size: 1.05rem; }
}


/* ---------------------------------------------------------------------------
   Sign in, register, profile.

   The same narrow column as the checkout, because they are the same kind of
   page: one form, nothing to browse, nothing to compare. The inputs borrow the
   checkout's shape rather than restating it, so a change to one field style
   reaches every form the shop has.
   --------------------------------------------------------------------------- */

.auth-page, .profile-page {
  max-width: 26rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}

.auth-head { text-align: center; margin-bottom: 1.75rem; }
.auth-head h1 {
  font: 400 1.6rem/1.2 var(--serif, var(--sans));
  margin: 0 0 0.4rem;
}

.auth-form label {
  display: block;
  margin-bottom: 0.3rem;
  font: 600 0.8rem/1.4 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--dark);
}
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"],
.auth-form input:not([type]) {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.6rem 0.7rem;
  font: 400 1rem/1.3 var(--sans);
  color: var(--dark);
  background: var(--paper);
  border: 1px solid var(--light);
  border-radius: var(--r);
}

/* A consent box is a sentence with a checkbox in it, not a labelled field, so
   it opts out of the uppercase treatment above. */
.auth-form .check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0 0 0.85rem;
  font: 400 0.85rem/1.45 var(--sans);
  text-transform: none;
  letter-spacing: normal;
}
.auth-form .check input { margin-top: 0.2rem; flex: none; }

/* The aphorisms.
   Each one is a picture with the sentence drawn into it — two shapes, 1200x628
   and 1280x1280 — so the column is sized for the wider of them and the square
   ones simply sit taller. `aspect-ratio` is deliberately not set: the mirror
   does not carry the dimensions, and guessing one would reserve the wrong box
   for two of the fourteen. See docs/DECISIONS.md D110. */
.aphorisms { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.aphorisms-head { text-align: center; margin-bottom: 1.5rem; }
.aphorisms-head h1 { font: 400 1.6rem/1.2 var(--serif, var(--sans)); margin: 0 0 0.3rem; }

.aphorism-list { list-style: none; margin: 0; padding: 0; }
.aphorism { margin: 0 0 1.5rem; }
.aphorism img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r);
  background: var(--light);
}

/* The contact form is the only one in this family with a paragraph in it, and
   26rem is a column for a password, not for a question. */
.auth-page.contact-page { max-width: 34rem; }

.auth-form textarea {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.6rem 0.7rem;
  font: 400 1rem/1.45 var(--sans);
  color: var(--dark);
  background: var(--paper);
  border: 1px solid var(--light);
  border-radius: var(--r);
  box-sizing: border-box;
  resize: vertical;
}

.auth-form .buy { width: 100%; margin-top: 0.5rem; }

.auth-page .help, .profile-page .help { text-align: center; }

.profile-page .panel { margin-bottom: 1.5rem; }
.profile-page form.inline { text-align: center; }

/* The owned-products grid reuses the catalogue's card wholesale — same widths,
   same cover box — and adds one thing the catalogue has no use for: the grey
   plate over a book that cannot be opened yet. `Очаква плащане` and
   `ПРЕДпродажба` were an absolutely-positioned half-transparent overlay in the
   old thumbnail, and that is what this is. */
.book-card-cover.owned { position: relative; }
.owned-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
/* No cover mirrored yet: the plate still has to be readable, so the box needs a
   height of its own rather than collapsing to the height of the text. */
.book-card-cover.owned:not(:has(img)) { min-height: 8rem; background: var(--light); }
.book-card-cover.owned .buy { text-decoration: none; }
/* The audiobook player. One row — a button, a bar, two clocks — which is the
   whole interface: everything else it does is fetching, and fetching has no
   pixels. The old player drew the same three things and put them in that order.
   `tabular-nums` on the clock because it ticks once a second and a proportional
   font makes the whole row twitch. */
.audio { max-width: 46rem; margin: 0 auto; padding: 1rem; }
.audio-head h1 { margin: 0 0 0.25rem; font: 400 1.8rem/1.2 var(--serif); }

.audio-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
}
.audio-play {
  flex: 0 0 auto;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.audio-seek { flex: 1 1 12rem; min-width: 8rem; }
.audio-seek[disabled] { opacity: 0.45; cursor: default; }
.audio-clock {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: #666;
}
.audio-sep { margin: 0 0.35rem; }
.audio-status { min-height: 1.5rem; margin: 0; color: #666; }

/* --- Bonus illustrations (/bonuses/:key/:order) ----------------------------
   The grid is images and nothing else, so it is sized by the pictures rather
   than by a column count: a book with four illustrations and one with nineteen
   both read as a wall of drawings. `is-full` greys out what cannot be added
   until something is removed - it is a class and not `disabled`, because a
   disabled checkbox posts nothing. */
.bonuses { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.bonuses-head h1 { margin: 0 0 .25rem; }
.bonus-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin: 1rem 0; }
.bonus-card { background: #fff; border: 2px solid #e4e4e4; border-radius: .5rem; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.bonus-card.is-chosen { border-color: #c0392b; }
.bonus-card.is-full { opacity: .45; }
.bonus-image { width: 100%; height: auto; display: block; cursor: pointer; border-radius: .25rem; }
.bonus-pick { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.bonus-name { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.bonus-name input { font-size: 1rem; padding: .4rem; width: 100%; box-sizing: border-box; }
.bonus-note { min-height: 1.4em; color: #c0392b; margin: .5rem 0; }
.bonuses-form button[type="submit"][disabled] { opacity: .5; cursor: not-allowed; }

/* --- the signed illustration (/get-bonuses) ------------------------------ */
.signed { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.signed-head h1 { margin: 0 0 .25rem; }
.signed-list { display: flex; flex-direction: column; gap: 2rem; margin-top: 1.5rem; }
.signed-item { margin: 0; background: #fff; border: 2px solid #e4e4e4; border-radius: .5rem; padding: .75rem; }
.signed-canvas, .signed-fallback { display: block; width: 100%; height: auto; max-width: 100%; }
.signed-item figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: .75rem; }
.signed-wish { margin: 0; flex: 1 1 12rem; font-size: 1.1rem; }
.signed-plain { font-size: .9rem; }
.signed-note { min-height: 1.4em; color: #c0392b; margin: 1rem 0; }
.signed-item button[disabled] { opacity: .5; cursor: not-allowed; }

/* --- the legal documents (/terms, /confidentiality) -----------------------
 *
 * Long-form reading, so the only thing that matters is line length: `65ch`
 * rather than a pixel width, because the limit is words per line and not
 * millimetres. Everything else is the baseline stylesheet doing its job.
 *
 * `scroll-margin-top` on the headings is what makes `#razdel-6` and `#cookies`
 * usable — without it the browser puts the target's first pixel at the top of
 * the viewport, under nothing, and the heading reads as cut off.
 */
.legal { max-width: 65ch; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.legal h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 1.5rem; }
.legal-body h2 { font-size: 1.15rem; margin: 2.5rem 0 .75rem; }
.legal-body p { margin: 0 0 .9rem; }
.legal-body [id] { scroll-margin-top: 1.5rem; }

/* The footer's legal links: one row on a wide screen, a stack on a phone,
   and never the run-together look of anchors separated by a space alone. */
.shop-legal {
  display: flex; flex-wrap: wrap; gap: .4rem 1.25rem;
  justify-content: center; margin-top: .8rem; font-size: .9rem;
}
