:root {
  --rojo: #8f1d2c;
  --rojo-oscuro: #641320;
  --morado: #4b2e5c;
  --amarillo: #d6a84f;
  --crema: #f7f1e8;
  --texto: #242124;
  --gris: #6b6268;
  --blanco: #ffffff;
  --sombra: 0 18px 45px rgba(61, 28, 35, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--texto);
  background: var(--crema);
  line-height: 1.6;
}
a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 241, 232, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(100, 19, 32, 0.12);
}
.navbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  text-decoration: none;
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--rojo-oscuro);
  letter-spacing: -0.02em;
}
.logo span { color: var(--morado); }
.nav-links {
  list-style: none;
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.nav-links a {
  text-decoration: none;
  font-weight: 650;
  color: var(--texto);
}
.nav-links a:hover { color: var(--rojo); }
.menu-toggle {
  display: none;
  border: 0;
  background: var(--rojo);
  color: white;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 1.1rem;
}

.hero {
  min-height: 72vh;
  display: grid;
  align-items: center;
  padding: 80px 24px;
  background:
    linear-gradient(120deg, rgba(100, 19, 32, .92), rgba(75, 46, 92, .82)),
    radial-gradient(circle at top right, rgba(214, 168, 79, .55), transparent 34%),
    var(--rojo);
  color: var(--blanco);
}
.hero-content { max-width: 980px; margin: 0 auto; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--amarillo);
  margin-bottom: 10px;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 5rem);
  line-height: 1.02;
  margin: 0 0 24px;
  letter-spacing: -0.05em;
}
.hero-text {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  max-width: 780px;
  color: rgba(255,255,255,0.9);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }
