/* =====================================================================
   aml-cards.css (round 1118)
   The Asset board (All Assets, #view-am-list) in the Figma "All tasks"
   list-row style: every asset and task row is its own white card with an
   8px status bar on the left, no dots, tasks pushed in under their asset
   with a thin grey L connector.

   Loads AFTER am.css and cl-components.css. Every rule is scoped under
   #view-am-list, so nothing else in the Hub changes, and the id lifts these
   rules over am.css / cl-components.css without !important.

   CSS only: no markup or JS changes. Status colours reuse the 1114 mapping in
   cl-components.css section 10 (the pill's inline --sc colour -> DS status).
   Sources: FIGMA_SPEC 3.2 and 11.3, DESIGN_SYSTEM 7 and 9.
   ===================================================================== */

/* ---------- 0. Shared values ---------- */
#view-am-list {
  --aml-gap: 8px;                 /* gap between cards */
  --aml-bar: 8px;                 /* left status bar */
  --aml-indent: 56px;             /* how far task cards are pushed in */
  --aml-car: 20px;                /* chevron column */
  --aml-colgap: 16px;             /* column gap */
  --aml-minw: 860px;              /* below this a group scrolls inside its own box */
  /* Status | Type | DRI/Assignee | Timeline | Taken/planned: a share of the group's
     width (cqi), held between a floor and a ceiling */
  --aml-c3: clamp(128px, 12cqi, 150px);
  --aml-c4: clamp(96px, 8cqi, 112px);
  --aml-c5: clamp(112px, 11cqi, 150px);
  --aml-c6: clamp(124px, 12cqi, 150px);
  --aml-c7: clamp(96px, 9cqi, 116px);
  --aml-card-bg: var(--cl-bg-surface, #FFFFFF);
  --aml-line: var(--cl-border-default, #E3E6EF);
  --aml-line-strong: var(--cl-border-strong, #C9CEDC);
  --aml-ink: var(--cl-text-heading, #192341);
  --aml-muted: var(--cl-text-secondary, #6B7390);
  --aml-font: var(--cl-font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

/* ---------- 1. Groups: no heavy left block, no box; the cards carry the look ---------- */
#view-am-list .amltable { gap: 28px; padding: 4px 0 8px; }
#view-am-list .amlgrp {
  border: 0; border-radius: 0; background: transparent;
  /* room for the hover shadow, which the group's own scroll box would clip */
  padding: 0 8px 10px 4px;
  /* the column widths below are fractions of the GROUP width (cqi), so a task card
     (narrower, pushed in) and its asset card get exactly the same column sizes */
  container-type: inline-size;
}
#view-am-list .amlgrp.folded { padding-bottom: 0; }

/* client group header: name in navy, client colour as the small dot, counts in grey */
#view-am-list .amlgh {
  gap: 8px; padding: 6px 8px 8px 4px; border-radius: 8px; background: transparent;
}
#view-am-list .amlgh:hover { background: var(--cl-bg-subtle, #F5F6FA); }
#view-am-list .amlgh b {
  font: 700 15px/22px var(--aml-font); color: var(--aml-ink); letter-spacing: 0;
}
#view-am-list .amlgdot { width: 10px; height: 10px; border-radius: 50%; background: var(--gc, #ff6a1f); }
#view-am-list .amlgh .amomut, #view-am-list .amlsgh .amomut { font: 500 12px/16px var(--aml-font); color: var(--aml-muted); }

/* "split retained / ad hoc" and "quote groups" sub-headers: plain text, no band */
#view-am-list .amlsg { border-top: 0; margin-top: 10px; }
#view-am-list .amlsgh, #view-am-list .amlsg.ret .amlsgh {
  background: transparent; padding: 4px 8px 2px 22px; border-radius: 8px;
}
#view-am-list .amlsgh:hover { background: var(--cl-bg-subtle, #F5F6FA); }
#view-am-list .amlsgh b { font: 700 13px/18px var(--aml-font); }

/* ---------- 2. One grid for header, asset and task rows ----------
   chevron | Asset/Task | Status | Type | DRI/Assignee | Timeline | Taken/planned
   Only the name column is flexible; the others scale with the group width (cqi),
   so every row in a group lines up with the header whatever its own width. */
#view-am-list .amlrow {
  grid-template-columns:
    var(--aml-car)
    minmax(0, 1fr)
    var(--aml-c3) var(--aml-c4) var(--aml-c5) var(--aml-c6) var(--aml-c7);
  column-gap: var(--aml-colgap);
  min-width: var(--aml-minw);
  padding-right: 14px;
  box-sizing: border-box;
}
#view-am-list .amlc { padding: 8px 0; }
#view-am-list .amlc.amlcar0 { padding: 0; }

/* column header row: plain 12/600 grey text above the cards, no band, no border.
   It gets the same (transparent) borders as a card so its columns sit over theirs. */
#view-am-list .amlrow.amlhd {
  background: transparent; min-height: 0; margin: 0;
  border: 1px solid transparent; border-left: var(--aml-bar) solid transparent;
}
#view-am-list .amlrow.amlhd .amlc {
  font: 600 12px/16px var(--aml-font); color: var(--aml-muted);
  letter-spacing: 0; text-transform: none; padding: 4px 0 2px;
}

