:root {
  /* Substack dark mode — extracted from feed & reading views */
  --substack-orange: #ff6719;
  --substack-orange-pressed: #e5560e;
  --substack-orange-tint: #2a1c12;
  --substack-orange-border: #5c3a24;

  --bg-main: #121212;
  --bg-elevated: #1c1c1c;
  --bg-input: #1e1e1e;
  --bg-hover: #252525;

  --text-primary: #ffffff;
  --text-body: #e5e5e5;
  --text-secondary: #a0a0a0;
  --text-muted: #737373;
  --text-caption: #8e8e8e;

  --border: #2d2d2d;
  --border-subtle: #262626;
  --divider: #262626;

  --link: #6b9fff;
  --link-hover: #8bb4ff;
  --shadow: rgba(0, 0, 0, 0.35);

  /* Semantic aliases */
  --bg: var(--bg-main);
  --bg-card: var(--bg-elevated);
  --text: var(--text-body);
  --text-strong: var(--text-primary);
  --accent: var(--substack-orange);
  --accent-hover: var(--substack-orange-pressed);
  --accent-soft: var(--substack-orange-tint);
  --accent-border: var(--substack-orange-border);

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --max-width: 680px;
  --container: 960px;
  --radius-card: 12px;
  --img-fade-duration: 2s;
  --img-fade-easing: cubic-bezier(0.22, 1, 0.36, 1);
  --reading-fade-duration: 0.75s;
  --reading-fade-easing: cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(var(--container), 100% - 2rem);
  margin-inline: auto;
}

.container.narrow {
  width: min(var(--max-width), 100% - 2rem);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

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

.site-logo {
  font-family: var(--sans);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-logo:hover {
  color: var(--accent-hover);
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.site-nav a:hover {
  color: var(--text-primary);
}

.site-nav a.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* Hero */
.hero {
  position: relative;
  padding: 4rem 0 3rem;
  text-align: center;
  background-image: var(--hero-image);
  background-size: cover;
  background-position: center;
  isolation: isolate;
  animation: fade-in var(--img-fade-duration) var(--img-fade-easing) both;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(18, 18, 18, 0.55) 0%,
    rgba(18, 18, 18, 0.75) 50%,
    rgba(18, 18, 18, 0.9) 100%
  );
  z-index: 0;
}

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

.hero-title {
  font-family: var(--sans);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Filter tabs — Substack-style underline solapas */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.filter-tab {
  padding: 0.85rem 0;
  margin-bottom: -1px;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  transition: color 0.15s, border-color 0.15s;
}

.filter-tab:hover {
  color: var(--text-primary);
  background: transparent;
}

.filter-tab.active {
  color: var(--text-primary);
  background: transparent;
  border-bottom-color: var(--text-primary);
}

.publication-grid {
  display: grid;
  gap: 0;
  margin-bottom: 3rem;
  margin-top: 0;
  border-top: none;
}

.publication-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  transition: background 0.15s;
}

.publication-card:hover {
  background: var(--bg-hover);
  box-shadow: none;
  transform: none;
  border-color: var(--border-subtle);
}

.publication-card--has-cover {
  border-bottom: none;
  margin-bottom: 0.75rem;
}

.publication-card--has-cover:hover {
  background: transparent;
}

.publication-card--has-cover .card-link {
  position: relative;
  padding: 1.5rem;
  min-height: 13rem;
  border-radius: var(--radius-card);
  background-image: var(--cover-image);
  background-size: cover;
  background-position: center;
  isolation: isolate;
  overflow: hidden;
  animation: fade-in var(--img-fade-duration) var(--img-fade-easing) both;
}

.publication-card--has-cover:nth-child(1) .card-link { animation-delay: 0.05s; }
.publication-card--has-cover:nth-child(2) .card-link { animation-delay: 0.15s; }
.publication-card--has-cover:nth-child(3) .card-link { animation-delay: 0.25s; }
.publication-card--has-cover:nth-child(4) .card-link { animation-delay: 0.35s; }
.publication-card--has-cover:nth-child(5) .card-link { animation-delay: 0.45s; }
.publication-card--has-cover:nth-child(n + 6) .card-link { animation-delay: 0.55s; }

.publication-card--has-cover .card-link::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(18, 18, 18, 0.92) 0%,
    rgba(18, 18, 18, 0.55) 45%,
    rgba(18, 18, 18, 0.3) 100%
  );
  z-index: 0;
  transition: background 0.15s;
}

.publication-card--has-cover:hover .card-link::before {
  background: linear-gradient(
    to top,
    rgba(18, 18, 18, 0.95) 0%,
    rgba(18, 18, 18, 0.65) 45%,
    rgba(18, 18, 18, 0.4) 100%
  );
}

.publication-card--has-cover .card-link > * {
  position: relative;
  z-index: 1;
}

.card-link {
  display: block;
  padding: 1.25rem 0;
  text-decoration: none;
  color: inherit;
}

.card-title {
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.5rem 0 0.35rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.card-excerpt {
  color: var(--text-secondary);
  font-size: 0.925rem;
  margin: 0 0 0.75rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--text-caption);
}

