/* =========================================================
   Tokens — one hue (148), HSB variations
   148,55,13 ink · 148,70,45 brand · 148,25,37 muted
   148,20,54 line · 148,9,94 wash · plus a dark-side pair
   used only inside the control panel.
   ========================================================= */
:root {
  --ink: #0d2117;
  --brand: #227348;
  --muted: #4a5f52;
  --line: #6e8a78;
  --wash: #e8f0ea;
  --page: #eff3f0;
  --sheet: #ffffff;

  --on-dark: #e6f0e9;
  --on-dark-muted: #9db4a6;
  --on-dark-accent: #7fc79b;

  --danger: #a32014;

  --f-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

  /* base 16, ratio 1.25, line-heights divisible by 4 */
  --t-tiny: 14px;
  --t-body: 16px;
  --t-lead: 20px;
  --t-h2: 24px;
  --t-h1: 32px;
  --t-display: 40px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 40px;
  --s8: 48px;
  --s9: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 var(--t-body) / 24px var(--f-sans);
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.4px; }
h1 { font-size: var(--t-display); line-height: 48px; }
h2 { font-size: var(--t-h2); line-height: 32px; letter-spacing: -0.2px; }
h3 { font-size: var(--t-lead); line-height: 28px; letter-spacing: -0.2px; }
p { margin: 0; }

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

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

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

.mono { font-family: var(--f-mono); font-size: var(--t-tiny); line-height: 24px; }
.prose { max-width: 68ch; }
.muted { color: var(--muted); }

.skip { position: absolute; left: -9999px; top: 0; background: var(--sheet); padding: var(--s3) var(--s4); }
.skip:focus { left: var(--s4); top: var(--s4); z-index: 30; }

/* =========================================================
   Frame: paper sheet (left) + dark control panel (right)
   ========================================================= */
.page {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s6);
  max-width: 1360px;
  margin: 0 auto;
  padding: var(--s6);
}

.sheet {
  grid-column: span 7;
  background: var(--sheet);
  padding: var(--s7) var(--s6) var(--s8);
}

.panel {
  grid-column: 9 / span 4;
  position: sticky;
  top: var(--s6);
  align-self: start;
  max-height: calc(100vh - var(--s9));
  overflow-y: auto;
  background: var(--ink);
  color: var(--on-dark);
  padding: var(--s6) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.panel a { color: var(--on-dark-accent); }
.panel a:hover { color: var(--on-dark); }
.panel .mono { color: var(--on-dark-muted); }

.wordmark {
  display: block;
  font-size: var(--t-h2);
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--on-dark);
  text-decoration: none;
}
.panel-brand p { margin-top: var(--s1); }

.panel-title {
  font-family: var(--f-mono);
  font-size: var(--t-tiny);
  line-height: 24px;
  color: var(--on-dark-muted);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--on-dark-muted);
  margin-bottom: var(--s2);
}

.panel-nav { display: flex; flex-direction: column; }
.panel-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 48px;
  padding: var(--s2) 0;
  color: var(--on-dark);
  text-decoration: none;
  border-bottom: 1px solid rgba(157, 180, 166, 0.35);
}
.panel-nav a:hover { color: var(--on-dark-accent); }
.panel-nav span { font-family: var(--f-mono); font-size: var(--t-tiny); color: var(--on-dark-muted); white-space: nowrap; }
.panel-nav a[aria-current="page"] { font-weight: 700; }
.panel-nav a[aria-current="page"]::before { content: "\2192\00a0"; }

.panel-links { display: flex; flex-direction: column; }
.panel-links a { display: inline-flex; align-items: center; min-height: 48px; font-size: var(--t-tiny); }

.cur { display: flex; gap: var(--s2); }
.cur button {
  flex: 1;
  min-height: 48px;
  min-width: 48px;
  padding: var(--s3) var(--s4);
  font: 400 var(--t-body) / 24px var(--f-mono);
  color: var(--on-dark);
  background: transparent;
  border: 1px solid var(--on-dark-accent);
  cursor: pointer;
}
.cur button:hover { background: rgba(127, 199, 155, 0.16); }
.cur button[aria-pressed="true"] { background: var(--on-dark-accent); color: var(--ink); font-weight: 700; }
.cur button[aria-pressed="true"]::before { content: "\2713\00a0"; }

