/* ==========================================================================
   gale.earth - design system v2
   "An archive from the future of a person trying to make the present more honest."

   Palette:   Antigravity-adjacent - deep teal ground, mist, shoji paper,
              gold thread, signal teal. (Veydra-resonant, but looser.)
   Type:      Newsreader (serif, long-form) · Lato (labels) · IBM Plex Mono (inputs)
   Motifs:    the field of variables, strata, margin notes, civic numbering
   Proportion: ~70 teal + space · ~20 paper · ~10 accents
   ========================================================================== */

/* ---- Tokens ---- */
:root {
  /* ground */
  --teal:        #003b40;   /* hero ground - the main colour */
  --abyssal:     #002b33;   /* deeper layer - panels, bands, footer */
  --teal-line:   #0e5158;   /* borders on teal */
  --teal-line-soft: #0a464d;

  /* light side */
  --paper:       #f4f2ec;   /* shoji white - light band background */
  --paper-dim:   #e7e3d6;   /* body text on teal (warm, not pure white) */
  --white:       #ffffff;   /* headings on teal - reserved, crisp */
  --sumi:        #15181d;   /* text on light grounds - blue-black */
  --concrete:    #8b9098;   /* muted ui, metadata on light */

  /* voices */
  --mist:        #a8d8cf;   /* light teal tint - subtitles, captions, secondary */
  --mist-dim:    #7fb3aa;   /* faint mist - metadata on teal */
  --gold:        #bd8328;   /* the warm thread - rules, emphasis */
  --gold-bright: #d7a14c;   /* gold for small text / hover on dark */
  --signal:      #2aa198;   /* cool accent - links, data, technical labels */
  --signal-bright: #3cc4b9; /* link hover / small text on dark */
  --red:         #d8352b;   /* one hot note per layout, if any */

  /* type */
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans:  "Lato", -apple-system, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

  /* scale */
  --measure: 42rem;
  --measure-wide: 70rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.75rem;
  --space-4: 3rem;
  --space-5: 5rem;
  --space-6: 7.5rem;

  --radius: 4px;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--teal);
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 1.1875rem;          /* 19px */
  line-height: 1.7;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

::selection { background: rgba(189, 131, 40, 0.35); }

/* ---- Typography ---- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
  color: var(--white);
  text-wrap: balance;
}

h1 { font-size: clamp(2.4rem, 6vw, 3.9rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; }

p { margin: 0 0 var(--space-2); }

a {
  color: var(--signal-bright);
  text-decoration: underline;
  text-decoration-color: rgba(42, 161, 152, 0.45);
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--gold-bright); text-decoration-color: var(--gold-bright); }

strong { font-weight: 600; color: var(--white); }
em { font-style: italic; }

hr {
  border: none;
  border-top: 1px solid var(--teal-line);
  margin: var(--space-4) 0;
}

/* small-caps label - nav, meta, section kickers */
.label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mist-dim);
}

/* mono fragment - the "inputs" motif */
.input-frag {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--signal-bright);
  letter-spacing: 0.01em;
}

/* ---- Layout primitives ---- */
.wrap        { max-width: var(--measure-wide); margin: 0 auto; padding: 0 var(--space-3); }
.wrap-narrow { max-width: var(--measure);      margin: 0 auto; padding: 0 var(--space-3); }

section { padding: var(--space-5) 0; }

.kicker {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--gold-bright);
}

/* strata divider - layered lines on teal */
.strata {
  border: none;
  height: 9px;
  margin: 0;
  background:
    linear-gradient(var(--teal-line) 1px, transparent 1px) 0 0 / 100% 4px;
  opacity: 0.7;
}

/* ---- Header / nav ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0, 43, 51, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--teal-line-soft);
}

.site-header .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--white);
  text-decoration: none;
}
.wordmark:hover { color: var(--mist); }
.wordmark .tld { color: var(--gold-bright); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
}

.site-nav a {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mist);
  text-decoration: none;
  padding: 0.35rem 0 2px;          /* taller tap target */
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--white); border-bottom-color: var(--gold); }
.site-nav a[aria-current="page"] { color: var(--white); border-bottom-color: var(--signal); }

