/* ==========================================================================
   ARTIF1QO — hoja de estilos
   Paleta clara por defecto, oscura con [data-theme="dark"].
   ========================================================================== */

:root {
  --bg: #faf9f6;
  --bg-soft: #f2f0eb;
  --surface: #ffffff;
  --surface-2: #f7f6f2;
  --border: #e3e0d8;
  --border-strong: #cdc9be;
  --text: #14161a;
  --text-soft: #55595f;
  --text-mute: #85898f;
  --accent: #0e7c5a;
  --accent-ink: #0a5a42;
  --alta: #0e7c5a;
  --media: #b8791a;
  --baja: #6b7280;
  --tesis: #5b57d1;
  --danger: #b4232c;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 8px 24px -12px rgba(20, 22, 26, .18);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0d0f13;
  --bg-soft: #12151a;
  --surface: #15181e;
  --surface-2: #1a1e25;
  --border: #262b34;
  --border-strong: #363d49;
  --text: #e9ebef;
  --text-soft: #a5acb8;
  --text-mute: #767e8c;
  --accent: #2fbf8f;
  --accent-ink: #6fe0bb;
  --alta: #2fbf8f;
  --media: #e0a33a;
  --baja: #8b93a1;
  --tesis: #8b87f0;
  --danger: #f2666f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .8);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- Barra superior ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .06em;
}

.brand-mark em {
  font-style: normal;
  color: var(--accent);
}

.brand-sub {
  font-size: 12.5px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topnav a {
  font-size: 14px;
  color: var(--text-soft);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}

.topnav a:hover { color: var(--text); background: var(--bg-soft); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-soft);
  transition: background .15s, color .15s, border-color .15s;
}

.icon-btn:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }

/* ---------- Hero y buscador ---------- */

.hero { padding: 56px 0 8px; }

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(30px, 5.2vw, 46px);
  line-height: 1.12;
  letter-spacing: -.015em;
  margin: 0 0 14px;
}

.hero-title em {
  font-style: italic;
  color: var(--accent);
}

.hero-sub {
  max-width: 640px;
  color: var(--text-soft);
  font-size: 16.5px;
  margin: 0 0 30px;
}

.hero-sub strong { color: var(--text); font-weight: 600; }

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow);
}

.search-icon { color: var(--text-mute); flex: none; }

#q {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16.5px;
  padding: 12px 0;
}

#q::placeholder { color: var(--text-mute); }
#q::-webkit-search-cancel-button { cursor: pointer; }

.btn-primary {
  flex: none;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 11px 20px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn-primary:hover { background: var(--accent-ink); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: progress; }

/* ---------- Chips de nivel ---------- */

.tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.tier-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}

.tier-chip small { color: var(--text-mute); font-size: 11.5px; }

.tier-chip:hover { border-color: var(--border-strong); color: var(--text); }

.tier-chip.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 500;
}

.tier-chip.is-active small { color: color-mix(in srgb, var(--bg) 70%, transparent); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.dot-all { background: linear-gradient(135deg, var(--alta), var(--media), var(--tesis)); }
.dot-alta { background: var(--alta); }
.dot-media { background: var(--media); }
.dot-baja { background: var(--baja); }
.dot-tesis { background: var(--tesis); }

.tier-chip.is-active .dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg) 55%, transparent); }

/* ---------- Controles ---------- */

#controls-bar { margin-top: 26px; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
}

.ctl select,
.ctl input[type="number"] {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13.5px;
}

.ctl input[type="number"] { width: 78px; }

.ctl-check { cursor: pointer; user-select: none; }

.ctl input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Resultados ---------- */

#results-section { margin-top: 24px; padding-bottom: 40px; }

.status {
  font-size: 14px;
  color: var(--text-mute);
  min-height: 22px;
}

.status.is-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: 10px;
  padding: 12px 14px;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 18px;
  font-size: 13px;
  color: var(--text-soft);
  align-items: center;
}

.summary .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

.results { display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tier-color, transparent);
}

