/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #0f0d1a;
  --bg-2: #171425;
  --surface: #1f1b30;
  --surface-2: #2a2540;
  --border: #2f2b45;
  --text: #ececf6;
  --text-dim: #a29fc0;
  --accent: #ff4d8d;
  --accent-2: #7c5cff;
  --accent-glow: rgba(255, 77, 141, .35);
  --ok: #5ce7b1;
  --warn: #ffb86b;

  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Zen Kaku Gothic New', 'Inter', sans-serif;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .3);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .5);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(124, 92, 255, .18), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(255, 77, 141, .14), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100vh;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: none; transition: color .15s var(--ease-out); }
a:hover { color: var(--accent-2); }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; font-family: var(--display); }
h1 { font-size: clamp(2.2rem, 5vw + 1rem, 4rem); font-weight: 900; }
h2 { font-size: clamp(1.5rem, 2.5vw + 0.5rem, 2.2rem); font-weight: 700; margin: 0 0 1rem; }
h3 { font-size: 1.2rem; font-weight: 700; margin: 0 0 .5rem; }

::selection { background: var(--accent); color: white; }

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

/* =============================================================
   3. Utilities
   ============================================================= */
.wrap { width: min(1120px, 92%); margin-inline: auto; }
.narrow { max-width: 780px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--accent); color: white;
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  background: rgba(15, 13, 26, .75);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 0;
}
.logo {
  display: inline-flex; align-items: center; gap: .5rem;
  color: var(--text); font-weight: 700; font-size: 1.15rem;
}
.logo-mark {
  color: var(--accent); font-size: 1.4rem;
  text-shadow: 0 0 12px var(--accent-glow);
}
.logo-text { font-family: var(--display); letter-spacing: -0.02em; }
.site-nav { display: flex; gap: 1.4rem; }
.site-nav a { color: var(--text-dim); font-size: .95rem; }
.site-nav a:hover { color: var(--text); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.6rem 0;
  margin-top: 4rem;
  color: var(--text-dim);
  font-size: .9rem;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.footer-inner nav { display: flex; gap: 1rem; }
.footer-inner a { color: var(--text-dim); }
.footer-inner a:hover { color: var(--text); }

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding: 3rem 0 2rem; text-align: center; }
.hero h1 {
  background: linear-gradient(135deg, #ff4d8d 0%, #7c5cff 60%, #4ec3ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: .5rem;
}
.lead {
  color: var(--text-dim);
  font-size: clamp(1rem, 1vw + .8rem, 1.15rem);
  max-width: 640px; margin: 0 auto 2rem;
}

.tool-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  max-width: 820px; margin: 0 auto;
  text-align: left;
}

.search-form { margin-bottom: 1rem; }
.search-row {
  display: flex; gap: .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .35rem;
  transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.search-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.search-row input {
  flex: 1;
  background: transparent; border: 0; color: var(--text);
  font-size: 1.05rem; padding: .8rem 1rem;
  outline: none; min-width: 0;
}
.search-row input::placeholder { color: var(--text-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  padding: .8rem 1.4rem;
  border-radius: 10px;
  font-weight: 600; font-size: .95rem;
  transition: transform .1s var(--ease-out), background .2s var(--ease-out), box-shadow .2s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 10px 30px var(--accent-glow); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface); }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: white;
  border-radius: 50%;
  display: none;
  animation: spin .8s linear infinite;
}
.tool-card[data-state="loading"] .btn-spinner { display: inline-block; }
.tool-card[data-state="loading"] .btn-label { opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  color: var(--text-dim); font-size: .82rem;
  margin-top: .6rem; text-align: center;
}

.tool-status {
  min-height: 1.5rem;
  font-size: .95rem;
  color: var(--text-dim);
  text-align: center;
  padding: .5rem 0;
}
.tool-status.err { color: var(--warn); }

.privacy-badge {
  margin-top: 1.5rem;
  color: var(--text-dim);
  font-size: .88rem;
}

