/* =====================================================================
   Extem — "we do" tree
   One root fanning into 5 curved dashed arrow-branches (drawn by JS
   into .todo-wires so curves stay docked when cards expand).
   Loads after ocean.css. Theme + RTL aware.
   ===================================================================== */

.todo-layout {
  position: relative;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 0 110px;
  max-width: 1100px;
  margin: 40px auto 0;
  text-align: start;
}
/* Fade-only entrance: a translate would briefly extend the page and
   flash the scrollbar on load. The tree still arrives as one piece. */
.todo-layout.revealy {
  transform: none;
}

/* curved wires canvas — sits behind cards, drawn by home.js */
.todo-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
.todo-wires path {
  fill: none;
  stroke: rgba(24, 153, 201, 0.75);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 10;
  animation: wireMarch 1.1s linear infinite;
  filter: drop-shadow(0 0 6px rgba(24, 153, 201, 0.45));
  transition: stroke 0.3s ease, filter 0.3s ease;
}
[data-theme="dark"] .todo-wires path {
  stroke: rgba(138, 180, 248, 0.8);
  filter: drop-shadow(0 0 6px rgba(138, 180, 248, 0.5));
}
.todo-wires path.lit {
  stroke-width: 2.6;
  filter: drop-shadow(0 0 10px rgba(24, 153, 201, 0.8));
}
[data-theme="dark"] .todo-wires path.lit {
  filter: drop-shadow(0 0 10px rgba(138, 180, 248, 0.9));
}
@keyframes wireMarch {
  to { stroke-dashoffset: -11; }
}

/* ---- Root ---- */
.todo-trunk {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-inline-end: 18px;
  min-height: 100%;
}
.todo-root {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 16px 34px;
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
  color: #04263e;
  border-radius: 999px;
  background: linear-gradient(135deg, #a5f3fc, #38d6f5 55%, #1aa3d6);
  box-shadow: 0 6px 18px rgba(56, 214, 245, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
[dir="rtl"] .todo-root {
  font-family: "Tajawal", "Montserrat", sans-serif;
  letter-spacing: 0;
}
/* port dot where the 5 wires leave the pill */
.todo-root::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline-end: -8px;
  width: 10px;
  height: 10px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #1aa3d6;
  box-shadow: 0 0 6px rgba(24, 153, 201, 0.5);
}
[data-theme="dark"] .todo-root::after {
  background: #8ab4f8;
  box-shadow: 0 0 6px rgba(138, 180, 248, 0.5);
}

/* ---- Branch cards ---- */
.todo-branches {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.todo-node {
  position: relative;
  margin: 0;
  border-radius: 18px;
  padding: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
/* straight stub is desktop-hidden (SVG curves do the job);
   it becomes the vertical drop on mobile */
.todo-node::before {
  display: none;
}
/* arrow head where each curve docks */
.todo-node::after {
  content: "";
  position: absolute;
  inset-inline-start: -13px;
  top: 29px;
  border: 7px solid transparent;
  border-inline-start-color: rgba(24, 153, 201, 0.95);
  filter: drop-shadow(0 0 6px rgba(24, 153, 201, 0.5));
}
[data-theme="dark"] .todo-node::after {
  border-inline-start-color: rgba(138, 180, 248, 0.95);
}
.todo-node:hover {
  transform: translateY(-3px);
}
.todo-node.open {
  border-color: rgba(24, 153, 201, 0.6);
  box-shadow: 0 12px 32px rgba(56, 214, 245, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* node head is a real button: click / Enter / Space toggles */
.todo-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: start;
}
.todo-ico {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: 12px;
  color: #1aa3d6;
  background: rgba(56, 214, 245, 0.14);
  border: 1px solid rgba(56, 214, 245, 0.3);
}
[data-theme="dark"] .todo-ico {
  color: #8ab4f8;
  background: rgba(138, 180, 248, 0.12);
  border-color: rgba(138, 180, 248, 0.3);
}
.todo-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--primary);
}
[data-theme="dark"] .todo-title {
  color: var(--text-primary);
}
.todo-plus {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid rgba(5, 5, 95, 0.2);
  color: var(--primary);
  transition: transform 0.3s ease, background 0.3s ease;
}
[data-theme="dark"] .todo-plus {
  border-color: rgba(138, 180, 248, 0.35);
  color: var(--primary);
}
.todo-node.open .todo-plus {
  transform: rotate(45deg);
  background: rgba(56, 214, 245, 0.18);
}
.todo-head:focus-visible {
  outline: 2px solid #1aa3d6;
  outline-offset: 3px;
  border-radius: 12px;
}

/* expandable packet: attached under the head, tree stays intact */
.todo-body {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.45s ease, opacity 0.3s ease, margin 0.3s ease;
}
.todo-body > span {
  overflow: hidden;
  min-height: 0;
  display: block;
  margin: 0 20px 0;
  padding: 0 0 0 16px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-secondary);
  border-inline-start: 2px solid rgba(26, 163, 214, 0.55);
}
[dir="rtl"] .todo-body > span {
  font-family: "Tajawal", "Montserrat", sans-serif;
}
.todo-node.open .todo-body {
  grid-template-rows: 1fr;
  opacity: 1;
}
.todo-node.open .todo-body > span {
  margin-bottom: 20px;
  padding-top: 2px;
}

/* ---- Mobile: endless side-scroll rail (JS clones + wraps, see home.js) ---- */
@media (max-width: 860px) {
  .todo-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .todo-wires {
    display: none;
  }
  .todo-trunk {
    justify-content: center;
    padding: 0 0 22px;
    min-height: 0;
  }
  .todo-root::after {
    top: auto;
    bottom: -7px;
    inset-inline-end: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  .todo-root::after {
    display: none;
  }
  .todo-branches {
    flex-direction: row;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-inline: -7%;
    padding: 8px 7% 20px;
  }
  .todo-branches::-webkit-scrollbar {
    display: none;
  }
  .todo-node {
    flex: 0 0 78vw;
    max-width: 330px;
    scroll-snap-align: center;
  }
  .todo-node::before,
  .todo-node::after {
    display: none;
  }
  .todo-node:hover {
    transform: none;
  }
  .todo-plus {
    display: none;
  }
  .todo-head {
    cursor: default;
  }
  /* cards ride open on the rail — no accordion punching holes */
  .todo-node .todo-body {
    grid-template-rows: 1fr;
    opacity: 1;
  }
  .todo-node .todo-body > span {
    margin-bottom: 20px;
    padding-top: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .todo-wires path {
    animation: none;
  }
}
