/* ============================================================
   Session Timing Modal — Visual Proportional Timeline
   ============================================================ */

/*
 * When the modal contains a timing track, make the dialog itself a flex
 * column so the header is fixed and the body can grow to fill max-height.
 * Uses CSS :has() — supported in all modern browsers.
 */
/*
 * Give the dialog an explicit height so flex children can grow into it.
 * Without height, flex: 1 on .modal-body has nothing to expand against
 * and the entire content collapses to zero.
 */
.modal-dialog:has(.timing-track) {
  height: 90vh; /* match max-height so body fills the dialog */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog:has(.timing-track) .modal-header {
  flex-shrink: 0;
}

.modal-dialog:has(.timing-track) .modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

@media screen and (max-width: 768px) {
  .modal-dialog:has(.timing-track) {
    height: 100dvh;
  }
}

/* ── Calendar day clock icon button ─────────────────────── */

.calendar-timing-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: 0.25rem;
  border-radius: 0.25rem;
  color: var(--primary-color-light);
  opacity: 0.7;
  text-decoration: none;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.calendar-timing-btn:hover {
  opacity: 1;
  background-color: oklch(100% 0 0 / 0.1);
}

@supports not (color: oklch(0 0 0)) {
  .calendar-timing-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
}

/* ── Content wrapper ─────────────────────────────────────── */

.timing-modal-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Small metadata strip: template name · class length */
.timing-modal-meta {
  font-size: 0.8125rem;
  color: var(--medium-gray);
  padding: 0.5rem 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--medium-gray-dark);
}

/* ── Timing track section — grows to fill space ──────────── */

.timing-track-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.25rem;
}

/*
 * Two-column layout:
 *   left  — time labels (fixed width)
 *   right — proportional coloured blocks
 *
 * Both columns use matching inline flex values so labels
 * stay aligned with their blocks without absolute positioning.
 */
.timing-track {
  display: flex;
  flex-direction: row;
  gap: 0.625rem;
  flex: 1;
  min-height: 0;
}

/* ── Left column: time labels ────────────────────────────── */

.timing-track-labels {
  display: flex;
  flex-direction: column;
  width: 2.5rem;
  flex-shrink: 0;
}

/*
 * Each label cell gets `flex: N` via inline style (where N =
 * the section's duration_minutes). This keeps it in sync with
 * the matching block on the right — no pixel math needed.
 */
.timing-label-cell {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 0.2rem;
  min-height: 0;
  overflow: hidden;
}

.timing-label-time {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: 0.6875rem;
  color: var(--medium-gray);
  line-height: 1;
  white-space: nowrap;
}

/* ── Right column: coloured section blocks ───────────────── */

.timing-track-blocks {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-radius: 0.375rem;
  overflow: hidden;
  gap: 1px; /* 1px hairline between sections */
  background-color: var(--medium-gray-dark); /* shows through gap */
}

/*
 * Each block gets `flex: N` via inline style.
 * `min-height: 0` allows blocks to compress below content size.
 */
.timing-block {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.timing-block-label {
  font-size: 0.8125rem;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.timing-block-duration {
  font-size: 0.6875rem;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Block colour variants ───────────────────────────────── */

.timing-block--gathering,
.timing-block--cleanup {
  background-color: var(--medium-gray-dark);
  color: var(--light-gray);
}

.timing-block--warmup {
  background-color: color-mix(in oklch, var(--primary-color) 22%, var(--dark-gray));
  color: var(--primary-color-light);
}

.timing-block--workout {
  background-color: color-mix(in oklch, var(--success-color) 22%, var(--dark-gray));
  color: var(--success-color);
}

.timing-block--transition {
  background-color: var(--dark-gray);
  color: var(--medium-gray);
}

/* Fallback for browsers without color-mix support */
@supports not (background-color: color-mix(in oklch, red, blue)) {
  .timing-block--warmup {
    background-color: #1a2e4a;
    color: var(--primary-color-light);
  }

  .timing-block--workout {
    background-color: #1a3326;
    color: var(--success-color);
  }
}

/* ── Additional info sections (equipment, notes) ─────────── */

.timing-modal-sections {
  flex-shrink: 0;
  overflow-y: auto;
  border-top: 1px solid var(--medium-gray-dark);
  -webkit-overflow-scrolling: touch;
}

.timing-modal-section {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--medium-gray-dark);
}

.timing-modal-section:last-child {
  border-bottom: none;
}

/* Override global h4 styling inside timing sections */
.timing-modal-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--medium-gray);
  margin-bottom: 0.5rem;
  margin-top: 0;
  background-color: transparent;
  border: none;
  padding: 0;
}

.timing-equipment-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
}

.timing-equipment-list li {
  font-size: 0.8125rem;
  background-color: var(--dark-gray);
  border: 1px solid var(--medium-gray-dark);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  color: var(--light-gray);
}

.timing-coach-notes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timing-coach-note {
  font-size: 0.875rem;
  color: var(--light-gray);
  line-height: 1.5;
  margin: 0;
}

/* ── State messages ──────────────────────────────────────── */

.timing-empty {
  font-size: 0.875rem;
  color: var(--medium-gray);
  padding: 1rem 1.25rem;
}

.timing-warning {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid var(--badge-warning);
  color: var(--badge-warning);
  background-color: color-mix(in oklch, var(--badge-warning) 12%, var(--dark-gray));
}

@supports not (background-color: color-mix(in oklch, red, blue)) {
  .timing-warning {
    background-color: #3d2a1a;
  }
}

/* ── Mobile adjustments ──────────────────────────────────── */

@media screen and (max-width: 768px) {
  .timing-track-section {
    padding: 0.5rem 0.75rem;
  }

  .timing-modal-meta {
    padding: 0.4rem 0.75rem;
  }

  .timing-modal-section {
    padding: 0.625rem 0.75rem;
  }
}
