/* diegoantunes.net: an old ledger, set in type */

:root {
  --font-heading: 'IM Fell English SC', 'Iowan Old Style', Georgia, serif;
  --font-body: 'EB Garamond', 'Iowan Old Style', Georgia, 'Times New Roman', serif;

  --paper: #E4E2D7;
  --paper-deep: #D9D6C8;
  --ink: #1B1E22;
  --ink-soft: #4E4B43;
  --rule: #8F8A7B;
  --accent: #14303F;
  --grain-opacity: .22;

  --gap-s: 1.5rem;
  --gap-m: 3rem;
  --gap-l: clamp(4rem, 8vw, 8rem);
  --measure: 36rem;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12232C;
    --paper-deep: #0E1C24;
    --ink: #E4E2D7;
    --ink-soft: #AEB4AE;
    --rule: #5B6B70;
    --accent: #A9C4D2;
    --grain-opacity: .10;
  }
}
:root[data-theme="dark"] {
  --paper: #12232C;
  --paper-deep: #0E1C24;
  --ink: #E4E2D7;
  --ink-soft: #AEB4AE;
  --rule: #5B6B70;
  --accent: #A9C4D2;
  --grain-opacity: .10;
}

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

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

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.2rem;
  line-height: 1.6;
  font-feature-settings: "liga", "onum";
  text-rendering: optimizeLegibility;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}

/* paper grain, drawn in-page: no image request */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .32 0 0 0 0 .25 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::before { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; }
}

.page { position: relative; z-index: 1; }

.container {
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 0 1rem;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: 1rem; top: -4rem;
  background: var(--ink); color: var(--paper);
  padding: .6rem 1rem; z-index: 10; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* ---------- Title page ---------- */

.title-page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--gap-m) 0;
}

.title-page h1 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(4rem, 15vw, 6.5rem);
  line-height: .92;
  letter-spacing: -.01em;
  text-align: center;
  margin: 0 0 1.25rem;
}

.subtitle {
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  margin: 0 0 var(--gap-m);
}

.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li + li { margin-top: .35rem; }
.toc a {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  min-height: 44px;
  padding: .55rem 0;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 1.05rem;
}
.toc .dots {
  flex: 1;
  border-bottom: .16em dotted currentColor;
  opacity: .7;
  transform-origin: left;
  transform: translateY(-.28em);
}
.toc .num { font-weight: 600; letter-spacing: .04em; }

@media (prefers-reduced-motion: no-preference) {
  .toc .dots { animation: ledger 700ms var(--ease) both; }
  .toc li:nth-child(1) .dots { animation-delay: 120ms; }
  .toc li:nth-child(2) .dots { animation-delay: 220ms; }
  .toc li:nth-child(3) .dots { animation-delay: 320ms; }
  .toc li:nth-child(4) .dots { animation-delay: 420ms; }
}
@keyframes ledger {
  from { transform: translateY(-.28em) scaleX(0); }
  to   { transform: translateY(-.28em) scaleX(1); }
}

.colophon {
  margin-top: var(--gap-m);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  font-size: 1rem;
}
.colophon small { font-size: .95rem; font-weight: 600; letter-spacing: .04em; }

/* language switch */
.langs { display: flex; justify-content: center; align-items: center; gap: .25rem; flex-wrap: wrap; font-size: 1rem; }
.langs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .4rem; text-decoration: none; }
.langs a:hover { text-decoration: underline; }
.langs a[aria-current="page"] { font-weight: 700; text-decoration: underline; text-decoration-thickness: 1px; }
.site-footer .langs { margin-bottom: .6rem; color: var(--ink); }

.ledger .entry a { text-decoration-color: var(--rule); }
.ledger .entry a:hover { text-decoration-color: var(--accent); }

.mode-toggle {
  display: inline-flex; flex-direction: column; align-items: center; gap: .1rem;
  min-width: 44px; min-height: 44px; padding: .35rem;
  background: none; border: 0; color: var(--ink); cursor: pointer;
  font-family: var(--font-body); font-size: .85rem; font-style: italic;
}
.mode-toggle svg { width: 22px; height: 22px; }
.mode-toggle .moon { display: none; }
:root[data-theme="dark"] .mode-toggle .moon { display: inline; }
:root[data-theme="dark"] .mode-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mode-toggle .moon { display: inline; }
  :root:not([data-theme="light"]) .mode-toggle .sun { display: none; }
}

/* ---------- Chapters ---------- */

