/* ═══════════════════════════════════════════════════════════════════
   mobile-timeline.css — عرض الجدول الزمني العمودي للجوال
   Layout per node row (LTR):  [time-label] [pill/line] [content]
   ═══════════════════════════════════════════════════════════════════ */

/* ─── visibility: default per screen size ─── */
@media (max-width: 768px) {
  .wt-period      { display: none !important; }
  .work-total-bar { display: none !important; }
  .wt-act-chips   { display: none !important; }
  .wt-act-list    { display: none !important; }
}
@media (min-width: 769px) {
  .mt-timeline    { display: none !important; }
}

/* ─── manual override via .view-desktop / .view-mobile on .work-blocks ─── */
.work-blocks.view-desktop .wt-period      { display: block !important; }
.work-blocks.view-desktop .work-total-bar { display: flex !important; }
.work-blocks.view-desktop .wt-act-chips   { display: flex !important; }
.work-blocks.view-desktop .wt-act-list    { display: flex !important; }
.work-blocks.view-desktop .mt-timeline    { display: none !important; }

.work-blocks.view-mobile .wt-period      { display: none !important; }
.work-blocks.view-mobile .work-total-bar { display: none !important; }
.work-blocks.view-mobile .wt-act-chips   { display: none !important; }
.work-blocks.view-mobile .wt-act-list    { display: none !important; }
.work-blocks.view-mobile .mt-timeline    { display: block !important; }

/* ─── toggle button ─── */
.btn-view-toggle {
  width: 30px;
  height: 30px;
  background: rgba(124, 106, 239, 0.1);
  border: 1px solid rgba(124, 106, 239, 0.2);
  border-radius: 8px;
  color: var(--purple);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-view-toggle:hover {
  background: rgba(124, 106, 239, 0.2);
  transform: scale(1.1);
}

/* ─── container ─── */
.mt-timeline {
  padding: 0;
  max-width: 480px;
  margin: 0 auto;
}

/* ════════════════════════════
   Period
   ════════════════════════════ */
.mt-period {
  margin-bottom: 16px;
}

.mt-period-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: rgba(78, 205, 196, 0.05);
  border: 1px solid rgba(78, 205, 196, 0.12);
  border-radius: var(--radius-sm);
  position: relative;
  direction: rtl;
}

.mt-period-header::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--success);
  border-radius: 2px 0 0 2px;
}

.mt-period-current .mt-period-header {
  border-color: rgba(78, 205, 196, 0.3);
  background: rgba(78, 205, 196, 0.08);
}

.mt-period-time {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: bidi-override;
}

.mt-period-dur {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  flex: 1;
  text-align: left;
}

.mt-edit-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  background: rgba(78, 205, 196, 0.1);
  border: 1px solid rgba(78, 205, 196, 0.2);
  border-radius: 8px;
  color: var(--success);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mt-period-disabled .mt-period-header {
  opacity: 0.4;
  border-color: rgba(255, 255, 255, 0.05);
}
.mt-period-disabled .mt-period-header::before {
  background: var(--text-muted);
}

.mt-period-progress {
  padding: 0 8px 10px;
}

/* separator between periods */
.mt-period-sep {
  display: flex;
  justify-content: center;
  padding: 4px 0;
  margin-left: 62px; /* align with rail center */
}
.mt-period-sep::before {
  content: '';
  width: 2px;
  height: 16px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.1) 0, rgba(255, 255, 255, 0.1) 3px,
    transparent 3px, transparent 7px
  );
}

/* ════════════════════════════
   Track
   ════════════════════════════ */
.mt-track {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 8px;
}

/* ════════════════════════════
   Time label
   ════════════════════════════ */
.mt-label {
  display: flex;
  align-items: center;
  height: 18px;
  padding-left: 2px;
  direction: ltr;
}

.mt-label::before {
  content: attr(data-t);
  display: inline-block;
  width: 52px;
  min-width: 52px;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.mt-label::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  margin-left: 7px;
  flex-shrink: 0;
}

/* collapse consecutive duplicate labels */
.mt-label + .mt-label {
  display: none;
}

/* ════════════════════════════
   Node (shared)
   ════════════════════════════ */
.mt-node {
  display: flex;
  align-items: stretch;
  direction: ltr;
  --node-color: var(--success);
}

/* ════════════════════════════
   Rail column
   ════════════════════════════ */
.mt-rail {
  width: 20px;
  margin-left: 52px; /* = label width */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

/* pill (activity) */
.mt-pill {
  width: 14px;
  border-radius: 20px;
  background: var(--node-color);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(var(--node-color-rgb, 78, 205, 196), 0.3);
  transition: box-shadow 0.3s, filter 0.3s;
}

.mt-pill-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: rgba(46, 204, 113, 0.45);
  border-radius: 20px;
  transition: height 1s linear;
}

/* line (free time) */
.mt-line {
  width: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.mt-line-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: rgba(78, 205, 196, 0.35);
  border-radius: 2px;
  transition: height 1s linear;
}

/* ════════════════════════════
   Body (content area)
   ════════════════════════════ */
.mt-body {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 6px;
  min-width: 0;
  direction: rtl;
}

/* icon */
.mt-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(var(--node-color-rgb, 78, 205, 196), 0.3);
  flex-shrink: 0;
  position: relative;
  transition: box-shadow 0.3s, transform 0.3s;
}

.mt-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  border-radius: inherit;
}

/* info */
.mt-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.mt-timerange {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  direction: ltr;
  text-align: right;
  line-height: 1.2;
}

.mt-dur {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.mt-note {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
  direction: rtl;
}

.mt-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
}

