/* Ancestra — the whole visual system, in one file.
 * Made by: Bert Rendon
 *
 * Every colour, size and space is a token defined once in :root. A value
 * written anywhere else in this file, or in a template, is a bug.
 * The reasoning, and the MEASURED contrast of every pair, is in docs/design.md.
 * The measurement itself is scripts/check_contrast.py.
 */

:root {
  /* --- colour: an archive, not a dashboard ------------------------------ */
  /* Every ink below is MEASURED from the logo, not chosen: the mark leads.
   * scripts/build_logo_assets.py prints the clusters and the derivation,
   * scripts/check_contrast.py prints the ratios. See design.md 2. */
  --anc-ink:        #15374C;  /* the trunk, straight off the logo. 11.27:1 — AAA */
  --anc-parchment:  #F7F3EA;
  --anc-paper:      #FFFDF8;
  --anc-muted:      #405F73;  /* the ink, lightened, half saturation. 6.11:1 — AA */
  --anc-accent:     #486865;  /* the teal leaf, darkened to AA. 5.51:1. The one accent. */
  --anc-accent-dark:#38514F;  /* hover. 7.71:1 */
  --anc-sage:       #4F684F;  /* the sage leaf, darkened to AA. 5.54:1 */
  --anc-rust:       #A02A20;  /* 6.66:1 — AA */
  --anc-gold:       #E8C86A;  /* ink on top: 9.00:1 — AAA */
  --anc-alert-tint: #F3D9D4;  /* ink on top: 10.95:1 — AAA */
  --anc-sage-tint:  #DCE8DE;  /* ink on top: 11.61:1 — AAA */
  --anc-rule:       #DED6C6;

  /* --- type: no web font, on purpose. See design.md 3. ------------------ */
  --anc-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
               "Times New Roman", serif;
  --anc-sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;

  /* Base 18px, not 16: some of the people using this are in their seventies. */
  --anc-text-xs:   0.834rem;
  --anc-text-sm:   0.889rem;
  --anc-text-base: 1rem;
  --anc-text-lg:   1.167rem;
  --anc-text-xl:   1.445rem;
  --anc-text-2xl:  1.834rem;

  --anc-space-1: 4px;  --anc-space-2: 8px;  --anc-space-3: 12px;
  --anc-space-4: 16px; --anc-space-5: 24px; --anc-space-6: 32px;
  --anc-space-7: 48px; --anc-space-8: 64px;

  --anc-radius:    6px;
  --anc-radius-lg: 10px;
  --anc-border:    1px solid var(--anc-rule);
  --anc-shadow:    0 1px 2px rgba(21, 55, 76, 0.08);
  --anc-touch:     48px;
  --anc-measure:   62ch;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 18px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--anc-sans);
  font-size: var(--anc-text-base);
  line-height: 1.6;
  color: var(--anc-ink);
  background: var(--anc-parchment);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- focus: never removed. This is how a keyboard navigates. ------------- */
:focus-visible {
  outline: 3px solid var(--anc-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Lets a keyboard user jump the header instead of tabbing through it. */
.anc-skip {
  position: absolute; left: -9999px;
  background: var(--anc-accent); color: var(--anc-parchment);
  padding: var(--anc-space-3) var(--anc-space-4);
}
.anc-skip:focus { left: var(--anc-space-4); top: var(--anc-space-4); z-index: 10; }

/* --- headings: serif, because this is a record of a family --------------- */
h1, h2, h3 {
  font-family: var(--anc-serif);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--anc-space-4);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--anc-text-2xl); }
h2 { font-size: var(--anc-text-xl); }
h3 { font-size: var(--anc-text-lg); }
p  { margin: 0 0 var(--anc-space-4); max-width: var(--anc-measure); }

a { color: var(--anc-accent); text-underline-offset: 3px; }
a:hover { color: var(--anc-accent-dark); }