/* mobile: wordmark above a horizontally scrollable nav row, no wrapping/cramping */
@media (max-width: 40rem) {
  .site-header .wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding-top: 0.75rem;
    padding-bottom: 0.55rem;
  }
  .site-nav {
    width: 100%;
    flex-wrap: nowrap;
    gap: 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* fade hint that the row scrolls */
    mask-image: linear-gradient(90deg, #000 88%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { white-space: nowrap; padding: 0.5rem 0 0.4rem; }
}

/* ---- Hero (with the field) ---- */
.hero {
  position: relative;
  padding: var(--space-6) 0 var(--space-5);
  overflow: hidden;
  background: linear-gradient(180deg, var(--abyssal) 0%, var(--teal) 100%);
}

.field-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero .wrap-narrow { position: relative; z-index: 1; }

.hero h1 { margin-bottom: var(--space-2); }

.hero .subtitle {
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  line-height: 1.45;
  color: var(--mist);
  font-style: italic;
  margin-bottom: var(--space-3);
  text-wrap: balance;
}

.hero-lede p { font-size: 1.1em; }

.field-caption {
  position: relative;
  z-index: 1;
  margin-top: var(--space-4);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--mist-dim);
  max-width: 34rem;
}
.field-caption .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 0.45em;
  vertical-align: baseline;
}

/* gold rule - the Veydra-style formal anchor, reusable */
.goldrule { width: 120px; height: 2px; background: var(--gold); border: none; margin: var(--space-3) 0; }

/* ---- Buttons ---- */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--mist);
  color: var(--mist);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--mist); color: var(--abyssal); border-color: var(--mist); }

.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--abyssal); }
.btn-primary:hover { background: var(--gold-bright); border-color: var(--gold-bright); color: var(--abyssal); }

.btn-quiet { border-color: var(--teal-line); color: var(--mist-dim); }
.btn-quiet:hover { border-color: var(--mist); background: transparent; color: var(--mist); }

/* light-ground button variants */
.band-paper .btn { border-color: var(--sumi); color: var(--sumi); }
.band-paper .btn:hover { background: var(--sumi); color: var(--paper); }

/* ---- Bands ---- */
/* deep band - abyssal panel on the teal ground */
.band-deep {
  background: var(--abyssal);
  border-top: 1px solid var(--teal-line-soft);
  border-bottom: 1px solid var(--teal-line-soft);
}

/* paper band - the light side; ~20% of any page at most */
.band-paper {
  background: var(--paper);
  color: var(--sumi);
}
.band-paper h1, .band-paper h2, .band-paper h3, .band-paper h4 { color: var(--sumi); }
.band-paper p { color: #3a3e45; }
.band-paper .label { color: #5b626b; }   /* concrete darkened for AA on paper */
.band-paper .kicker { color: #8a5f1d; }  /* gold darkened for AA on paper */
.band-paper a { color: #1d7a72; text-decoration-color: rgba(29, 122, 114, 0.4); }
.band-paper a:hover { color: var(--gold); text-decoration-color: var(--gold); }
.band-paper strong { color: var(--sumi); }

/* ---- Concept cards (live on the paper band) ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.concept-card {
  background: var(--white);
  border: 1px solid #ddd8c9;
  border-top: 2px solid var(--signal);
  border-radius: var(--radius);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.concept-card:nth-child(2n) { border-top-color: var(--gold); }
.concept-card:nth-child(3n) { border-top-color: var(--concrete); }
.concept-card:nth-child(5n) { border-top-color: var(--red); }

.concept-card .num {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: #5b626b;
}

.concept-card h3 { margin: 0; font-size: 1.2rem; color: var(--sumi); }
.concept-card p { margin: 0; font-size: 0.97rem; color: #3a3e45; }

/* ---- Quote block ---- */
.quote-block {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-left: 3px solid var(--gold);
  background: var(--abyssal);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.quote-block p {
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  line-height: 1.4;
  font-style: italic;
  margin: 0;
  color: var(--white);
  text-wrap: balance;
}

.quote-block cite {
  display: block;
  margin-top: var(--space-2);
  font-style: normal;
}

/* ---- Principles (civic-document numbering) ---- */
.principles { counter-reset: principle; list-style: none; margin: var(--space-3) 0; padding: 0; }

.principles li {
  counter-increment: principle;
  position: relative;
  padding: var(--space-2) 0 var(--space-2) 4rem;
  border-bottom: 1px solid var(--teal-line-soft);
}
.principles li:first-child { border-top: 1px solid var(--teal-line-soft); }

.principles li::before {
  content: counter(principle, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: var(--space-2);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--gold-bright);
  padding-top: 0.3em;
}

.principles li strong { display: block; font-size: 1.1rem; font-weight: 600; color: var(--white); }
.principles li span   { color: var(--mist); font-size: 0.97rem; }

/* ---- Essay / note cards (Field Notes) ---- */
.note-list { display: flex; flex-direction: column; margin-top: var(--space-3); }

.note-card {
  display: block;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--teal-line);
  text-decoration: none;
  color: inherit;
}
.note-card:first-child { border-top: 1px solid var(--teal-line); }
.note-card:hover { color: inherit; }
.note-card:hover h3 { color: var(--gold-bright); }

.note-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.note-card h3 { margin: 0 0 0.4rem; transition: color 0.15s ease; }
.note-card p  { margin: 0; color: var(--mist); font-size: 1rem; max-width: var(--measure); }

/* tags - voices of the palette */
.tag {
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--signal-bright);
  background: rgba(42, 161, 152, 0.14);
  border: 1px solid rgba(42, 161, 152, 0.25);
  padding: 0.22rem 0.6rem;
  border-radius: 2px;
}

.tag.is-clay   { color: var(--gold-bright); background: rgba(189, 131, 40, 0.14); border-color: rgba(189, 131, 40, 0.3); }
.tag.is-blue   { color: var(--mist);        background: rgba(168, 216, 207, 0.1); border-color: rgba(168, 216, 207, 0.25); }
.tag.is-ochre  { color: #e08a82;            background: rgba(216, 53, 43, 0.12);  border-color: rgba(216, 53, 43, 0.25); }

/* category index on field notes page */
.cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: var(--space-2);
}

/* ---- Long-form article ---- */
.article-header { padding: var(--space-5) 0 var(--space-3); }
.article-header .meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-bottom: var(--space-2); align-items: center; }

article.longform { padding-bottom: var(--space-5); }
article.longform p,
article.longform ul,
article.longform ol,
article.longform blockquote { max-width: var(--measure); }

article.longform h2 { margin-top: var(--space-4); font-size: 1.6rem; }
article.longform h3 { margin-top: var(--space-3); }

article.longform blockquote {
  margin: var(--space-3) 0;
  padding: 0 0 0 var(--space-3);
  border-left: 2px solid var(--gold);
  font-style: italic;
  color: var(--mist);
}

/* margin note - inline on mobile, floats right on wide screens */
.margin-note {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--mist-dim);
  border-top: 1px solid var(--teal-line);
  padding-top: 0.5rem;
  margin: var(--space-2) 0;
}

@media (min-width: 74rem) {
  article.longform { position: relative; }
  .margin-note {
    float: right;
    clear: right;
    width: 14rem;
    margin: 0.25rem -16rem var(--space-2) var(--space-2);
  }
}

/* ---- Threads page ---- */
.thread {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--teal-line);
}
.thread:first-of-type { border-top: 1px solid var(--teal-line); }

