/* Marginalia — tokens */
:root {
  --paper: #f6f5f0;
  --paper-deep: #ecebe4;
  --ink: #1f2f6b;
  --ink-soft: #3d4c86;
  --graphite: #222222;
  --pencil: #5a5a5a;
  --rule: #cfd6e6;
  --highlighter: #f5e663;
  --danger: #8a2a2a;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;

  --line: 2rem; /* ruled-paper line pitch; hero text sits on it */
  --measure: 62ch;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--graphite);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}

p {
  margin: 0 0 1rem;
  max-width: var(--measure);
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

/* ---- Masthead ---- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem var(--gutter);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}

.masthead nav {
  display: flex;
  gap: 1.5rem;
}

.masthead nav a {
  color: var(--graphite);
  text-decoration: none;
}

.masthead nav a:hover {
  text-decoration: underline;
}

.cart-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--graphite);
  background: transparent;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
}

.cart-count {
  min-width: 1.4rem;
  text-align: center;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--highlighter);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---- Hero on ruled paper ---- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--gutter);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--rule);
  overflow: clip; /* the fanned notebooks may poke past the column */
}

.ruled {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--line) - 1px),
    var(--rule) calc(var(--line) - 1px),
    var(--rule) var(--line)
  );
  background-position: 0 var(--line);
}

.hero-copy {
  padding-block: calc(var(--line) * 2) calc(var(--line) * 3);
  border-left: 2px solid #d9a6a6; /* the red margin line of a ruled page */
  padding-left: 1.5rem;
}

.hero-copy .display {
  line-height: var(--line);
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  max-width: 18ch;
}

@media (min-width: 900px) {
  .hero-copy .display {
    line-height: calc(var(--line) * 2);
  }
}

.hero-copy .lede {
  margin-top: var(--line);
  line-height: var(--line);
  max-width: 44ch;
  color: var(--pencil);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  align-items: center;
  margin-top: var(--line);
  line-height: var(--line);
}

.hero-actions .button {
  white-space: nowrap;
}

.button {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 0.65rem 1.2rem;
  text-decoration: none;
  line-height: 1.2;
  transition: background 150ms var(--ease);
}

.button:hover {
  background: var(--ink-soft);
}

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

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

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hero-art {
  position: relative;
  min-height: 360px;
  align-self: stretch;
}

.hero-art svg {
  position: absolute;
  width: 62%;
  bottom: -4%;
  filter: drop-shadow(0 18px 24px rgb(31 47 107 / 0.18));
}

.hero-art svg:nth-child(1) {
  left: 2%;
  transform: rotate(-12deg);
}

.hero-art svg:nth-child(2) {
  left: 24%;
  bottom: 4%;
  transform: rotate(-2deg);
}

.hero-art svg:nth-child(3) {
  left: 44%;
  transform: rotate(9deg);
}

/* ---- Sections ---- */
.section {
  padding: calc(var(--line) * 2) var(--gutter);
}

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

.section-head h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
}

.section-head p {
  margin: 0;
  color: var(--pencil);
}

/* ---- Filters ---- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  border: 1px solid var(--rule);
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}

.chip:hover {
  border-color: var(--graphite);
}

.chip[aria-pressed="true"] {
  background: var(--graphite);
  border-color: var(--graphite);
  color: var(--paper);
}

/* ---- Catalogue grid: objects on paper, no card chrome ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 2.5rem 1.5rem;
  align-items: start;
}

.product {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
}

.product-art {
  aspect-ratio: 1;
  background: var(--paper-deep);
  border-radius: 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-art svg {
  width: 82%;
  height: 82%;
  transition: transform 220ms var(--ease);
}

.product:hover .product-art svg,
.product:focus-visible .product-art svg {
  transform: translateY(-6px);
}

.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
}

.product-name {
  font-weight: 500;
}

.product-price {
  color: var(--pencil);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  color: var(--pencil);
  padding: 2rem 0;
}

/* ---- Paper facts ---- */
.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gutter);
  border-top: 1px solid var(--rule);
}

.facts dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem 1.5rem;
}

.facts dt {
  color: var(--pencil);
}

.facts dd {
  margin: 0;
}

/* ---- Notes from customers ---- */
.quotes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2rem;
  border-top: 1px solid var(--rule);
}

.quote {
  margin: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--highlighter);
}

.quote p {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.4;
}

.quote footer {
  color: var(--pencil);
  font-size: 0.95rem;
}

