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

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

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

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

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

/* ── Icons ──────────────────────────────────────────────── */
.icon {
  width: 1.1em;
  height: 1.1em;
  display: block;
}

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  color: var(--fg-muted);
  padding: 0;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── 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);
  text-wrap: balance;
}
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; text-wrap: pretty; }

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

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


/* ── Homepage ───────────────────────────────────────────── */
.home { font-family: var(--serif); }
.home-intro {
  margin-bottom: 3rem;
  line-height: 1.45;
  font-variant-numeric: oldstyle-nums;
}
.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; }

/* Animated ASCII art from ascii.rest (vendored in assets/ascii/). 65 columns
   at about 0.6em per character, with a little slack for wider fallback glyphs:
   sized from the column's own width (cqi), it never overflows. */
.home-ascii { margin: 0 0 3rem; container-type: inline-size; }
.home-ascii ascii-art {
  color: var(--fg-muted);
  font-size: min(0.95rem, 100cqi / 40);
  overflow: hidden;
}

.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-main > *:first-child,
.home-main > *:first-child > *:first-child,
.home-main > *:first-child > *:first-child > *:first-child {
  margin-top: 0;
}

.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); }


/* ── 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.4;
  font-variant-numeric: oldstyle-nums;
}
.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; }

/* ── Lecturas table ─────────────────────────────────────── */
.publicaciones table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 0;
  font-size: calc(var(--post-font-size) * 0.85);
  line-height: 1.35;
}
.publicaciones th,
.publicaciones td {
  padding: 0.35em 0.75em 0.35em 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: baseline;
}
.publicaciones th {
  font-family: var(--mono);
  font-size: 0.8em;
  font-weight: normal;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  border-bottom-color: var(--fg-muted);
}
.publicaciones tr:last-child td { border-bottom: none; }
/* Title column: italic, like a citation */
.publicaciones td:first-child { font-style: italic; }
/* Date column: mono, right-aligned, never wrapped */
.publicaciones th:last-child,
.publicaciones td:last-child {
  font-family: var(--mono);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--fg-muted);
  text-align: right;
  padding-right: 0;
  width: 1%;
}

/* Titles that link off-site get a small mark */
.publicaciones a.enlace-externo::after {
  content: "↗";
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.75em;
  color: var(--fg-muted);
  margin-left: 0.25em;
  vertical-align: 0.15em;
}
.publicaciones a.enlace-externo:hover::after { color: var(--accent); }

@media (max-width: 34rem) {
  .publicaciones table { font-size: calc(var(--post-font-size) * 0.75); }
  .publicaciones th,
  .publicaciones td { padding-right: 0.5em; }
  .publicaciones th:last-child,
  .publicaciones td:last-child { padding-right: 0; }
}

/* ── Book note ──────────────────────────────────────────── */
.libro-nav {
  font-family: var(--mono);
  font-size: 1.1rem;
  margin: var(--space) 0 33vh;
}
.libro-nav a { color: var(--fg-muted); text-decoration: none; }
.libro-nav a:hover { color: var(--accent); }

/* ── 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;
  line-height: 1.45;
  font-variant-numeric: oldstyle-nums;
}
.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; }

.post-body ul,
.post-body ol {
  font-size: var(--post-font-size);
  margin: 0 0 1em;
  padding-left: 1.5em;
}
.post-body li + li { margin-top: 0.25em; }
.post-body li p { margin-bottom: 0.25em; }

.post-body blockquote {
  margin: 1.5em 0;
  padding-left: 1.25em;
  border-left: 2px solid var(--fg-muted);
}
.post-body blockquote p {
  font-size: calc(var(--post-font-size) * 0.95);
}

.post-body code {
  font-family: var(--mono);
  font-size: 0.85em;
}
.post-body pre {
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.4;
  overflow-x: auto;
  padding: 0.75em 1em;
  margin: 1.5em 0;
  border: 1px solid var(--border);
  border-radius: 2px;
}
.post-body pre code { font-size: inherit; }

.post-body table {
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: calc(var(--post-font-size) * 0.85);
  line-height: 1.35;
}
.post-body th,
.post-body td {
  padding: 0.3em 0.75em;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.post-body th {
  font-family: var(--mono);
  font-weight: normal;
  color: var(--fg-muted);
}

.post-body hr {
  border: none;
  margin: 2.5rem 0;
  text-align: center;
  font-family: var(--mono);
  color: var(--fg-muted);
  line-height: 1;
}
.post-body hr::before { content: "::::::::::::::::"; }

/* ── 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 {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 2rem;
  margin-left: -3rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
  padding-left: 3rem;
  font-family: var(--mono);
  font-size: 1.1rem;
}
.post-nav::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: calc(-100vw);
  height: 1px;
  background: var(--border);
}
.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; }

/* ── Homepage sidebar layout ────────────────────────────── */
.home-layout {
  min-height: 100vh;
}

.home-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
}

.home-sidebar {
  display: flex;
  justify-content: flex-end;
  padding: 3rem 3rem 3rem 2rem;
  border-right: 1px solid var(--border);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  font-family: var(--mono);
  text-align: right;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  line-height: 1.3;
  color: var(--fg);
}

.sidebar-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.sidebar-links a {
  color: var(--fg);
  text-decoration: none;
}
.sidebar-links a:hover { color: var(--accent); }
.sidebar-links a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

.home-main {
  padding: 3rem 3rem 8rem 3rem;
  max-width: calc(var(--measure) + 4rem);
  min-width: 0;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 760px) {
  .home-grid {
    grid-template-columns: 1fr;
    min-height: unset;
  }

  .home-sidebar {
    justify-content: flex-start;
    padding: 1.5rem 1.25rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    text-align: left;
    position: static;
  }

  .sidebar-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 0.75rem;
  }

  .sidebar-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }

  .sidebar-icons {
    margin-top: 0.75rem;
    gap: 1rem;
  }

  .home-main {
    padding: 1.5rem 1.25rem 6rem;
  }
}

@media (max-width: 600px) {
  body { font-size: 1.0625rem; }

  /* 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);
  }
}