.btn {
  display: inline-flex;
  text-decoration: none;
  padding: 13px 20px;
  border-radius: 999px;
  font-weight: 800;
}
.btn.primary { background: var(--amarillo); color: #261315; }
.btn.secondary { border: 1px solid rgba(255,255,255,.55); color: var(--blanco); }

.section { max-width: 1180px; margin: 0 auto; padding: 78px 24px; }
.section.muted { max-width: none; background: #fffaf3; }
.section.muted > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.section-heading { margin-bottom: 30px; }
.section h2 {
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.08;
  margin: 0;
  color: var(--rojo-oscuro);
  letter-spacing: -0.035em;
}
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.card, .article-card, .archive-box, .quote-box, .admin-card {
  background: var(--blanco);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--sombra);
  border: 1px solid rgba(100, 19, 32, 0.08);
}
.card-icon { color: var(--amarillo); font-size: 1.6rem; }
.card h3, .article-card h3 { color: var(--morado); line-height: 1.2; }
.article-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.article-card a { text-decoration: none; }
.article-card h3 a:hover, .read-more:hover { color: var(--rojo); }
.tag {
  display: inline-block;
  background: rgba(143, 29, 44, 0.1);
  color: var(--rojo);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 800;
}
.read-more {
  display: inline-block;
  margin-top: 8px;
  color: var(--rojo-oscuro);
  font-weight: 850;
}
.timeline { border-left: 4px solid var(--rojo); padding-left: 24px; }
.timeline-item {
  margin-bottom: 24px;
  background: var(--blanco);
  padding: 20px;
  border-radius: 18px;
  box-shadow: var(--sombra);
}
.timeline-item span { color: var(--rojo); font-size: 1.4rem; font-weight: 900; }
.archive-box ul { columns: 2; padding-left: 20px; }
.about { display: grid; grid-template-columns: 1.5fr .8fr; gap: 24px; align-items: center; }
.quote-box { background: var(--rojo-oscuro); color: var(--blanco); font-size: 1.25rem; font-weight: 800; }
.site-footer { padding: 28px 24px; background: #261315; color: rgba(255,255,255,.78); text-align: center; }
.article-page { max-width: 860px; margin: 0 auto; padding: 70px 24px; }
.article-page h1 {
  color: var(--rojo-oscuro);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.article-page p { font-size: 1.08rem; }
.back-link {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--rojo);
  font-weight: 800;
  text-decoration: none;
}

/* Área privada */
.admin-body { background: #f3ede4; }
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 28px 24px 70px; }
.admin-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}
.admin-title h1 { margin: 0; color: var(--rojo-oscuro); line-height: 1.05; }
.admin-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 30px;
}
.admin-nav a, .admin-button, button.admin-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: var(--rojo);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  font-size: .95rem;
}
.admin-nav a.secondary, .admin-button.secondary { background: var(--morado); }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.admin-form {
  display: grid;
  gap: 14px;
}
.admin-form label {
  font-weight: 800;
  color: var(--rojo-oscuro);
}
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid rgba(100,19,32,.18);
  font: inherit;
  background: #fff;
}
.admin-form textarea { min-height: 300px; }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #fff8ef;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(100,19,32,.1);
}
.editor-toolbar button {
  border: 0;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 800;
  color: var(--rojo-oscuro);
  box-shadow: 0 3px 12px rgba(0,0,0,.06);
}
.visual-editor {
  min-height: 340px;
  background: #fff;
  border: 1px solid rgba(100,19,32,.18);
  border-radius: 14px;
  padding: 16px;
  outline: none;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: var(--sombra);
}
.admin-table th,
.admin-table td {
  padding: 14px;
  border-bottom: 1px solid rgba(100,19,32,.08);
  text-align: left;
  vertical-align: top;
}
.admin-table th { color: var(--rojo-oscuro); background: #fff8ef; }
.notice {
  background: #fff8df;
  border: 1px solid #e9cf79;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.error {
  background: #ffe7e7;
  border: 1px solid #ee9b9b;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.login-box {
  max-width: 440px;
  margin: 80px auto;
}

@media (max-width: 900px) {
  .cards, .article-list, .about, .admin-grid { grid-template-columns: 1fr; }
  .nav-links {
    position: absolute;
    top: 68px;
    right: 24px;
    background: var(--blanco);
    flex-direction: column;
    padding: 18px;
    border-radius: 18px;
    box-shadow: var(--sombra);
    display: none;
  }
  .nav-links.open { display: flex; }
  .menu-toggle { display: block; }
  .archive-box ul { columns: 1; }
  .admin-top { align-items: flex-start; flex-direction: column; }
  .admin-table { display: block; overflow-x: auto; }
}


/* =========================
   Efectos visuales dinámicos
   ========================= */

body {
  overflow-x: hidden;
}

.site-header {
  transition: box-shadow .25s ease, background .25s ease, transform .25s ease;
}

.site-header.scrolled {
  background: rgba(247, 241, 232, 0.98);
  box-shadow: 0 12px 35px rgba(38, 19, 21, .12);
}

.logo {
  position: relative;
}

.logo::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -7px;
  width: 0;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rojo), var(--amarillo), var(--morado));
  transition: width .3s ease;
}

.logo:hover::after {
  width: 100%;
}

.nav-links a {
  position: relative;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -7px;
  width: 0;
  height: 2px;
  border-radius: 999px;
  background: var(--rojo);
  transition: width .25s ease;
}

.nav-links a:hover::after {
  width: 100%;
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(3px);
  opacity: .42;
  z-index: -1;
  animation: floatShape 9s ease-in-out infinite alternate;
}

.hero::before {
  width: 360px;
  height: 360px;
  background: rgba(214, 168, 79, .32);
  top: 8%;
  right: -90px;
}

.hero::after {
  width: 260px;
  height: 260px;
  background: rgba(255, 255, 255, .12);
  bottom: -80px;
  left: 5%;
  animation-delay: 1.4s;
}

@keyframes floatShape {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-28px, 24px, 0) scale(1.08);
  }
}

.hero h1 {
  animation: heroTitle .75s ease both;
}

.hero .eyebrow,
.hero-text,
.hero-actions {
  animation: heroFade .75s ease both;
}

