/* ============================================================================
 * CodeFinder — Sistema de diseño premium
 * Tipografías: Sora (titulares) + Inter (texto). Paleta: navy profundo + naranja.
 * Mobile First.
 * ========================================================================== */

:root {
  --bg-0: #070b14;
  --bg-1: #0b1220;
  --bg-2: #0f1830;
  --surface: #121c30;
  --surface-2: #182440;
  --surface-3: #1f2e4a;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e8eef7;
  --muted: #93a3b8;
  --muted-2: #74859a;

  --accent: #f97316;
  --accent-2: #fbbf24;
  --accent-deep: #ea580c;
  --accent-grad: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  --accent-glow: rgba(249, 115, 22, 0.35);

  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;

  --radius: 16px;
  --radius-lg: 22px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 44px rgba(0, 0, 0, 0.42);
  --font-display: "Sora", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.6;
  background-color: var(--bg-1);
  background-image:
    radial-gradient(1000px 560px at 85% -8%, rgba(249, 115, 22, 0.13), transparent 60%),
    radial-gradient(900px 520px at -10% 20%, rgba(96, 165, 250, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(249, 115, 22, 0.35); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: #24324a; border-radius: 8px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: #33455f; }

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-2); }

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

/* ============================================================================
 * Header
 * ========================================================================== */
.cf-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 16, 28, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}

.cf-header .container,
.cf-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.cf-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.cf-brand:hover { color: var(--text); }
.cf-brand .brand-mark { flex: none; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.4)); }
.cf-brand .brand-accent {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.cf-lang-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.cf-lang-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2393a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cf-lang-select:hover { border-color: var(--border-strong); }
.cf-lang-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ============================================================================
 * Hero / buscador
 * ========================================================================== */
.hero {
  padding: 4rem 0 2.4rem;
  text-align: center;
  animation: fade-up 0.6s ease both;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.08);
  color: var(--accent-2);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.1rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 0.9rem;
}
.hero-title .accent {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-subtitle {
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  max-width: 660px;
  margin: 0 auto 2rem;
}

.search-wrap { position: relative; max-width: 660px; margin: 0 auto; }

.search-box {
  display: flex;
  gap: 0.5rem;
  background: rgba(18, 28, 48, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  box-shadow: var(--shadow-2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-box:focus-within {
  border-color: rgba(249, 115, 22, 0.55);
  box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-2);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.72rem 0.85rem;
  min-width: 0;
  text-transform: uppercase;
}
.search-input::placeholder {
  color: var(--muted-2);
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-body);
  font-weight: 400;
}

.search-btn {
  background: var(--accent-grad);
  color: #1a1206;
  border: none;
  border-radius: 14px;
  padding: 0.72rem 1.5rem;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.35);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.search-btn:hover { color: #1a1206; filter: brightness(1.05); box-shadow: 0 8px 24px rgba(249, 115, 22, 0.45); transform: translateY(-1px); }
.search-btn:active { transform: translateY(1px); }

/* ============================================================================
 * Sugerencias (autocompletado)
 * ========================================================================== */
.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(15, 24, 42, 0.98);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  max-height: 340px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  text-align: left;
  backdrop-filter: blur(8px);
}
.suggestions.open { display: block; animation: fade-up 0.18s ease both; }
.suggestions-title {
  padding: 0.6rem 0.9rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  border-bottom: 1px solid var(--border);
}
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem 0.95rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover,
.suggestion-item.active { background: var(--surface-2); }
.suggestion-code {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-2);
  min-width: 5rem;
  letter-spacing: 0.03em;
}
.suggestion-desc {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================================
 * Chips de códigos populares
 * ========================================================================== */
.popular { max-width: 680px; margin: 1.6rem auto 0; text-align: center; }
.popular-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  margin-bottom: 0.7rem;
}
.chip {
  display: inline-block;
  margin: 0.3rem;
  padding: 0.45rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}
.chip:hover {
  background: var(--accent);
  color: #1a1206;
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.35);
  transform: translateY(-1px);
}

/* ============================================================================
 * Resultados
 * ========================================================================== */
.results { margin: 1.8rem 0 2.5rem; }
.results-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.85rem;
}
.result-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.05rem 1.2rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.result-card:hover {
  background: var(--surface-2);
  border-color: rgba(249, 115, 22, 0.4);
  box-shadow: var(--shadow-1);
  transform: translateY(-2px);
}
.result-code {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent-2);
  min-width: 5.4rem;
}
.result-desc { color: var(--text); font-size: 0.98rem; }
.result-arrow { margin-left: auto; color: var(--muted-2); font-size: 1.3rem; }

/* ============================================================================
 * Detalle
 * ========================================================================== */