.card[data-tier="alta"] { --tier-color: var(--alta); }
.card[data-tier="media"] { --tier-color: var(--media); }
.card[data-tier="baja"] { --tier-color: var(--baja); }
.card[data-tier="tesis"] { --tier-color: var(--tesis); }

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-alta { background: color-mix(in srgb, var(--alta) 14%, transparent); color: var(--alta); }
.badge-media { background: color-mix(in srgb, var(--media) 16%, transparent); color: var(--media); }
.badge-baja { background: color-mix(in srgb, var(--baja) 15%, transparent); color: var(--baja); }
.badge-tesis { background: color-mix(in srgb, var(--tesis) 15%, transparent); color: var(--tesis); }

.badge-soft {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-size: 11.5px;
  color: var(--text-mute);
  border: 1px solid var(--border);
  background: transparent;
}

.score {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  white-space: nowrap;
}

.score b { color: var(--text); font-weight: 700; }

.card h3 {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.32;
  font-weight: 600;
  margin: 0 0 9px;
  letter-spacing: -.005em;
}

.card h3 a { text-decoration: none; }
.card h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.meta {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--text-soft);
}

.meta .sep { color: var(--text-mute); margin: 0 6px; }
.meta .venue { color: var(--text); font-weight: 500; }
.meta .oa { color: var(--accent); font-weight: 500; }

.abstract {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.abstract.is-open { -webkit-line-clamp: unset; line-clamp: unset; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--text-soft);
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
}

.link-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg-soft);
}

.link-btn.primary {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

.link-btn.primary:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: var(--accent); }

.more-wrap { display: flex; justify-content: center; margin-top: 22px; }

.btn-ghost {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.btn-ghost:hover { background: var(--bg-soft); }
.btn-ghost:disabled { opacity: .5; cursor: progress; }

/* Esqueletos de carga */
.skeleton {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.sk-line {
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  margin-bottom: 10px;
}

.sk-line.w40 { width: 40%; }
.sk-line.w70 { width: 70%; }
.sk-line.w90 { width: 90%; }
.sk-line.h18 { height: 18px; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Estado vacío */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-soft);
}

.empty h3 {
  font-family: var(--serif);
  font-size: 21px;
  margin: 0 0 8px;
  color: var(--text);
}

.empty p { margin: 0 auto 18px; max-width: 440px; font-size: 14.5px; }

.empty .suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ---------- Sección método ---------- */

.metodo {
  padding: 56px 24px 40px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.metodo h2 {
  font-family: var(--serif);
  font-size: clamp(23px, 3.4vw, 30px);
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0 0 10px;
}

.metodo-intro {
  color: var(--text-soft);
  max-width: 620px;
  margin: 0 0 26px;
  font-size: 15.5px;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.tier-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin: 0 0 8px;
  font-weight: 600;
}

.tier-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.55;
}

.tc-alta { border-top: 2px solid var(--alta); }
.tc-media { border-top: 2px solid var(--media); }
.tc-baja { border-top: 2px solid var(--baja); }
.tc-tesis { border-top: 2px solid var(--tesis); }

.metodo-more {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 4px 18px;
}

.metodo-more summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 500;
}

.metodo-more ul {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.65;
}

.metodo-more li { margin-bottom: 6px; }

code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  margin-top: 20px;
}

.footer-inner p { margin: 0 0 6px; font-size: 13px; color: var(--text-soft); }
.footer-inner .muted { color: var(--text-mute); font-size: 12.5px; }

/* ---------- Utilidades ---------- */

[hidden] { display: none !important; }

.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;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .hero { padding-top: 34px; }
  .brand-sub { display: none; }
  .search { flex-wrap: wrap; padding: 8px 10px; }
  .search-icon { display: none; }
  #q { flex-basis: 100%; padding: 10px 4px; font-size: 16px; }
  .btn-primary { width: 100%; }
  .card { padding: 16px 16px 14px; }
  .card h3 { font-size: 17.5px; }
  .score { font-size: 11px; }
  .metodo { padding: 40px 16px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- Impresión ---------- */

@media print {
  .topbar, .tiers, #controls-bar, .card-actions, .more-wrap, .footer { display: none !important; }
  .card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  .abstract { -webkit-line-clamp: unset; line-clamp: unset; }
}
