/* ==========================================================================
   site.css — componentes nuevos (cuentas, galería, admin) y arreglos de
   accesibilidad y móvil.
   Se carga DESPUÉS de style.css y respeta sus variables de color: la
   identidad visual del prado no cambia, sólo se completa.
   ========================================================================== */

/* ---------- Utilidades de accesibilidad ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Foco visible y consistente en todo lo interactivo.
   El original sólo lo tenía en .theme-toggle. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Enlaces del cuerpo del texto: que se distingan de verdad. */
.list-row .desc a,
.page-hero a,
main p a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.list-row .desc a:hover,
main p a:hover { color: var(--accent); }

/* ---------- Barra de navegación ---------- */
nav.wrap {
  gap: 12px;
  flex-wrap: nowrap;
  align-items: center;
}

.nav-links { flex: 1 1 auto; justify-content: center; }
.nav-links a.is-active { color: var(--text); }
.nav-links a.is-active::after { width: 100%; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-account {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.nav-account-link {
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  font: inherit;
  cursor: pointer;
}
.nav-account-link:hover {
  color: var(--accent-strong);
  border-color: var(--border);
  background: var(--surface);
}
.nav-account-cta {
  border-color: var(--border-strong);
  color: var(--accent-strong);
}
.nav-account-user { color: var(--text); font-weight: 600; }
.nav-account-admin { color: var(--accent-warm); }
.nav-avatar { border-radius: 50%; object-fit: cover; display: block; }

.btn-sm { padding: 9px 16px; font-size: 0.85rem; }

/* Menú móvil */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 42px; height: 42px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle-bar {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

@media (max-width: 900px) {
  nav.wrap { flex-wrap: wrap; height: auto; padding-top: 14px; padding-bottom: 14px; row-gap: 10px; }
  .nav-toggle { display: flex; order: 2; margin-left: auto; }
  .nav-actions { order: 3; }
  .nav-links {
    order: 4;
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--border);
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 10px 4px; font-size: 1rem; }
  .nav-links a::after { display: none; }
  .nav-actions .btn-sm { padding: 8px 12px; }
  .theme-toggle { width: 42px; height: 42px; margin-left: 0; }
}

/* ---------- Pie ---------- */
footer .footer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  color: var(--text);
}
.footer-brand strong { color: var(--accent-strong); font-weight: 600; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; }
.footer-links a { color: var(--text-dim); transition: color .2s ease; }
.footer-links a:hover, .footer-links a.is-active { color: var(--accent-strong); }
footer .footer-legal { margin-top: 0; border-top: 1px solid var(--border); }

/* ---------- Aviso de backend caído ---------- */
.offline-notice {
  margin: 0 0 24px;
  padding: 14px 18px;
  border: 1px solid var(--accent-warm);
  border-left-width: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-warm) 10%, var(--surface));
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* ---------- Formularios de cuenta ---------- */
.auth-shell {
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 0 60px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}
.auth-card h1 { font-size: 1.5rem; margin: 0 0 6px; }
.auth-card > p.lede { color: var(--text-dim); margin: 0 0 24px; font-size: 0.95rem; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--border-strong); }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { display: block; margin-top: 6px; font-size: 0.78rem; color: var(--text-dim); }
.field input[aria-invalid="true"] { border-color: #e04e4e; }

.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-alt { margin-top: 20px; text-align: center; font-size: 0.9rem; color: var(--text-dim); }
.auth-alt a { color: var(--accent-strong); }

.form-message {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
}
.form-message.error { border-color: #e04e4e; color: #ffb3b3; }
.form-message.success { border-color: var(--accent); color: var(--accent-strong); }
.form-message.info { border-color: var(--border-strong); }
[data-theme="light"] .form-message.error { color: #a01f1f; }
[data-theme="light"] .form-message.success { color: #2f5c1f; }

/* ---------- Tarjetas y paneles ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}
.panel > h2 { margin-top: 0; }
.panel-title {
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  font-size: 1.1rem;
  margin: 0 0 18px;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title::after { content: none; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.metric {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.metric .value {
  display: block;
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-strong);
  line-height: 1.1;
}
.metric .label {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Barra de cuota */
.quota { margin-top: 16px; }
.quota-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.quota-track {
  height: 8px;
  border-radius: 100px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}
.quota-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width .4s ease;
}
.quota-fill.is-high { background: linear-gradient(90deg, var(--accent-warm), #e04e4e); }

/* ---------- Galería ---------- */
.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.gallery-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.gallery-filters label { font-size: 0.82rem; color: var(--text-dim); }
.gallery-filters select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.gallery-grid { list-style: none; padding: 0; margin: 0; }
.gallery-grid > li { display: block; }

.gallery-figure { margin: 0; padding: 0; position: relative; }

.gallery-tile img { background: var(--surface-elevated); }
.gallery-tile .tile-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 12px;
  background: linear-gradient(180deg, transparent, rgba(15,18,16,0.94));
  transform: translateY(101%);
  transition: transform .3s ease;
  text-align: left;
  pointer-events: none;
}
.gallery-tile:hover .tile-overlay,
.gallery-tile:focus-within .tile-overlay { transform: translateY(0); }
.gallery-tile .tile-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-tile .tile-meta { display: block; font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

.tile-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .2s ease;
}
.gallery-tile:hover .tile-actions,
.gallery-tile:focus-within .tile-actions { opacity: 1; }
.tile-actions button {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(15,18,16,0.85);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.tile-actions button:hover { border-color: var(--accent); color: var(--accent-strong); }
.tile-actions button.is-liked { color: var(--accent-strong); border-color: var(--accent); }
.tile-actions button[data-action="delete"]:hover { border-color: #e04e4e; color: #ff9a9a; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.pagination button,
.pagination span {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-family: inherit;
}
.pagination button { cursor: pointer; }
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.pagination button:disabled { opacity: 0.45; cursor: not-allowed; }
.pagination .page-info { border: none; background: none; }

.skeleton {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-elevated) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- Subida ---------- */
.drop-zone { position: relative; }
.drop-zone:focus-within { border-color: var(--accent); }
.drop-zone.drag { border-color: var(--accent); background: rgba(138,171,92,0.08); }
.file-info {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.file-info img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ---------- Perfil ---------- */
.profile-header {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.profile-avatar {
  width: 88px; height: 88px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface-elevated);
  object-fit: cover;
  display: grid;
  place-items: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-strong);
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-meta h1 { margin: 0 0 4px; font-size: 1.6rem; }
.profile-meta .since { color: var(--text-dim); font-size: 0.85rem; }
.profile-meta .bio { margin: 8px 0 0; color: var(--text-dim); max-width: 60ch; }

/* ---------- Administración ---------- */
.admin-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.admin-toolbar input[type="search"] {
  flex: 1 1 220px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
table.data tbody tr:hover { background: var(--surface-elevated); }
table.data td.actions { white-space: nowrap; }
table.data td.actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 9px;
  font-size: 0.8rem;
  font-family: inherit;
  margin-right: 4px;
}
table.data td.actions button:hover { border-color: var(--accent); color: var(--accent-strong); }
table.data td.actions button.danger:hover { border-color: #e04e4e; color: #ff9a9a; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.tag.admin { border-color: var(--accent-warm); color: var(--accent-warm); }
.tag.banned { border-color: #e04e4e; color: #ff9a9a; }
.tag.ok { border-color: var(--accent); color: var(--accent-strong); }

/* ---------- Varios ---------- */
.section-plain { border-top: 1px solid var(--border); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.loading-text { color: var(--text-dim); font-size: 0.95rem; }

/* Corrige la fila de admin del original: dos columnas, no una. */
.admin-row { align-items: flex-start; }
.admin-row .avatar + div { min-width: 0; }

/* ==========================================================================
   Contraste en modo claro.
   El CSS original tenía fondos oscuros escritos a mano (rgba(26,32,28,…) y
   rgba(15,18,16,…)) pero colores de texto que SÍ cambian con el tema. En modo
   claro eso deja texto oscuro sobre fondo oscuro: las tres tarjetas de vista
   previa de la portada quedaban casi ilegibles. Se atan a las variables del
   tema, salvo donde el fondo es una foto y el color claro es lo correcto.
   ========================================================================== */
.hero-preview .preview-card {
  /* Longhand a propósito: con el atajo `background` el background-color queda
     en transparente y desaparece el color de respaldo del tema. */
  background-color: var(--surface);
  background-image: linear-gradient(135deg, var(--surface-elevated), var(--surface));
  border-color: var(--border);
}
.hero-preview .preview-msg { color: var(--text-dim); }
.hero-preview .preview-msg strong { color: var(--text); }

/* La capa que aparece encima de una foto es siempre oscura (para que se lea
   sobre cualquier imagen), así que aquí el texto va en claro fijo. */
.gallery-tile .tile-overlay { color: #edede7; }
.gallery-tile .tile-overlay .tile-title { color: #ffffff; }
.gallery-tile .tile-overlay .tile-meta { color: #c4cbc0; }
.gallery-tile .tile-overlay .tile-meta a { color: var(--accent-strong); text-decoration: none; }
.gallery-tile .tile-overlay .tile-meta a:hover { text-decoration: underline; }

/* Mismo caso en los botones de acción de cada ficha: fondo oscuro fijo. */
.tile-actions button { color: #edede7; }
.tile-actions button:hover { color: var(--accent-strong); }
.tile-actions button.is-liked { color: var(--accent-strong); }

@media (max-width: 560px) {
  .auth-card { padding: 22px; }
  .panel { padding: 18px; }
  .profile-header { gap: 16px; }
  .profile-avatar { width: 68px; height: 68px; font-size: 1.4rem; }
}