.chapter { padding: var(--gap-l) 0 0; scroll-margin-top: 1rem; }
.chapter:last-of-type { padding-bottom: var(--gap-l); }

.numeral {
  display: block;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .08em;
  margin-bottom: .75rem;
}

.chapter h2 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  line-height: 1;
  letter-spacing: -.01em;
  text-align: center;
  margin: 0 0 var(--gap-m);
}

.chapter h3 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: var(--gap-m) 0 var(--gap-s);
}

.prose p { margin: 0 0 var(--gap-s); }

.portrait {
  float: left;
  width: 9.5rem;
  margin: .45rem 1.1rem .4rem 0;
  padding: 5px;
  border: 1px solid var(--ink);
}
.portrait img { display: block; width: 100%; height: auto; }

.dropcap::first-letter {
  float: left;
  font-family: var(--font-heading);
  font-size: 4.4em;
  line-height: .78;
  padding: .06em .08em 0 0;
  color: var(--accent);
}

.clear { clear: both; }

/* pull line between rules */
.maxim {
  margin: var(--gap-m) 0 0;
  padding: var(--gap-s) 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 1.4rem;
  line-height: 1.45;
  text-align: center;
  font-style: italic;
}
.maxim p { margin: 0; }
.maxim footer { margin-top: .6rem; font-size: 1rem; font-style: normal; letter-spacing: .06em; text-transform: uppercase; }

/* ledger lists */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: .7rem 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 1.1rem;
  line-height: 1.35;
}
.ledger li:first-child { border-top: 1px dashed var(--rule); }
.ledger .entry { flex: 1; }
.ledger .entry span { display: block; color: var(--ink-soft); font-size: 1rem; margin-top: .2rem; }
.ledger .amount { white-space: nowrap; font-variant-numeric: oldstyle-nums; }
.ledger .tag { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }

/* ---------- Contact ---------- */

.form { margin-top: var(--gap-s); }
.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .3rem;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: .55rem .2rem;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.field select option { background: var(--paper); color: var(--ink); }
.field textarea { resize: vertical; min-height: 7rem; border: 1px solid var(--ink); padding: .6rem; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-soft); opacity: 1; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 1px 0 0 var(--accent); }
.field textarea:focus { box-shadow: 0 0 0 1px var(--accent); }

.consent { display: flex; gap: .6rem; align-items: flex-start; font-size: 1rem; line-height: 1.45; margin: 1.2rem 0; }
.consent input { width: 20px; height: 20px; margin-top: .15rem; flex-shrink: 0; accent-color: var(--accent); }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: .6rem 1.8rem;
  font-family: var(--font-body); font-size: 1rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
  color: var(--paper); background: var(--ink);
  border: 1px solid var(--ink); border-radius: 0; cursor: pointer;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
.button:hover { background: transparent; color: var(--ink); }

.sent { display: none; margin-top: var(--gap-s); padding: var(--gap-s) 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); text-align: center; font-style: italic; }
.sent.is-visible { display: block; }

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

.site-footer {
  padding: var(--gap-m) 0;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: .95rem;
  color: var(--ink-soft);
}
.site-footer p { margin: 0 0 .6rem; }
.site-footer .finis { font-family: var(--font-heading); font-size: 1.6rem; color: var(--ink); margin-bottom: 1rem; }
.site-footer a { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Plain pages (privacy, 404) ---------- */

.plain { min-height: 100vh; min-height: 100svh; padding: var(--gap-m) 0; }
.plain .back { display: inline-flex; align-items: center; min-height: 44px; text-transform: uppercase; letter-spacing: .06em; font-size: .95rem; text-decoration: none; }
.plain .back:hover { text-decoration: underline; }
.plain h1 {
  font-family: var(--font-heading); font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 3.6rem); line-height: 1; letter-spacing: -.01em;
  text-align: center; margin: var(--gap-m) 0 .5rem;
}
.plain .updated { text-align: center; color: var(--ink-soft); font-style: italic; margin: 0 0 var(--gap-m); }
.plain h2 { font-size: 1.15rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: var(--gap-s) 0 .4rem; }
.plain p { margin: 0 0 1rem; }

.notfound { display: flex; flex-direction: column; justify-content: center; text-align: center; }
.notfound .big { font-family: var(--font-heading); font-size: clamp(5rem, 22vw, 9rem); line-height: .9; margin: 0; }

@media (max-width: 480px) {
  body { font-size: 1.125rem; }
  .portrait { width: 7.5rem; margin-right: .9rem; }
  .ledger li { flex-direction: column; gap: .2rem; }
  .button { width: 100%; }
}
