/* Nudge Books: calm, editorial, covers first. No framework, no web fonts. */

:root {
  --paper: #faf8f4;
  --paper-deep: #f1ede4;
  --ink: #1f1d1a;
  --ink-soft: #4a463f;
  --muted: #5f5a52;
  --rule: #ddd6c8;
  --accent: #2f5d50;
  --accent-deep: #234a3f;
  --warn: #8a4b0f;
  --danger: #9b2c2c;
  --ok: #2f6b3a;
  --focus: #1d4ed8;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 6px;
  --wrap: 72rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2rem, 1.4rem + 2.5vw, 3rem);
}

h2 {
  font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem);
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--accent-deep);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-inline: 1.25rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  z-index: 10;
}

.skip-link:focus {
  top: 1rem;
  color: var(--paper);
}

.demo-banner {
  margin: 0;
  padding: 0.4rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.8rem;
  text-align: center;
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--ink);
}

.site-header nav ul,
.site-footer nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
}

.site-header nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-header nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.site-search {
  display: flex;
  gap: 0.4rem;
  flex: 1 1 14rem;
  max-width: 24rem;
  margin-left: auto;
}

.site-search input {
  flex: 1;
  min-width: 0;
}

.nav-account {
  margin-left: auto;
}

.cart-count {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  text-align: center;
  font-size: 0.85em;
  color: var(--ink);
}

main {
  padding-top: 2.5rem;
  padding-bottom: 4rem;
  min-height: 60vh;
}

main:focus {
  outline: none;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--paper-deep);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.footer-brand {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin: 0;
}

.footer-note {
  margin: 0;
  color: var(--muted);
}

.site-footer a {
  color: var(--ink-soft);
}

/* Forms and buttons */

label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
}

input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b9b1a2;
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  width: 100%;
}

textarea {
  min-height: 8rem;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.field {
  margin-bottom: 1.1rem;
}

.field-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.3rem 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  background: #000;
  color: var(--paper);
  text-decoration: none;
}