/* =============================================================
   6. Results grid
   ============================================================= */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.results:empty { display: none; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s var(--ease-out), border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
  display: flex; flex-direction: column;
  text-align: left;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.card-cover {
  aspect-ratio: 2/3;
  background: var(--surface-2);
  overflow: hidden;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: .7rem .8rem .9rem; }
.card-title {
  font-size: .95rem; font-weight: 600;
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: .25rem;
}
.card-meta {
  font-size: .78rem;
  color: var(--text-dim);
  display: flex; gap: .5rem; align-items: center;
}
.card-meta .dot { opacity: .5; }
.card-score {
  color: var(--warn);
  font-weight: 600;
}

/* =============================================================
   7. Detail modal
   ============================================================= */
dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: 100vw;
  max-height: 100vh;
}
dialog::backdrop {
  background: rgba(5, 3, 15, .75);
  backdrop-filter: blur(6px);
}
.detail-modal {
  width: min(920px, 96vw);
  max-height: 92vh;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
}
.detail-body {
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.5rem;
}
.detail-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.2rem;
  align-items: start;
  margin-bottom: 1.2rem;
}
@media (max-width: 640px) {
  .detail-hero { grid-template-columns: 1fr; }
  .detail-hero .detail-cover { max-width: 200px; margin: 0 auto; }
}
.detail-cover {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  aspect-ratio: 2/3;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-title {
  font-family: var(--display);
  font-size: clamp(1.4rem, 2.5vw + .5rem, 2rem);
  font-weight: 900;
  margin-bottom: .3rem;
}
.detail-subtitle {
  color: var(--text-dim);
  font-size: .95rem;
  margin-bottom: .8rem;
}
.detail-badges {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin-bottom: 1rem;
}
.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .2rem .7rem;
  font-size: .75rem;
  color: var(--text-dim);
}
.badge-accent { background: var(--accent); color: white; border-color: var(--accent); }
.badge-warn { background: rgba(255, 184, 107, .15); color: var(--warn); border-color: rgba(255, 184, 107, .3); }

.detail-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .8rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.fact { font-size: .88rem; }
.fact-label {
  display: block;
  color: var(--text-dim);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .15rem;
}
.fact-value { color: var(--text); font-weight: 500; }

.detail-section { margin-bottom: 1.5rem; }
.detail-section h3 {
  font-family: var(--display);
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: .4rem; margin-bottom: .7rem;
}
.detail-section p { color: var(--text-dim); }

.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .7rem;
}
.character {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.character-img { aspect-ratio: 1; background: var(--surface-2); overflow: hidden; }
.character-img img { width: 100%; height: 100%; object-fit: cover; }
.character-info { padding: .5rem .6rem; font-size: .82rem; }
.character-name { font-weight: 600; color: var(--text); }
.character-role { color: var(--text-dim); font-size: .75rem; }

.detail-actions {
  display: flex; flex-wrap: wrap; gap: .6rem;
  padding-top: .5rem;
}

.modal-close {
  position: absolute;
  top: .7rem; right: .8rem;
  z-index: 2;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.4rem; line-height: 1;
  border: 1px solid var(--border);
  transition: background .2s var(--ease-out);
}
.modal-close:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* =============================================================
   8. Sections + chips
   ============================================================= */
.section { padding: 2.5rem 0; }
.section p { color: var(--text-dim); margin-bottom: 1rem; }
.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 1rem 0 2rem;
}
.steps li {
  counter-increment: step;
  padding: .8rem 0 .8rem 3rem;
  position: relative;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}
.steps li:last-child { border-bottom: 1px solid var(--border); }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 2rem; height: 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: .95rem;
}
.steps li strong { color: var(--text); }

details {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
details summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text);
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '+';
  color: var(--accent); font-size: 1.5rem; line-height: 1;
  transition: transform .2s var(--ease-out);
}
details[open] summary::after { transform: rotate(45deg); }
details p { color: var(--text-dim); margin-top: .6rem; }

