/* Members' club app: visual system v0.1 (draft)
   Self-only CSP safe: no external URLs, no @import, no inline needed.
   Fonts: Crimson Pro (display) + Work Sans (body), both SIL OFL 1.1.
   Place the files in ./fonts/ beside this stylesheet (see design.md, Fonts).
   If a file is missing the stack falls back to system serif / sans, and the
   layout still holds. */

@font-face { font-family: "Crimson Pro"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: local("Crimson Pro"), local("CrimsonPro-Regular"), url("fonts/CrimsonPro-Regular.ttf") format("truetype"); }
@font-face { font-family: "Crimson Pro"; font-style: normal; font-weight: 600 700; font-display: swap;
  src: local("Crimson Pro Bold"), local("CrimsonPro-Bold"), url("fonts/CrimsonPro-Bold.ttf") format("truetype"); }
@font-face { font-family: "Crimson Pro"; font-style: italic; font-weight: 400; font-display: swap;
  src: local("Crimson Pro Italic"), local("CrimsonPro-Italic"), url("fonts/CrimsonPro-Italic.ttf") format("truetype"); }
@font-face { font-family: "Work Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Work Sans"), local("WorkSans-Regular"), url("fonts/WorkSans-Regular.ttf") format("truetype"); }
@font-face { font-family: "Work Sans"; font-style: normal; font-weight: 600 700; font-display: swap;
  src: local("Work Sans Bold"), local("WorkSans-Bold"), url("fonts/WorkSans-Bold.ttf") format("truetype"); }

:root {
  /* Surfaces */
  --paper: #F4F0E6;      /* page */
  --card: #FBF9F4;       /* raised surface, inputs */
  --sunk: #EBE5D6;       /* table header, quiet wells */
  --night: #12231C;      /* footer band and hero only */
  /* Ink */
  --ink: #17221D;        /* body, 14.4:1 on paper */
  --ink-2: #4A5650;      /* secondary, 6.7:1 */
  --mute: #5C675F;       /* captions, 5.2:1 on paper, 4.7:1 on sunk */
  /* Brand */
  --green: #1E3A2F;      /* primary button, headings accent, 10.9:1 on paper */
  --green-2: #2B5242;    /* hover */
  --brass: #7A5C1E;      /* links, accent text, 5.5:1 on paper */
  --brass-l: #B8975A;    /* decoration only: rules, monogram. Never text on light. */
  /* Lines */
  --hair: #CFC7B3;       /* decorative hairlines (not for input edges) */
  --edge: #77715F;       /* input and control edges, 4.3:1 on paper (3:1 needed) */
  /* Status (always paired with an icon/word) */
  --err: #9B2C2C;  --err-bg: #F8E6E3;
  --ok: #2F6B3F;   --ok-bg: #E4F0E6;
  --warn: #8A5A00; --warn-bg: #F6EBD0;
  --info: #1E3A2F; --info-bg: #E6ECE7;

  /* Type */
  --font-display: "Crimson Pro", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Work Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.8125rem;  --fs-sm: 0.9375rem;  --fs-base: 1.0625rem;
  --fs-lg: 1.25rem;    --fs-xl: 1.625rem;   --fs-2xl: 2.125rem;  --fs-3xl: 2.75rem;

  /* Space: 4px base */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --gutter: 16px;
  --measure: 38rem;      /* reading and form column */
  --wide: 68rem;         /* directory, tables */

  --r: 4px;              /* radii kept small: tailored, not bubbly */
  --tap: 48px;           /* minimum touch height */
  --shadow: 0 1px 0 rgba(23,34,29,.04), 0 6px 18px -10px rgba(23,34,29,.25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font: 400 var(--fs-base)/1.6 var(--font-body);
  /* Subtle texture: fine diagonal weave, pure CSS */
  background-image: repeating-linear-gradient(135deg, rgba(23,34,29,.018) 0 1px, transparent 1px 5px);
}
img, svg, video { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; color: var(--green); line-height: 1.15; margin: 0 0 var(--s3); letter-spacing: .005em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
p { margin: 0 0 var(--s4); max-width: 65ch; }
a { color: var(--brass); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--green); text-decoration-thickness: 2px; }
hr, .rule { border: 0; height: 1px; background: var(--hair); margin: var(--s6) 0; }
.rule-brass { height: 2px; width: 56px; background: var(--brass-l); margin: var(--s4) 0; border: 0; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--green); color: #fff; }
.skip { position: absolute; left: -999px; top: 0; background: var(--green); color: #fff; padding: var(--s3) var(--s4); z-index: 10; }
.skip:focus { left: var(--s3); top: var(--s3); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: var(--measure); }
main { flex: 1 0 auto; padding: var(--s6) 0 var(--s8); }
.page-head { margin-bottom: var(--s6); }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--brass); margin: 0 0 var(--s2); }
.lede { font-family: var(--font-display); font-size: var(--fs-lg); line-height: 1.45; color: var(--ink-2); }
.stack > * + * { margin-top: var(--s5); }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.grid { display: grid; gap: var(--s4); grid-template-columns: 1fr; }

