/* Founders Press organization ordering. Tokens from the Figma file (color/ink, muted, line, tint, surface). */
@font-face {
  font-family: 'Tiller';
  src: url('/fonts/Tiller-Demi.woff2') format('woff2');
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: 'Tiller';
  src: url('/fonts/Tiller-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #2b2842;
  --muted: #6b6880;
  --line: #e4e2ea;
  --tint: #f6f5f8;
  --surface: #fff;
  --ui: 'Tiller', system-ui, sans-serif;
  --book: 'Crimson Pro', Georgia, serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--book);
  font-size: 1rem;
  line-height: 1.3;
}

p,
h1,
h2 {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

main,
.header,
.bar {
  max-width: 40rem;
  margin-inline: auto;
}

/* Header */
.header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6.5px 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: grid;
  gap: 1px;
  color: inherit;
  text-decoration: none;
  line-height: 16px;
}

.wordmark {
  font-family: var(--ui);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.org {
  font-size: 14px;
  color: var(--muted);
}

.menu-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-inline-end: -10px;
  padding: 0;
  border: 0;
  background: none;
}

#menu {
  inset: 52px 12px auto auto;
  margin: 0;
  min-width: 13rem;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 24px rgb(43 41 66 / 0.12);
}

#menu a {
  display: block;
  padding: 10px 16px;
  color: inherit;
  font-family: var(--ui);
  font-size: 15px;
  text-decoration: none;
}

.menu-note {
  padding: 8px 16px 4px;
  font-size: 14px;
  color: var(--muted);
}

/* Search and tools */
.tools {
  display: grid;
  gap: 12px;
  padding: 20px 16px 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.search:focus-within {
  border-color: var(--ink);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font-family: var(--book);
  font-size: 17px; /* 17px: also keeps iOS from zooming on focus */
}

.search input::placeholder {
  color: var(--muted);
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}

.load {
  padding: 8px 12px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--ui);
  font-weight: 500;
  font-size: 13px;
  line-height: 18px;
}

.load[aria-busy='true'] {
  opacity: 0.5;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  line-height: 18px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.track {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--line);
  transition: background-color 150ms;
}

.track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform 150ms;
}

.switch input:checked + .track {
  background: var(--ink);
}

.switch input:checked + .track::after {
  transform: translateX(14px);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Rows */
.rows {
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
  border-top: 1px solid var(--line);
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.row.is-selected {
  background: var(--tint);
}

.row.is-selected::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: -1px;
  left: 0;
  width: 4px;
  background: var(--ink);
}

.cover {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 7px 10px;
  border-radius: 4px;
  background: var(--tint);
}

.row.is-selected .cover {
  background: #eeedf2;
}

.cover img,
.cover-blank {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cover-blank {
  background: #cdcdcd;
}

.info {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.title {
  font-weight: 700;
  font-size: 17px;
  line-height: 19px;
  text-wrap: pretty;
}

.format {
  font-size: 13px;
  line-height: 16px;
  color: var(--muted);
}

.prices {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.prices strong {
  font-size: 15px;
  line-height: 20px;
}

.row.is-unavailable .cover,
.row.is-unavailable .info {
  opacity: 0.5;
}

.sold-out {
  flex: none;
  font-size: 14px;
  color: var(--muted);
}

/* Quantity: a round + at 0, a − count + pill from 1 */
.qty {
  display: flex;
  justify-content: flex-end;
  flex: none;
  width: 96px;
}

.qty-add {
  display: grid;
  place-items: center;
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 17px;
  background: var(--surface);
  font-family: var(--ui);
  font-weight: 500;
  font-size: 16px;
}

.qty-pill {
  display: none;
  align-items: center;
  width: 96px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 17px;
  background: var(--ink);
  color: var(--surface);
}

.row.is-selected .qty-add {
  display: none;
}

.row.is-selected .qty-pill {
  display: flex;
}

.qty-pill button {
  position: relative;
  flex: none;
  width: 28px;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--ui);
  font-weight: 500;
  font-size: 16px;
}

/* Bigger hit areas than the drawn controls */
.qty-add::after,
.qty-pill button::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.qty-pill input {
  flex: 1;
  min-width: 0;
  width: 38px;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--book);
  font-weight: 600;
  font-size: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.qty-pill input::-webkit-inner-spin-button,
.qty-pill input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.qty-pill :focus-visible {
  outline-color: var(--surface);
  outline-offset: -2px;
  border-radius: 14px;
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

/* Sticky order bar */
.bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -4px 16px rgb(43 41 66 / 0.08);
}

.bar-text {
  display: grid;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.bar-total {
  font-weight: 600;
  font-size: 17px;
  line-height: 20px;
}

.bar-savings {
  font-size: 14px;
  line-height: 16px;
  color: var(--muted);
}

.review,
.checkout {
  padding: 12px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-family: var(--ui);
  font-weight: 600;
  font-size: 15px;
  line-height: 20px;
  text-decoration: none;
  text-align: center;
}

.review:disabled {
  opacity: 0.35;
  cursor: default;
}

.status {
  flex-basis: 100%;
  font-size: 14px;
  color: var(--muted);
}

.status:empty {
  display: none;
}

/* Order sheet */
.sheet {
  width: 100%;
  max-width: 40rem;
  max-height: 85dvh;
  margin: auto auto 0;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  color: var(--ink);
}

.sheet::backdrop {
  background: rgb(43 41 66 / 0.4);
}

.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 8px;
  background: var(--surface);
}

.sheet-head h2 {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 18px;
}

.sheet-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-inline-end: -10px;
  padding: 0;
  border: 0;
  background: none;
}

.sheet-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sheet-lines li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.sheet-lines .line-format {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.sheet-lines .line-total {
  flex: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.sheet-totals {
  display: grid;
  gap: 4px;
  margin: 12px 0 16px;
  font-variant-numeric: tabular-nums;
}

.sheet-totals div {
  display: flex;
  justify-content: space-between;
}

.sheet-totals dd {
  margin: 0;
}

.sheet-subtotal {
  font-weight: 700;
  font-size: 18px;
}

.checkout {
  display: block;
}

.sheet-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 40rem) {
  .rows {
    border-inline: 1px solid var(--line);
  }
}
