/* ===========================================================================
   RutaEnlaces — hoja de estilos publica
   Paleta y animaciones heredadas del prototipo, ajustadas a los colores
   institucionales de La Ruta 500+ (cian #12ABE3 / azul #00578D).
   =========================================================================== */

:root {
  --bg:            #FAF7F5;
  --surface:       #FFFFFF;
  --ink:           #17141F;
  --ink-2:         #3B3550;
  --ink-3:         #6C6880;
  --ink-4:         #8A8698;
  --ink-5:         #A5A1B0;
  --line:          rgba(23, 20, 31, .09);
  --line-strong:   rgba(23, 20, 31, .14);

  --ruta-cyan:     #12ABE3;
  --ruta-blue:     #00578D;
  --ruta-yellow:   #FFDB28;

  --brand:         linear-gradient(120deg, #12ABE3, #00578D);
  --brand-soft:    rgba(18, 171, 227, .12);

  /* Portadas de las tarjetas (un solo lugar para cambiarlas). */
  --grad-g1: linear-gradient(135deg, #4FC8F0, #12ABE3);
  --grad-g2: linear-gradient(135deg, #2A8FC4, #00578D);
  --grad-g3: linear-gradient(135deg, #62D2A6, #1F9D6B);
  --grad-g4: linear-gradient(135deg, #FFE874, #F2B417);
  --grad-g5: linear-gradient(135deg, #F3A38C, #DE6350);
  --grad-g6: linear-gradient(135deg, #A895EC, #6A4FC6);

  --ok:            #1F9D6B;
  --warn:          #C8891A;
  --danger:        #C7443C;

  --edg-green:     #0FD08A;
  --edg-green-dk:  #07B87A;

  --r-sm: 11px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;

  --shadow-1: 0 2px 10px rgba(23, 20, 31, .05);
  --shadow-2: 0 4px 18px rgba(23, 20, 31, .07);
  --shadow-3: 0 18px 40px rgba(23, 20, 31, .14);

  --ease-out:  cubic-bezier(.2, .9, .3, 1);
  --ease-back: cubic-bezier(.34, 1.4, .64, 1);

  --shell-max: 560px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* El atributo `hidden` debe ganarle a cualquier `display` que pongamos abajo
   (botones flex, modales grid, etc.). Sin esto, ocultar por JS no funciona. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ruta-blue); text-decoration: none; }

input, textarea, button, select { font: inherit; color: inherit; }
button { cursor: pointer; }

img { max-width: 100%; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- Fondo animado -------------------------------------------------------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.aurora__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(52px);
  will-change: transform;
}

.aurora__blob--a {
  top: -160px; left: -120px; width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(18, 171, 227, .40), transparent 70%);
  animation: floatA 16s ease-in-out infinite;
}

.aurora__blob--b {
  top: 24%; right: -140px; width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(0, 87, 141, .26), transparent 70%);
  animation: floatB 21s ease-in-out infinite;
}

.aurora__blob--c {
  bottom: -170px; left: 14%; width: 360px; height: 360px;
  background: radial-gradient(circle, rgba(255, 219, 40, .34), transparent 70%);
  animation: floatA 26s ease-in-out infinite reverse;
}

@keyframes floatA {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(44px, -62px, 0) scale(1.16); }
}

@keyframes floatB {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.1); }
  50%      { transform: translate3d(-52px, 54px, 0) scale(.9); }
}

/* --- Estructura ----------------------------------------------------------- */

.shell {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  max-width: var(--shell-max);
  min-height: 100dvh;
  padding-bottom: 132px;
}

.shell--message {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 132px;
}

/* --- Cabecera ------------------------------------------------------------- */

/* La cabecera se desplaza con la pagina: al hacer scroll solo queda fijo
   el buscador (.searchdock). */
.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 20px 4px;
  text-align: center;
}

.brand__logo {
  width: 96px;
  height: auto;
  display: block;
  animation: riseIn .6s var(--ease-out) both;
}

.brand__title {
  margin: 0;
  max-width: 22ch;
  font-family: "Space Grotesk", sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.01em;
  color: var(--ink);
  text-wrap: balance;
  animation: fadeIn .8s ease both .15s;
}

