/* ==========================================================================
   vitygas.com — typography-first stylesheet
   Built on the principles in Richard Rutter's *Web Typography*:
   a real reading typeface, a comfortable measure, generous leading,
   a modular hierarchy, and careful micro-typography.
   ========================================================================== */

/* --- Self-hosted typefaces ------------------------------------------------
   Source Serif 4 (humanist serif) for reading; Source Sans 3 (humanist sans)
   for headings and interface. A designed-to-pair superfamily — the safe,
   coherent pairing Rutter recommends. Latin woff2 subsets, ~130 KB total. */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/serif-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic; font-weight: 400; font-display: swap;
  src: url("/fonts/serif-400i.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/serif-600.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/serif-700.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/sans-700.woff2") format("woff2");
}

/* --- Design tokens -------------------------------------------------------- */

:root {
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Warm paper palette: softened contrast, not pure black on pure white. */
  --ink:        #26231d;
  --ink-soft:   #423d34;
  --muted:      #6c6457;
  --bg:         #fbfaf6;
  --bg-sunk:    #f4f1e8;
  --rule:       #e4ddcd;
  --link:       #1d5b73;
  --link-hover: #103e4f;
  --accent:     #9a3b2e;
  --highlight:  #fbe9e2;

  /* Measure: ~66 characters of body text — the heart of "type to be read". */
  --measure: 34rem;
  --band:    52rem;

  --lh-body: 1.62;
  --lh-tight: 1.14;
}

/* Fluid base type scales gently with the viewport — sizing for reading
   distance (the media-queries chapter), while respecting user zoom. */
:root { font-size: clamp(1.0625rem, 1.0rem + 0.42vw, 1.215rem); }

/* --- Reset & base --------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: var(--lh-body);
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern" 1, "liga" 1;
  font-variant-numeric: oldstyle-nums proportional-nums;
  hanging-punctuation: first last;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Layout helpers ------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--band);
  margin-inline: auto;
  padding-inline: 1.5rem;
}
.measure { max-width: var(--measure); }
main { flex: 1 0 auto; }

/* Vertical rhythm for flowing prose: space between blocks, never above the
   first. Spaced paragraphs (not indented) — clearer for text that is scanned. */
.flow > * { margin-block: 0; }
.flow > * + * { margin-block-start: 1.15em; }
.flow > * + :is(h2, h3) { margin-block-start: 2.1em; }
.flow > :is(h2, h3) + * { margin-block-start: 0.55em; }

/* --- Reading typography --------------------------------------------------- */

.content, .hero-intro, .lede {
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 7 3 3;
}
.content p { max-width: var(--measure); }

p { text-wrap: pretty; }

strong, b { font-weight: 700; }
em, i { font-style: italic; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.14em;
  text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent);
}
a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

/* --- Headings ------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--sans);
  color: var(--ink);
  line-height: var(--lh-tight);
  font-weight: 700;
  text-wrap: balance;
  letter-spacing: -0.006em;
}
h1 {
  font-size: clamp(2rem, 1.55rem + 1.7vw, 2.7rem);
  letter-spacing: -0.014em;
  margin: 0 0 0.4em;
}
h2 { font-size: clamp(1.45rem, 1.28rem + 0.7vw, 1.8rem); }
h3 { font-size: clamp(1.18rem, 1.1rem + 0.34vw, 1.36rem); font-weight: 600; }
h4 {
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

/* --- Lists, quotes, rules, tables ----------------------------------------- */

.content ul, .content ol { padding-left: 1.3em; }
.content li + li { margin-top: 0.35em; }
.content li { padding-left: 0.15em; }

blockquote {
  margin-inline: 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
}

