/*
 * The app's Intentions tree, drawn for the web as the app draws it (ADR-0036's whole shape, as amended 2026-09-21:
 * "Today's rows at every generation"). A breakdown goes DOWN AND ACROSS, never down a list: every parent lays the steps
 * it breaks into as a ROW of at most three columns centred under it, joined by one comb (a drop out of the parent, a
 * run only as wide as the row, a drop into each column); a parent with one child sits straight above it; sibling
 * branches stand side by side, each as wide as its own widest row. The canvas grows sideways as a tree bushes, and
 * where it is wider than its room it pans, as the app's camera does (tree.js arrives on the root).
 *
 * The blocks are apps/ios/Sources/DecompositionBlocks.swift's, in Theme.swift's Dusk column (the App Store creative's
 * port, docs/design/store-screenshots/creative/tree.css), at the app's fixed block width: a title wraps inside it and
 * cuts at its lines, as the app's canvas does. The home page's Intentions draws one you can tick (index.html,
 * home.js); an article's `tree` diagram draws one to read (diagrams.ts). The step to do next wears the glow of the
 * thing the magpie holds, as every diagram's does.
 *
 * No style is written inline (the site's CSP refuses it): a bar's fill is a class, `w-0` to `w-100`.
 */

.tree-canvas {
  --tree-surface: #3a2a24; /* Theme.surface */
  --tree-tint: #4a2a18; /* Theme.accentTint: a step done */
  --tree-accent: #ff8a33; /* Theme.accent */
  --tree-strong: #fff3ea; /* Theme.textStrong */
  --tree-muted: #a88e7e; /* Theme.textMuted */
  --tree-ring: #5a4338; /* Theme.borderBase */
  /* Theme.railDim (borderBase at 0.78) as it lands on Theme.appBg, solid: where two lengths of rail meet, a
     see-through one would show the seam twice as bright. */
  --tree-rail: #503b31;
  --tree-track: #33241f; /* Theme.surfaceMuted */
  --tree-next: #ffb071; /* the site's lit: what the reader is heading for */
  /* CascadeLayout's geometry at the 0.82 Today draws it: a 152pt block, a 12pt lattice gap, a 34pt band between a
     parent and its row (a drop to the comb, then a fall into each column). */
  --tree-w: 8rem;
  --tree-gap: 10px;
  --tree-drop: 9px;
  --tree-fall: 19px;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  padding: 4px 0 16px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: rgb(255 226 200 / 0.18) transparent;
  scrollbar-width: thin;
}

/* Wider than its room: the edges fade, so the tree reads as going on past them. */
.tree-canvas.is-wide {
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent,
    #000 24px,
    #000 calc(100% - 24px),
    transparent
  );
  mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.tree-hint {
  display: none;
  margin: 6px 0 0;
  color: #a88e7e;
  font-size: 0.8125rem;
  text-align: center;
}

.tree-canvas.is-wide + .tree-hint {
  display: block;
}

/* The tree: centred while it fits, starting at the canvas's edge once it is wider, so nothing hides off the left. */
.tree {
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  width: max-content;
  min-width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A node: its block, and under it the row its smaller steps make. */
.tree-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
}

/* Columns part by the lattice gap, never by padding, so a tree is exactly as wide as its columns at any depth. */
.tree-children {
  position: relative;
  display: flex;
  justify-content: center;
  gap: var(--tree-gap);
  margin: 0;
  padding: var(--tree-drop) 0 0;
  list-style: none;
}

/* The comb. A drop out of the parent... */
.tree-children::before {
  position: absolute;
  top: 0;
  left: calc(50% - 1px);
  width: 2px;
  height: var(--tree-drop);
  background: var(--tree-rail);
  content: "";
}

.tree-children > .tree-node {
  padding-top: var(--tree-fall);
}

/* ...a run only as wide as the row: each column draws its half, out from its centre into half the gap beside it, so
   neighbours' halves meet and the run stops at the first and last columns' centres... */
.tree-children > .tree-node::before,
.tree-children > .tree-node::after {
  position: absolute;
  top: 0;
  height: 2px;
  background: var(--tree-rail);
  content: "";
}

.tree-children > .tree-node::before {
  right: 50%;
  left: calc(var(--tree-gap) / -2);
}

.tree-children > .tree-node::after {
  right: calc(var(--tree-gap) / -2);
  left: 50%;
}

.tree-children > .tree-node:first-child::before,
.tree-children > .tree-node:last-child::after {
  display: none;
}

/* ...and a fall into each column. One child alone takes the drop and the fall as one straight line. */
.tree-children > .tree-node > .tree-block::before {
  position: absolute;
  bottom: 100%;
  left: calc(50% - 1px);
  width: 2px;
  height: var(--tree-fall);
  background: var(--tree-rail);
  content: "";
}

/* A block: one intention, plan or step, the app's width, at least the app's height for its kind. */