/* ---------- Header and nav (phone: wordmark + Menu button via checkbox, no JS) ---------- */
.site-head { background: var(--card); border-bottom: 1px solid var(--hair); position: relative; }
.site-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--brass-l) 0 56px, transparent 56px); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: var(--s3); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); color: var(--green); text-decoration: none; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; letter-spacing: .04em; min-height: var(--tap); }
.brand:hover { color: var(--green); }
.monogram { width: 36px; height: 36px; flex: none; color: var(--green); }
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; }
.nav-btn { cursor: pointer; min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 var(--s4); border: 1px solid var(--edge); border-radius: var(--r); font-weight: 600; font-size: var(--fs-sm); background: var(--card); }
.nav-toggle:checked + .nav-btn { background: var(--green); color: #fff; border-color: var(--green); }
.nav-toggle:focus-visible + .nav-btn { outline: 3px solid var(--brass); outline-offset: 2px; }
.nav-menu nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--card); border-bottom: 1px solid var(--hair); box-shadow: var(--shadow); padding: var(--s2) var(--gutter) var(--s4); z-index: 5; }
.nav-toggle:checked ~ nav { display: block; }
.nav-menu nav a { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); padding: 0 var(--s2); color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--hair); }
.nav-menu nav a[aria-current="page"] { color: var(--green); font-weight: 600; box-shadow: inset 3px 0 0 var(--brass-l); padding-left: var(--s3); }
.nav-menu nav a:hover { background: var(--sunk); }
.badge { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 11px; background: var(--brass); color: #fff; font-size: var(--fs-xs); font-weight: 600; text-align: center; }

/* ---------- Buttons ---------- */
.btn, button, input[type="submit"] {
  font: 600 var(--fs-base)/1 var(--font-body); letter-spacing: .02em;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s5); border-radius: var(--r);
  border: 1px solid var(--green); background: var(--green); color: #fff;
  text-decoration: none; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.btn:hover, button:hover, input[type="submit"]:hover { background: var(--green-2); border-color: var(--green-2); color: #fff; }
.btn:active, button:active { transform: translateY(1px); }
.btn-secondary { background: transparent; color: var(--green); border-color: var(--green); }
.btn-secondary:hover { background: var(--info-bg); color: var(--green); border-color: var(--green); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--brass); text-decoration: underline; text-underline-offset: 3px; padding: 0 var(--s3); }
.btn-quiet:hover { background: var(--sunk); color: var(--green); }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-danger:hover { background: #7C2222; border-color: #7C2222; }
.btn-block { width: 100%; }
.btn[disabled], button[disabled], .btn[aria-disabled="true"] { background: var(--sunk); color: var(--mute); border-color: var(--hair); cursor: not-allowed; }
.actions { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s5); }

/* ---------- Forms (plain <form method="post">; labels always visible) ---------- */
form { margin: 0; }
.field { margin-bottom: var(--s5); }
label, .label { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--s2); color: var(--ink); }
.hint { display: block; font-size: var(--fs-sm); color: var(--mute); margin-top: var(--s2); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="url"],
input[type="number"], input[type="search"], input[type="date"], input[type="file"], select, textarea {
  display: block; width: 100%; min-height: var(--tap); padding: var(--s3) var(--s4);
  font: 400 1rem/1.4 var(--font-body); /* 16px minimum: stops iOS zoom on focus */
  color: var(--ink); background: var(--card); border: 1px solid var(--edge); border-radius: var(--r);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 8rem; resize: vertical; }
select { padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--green) 50%), linear-gradient(135deg, var(--green) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brass); outline-offset: 0; border-color: var(--green); }
input::placeholder, textarea::placeholder { color: var(--mute); }
input[aria-invalid="true"], .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--err); border-width: 2px; }
.error-text { display: block; color: var(--err); font-size: var(--fs-sm); font-weight: 600; margin-top: var(--s2); }
.error-text::before { content: "Problem: "; }
input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; accent-color: var(--green); flex: none; margin: 0; }
.check { display: flex; gap: var(--s3); align-items: flex-start; min-height: var(--tap); padding: var(--s2) 0; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s5); }
legend { font-weight: 600; font-size: var(--fs-sm); padding: 0; margin-bottom: var(--s2); }
/* One-time code: big, spaced, numeric keypad (use inputmode="numeric" autocomplete="one-time-code") */
.code-input { font-family: var(--font-display); font-size: var(--fs-2xl); letter-spacing: .5em; text-align: center; padding-left: calc(var(--s4) + .5em); }
/* Honeypot for the request form: keep off-screen, not display:none */
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r); padding: var(--s5); box-shadow: var(--shadow); position: relative; }
.card--featured { border-top: 2px solid var(--brass-l); }
.card h3 { margin-bottom: var(--s2); }
.card .meta { color: var(--mute); font-size: var(--fs-sm); margin: 0 0 var(--s3); }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--green); }
.card-media { margin: calc(var(--s5) * -1) calc(var(--s5) * -1) var(--s4); aspect-ratio: 3 / 2; background: var(--sunk); display: flex; align-items: center; justify-content: center; color: var(--mute); overflow: hidden; border-radius: var(--r) var(--r) 0 0; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.spec { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); margin: 0 0 var(--s4); }
.spec dt { color: var(--mute); font-size: var(--fs-sm); }
.spec dd { margin: 0; font-weight: 600; }
.plate { display: inline-block; font: 700 1.125rem/1 var(--font-body); letter-spacing: .12em; padding: 6px 12px; background: #F2D44B; color: #17221D; border: 1px solid #17221D; border-radius: 3px; text-transform: uppercase; }
.price { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; color: var(--green); }

/* ---------- Tables (phone: rows become stacked blocks; add data-label to each td) ---------- */
.table-wrap { width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { text-align: left; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); background: var(--sunk); padding: var(--s3) var(--s4); border-bottom: 2px solid var(--brass-l); }
td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--hair); vertical-align: top; }
tbody tr:hover { background: rgba(235,229,214,.45); }
@media (max-width: 47.99em) {
  table.stack-table thead { position: absolute; left: -9999px; }
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table tr { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r); margin-bottom: var(--s3); padding: var(--s2) 0; }
  table.stack-table td { border: 0; padding: var(--s2) var(--s4); display: flex; justify-content: space-between; gap: var(--s4); }
  table.stack-table td::before { content: attr(data-label); color: var(--mute); font-size: var(--fs-sm); flex: none; }
}

