/* ==========================================================================
   Blog · Fernando Cortés Calderón
   Identidad tomada de cortescalderon.com: negro, dorado y esmeralda.
   ========================================================================== */

/* ---- Fuentes autoalojadas (SIL OFL 1.1, ver assets/fonts) ---- */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono-latin-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/fraunces-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/fraunces-latin-600-normal.woff2') format('woff2');
}

/* ---- Tokens ---- */
:root {
  --bg: #121212;
  --panel: #1A1A18;
  --text: #F5F0E8;
  --text-muted: #9C9689;
  --accent: #C9A24B;
  --accent2: #3FA089;
  --line: #2E2E2A;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --serif: 'Fraunces', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: radial-gradient(ellipse 900px 600px at 50% -10%, #1C1B17 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-wrap: break-word;
}

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

:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--accent2);
  color: var(--bg);
  padding: 0.4rem 0.8rem;
  border-radius: 3px;
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

[hidden] { display: none !important; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.site-header, main, .site-footer { animation: rise 0.8s var(--ease) both; }
main { animation-delay: 0.12s; }
.site-footer { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Encabezado ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand:hover .monogram { background: rgba(201, 162, 75, 0.08); }

.monogram {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  transition: background 0.35s var(--ease);
}

.brand-name { display: flex; flex-direction: column; line-height: 1.3; }
.brand-name .line1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
}
.brand-name .line2 {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent2);
}

.back-link {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  transition: border-color 0.35s var(--ease), color 0.35s var(--ease);
}
.back-link:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Índice ---- */
.tagline {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.intro { margin-bottom: 2rem; }
.intro-text { color: var(--text); max-width: 60ch; }

.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2rem;
}

.filter button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: 3px;
  padding: 0.5rem 0.9rem;
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.35s var(--ease), color 0.35s var(--ease), background 0.35s var(--ease);
}
.filter button:hover { border-color: var(--accent); color: var(--accent); }
.filter button[aria-pressed="true"] {
  background: var(--accent2);
  border-color: var(--accent2);
  color: var(--bg);
  font-weight: 500;
}

.post-list { list-style: none; display: grid; gap: 1rem; }

.post-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.4rem 1.5rem;
  position: relative;
  transition: border-color 0.35s var(--ease), transform 0.35s var(--ease);
}
.post-card:hover { border-color: rgba(201, 162, 75, 0.45); transform: translateY(-2px); }

.post-card-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.3;
  margin: 0.6rem 0 0.4rem;
}
.post-card-title a { color: var(--text); text-decoration: none; }
/* Toda la tarjeta es clicable sin anidar enlaces. */
.post-card-title a::after { content: ''; position: absolute; inset: 0; border-radius: 6px; }
.post-card-title a:focus-visible { outline: none; }
.post-card:focus-within { outline: 2px solid var(--accent2); outline-offset: 2px; }

.post-card-desc { color: var(--text-muted); font-size: 0.88rem; }

.empty { color: var(--text-muted); font-style: italic; margin-top: 1rem; }

/* ---- Metadatos y pilares ---- */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.1rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pillar {
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  font-weight: 500;
}
.tone-emerald { color: var(--accent2); }
.tone-gold { color: var(--accent); }
.tone-cream { color: var(--text); }

.meta-flag { color: var(--text-muted); opacity: 0.85; }

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

.post-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0.9rem 0 0.8rem;
}

.post-lead { color: var(--text-muted); font-size: 1rem; max-width: 62ch; }

/* ---- Video ---- */
.video { margin: 0 0 2rem; }

.video-facade, .video-frame {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(201, 162, 75, 0.06);
}

.video-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s var(--ease), opacity 0.35s var(--ease);
  opacity: 0.85;
}
.video-facade:hover .video-cover { transform: scale(1.02); opacity: 1; }

.video-cover-default {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #22211C 0%, var(--panel) 70%);
}
.video-cover-default .monogram { width: 96px; height: 96px; font-size: 2rem; }

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.78);
  border: 1px solid var(--accent);
  transition: background 0.35s var(--ease);
}
.video-play::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent var(--accent);
}
.video-facade:hover .video-play { background: var(--accent2); border-color: var(--accent2); }
.video-facade:hover .video-play::after { border-left-color: var(--bg); }

