/* ===== Variables ===== */
:root {
  --bg: #0c0a10;
  --card: #181420;
  --card2: #201a29;
  --line: #2e2638;
  --text: #efe9f3;
  --muted: #a398b0;
  --gold: #dcb870;
  --gold-soft: rgba(220, 184, 112, .14);
  --rose: #e2507e;
  --rose-soft: rgba(226, 80, 126, .12);
  --ok: #6fd3a0;
  --bad: #ff8a99;
  --radius: 14px;
  --col: 560px; /* ancho de la columna de publicaciones: súbelo o bájalo a tu gusto */
  --serif: 'Playfair Display', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 50% -12%, rgba(226, 80, 126, .14), transparent 60%),
    radial-gradient(900px 480px at 105% 0%, rgba(220, 184, 112, .09), transparent 55%),
    var(--bg);
}

a { color: var(--gold); text-underline-offset: 3px; }
a:hover { color: #f0d49a; }

img, video, iframe { max-width: 100%; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--gold); color: #1a1305; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ===== Barra superior ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 12px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(12, 10, 16, .82);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__left { justify-self: start; }
.topbar__right { justify-self: end; }

.brand {
  margin: 0;
  font-family: var(--serif); font-style: italic; font-weight: 600;
  font-size: clamp(1.35rem, 4vw, 1.9rem); letter-spacing: .02em; line-height: 1.1;
  text-align: center; color: var(--text);
}

.visit-counter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: .85rem; color: var(--muted); white-space: nowrap;
}
.visit-counter__icon { color: var(--gold); flex: none; }
.visit-counter__num { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

.tagline {
  margin: 22px auto 6px; padding: 0 20px; max-width: 640px;
  text-align: center; font-family: var(--serif); font-style: italic;
  color: var(--muted); font-size: 1.05rem;
}
.tagline:empty { display: none; }

/* ===== Layout ===== */
.wrap { max-width: var(--col); margin: 0 auto; padding: 18px 14px 40px; }
.center { text-align: center; margin: 8px 0 28px; }

/* ===== Botones ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: .62rem 1.2rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: border-color .15s, transform .15s, filter .15s;
}
.btn:hover { border-color: var(--gold); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--small { padding: .4rem .9rem; font-size: .85rem; }
.btn--gold { background: linear-gradient(135deg, #ecc983, #c99a45); color: #1a1305; border-color: transparent; }
.btn--gold:hover { color: #1a1305; filter: brightness(1.08); border-color: transparent; }
.btn--rose { background: linear-gradient(135deg, #ee628f, #c93a69); color: #fff; border-color: transparent; }
.btn--rose:hover { color: #fff; filter: brightness(1.08); border-color: transparent; }
.btn--danger { color: var(--bad); }
.btn--danger:hover { border-color: var(--bad); color: var(--bad); }

/* ===== Publicaciones ===== */
.post {
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .32);
}
.post.is-pinned { border-color: rgba(220, 184, 112, .55); }
.post.is-enigma { border-color: rgba(226, 80, 126, .4); }
.post.is-new { animation: glow 2.4s ease-out 1; }

.post__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .78rem; color: var(--muted); }
.post__meta time { margin-left: auto; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.badge--gold { background: var(--gold-soft); color: var(--gold); }
.badge--rose { background: var(--rose-soft); color: var(--rose); }

.post__title { margin: 0 0 6px; font-family: var(--serif); font-size: 1.25rem; line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }
.post__body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.55; }
.post__body a { word-break: break-all; }

