/**
 * Shared design tokens and form primitives.
 * Every page loads this first; page-specific layout follows in its own file.
 */

:root {
  color-scheme: light dark;

  --bg: #f3f0eb;
  --stage: radial-gradient(120% 90% at 50% 0%, #fbf9f6 0%, #eceae5 55%, #e3e0da 100%);
  --panel: #fffefc;
  --sunk: #f5f2ed;
  --ink: #16130f;
  /* Long-form prose: full --ink over many lines reads as glare. */
  --ink-soft: #4a423a;
  --muted: #7b736a;
  --faint: #a49b91;
  --line: #e8e2d9;
  --line-strong: #d8d0c4;
  --accent: #16130f;
  --accent-ink: #fffefc;
  /* The brand terracotta. Same value as --focus today, but its own token: a
     logo must not change colour because someone retunes a focus ring. */
  --brand: #b4724a;
  --focus: #b4724a;
  --focus-soft: rgba(180, 114, 74, 0.14);
  --danger: #b03a26;
  --ok: #3f7d4e;
  --ok-soft: rgba(63, 125, 78, 0.12);
  --r: 12px;
  --r-sm: 9px;
  --shadow-card: 0 1px 2px rgba(22, 19, 15, .05), 0 8px 24px -12px rgba(22, 19, 15, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100f0e;
    --stage: radial-gradient(120% 90% at 50% 0%, #1c1a18 0%, #141312 55%, #0d0c0b 100%);
    --panel: #1a1817;
    --sunk: #221f1d;
    --ink: #f4f0ea;
    --ink-soft: #cbc3ba;
    --muted: #9b938a;
    --faint: #6f675f;
    --line: #2c2926;
    --line-strong: #3a3632;
    --accent: #f4f0ea;
    --accent-ink: #16130f;
    --brand: #d09163;
    --focus: #d09163;
    --focus-soft: rgba(208, 145, 99, 0.16);
    --ok: #6fbb83;
    --ok-soft: rgba(111, 187, 131, 0.14);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--focus-soft); }

/* Any component class that sets `display` outbids the UA rule for [hidden],
   which is how a hidden grid or flex container stays stubbornly visible. */
[hidden] { display: none !important; }

/* ----------------------------------------------------------------- wordmark */

/*
 * The logo. One definition, because it was five — two of which had quietly
 * lost the comma, and which disagreed on the weight of the name and on how
 * big the pin should be beside it.
 *
 * Everything scales off the element's own font-size, so a context sets
 * --wordmark and gets a mark, a gap and a comma in proportion. Two sizes are
 * in use: 21px where this is the page's own brand line, 19px where it is a
 * secondary mention in a footer or a toolbar.
 */
.wordmark {
  display: inline-flex;
  align-items: center;
  /* Unitless multipliers of the wordmark size, so a context can set them
     once and have the descriptor under the name line up off the same two
     numbers. The editor wants a heavier pin than a footer does. */
  gap: calc(var(--wordmark-gap, 0.42) * 1em);
  /* A fallback rather than a declaration, so a parent can set --wordmark
     once and have both the lockup and anything aligned to it follow. */
  font-size: var(--wordmark, 21px);
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
}

.wordmark .mark {
  width: calc(var(--wordmark-mark, 1.16) * 1em);
  height: calc(var(--wordmark-mark, 1.16) * 1em);
  flex: none;
  color: var(--brand);
}
.wordmark .mark svg { width: 100%; height: 100%; fill: currentColor; display: block; }

.wordmark .name {
  margin: 0;
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 1em;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.004em;
}

/*
 * The two-line variant: a descriptor beneath the name, with the mark
 * centred against the pair rather than against the name alone.
 *
 * It is the lockup's own arrangement, not one page's: putting the second
 * line inside means the centring keeps working if the descriptor wraps,
 * which an indent or a nudged mark would not. The note has to name its
 * own size — everything inside the lockup inherits the wordmark's.
 */
.wordmark-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.wordmark-note {
  font-size: var(--wordmark-note, 11px);
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* Brand furniture rather than part of the name: it lives in markup here so
   that renaming the business in app.name cannot strand a stray comma. */
/*
 * At its own size, not enlarged. The 1.16em it used to carry was tuned for
 * Bodoni, whose comma is a fine teardrop that needed the help to register at
 * all; Garamond's is already a full slanted wedge, and the same multiplier
 * pushed it into the descender zone where it read as an ornament stuck on
 * after the name rather than as part of it. Colour and weight are enough.
 */
.wordmark .comma {
  color: var(--brand);
  font-weight: 500;
}

/* Secondary mentions: a footer, a toolbar. */
.wordmark--sm { --wordmark: 19px; }

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

/* ------------------------------------------------------------------- fields */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field > label, .grouplabel {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

/* A field's bottom margin would otherwise offset it against its neighbour,
   because end-alignment counts the margin as part of the box. */
.grid2 > .field { margin-bottom: 0; }

.hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--faint);
}
.hint.tight { margin-top: 7px; }

.note { font-size: 11.5px; color: var(--faint); }

/* ------------------------------------------------------------------- inputs */

input[type="text"], input[type="search"], input[type="email"], input[type="date"], select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}

select {
  appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 15px, calc(100% - 8px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-soft);
}

input[disabled], select[disabled] { opacity: .42; cursor: not-allowed; }

.swatchrow { display: flex; align-items: center; gap: 8px; }

input[type="color"] {
  width: 36px;
  height: 36px;
  flex: none;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

.swatchrow output {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}

input[type="range"] {
  width: 100%;
  height: 36px;              /* matches the other controls, so rows line up */
  appearance: none;
  background: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--panel); border: 1.5px solid var(--ink);
}

input[type="checkbox"] { accent-color: var(--focus); width: 15px; height: 15px; }

.checkline label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}

/* ------------------------------------------------------------------ buttons */

.primary {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 26px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s, transform .06s;
  text-decoration: none;
  display: inline-block;
}
.primary:hover { opacity: .87; }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .45; cursor: progress; }

.ghost {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 11px 24px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.ghost:hover { border-color: var(--focus); }

.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--focus);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* --------------------------------------------------------------- callouts */

.warnline {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: rgba(176, 58, 38, .09);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.status { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }
.status.error { color: var(--danger); }

.dev {
  margin-top: 14px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--focus-soft);
  color: var(--focus);
}