.video-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.5rem 1rem 0.8rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text);
  background: linear-gradient(transparent, rgba(18, 18, 18, 0.9));
}

/* Con portada propia (miniatura con texto), el botón va a la esquina para no taparla. */
.video-has-cover .video-cover { opacity: 1; }
.video-has-cover .video-play { top: auto; left: auto; right: 18px; bottom: 18px; transform: none; width: 60px; height: 60px; }
.video-has-cover .video-label { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; padding: 0; white-space: nowrap; }

.video-note {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ---- Enlace al repositorio ---- */
.repo-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 2.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: rgba(201, 162, 75, 0.06);
  color: var(--text);
  text-decoration: none;
  transition: background 0.35s var(--ease);
}
.repo-link:hover { background: rgba(201, 162, 75, 0.14); color: var(--text); }
.repo-icon { color: var(--accent); flex-shrink: 0; }
.repo-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.repo-label { font-weight: 500; font-size: 0.9rem; }
.repo-path { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-arrow { color: var(--accent); transition: transform 0.35s var(--ease); }
.repo-link:hover .repo-arrow { transform: translateX(4px); }

/* ---- Contenido Markdown ---- */
.prose > * + * { margin-top: 1.2rem; }

.prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  margin-top: 2.5rem;
}
.prose h2 { font-size: 1.55rem; }
.prose h3 { font-size: 1.25rem; }
.prose h4 { font-size: 1.05rem; color: var(--text-muted); }

.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35rem; }
.prose li::marker { color: var(--accent2); }

.prose strong { font-weight: 500; color: var(--text); }

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.2rem;
  color: var(--text-muted);
  font-style: italic;
}

.prose hr { border: none; border-top: 1px solid var(--line); margin: 2.5rem 0; }

.prose img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 0.55rem 0.8rem; text-align: left; }
.prose th { color: var(--accent); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }

.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--accent2);
  background: rgba(63, 160, 137, 0.08);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

.prose pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}
.prose pre code { background: none; padding: 0; color: var(--text); font-size: inherit; }
.prose div.highlight, .prose figure.highlight { margin-top: 1.2rem; }

/* Resaltado de sintaxis (Rouge) con la paleta del sitio */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp { color: #6F6A60; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kt, .highlight .kc { color: var(--accent); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sh, .highlight .sx, .highlight .se { color: var(--accent2); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh { color: #D9B871; }
.highlight .nf, .highlight .fm, .highlight .nb, .highlight .bp { color: #E6D3A3; }
.highlight .nv, .highlight .vi, .highlight .vg, .highlight .na { color: #7CC4B0; }
.highlight .o, .highlight .ow, .highlight .p { color: var(--text-muted); }
.highlight .gp { color: var(--accent2); user-select: none; }
.highlight .err { color: inherit; background: none; }

/* ---- Navegación entre posts ---- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--text);
}
.post-nav-next { grid-column: 2; text-align: right; }
.post-nav-label { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.post-nav-title { font-family: var(--serif); font-weight: 500; }
.post-nav a:hover .post-nav-title { color: var(--accent); }

.back-to-index {
  margin-top: 2rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.back-to-index a { text-decoration: none; }

.not-found { padding: 2rem 0; }

/* ---- Pie ---- */
.site-footer {
  margin-top: 4.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  text-align: center;
}
.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.attribution {
  margin-top: 1rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ---- Móvil ---- */
@media (max-width: 560px) {
  body { font-size: 14px; }
  .wrap { padding: 1.75rem 1rem 3rem; }
  .site-header { margin-bottom: 2.5rem; }
  .brand-name .line1 { font-size: 0.95rem; }
  .post-card { padding: 1.2rem 1.1rem; }
  .post-card-title { font-size: 1.15rem; }
  .video-play { width: 60px; height: 60px; }
  .video-has-cover .video-play { width: 38px; height: 38px; right: 8px; bottom: 8px; }
  .video-has-cover .video-play::after { border-width: 7px 0 7px 12px; }
  /* En pantallas chicas la etiqueta taparía la portada: se mantiene solo para lectores de pantalla. */
  .video-label { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; padding: 0; white-space: nowrap; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { grid-column: 1; text-align: left; }
}