/* --- shell --------------------------------------------------------------- */
.anc-header {
  background: var(--anc-paper);
  border-bottom: var(--anc-border);
  padding: var(--anc-space-3) var(--anc-space-4);
  display: flex; flex-wrap: wrap; gap: var(--anc-space-3);
  align-items: center; justify-content: space-between;
}
.anc-wordmark {
  font-family: var(--anc-serif);
  font-size: var(--anc-text-xl);
  color: var(--anc-ink);
  text-decoration: none;
  letter-spacing: 0.01em;
  display: flex; align-items: center; gap: var(--anc-space-3);
  min-height: var(--anc-touch);
}
/* The tree beside the word. Sized in the CSS as well as in the attributes:
 * the attributes reserve the box before the image lands, this keeps it from
 * growing if the page is zoomed. */
.anc-wordmark__tree { width: 46px; height: 44px; display: block; }
/* The whole mark on the way in. It carries no white box behind it -- the
 * background was keyed out -- so it sits straight on the parchment. */
.anc-logo {
  display: block;
  width: 240px; max-width: 70%; height: auto;
  margin: 0 auto var(--anc-space-5);
}
.anc-main { flex: 1; width: 100%; padding: var(--anc-space-5) var(--anc-space-4); }
.anc-card {
  background: var(--anc-paper);
  border: var(--anc-border);
  border-radius: var(--anc-radius-lg);
  box-shadow: var(--anc-shadow);
  padding: var(--anc-space-5);
  margin: 0 auto;
  max-width: 34rem;
}
.anc-card--wide { max-width: 48rem; }
.anc-lede { color: var(--anc-muted); font-size: var(--anc-text-sm); }

/* --- forms: the rules of design.md 6 ------------------------------------- */
.anc-field { margin-bottom: var(--anc-space-5); }
.anc-field label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--anc-space-2);
}
.anc-hint { display: block; color: var(--anc-muted); font-size: var(--anc-text-sm); }
.anc-input {
  width: 100%;
  min-height: var(--anc-touch);
  padding: var(--anc-space-3);
  font: inherit;
  color: var(--anc-ink);
  background: var(--anc-paper);
  border: 2px solid var(--anc-rule);
  border-radius: var(--anc-radius);
}
.anc-input:focus { border-color: var(--anc-accent); }
.anc-input[aria-invalid="true"] { border-color: var(--anc-rust); }

.anc-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--anc-touch);
  width: 100%;
  padding: var(--anc-space-3) var(--anc-space-5);
  font: inherit; font-weight: 600;
  color: var(--anc-parchment);
  background: var(--anc-accent);
  border: 2px solid var(--anc-accent);
  border-radius: var(--anc-radius);
  cursor: pointer;
  text-decoration: none;
}
.anc-button:hover { background: var(--anc-accent-dark); border-color: var(--anc-accent-dark); }
.anc-button--quiet {
  color: var(--anc-accent);
  background: transparent;
}
.anc-button--quiet:hover { background: var(--anc-parchment); color: var(--anc-accent-dark); }

/* --- messages: colour is NEVER the only signal (design.md 2) ------------- */
.anc-note {
  display: flex; gap: var(--anc-space-3);
  padding: var(--anc-space-4);
  border-radius: var(--anc-radius);
  border: var(--anc-border);
  margin-bottom: var(--anc-space-5);
  max-width: var(--anc-measure);
}
.anc-note__mark { font-weight: 700; flex: none; }
.anc-note--error   { background: var(--anc-alert-tint); border-color: var(--anc-rust); }
.anc-note--success { background: var(--anc-sage-tint);  border-color: var(--anc-sage); }
.anc-note--info    { background: var(--anc-paper); }

.anc-field-error {
  display: block;
  margin-top: var(--anc-space-2);
  color: var(--anc-rust);
  font-weight: 600;
}

/* --- the trial bar (design.md 7) ----------------------------------------- */
.anc-trial {
  background: var(--anc-paper);
  border-bottom: var(--anc-border);
  padding: var(--anc-space-3) var(--anc-space-4);
  font-size: var(--anc-text-sm);
}
.anc-trial--warning { background: var(--anc-gold); border-bottom-color: var(--anc-accent); }
.anc-trial--readonly { background: var(--anc-alert-tint); border-bottom-color: var(--anc-rust); }
.anc-trial__facts {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--anc-space-1);
}
.anc-trial__notices { margin: var(--anc-space-2) 0 0; padding-left: var(--anc-space-5); }

