/* ── Fonts ──────────────────────────────────────────────── */
@font-face {
  font-family: "Valkyrie";
  src: url("/assets/fonts/valkyrie/valkyrie-t3.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Valkyrie";
  src: url("/assets/fonts/valkyrie/valkyrie-t3-italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: "Valkyrie";
  src: url("/assets/fonts/valkyrie/valkyrie-t3-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "Valkyrie";
  src: url("/assets/fonts/valkyrie/valkyrie-t3-bold-italic.otf") format("opentype");
  font-weight: 700;
  font-style: italic;
}
@font-face {
  font-family: "Triplicate";
  src: url("/assets/fonts/triplicate/triplicate-t4.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Triplicate";
  src: url("/assets/fonts/triplicate/triplicate-t4-italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: "Triplicate";
  src: url("/assets/fonts/triplicate/triplicate-t4-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "Triplicate";
  src: url("/assets/fonts/triplicate/triplicate-t4-bold-italic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
}

/* ── Variables ─────────────────────────────────────────── */
:root {
  --serif: "Valkyrie", Georgia, serif;
  --mono: "Triplicate", "SFMono-Regular", Consolas, monospace;

  --accent:   #890017;
  --fg:       #1a1a1a;
  --fg-muted: #666;
  --bg:       #EFEFEF;
  --border:   #e0ddd8;

  --measure: 38rem;
  --space:   1.0rem;
  --post-font-size: 1.333rem;
}

[data-theme="dark"] {
  --accent:   #FF8E8E;
  --fg:       #e8e4de;
  --fg-muted: #8a8480;
  --bg:       #1E1E1B;
  --border:   #2e2c29;
}

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--fg);
  padding: 0;
}
.theme-toggle:hover { color: var(--accent); }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.2;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: normal;
  line-height: 1.25;
  margin: 0 0 var(--space);
}
h1 { font-size: 1.55rem; }
h2 { font-size: 1.45rem; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
a:hover { text-decoration-thickness: 2px; }

p { margin: 0; }

time {
  font-family: var(--serif);
  font-size: inherit;
  color: inherit;
}

/* ── Layout ─────────────────────────────────────────────── */
.site-header,
.site-footer,
.main-content {
  max-width: calc(var(--measure) + 4rem);
  margin-inline: 20% auto;
  padding-inline: 2rem;
}

/* ── Header / Nav ───────────────────────────────────────── */
.site-header {
  padding-block: 1.0rem;
  margin-bottom: 3rem;
}

.site-footer {
  padding-block: 0.75rem 1.0rem;
}

.post-byline {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--fg-muted);
  margin: 0;
}

.site-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: inherit;
}

.nav-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.nav-home {
  color: var(--fg);
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  width: 100%;
}
.nav-links a {
  color: var(--fg);
  text-decoration: none;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ── Main ───────────────────────────────────────────────── */
.main-content {
  padding-block: 0 8rem;
}


/* ── Homepage ───────────────────────────────────────────── */
.home { font-family: var(--serif); }
.home-intro { margin-bottom: 3rem; }
.home-intro p { margin-bottom: 1em; font-size: var(--post-font-size); }
.home-intro a { color: var(--fg); }
.home-intro h1 { font-size: 2rem; margin-bottom: 0.75rem; }

.home-intro h2,
.home-recent h2 {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: normal;
  margin: 2rem 0 0;
  line-height: 1;
}

.home-intro h2::after,
.home-recent h2::after {
  content: "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
  display: block;
  overflow: hidden;
  color: var(--fg-muted);
  line-height: 1;
}

.home-recent-list {
  font-size: var(--post-font-size);
  margin-top: 0;
}
.home-recent-list a { color: var(--fg); text-decoration: none; }
.home-recent-list a:hover { color: var(--accent); }

.nav-icons {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-icons a,
.nav-icons button {
  display: flex;
  align-items: center;
  color: var(--fg-muted);
  text-decoration: none;
}
.nav-icons a:hover { color: var(--accent); }

.nav-email {
  font-size: 1.3rem;
  color: var(--fg);
  text-decoration: none;
  line-height: 1;
}
.nav-email:hover { color: var(--accent); }
.nav-email i, .theme-toggle i { font-size: 1.1rem; }

/* ── Post list ──────────────────────────────────────────── */
.post-list-date::after { content: "--"; }
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: var(--post-font-size);
  line-height: 1.2;
}
.post-list-item + .post-list-item {
  margin-top: 0.15em;
}

.post-list-link {
  color: var(--fg);
  text-decoration: none;
  display: block;
  padding-left: 12ch;
  text-indent: -12ch;
}
.post-list-link:hover { color: var(--accent); text-decoration: underline; }
.post-list-title { font-family: var(--serif); }
.post-list-tags { display: none; }

/* ── Tag nav ────────────────────────────────────────────── */
.tag-nav {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.tag-nav-label { color: var(--fg-muted); }

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-list a {
  color: var(--fg-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.1em 0.5em;
  border-radius: 2px;
}
.tag-list a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Publicaciones ──────────────────────────────────────── */
.publicaciones {
  font-family: var(--serif);
  font-size: var(--post-font-size);
  line-height: 1.2;
}
.publicaciones h2 {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: normal;
  margin: 2rem 0 0;
  line-height: 1;
}
.publicaciones h2::after {
  content: "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
  display: block;
  overflow: hidden;
  color: var(--fg-muted);
  line-height: 1;
}
.publicaciones p,
.publicaciones ul,
.publicaciones ol {
  padding-left: 1.5em;
  text-indent: -1.5em;
  margin: 0;
}
.publicaciones h2 + p,
.publicaciones h2 + ul,
.publicaciones h2 + ol {
  margin-top: 0.25rem;
}
.publicaciones a {
  color: var(--fg);
  text-decoration: none;
}
.publicaciones a:hover { color: var(--accent); text-decoration: underline; }

/* ── Writing index ──────────────────────────────────────── */
.writing-index h1 { margin-bottom: 1.5rem; }
.writing-index-heading {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: normal;
  margin: 0 0 0.25rem;
}
.writing-index-heading::after {
  content: "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
  display: block;
  overflow: hidden;
  color: var(--fg-muted);
  line-height: 1;
}
.tag-heading {
  font-family: var(--mono);
  font-size: 1.2rem;
  margin-bottom: 1em;
}

/* ── Post ───────────────────────────────────────────────── */
.post-header { margin-bottom: 2rem; }

.post-title-row {
  display: block;
}
.post-title {
  font-family: var(--mono);
  margin-bottom: 0;
}
.post-title-date {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: normal;
  color: var(--fg-muted);
  display: block;
  margin: 0.25rem 0 0.75rem;
}

.post-dateline {
  font-family: var(--mono);
  font-size: 1.1rem;
  overflow: hidden;
  white-space: nowrap;
  color: var(--fg-muted);
}
.post-dateline::before {
  content: "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::";
}

.post-tags {
  list-style: none;
  margin: var(--space) 0 33vh;
  padding: 0;
  display: flex;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 1.1rem;
}
.post-tags a { color: var(--fg-muted); text-decoration: none; }
.post-tags a:hover { color: var(--accent); }

.post-body {
  hyphens: auto;
  -webkit-hyphens: auto;
}
.post-body a { color: var(--fg); }
.post-body a:hover { color: var(--accent); }
.post-body p { font-size: var(--post-font-size); margin-bottom: 1em; }
.post-body p:last-child { margin-bottom: 0; }
.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--mono);
  margin-top: 2rem;
  margin-bottom: 0.25rem;
}

.post-body img {
  display: block;
  max-width: 90%;
  height: auto;
  margin-inline: auto;
}
.post-body p:has(> img) {
  margin-block: 2.5rem;
}
.post-body p:has(> img) + p { text-indent: 0; }

/* ── Footnote tooltip ───────────────────────────────────── */
.fn-tooltip {
  position: fixed;
  max-width: 32ch;
  max-height: 10lh;
  overflow-y: auto;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.5em 0.75em;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 100;
}
.fn-tooltip--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Footnotes ──────────────────────────────────────────── */
.footnote-definition {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  font-size: calc(var(--post-font-size) * 0.85);
  margin-bottom: 1em;
}
.footnote-definition sup { flex-shrink: 0; }
.footnote-definition .footdef { margin: 0; }
.footnote-definition .footdef p {
  font-size: inherit;
  text-indent: 0;
  margin: 0;
}

.post-nav {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 2rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 1.1rem;
}
.post-nav a { color: var(--fg-muted); text-decoration: none; }
.post-nav a:hover { color: var(--accent); }
.post-nav-disabled { color: var(--border); cursor: default; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 0.95rem; }

  .site-header,
  .site-footer,
  .main-content { padding-inline: 1.25rem; margin-inline: auto; }

  .nav-links { gap: 0.4rem; flex-direction: column; }

  /* Undo explicit font-size overrides so they inherit the smaller body size */
  .post-list,
  .home-recent h2,
  .home-intro h2,
  .writing-index-heading,
  .publicaciones,
  .publicaciones h2 { font-size: inherit; }

  .post-body p,
  .home-recent-list,
  .home-intro p { font-size: inherit; }

  h1, h2, h3, h4 { font-size: inherit; }
  .post-title { font-size: 1.3rem; }
  .post-tags,
  .post-title-date,
  .post-dateline,
  .post-nav,
  .post-body h2,
  .post-body h3,
  .post-body h4 { font-size: inherit; }

  /* 2. Weblog post list: date on its own line, title + tags below */
  .post-list-link {
    display: block;
    padding-left: 0;
    text-indent: 0;
  }
  .post-list-date  { display: block; font-size: 0.9em; }
  .post-list-date::after { content: none; }
  .post-list-title { display: block; }

  /* 3. Individual post header: title, then date, then dateline */
  .post-title-row {
    flex-direction: column;
    gap: 0.1rem;
  }

  /* 4. Tooltip: clamp to viewport near cursor */
  .fn-tooltip {
    position: fixed;
    max-width: calc(100vw - 2rem);
  }
}