.content hr {
  border: 0;
  width: 4rem;
  height: 1px;
  margin: 2.4em auto;
  background: var(--rule);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: lining-nums tabular-nums; /* numerals align in columns */
  font-size: 0.95em;
}
th, td {
  text-align: left;
  padding: 0.5em 0.8em 0.5em 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
th { font-family: var(--sans); font-weight: 600; font-size: 0.85em; }

/* Numerals that should stay aligned regardless of context. */
.tabular, time { font-variant-numeric: lining-nums tabular-nums; }

/* --- Risk icon arrays (pictographs) --------------------------------------- */

.risk {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.4rem;
  align-items: center;
  margin: 1.6rem 0;
}
.risk .ia { width: 170px; height: auto; }
.ia-on  { fill: var(--accent); }
.ia-off { fill: var(--rule); }
.risk figcaption { font-family: var(--serif); }
.risk figcaption strong, .risk figcaption b { font-weight: 700; }

@media (max-width: 34rem) {
  .risk { grid-template-columns: 1fr; gap: 0.6rem; }
  .risk .ia { width: 150px; }
}
@media print {
  .ia-on  { fill: #333; }
  .ia-off { fill: #ddd; }
}

/* --- Site header / masthead ----------------------------------------------- */

.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  padding-block: 1.15rem;
}
.masthead { text-decoration: none; color: inherit; line-height: 1.1; }
.masthead-name {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
}
.masthead-role {
  display: block;
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 0.12em;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}
.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  text-underline-offset: 0.18em;
}
.site-nav a:hover { color: var(--link-hover); text-decoration: underline; }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.1em;
}

/* --- Home ----------------------------------------------------------------- */

.hero { padding-block: clamp(2.5rem, 1.5rem + 4vw, 4.5rem) 1rem; }
.hero-eyebrow {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.8rem;
}
.hero-title { margin: 0; font-size: clamp(2.4rem, 1.7rem + 3vw, 4rem); }
.hero-role {
  font-family: var(--sans);
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0.2rem 0 1.8rem;
}
.hero-intro { font-size: 1.06rem; }
.hero-intro :first-child { margin-top: 0; }

.home-links { padding-block: 2.5rem 3.5rem; }
.section-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { border-top: 1px solid var(--rule); padding: 0.85rem 0; }
.link-list a {
  font-size: 1.2rem;
  text-decoration: none;
  text-underline-offset: 0.16em;
}
.link-list a:hover { text-decoration: underline; }
.link-note {
  display: block;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* --- Article pages -------------------------------------------------------- */

.page { padding-block: 2.4rem 3.5rem; }
.page-head { margin-bottom: 1.6rem; }
.page-tag {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.5rem;
}
.lede { font-size: 1.05rem; color: var(--ink-soft); }

/* Section listings */
.entry-list { list-style: none; margin: 0.4rem 0; padding: 0; }
.entry {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
}
.entry-list:last-child .entry:last-child { border-bottom: 1px solid var(--rule); }
.entry-link { font-size: 1.12rem; text-decoration: none; text-underline-offset: 0.16em; }
.entry-link:hover { text-decoration: underline; }
.entry-tag {
  flex: none;
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.entry-highlight {
  background: var(--highlight);
  border-top-color: transparent;
  padding-inline: 0.8rem;
  margin-inline: -0.8rem;
  border-radius: 4px;
}
.entry-highlight .entry-link { color: var(--accent); font-weight: 600; }
.entry-divider { border: 0; height: 0; margin: 1.4rem 0; }

/* Related + page foot */
.related { margin-top: 2.6rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.related-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.related ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; }
.related a { font-family: var(--sans); font-size: 0.95rem; }

.page-foot { margin-top: 2.4rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.print summary {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.print summary:hover { color: var(--link-hover); }
.print-options { font-family: var(--sans); font-size: 0.9rem; margin: 0.5rem 0 0; }
.print-options a { margin-right: 1.2rem; }
.updated {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 1rem 0 0;
}

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--rule);
  background: var(--bg-sunk);
  padding-block: 1.8rem;
  font-family: var(--sans);
}
.footer-name { font-weight: 600; margin: 0 0 0.3rem; color: var(--ink); }
.footer-meta { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* --- Accessibility -------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 1px;
}

/* --- Dark mode ------------------------------------------------------------ */

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #e9e3d6;
    --ink-soft:   #cfc8b8;
    --muted:      #9d9684;
    --bg:         #1b1a16;
    --bg-sunk:    #221f1a;
    --rule:       #35322a;
    --link:       #84c4dc;
    --link-hover: #a6d8ec;
    --accent:     #e0917f;
    --highlight:  #2c241e;
  }
  body { -webkit-font-smoothing: antialiased; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* --- Print ---------------------------------------------------------------- */

@media print {
  .site-header, .site-nav, .page-foot, .related, .site-footer { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