/* Fotos y videos subidos: pequeños dentro del post; al hacer clic se abren en grande */
.post__media { margin-top: 10px; display: grid; gap: 8px; }
.post__images { display: grid; gap: 6px; }
.post__images--1 { display: block; }
.post__images--multi { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.post__images img { cursor: zoom-in; border-radius: 10px; background: #000; transition: filter .15s; }
.post__images img:hover { filter: brightness(1.12); }
.post__images--1 img { display: block; max-width: 100%; max-height: 280px; width: auto; height: auto; }
.post__images--multi img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.post__video { width: 100%; max-height: 320px; border-radius: 10px; background: #000; display: block; }

.post__embeds { display: grid; gap: 10px; margin-top: 10px; }

/* Embeds */
.embed { position: relative; width: 100%; border-radius: 10px; overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed--video { aspect-ratio: 16 / 9; }
.embed--twitch { aspect-ratio: 16 / 9; min-height: 300px; }
.embed--vertical { aspect-ratio: 9 / 16; max-width: 270px; margin-inline: auto; }
.embed--tiktok { aspect-ratio: 325 / 740; max-width: 300px; margin-inline: auto; }
.embed--instagram { aspect-ratio: 4 / 5.6; max-width: 380px; margin-inline: auto; background: #fff; }
.embed--spotify { height: 152px; }
.embed--spotify-l { height: 352px; }
.embed-file video { width: 100%; border-radius: 10px; background: #000; display: block; max-height: 320px; }
.embed-file img { max-width: 100%; max-height: 280px; border-radius: 10px; background: #000; display: block; cursor: zoom-in; }
.embed-file audio { width: 100%; }

.link-card {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "host go" "url go";
  align-items: center; column-gap: 12px;
  padding: 9px 14px; border-radius: 10px; text-decoration: none;
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  transition: border-color .15s;
}
.link-card:hover { border-color: var(--gold); color: var(--text); }
.link-card__host { grid-area: host; color: var(--gold); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.link-card__url { grid-area: url; color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card__go { grid-area: go; font-size: 1.2rem; color: var(--gold); }

/* Enigmas */
.enigma {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  border: 1px dashed rgba(226, 80, 126, .55); background: var(--rose-soft);
}
.enigma--solved { border-style: solid; border-color: rgba(111, 211, 160, .5); background: rgba(111, 211, 160, .08); }
.enigma__label { margin: 0 0 8px; font-weight: 700; font-size: .9rem; letter-spacing: .02em; }
.enigma--solved .enigma__label { color: var(--ok); }
.enigma__hint { margin: 0 0 12px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.enigma__reward { white-space: pre-wrap; overflow-wrap: anywhere; }
.enigma__reward + .post__embeds { margin-top: 14px; }
.enigma__form { display: grid; gap: 10px; }
.enigma__form input {
  width: 100%; padding: .7rem .9rem; border-radius: 10px;
  border: 1px solid var(--line); background: #100d15; color: var(--text); font: inherit;
}
.enigma__form input::placeholder { color: #7d7289; }
.enigma__form input:focus { outline: none; border-color: var(--gold); }
.enigma__form .btn { justify-self: start; }
.enigma__msg { margin: 0; min-height: 1.4em; font-size: .92rem; color: var(--muted); }
.enigma__msg--bad { color: var(--bad); }
.shake { animation: shake .4s; }

/* Donaciones */
.donate {
  margin-top: 28px; padding: 20px; text-align: center;
  border-radius: var(--radius); border: 1px solid rgba(220, 184, 112, .4);
  background: linear-gradient(160deg, var(--gold-soft), transparent 70%), var(--card);
}
.donate h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.6rem; }
.donate p { margin: 0 auto 18px; max-width: 460px; color: var(--muted); }

.notice { text-align: center; color: var(--muted); padding: 30px 10px; font-family: var(--serif); font-style: italic; }
.notice--bad { color: var(--bad); font-style: normal; font-family: var(--sans); }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 10px 16px 40px; }

/* Imagen ampliada con zoom */
html.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(5, 4, 8, .97); }
.lightbox:focus { outline: none; }
.lightbox__stage {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: zoom-in;
}
.lightbox.is-zoomed .lightbox__stage { cursor: grab; }
.lightbox.is-dragging .lightbox__stage { cursor: grabbing; }
.lightbox__stage img {
  max-width: 100vw; max-height: 100vh; max-height: 100dvh; display: block;
  transform-origin: center center; will-change: transform;
  -webkit-user-drag: none; user-select: none; -webkit-user-select: none;
}
.lightbox--anim .lightbox__stage img { transition: transform .18s ease-out; }
.lightbox__bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px;
}
.lightbox__bar > * { pointer-events: auto; }
.lightbox__tools { display: flex; gap: 8px; margin-left: auto; }
.lightbox__count { padding: 6px 12px; border-radius: 999px; background: rgba(32, 26, 41, .85); border: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.lightbox__btn {
  min-width: 42px; height: 42px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(32, 26, 41, .88); color: var(--text);
  font: inherit; font-size: 1.25rem; font-weight: 600; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.lightbox__btn:hover { border-color: var(--gold); }
.lightbox__btn--text { font-size: .85rem; }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 46px; height: 46px; font-size: 1.6rem; padding: 0; }
.lightbox__nav--prev { left: 12px; }
.lightbox__nav--next { right: 12px; }
.lightbox__hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: .8rem; color: var(--text); text-shadow: 0 1px 6px #000; pointer-events: none; z-index: 2; animation: hintfade .5s ease 4s forwards; }
@keyframes hintfade { to { opacity: 0; } }

/* ===== Animaciones ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@keyframes glow {
  0% { box-shadow: 0 0 0 2px var(--gold), 0 0 40px rgba(220, 184, 112, .5); }
  100% { box-shadow: 0 14px 34px rgba(0, 0, 0, .35); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ===== Móvil ===== */
@media (max-width: 700px) {
  /* nombre largo del sitio: baja a su propia fila para no pisar el contador ni el botón */
  .topbar { grid-template-columns: auto 1fr; grid-template-areas: "left right" "brand brand"; row-gap: 6px; padding-block: 10px; }
  .topbar__left { grid-area: left; }
  .topbar__right { grid-area: right; }
  .brand { grid-area: brand; font-size: 1.3rem; min-width: 0; overflow-wrap: anywhere; }
}
@media (max-width: 520px) {
  .visit-counter__label { display: none; }
  .topbar { gap: 8px; }
  .wrap { padding-inline: 10px; }
  .post { padding: 12px 13px; }
  .post__meta time { margin-left: 0; width: 100%; }
  .lightbox__hint { display: none; }
}