/* ---------- 3. Every asset and task row is its own card ---------- */
#view-am-list .amlasset,
#view-am-list .amltask {
  --bar: var(--cl-task-not-assigned-icon, #8A90A8); /* fallback: anything unmatched */
  position: relative;
  margin-top: var(--aml-gap);
  background: var(--aml-card-bg);
  border: 1px solid var(--aml-line);
  border-left: var(--aml-bar) solid var(--bar);
  border-radius: 10px;
  box-shadow: var(--cl-shadow-rest, 0 1px 2px rgba(25,35,65,.06));
  transition: box-shadow .15s ease, border-color .15s ease;
}
#view-am-list .amlasset { min-height: 56px; }
#view-am-list .amltask { min-height: 52px; }
/* the asset row's lilac fill (and its hover/open shades) is gone; tasks lose their grey */
#view-am-list .amlasset,
#view-am-list .amlasset.open,
#view-am-list .amlasset:hover,
#view-am-list .amltask,
#view-am-list .amltask:hover { background: var(--aml-card-bg); }
/* hover: DS shadow-hover plus a darker border (the status bar keeps its colour) */
#view-am-list .amlasset:hover,
#view-am-list .amltask:hover {
  border-color: var(--aml-line-strong); border-left-color: var(--bar);
  box-shadow: var(--cl-shadow-hover, 0 4px 14px rgba(25,35,65,.12));
}
/* the row whose side card is open: orange edge and a faint warm fill */
#view-am-list .amlasset.sel,
#view-am-list .amltask.sel,
#view-am-list .amltask.sel .amlc:first-child { background: #FFF8F3; }
#view-am-list .amlasset.sel,
#view-am-list .amltask.sel {
  border-color: var(--cl-orange, #ff6a1f); border-left-color: var(--bar);
  box-shadow: 0 0 0 1px var(--cl-orange, #ff6a1f);
}
#view-am-list .amltask.sel .amlcar0::after { display: none; }
#view-am-list .amlasset:focus-visible,
#view-am-list .amltask:focus-visible { outline: 2px solid var(--cl-border-focus, #8900B5); outline-offset: 2px; }

/* ---------- 4. Left status bar colour ----------
   The row's status is only on its pill: the asset's .amlst / the task's .amlsttxt,
   which carry it as an inline --sc colour (AML.STC). Same detection and the same
   Hub-status -> DS-status mapping as cl-components.css section 10. The bar takes the
   chip's bg colour (the solid colour for the solid statuses), as DS v2 section 3 says. */
/* not planned -> Not scheduled */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#8d97a8"]) { --bar: var(--cl-task-not-scheduled-bg, #CDEBFA); }
/* upcoming -> Scheduled */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#3b82f6"]) { --bar: var(--cl-task-scheduled-bg, #C7CCFB); }
/* in progress -> In progress (solid) */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#7c3aed"]) { --bar: var(--cl-task-in-progress-bg, #2173F6); }
/* internal review -> Internal review */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#d97706"]) { --bar: var(--cl-task-internal-review-bg, #E8CCF5); }
/* client review -> Client review */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#ea580c"]) { --bar: var(--cl-task-client-review-bg, #FAC8E6); }
/* revisions -> Making changes (solid) */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#db2777"]) { --bar: var(--cl-task-making-changes-bg, #EC720E); }
/* paused -> On hold */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#6b5b3e"]) { --bar: var(--cl-task-on-hold-bg, #DDE1EA); }
/* complete -> Done (solid) */
#view-am-list .amlrow:has(> .amlc > :is(.amlst, .amlsttxt)[style*="#16a34a"]) { --bar: var(--cl-task-done-bg, #1B7F52); }

/* ---------- 5. No dots ----------
   The RAG light (.amorag) and the task status dot (.amldot) at the left of names.
   Their meaning stays on the status pill, the timeline pill and the late (red) name. */
#view-am-list .amlrow .amldot,
#view-am-list .amlrow .amorag { display: none; }

/* ---------- 6. Tasks pushed in, with a thin grey L connector ---------- */
#view-am-list .amlsub {
  margin-left: var(--aml-indent);
  background: transparent; box-shadow: none;
}
/* task cards are narrower by the indent; their empty chevron column collapses so
   the name column absorbs the difference and every other column stays aligned */
