/* styles.css — Reset, layout global, topbar, sidebar, búsqueda, grid */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }
button { font: inherit; cursor: pointer; }

img { max-width: 100%; height: auto; display: block; }

/* — Banner uso personal — */
#disclaimer-banner[hidden] { display: none; }
#disclaimer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--warn-bg);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
#disclaimer-banner button {
  background: transparent;
  border: 0;
  font-size: 20px;
  line-height: 1;
  padding: 0 var(--space-2);
  color: var(--ink-soft);
}
#disclaimer-banner button:hover { color: var(--ink); }

/* — Topbar — */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  height: var(--topbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #C8102E 0%, #E94E1B 100%);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-text small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-mute);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--r-md);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }

#toggle-sidebar { display: none; }

.search {
  flex: 1;
  max-width: 520px;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 0 var(--space-3);
  height: 38px;
  color: var(--ink-mute);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--c-D);
  box-shadow: 0 0 0 4px rgba(230, 48, 39, 0.12);
  color: var(--ink);
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  color: var(--ink);
  padding: 0 var(--space-2);
}
.search input::placeholder { color: var(--ink-mute); }
.search kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-mute);
}

.topnav {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.topnav a {
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink-soft);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
  transition: background .12s, color .12s;
}
.topnav a:hover { background: var(--bg-soft); color: var(--ink); }
.topnav a.active { background: var(--bg-sunken); color: var(--ink); }

/* — Layout principal — */
.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: var(--space-4) var(--space-3);
}

.sidebar-nav {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.sidebar-nav a {
  display: block;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-radius: var(--r-md);
}
.sidebar-nav a:hover { background: var(--bg-soft); color: var(--ink); }

.alpha-index {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-1);
}
.alpha-index li a {
  display: block;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  padding: 6px 0;
  border-radius: var(--r-sm);
  background: var(--c-A);
  transition: transform .12s ease, filter .12s ease;
}
.alpha-index li a:hover { transform: translateY(-1px); filter: brightness(1.08); }
.alpha-index li.disabled a {
  background: var(--bg-sunken);
  color: var(--ink-mute);
  pointer-events: none;
  filter: grayscale(1) opacity(.7);
}

.sidebar-recents {
  margin-top: var(--space-6);
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
}
.sidebar-recents summary {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-mute);
  cursor: pointer;
  list-style: none;
}
.sidebar-recents summary::-webkit-details-marker { display: none; }
.sidebar-recents summary::after { content: "▾"; float: right; }
.sidebar-recents[open] summary::after { content: "▴"; }
.sidebar-recents ol {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-recents a {
  display: block;
  text-decoration: none;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 4px 6px;
  border-radius: var(--r-sm);
}
.sidebar-recents a:hover { background: var(--bg-soft); color: var(--ink); }

/* — Vista principal — */
.view {
  padding: var(--space-6) var(--space-6) var(--space-10);
  outline: none;
  min-width: 0;
}
.view h1 {
  font-size: 26px;
  margin: 0 0 var(--space-4);
  letter-spacing: -0.01em;
}
.view .crumbs {
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: var(--space-4);
}
.view .crumbs a { color: var(--ink-mute); text-decoration: none; }
.view .crumbs a:hover { color: var(--ink); }

/* — Filtros chip — */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] {
  background: var(--c-D);
  border-color: var(--c-D);
  color: #fff;
}
.chip svg { width: 14px; height: 14px; }

/* — Grid de fichas — */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
  gap: var(--space-5);
}

.results-meta {
  font-size: 13px;
  color: var(--ink-mute);
  margin: 0 0 var(--space-4);
}

/* Empty state */
.empty {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--ink-mute);
}
.empty h2 { color: var(--ink-soft); margin: 0 0 var(--space-3); font-size: 18px; }

/* Loader */
#loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink-mute);
  z-index: 100;
  transition: opacity .25s;
}
#loader.fade { opacity: 0; pointer-events: none; }

/* — Responsive — */
@media (max-width: 960px) {
  .topnav a:not(.active) span { display: none; }
}

@media (max-width: 800px) {
  #toggle-sidebar { display: inline-flex; }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 40;
    box-shadow: var(--shadow-2);
  }
  .sidebar.open { transform: translateX(0); }
  .view { padding: var(--space-4); }
  .grid { grid-template-columns: 1fr; }
  .brand-text { display: none; }
}

@media (max-width: 540px) {
  .topbar {
    padding: 0 var(--space-2);
    gap: var(--space-2);
  }
  .topnav a { padding: var(--space-1) var(--space-2); font-size: 13px; }
  .search { height: 36px; max-width: none; min-width: 0; }
  .search kbd { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-mark::after { font-size: 20px; }
  #disclaimer-banner { padding: var(--space-2); font-size: 12px; }
}

@media (max-width: 420px) {
  .view { padding: var(--space-3) var(--space-2) var(--space-6); }
  .view h1 { font-size: 20px; }
  .grid { gap: var(--space-3); }
  .brand { display: none; }
  .topnav { display: none; }
  .sidebar-nav { display: flex; }
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-2);
  }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; font-size: 12px; padding: 5px 10px; }
}
