/* ==========================================================================
   RANKHUB · CALENDARIO DEL CLUB (calendario.html + common/js/rh-agenda.js)
   Depende de rh-base.css (tokens :root, .rh-card, .rh-btn).
   ========================================================================== */

.rh-agenda-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rh-agenda-intro p {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--muted);
}

.rh-agenda-intro .rh-btn {
  width: auto;
  flex: none;           /* en escritorio, en la misma línea que el texto */
  white-space: nowrap;
}

/* Móvil: el botón ocupa el ancho de la tarjeta, como "Conectar con Strava" en Registro */
@media (max-width: 768px) {
  .rh-agenda-intro {
    flex-direction: column;
    align-items: stretch;
  }

  .rh-agenda-intro .rh-btn {
    width: 100%;
  }
}

/* Barra sobre los meses: filtro por tipo (segmentado) y plegar / desplegar todo */
.rh-agenda-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.rh-agenda-filter {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--bg-alt);
}

.rh-agenda-filter-btn {
  min-height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.rh-agenda-filter-btn[aria-pressed="true"] {
  background: var(--card-bg);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.rh-agenda-fold {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

/* Mismo chevron que los meses: ▾ todo abierto (plegar), ▸ algo plegado (desplegar) */
.rh-agenda-fold::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  margin-top: 4px;
  transform: rotate(-135deg);
  transition: transform 0.2s ease;
}

.rh-agenda-fold.is-folded::after {
  margin-top: -4px;
  transform: rotate(45deg);
}

.rh-agenda-filter-btn:focus-visible,
.rh-agenda-fold:focus-visible {
  outline: 2px solid var(--blue-2);
  outline-offset: 2px;
}

@media (hover: hover) {
  .rh-agenda-filter-btn:not([aria-pressed="true"]):hover {
    color: var(--text);
  }

  .rh-agenda-fold:hover {
    text-decoration: underline;
  }
}

/* «✨ Novedades (X)»: solo si hay novedades. Morado como la etiqueta «Novedad»; pegado al filtro en PC y,
   en el móvil, a la izquierda de la fila de «Plegar todo» (no añade una fila) */
.rh-agenda-filter-new {
  margin-right: auto;
  border: 1.5px solid #7c3aed;
  background: var(--card-bg);
  color: #7c3aed;
}

.rh-agenda-filter-new[aria-pressed="true"] {
  background: #7c3aed;
  color: #fff;
  box-shadow: 0 1px 4px rgba(124, 58, 237, 0.35);
}

@media (hover: hover) {
  .rh-agenda-filter-new:not([aria-pressed="true"]):hover {
    color: #6d28d9;
    background: #f5f3ff;
  }
}

/* Móvil: el filtro ocupa todo el ancho, con los tres botones a partes iguales */
@media (max-width: 480px) {
  .rh-agenda-filter {
    display: flex;
    width: 100%;
  }

  .rh-agenda-filter .rh-agenda-filter-btn {
    flex: 1;
    padding: 0 8px;
  }
}

.rh-agenda-month {
  margin-top: 28px;
}

.rh-agenda-months > .rh-agenda-empty {
  margin-top: 20px;
}

.rh-agenda-month-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 800;
  color: #1e293b;
  padding-bottom: 6px;
  border-bottom: 2px solid #e2e8f0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.rh-agenda-month-title::-webkit-details-marker {
  display: none;
}

.rh-agenda-month-title .num {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

/* Chevron: ▸ plegado, ▾ abierto */
.rh-agenda-month-title::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

.rh-agenda-month[open] > .rh-agenda-month-title::after {
  transform: rotate(45deg);
}

.rh-agenda-month:not([open]) > .rh-agenda-month-title {
  margin-bottom: 0;
}

.rh-agenda-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.rh-agenda-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  line-height: 1.45;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

/* Ribbon diagonal en la esquina superior derecha: carrera / quedada */
.rh-agenda-card.has-ribbon {
  position: relative;
  overflow: hidden;
}

/* Hueco para la cinta: el título se aparta 40px; el día y la hora, solo 12px (la cinta apenas llega a esa línea) */
.rh-agenda-card.has-ribbon .rh-agenda-title {
  padding-right: 40px;
}

.rh-agenda-card.has-ribbon .rh-agenda-when {
  padding-right: 12px;
}

.rh-agenda-ribbon {
  position: absolute;
  top: 16px;
  right: -34px;
  width: 124px;
  padding: 3px 0;
  transform: rotate(45deg);
  text-align: center;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.rh-agenda-ribbon.is-race {
  background: #d9480f;
}

.rh-agenda-ribbon.is-meetup {
  background: #15803d;
}

.rh-agenda-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rh-agenda-date {
  flex: 0 0 52px;
  height: 56px;
  border-radius: 12px;
  border: 2px solid var(--blue);
  background: var(--blue-pale);
  color: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  box-shadow: 0 2px 6px rgba(0, 74, 153, 0.15);
}

.rh-agenda-date .day {
  font-size: 1.2rem;
  font-weight: 800;
}

.rh-agenda-date .mon {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.rh-agenda-titlewrap {
  min-width: 0;
}

/* «Novedad»: evento dado de alta en los últimos 7 días (mismo distintivo que la agenda de forms).
   Pestaña sobre el borde superior del cuadro de la fecha: no desplaza el título */
.rh-agenda-date {
  position: relative;
}

.rh-agenda-new {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: 999px;
  background: #7c3aed;
  color: #fff;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.35);
}

.rh-agenda-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #1e293b;
  overflow-wrap: anywhere;
}

.rh-agenda-when {
  margin-top: 2px;
  font-size: 0.8rem;
  color: #64748b;
}

.rh-agenda-reg {
  font-size: 0.82rem;
  color: #475569;
}

.rh-agenda-reg.is-open {
  color: #15803d;
  font-weight: 700;
}

.rh-agenda-reg.is-closed {
  color: #c0392b;
  font-weight: 700;
}

/* Evento celebrado (se lista hasta 2 días después) */
.rh-agenda-card.is-past .rh-agenda-date {
  border-color: var(--dim);
  background: #f1f5f9;
  color: var(--dim);
  box-shadow: none;
}

.rh-agenda-reg.is-past {
  color: var(--dim);
  font-weight: 700;
}

.rh-agenda-desc {
  margin: 0;
  font-size: 0.875rem;
  color: #475569;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Título con web del evento: azul y con el icono de enlace externo al final; sin web, en negro y sin icono
   (igual que la agenda de forms) */
.rh-agenda-titlelink {
  color: var(--blue);
  text-decoration: none;
}

.rh-agenda-titlelink .ext {
  display: inline-block;
  margin-left: 5px;
  vertical-align: -1px;
  color: var(--blue);
}

@media (hover: hover) {
  .rh-agenda-titlelink:hover {
    text-decoration: underline;
  }
}

.rh-agenda-titlelink:focus-visible {
  outline: 2px solid var(--blue-2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Pie de la tarjeta: «Compartir» a la izquierda y el recuento a la derecha, siempre en una línea.
   Si el pie es estrecho (móvil), letra e iconos algo menores; si aun así no cabe, «Compartir» solo con el icono */
.rh-agenda-foot {
  container-type: inline-size;
  margin-top: auto;
  padding-top: 4px;
}

.rh-agenda-foot-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.rh-agenda-counts {
  display: flex;
  flex: 1;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.rh-agenda-counts .item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rh-agenda-counts .ico {
  flex: none;
}

.rh-agenda-counts .sep {
  color: var(--dim);
}

/* Enlace a la agenda del área privada: hover solo con ratón (en táctil se quedaría "pegado") */
@media (hover: hover) {
  a.rh-agenda-counts:hover {
    color: var(--blue);
    text-decoration: underline;
  }
}

a.rh-agenda-counts:focus-visible {
  outline: 2px solid var(--blue-2);
  outline-offset: 2px;
  border-radius: 4px;
}

.rh-agenda-empty {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
}

/* Evento del enlace compartido (calendario?evento=<id>) */
.rh-agenda-card.is-target {
  border-color: #004a99;
  box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.25), 0 2px 8px rgba(15, 23, 42, 0.06);
  scroll-margin-top: 80px;
}

.rh-agenda-notfound {
  margin-top: 16px;
  text-align: center;
  color: #64748b;
}

/* Lugar con enlace (Google Maps…) */
.rh-agenda-location {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

@media (hover: hover) {
  .rh-agenda-location:hover {
    text-decoration: underline;
  }
}

/* Compartir por WhatsApp (como en la agenda de forms) */
.rh-agenda-share {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: #128c7e;
  text-decoration: none;
}

@media (hover: hover) {
  .rh-agenda-share:hover {
    text-decoration: underline;
  }
}

@container (max-width: 330px) {
  .rh-agenda-foot-row {
    gap: 6px;
  }

  .rh-agenda-counts,
  .rh-agenda-share {
    font-size: 0.74rem;
  }

  .rh-agenda-counts {
    gap: 4px;
  }

  .rh-agenda-counts .item {
    gap: 3px;
  }

  .rh-agenda-counts .ico,
  .rh-agenda-share svg {
    width: 13px;
    height: 13px;
  }
}

@container (max-width: 270px) {
  .rh-agenda-share .txt {
    display: none;
  }
}