/* Barra fija: es lo unico que acompana al usuario mientras baja. */
.searchdock {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 12px 20px;
  background: rgba(250, 247, 245, .82);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  transition: background .25s, box-shadow .25s;
}

/* Cuando queda pegada arriba se despega visualmente del contenido. */
.searchdock.is-stuck {
  background: rgba(250, 247, 245, .94);
  box-shadow: 0 6px 22px rgba(23, 20, 31, .08);
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  transition: border-color .25s, box-shadow .25s;
}

.searchbar:focus-within {
  border-color: rgba(18, 171, 227, .65);
  box-shadow: 0 0 0 4px rgba(18, 171, 227, .12);
}

.searchbar__icon  { color: var(--ink-4); flex: 0 0 auto; }

.searchbar__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 15px;
}

.searchbar__input::-webkit-search-cancel-button { display: none; }

.searchbar__clear {
  border: 0; background: none; color: var(--ink-4);
  font-size: 20px; line-height: 1; padding: 0 2px;
}

.searchbar__clear:hover { color: var(--ink); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

/* Fila de filtros de la vista publica (la del panel usa .chips--wrap). */
.chips--filters { padding: 12px 20px 4px; }

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: transform .28s var(--ease-back), background .22s, color .22s, border-color .22s;
}

.chip:hover  { background: #F2FAFE; }
.chip:active { transform: scale(.93); }

.chip.is-active {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  transform: scale(1.04);
  box-shadow: 0 6px 16px rgba(0, 87, 141, .22);
}

.chip__count {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10.5px;
  opacity: .65;
}

/* --- Tarjetas ------------------------------------------------------------- */

.board {
  padding: 6px 20px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(23, 20, 31, .08);
  box-shadow: var(--shadow-2);
  animation: riseIn .55s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 62ms);
  transition: transform .28s var(--ease-back), border-color .28s, box-shadow .28s;
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-3);
}

.card:active { transform: scale(.985); }

.card.is-hidden { display: none; }

/* Toda la tarjeta es clicable, pero los botones quedan por encima. */
.card__hit {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card__cover {
  position: relative;
  height: 132px;
  background-size: cover;
  background-position: center;
}

.card__texture {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .15) 0 2px, transparent 2px 11px),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 45%, rgba(255, 255, 255, .3));
}

/* Las seis portadas. Se aplican tanto a la cabecera de una tarjeta
   (.cover-gN .card__cover) como a cualquier elemento que lleve la clase
   directamente: la miniatura del listado y las muestras del formulario. */
.cover-g1 .card__cover, .cover-g1.is-swatch { background-image: var(--grad-g1); }
.cover-g2 .card__cover, .cover-g2.is-swatch { background-image: var(--grad-g2); }
.cover-g3 .card__cover, .cover-g3.is-swatch { background-image: var(--grad-g3); }
.cover-g4 .card__cover, .cover-g4.is-swatch { background-image: var(--grad-g4); }
.cover-g5 .card__cover, .cover-g5.is-swatch { background-image: var(--grad-g5); }
.cover-g6 .card__cover, .cover-g6.is-swatch { background-image: var(--grad-g6); }

/* Con imagen propia no se pinta el degradado de fondo. */
.card__cover[style*="background-image"] .card__texture {
  background: linear-gradient(180deg, rgba(0, 0, 0, .12) 0%, rgba(0, 0, 0, 0) 45%, rgba(255, 255, 255, .22));
}

.card__tags {
  position: absolute;
  left: 13px; top: 13px;
  display: flex; gap: 6px; flex-wrap: wrap;
  max-width: calc(100% - 120px);
}

.tag {
  padding: 5px 10px;
  border-radius: 999px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag--cat { background: rgba(255, 255, 255, .92); color: var(--ink-2); }

.tag--new {
  background: var(--ink);
  color: #fff;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  animation: ring 2.4s ease-out infinite;
}

.countdown {
  position: absolute;
  right: 12px; top: 12px;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .93);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10.5px;
  white-space: nowrap;
  color: var(--ok);
}