/* timer badge */
.mt-timer {
  display: none;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--bg-mid);
  border: 1px solid rgba(244, 196, 48, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(244, 196, 48, 0.15);
  flex-shrink: 0;
}

/* ════════════════════════════
   Free-time node
   ════════════════════════════ */
.mt-body-free {
  padding: 2px 8px 2px 6px;
  min-height: 0;
}

.mt-free-dur {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  font-style: italic;
}

.mt-clickable { cursor: pointer; }
.mt-node-free.mt-clickable:hover .mt-body-free { background: rgba(78, 205, 196, 0.1); border-radius: 8px; }
.mt-node-act.mt-clickable:hover .mt-body { background: rgba(255,255,255,0.05); border-radius: 8px; }

/* ════════════════════════════
   States: Done
   ════════════════════════════ */
.mt-node.mt-done .mt-pill {
  background: rgba(78, 205, 196, 0.4);
  box-shadow: none;
  filter: saturate(0.6);
}

.mt-node.mt-done .mt-pill-fill {
  height: 100% !important;
  background: rgba(46, 204, 113, 0.25);
}

.mt-node.mt-done .mt-icon {
  opacity: 0.55;
  filter: grayscale(30%);
  box-shadow: none;
}

.mt-node.mt-done .mt-name {
  opacity: 0.5;
  text-decoration: line-through;
  text-decoration-color: rgba(240, 240, 245, 0.2);
}

.mt-node.mt-done .mt-timerange {
  opacity: 0.45;
}

.mt-node-free.mt-done .mt-line {
  background: rgba(78, 205, 196, 0.2);
}

.mt-node-free.mt-done .mt-free-dur {
  opacity: 0.4;
}

/* ════════════════════════════
   States: Active
   ════════════════════════════ */
.mt-node.mt-active .mt-pill {
  animation: mt-pulse 2.5s ease-in-out infinite;
  box-shadow:
    0 0 0 4px rgba(var(--node-color-rgb, 78, 205, 196), 0.12),
    0 0 18px rgba(var(--node-color-rgb, 78, 205, 196), 0.4);
}

.mt-node.mt-active .mt-icon {
  animation: mt-glow 2.5s ease-in-out infinite;
  box-shadow:
    0 0 0 4px rgba(var(--node-color-rgb, 78, 205, 196), 0.12),
    0 4px 14px rgba(var(--node-color-rgb, 78, 205, 196), 0.4);
}

.mt-node.mt-active .mt-timer {
  display: block;
}

.mt-node.mt-active .mt-name {
  color: var(--text-primary);
}

.mt-node-free.mt-active .mt-line {
  background: linear-gradient(to bottom,
    rgba(78, 205, 196, 0.4),
    rgba(78, 205, 196, 0.1));
  animation: mt-breathe 2s ease-in-out infinite;
}

.mt-node-free.mt-active .mt-timer {
  display: block;
}

/* ════════════════════════════
   Animations
   ════════════════════════════ */
@keyframes mt-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(var(--node-color-rgb, 78, 205, 196), 0.12),
      0 0 18px rgba(var(--node-color-rgb, 78, 205, 196), 0.4);
    transform: scaleX(1);
  }
  50% {
    box-shadow:
      0 0 0 7px rgba(var(--node-color-rgb, 78, 205, 196), 0.05),
      0 0 26px rgba(var(--node-color-rgb, 78, 205, 196), 0.5);
    transform: scaleX(1.1);
  }
}

@keyframes mt-glow {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(var(--node-color-rgb, 78, 205, 196), 0.12),
      0 4px 14px rgba(var(--node-color-rgb, 78, 205, 196), 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(var(--node-color-rgb, 78, 205, 196), 0.05),
      0 6px 20px rgba(var(--node-color-rgb, 78, 205, 196), 0.5);
    transform: scale(1.04);
  }
}

@keyframes mt-breathe {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1;   }
}

/* entrance */
@keyframes mt-slide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mt-node {
  animation: mt-slide 0.3s ease both;
}

.mt-track > :nth-child(1)  { animation-delay: 0.02s; }
.mt-track > :nth-child(2)  { animation-delay: 0.05s; }
.mt-track > :nth-child(3)  { animation-delay: 0.08s; }
.mt-track > :nth-child(4)  { animation-delay: 0.11s; }
.mt-track > :nth-child(5)  { animation-delay: 0.14s; }
.mt-track > :nth-child(6)  { animation-delay: 0.17s; }
.mt-track > :nth-child(7)  { animation-delay: 0.20s; }
.mt-track > :nth-child(8)  { animation-delay: 0.23s; }
.mt-track > :nth-child(9)  { animation-delay: 0.26s; }
.mt-track > :nth-child(10) { animation-delay: 0.29s; }

/* ════════════════════════════
   Total bar
   ════════════════════════════ */
.mt-total {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  margin-top: 4px;
  background: rgba(78, 205, 196, 0.05);
  border: 1px solid rgba(78, 205, 196, 0.1);
  border-radius: var(--radius-sm);
  direction: rtl;
}

.mt-total-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mt-total-value {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--success);
}

/* ════════════════════════════
   Small screens
   ════════════════════════════ */
@media (max-width: 380px) {
  .mt-label::before {
    width: 44px;
    min-width: 44px;
    font-size: 0.6rem;
  }
  .mt-rail {
    margin-left: 44px;
  }
  .mt-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 1rem;
  }
  .mt-name {
    font-size: 0.84rem;
  }
  .mt-period-sep {
    margin-left: 54px;
  }
}

/* ─── Activity focus progress ─── */
.mt-focus-progress {
  margin-top: 4px;
  width: 100%;
}

.mt-focus-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.mt-focus-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.mt-focus-text {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
  display: block;
}