/* --- language switch ----------------------------------------------------- */
.anc-lang { display: flex; gap: var(--anc-space-2); align-items: center; }
.anc-lang__link {
  min-height: var(--anc-touch); min-width: var(--anc-touch);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 var(--anc-space-3);
  border: var(--anc-border); border-radius: var(--anc-radius);
  text-decoration: none; color: var(--anc-ink); background: var(--anc-paper);
}
/* aria-current carries the state for a screen reader; the weight and the
 * border carry it for everyone who is not distinguishing colours. */
.anc-lang__link[aria-current="true"] {
  font-weight: 700;
  border-color: var(--anc-accent);
  border-width: 2px;
}

/* --- footer -------------------------------------------------------------- */
.anc-footer {
  border-top: var(--anc-border);
  padding: var(--anc-space-5) var(--anc-space-4);
  font-size: var(--anc-text-xs);
  color: var(--anc-muted);
  text-align: center;
}

.anc-stack > * + * { margin-top: var(--anc-space-4); }
.anc-meta { list-style: none; margin: 0; padding: 0; }
.anc-meta li { padding: var(--anc-space-3) 0; border-bottom: var(--anc-border); }
.anc-meta li:last-child { border-bottom: 0; }

/* --- F3: people and relationships ---------------------------------------
 * Same tokens as everything above. No new colour is defined here: a value
 * that is not already in :root is a bug (see the header of this file). */

/* A select and a textarea are inputs, so they inherit the input's box, its
 * 48px touch target and its focus ring rather than the browser's defaults. */
select.anc-input { appearance: none; background-image: none; }
.anc-textarea { min-height: calc(var(--anc-touch) * 2); line-height: 1.5; }

.anc-fieldset {
  border: var(--anc-border);
  border-radius: var(--anc-radius);
  padding: var(--anc-space-4);
  margin: 0 0 var(--anc-space-5);
}
.anc-fieldset legend { font-weight: 600; padding: 0 var(--anc-space-2); }
/* A group of boxes that belong together: year, month, day. They wrap on a
 * narrow screen instead of shrinking below a usable width. */
.anc-row { display: flex; flex-wrap: wrap; gap: var(--anc-space-4); }
.anc-row > * { flex: 1 1 10rem; }
.anc-row--actions { align-items: center; margin-bottom: var(--anc-space-5); }
.anc-row--actions > * { flex: 0 1 auto; }
.anc-field--narrow { flex: 0 1 7rem; }

.anc-check {
  display: flex; align-items: center; gap: var(--anc-space-3);
  min-height: var(--anc-touch);
}
/* 24px, not the browser's 13px: the checkbox is a touch target like every
 * other control on the site. */
.anc-check__box { width: 24px; height: 24px; flex: none; accent-color: var(--anc-accent); }
.anc-check label { font-weight: 400; margin: 0; }

.anc-search { margin-bottom: var(--anc-space-5); }
.anc-search .anc-button { width: auto; }

/* A list row that is one whole link, so the target is the row and not the
 * six characters of a short name. */
.anc-person {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--anc-space-3);
  min-height: var(--anc-touch);
  padding: var(--anc-space-2) 0;
  text-decoration: none; color: var(--anc-ink);
}
.anc-person:hover .anc-person__name { color: var(--anc-accent-dark); text-decoration: underline; }
.anc-person__name { font-family: var(--anc-serif); font-size: var(--anc-text-lg); }
.anc-person__dates { color: var(--anc-muted); font-size: var(--anc-text-sm); }
.anc-inline-link { font-size: var(--anc-text-sm); }

/* "taken out of the tree". The word carries it; the tint only repeats it. */
.anc-tag {
  font-size: var(--anc-text-xs);
  padding: var(--anc-space-1) var(--anc-space-2);
  border: var(--anc-border);
  border-radius: var(--anc-radius);
  background: var(--anc-alert-tint);
  color: var(--anc-ink);
}

.anc-pager {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--anc-space-4);
  margin-top: var(--anc-space-5);
}
.anc-pager .anc-button { width: auto; }

@media (min-width: 1024px) {
  .anc-trial__facts { flex-direction: row; gap: var(--anc-space-5); }
  .anc-main { padding: var(--anc-space-7) var(--anc-space-5); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