.countdown__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.7s ease-in-out infinite;
}

.countdown.is-soon    { color: var(--warn); }
.countdown.is-urgent  { color: var(--danger); }
.countdown.is-expired { color: var(--danger); }

.countdown__track {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .45);
}

.countdown__bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ok);
  transition: width 1s linear, background .4s;
}

.countdown__bar.is-soon    { background: var(--warn); }
.countdown__bar.is-urgent  { background: var(--danger); }

.card__host {
  position: absolute;
  right: 13px; bottom: 11px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  color: rgba(23, 20, 31, .58);
  background: rgba(255, 255, 255, .72);
  padding: 3px 8px;
  border-radius: 999px;
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__body { padding: 14px 16px 16px; }

.card__title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.25;
}

.card__desc {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-3);
  text-wrap: pretty;
}

.card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .2s var(--ease-back), background .2s, box-shadow .2s, border-color .2s;
}

.btn:active { transform: scale(.94); }

.btn--primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 87, 141, .24);
}

.btn--primary:hover { box-shadow: 0 10px 24px rgba(0, 87, 141, .3); }

.btn--ghost {
  background: #F3F8FB;
  border-color: var(--line-strong);
  color: var(--ink-2);
  font-weight: 500;
}

.btn--ghost:hover { background: #E7F3F9; }

.card__open {
  flex: 1;
  pointer-events: none;   /* el clic lo captura .card__hit */
}

.card__copy { position: relative; z-index: 2; }

/* --- Vacio, pie y FAB ----------------------------------------------------- */

.empty {
  text-align: center;
  padding: 56px 20px 8px;
  animation: popIn .4s ease both;
  grid-column: 1 / -1;
}

.empty__mark {
  font-size: 34px;
  opacity: .4;
  display: inline-block;
  animation: spinSlow 8s linear infinite;
}

.empty__text { margin: 12px 0 4px; color: var(--ink-3); font-size: 14px; }
.empty__hint { margin: 0 0 14px; color: var(--ink-5); font-size: 12.5px; }

.footnote {
  text-align: center;
  padding: 34px 20px 0;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--ink-5);
}

.fab {
  position: fixed;
  right: 18px;
  bottom: 104px;
  z-index: 30;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  color: var(--ink-2);
  box-shadow: var(--shadow-2);
  animation: popIn .3s var(--ease-back) both;
  transition: transform .25s var(--ease-back), background .2s;
}

.fab:hover  { background: #fff; transform: translateY(-3px); }
.fab:active { transform: scale(.9); }

/* --- Tarjeta de mensaje --------------------------------------------------- */

.message-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 36px 28px;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  animation: popIn .45s var(--ease-out) both;
}

.message-card__code {
  font-family: "Space Grotesk", sans-serif;
  font-size: 54px;
  font-weight: 700;
  letter-spacing: -.04em;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}

.message-card__mark { font-size: 40px; }

.message-card__title {
  margin: 14px 0 6px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 21px;
  letter-spacing: -.02em;
}

.message-card__text { margin: 0 0 22px; color: var(--ink-3); font-size: 14px; line-height: 1.55; }

/* --- Toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 104px;
  z-index: 80;
  transform: translate(-50%, 24px) scale(.92);
  padding: 12px 20px;
  border-radius: var(--r-lg);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 16px 40px rgba(23, 20, 31, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s, transform .32s var(--ease-back);
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.is-error { background: var(--danger); }

/* ===========================================================================
   Badge flotante "Con tecnologia inteligente de edgfast"
   =========================================================================== */

.edg-badge {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 70;
  transform: translateX(-50%);
  display: block;
  /* Con `left: 50%` el ancho disponible seria solo media pantalla y el
     contenido se recortaria. `max-content` lo dimensiona por su contenido
     real; el `max-width` evita que se salga en pantallas muy angostas. */
  width: max-content;
  max-width: calc(100vw - 24px);
  border-radius: 999px;
  isolation: isolate;
  animation: badgeIn .7s var(--ease-back) both .5s, badgeFloat 5.5s ease-in-out infinite 1.2s;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.edg-badge__inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 15px 0 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(255, 255, 255, .75);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow:
    0 8px 26px rgba(23, 20, 31, .13),
    inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden;
  transition: transform .32s var(--ease-back), box-shadow .3s, background .3s;
}