/* ---- Newsletter ---- */
.post {
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gutter);
  align-items: start;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1 1 220px;
}

input,
select {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
  color: var(--graphite);
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--ink);
  outline: none;
}

.form-note {
  color: var(--pencil);
  font-size: 0.95rem;
}

/* ---- Footer ---- */
.footer {
  border-top: 1px solid var(--rule);
  padding: 2rem var(--gutter) 3rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
  color: var(--pencil);
  font-size: 0.95rem;
}

.footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

/* ---- Cart drawer ---- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgb(34 34 34 / 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
  z-index: 30;
}

.scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(420px, 100vw);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  transform: translateX(100%);
  transition: transform 260ms var(--ease);
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.drawer-head h2 {
  font-size: 1.4rem;
}

.icon-button {
  border: 0;
  background: transparent;
  padding: 0.4rem;
  border-radius: 4px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--paper-deep);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.line {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.9rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}

.line-art {
  width: 64px;
  height: 64px;
  background: var(--paper-deep);
  border-radius: 4px;
}

.line-name {
  font-weight: 500;
}

.line-variant {
  color: var(--pencil);
  font-size: 0.9rem;
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin-top: 0.4rem;
}

.qty button {
  border: 0;
  background: transparent;
  width: 2rem;
  height: 2rem;
}

.qty output {
  min-width: 2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.line-price {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.line-remove {
  display: block;
  margin-top: 0.3rem;
  border: 0;
  background: transparent;
  color: var(--pencil);
  font-size: 0.9rem;
  text-decoration: underline;
  padding: 0;
}

.drawer-foot {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--rule);
}

.totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 1rem;
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

.totals .grand {
  font-weight: 600;
  font-size: 1.1rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.4rem;
}

.shipping-note {
  color: var(--pencil);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.drawer-foot .button {
  width: 100%;
  text-align: center;
}

/* ---- Quick view dialog ---- */
dialog.quickview {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0;
  width: min(820px, calc(100vw - 2rem));
  background: var(--paper);
  color: var(--graphite);
}

dialog.quickview::backdrop {
  background: rgb(34 34 34 / 0.4);
}

.qv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.qv-art {
  background: var(--paper-deep);
  display: grid;
  place-items: center;
  padding: 2rem;
}

.qv-art svg {
  width: 100%;
  max-width: 320px;
}

.qv-body {
  padding: 1.75rem;
  position: relative;
}

.qv-body h2 {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.qv-price {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

.qv-specs {
  margin: 1rem 0 1.25rem;
  padding-left: 1.1rem;
  color: var(--pencil);
}

.qv-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.field span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--pencil);
  font-size: 0.95rem;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  background: var(--graphite);
  color: var(--paper);
  padding: 0.7rem 1.1rem;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  z-index: 50;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---- Checkout page ---- */
.page-narrow {
  padding: calc(var(--line) * 2) var(--gutter);
  max-width: 72ch;
}

.page-narrow .display {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: var(--line);
  margin-bottom: var(--line);
}

.checkout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--gutter);
  padding: 2rem var(--gutter) 4rem;
  align-items: start;
}

.checkout h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  margin-bottom: 1.5rem;
}

.checkout fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 2rem;
}

.checkout legend {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 0.9rem;
  padding: 0;
}

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

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.3rem 0 0;
  min-height: 1.2em;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.summary {
  position: sticky;
  top: 5.5rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.25rem;
  background: #fff;
}

.summary h2 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}

.confirmation {
  padding: calc(var(--line) * 2) var(--gutter) 4rem;
  max-width: 64ch;
}

.confirmation h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 1rem;
}

.order-number {
  display: inline-block;
  background: var(--highlighter);
  padding: 0.1rem 0.4rem;
  font-variant-numeric: tabular-nums;
}

[hidden] {
  display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .hero,
  .facts,
  .post,
  .checkout,
  .qv {
    grid-template-columns: 1fr;
  }

  .hero-art {
    min-height: 260px;
    order: -1;
  }

  .hero-art svg {
    width: 44%;
    bottom: 0;
  }

  .hero-art svg:nth-child(1) {
    left: 8%;
  }

  .hero-art svg:nth-child(2) {
    left: 28%;
  }

  .hero-art svg:nth-child(3) {
    left: 48%;
  }

  .hero-copy {
    padding-left: 1rem;
  }

  .masthead nav {
    display: none;
  }

  .summary {
    position: static;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