.hero .eyebrow {
  animation-delay: .08s;
}

.hero-text {
  animation-delay: .16s;
}

.hero-actions {
  animation-delay: .24s;
}

@keyframes heroTitle {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heroFade {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn {
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(38, 19, 21, .22);
}

.card,
.article-card,
.timeline-item,
.archive-box,
.quote-box,
.admin-card {
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.card:hover,
.article-card:hover,
.timeline-item:hover,
.archive-box:hover,
.quote-box:hover,
.admin-card:hover {
  transform: translateY(-7px);
  box-shadow: 0 24px 55px rgba(61, 28, 35, 0.18);
  border-color: rgba(143, 29, 44, .22);
}

.card-icon {
  transition: transform .3s ease;
}

.card:hover .card-icon {
  transform: rotate(12deg) scale(1.15);
}

.article-card {
  position: relative;
  overflow: hidden;
}

.article-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(143,29,44,.08), transparent 48%);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}

.article-card:hover::before {
  opacity: 1;
}

.timeline {
  position: relative;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -34px;
  top: 26px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amarillo);
  border: 4px solid var(--rojo);
  box-shadow: 0 0 0 6px rgba(143,29,44,.12);
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .7s ease, transform .7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.cards .reveal:nth-child(2),
.article-list .reveal:nth-child(2) {
  transition-delay: .08s;
}

.cards .reveal:nth-child(3),
.article-list .reveal:nth-child(3) {
  transition-delay: .16s;
}

.cards .reveal:nth-child(4),
.article-list .reveal:nth-child(4) {
  transition-delay: .24s;
}

.progress-line {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0;
  background: linear-gradient(90deg, var(--rojo), var(--amarillo), var(--morado));
  z-index: 999;
  transition: width .08s linear;
}

.article-page h1 {
  position: relative;
}

.article-page h1::after {
  content: "";
  display: block;
  width: 96px;
  height: 5px;
  margin-top: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rojo), var(--amarillo));
}

.read-more {
  transition: transform .2s ease, color .2s ease;
}

.read-more:hover {
  transform: translateX(3px);
}

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

  .reveal {
    opacity: 1;
    transform: none;
  }
}


/* Página de enlaces */

.links-hero {
  padding: 92px 24px 62px;
  color: var(--blanco);
  background:
    linear-gradient(135deg, rgba(100, 19, 32, .96), rgba(75, 46, 92, .86)),
    radial-gradient(circle at 85% 15%, rgba(214,168,79,.42), transparent 30%),
    var(--rojo-oscuro);
  position: relative;
  overflow: hidden;
}

.links-hero::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  right: -120px;
  bottom: -160px;
  background: rgba(255,255,255,.09);
  animation: floatShape 11s ease-in-out infinite alternate;
}

.links-hero-content {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.links-hero h1 {
  max-width: 920px;
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.links-hero p {
  max-width: 820px;
  color: rgba(255,255,255,.88);
  font-size: 1.12rem;
}

.links-search-box {
  margin-top: 30px;
  max-width: 720px;
}

.links-search-box input {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 17px 22px;
  font: inherit;
  box-shadow: 0 20px 50px rgba(0,0,0,.22);
  outline: none;
}

.links-search-box input:focus {
  box-shadow: 0 0 0 4px rgba(214,168,79,.35), 0 20px 50px rgba(0,0,0,.22);
}

.links-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.links-categories button {
  border: 1px solid rgba(255,255,255,.36);
  background: rgba(255,255,255,.08);
  color: white;
  padding: 9px 13px;
  border-radius: 999px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}

.links-categories button:hover,
.links-categories button.active {
  background: var(--amarillo);
  color: #261315;
  transform: translateY(-2px);
}

.links-section {
  max-width: 1180px;
}

.links-group {
  margin-bottom: 58px;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.link-card {
  background: var(--blanco);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--sombra);
  border: 1px solid rgba(100,19,32,.08);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  position: relative;
  overflow: hidden;
}

.link-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(214,168,79,.16), transparent 45%);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}

