/**
 * Componentes reutilizables: badge de estado, barra de progreso, índice
 * del diario (timeline), artículo de semana y su paginador.
 */

/* — Badge de estado — */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.3em 0.7em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.status-badge__dot {
  width: 0.4em;
  height: 0.4em;
  border-radius: 50%;
  background: currentColor;
}

.status-badge--completada {
  color: var(--color-completed);
  background: var(--color-completed-soft);
}

.status-badge--disponible {
  color: var(--color-available);
  background: var(--color-available-soft);
}

.status-badge--proxima {
  color: var(--color-upcoming);
  background: var(--color-upcoming-soft);
}

/* — Barra de progreso — */
.progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 14rem;
  flex-shrink: 0;
}

.progress__meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.progress__figure {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: 1;
  white-space: nowrap;
}

.progress__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.progress__track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-surface-sunken);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: var(--progress-percent, 0%);
  background: var(--color-accent);
  border-radius: var(--radius-full);
  animation: fill-progress var(--duration-slow) var(--ease-standard) both;
  animation-delay: 100ms;
}

@keyframes fill-progress {
  from {
    width: 0%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress__fill {
    animation: none;
    width: var(--progress-percent, 0%);
  }
}

/* — Índice del diario (timeline) —
   Un número editorial grande (marcador principal de posición), un nodo
   de estado, el bloque de fechas (rango de semana + fecha de clase —
   dos jerarquías distintas a propósito) y el título. El estado se lee
   en tres lugares reforzándose entre sí: el nodo, el número y el badge
   — nunca solo color. Todo por grid-area, sin posicionamiento absoluto:
   así el layout no depende de medir a ojo el ancho de cada elemento. */
.timeline {
  border-top: 1px solid var(--color-border);
}

.timeline__item {
  border-bottom: 1px solid var(--color-border);
}

.timeline__row {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    'index index'
    'node body'
    'node status';
  column-gap: var(--space-4);
  row-gap: var(--space-2);
  align-items: start;
  padding: var(--space-5) var(--space-3);
  transition: background-color var(--duration-fast) var(--ease-standard);
}

/* El <a> envuelve index+nodo+cuerpo para que todo eso sea un único
   objetivo de clic, pero no debe generar su propia caja — así sus hijos
   participan directo del grid de .timeline__row (ver grid-area abajo). */
.timeline__link {
  display: contents;
  text-decoration: none;
}

.timeline__row:hover,
.timeline__row:has(.timeline__link:focus-visible) {
  background: var(--color-surface-sunken);
}

.timeline__index {
  grid-area: index;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-variant-numeric: tabular-nums;
  color: var(--color-border-strong);
  line-height: 1;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-standard);
}

.timeline__item--completada .timeline__index,
.timeline__item--disponible .timeline__index {
  color: var(--color-text-faint);
}

.timeline__item--current .timeline__index {
  color: var(--color-accent);
}

.timeline__link:hover .timeline__index {
  color: var(--color-accent);
}

.timeline__node {
  grid-area: node;
  align-self: start;
  margin-top: 0.5em;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-bg);
  transition: background-color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.timeline__link:hover .timeline__node {
  transform: scale(1.25);
}

.timeline__item--completada .timeline__node {
  background: var(--color-completed);
  border-color: var(--color-completed);
}

.timeline__item--disponible .timeline__node {
  background: var(--color-available);
  border-color: var(--color-available);
}

.timeline__item--proxima .timeline__node {
  background: transparent;
  border-style: dashed;
}

.timeline__item--current .timeline__node {
  box-shadow: 0 0 0 3px var(--color-accent-soft);
  border-color: var(--color-accent);
}

.timeline__body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.timeline__dates {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.timeline__range {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.timeline__class {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.timeline__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}

.timeline__placeholder {
  color: var(--color-text-faint);
  font-style: italic;
}

.timeline__meta-actions {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-self: start;
}

.timeline__edit-link {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  transition: color var(--duration-fast) var(--ease-standard);
}

.timeline__edit-link:hover {
  color: var(--color-accent);
}

@media (min-width: 640px) {
  .timeline__row {
    grid-template-columns: 5.5rem auto 1fr auto;
    grid-template-areas: 'index node body status';
    align-items: center;
    column-gap: var(--space-5);
    padding-inline: var(--space-4);
  }

  .timeline__index {
    font-size: var(--text-3xl);
  }

  .timeline__node {
    margin-top: 0;
  }

  .timeline__meta-actions {
    justify-self: end;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
  }
}

/* — Artículo de semana — */
.week {
  max-width: var(--reading-width);
  margin-inline: auto;
  padding-inline: var(--space-5);
  padding-block: var(--space-7) var(--space-10);
}

.week__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-7);
}

