:root {
  --green-light:  #EAF3DE;
  --green-mid:    #3B6D11;
  --green-dark:   #27500A;
  --green-border: #97C459;
  --green-hero1:  #0d2408;
  --green-hero2:  #1e4d0a;
  --green-hero3:  #3B6D11;
  --blue-light:   #E6F1FB;
  --blue-mid:     #185FA5;
  --blue-dark:    #0C447C;
  --text:         #1a1a1a;
  --text-sec:     #555;
  --text-ter:     #999;
  --border:       #e5e5e5;
  --border-sec:   #d9d9d9;
  --border-ter:   #f0f0f0;
  --bg-sec:       #f8f8f8;
  --activa-bg:    #EAF3DE; --activa-text:   #27500A;
  --aplazada-bg:  #FEF3E2; --aplazada-text: #92400E;
  --cancel-bg:    #FEE2E2; --cancel-text:   #991B1B;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
  color: var(--text);
  background: #fff;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── Hero ── */
.site-hero {
  background: linear-gradient(175deg, var(--green-hero1) 0%, var(--green-hero2) 45%, var(--green-hero3) 100%);
  position: relative;
  overflow: hidden;
  padding: 36px 20px 60px;
}
.site-hero.has-image {
  background-size: cover;
  background-position: center;
}
.site-hero.has-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(175deg, rgba(13,36,8,0.78) 0%, rgba(30,77,10,0.62) 100%);
  z-index: 1;
}
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  transition: opacity 1.5s ease-in-out;
}
.hero-video.fade-out {
  opacity: 0;
}
.hero-content { position: relative; z-index: 2; }

.site-logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-block;
}
.logo-trail    { color: #fff; }
.logo-asturias { color: #a8d96a; }
.logo-asturias2{ color: #97C459; }
.logo-tld      { color: rgba(255,255,255,0.45); font-weight: 400; font-size: 20px; }

.hero-tagline {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  margin-top: 7px;
}
.hero-mountains {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 160px;
  pointer-events: none;
}

@media (min-width: 640px) {
  .site-hero    { padding: 60px 28px 80px; }
  .site-logo    { font-size: 34px; }
  .logo-tld     { font-size: 28px; }
  .hero-tagline { font-size: 16px; margin-top: 10px; }
}
@media (min-width: 960px) {
  .site-hero    { padding: 120px 40px 140px; }
  .site-logo    { font-size: 52px; }
  .logo-tld     { font-size: 40px; }
  .hero-tagline { font-size: 20px; margin-top: 16px; }
}

/* ── Próxima carrera bar ── */
#proxima-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--green-light);
  border-bottom: 1px solid var(--green-border);
  padding: 10px 16px;
  font-size: 13px;
  min-height: 42px;
}
.proxima-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.proxima-dot   { color: var(--green-mid); font-size: 20px; flex-shrink: 0; line-height: 1; }
.proxima-label { color: var(--green-mid); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0; }
.proxima-name  { font-weight: 600; color: var(--green-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proxima-date  { color: var(--green-mid); flex-shrink: 0; white-space: nowrap; font-weight: 500; }
.proxima-count {
  font-size: 11px; color: var(--green-mid); font-weight: 700;
  flex-shrink: 0; white-space: nowrap;
  background: rgba(59,109,17,0.13);
  padding: 3px 9px; border-radius: 20px;
}

/* ── Layout ── */
.page-outer { max-width: 1200px; margin: 0 auto; }
.page-layout { display: flex; align-items: flex-start; }
.main-col { flex: 1; min-width: 0; max-width: 760px; }
.sidebar  { display: none; }

@media (min-width: 960px) {
  .page-layout { gap: 40px; padding: 0 32px; }
  .sidebar {
    display: block;
    width: 320px;
    flex-shrink: 0;
  }
  .sidebar-sticky { position: sticky; top: 16px; padding-top: 16px; }
  
  /* Filtros wrap en escritorio */
  .filtros-row { flex-wrap: wrap; }
}

/* ── Sidebar Widgets ── */
.sidebar-widget {
  background: #fdfdfd;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.widget-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.widget-title::before {
  content: '';
  display: block;
  width: 8px; height: 8px;
  background: var(--activa-bg);
  border-radius: 50%;
}
.widget-item {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-ter);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s;
}
.widget-item:last-child { border-bottom: none; padding-bottom: 0; }
a.widget-item:hover { opacity: 0.7; }
.widget-item-date { font-size: 11px; color: var(--green-mid); font-weight: 700; margin-bottom: 2px; }
.widget-item-name { font-size: 13px; font-weight: 600; line-height: 1.35; margin-bottom: 4px; }
.widget-item-lugar { font-size: 11px; color: var(--text-sec); }

/* ── Filtros + Búsqueda sticky ── */
.filtros-wrapper {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Búsqueda */
.search-row { padding: 10px 16px; }
.search-input-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 11px;
  width: 16px; height: 16px;
  color: var(--text-ter); pointer-events: none;
}
#buscador {
  width: 100%;
  padding: 9px 36px 9px 34px;
  border: 1px solid var(--border-sec);
  border-radius: 8px;
  font-size: 16px; /* ≥16px evita el auto-zoom de iOS Safari al hacer foco */
  color: var(--text);
  background: var(--bg-sec);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
@media (min-width: 640px) {
  #buscador { font-size: 14px; }
}
#buscador::placeholder { color: var(--text-ter); }
#buscador:focus {
  border-color: var(--green-mid);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,109,17,0.1);
}
.search-clear {
  position: absolute; right: 8px;
  background: var(--border-sec); border: none;
  border-radius: 50%; width: 20px; height: 20px;
  font-size: 10px; color: var(--text-sec);
  cursor: pointer; display: none;
  align-items: center; justify-content: center;
  line-height: 1; padding: 0; transition: background 0.1s;
}
.search-clear.visible { display: flex; }
.search-clear:hover { background: var(--border); }

/* Pills */
.filtros-sep { height: 1px; background: var(--border-ter); margin: 0 16px; }
.filtros-row {
  padding: 8px 16px;
  display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  align-items: center;
}
#filtros-mes {
  flex-wrap: wrap;
}
.filtros-row::-webkit-scrollbar { display: none; }
.pills-group { display: flex; gap: 6px; }
.filtros-spacer { flex-grow: 1; min-width: 16px; }


