/* ============================================================
   HAVEN & HOLD — stylesheet
   Tokens follow ui-design-rules.md:
   - spacing scale 4/8/12/16/24/32/40/48/64 only
   - type scale base 16, ratio 1.25 → 16/20/24/32/40, small 14
   - 1 brand hue (spruce, ~163°) + 5 HSB variations, black + white
   - contrast: text ≥4.5:1, large text/UI/borders ≥3:1
   ============================================================ */

:root {
  /* Spacing scale */
  --s-4: 4px;  --s-8: 8px;   --s-12: 12px; --s-16: 16px;
  --s-24: 24px; --s-32: 32px; --s-40: 40px; --s-48: 48px; --s-64: 64px;

  /* Brand hue 163 — five variations (HSB-derived) */
  --brand-strong: #1D5C4C;   /* HSB 163,68,36 — interactive, 7.8:1 on white */
  --brand-dark:   #123B31;   /* HSB 165,69,23 — heading accents, 11.9:1 */
  --brand-mid:    #2E7361;   /* HSB 164,60,45 — hover, 5.6:1 */
  --brand-border: #64887D;   /* HSB 162,26,53 — meaningful borders, 3.5:1 */
  --brand-fill:   #EDF3F1;   /* HSB 160,3,95 — weak fill */

  /* Neutrals (no pure black) */
  --text-strong: #1B201E;    /* 16.4:1 */
  --text-weak:   #4A524E;    /* 7.3:1 */
  --stroke-weak: #D6DDDA;    /* decorative hairlines only */
  --paper:       #FFFFFF;
  --paper-tint:  #F7F9F8;

  --font-ui: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bitter", Georgia, serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 24px; /* 1.5 */
  color: var(--text-strong);
  background: var(--paper);
}

/* ---------- Type scale: 40 / 32 / 24 / 20 / 16 / 14 ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; }
h1 { font-size: 40px; line-height: 48px; letter-spacing: -0.5px; }
h2 { font-size: 32px; line-height: 40px; letter-spacing: -0.25px; }
h3 { font-size: 24px; line-height: 32px; }
h4 { font-size: 20px; line-height: 28px; }
p  { margin: 0 0 var(--s-16); }
.small { font-size: 14px; line-height: 20px; }

a { color: var(--brand-strong); }
a:hover { color: var(--brand-mid); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 2px;
}

/* ============================================================
   Shell: fixed side rail (desktop) + main column
   ============================================================ */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: 256px;
  flex: 0 0 256px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  padding: var(--s-32) var(--s-24);
  border-right: 1px solid var(--stroke-weak);
  background: var(--paper-tint);
  display: flex;
  flex-direction: column;
  gap: var(--s-32);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 32px;
  color: var(--text-strong);
  text-decoration: none;
}
.brand:hover { color: var(--brand-strong); }
.brand-sub {
  display: block;
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-weak);
  margin-top: var(--s-4);
}

.rail nav { display: flex; flex-direction: column; }
.rail-heading {
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  color: var(--text-weak);
  margin-bottom: var(--s-8);
}
.rail nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-8);
  min-height: 48px;               /* touch target */
  padding: var(--s-12) var(--s-8);
  text-decoration: none;
  color: var(--text-strong);
  border-bottom: 1px solid var(--stroke-weak);
}
.rail nav a:hover { background: var(--brand-fill); color: var(--brand-strong); }
.rail nav a .count { color: var(--text-weak); font-size: 14px; line-height: 20px; }

/* Currency switcher — segmented control, real radio inputs */
.currency { display: flex; flex-direction: column; gap: var(--s-8); }
.currency-options {
  display: flex;
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  overflow: hidden;
}
.currency-options label {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-strong);
  background: var(--paper);
}
.currency-options label + label { border-left: 1px solid var(--brand-border); }
.currency-options input { position: absolute; opacity: 0; }
.currency-options label.is-checked,
.currency-options label:has(input:checked) {
  background: var(--brand-strong);
  color: #FFFFFF;
}
.currency-options label:has(input:focus-visible) {
  outline: 2px solid var(--brand-strong);
  outline-offset: 2px;
}

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-8); }
.rail-foot a { font-size: 14px; line-height: 20px; }

/* ---------- Main column ---------- */
.main { flex: 1; min-width: 0; }

.page {
  max-width: 1080px;
  padding: var(--s-48) var(--s-32) var(--s-64);
  margin: 0 auto;
}

/* Intro band — quiet, no hero */
.intro {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s-24);
  padding-bottom: var(--s-40);
  border-bottom: 1px solid var(--stroke-weak);
  margin-bottom: var(--s-48);
}
.intro h1 { grid-column: 1 / 8; }
.intro .intro-note {
  grid-column: 8 / 13;
  align-self: end;
  color: var(--text-weak);
  margin: 0;
}