.meta-sep {
  margin: 0 0.35rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-cuento {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.badge-micro_relato {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-reflexion {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-poema {
  background: #1e1a28;
  color: #c4b5fd;
  border: 1px solid #3d3558;
}

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--accent-soft);
  color: #ffb899;
  border: 1px solid var(--accent-border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.preview-export-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--accent-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.preview-export-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: #ffffff;
}

.reading-page {
  padding: 2rem 0 4rem;
}

.reading-page .reading-close-btn {
  animation: fade-in-up var(--reading-fade-duration) var(--reading-fade-easing) both;
}

.reading-close-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 2rem;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.reading-close-tooltip {
  position: absolute;
  left: calc(100% + 0.6rem);
  top: 50%;
  z-index: 10;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-body);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 12px var(--shadow);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%) translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.reading-close-tooltip::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  border: 5px solid transparent;
  border-right-color: var(--border);
  transform: translateY(-50%);
}

.reading-close-tooltip::after {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  margin-right: -1px;
  border: 4px solid transparent;
  border-right-color: var(--bg-elevated);
  transform: translateY(-50%);
}

.reading-close-btn:hover .reading-close-tooltip,
.reading-close-btn:focus-visible .reading-close-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.reading-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.reading-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reading-page .reading-header {
  animation: fade-in-up var(--reading-fade-duration) var(--reading-fade-easing) 0.08s both;
}

.reading-page .prose {
  animation: fade-in-up calc(var(--reading-fade-duration) + 0.15s) var(--reading-fade-easing) 0.16s both;
}

.reading-page .prose img {
  animation: none;
}

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 2rem;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--text-primary);
}

.reading-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.reading-title {
  font-family: var(--sans);
  font-size: clamp(1.75rem, 4.5vw, 2.35rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  margin: 0.75rem 0;
  letter-spacing: -0.025em;
}

.reading-excerpt {
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
}

.reading-byline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.reading-byline-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.reading-byline-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
}

.reading-byline-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.reading-byline-name {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-decoration: none;
  width: fit-content;
  transition: color 0.15s;
}

.reading-byline-name:hover {
  color: var(--link);
}

.reading-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.prose {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-body);
}

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: var(--link-hover);
}

.prose blockquote {
  margin: 1.5em 0;
  padding-left: 1.25em;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  font-style: italic;
}

.prose p,
.prose h1,
.prose h2,
.prose h3,
.prose blockquote,
.prose li {
  /* Preserve inline typography from the editor */
}

.prose p {
  margin: 0 0 1.25em;
}

.prose u {
  text-decoration: underline;
}

.prose mark {
  border-radius: 2px;
  padding: 0 1px;
}

.prose .footnote-ref-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.72em;
  font-weight: 600;
  vertical-align: super;
  padding: 0 1px;
}

.prose .footnote-ref-link:hover {
  text-decoration: underline;
}

.prose .footnote-item {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
}

.prose .footnote-item::before {
  content: attr(data-footnote-number) ". ";
  color: var(--accent);
  font-weight: 600;
}

.prose .footnote-item:first-of-type {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top-color: var(--border);
}

.prose .footnote-number {
  display: none;
}

.prose .poetry-block {
  white-space: pre-wrap;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.85;
  color: var(--text-body);
  margin: 1.75rem 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.prose s,
.prose del {
  text-decoration: line-through;
}

.prose p[style*="text-align: center"],
.prose h1[style*="text-align: center"],
.prose h2[style*="text-align: center"],
.prose h3[style*="text-align: center"] {
  text-align: center;
}

.prose p[style*="text-align: right"],
.prose h1[style*="text-align: right"],
.prose h2[style*="text-align: right"],
.prose h3[style*="text-align: right"] {
  text-align: right;
}

.prose p[style*="text-align: justify"],
.prose h1[style*="text-align: justify"],
.prose h2[style*="text-align: justify"],
.prose h3[style*="text-align: justify"] {
  text-align: justify;
}

.prose span[style],
.prose p[style],
.prose h1[style],
.prose h2[style],
.prose h3[style] {
  /* Inline font-family, font-size, line-height from editor are kept as-is */
}

.prose h1,
.prose h2,
.prose h3 {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 2em 0 0.75em;
}

.prose h1 { font-size: 1.75rem; }
.prose h2 { font-size: 1.45rem; }
.prose h3 { font-size: 1.2rem; }

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5em 0;
  animation: fade-in-up var(--img-fade-duration) var(--img-fade-easing) both;
}

.prose img:nth-of-type(1) { animation-delay: 0.05s; }
.prose img:nth-of-type(2) { animation-delay: 0.15s; }
.prose img:nth-of-type(3) { animation-delay: 0.25s; }
.prose img:nth-of-type(4) { animation-delay: 0.35s; }
.prose img:nth-of-type(5) { animation-delay: 0.45s; }
.prose img:nth-of-type(n + 6) { animation-delay: 0.55s; }

.prose ul,
.prose ol {
  margin: 0 0 1.25em;
  padding-left: 1.5em;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2em 0;
}

/* About page */
.about-page {
  padding: 3rem 0 4rem;
}

.about-title {
  font-family: var(--sans);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2rem;
}

.about-profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.about-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  animation: fade-in-up var(--img-fade-duration) var(--img-fade-easing) both;
}

.about-photo-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--bg-elevated);
  color: var(--accent);
  border: 2px solid var(--border);
}

.about-name {
  font-family: var(--sans);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.25rem;
}

.about-email {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.about-email:hover {
  color: var(--accent);
}

.about-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
}

.about-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.about-meta-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.about-bio {
  margin-top: 0.5rem;
}

.about-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 0 3rem;
}

.page-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
}

.page-link:hover {
  color: var(--accent-hover);
}

.page-info {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 0;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-caption);
  font-size: 0.8125rem;
}

.site-main {
  min-height: calc(100vh - 160px);
}

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .about-profile {
    flex-direction: column;
    text-align: center;
  }

  .about-meta {
    justify-content: center;
  }

  .site-nav {
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero,
  .publication-card--has-cover .card-link,
  .prose img,
  .about-photo,
  .reading-page .reading-close-btn,
  .reading-page .reading-header,
  .reading-page .prose {
    animation: none;
  }

  .reading-close-tooltip {
    transition: none;
  }
}