.button[disabled],
.button[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button-quiet {
  background: transparent;
  color: var(--ink);
}

.button-quiet:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.button-small {
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.form-status {
  margin: 0.6rem 0 0;
  font-size: 0.92rem;
  min-height: 1.4em;
}

.form-status[data-tone="error"] {
  color: var(--danger);
}

.form-status[data-tone="ok"] {
  color: var(--ok);
}

.form-card {
  max-width: 28rem;
  padding: 2rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 2);
}

.form-card h1 {
  font-size: 2rem;
}

.form-links {
  margin-top: 1.25rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.notice {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  margin-bottom: 1.5rem;
}

.notice-ok {
  border-color: #b5d3bb;
  background: #eef6ef;
}

/* Home */

.hero {
  padding: 1rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
  max-width: 46rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.lede {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 38rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.section {
  margin-bottom: 3.5rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.shelves {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.shelves a {
  display: block;
  height: 100%;
  padding: 1.4rem;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 2);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.shelves a:hover {
  border-color: var(--ink-soft);
}

.shelf-name {
  display: block;
  font-family: var(--serif);
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}

.shelf-desc {
  display: block;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.shelf-count {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Book grid and cards */

.book-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 2.25rem 1.5rem;
}

.book-card-cover img {
  aspect-ratio: 2 / 3;
  width: 100%;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 8px 20px rgb(0 0 0 / 0.08);
  transition: transform 0.15s ease;
}

.book-card-cover:hover img {
  transform: translateY(-3px);
}

.book-card-title {
  font-size: 1.05rem;
  margin: 0.9rem 0 0.2rem;
}

.book-card-title a {
  color: var(--ink);
  text-decoration: none;
}

.book-card-title a:hover {
  text-decoration: underline;
}

.book-card-authors {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.book-card-authors a {
  color: inherit;
  text-decoration: none;
}

.book-card-authors a:hover {
  text-decoration: underline;
}

.book-card-meta {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
}

.price {
  font-weight: 700;
}

.format {
  color: var(--muted);
}

.stock {
  font-size: 0.82rem;
  font-weight: 600;
}

.stock-ok {
  color: var(--ok);
}

.stock-low {
  color: var(--warn);
}

.stock-out {
  color: var(--danger);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

/* Breadcrumbs */

.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.4rem;
  color: var(--rule);
}

.breadcrumbs a {
  color: var(--muted);
}

/* Book page */

.book-detail {
  display: grid;
  grid-template-columns: minmax(12rem, 22rem) 1fr;
  gap: 2.5rem 3.5rem;
  align-items: start;
}

.book-detail-cover img {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.12), 0 18px 40px rgb(0 0 0 / 0.12);
}

.book-subtitle {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink-soft);
  margin-top: -0.25rem;
}

.book-byline {
  font-size: 1.05rem;
}

.book-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.buy-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 1.25rem 0 2rem;
}

.buy-box .price {
  font-size: 1.6rem;
}

.add-to-cart {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.add-to-cart .form-status {
  flex-basis: 100%;
  margin: 0;
}

.quantity-field {
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0;
}

.quantity-field input {
  width: 5rem;
  display: block;
  margin-top: 0.25rem;
}

.why-read {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.55;
}

.key-ideas {
  padding-left: 1.2rem;
}

.key-ideas li {
  margin-bottom: 0.6rem;
}

.stars {
  color: #a86b00;
  letter-spacing: 0.05em;
}

.stars-empty {
  color: #d4cbb9;
}

.reviews {
  margin-top: 3.5rem;
  max-width: 46rem;
}

.review-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}

.review {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.review-meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.25rem 0 0.5rem;
}

.review-body {
  margin: 0;
}

.review-form {
  max-width: 34rem;
}

/* Author page */

.author-head {
  max-width: 44rem;
  margin-bottom: 2.5rem;
}

/* Category and search */

.listing-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 1rem 2rem;
  margin-bottom: 2rem;
}

.listing-head p {
  max-width: 40rem;
  color: var(--ink-soft);
  margin: 0;
}

.sort-form {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.sort-form label {
  margin: 0;
}

.sort-form select {
  margin-top: 0.25rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  max-width: 34rem;
  margin-bottom: 2rem;
}

/* Cart and checkout */

.cart-layout {
  display: grid;
  grid-template-columns: 1fr minmax(16rem, 22rem);
  gap: 2.5rem;
  align-items: start;
}

.cart-items {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}

.cart-item {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}

.cart-item img {
  width: 4.5rem;
  border-radius: 2px;
}

.cart-item h3 {
  font-size: 1.05rem;
  margin-bottom: 0.15rem;
}

.cart-item h3 a {
  color: var(--ink);
}

.cart-item-meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.cart-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.6rem 1rem;
}

.cart-item-actions .form-status {
  flex-basis: 100%;
  margin: 0;
}

.cart-line-total {
  font-weight: 700;
  text-align: right;
}

.summary {
  padding: 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 2);
}

.summary h2 {
  font-size: 1.35rem;
}

.summary dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0;
  margin: 0 0 1.25rem;
}

.summary dt {
  color: var(--ink-soft);
}

.summary dd {
  margin: 0;
  padding-left: 1rem;
  text-align: right;
}

.summary .total {
  font-weight: 700;
  font-size: 1.1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}

.promo-form {
  margin: 1.25rem 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.promo-row {
  display: flex;
  gap: 0.5rem;
}

.promo-applied {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.summary .button {
  width: 100%;
}

.fine-print {
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.form-grid .span-2 {
  grid-column: span 2;
}

/* Account */

.account-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: 2.5rem;
  align-items: start;
}

.order {
  padding: 1.25rem 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 2);
  margin-bottom: 1rem;
}

.order-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.order-head h3 {
  margin: 0;
}

.order ul {
  margin: 0 0 0.5rem;
  padding-left: 1.1rem;
}

.order-total {
  font-weight: 700;
  margin: 0;
}

/* Static pages */

.prose {
  max-width: 42rem;
}

.prose h2 {
  margin-top: 2rem;
}

/* /lab */

.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  background: #fff;
}

.lab-table th,
.lab-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
}

.lab-table th {
  width: 16rem;
  font-weight: 600;
  background: var(--paper-deep);
}

.lab-table td {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.redacted {
  color: var(--muted);
  font-style: italic;
}

/* Small screens */

@media (max-width: 46rem) {
  .book-detail,
  .cart-layout,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .book-detail-cover {
    max-width: 16rem;
  }

  .site-search {
    order: 5;
    flex-basis: 100%;
    max-width: none;
    margin-left: 0;
  }

  .nav-account {
    margin-left: 0;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 1.75rem 1rem;
  }

  .lab-table th {
    width: 40%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-card-cover img {
    transition: none;
  }
}