/* Category section */
.category { margin-bottom: var(--s-64); }
.category-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-16);
  margin-bottom: var(--s-24);
}
.category-head h2 { color: var(--text-strong); }
.category-head .note { color: var(--text-weak); margin: 0; }

/* 12-column product grid, cards span 4 */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s-24);
}
.card { grid-column: span 4; display: flex; flex-direction: column; }

/* Inventory-tag card: flat, hairline top rule in brand colour */
.card {
  border-top: 2px solid var(--brand-strong);
  padding-top: var(--s-16);
}
.card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--brand-fill);
  border-radius: 4px;
  display: block;
  margin-bottom: var(--s-16);
}
.card h3 {
  font-size: 20px;      /* H4 size — card titles are H3 semantically */
  line-height: 28px;
  margin-bottom: var(--s-8);
}
.card .desc {
  color: var(--text-weak);
  margin-bottom: var(--s-16);
  flex: 1;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-16);
}
.price { font-weight: 700; font-size: 20px; line-height: 28px; }

/* ---------- Buttons: 3 weights ---------- */
button { font-family: var(--font-ui); font-size: 16px; line-height: 24px; }

.btn {
  min-height: 48px;
  min-width: 48px;
  padding: var(--s-12) var(--s-16);
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  background: var(--brand-strong);
  color: #FFFFFF;
  border: 1px solid var(--brand-strong);
}
.btn-primary:hover { background: var(--brand-mid); border-color: var(--brand-mid); }
.btn-secondary {
  background: var(--paper);
  color: var(--brand-strong);
  border: 1px solid var(--brand-border);
}
.btn-secondary:hover { background: var(--brand-fill); }
.btn-tertiary {
  background: transparent;
  color: var(--brand-strong);
  border: 1px solid transparent;
}
.btn-tertiary:hover { background: var(--brand-fill); }

/* Basket note in rail */
.basket-note {
  padding: var(--s-12);
  background: var(--brand-fill);
  border-radius: 4px;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-strong);
}

/* ---------- Policy pages ---------- */
.policy { max-width: 720px; }           /* keeps 40–80 chars per line */
.policy h1 { margin-bottom: var(--s-8); }
.policy .updated { color: var(--text-weak); margin-bottom: var(--s-40); }
.policy h2 { margin: var(--s-40) 0 var(--s-16); }
.policy h3 { margin: var(--s-24) 0 var(--s-12); font-size: 20px; line-height: 28px; }
.policy ul, .policy ol { margin: 0 0 var(--s-16); padding-left: var(--s-24); }
.policy li { margin-bottom: var(--s-8); }
.policy table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--s-16);
}
.policy th, .policy td {
  text-align: left;
  padding: var(--s-12);
  border-bottom: 1px solid var(--brand-border);
  vertical-align: top;
}
.policy th { font-weight: 700; }
.callout {
  background: var(--brand-fill);
  border-left: 2px solid var(--brand-strong);
  padding: var(--s-16);
  border-radius: 4px;
  margin-bottom: var(--s-16);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--stroke-weak);
  margin-top: var(--s-64);
  padding-top: var(--s-32);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s-24);
  color: var(--text-weak);
  font-size: 14px;
  line-height: 20px;
}
.footer .foot-brand { grid-column: 1 / 5; }
.footer .foot-legal { grid-column: 5 / 10; }
.footer .foot-links { grid-column: 10 / 13; display: flex; flex-direction: column; gap: var(--s-8); }
.footer a { color: var(--brand-strong); }
.foot-brand .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  line-height: 24px;
  color: var(--text-strong);
}

/* Skip link */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-strong);
  color: #fff;
  padding: var(--s-12) var(--s-16);
  z-index: 10;
}
.skip:focus { left: var(--s-8); top: var(--s-8); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .card { grid-column: span 6; }
  .intro h1 { grid-column: 1 / 13; }
  .intro .intro-note { grid-column: 1 / 13; }
  .footer .foot-brand,
  .footer .foot-legal,
  .footer .foot-links { grid-column: 1 / 13; }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .rail {
    position: static;
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--stroke-weak);
    padding: var(--s-16);
    gap: var(--s-16);
  }
  .rail-foot { margin-top: 0; }
  .page { padding: var(--s-32) var(--s-16) var(--s-48); }
  .card { grid-column: span 12; }
  .category-head { flex-direction: column; gap: var(--s-4); }
  h1 { font-size: 32px; line-height: 40px; }
  h2 { font-size: 24px; line-height: 32px; }
}