.detail-hero {
  position: relative;
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.9rem;
  margin: 2rem 0 1.3rem;
  overflow: hidden;
}
.detail-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-grad);
}
.detail-hero::after {
  content: "";
  position: absolute;
  top: -70px;
  right: -70px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.16), transparent 70%);
  pointer-events: none;
}
.detail-code {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.detail-desc { font-size: 1.18rem; color: var(--text); margin-top: 0.6rem; }

.badge-cat {
  display: inline-block;
  padding: 0.32rem 0.75rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.9rem;
}

.severity-row { margin-top: 0.9rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.severity-label { color: var(--muted); font-size: 0.9rem; }
.sev-badge {
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}
.sev-low { background: rgba(52, 211, 153, 0.14); color: var(--green); }
.sev-medium { background: rgba(251, 191, 36, 0.14); color: var(--amber); }
.sev-high { background: rgba(248, 113, 113, 0.15); color: var(--red); }

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.45rem;
  margin-bottom: 1.25rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.card-panel:hover { border-color: var(--border-strong); }
.card-panel h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.9rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.cause-list { margin: 0; padding-left: 1.25rem; }
.cause-list li { margin-bottom: 0.5rem; color: var(--text); }
.cause-list li::marker { color: var(--accent); }
.note { color: var(--muted); font-size: 0.85rem; margin-top: 0.85rem; }

/* ============================================================================
 * Video
 * ========================================================================== */
.video-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-list { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.95rem; }
.video-thumb {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.video-thumb:hover { border-color: rgba(249, 115, 22, 0.5); transform: translateX(2px); }
.video-thumb img { width: 104px; height: 58px; object-fit: cover; border-radius: 7px; background: #000; flex: none; }
.video-thumb .vt-title { font-size: 0.87rem; color: var(--text); font-weight: 500; }
.video-thumb .vt-channel { font-size: 0.76rem; color: var(--muted-2); }

/* ============================================================================
 * Anuncios
 * ========================================================================== */
.ad-slot { margin: 1.5rem auto; text-align: center; }
.ad-slot ins.adsbygoogle { display: block; }
.ad-side { min-width: 300px; min-height: 250px; }

/* ============================================================================
 * Pie
 * ========================================================================== */
.cf-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: rgba(8, 13, 23, 0.7);
  padding: 2rem 0 1.6rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.cf-footer p { margin: 0.25rem 0; }
.cf-footer-nav { margin-bottom: 0.9rem; }
.cf-footer-nav a {
  color: var(--muted);
  margin: 0 0.65rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}
.cf-footer-nav a:hover { color: var(--accent-2); }

/* ============================================================================
 * Páginas de contenido (guías, legal)
 * ========================================================================== */
.content-page { max-width: 840px; margin: 2.2rem auto 3rem; }
.content-page h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}
.content-page .lead { color: var(--muted); margin-bottom: 1.7rem; font-size: 1.05rem; }
.content-page h2 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 700;
  margin: 2rem 0 0.7rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.content-page h3 { font-size: 1.05rem; font-weight: 600; margin: 1.3rem 0 0.45rem; }
.content-page p { color: var(--text); line-height: 1.7; margin-bottom: 0.95rem; }
.content-page ul, .content-page ol { color: var(--text); line-height: 1.65; padding-left: 1.4rem; }
.content-page li { margin-bottom: 0.45rem; }
.content-page li::marker { color: var(--accent); }
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.7rem;
}
.toc a { display: block; padding: 0.28rem 0; color: var(--accent-2); font-weight: 500; }
.toc a:hover { color: var(--accent); }
.guide { margin-bottom: 1.7rem; }
.guide-tag {
  display: inline-block;
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-2);
  border-radius: 7px;
  padding: 0.18rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

/* ============================================================================
 * Utilidades / estados
 * ========================================================================== */
.loading { text-align: center; color: var(--muted); padding: 2.4rem 0; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 0.9rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; color: var(--muted); padding: 2.6rem 0; }
.empty-state .big { font-size: 3.2rem; margin-bottom: 0.7rem; }

.back-link {
  display: inline-block;
  margin: 1.1rem 0 0;
  font-weight: 600;
  color: var(--muted);
}
.back-link:hover { color: var(--accent-2); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
 * Responsive
 * ========================================================================== */
@media (min-width: 992px) {
  .detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 1.5rem;
    align-items: start;
  }
}

@media (max-width: 576px) {
  .hero { padding: 3rem 0 2rem; }
  .search-btn { padding: 0.72rem 1.05rem; }
  .suggestion-desc { max-width: 58vw; }
  .detail-code { font-size: 2.2rem; }
  .detail-hero { padding: 1.4rem; }
  .card-panel { padding: 1.2rem; }
  .video-thumb img { width: 84px; height: 47px; }
}

/* ============================================================================
 * Banner de cookies (RGPD)
 * ========================================================================== */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(10, 16, 28, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-strong);
  padding: 1rem 1.1rem;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  animation: fade-up 0.4s ease both;
}
.cookie-box {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: space-between;
}
.cookie-box p { margin: 0; color: var(--muted); font-size: 0.9rem; flex: 1; min-width: 220px; }
.cookie-btns { display: flex; gap: 0.6rem; }
.cookie-reject {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.cookie-reject:hover { border-color: var(--accent); color: var(--accent-2); }

/* Accesibilidad: reduce el movimiento si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