/* Halo verde que late detras del badge para llamar la atencion. */
.edg-badge__glow {
  position: absolute;
  inset: -7px;
  z-index: 1;
  border-radius: 999px;
  background: radial-gradient(60% 120% at 50% 50%, rgba(15, 208, 138, .55), rgba(15, 208, 138, 0) 72%);
  filter: blur(9px);
  opacity: .75;
  animation: badgePulse 3.4s ease-in-out infinite;
  pointer-events: none;
}

/* Brillo que recorre el badge de izquierda a derecha. */
.edg-badge__sheen {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
}

.edg-badge__sheen::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .85), transparent);
  transform: skewX(-18deg);
  animation: badgeSheen 4.2s ease-in-out infinite;
}

.edg-badge__spark {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--edg-green), var(--edg-green-dk));
  color: #fff;
  box-shadow: 0 3px 10px rgba(15, 208, 138, .45);
  animation: sparkSpin 6s ease-in-out infinite;
}

.edg-badge__text {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .005em;
  color: var(--ink-2);
  white-space: nowrap;
}

.edg-badge__logo {
  height: 20px;
  width: auto;
  display: block;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(7, 184, 122, .28));
}

.edg-badge__arrow {
  display: grid;
  place-items: center;
  color: var(--edg-green-dk);
  opacity: .8;
  transition: transform .3s var(--ease-back), opacity .3s;
}

.edg-badge:hover .edg-badge__inner {
  transform: translateY(-3px) scale(1.035);
  background: rgba(255, 255, 255, .78);
  box-shadow:
    0 14px 34px rgba(7, 184, 122, .26),
    inset 0 1px 0 rgba(255, 255, 255, .95);
}

.edg-badge:hover .edg-badge__arrow { transform: translate(2px, -2px); opacity: 1; }
.edg-badge:active .edg-badge__inner { transform: translateY(-1px) scale(.97); }

.edg-badge:focus-visible .edg-badge__inner {
  outline: 2px solid var(--edg-green-dk);
  outline-offset: 3px;
}

@keyframes badgeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(26px) scale(.86); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes badgeFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-5px); }
}

@keyframes badgePulse {
  0%, 100% { opacity: .45; transform: scale(.94); }
  50%      { opacity: .95; transform: scale(1.06); }
}

@keyframes badgeSheen {
  0%       { left: -60%; }
  55%, 100% { left: 130%; }
}

@keyframes sparkSpin {
  0%, 100% { transform: rotate(0deg)   scale(1); }
  25%      { transform: rotate(-12deg) scale(1.12); }
  60%      { transform: rotate(10deg)  scale(.96); }
}

/* --- Animaciones compartidas ---------------------------------------------- */

@keyframes riseIn {
  from { opacity: 0; transform: translateY(24px) scale(.965); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes popIn {
  from { opacity: 0; transform: scale(.92) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes ring {
  0%   { box-shadow: 0 0 0 0 rgba(23, 20, 31, .35); }
  100% { box-shadow: 0 0 0 14px rgba(23, 20, 31, 0); }
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

@keyframes spinSlow { to { transform: rotate(360deg); } }

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

@media (min-width: 900px) {
  :root { --shell-max: 1080px; }
  .board { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .brand__logo  { width: 112px; }
  .brand__title { font-size: 16px; max-width: none; }
}

/* En pantallas angostas el badge se aprieta antes de renunciar al texto:
   el mensaje completo es lo que le da sentido. */
@media (max-width: 420px) {
  .edg-badge__inner { height: 38px; gap: 6px; padding: 0 12px 0 10px; }
  .edg-badge__text  { font-size: 10.5px; }
  .edg-badge__logo  { height: 17px; }
  .edg-badge__spark { width: 19px; height: 19px; }
}

@media (max-width: 330px) {
  .edg-badge__text { display: none; }
}

/* --- Accesibilidad: respetar "reducir movimiento" ------------------------- */

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