/* =========================================================
   Buttons — 3 weights
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  padding: var(--s3) var(--s5);
  border: 1px solid transparent;
  font: 700 var(--t-body) / 24px var(--f-sans);
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--ink); color: #fff; }
.btn-secondary { background: transparent; color: var(--brand); border-color: var(--line); }
.btn-secondary:hover { background: var(--wash); }
.btn-on-dark { background: transparent; color: var(--on-dark); border-color: var(--on-dark-accent); }
.btn-on-dark:hover { background: rgba(127, 199, 155, 0.16); color: var(--on-dark); }
.btn-text { padding: var(--s3) 0; font-weight: 400; color: var(--brand); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.btn-text:hover { color: var(--ink); }

/* =========================================================
   Sheet head
   ========================================================= */
.sheet-head { padding-bottom: var(--s6); border-bottom: 2px solid var(--ink); }
.sheet-head h1 { margin: var(--s3) 0 var(--s4); }
.sheet-head .mono { color: var(--muted); }
.sheet-head p + p { margin-top: var(--s3); }

/* =========================================================
   Ledger — the catalogue as a price list
   ========================================================= */
.cat-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sheet);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s5) 0 var(--s2);
  border-bottom: 1px solid var(--line);
}
.cat-head p { color: var(--muted); }

.row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: var(--s4);
  width: 100%;
  min-height: 88px;
  padding: var(--s4) var(--s3);
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--wash);
  border-left: 4px solid transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.row:hover { background: var(--wash); }
.row[aria-pressed="true"] { background: var(--wash); border-left-color: var(--brand); }
.row[aria-pressed="true"] .row-name::before { content: "\25b8\00a0"; }

.row-main { display: flex; flex-direction: column; gap: var(--s1); }
.row-name { font-weight: 700; line-height: 24px; }
.row-spec { font-family: var(--f-mono); font-size: var(--t-tiny); line-height: 24px; color: var(--muted); }
.row-price { font-family: var(--f-mono); font-size: var(--t-lead); line-height: 24px; font-weight: 700; text-align: right; }

.thumb { position: relative; width: 56px; height: 56px; background: var(--wash); overflow: hidden; }
.thumb::before {
  content: attr(data-code);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-mono);
  font-size: var(--t-tiny);
  color: var(--brand);
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--sheet); }

/* =========================================================
   Detail — in the panel on wide screens,
   under the selected row on narrow ones
   ========================================================= */
.detail { display: flex; flex-direction: column; gap: var(--s3); }
#stage:empty { display: none; }
.detail-shot {
  position: relative;
  aspect-ratio: 4 / 3;
  background: rgba(157, 180, 166, 0.18);
  border: 1px solid var(--on-dark-muted);
}
.detail-shot::before {
  content: attr(data-code) " · photo pending";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-mono);
  font-size: var(--t-tiny);
  color: var(--on-dark-muted);
}
.detail-shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.detail h3 { color: var(--on-dark); }
.detail p { color: var(--on-dark-muted); font-size: var(--t-tiny); line-height: 24px; }
.detail-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--on-dark-muted);
  font-family: var(--f-mono);
  font-size: var(--t-lead);
  line-height: 32px;
  font-weight: 700;
  color: var(--on-dark);
}
.detail-price .unit { font-size: var(--t-tiny); font-weight: 400; color: var(--on-dark-muted); }
.detail .btn { width: 100%; }

.sheet .detail { background: var(--wash); padding: var(--s5); border-left: 4px solid var(--brand); }
.sheet .detail h3 { color: var(--ink); }
.sheet .detail p { color: var(--muted); }
.sheet .detail-shot { background: var(--sheet); border-color: var(--line); }
.sheet .detail-shot::before { color: var(--muted); }
.sheet .detail-price { color: var(--ink); border-top-color: var(--line); }
.sheet .detail-price .unit { color: var(--muted); }
.sheet .detail .btn-on-dark { color: var(--brand); border-color: var(--line); }

/* =========================================================
   Terms strip
   ========================================================= */