/* ---------- Flash messages (icon glyph + word + colour; never colour alone) ---------- */
.flash { display: flex; gap: var(--s3); padding: var(--s4); border: 1px solid; border-left-width: 4px; border-radius: var(--r); margin-bottom: var(--s5); font-size: var(--fs-sm); }
.flash::before { font-weight: 700; flex: none; }
.flash p { margin: 0; }
.flash--error { background: var(--err-bg); border-color: var(--err); color: #5E1B1B; }
.flash--error::before { content: "\2715  Error"; color: var(--err); }
.flash--success { background: var(--ok-bg); border-color: var(--ok); color: #1D4328; }
.flash--success::before { content: "\2713  Done"; color: var(--ok); }
.flash--warning { background: var(--warn-bg); border-color: var(--warn); color: #5B3B00; }
.flash--warning::before { content: "\0021  Note"; color: var(--warn); }
.flash--info { background: var(--info-bg); border-color: var(--green); color: var(--ink); }
.flash--info::before { content: "i  Info"; color: var(--green); }

/* ---------- Tags and status chips ---------- */
.chip { display: inline-block; padding: 3px 10px; border: 1px solid var(--edge); border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; background: var(--card); }
.chip--ok { background: var(--ok-bg); border-color: var(--ok); color: #1D4328; }
.chip--warn { background: var(--warn-bg); border-color: var(--warn); color: #5B3B00; }

/* ---------- Media gallery (car page): scroll-snap strip, no JS ---------- */
.gallery { display: flex; gap: var(--s3); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: var(--s3); margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); -webkit-overflow-scrolling: touch; }
.gallery figure { flex: 0 0 88%; margin: 0; scroll-snap-align: center; }
.gallery img, .gallery video { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--r); background: var(--sunk); display: block; }
.gallery figcaption { font-size: var(--fs-sm); color: var(--mute); padding-top: var(--s2); }

/* ---------- Directory (The Circle) ---------- */
.member { display: flex; gap: var(--s4); align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--green); color: var(--brass-l); font: 600 1.375rem/56px var(--font-display); text-align: center; flex: none; }

/* ---------- Messages ---------- */
.thread { display: flex; flex-direction: column; gap: var(--s3); }
.msg { max-width: 85%; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--card); border: 1px solid var(--hair); }
.msg--me { align-self: flex-end; background: var(--info-bg); border-color: #B9C8BF; }
.msg time { display: block; font-size: var(--fs-xs); color: var(--mute); margin-top: var(--s1); }
.msg-row { display: block; padding: var(--s4); border-bottom: 1px solid var(--hair); color: inherit; text-decoration: none; min-height: var(--tap); }
.msg-row--unread { box-shadow: inset 3px 0 0 var(--brass); font-weight: 600; }
.composer { position: sticky; bottom: 0; background: var(--paper); padding: var(--s3) 0 var(--s4); border-top: 1px solid var(--hair); }

/* ---------- Empty and loading states ---------- */
.empty { text-align: center; padding: var(--s7) var(--s4); border: 1px dashed var(--edge); border-radius: var(--r); color: var(--ink-2); }
.empty h3 { margin-bottom: var(--s2); }
.skeleton { background: linear-gradient(90deg, var(--sunk), var(--card), var(--sunk)); background-size: 200% 100%; animation: sk 1.4s linear infinite; border-radius: var(--r); min-height: 1em; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Auth pages (request invite, accept, sign in, code) ---------- */
.auth { max-width: 26rem; margin: 0 auto; }
.auth .monogram { width: 56px; height: 56px; margin-bottom: var(--s4); }
.auth-hero { background: var(--night); color: #E9E4D6; text-align: center; padding: var(--s7) var(--gutter) var(--s6); border-bottom: 2px solid var(--brass-l); }
.auth-hero h1 { color: #F4F0E6; }
.auth-hero .monogram { color: var(--brass-l); width: 64px; height: 64px; }
.auth-hero p { margin-left: auto; margin-right: auto; }
.auth-hero .lede { color: #C9D0C8; } /* the generic .lede grey is unreadable on the dark band (changed from design v0.1) */
.auth-links { margin-top: var(--s5); font-size: var(--fs-sm); display: flex; flex-direction: column; gap: var(--s2); }
.auth-links a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Footer ---------- */
.site-foot { background: var(--night); color: #C9D0C8; padding: var(--s6) 0 calc(var(--s6) + env(safe-area-inset-bottom)); font-size: var(--fs-sm); border-top: 2px solid var(--brass-l); }
.site-foot a { color: #E3D3AC; display: inline-flex; align-items: center; min-height: 44px; }
.site-foot a:hover { color: #fff; }
.site-foot .foot-links { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-bottom: var(--s4); }
.site-foot .built { margin: 0; font-size: var(--fs-xs); letter-spacing: .06em; color: #A9B3AB; } /* 7.6:1 on night; quiet, not hidden */

/* ---------- Admin ---------- */
.admin-bar { background: var(--sunk); border: 1px solid var(--hair); border-radius: var(--r); padding: var(--s3) var(--s4); display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-bottom: var(--s5); }
.stat { font-family: var(--font-display); font-size: var(--fs-3xl); line-height: 1; color: var(--green); }
.stat-label { font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }

/* ---------- Wider screens ---------- */
@media (min-width: 48em) {
  :root { --gutter: 32px; --fs-2xl: 2.5rem; --fs-3xl: 3.25rem; }
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .actions { flex-direction: row; }
  .btn-block { width: auto; }
  .nav-btn, .nav-toggle { display: none; }
  .nav-menu nav { position: static; display: flex; gap: var(--s5); border: 0; box-shadow: none; padding: 0; background: none; }
  .nav-menu nav a { border: 0; min-height: var(--tap); padding: 0 var(--s1); }
  .nav-menu nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--brass-l); padding-left: var(--s1); }
  .gallery { margin: 0; padding: 0 0 var(--s3); }
  .gallery figure { flex-basis: 46%; }
  .msg { max-width: 60%; }
  .auth-links { flex-direction: row; justify-content: space-between; }
}
@media (min-width: 64em) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
  .gallery figure { flex-basis: 31%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .site-head, .site-foot, .composer, .actions { display: none; } body { background: #fff; } }
