/* ============================================================
   Day Timeline — Visual Proportional Session Timeline
   Single source of truth for ::Components::DayTimeline
   Used in builder, calendar/week (dark), and plan (light).
   ============================================================ */

/* ── Container ────────────────────────────────────────────── */

.day-timeline {
  display: flex;
  flex-direction: column;
  height: 480px;
}

/*
 * 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: 1.25rem;
  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.
 * All blocks get a minimum height so labels remain readable.
 */
.timing-block {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0.25rem 0.75rem;
  gap: 0.5rem;
  min-height: 1.25rem;
  overflow: hidden;
}

/* Workout blocks need column layout to hold the occurrence card */
.timing-block--workout {
  flex-direction: column;
  align-items: stretch;
  padding: 0.5rem 0.625rem;
  gap: 0.375rem;
  min-height: 2rem;
}

.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 (dark theme — default) ────────── */

.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);
}

/* Movement-specific build-up window carved out of the general warmup.
   Same hue as the warmup but dashed on top to distinguish it as the
   dedicated lead-in for the workout immediately below. The negative
   margin consumes the 1px hairline gap from .timing-track-blocks so
   the dashed border isn't doubled by the track-background line. */
.timing-block--prep {
  background-color: color-mix(in oklch, var(--primary-color) 16%, var(--dark-gray));
  color: var(--primary-color-light);
  border-top: 2px dashed color-mix(in oklch, var(--primary-color-light) 60%, transparent);
  margin-top: -1px;
  font-style: italic;
}

/* 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);
  }
}

/* ── Unfulfilled blocks (planned but not yet programmed) ── */

.timing-block--unfulfilled {
  background-color: color-mix(in oklch, var(--dark-gray) 90%, transparent);
  border: 2px dashed var(--medium-gray);
  opacity: 0.7;
  overflow: visible;
}

/* Allow assign dropdown to escape overflow clipping */
.timing-track-blocks:has(.day-plan-assign[open]) {
  overflow: visible;
}

.day-timeline--light .timing-block--unfulfilled {
  background-color: var(--surface-raised);
  border: 2px dashed var(--border-emphasis);
  opacity: 1;
  color: var(--text-muted);
}

/* ── Unfulfilled block warning ──────────────────────────── */

.timeline-unfulfilled-warning {
  font-size: 0.65rem;
  font-style: italic;
  color: oklch(70% 0.15 55);
}

.day-timeline--light .timeline-unfulfilled-warning {
  color: oklch(55% 0.15 55);
}

/* ── Occurrence cards (inside workout blocks) ────────────── */

.timeline-occurrence { display: flex; flex-direction: column; gap: 0.25rem; position: relative; padding-right: 4.5rem; }
.timeline-occurrence-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--success-color); text-decoration: none; }
.timeline-occurrence-badges { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.timeline-occurrence-stimulus { font-size: 0.625rem; padding: 0.1rem 0.35rem; border-radius: 0.25rem; background-color: oklch(100% 0 0 / 0.18); color: white; white-space: nowrap; font-weight: 600; }
.timeline-occurrence-element { font-size: 0.625rem; padding: 0.1rem 0.35rem; border-radius: 0.25rem; background-color: oklch(100% 0 0 / 0.12); color: var(--success-color); white-space: nowrap; }
.timeline-occurrence-cap { font-size: 0.625rem; padding: 0.1rem 0.35rem; border-radius: 0.25rem; background-color: oklch(100% 0 0 / 0.18); color: white; white-space: nowrap; font-weight: 600; }
.timeline-occurrence-actions { display: flex; gap: 0.5rem; font-size: 0.6875rem; position: absolute; top: 0; right: 0; }
.timeline-occurrence-actions a {
  color: var(--light-gray);
  text-decoration: none;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  opacity: 0.7;
  transition: background-color 120ms ease, color 120ms ease, opacity 120ms ease;
}
.timeline-occurrence-actions a:hover,
.timeline-occurrence-actions a:focus-visible {
  opacity: 1;
  color: white;
  background-color: var(--danger-color, oklch(60% 0.18 25));
  text-decoration: none;
}
.timeline-block-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; align-items: flex-start; }
.timeline-unmatched { border-top: 1px solid var(--medium-gray-dark); padding: 0.5rem 0.625rem; }
.timeline-unmatched-title { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--medium-gray); margin-bottom: 0.375rem; }

/* ── Dark theme (builder / calendar) ─────────────────────── */

/* In modal context, let DayTimeline fill the flex container */
.timing-modal-content .day-timeline {
  flex: 1;
  height: auto;
  min-height: 0;
}

/* ── Light theme (plan view) — colors only ───────────────── */

.day-timeline--light .timing-track-blocks {
  background-color: var(--border);
}

.day-timeline--light .timing-block--gathering,
.day-timeline--light .timing-block--cleanup {
  background-color: var(--timeline-light-neutral);
  color: var(--timeline-light-neutral-text);
}

.day-timeline--light .timing-block--warmup {
  background-color: var(--timeline-light-warmup);
  color: var(--timeline-light-warmup-text);
}

.day-timeline--light .timing-block--workout {
  background-color: var(--timeline-light-workout);
  color: var(--timeline-light-workout-text);
}

.day-timeline--light .timing-block--transition {
  background-color: var(--surface-subtle);
  color: var(--border-emphasis);
}

.day-timeline--light .timing-block--prep {
  background-color: color-mix(in oklch, var(--timeline-light-warmup) 75%, white);
  color: var(--timeline-light-warmup-text);
  border-top: 2px dashed color-mix(in oklch, var(--timeline-light-warmup-text) 60%, transparent);
  margin-top: -1px;
}

/* Light theme: occurrence name inherits block color */
.day-timeline--light .timeline-occurrence-name {
  color: var(--timeline-light-workout-text);
}

.day-timeline--light .timeline-occurrence-element {
  background-color: oklch(50% 0 0 / 0.08);
  color: var(--text-secondary);
}

/* Stimulus chip in light theme: dark fill on a light card so the type
   stays legible. The dark theme rule uses translucent white over the
   block's dark wash, which inverts to white-on-white here. */
.day-timeline--light .timeline-occurrence-stimulus {
  background-color: var(--timeline-light-workout-text);
  color: white;
}

.day-timeline--light .timeline-occurrence-cap {
  background-color: var(--timeline-light-workout-text);
  color: white;
}

.day-timeline--light .timeline-occurrence-actions a {
  color: var(--text-secondary);
}

.day-timeline--light .timeline-occurrence-actions a:hover,
.day-timeline--light .timeline-occurrence-actions a:focus-visible {
  color: white;
  background-color: var(--danger-color, oklch(60% 0.18 25));
}