.terms { margin-top: var(--s8); border-top: 2px solid var(--ink); padding-top: var(--s5); display: grid; gap: var(--s5); }
.terms .item { display: grid; grid-template-columns: 112px 1fr; gap: var(--s4); align-items: baseline; }
.terms .k { font-family: var(--f-mono); font-size: var(--t-tiny); line-height: 24px; color: var(--brand); }
.terms p { font-size: var(--t-tiny); line-height: 24px; color: var(--muted); }
.terms a { font-size: var(--t-tiny); }

/* =========================================================
   Order request
   ========================================================= */
.request { margin-top: var(--s8); border-top: 2px solid var(--ink); padding-top: var(--s5); }
.request h2 { margin-bottom: var(--s3); }
.request > p { color: var(--muted); }
.form { display: flex; flex-direction: column; gap: var(--s5); margin-top: var(--s5); max-width: 560px; }

.field { display: flex; flex-direction: column; }
.field label { font-weight: 700; }
.field .hint { font-family: var(--f-mono); font-size: var(--t-tiny); line-height: 24px; color: var(--muted); margin-bottom: var(--s2); }
.field input, .field textarea {
  min-height: 48px;
  padding: var(--s3) var(--s4);
  font: 400 var(--t-body) / 24px var(--f-sans);
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--line);
}
.field textarea { font-family: var(--f-mono); min-height: 144px; resize: vertical; }
.field.short input { max-width: 224px; }
.field .err { display: none; margin-top: var(--s2); font-size: var(--t-tiny); line-height: 24px; color: var(--danger); }
.field.is-bad input, .field.is-bad textarea { border-color: var(--danger); border-width: 2px; }
.field.is-bad .err { display: block; }
.form-status { font-family: var(--f-mono); font-size: var(--t-tiny); line-height: 24px; color: var(--muted); margin-top: var(--s2); }

/* =========================================================
   Policy documents
   ========================================================= */
.doc h1 { margin-bottom: var(--s4); }
.doc h2 { margin: var(--s8) 0 var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.doc p { margin-bottom: var(--s4); max-width: 68ch; }
.doc ul, .doc ol { margin: 0 0 var(--s4); padding-left: var(--s5); max-width: 68ch; }
.doc li { margin-bottom: var(--s2); }
.doc table { width: 100%; border-collapse: collapse; margin-bottom: var(--s4); }
.doc th, .doc td { text-align: left; vertical-align: top; padding: var(--s3); border-bottom: 1px solid var(--wash); font-size: var(--t-tiny); line-height: 24px; }
.doc th { font-weight: 700; border-bottom: 1px solid var(--line); }
.doc td { color: var(--muted); }
.doc .lede { background: var(--wash); padding: var(--s5); border-left: 4px solid var(--brand); }

/* =========================================================
   Footer
   ========================================================= */
.foot { border-top: 1px solid var(--line); margin: 0 var(--s6); padding: var(--s6) 0 var(--s8); }
.foot-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--s5); max-width: 1296px; margin: 0 auto; }
.foot-col { grid-column: span 3; }
.foot h2 { font-family: var(--f-mono); font-size: var(--t-tiny); line-height: 24px; font-weight: 400; letter-spacing: 0; color: var(--brand); margin-bottom: var(--s2); }
.foot p { font-size: var(--t-tiny); line-height: 24px; color: var(--muted); margin-bottom: var(--s2); }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li a { display: inline-flex; align-items: center; min-height: 48px; font-size: var(--t-tiny); }
.foot a { font-size: var(--t-tiny); }
.foot-note { grid-column: span 12; font-size: var(--t-tiny); line-height: 24px; color: var(--muted); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1080px) {
  .page { gap: var(--s5); padding: var(--s5); }
  .sheet { grid-column: span 12; order: 2; padding: var(--s6) var(--s5) var(--s7); }
  .panel { grid-column: span 12; order: 1; position: static; max-height: none; overflow: visible; }
  .foot { margin: 0 var(--s5); }
  .foot-col { grid-column: span 6; }
}

@media (max-width: 640px) {
  :root { --t-display: 32px; --t-h1: 24px; }
  h1 { line-height: 40px; }
  .row { grid-template-columns: 56px 1fr; row-gap: var(--s2); padding: var(--s4) var(--s2); }
  .row-price { grid-column: 2; text-align: left; }
  .terms .item { grid-template-columns: 1fr; gap: var(--s1); }
  .foot-col { grid-column: span 12; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