#view-am-list .amlsub .amltask {
  grid-template-columns:
    0px
    minmax(0, 1fr)
    var(--aml-c3) var(--aml-c4) var(--aml-c5) var(--aml-c6) var(--aml-c7);
  min-width: calc(var(--aml-minw) - var(--aml-indent));
}
/* am.css's vertical rail inside the old task rows */
#view-am-list .amltask .amlcar0::before,
#view-am-list .amltask .amlname::before { display: none; }
/* the L: from the asset's chevron line down to the middle of each task card.
   x: chevron centre = bar + half the chevron column inside the asset card;
   measured from the task's padding edge that is (bar + car/2) - indent - bar,
   and the horizontal stroke runs from there to the task card's outer left edge. */
#view-am-list .amlsub .amltask::after {
  content: ""; position: absolute; pointer-events: none;
  left: calc(var(--aml-car) / 2 - var(--aml-indent));
  width: calc(var(--aml-indent) - var(--aml-car) / 2 - var(--aml-bar));
  /* reaches up through the gap to the previous card's middle, so the stack reads as one line */
  top: calc(-1 * (var(--aml-gap) + 27px));
  height: calc(var(--aml-gap) + 27px + 25px);
  border-left: 1px solid var(--aml-line-strong);
  border-bottom: 1px solid var(--aml-line-strong);
  border-bottom-left-radius: 2px;
}
/* the first task's line starts at the bottom edge of the asset card */
#view-am-list .amlsub .amltask:first-child::after {
  top: calc(-1 * var(--aml-gap) - 1px);
  height: calc(var(--aml-gap) + 1px + 25px);
}
/* "no tasks on it yet" / "N more not passing the filters": a quiet dashed card */
#view-am-list .amltask.amlnote {
  --bar: var(--aml-line);
  min-height: 40px; border-style: dashed; border-left-style: solid; box-shadow: none;
}
#view-am-list .amltask.amlnote:hover { border-color: var(--aml-line); border-left-color: var(--bar); box-shadow: none; }

/* the RETAINED / AD HOC panel opens under its asset, pushed in like the tasks */
#view-am-list .amlpanel {
  margin: var(--aml-gap) 0 0 var(--aml-indent); border-radius: 10px;
  border-top-color: var(--aml-line); border-right-color: var(--aml-line); border-bottom-color: var(--aml-line);
  box-shadow: var(--cl-shadow-rest, 0 1px 2px rgba(25,35,65,.06));
  min-width: calc(var(--aml-minw) - var(--aml-indent)); box-sizing: border-box;
}

/* ---------- 7. Type and cells to Figma ---------- */
/* names: Inter 14/600 navy (late rows keep their red name) */
#view-am-list .amlrow .amlnm {
  font: 600 14px/20px var(--aml-font); color: var(--aml-ink); letter-spacing: 0;
}
#view-am-list .amlrow.late .amlnm { color: var(--cl-crimson, #c8102e); }

/* the name cell: name then its pills on ONE line (wrapping only when long) */
#view-am-list .amlasset .amlname {
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding-top: 7px; padding-bottom: 7px;
}
#view-am-list .amltask .amlname { padding-left: 0; gap: 8px; align-items: center; }
#view-am-list .amlpills { gap: 6px; }

/* chevrons: the ▸ / ▾ text glyphs render tiny in Inter, so the glyph is hidden and the
   Lucide chevron-down from cl-components.css section 0 (--clx-chevron-down) is drawn
   instead; turned -90deg it is chevron-right. Same open/fold rotations as before. */