.link-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 26px 60px rgba(61,28,35,.18);
  border-color: rgba(143,29,44,.22);
}

.link-card:hover::before {
  opacity: 1;
}

.link-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.external-icon {
  color: var(--rojo);
  font-weight: 950;
  font-size: 1.15rem;
}

.link-card h3 {
  color: var(--morado);
  line-height: 1.18;
  margin-bottom: 8px;
}

.link-card p {
  color: var(--gris);
  flex: 1;
}

.link-card .admin-button {
  align-self: flex-start;
  margin-top: 10px;
}

.link-card.hidden,
.links-group.hidden {
  display: none;
}

.article-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 900px) {
  .links-grid {
    grid-template-columns: 1fr;
  }

  .links-hero {
    padding-top: 70px;
  }
}


/* Logotipos y capturas en enlaces */

.link-card-media {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: #fff8ef;
  border: 1px solid rgba(100,19,32,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.65);
  overflow: hidden;
}

.link-card-media img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  transition: transform .25s ease;
}

.link-card:hover .link-card-media img {
  transform: scale(1.08) rotate(-2deg);
}

.link-logo-fallback {
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--rojo), var(--morado));
  color: white;
  font-size: 2rem;
  font-weight: 950;
}

.admin-link-thumb {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff8ef;
  padding: 6px;
  border: 1px solid rgba(100,19,32,.12);
}


/* Capturas automáticas en la página de enlaces */

.link-card-screenshot {
  width: calc(100% + 48px);
  height: 150px;
  margin: -24px -24px 18px;
  background: #fff8ef;
  border-bottom: 1px solid rgba(100,19,32,.12);
  overflow: hidden;
  position: relative;
}

.link-card-screenshot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 58%, rgba(38,19,21,.20));
  pointer-events: none;
}

.link-card-screenshot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease, filter .35s ease;
}

.link-card:hover .link-card-screenshot img {
  transform: scale(1.06);
  filter: saturate(1.05) contrast(1.03);
}

.link-card-screenshot img.favicon-fallback {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 39px auto;
  display: block;
  transform: none !important;
  filter: none !important;
}

.admin-link-screenshot-thumb {
  width: 72px;
  height: 46px;
  object-fit: cover;
  border-radius: 10px;
  background: #fff8ef;
  border: 1px solid rgba(100,19,32,.12);
}

@media (max-width: 900px) {
  .link-card-screenshot {
    height: 180px;
  }
}


/* Previsualizaciones estables: captura si carga, logotipo si falla */

.link-card-screenshot {
  background:
    linear-gradient(135deg, rgba(143,29,44,.12), rgba(75,46,92,.12)),
    #fff8ef;
}

.link-card-screenshot.preview-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent),
    linear-gradient(135deg, rgba(143,29,44,.08), rgba(214,168,79,.10));
  animation: previewPulse 1.3s linear infinite;
  z-index: 1;
}

@keyframes previewPulse {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.link-card-screenshot.preview-failed {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.link-card-screenshot.preview-failed::after {
  background: linear-gradient(180deg, transparent 55%, rgba(38,19,21,.10));
}

.link-card-screenshot.preview-failed img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  padding: 12px;
  border-radius: 22px;
  background: white;
  box-shadow: 0 14px 35px rgba(38,19,21,.14);
  transform: none !important;
  filter: none !important;
}

.link-domain {
  position: absolute;
  left: 14px;
  bottom: 12px;
  right: 14px;
  z-index: 2;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  color: var(--rojo-oscuro);
  font-size: .78rem;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 20px rgba(38,19,21,.10);
}

.link-card-screenshot.preview-failed .link-domain {
  bottom: 14px;
}


/* Corrección: las tarjetas de enlaces nunca deben quedar invisibles si falla la animación */
.link-card.reveal {
  opacity: 1;
  transform: none;
}

.link-card.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