.pill {
  border-radius: 20px; padding: 5px 13px;
  font-size: 12px; font-weight: 400;
  border: 1px solid var(--border-sec);
  background: #fff; color: var(--text-sec);
  cursor: pointer; white-space: nowrap;
  flex-shrink: 0; line-height: 1.4;
  transition: border-color 0.1s, background 0.1s, color 0.1s;
}
.pill:hover { border-color: #aaa; color: var(--text); }
.pill.active {
  background: var(--green-light);
  border-color: var(--green-mid);
  color: var(--green-dark);
  font-weight: 600;
}

/* Contador */
.results-count {
  padding: 7px 16px;
  font-size: 11px; color: var(--text-ter);
  border-bottom: 1px solid var(--border-ter);
  min-height: 30px; display: flex; align-items: center;
}
.results-count strong { color: var(--text-sec); font-weight: 600; }

/* ── Mes header ── */
.mes-header {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-ter);
  padding: 20px 16px 8px;
}

/* ── Carrera row ── */
a.carrera-row,
div.carrera-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-ter);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease, background 0.1s ease;
  position: relative;
}
a.carrera-row { cursor: pointer; }
div.carrera-row { cursor: default; }
a.carrera-row:hover { background: var(--bg-sec); }
a.carrera-row:hover .carrera-chevron { opacity: 0.7; }

@media (min-width: 960px) {
  a.carrera-row { border-radius: 8px; margin: 0 4px; padding: 12px; }
  div.carrera-row { border-radius: 8px; margin: 0 4px; padding: 12px; }
  a.carrera-row:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 12px 24px rgba(0,0,0,0.08);
    background: #fff;
    border-bottom-color: transparent;
    z-index: 2;
  }
}