#view-am-list .amlcar,
#view-am-list .amlgcar {
  display: inline-block; width: 16px; height: 16px; font-size: 0; color: transparent;
  background: var(--cl-text-body, #3D4663);
  -webkit-mask: var(--clx-chevron-down) center / 16px 16px no-repeat;
  mask: var(--clx-chevron-down) center / 16px 16px no-repeat;
  transition: transform .15s ease;
}
#view-am-list .amlcar { transform: rotate(-90deg); }
#view-am-list .amlasset.open .amlcar { transform: none; }
#view-am-list .amlgh[aria-expanded="false"] .amlgcar,
#view-am-list .amlsgh[aria-expanded="false"] .amlgcar { transform: rotate(-90deg); }
#view-am-list .amlasset .amlcar0 { justify-content: center; }

/* "N tasks" count badge (Figma count pill), "N need assignee", brief tag, Open */
#view-am-list .amlcount {
  font: 600 12px/18px var(--aml-font); color: var(--cl-text-body, #3D4663);
  background: var(--cl-bg-muted, #ECEEF4); border-radius: 999px; padding: 0 8px;
}
#view-am-list .amlunc {
  font: 600 12px/18px var(--aml-font); border-radius: 999px; padding: 0 8px;
}
#view-am-list .amltag {
  font: 600 11px/18px var(--aml-font); border-radius: 999px; padding: 0 8px;
}
#view-am-list .amlclip, #view-am-list .amlcn { font: 500 12px/18px var(--aml-font); }
#view-am-list .amlopen {
  height: 22px; padding: 0 9px; border-radius: 6px; border-color: var(--aml-line-strong);
  font: 600 12px/20px var(--aml-font); color: var(--aml-ink);
}

/* status pill centred in its column (and its header over it) */
#view-am-list .amlrow > .amlc:nth-child(3) { text-align: center; }

/* RETAINED / AD HOC badge: unchanged colours, a touch rounder */
#view-am-list .amlkind { border-radius: 6px; padding: 3px 8px; }

/* DRI / assignee */
#view-am-list .amlwt b { font: 600 13px/18px var(--aml-font); color: var(--aml-ink); }
#view-am-list .amlnone { font: italic 500 12px/16px var(--aml-font); }

/* timeline pill: Figma 11-12/600, navy on #ECEEF4; late stays red; inherited stays dashed.
   A long range with years ("29 Oct 2025 -> 28 Nov 2025") wraps inside the pill
   rather than running into the hours column. */
#view-am-list .amlwhen {
  display: inline-block; max-width: 100%; box-sizing: border-box;
  font: 600 12px/16px var(--aml-font); color: var(--aml-ink); letter-spacing: 0;
  background: var(--cl-bg-muted, #ECEEF4); border-radius: 10px; padding: 3px 10px; white-space: normal;
}
#view-am-list .amlwhen.amlinh { background: transparent; color: var(--aml-muted); }
#view-am-list .amlwhen.late {
  background: var(--cl-bg-danger-subtle, #FDE7EB); color: var(--cl-crimson, #c8102e);
}
/* month label and its arrows (retained lines) */
#view-am-list .amlmon { font: 600 12px/18px var(--aml-font); border-radius: 999px; padding: 2px 4px; }
#view-am-list .amlmon b { font-weight: 600; padding: 0 6px; }

/* taken / planned with its bar */
#view-am-list .amlhn { font: 500 12px/16px var(--aml-font); font-variant-numeric: tabular-nums; color: var(--cl-text-body, #3D4663); }
#view-am-list .amlhn b { font-weight: 700; color: var(--aml-ink); }
#view-am-list .amlbar { height: 4px; border-radius: 999px; background: var(--cl-bg-muted, #ECEEF4); }
#view-am-list .amlbar i { border-radius: 999px; }

/* ---------- 8. Narrow screens ----------
   am.css sets .amlrow min-widths at 900px; the id-scoped min-width above already
   wins, so each group keeps scrolling inside its own box, as today. */
@media (max-width: 900px) {
  /* the group scrolls sideways inside its own box here (row min-width 860px), as
     today; tasks step in a little less so the name column keeps its room */
  #view-am-list { --aml-indent: 40px; }
}