.thread .thread-id {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--signal-bright);   /* AA on teal; --signal alone falls short */
  padding-top: 0.45rem;
}

.thread h3 { margin-bottom: 0.4rem; }
.thread p { margin: 0; color: var(--mist); font-size: 1rem; max-width: var(--measure); }

@media (max-width: 40rem) {
  .thread { grid-template-columns: 1fr; gap: 0.4rem; }
}

/* ---- Contact / subscribe ---- */
.contact-box {
  background: var(--abyssal);
  border: 1px solid var(--teal-line);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-top: var(--space-3);
}

.subscribe-form { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-2); }

.subscribe-form input[type="email"],
.subscribe-form input[type="text"]:not([aria-hidden]) {
  flex: 1 1 14rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--teal-line);
  border-radius: var(--radius);
  background: var(--teal);
  color: var(--paper-dim);
}
.subscribe-form input:focus { outline: 2px solid var(--signal); outline-offset: 1px; }
.subscribe-form .cf-turnstile { flex-basis: 100%; }

.subscribe-note {
  margin: 0.75rem 0 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--mist-dim);
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--teal-line);
  padding: var(--space-4) 0 var(--space-5);
  margin-top: var(--space-5);
  background: var(--abyssal);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: flex-start;
}

.site-footer .foot-thesis {
  max-width: 26rem;
  font-size: 0.95rem;
  color: var(--mist);
  font-style: italic;
}

.site-footer nav { display: flex; flex-direction: column; gap: 0.5rem; }
.site-footer nav a {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--mist);
  text-decoration: none;
}
.site-footer nav a:hover { color: var(--gold-bright); }

.site-footer .colophon {
  width: 100%;
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--teal-line);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--mist-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 2rem;
  justify-content: space-between;
}

/* ---- Utilities ---- */
.mt-0 { margin-top: 0; }
.center { text-align: center; }

/* skip link for keyboard users */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gold);
  color: var(--abyssal);
  padding: 0.6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

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

/* print: it is an archive, after all */
@media print {
  .site-header, .site-footer, .btn-row, .field-canvas { display: none; }
  body { background: #fff; color: var(--sumi); font-size: 11pt; }
  h1, h2, h3, h4, strong { color: var(--sumi); }
}