.carrera-fecha {
  min-width: 38px; text-align: center;
  flex-shrink: 0; padding-top: 2px;
  align-self: flex-start;
}
.carrera-dia {
  font-size: 22px; font-weight: 700;
  line-height: 1; color: var(--text);
}
.carrera-mes-abr {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; color: var(--text-ter);
  letter-spacing: 0.04em; margin-top: 2px;
}

.carrera-info { flex: 1; min-width: 0; }
.carrera-nombre { font-size: 14px; font-weight: 600; line-height: 1.35; }
.carrera-lugar {
  font-size: 12px; color: var(--text-sec);
  margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
}
.carrera-lugar-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-ter); flex-shrink: 0;
  display: inline-block;
}
.carrera-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }

.badge {
  font-size: 10px; padding: 2px 8px;
  border-radius: 20px; font-weight: 600;
}
.badge-activa   { background: var(--activa-bg);   color: var(--activa-text); }
.badge-aplazada { background: var(--aplazada-bg); color: var(--aplazada-text); }
.badge-cancelada{ background: var(--cancel-bg);   color: var(--cancel-text); }
.badge-web      { background: var(--green-light);  color: var(--green-dark); }

/* Cards con web oficial — borde izquierdo verde sutil */
a.carrera-row.has-web {
  border-left: 2px solid var(--green-border);
  padding-left: 14px;
}
a.carrera-row.has-web .carrera-chevron {
  color: var(--green-mid);
  opacity: 0.7;
}
a.carrera-row.has-web:hover .carrera-chevron {
  opacity: 1;
}


/* Botón añadir al calendario */
.btn-cal {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-sec);
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-ter);
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-cal:hover {
  background: var(--green-light);
  border-color: var(--green-mid);
  color: var(--green-dark);
}
.btn-cal:active { transform: scale(0.95); }
.cal-icon { width: 14px; height: 14px; flex-shrink: 0; }
.btn-cal-label { display: none; }
@media (min-width: 480px) {
  .btn-cal-label { display: inline; }
}

.carrera-chevron {
  color: var(--text-ter); font-size: 20px;
  flex-shrink: 0; opacity: 0.35;
  transition: opacity 0.1s; font-weight: 300;
  align-self: center;
  width: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* Pasadas */
a.carrera-row.past,
div.carrera-row.past { opacity: 0.42; }

/* Highlight búsqueda */
mark {
  background: #FEF08A; color: inherit;
  border-radius: 2px; padding: 0 1px;
}

/* Estado vacío */
.empty-state {
  padding: 56px 24px; text-align: center; color: var(--text-sec);
}
.empty-icon { font-size: 42px; margin-bottom: 14px; opacity: 0.35; }
.empty-state p { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.empty-state small { font-size: 12px; color: var(--text-ter); }

/* ── AdSense ── */
.ad-slot {
  background: var(--bg-sec);
  border-top: 1px solid var(--border-ter);
  border-bottom: 1px solid var(--border-ter);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-ter); font-size: 11px;
}
.ad-inline {
  min-height: 260px; margin: 12px 16px;
  border-radius: 8px; border: 1px dashed var(--border-sec);
}
@media (min-width: 640px) {
  .ad-inline {
    min-height: 100px; margin: 12px 0;
    border-radius: 0; border-left: none; border-right: none;
  }
}
.ad-sidebar-unit {
  min-height: 260px; width: 100%;
  border-radius: 8px; border: 1px dashed var(--border-sec);
}

/* ── Footer ── */
.site-footer {
  padding: 28px 16px; text-align: center;
  font-size: 11px; color: var(--text-ter);
  border-top: 1px solid var(--border-ter); margin-top: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.site-footer a { color: var(--green-mid); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-copy { color: var(--text-ter); }

/* ── Botón Volver Arriba ── */
.btn-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--green-mid);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 109, 17, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 100;
}
.btn-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.btn-top:hover {
  background-color: var(--green-dark);
  transform: translateY(-2px);
}
.btn-top svg {
  width: 20px;
  height: 20px;
}