.chips {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-top: 1rem;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .5rem 1rem;
  font-size: .88rem;
  color: var(--text-dim);
  transition: all .2s var(--ease-out);
}
.chip:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* =============================================================
   9. Ads (placeholders)
   ============================================================= */
.ad-slot {
  position: relative;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .02);
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  margin: 2rem auto;
  overflow: hidden;
}
.ad-slot .ad-label {
  font-size: .7rem;
  letter-spacing: .2em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.ad-leaderboard { min-height: 90px; width: 100%; max-width: 728px; }
.ad-incontent { min-height: 250px; width: 100%; max-width: 336px; }
.ad-popup { min-height: 250px; width: 300px; margin: 1rem auto; }
.ad-corner { min-height: 100px; width: 100%; }

/* Pop-up download */
.ad-modal {
  width: min(360px, 92vw);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  text-align: center;
  position: relative;
}
.ad-modal-title {
  font-family: var(--display);
  font-size: 1.2rem;
  margin-bottom: .3rem;
  color: var(--text);
}
.ad-modal-sub {
  color: var(--text-dim);
  font-size: .9rem;
  margin-bottom: 1rem;
}
.ad-modal .btn { margin-top: 1rem; width: 100%; }

/* Corner notification */
.corner-ad {
  position: fixed;
  bottom: 1rem; right: 1rem;
  width: 300px; max-width: calc(100vw - 2rem);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem .8rem .8rem;
  z-index: 30;
  animation: slideUp .4s var(--ease-out);
}
.corner-ad .ad-slot { margin: 0; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.corner-close {
  position: absolute;
  top: 4px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 1.1rem; line-height: 1;
  background: transparent;
  transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.corner-close:hover { background: var(--surface-2); color: var(--text); }

/* =============================================================
   9.5. Collection rails (Top del año / Rankings)
   ============================================================= */
.section-collection { padding: 2.5rem 0 1.5rem; }
.section-head { max-width: 780px; margin: 0 auto 1.2rem; text-align: center; }
.section-head h2 { display: inline-flex; align-items: center; gap: .6rem; justify-content: center; }
.section-head p { color: var(--text-dim); margin-top: .3rem; }

.year-chip {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-family: var(--sans); font-size: 1rem; font-weight: 700;
  padding: .15rem .7rem; border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0;
}

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 1fr);
  gap: 1rem;
  overflow-x: auto;
  padding: .3rem .2rem 1rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.rail::-webkit-scrollbar { height: 8px; }
.rail::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 4px; }
.rail .card { scroll-snap-align: start; min-width: 0; }
.rail .card-cover { aspect-ratio: 2/3; }
.rail .rank-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.72);
  color: white;
  font-family: var(--display);
  font-weight: 900;
  font-size: .9rem;
  min-width: 26px; height: 26px;
  padding: 0 .45rem;
  border-radius: 8px;
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.2);
}
.rail .card { position: relative; }

@media (min-width: 720px) {
  .rail { grid-auto-columns: minmax(170px, 1fr); }
}
@media (min-width: 1024px) {
  .rail { grid-auto-columns: 1fr; grid-template-columns: repeat(5, 1fr); grid-auto-flow: row; overflow: visible; }
}

.rail-skeleton {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr);
  gap: 1rem;
}
.rail-skeleton span {
  display: block;
  aspect-ratio: 2/3;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.rail-empty {
  color: var(--text-dim);
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  grid-column: 1 / -1;
}

.genre-chips {
  display: flex; flex-wrap: wrap; gap: .5rem;
  justify-content: center;
  margin-bottom: 1.2rem;
}
.genre-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .5rem 1rem;
  font-size: .88rem;
  color: var(--text-dim);
  transition: all .18s var(--ease-out);
  cursor: pointer;
}
.genre-chip:hover {
  color: var(--text);
  border-color: var(--accent);
}
.genre-chip[aria-selected="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 18px var(--accent-glow);
}

/* =============================================================
   10. Reduced-motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .corner-ad { animation: none; }
  .rail-skeleton span { animation: none; }
  html { scroll-behavior: auto; }
}
