/* NOVA Living base: tokens, type, buttons, forms. Light mode only. */

@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --paper: #faf8f3;
  --white: #fffefb;
  --oat: #eee8db;
  --oat-deep: #e4dccb;
  --ink: #25231f;
  --stone: #5e594f;
  --line: #dcd5c6;
  --line-strong: #bdb5a3;
  --moss: #4b5a41;
  --moss-deep: #3a4733;
  --moss-tint: #e2e7d8;
  --ochre: #9a6b1c;
  --danger: #9c3b2b;
  --danger-tint: #f4e4df;

  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --gutter: clamp(20px, 4vw, 56px);
  --max: 1360px;
  --header-h: 76px;

  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
html.is-locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
p { margin: 0 0 1em; text-wrap: pretty; max-width: 68ch; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; text-wrap: balance; }
[hidden] { display: none !important; }

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

::selection { background: var(--moss-tint); color: var(--ink); }

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

.skip-link {
  position: absolute;
  left: 16px; top: -64px;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 16px; }

.container {
  width: 100%;
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Type ---------- */
.display, h1.display {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 1.5rem + 5.2vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
}
.h2, h2.h2 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 1.35rem + 2.6vw, 3.4rem);
  line-height: 1.06;
  letter-spacing: -0.008em;
}
.h3 {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 1.2rem + 1.1vw, 2.1rem);
  line-height: 1.12;
}
.lede {
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.2rem);
  line-height: 1.6;
  color: var(--stone);
  max-width: 54ch;
}
.small { font-size: 0.875rem; line-height: 1.5; }
.muted { color: var(--stone); }
.price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 28px;
  border: 1px solid var(--ink);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 550;
  letter-spacing: 0.005em;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--moss); border-color: var(--moss); }
.btn--secondary:hover { background: var(--ink); color: var(--paper); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 18px; font-size: 0.875rem; }
.btn[disabled], .btn[aria-disabled="true"] {
  cursor: not-allowed;
  background: transparent;
  color: var(--stone);
  border-color: var(--line-strong);
}
.btn--primary[disabled] { background: var(--oat); border-color: var(--oat); }

.link {
  font-weight: 550;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.3em;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}
.link:hover { color: var(--moss); text-decoration-color: var(--moss); }

.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  font-size: 0.875rem;
  color: var(--stone);
  text-decoration: underline;
  text-underline-offset: 0.25em;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: var(--oat); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .legend {
  font-size: 0.9rem;
  font-weight: 550;
}
.field .hint { font-size: 0.85rem; color: var(--stone); margin: 0; }
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2325231f' stroke-width='1.5'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 3px var(--moss-tint);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffaf8;
}
.error {
  margin: 0;
  font-size: 0.875rem;
  color: var(--danger);
  font-weight: 500;
}
.form-msg { margin: 10px 0 0; font-size: 0.9rem; min-height: 1.4em; }
.form-msg.is-ok { color: var(--moss); font-weight: 550; }
.form-msg.is-error { color: var(--danger); font-weight: 550; }

.check {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  cursor: pointer;
  font-size: 0.95rem;
}
.check input {
  appearance: none;
  width: 22px; height: 22px;
  margin: 1px 0 0;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check input:checked { background: var(--ink); }
.check input:checked::after {
  content: "";
  width: 10px; height: 6px;
  border-left: 2px solid var(--paper);
  border-bottom: 2px solid var(--paper);
  transform: translateY(-1px) rotate(-45deg);
}

/* ---------- Availability ---------- */
.avail {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  color: var(--stone);
  white-space: nowrap;
}
.avail__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--moss); }
.avail--low .avail__dot { background: var(--ochre); }
.avail--out .avail__dot { background: var(--line-strong); }

/* ---------- Quantity ---------- */
.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--white);
}
.qty__btn {
  display: grid;
  place-items: center;
  width: 40px; height: 44px;
  background: none;
  border: 0;
  cursor: pointer;
}
.qty__btn:hover:not([disabled]) { background: var(--oat); }
.qty__btn[disabled] { color: var(--line-strong); cursor: not-allowed; }
.qty__val {
  min-width: 34px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  width: min(92vw, 440px);
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 0.95rem;
}
.toast--error { background: var(--danger); }

/* ---------- Native dialogs ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(37, 35, 31, 0.42); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

::placeholder { color: #7a7468; opacity: 1; }
