:root {
  color-scheme: light;
  --paper: #f3eee6;
  --ink: #1d1a16;
  --muted: #6d655c;
  --line: #d9d0c4;
  --card: #fffdf9;
  --accent: #8d3b2e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
}

.wrap {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

#date {
  margin: 4px 0 0;
  color: var(--muted);
}

.signs {
  display: flex;
  gap: 8px;
  margin: 28px 0 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.reading {
  max-width: 38rem;
  padding: 12px 0 8px;
}

.sign-symbol {
  display: block;
  font-size: 42px;
  line-height: 1;
  margin-bottom: 4px;
}

.reading h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
}

.reading p {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.45;
}

.shelf-title {
  margin: 36px 0 14px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card img, .card-picture img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #efe8dc;
}

.card-title,
.card-price { padding: 0 12px; }

.card-title { margin-top: 10px; }

.card-price {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.end, .note, footer {
  color: var(--muted);
  font-size: 14px;
}

.end { margin-top: 18px; }

footer { margin-top: 28px; }

.fallback {
  width: min(880px, calc(100% - 32px));
  margin: 16px auto 32px;
  border: 1px solid var(--line);
  background: var(--card);
}

dialog {
  width: min(440px, calc(100% - 24px));
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 0 0 18px;
}

dialog::backdrop { background: rgba(29, 26, 22, 0.45); }

dialog h3 { margin: 14px 18px 0; font-family: var(--serif); font-size: 28px; font-weight: 500; }

dialog p { margin: 8px 18px 0; }

.card-picture svg { width: 100%; height: auto; }

.basket-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 12px 18px 0;
}

.basket-row img { width: 64px; height: 64px; object-fit: cover; }

.qty { display: flex; gap: 6px; align-items: center; }

.total { margin: 14px 18px 0; font-variant-numeric: tabular-nums; }

@media (min-width: 800px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}

:where(
  #cart-button, .signs button, .card button,
  dialog .add-cart, .close, .qty button, .checkout
) {
  --btn-bg: #fffdf9;
  --btn-hover: #f0e7db;
  --btn-down: #e6dacb;
  appearance: none;
  box-sizing: border-box;
  min-height: 44px;
  min-width: 0;
  padding: 10px 16px;
  border: 1px solid #d9d0c4;
  border-radius: 12px;
  background: var(--btn-bg);
  color: #1d1a16;
  box-shadow: 0 2px 0 rgb(29 26 22 / 10%);
  font: 600 15px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 100ms ease, background-color 120ms ease, box-shadow 100ms ease;
}

@media (hover: hover) and (pointer: fine) {
  :where(
    #cart-button, .signs button, .card button,
    dialog .add-cart, .close, .qty button
  ):enabled:hover {
    background: var(--btn-hover);
  }
}

:where(
  #cart-button, .signs button, .card button,
  dialog .add-cart, .close, .qty button
):enabled:active {
  background: var(--btn-down);
  transform: translateY(1px) scale(.985);
  box-shadow: inset 0 2px 3px rgb(29 26 22 / 14%);
}

:where(
  #cart-button, .signs button, .card button,
  dialog .add-cart, .close, .qty button, .checkout
):focus-visible {
  outline: 2px solid #8d3b2e;
  outline-offset: 3px;
}

#cart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

#cart-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f2dfd6;
  color: #8d3b2e;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.signs button {
  flex: 0 0 auto;
  padding-inline: 15px;
  border-radius: 999px;
  white-space: nowrap;
}

.signs button[aria-pressed="true"] {
  --btn-bg: #f2dfd6;
  --btn-hover: #ecd1c4;
  --btn-down: #e5c3b3;
  border-color: #8d3b2e;
  color: #8d3b2e;
}

.signs button[data-today="true"]::after {
  content: " · сегодня";
  color: #8d3b2e;
  font-size: .85em;
}

.signs button:focus-visible { outline-offset: -4px; }

.card button:not(.add-cart) {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 0 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #1d1a16;
  box-shadow: none;
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  transform: none;
}

.card button:not(.add-cart) img {
  border-radius: 14px;
  transition: transform 120ms ease, filter 120ms ease;
}

.card button:not(.add-cart):enabled:active img {
  transform: scale(.975);
  filter: brightness(.93);
}

.card .add-cart,
dialog .add-cart {
  --btn-bg: #8d3b2e;
  --btn-hover: #7e3227;
  --btn-down: #6d2a21;
  border-color: transparent;
  color: #fffdf9;
}

.card .add-cart {
  display: block;
  width: calc(100% - 24px);
  margin: 0 12px 12px;
}

dialog .add-cart {
  display: block;
  width: calc(100% - 36px);
  margin: 16px 18px 0;
}

.close {
  --btn-bg: transparent;
  margin: 16px 18px 0;
  box-shadow: none;
}

.qty button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.checkout:disabled {
  display: block;
  width: calc(100% - 36px);
  margin: 16px 18px 0;
  background: #e8e1d7;
  color: #6d655c;
  border-color: #d9d0c4;
  box-shadow: none;
  opacity: 1;
  transform: none;
  transition: none;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  :where(
    #cart-button, .signs button, .card button,
    dialog .add-cart, .close, .qty button, .checkout
  ) { transition: none; }

  :where(
    #cart-button, .signs button, .card button,
    dialog .add-cart, .close, .qty button
  ):enabled:active { transform: none; }

  .card button:not(.add-cart) img { transition: none; }
  .card button:not(.add-cart):enabled:active img { transform: none; }
}