.tree-block {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: var(--tree-w);
  min-height: 3.5rem;
  margin: 0;
  padding: 9px 10px;
  color: var(--tree-strong);
  background: var(--tree-surface);
  border-radius: 14px;
  box-shadow: 0 2px 7px rgb(0 0 0 / 0.32); /* warmShadow(.flat) */
  transition:
    background-color 300ms ease,
    box-shadow 300ms ease;
}

.tree-standing {
  min-height: 4rem;
  padding: 10px 11px;
  border-radius: 15px;
  box-shadow:
    0 8px 32px rgb(0 0 0 / 0.42),
    0 2px 10px rgb(0 0 0 / 0.3); /* warmShadow(.card) */
}

.tree-goal {
  min-height: 3.75rem;
  box-shadow: 0 3px 16px rgb(0 0 0 / 0.36); /* warmShadow(.small) */
}

.tree-task,
.tree-done {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.tree-done {
  min-height: 3.25rem;
  background: var(--tree-tint);
  box-shadow: none;
}

.tree-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.tree-dot {
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--tree-accent);
  border-radius: 50%;
  box-shadow: 0 0 6px rgb(255 138 51 / 0.3);
}

.tree-standing .tree-dot {
  width: 12px;
  height: 12px;
  box-shadow: 0 0 8px rgb(255 138 51 / 0.35);
}

.tree-words {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* A title wraps inside the block and cuts at its third line, as the app's canvas does. */
.tree-title {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--tree-strong);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.22;
  overflow-wrap: break-word;
  text-decoration: line-through transparent;
  text-decoration-thickness: 1px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  transition:
    color 300ms ease,
    text-decoration-color 300ms ease;
}

.tree-done .tree-title {
  color: var(--tree-muted);
  font-weight: 600;
  text-decoration-color: currentColor;
}

/* An intention that goes on: no finish line. */
.tree-inf {
  flex: none;
  color: var(--tree-muted);
  font-size: 0.8125rem;
}

/* The roll-up: how many of the steps under it are done. */

.tree-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.tree-bar {
  position: relative;
  flex: 1 1 auto;
  height: 5px;
  overflow: hidden;
  background: var(--tree-track);
  border-radius: 3px;
}

.tree-bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 5px;
  min-width: 5px;
  background: linear-gradient(90deg, #e0a766, #ff8a33); /* Theme.progressGradient */
  border-radius: 3px;
  transition: width 900ms cubic-bezier(0.2, 0.9, 0.25, 1.15);
}

.tree-count {
  flex: none;
  color: var(--tree-muted);
  font-size: 0.65625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A step's mark: the ring of one still to do, the tick of one done. */

.tree-ring {
  flex: none;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--tree-ring);
  border-radius: 50%;
}

.tree-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: var(--tree-accent);
  border-radius: 50%;
}

.tree-check svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* The next step: one, glowing, its name on a tag that hangs from its lower edge (a step to do has nothing under it). */

.tree-block.is-next {
  box-shadow:
    0 0 0 1px var(--tree-next),
    0 0 30px -6px rgb(255 154 77 / 0.55);
}

.is-next .tree-ring {
  border-color: var(--tree-next);
}

.tree-next-label {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 1;
  padding: 1px 8px;
  color: var(--tree-next);
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
  white-space: nowrap;
  background: #2b1e1a; /* Theme.appBg */
  border: 1px solid var(--tree-next);
  border-radius: 999px;
  transform: translate(-50%, 50%);
}

/* A bar's fill, in the twentieths of the whole a roll-up can be. */

.tree-bar i.w-5 {
  width: 5%;
}

.tree-bar i.w-10 {
  width: 10%;
}

.tree-bar i.w-15 {
  width: 15%;
}

.tree-bar i.w-20 {
  width: 20%;
}

.tree-bar i.w-25 {
  width: 25%;
}

.tree-bar i.w-30 {
  width: 30%;
}

.tree-bar i.w-35 {
  width: 35%;
}

.tree-bar i.w-40 {
  width: 40%;
}

.tree-bar i.w-45 {
  width: 45%;
}

.tree-bar i.w-50 {
  width: 50%;
}

.tree-bar i.w-55 {
  width: 55%;
}

.tree-bar i.w-60 {
  width: 60%;
}

.tree-bar i.w-65 {
  width: 65%;
}

.tree-bar i.w-70 {
  width: 70%;
}

.tree-bar i.w-75 {
  width: 75%;
}

.tree-bar i.w-80 {
  width: 80%;
}

.tree-bar i.w-85 {
  width: 85%;
}

.tree-bar i.w-90 {
  width: 90%;
}

.tree-bar i.w-95 {
  width: 95%;
}

.tree-bar i.w-100 {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .tree-block,
  .tree-title,
  .tree-bar i {
    transition: none;
  }
}