.week__breadcrumb a {
  text-decoration: none;
  color: var(--color-text-muted);
}

.week__breadcrumb a:hover {
  color: var(--color-accent);
}

.week__header {
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-7);
}

.week__index {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.week__eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.week__eyebrow-sep {
  color: var(--color-border-strong);
}

.week__title {
  font-size: var(--text-3xl);
}

.week__theme {
  margin-top: var(--space-2);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-accent);
}

.week__header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.week__edit-link {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  transition: color var(--duration-fast) var(--ease-standard);
}

.week__edit-link:hover {
  color: var(--color-accent);
}

.week__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* — Bloques de contenido (ver api/lib/blocks.php) — */
.block-heading {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}

.week__body > .block-heading:first-child {
  margin-top: 0;
}

.block-paragraph {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.block-highlight {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  color: var(--color-accent-ink);
  padding: var(--space-5);
  background: var(--color-accent-soft);
  border-radius: var(--radius-md);
}

.block-quote {
  padding-left: var(--space-5);
  border-left: 2px solid var(--color-accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-accent-ink);
}

.block-list {
  padding-left: 1.4em;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

ul.block-list {
  list-style: disc;
}

ol.block-list {
  list-style: decimal;
}

.block-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  width: 100%;
  margin-block: var(--space-2);
}

.block-link a,
.week__evidence {
  display: inline-block;
  color: var(--color-accent);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent);
}

.block-image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.block-image figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.inline-highlight {
  background: var(--color-accent-soft);
  color: var(--color-accent-ink);
  padding: 0.05em 0.3em;
  border-radius: var(--radius-sm);
}

/* — Foro de comentarios —
   Estética de foro académico/editorial, no de red social: sin
   avatares, sin likes, sin reacciones. Divisores horizontales simples
   entre comentarios (como una conversación transcrita), nombre en
   sans-serif semibold, fecha discreta, sin nada que se pueda "dar
   like" o "compartir". */
.comments {
  margin-top: var(--space-9);
  padding-top: var(--space-7);
  border-top: 1px solid var(--color-border);
}

.comments__header {
  margin-bottom: var(--space-6);
}

.comments__title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.comments__empty {
  padding: var(--space-5) 0;
  color: var(--color-text-faint);
  font-style: italic;
  border-top: 1px solid var(--color-border);
}

.comments__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comments__item {
  padding: var(--space-5) 0;
  border-top: 1px solid var(--color-border);
}

.comments__item:last-child {
  border-bottom: 1px solid var(--color-border);
}

.comments__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.comments__name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.comments__date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.comments__text {
  line-height: var(--leading-relaxed);
  color: var(--color-text);
  overflow-wrap: break-word;
}

.comments__delete {
  margin-top: var(--space-2);
}

.comments__delete-btn {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.comments__delete-btn:hover {
  color: var(--color-available);
}

/* — Formulario para participar — */
.comments__form-wrap {
  margin-top: var(--space-7);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.comments__form-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.comments__message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.comments__message p {
  margin: 0;
}

.comments__message p + p {
  margin-top: var(--space-1);
}

.comments__message--success {
  background: var(--color-completed-soft);
  color: var(--color-completed);
}

.comments__message--error {
  background: var(--color-available-soft);
  color: var(--color-available);
}

.comments__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.comments__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.comments__field span {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.comments__field input,
.comments__field textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.comments__field textarea {
  resize: vertical;
  min-height: 6rem;
}

.comments__field input:focus,
.comments__field textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* Honeypot: fuera de pantalla, no display:none (algunos bots lo detectan). */
.comments__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.comments__submit {
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-bg);
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-6);
  cursor: pointer;
}

.comments__submit:hover {
  opacity: 0.85;
}

.comments__submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.week__empty {
  padding: var(--space-6);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  line-height: var(--leading-relaxed);
}

.week__empty-hint {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.week__pager {
  margin-top: var(--space-9);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
}

.week__pager-link {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-decoration: none;
  font-size: var(--text-sm);
  min-width: 0;
}

.week__pager-link--next {
  align-items: flex-end;
  text-align: right;
}

.week__pager-direction {
  color: var(--color-text-muted);
}

.week__pager-label {
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--color-text);
}

.week__pager-link:hover .week__pager-label {
  color: var(--color-accent);
}

.week__pager-index {
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  justify-self: center;
}

.week__pager-index:hover {
  color: var(--color-accent);
}

@media (min-width: 768px) {
  .week {
    padding-block: var(--space-9) var(--space-12);
  }
}
