/* =========================================================
   DM Widgets — estilos base
   Tokens de marca (fuente: guia-de-diseño.pdf) + reglas anti-rotura.
   ========================================================= */

:root {
  --dm-accent-1: #ff3131;
  --dm-accent-2: #ff914d;
  --dm-grad: linear-gradient(90deg, var(--dm-accent-1) 0%, var(--dm-accent-2) 100%);
  --dm-text: #313131;
  --dm-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------------------------------------------------------
   Utilidades de marca reutilizables por todos los widgets
   --------------------------------------------------------- */

/* Texto con el degradado de marca (clip de texto).
   Con background-clip:text el degradado se pinta sobre el padding-box y luego se
   recorta a la silueta de las letras. Si una cola (g, y, p, j…) cae por debajo del
   padding-box, queda SIN degradado y se ve cortada. El padding-bottom extiende ese
   box hacia abajo para que las colas siempre reciban color. (Bug del encabezado.) */
.dm-title--accent {
  background: var(--dm-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  padding-bottom: 0.22em;  /* holgura suficiente para que las colas (g, y) reciban color */
}

/* ---------------------------------------------------------
   Widget de prueba (DM Test)
   Reglas anti-rotura acotadas al widget para no afectar el resto del sitio.
   --------------------------------------------------------- */
.dm-test,
.dm-test *,
.dm-test *::before,
.dm-test *::after { box-sizing: border-box; }

.dm-test img,
.dm-test svg { max-width: 100%; height: auto; display: block; }

.dm-test {
  font-family: var(--dm-font);
  color: var(--dm-text);
}

.dm-test__eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dm-text);
  opacity: 0.6;
  margin-bottom: 12px;
}

.dm-test__title {
  font-family: var(--dm-font);
  font-weight: 800;
  font-size: clamp(28px, 6vw, 64px); /* tipografía fluida: no se rompe entre breakpoints */
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0;
  overflow-wrap: anywhere; /* títulos largos no desbordan en mobile */
}

.dm-test__note {
  font-family: var(--dm-font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--dm-text);
  margin: 14px 0 0;
}

/* =========================================================
   Widget de calendario (DM Calendar) — agenda de próximos eventos
   ========================================================= */
.dm-cal,
.dm-cal *,
.dm-cal *::before,
.dm-cal *::after { box-sizing: border-box; }

/* Cinturón de seguridad: ningún ícono/imagen del calendario puede desbordar,
   aunque por algún motivo no llegue su regla específica de tamaño. */
.dm-cal img,
.dm-cal svg { max-width: 100%; height: auto; }

.dm-cal {
  font-family: var(--dm-font);
  color: var(--dm-text);
}

/* Encabezado opcional de la sección (estilo eyebrow + título de marca) */
.dm-cal__head {
  margin: 0 0 22px;
}
.dm-cal__eyebrow {
  display: block;          /* siempre en su propia línea, arriba del título */
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dm-text);
  opacity: 0.6;
  margin-bottom: 10px;
}
.dm-cal__title {
  font-family: var(--dm-font);
  font-weight: 800;
  font-size: clamp(24px, 4.5vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  overflow-wrap: anywhere;
}

.dm-cal__list {
  display: grid;
  gap: 14px;
}

.dm-event {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: start;
  padding: 18px;
  background: #ffffff;
  border: 1px solid #ececec;
  border-radius: 16px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.dm-event:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(49, 49, 49, .08);
}

/* Caja de fecha — único lugar con el degradado de marca (acento por evento) */
.dm-event__date {
  width: 64px;
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--dm-grad);
  color: #ffffff;
  line-height: 1;
}
.dm-event__day {
  display: block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.dm-event__month {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dm-event__body { min-width: 0; } /* CLAVE anti-rotura: evita que el texto estire el grid */

.dm-event__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--dm-text);
  overflow-wrap: anywhere;
}

.dm-event__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}
.dm-event__time,
.dm-event__duration,
.dm-event__location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b6b6b;
  min-width: 0;
}
.dm-event__time svg,
.dm-event__duration svg,
.dm-event__location svg {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  color: var(--dm-accent-1);
}
.dm-event__location span { overflow-wrap: anywhere; }

.dm-event__desc {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: #4a4a4a;
}

.dm-cal__empty {
  font-family: var(--dm-font);
  color: #6b6b6b;
  font-size: 15px;
  margin: 0;
}

/* Aviso visible sólo en el editor (faltan credenciales o error de API) */
.dm-notice {
  font-family: var(--dm-font);
  font-size: 14px;
  line-height: 1.5;
  color: #8a5a00;
  background: #fff7ec;
  border: 1px dashed #ffce99;
  border-radius: 12px;
  padding: 14px 16px;
}

/* En mobile mantenemos la fecha como cuadradito compacto a la izquierda
   (no se estira): sólo achicamos tamaños y separaciones. */
