/* ENGINEROOM design system — docs/design-system.md. One font, four sizes,
   one accent plus neutrals, one spacing scale, one width, one button, one
   card, one form. Pages use only these; anything new is added here first. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-small: 0.875rem;
  --text-body: 1.0625rem;
  --text-heading: 1.5rem;
  --text-display: clamp(2.25rem, 6vw, 3.25rem);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 40px;
  --space-6: 64px;

  --measure: 42rem;
  --radius: 6px;

  --bg: #f6f3ee;
  --surface: #fbf9f5;
  --ink: #1f1d1a;
  --muted: #6b665e;
  --rule: #d8d1c3;
  --accent: #7a5c3e;
  --button-bg: var(--ink);
  --button-ink: var(--bg);
  --button-edge: var(--ink);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--text-body) / 1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}
::selection { background: var(--ink); color: var(--bg); }
img { display: block; max-width: 100%; height: auto; }

/* --- Layout: one width, one column --- */
.page { max-width: var(--measure); margin: 0 auto; padding: 0 var(--space-3); }
main { padding: var(--space-5) 0 0; }
main > * + *, .section > * + * { margin-top: var(--space-3); }
main > h2 { margin-top: var(--space-5); }
main > .section + .section, main > * + .section { margin-top: 0; padding-top: var(--space-6); }

/* --- Type --- */
h1, h2, h3, p, ol, ul, figure { margin: 0; }
h1 { font-size: var(--text-display); font-weight: 700; line-height: 1.08; letter-spacing: -0.03em; text-wrap: balance; }
h1 .line { display: block; }
h2 { font-size: var(--text-heading); font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
h3 { font-size: var(--text-body); font-weight: 600; line-height: 1.3; }
p { max-width: 65ch; }
.meta { font-size: var(--text-small); color: var(--muted); }
.numbers { font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* --- Footer (the top bar is topbar.css, shared with admin) --- */
.staging-banner { position: sticky; top: 0; z-index: 10; background: var(--ink); color: var(--bg); text-align: center; font-size: var(--text-small); font-weight: 600; padding: var(--space-2) var(--space-3); }
.site-footer { margin-top: var(--space-6); padding: var(--space-4) 0 var(--space-5); border-top: 1px solid var(--rule); font-size: var(--text-small); color: var(--muted); }
.site-footer p + p { margin-top: var(--space-2); }
.site-footer .links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.site-footer a { color: var(--muted); white-space: nowrap; }

/* --- Button: one shape, primary and secondary --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4);
  border-radius: var(--radius); border: 1px solid var(--muted);
  background: transparent; color: var(--ink);
  font: 600 var(--text-body) / 1 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1), color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn-primary { background: var(--button-bg); color: var(--button-ink); border-color: var(--button-edge); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* --- Card: one card --- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3); }
.card > * + * { margin-top: var(--space-2); }

/* --- Badge --- */
.badge { display: inline-block; font-size: var(--text-small); font-weight: 600; line-height: 1; padding: var(--space-1) var(--space-2); border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); }
.badge-filled { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.badge-plain { border-color: transparent; color: var(--muted); padding-left: 0; }

/* --- Pins --- */
.pin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); list-style: none; padding: 0; }
@media (min-width: 40rem) { .pin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pin-grid.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pin { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pin > * + * { margin-top: 0; }
.pin-media { aspect-ratio: 4 / 5; background: var(--bg); }
.pin-media img { width: 100%; height: 100%; object-fit: contain; }
.pin-body { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.pin-title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pin-text { font-size: var(--text-small); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pin .actions { margin-top: auto; }
.pin .btn { flex: 1; padding: 0 var(--space-3); }

/* --- Steps (a real three-step order, so the numbers carry information) --- */
.steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: var(--space-3); }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: var(--space-3); align-items: baseline; }
.steps li::before { content: counter(step); font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.steps strong { display: block; }

/* --- Price --- */
.price { font-size: var(--text-display); font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.price span { font-size: var(--text-body); font-weight: 400; letter-spacing: 0; color: var(--muted); }

/* --- Form: one style --- */
.form { display: grid; gap: var(--space-4); }
.field { display: grid; gap: var(--space-2); }
.field label { font-size: var(--text-small); font-weight: 600; }
.field .meta { font-weight: 400; }
.field input, .field textarea {
  width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--radius);
  font: 400 var(--text-body) / 1.4 var(--font);
}
.field textarea { min-height: 7rem; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hp { position: absolute; left: -9999px; }

/* --- Utilities --- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.divider { border: 0; border-top: 1px solid var(--rule); margin: var(--space-5) 0 0; }

/* --- Notes: a message on a page (flash, error, heads-up). One look; role="alert" for errors. --- */
.note { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3); }
.note[role="alert"] { border-color: var(--accent); }
.note > * + * { margin-top: var(--space-2); }
.note ul { padding-left: var(--space-4); }

/* --- Tabs (portal Pins): links, the current one underlined --- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-3); border-bottom: 1px solid var(--rule); }
.tabs a { text-decoration: none; color: var(--muted); min-height: 44px; display: inline-flex; align-items: center; gap: var(--space-1); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

/* --- Rows: a plain divided list (posted pins, connections, suggestions) --- */
.rows { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.rows > li { padding: var(--space-3) 0; border-bottom: 1px solid var(--rule); display: grid; gap: var(--space-1); }
.row-media { display: grid; grid-template-columns: 64px 1fr; gap: var(--space-3); align-items: start; }
.row-media img { width: 64px; height: 96px; object-fit: cover; border-radius: var(--radius); background: var(--surface); }

/* --- Disclosure (More actions, day-by-day figures) --- */
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); font-size: var(--text-small); font-weight: 600; }
details > summary:hover { color: var(--ink); }
details[open] > summary { color: var(--ink); }
details > * + * { margin-top: var(--space-2); }

/* --- Forms that wrap the field in its label, and the other controls --- */
.form label { display: grid; gap: var(--space-2); font-size: var(--text-small); font-weight: 600; }
.form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .form textarea, .form select {
  width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius);
  font: 400 var(--text-body) / 1.4 var(--font);
}
.form textarea { min-height: 7rem; resize: vertical; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.form .check { display: flex; gap: var(--space-2); align-items: flex-start; font-weight: 400; font-size: var(--text-body); }
.form .check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ink); flex: none; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.form legend { font-size: var(--text-small); font-weight: 600; padding: 0; }
.rating { display: flex; gap: var(--space-2); }
.rating label { display: inline-flex; }
.rating input { position: absolute; opacity: 0; }
.rating span { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--muted); border-radius: var(--radius); font-weight: 600; font-size: var(--text-body); cursor: pointer; }
.rating input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.rating input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline { display: inline; }

/* --- Charts (portal Results — the same images as the monthly email) --- */
.chart { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-2); }
.chart img { width: 100%; height: auto; }
.chart .chart-dark { display: none; }
.big-number { font-size: var(--text-heading); font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- Progress (set-up checklist) and preformatted text --- */
progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--rule); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--rule); }
progress::-webkit-progress-value { background: var(--ink); }
progress::-moz-progress-bar { background: var(--ink); }
pre { font: 400 var(--text-small) / 1.5 ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3); overflow-x: auto; }
.form .card legend { font-weight: 600; font-size: var(--text-small); }

/* Review cards: one column on a phone, two inside the measure on wider screens. */
.pin-grid.cards { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.pin-grid.cards .pin-media { aspect-ratio: 2 / 3; }

/* --- Price packages: room for three, one column on a phone --- */
.packages { list-style: none; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

/* --- Legal pages' contents list --- */
.legal-toc { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3); font-size: var(--text-small); }
.legal-toc ol, .legal-toc ul { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-1); }
main ul:not([class]), main ol:not([class]) { padding-left: var(--space-4); }
main ul:not([class]) > li + li, main ol:not([class]) > li + li { margin-top: var(--space-1); }

/* Questions: a heading and its answer stay together; space between pairs. */
.section > h3 { margin-top: var(--space-4); }
.section > h3 + p { margin-top: var(--space-1); }
.card > ul { padding-left: var(--space-4); }

/* --- Portal Pins (23 Nov): summary line, and Approve / Skip / Rewrite in thumb reach right under the image --- */
.pins-summary { font-size: var(--text-small); color: var(--muted); }
.pin-decide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-3) 0; }
.pin-decide form { margin: 0; }
.pin-decide .btn, .pin-decide summary.btn { width: 100%; min-height: 52px; justify-content: center; padding-inline: var(--space-2); }
.pin-rewrite { display: contents; }
.pin-rewrite summary { list-style: none; cursor: pointer; }
.pin-rewrite summary::-webkit-details-marker { display: none; }
.pin-rewrite[open] > form { grid-column: 1 / -1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--space-2); margin: 0; }
.stats div { padding: var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.stats dt { font-size: var(--text-small); color: var(--muted); }
.stats dd { margin: 0; font-size: var(--text-heading); font-weight: 700; }

/* --- Home (23 Nov): the lead line, Why ENGINEROOM, the recommended package --- */
.lead { font-size: 1.25rem; line-height: 1.45; }
.compare { list-style: none; padding: 0; display: grid; gap: var(--space-3); }
.compare li { padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.compare li:last-child strong { color: var(--accent); }
.card-recommended { border-color: var(--ink); border-width: 2px; }

/* Instagram stream (23 Nov): the platform switch, and each post as it will look on a phone. */
.tabs.streams { margin-bottom: var(--space-3); }
.tabs.streams a { font-size: var(--text-body); }
.pin-grid:has(.ig-post) { grid-template-columns: minmax(0, 1fr); max-width: 26rem; }
@media (min-width: 52rem) { .pin-grid:has(.ig-post) { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; } }
.ig-post .phone { border: 1px solid var(--rule); border-radius: 18px; padding: var(--space-2); background: var(--surface); }
.ig-post .slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; border-radius: 12px; scrollbar-width: none; overscroll-behavior-x: contain; }
.ig-post .slides::-webkit-scrollbar { display: none; }
.ig-post .slides img { flex: 0 0 100%; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; scroll-snap-align: start; }
.ig-post .slides:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ig-post .slide-count { text-align: center; margin: var(--space-1) 0 0; }
.ig-post .slides-pending { aspect-ratio: 4 / 5; display: grid; place-items: center; text-align: center; padding: var(--space-4); margin: 0; }
.ig-caption { white-space: pre-line; }