@media (max-width: 480px) {
  .dm-event {
    gap: 13px;
    padding: 14px;
  }
  .dm-event__date {
    width: 52px;
    padding: 8px 4px;
  }
  .dm-event__day { font-size: 22px; }
  .dm-event__title { font-size: 17px; }
}

/* =========================================================
   Grilla mensual + layout (calendario al lado de la agenda)
   ========================================================= */

/* Layout: una columna por defecto; en desktop, calendario | agenda. */
.dm-cal__layout {
  display: grid;
  gap: 28px;
}
@media (min-width: 861px) {
  .dm-cal--split .dm-cal__layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* Selector de vista (sólo en mobile y sólo si el JS está activo). */
.dm-cal__tabs {
  display: none;
  margin: 0 0 18px;
  gap: 6px;
  background: #f1f1f1;
  border-radius: 999px;
  padding: 4px;
}
.dm-cal__tab {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--dm-font);
  font-size: 14px;
  font-weight: 600;
  color: var(--dm-text);
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.dm-cal__tab.is-active {
  background: var(--dm-grad);
  color: #ffffff;
}

/* La grilla sólo aparece con JS (degradación elegante: sin JS, sólo la lista). */
.dm-cal__calendar { display: none; }
.dm-cal--js .dm-cal__calendar { display: block; }

.dm-cal__calendar {
  background: #ffffff;
  border: 1px solid #ececec;
  border-radius: 16px;
  padding: 22px;
}
.dm-cal__cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
}
.dm-cal__cal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: capitalize;
}
.dm-cal__nav { display: flex; gap: 6px; }
.dm-cal__nav button {
  width: 34px;
  height: 34px;
  border: 0;
  background: #f4f4f4;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--dm-text);
  font-size: 18px;
  line-height: 1;
  transition: background .2s ease;
}
.dm-cal__nav button:hover { background: #e9e9e9; }

.dm-cal__weekdays,
.dm-cal__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.dm-cal__weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9a9a9a;
  padding-bottom: 8px;
}
.dm-cal__day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  font-size: 13px;
  color: var(--dm-text);
  border-radius: 10px;
}
.dm-cal__day.is-muted { color: #cccccc; }
.dm-cal__day.is-today {
  background: var(--dm-text);
  color: #ffffff;
  font-weight: 700;
}
.dm-cal__day.has-event {
  cursor: pointer;
  font-weight: 700;
}
.dm-cal__day.has-event:hover { background: #f4f4f4; }
.dm-cal__day.is-today.has-event:hover { background: var(--dm-text); }
.dm-cal__day.has-event::after {
  content: '';
  position: absolute;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dm-accent-1);
}
.dm-cal__day.is-today.has-event::after { background: #ffffff; }

/* Con JS, la tarjeta y los días con evento son clickeables (abren el popup). */
.dm-cal--js .dm-event,
.dm-cal--js .dm-cal__day.has-event { cursor: pointer; }
.dm-cal--js .dm-event:focus-visible,
.dm-cal--js .dm-cal__day.has-event:focus-visible {
  outline: 2px solid var(--dm-accent-1);
  outline-offset: 2px;
}

/* Mobile: aparecen las pestañas y se muestra una sola vista por vez (con JS). */
@media (max-width: 860px) {
  .dm-cal--js.dm-cal--split .dm-cal__tabs { display: flex; }
  .dm-cal--js.dm-cal--split[data-view="calendar"] .dm-cal__list { display: none; }
  .dm-cal--js.dm-cal--split[data-view="list"] .dm-cal__calendar { display: none; }
}

/* =========================================================
   Popup / modal de detalle del evento (se inyecta en <body>)
   ========================================================= */
.dm-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 20px;
  font-family: var(--dm-font);
  color: var(--dm-text);
}
.dm-modal[hidden] { display: none; }
.dm-modal *,
.dm-modal *::before,
.dm-modal *::after { box-sizing: border-box; }

.dm-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(2px);
}
.dm-modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px;
  padding: 30px 28px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  animation: dm-modal-in 0.18s ease-out;
}
@keyframes dm-modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dm-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  background: #f4f4f4;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  color: var(--dm-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease;
}
.dm-modal__close:hover { background: #e9e9e9; }

.dm-modal__title {
  margin: 0 40px 0 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.dm-modal__meta {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--dm-accent-1);
}
.dm-modal__location {
  margin-top: 6px;
  font-size: 14px;
  color: #6b6b6b;
  overflow-wrap: anywhere;
}
.dm-modal__desc {
  margin-top: 18px;
  font-size: 15px;
  line-height: 1.6;
  color: #3a3a3a;
  white-space: pre-wrap; /* respeta los saltos de línea de la descripción */
  overflow-wrap: anywhere;
}
.dm-modal__btn {
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--dm-grad);
  color: #ffffff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 22px;
  border-radius: 999px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dm-modal__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(255, 73, 49, 0.3);
}
.dm-modal__btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
