/* life-feed.css — /timeline.html spine, cards, rail, chip, sheet.
 * Tokens only (standard + cozy render from the same rules); the few cozy
 * overrides are at the bottom. Reduced-motion block is LAST (Dev Rule #33).
 * Byte-identical EN/CN. Spec §3.2, §5.3, §5.4, §7. */

.tl-page { --tl-line: var(--border-strong, var(--border)); --tl-gutter: 32px; }

/* ── Filters ─────────────────────────────────────────────────────────── */
.tl-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: -8px 0 20px; }
.tl-search { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; max-width: 320px; min-height: 40px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill, 999px); color: var(--fg-faded); }
.tl-search input { flex: 1; min-width: 0; background: none; border: 0; color: var(--fg); font: inherit; outline: none; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tl-chip { min-height: 36px; padding: 0 14px; border-radius: var(--radius-pill, 999px); border: 1px solid var(--border);
  background: transparent; color: var(--fg-muted); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.tl-chip:hover { color: var(--fg); border-color: var(--border-strong, var(--border)); }
.tl-chip.is-active { background: var(--accent-blue); border-color: var(--accent-blue); color: #0b1220 /* dark ink on the blue fill: white was 3.2:1 (reviewer 2026-09-03) */; }
.tl-chip:focus-visible, .tl-action:focus-visible, .tl-compact:focus-visible, .tl-year-link:focus-visible, .tl-back-now:focus-visible, .tl-mobile-chip:focus-visible {
  outline: 2px solid var(--accent-cyan, var(--accent-blue)); outline-offset: 2px; }

/* ── Layout: rail + spine ────────────────────────────────────────────── */
.tl-layout { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 28px; align-items: start; }
.tl-rail { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 100px); overflow: auto; padding-right: 4px; }
.tl-year-link { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 6px; min-height: 30px; padding: 2px 6px; border-radius: var(--radius-sm, 8px);
  color: var(--fg-faded); text-decoration: none; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.tl-year-link:hover { background: var(--surface-2); color: var(--fg); }
.tl-year-link.is-today .tl-year-name { color: var(--fg); font-weight: 600; }
.tl-year-link.is-current { color: var(--fg-strong, var(--fg)); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent-blue); }
.tl-rail-cells { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1px; height: 8px; }
.tl-rail-cells i { display: block; background: var(--accent-blue); border-radius: 1px; }

.tl-spine { position: relative; padding-left: var(--tl-gutter); overflow-anchor: none; min-height: 60vh; }
.tl-spine::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: var(--tl-line); opacity: .6; }
.tl-spine.is-measuring { visibility: hidden; }
.tl-sentinel { height: 1px; }

/* ── Year + group headers ────────────────────────────────────────────── */
.tl-year { position: sticky; top: 64px; z-index: 3; display: flex; align-items: baseline; gap: 10px; margin: 28px 0 10px calc(-1 * var(--tl-gutter)); padding: 6px 0 6px var(--tl-gutter);
  background: var(--bg-body); }
.tl-year::before { content: ""; position: absolute; left: 4px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%;
  background: var(--accent-purple, var(--accent-blue)); box-shadow: 0 0 0 4px var(--bg-body); }
.tl-year-label { font: 700 var(--text-xl, 1.35rem)/1 var(--font-display, inherit); color: var(--fg-strong, var(--fg)); }
.tl-year-count { font-size: var(--text-xs); color: var(--fg-faded); }
.tl-group { margin: 0 0 14px; }
.tl-group-label { margin: 14px 0 8px; font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-caps, .08em); text-transform: uppercase; color: var(--fg-faded); }
.tl-group-rows { display: flex; flex-direction: column; gap: 10px; }

/* ── Rows ────────────────────────────────────────────────────────────── */
.tl-row { position: relative; }
.tl-dot { position: absolute; left: calc(-1 * var(--tl-gutter) + 5px); top: 14px; width: 14px; height: 14px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-raised, var(--surface-1)); border: 2px solid var(--tl-line); box-shadow: 0 0 0 3px var(--bg-body); color: var(--fg-muted); }
.tl-dot .icon { width: 8px; height: 8px; }
.tl-row[data-kind="goal"] .tl-dot { border-color: var(--goal-color, var(--accent-purple)); background: var(--goal-color, var(--accent-purple)); color: #fff; width: 18px; height: 18px; left: calc(-1 * var(--tl-gutter) + 3px); }
.tl-row[data-kind="milestone"] .tl-dot { border-color: var(--goal-color, var(--accent-blue)); }
.tl-row[data-kind="work"] .tl-dot { border-color: var(--accent-cyan, var(--accent-blue)); color: var(--accent-cyan, var(--accent-blue)); }
.tl-row[data-kind="journal"] .tl-dot { border-style: dashed; }
.tl-row-full { animation: tl-in .18s ease-out both; }
.tl-row.is-target .tl-card { box-shadow: 0 0 0 2px var(--accent-cyan, var(--accent-blue)); }

.tl-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg, 14px); padding: 14px 16px 12px; }
.tl-row[data-kind="goal"] .tl-card { border-left: 4px solid var(--goal-color, var(--accent-purple)); background: var(--surface-raised, var(--surface-1)); }
.tl-row[data-kind="goal"] .tl-title { font-size: var(--text-lg, 1.15rem); }
.tl-row[data-kind="milestone"] .tl-card { border-left: 3px solid var(--goal-border, var(--border-strong, var(--border))); }
.tl-row[data-kind="journal"] .tl-card { background: transparent; border-style: dashed; }
.tl-row[data-kind="journal"] .tl-title { font-size: var(--text-base); font-weight: 500; color: var(--fg-muted); }
.tl-row[data-kind="work"] .tl-card { border-color: color-mix(in srgb, var(--accent-cyan, var(--accent-blue)) 35%, var(--border)); }
.tl-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 4px; }
.tl-date { font-size: var(--text-xs); color: var(--fg-faded); font-variant-numeric: tabular-nums; }
.tl-kind { font-size: var(--text-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--fg-faded); }
.tl-title { margin: 0 0 6px; font: 600 var(--text-base, 1rem)/1.3 var(--font-display, inherit); color: var(--fg-strong, var(--fg)); overflow-wrap: anywhere; }
.tl-phrase { color: var(--accent-cyan, var(--accent-blue)); font-weight: 600; }
.tl-summary { margin: 0 0 10px; color: var(--fg-muted); line-height: var(--line-body, 1.55); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
/* Fixed frame: a lazily loaded image must not change the row's height after the
 * scroll compensation ran (measured 2026-09-03: five images × 220px = 1,102px of drift). */
.tl-media { margin: 4px 0 10px; height: 220px; border-radius: var(--radius-md, 10px); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.tl-media img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.tl-progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 2px 0 4px; }
.tl-progress span { display: block; height: 100%; background: var(--goal-color, var(--accent-blue)); }
.tl-progress-label { font-size: var(--text-xs); color: var(--fg-faded); margin-bottom: 8px; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.tl-chips > span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--radius-pill, 999px); font-size: var(--text-xs); border: 1px solid var(--border); color: var(--fg-muted); }
.tl-chips .icon { width: 12px; height: 12px; }
.tl-chip-goal { background: var(--goal-light, var(--surface-2)); border-color: var(--goal-border, var(--border)) !important; color: var(--fg) !important; }
.tl-goal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--goal-color, var(--accent-blue)); }
.tl-chip-auto { border-style: dashed !important; }
.tl-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border-subtle, var(--border)); }
.tl-action { min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill, 999px); border: 1px solid var(--border); background: transparent;
  color: var(--fg-muted); font: inherit; font-size: var(--text-xs); text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
.tl-action:hover { color: var(--fg); border-color: var(--border-strong, var(--border)); background: var(--surface-2); }
.tl-action-danger:hover { color: var(--danger); border-color: var(--danger); }
.tl-action-quiet { border-color: transparent; }
.tl-action[aria-pressed="true"] { color: var(--fg); border-color: var(--accent-blue); box-shadow: inset 0 0 0 1px var(--accent-blue); }
.tl-action.is-done { color: var(--success); }

.tl-compact { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px; text-align: left; background: none; border: 0;
  border-radius: var(--radius-md, 10px); color: var(--fg); font: inherit; cursor: pointer; }
.tl-compact:hover { background: var(--surface-2); }
.tl-compact .tl-date { flex: 0 0 52px; }
.tl-compact-icon { width: 14px; height: 14px; color: var(--fg-faded); flex: 0 0 auto; }
.tl-compact-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tl-row[data-kind="journal"] .tl-compact-title { color: var(--fg-muted); }
.tl-chevron { width: 14px; height: 14px; color: var(--fg-faded); flex: 0 0 auto; }

/* ── NOW card ────────────────────────────────────────────────────────── */
.tl-now { position: relative; margin: 18px 0; }
.tl-dot-now { width: 24px; height: 24px; left: calc(-1 * var(--tl-gutter)); top: 12px; background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
.tl-dot-now .icon { width: 12px; height: 12px; }
.tl-now-card { border: 1px solid var(--accent-blue); border-radius: var(--radius-xl, 18px); padding: 16px 18px; background: var(--surface-raised, var(--surface-1)); box-shadow: var(--shadow-glow, var(--shadow-md)); }
.tl-now-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tl-now-label { font-size: var(--text-xs); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-blue); }
.tl-now-date { font: 600 var(--text-lg, 1.15rem)/1.2 var(--font-display, inherit); color: var(--fg-strong, var(--fg)); }
.tl-now-facts { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: var(--text-sm); color: var(--fg-muted); }
.tl-now-fact a { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
.tl-now-rel { color: var(--fg-faded); }
.tl-now-counts { margin-top: 8px; font-size: var(--text-sm); color: var(--fg-faded); }

/* ── Ends, errors, empty ─────────────────────────────────────────────── */
.tl-end { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 24px 0 8px; padding: 12px 14px; border: 1px dashed var(--border);
  border-radius: var(--radius-md, 10px); color: var(--fg-faded); font-size: var(--text-sm); }
.tl-end-future { margin: 8px 0 24px; }
.tl-error { display: flex; gap: 10px; align-items: center; margin: 12px 0; padding: 12px 14px; border: 1px solid var(--danger); border-radius: var(--radius-md, 10px); color: var(--fg); }
.tl-empty { margin: 24px 0; padding: 20px; text-align: center; color: var(--fg-muted); border: 1px dashed var(--border); border-radius: var(--radius-md, 10px); }

/* ── Back to now, mobile chip, sheet ─────────────────────────────────── */
.tl-back-now { position: fixed; right: 20px; bottom: 24px; z-index: 40; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-pill, 999px); border: 1px solid var(--accent-blue); background: var(--surface-raised, var(--surface-1)); color: var(--fg); font: inherit; font-weight: 600;
  box-shadow: var(--shadow-lg); cursor: pointer; }
.tl-back-now .icon { width: 14px; height: 14px; transform: rotate(-90deg); }
.tl-mobile-chip { position: sticky; top: 60px; z-index: 5; margin: 0 0 12px; min-height: 40px; padding: 0 14px; border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border); background: var(--surface-raised, var(--surface-1)); color: var(--fg); font: inherit; font-weight: 600; display: none; align-items: center; gap: 6px; box-shadow: var(--shadow-sm); }
.tl-mobile-chip .icon { width: 12px; height: 12px; transform: rotate(90deg); }
.tl-sheet { position: fixed; inset: 0; z-index: 60; background: rgba(8, 12, 24, .55); display: flex; align-items: flex-end; }
.tl-sheet-panel { width: 100%; max-height: 70vh; overflow: auto; background: var(--surface-raised, var(--surface-1)); border-radius: var(--radius-xl, 18px) var(--radius-xl, 18px) 0 0; padding: 16px 16px 24px; }
.tl-sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; }
.tl-sheet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.tl-sheet-year { display: flex; justify-content: space-between; min-height: 44px; padding: 0 12px; border-radius: var(--radius-md, 10px); border: 1px solid var(--border); background: transparent; color: var(--fg); font: inherit; cursor: pointer; }
.tl-sheet-year.is-today { border-color: var(--accent-blue); }
.tl-sheet-count { color: var(--fg-faded); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tl-layout { grid-template-columns: 1fr; gap: 0; }
  .tl-rail { display: none; }
  .tl-mobile-chip { display: inline-flex; }
  .tl-page { --tl-gutter: 26px; }
  .tl-year { top: 108px; }
  .tl-back-now { bottom: 84px; }
  .tl-card { padding: 12px 12px 10px; }
  .tl-actions .tl-action, .tl-compact, .tl-chip { min-height: 44px; }
  .tl-compact .tl-date { flex-basis: 46px; }
}

/* ── Cozy ────────────────────────────────────────────────────────────── */
html[data-ux-mode="cozy"] .tl-spine::before { opacity: .9; }
html[data-ux-mode="cozy"] .tl-year-label, html[data-ux-mode="cozy"] .tl-now-date, html[data-ux-mode="cozy"] .tl-title { font-family: var(--font-serif, var(--font-display, inherit)); }
html[data-ux-mode="cozy"] .tl-chip.is-active { background: var(--surface-2); color: var(--fg-strong, var(--fg)); border-color: var(--accent-rose, var(--accent-blue)); box-shadow: inset 0 0 0 1px var(--accent-rose, var(--accent-blue)); }
html[data-ux-mode="cozy"] .tl-now-card { border-color: var(--accent-rose, var(--accent-blue)); }
html[data-ux-mode="cozy"] .tl-now-label { color: var(--accent-rose-dark, var(--accent-rose, var(--accent-blue))); }

/* ── Motion (LAST — Dev Rule #33) ─────────────────────────────────────── */
@keyframes tl-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tl-row-full { animation: none; }
}
html.tl-no-motion .tl-row-full { animation: none; }

/* ── Overrides for styles.css's global button rules (the strongest is
 * `button:not(.icon-btn):not(.btn):not(.primary):not(.danger)`, specificity
 * 0,4,1 — it paints every button as a gradient pill with a ::before shimmer)
 * and for `[hidden]`, which a class-level `display` rule would otherwise
 * defeat. Id-anchored selectors (1,1,1) win regardless of load order.
 * Measured 2026-09-03 on first deploy: action buttons rendered as blue pills,
 * the year sheet showed on every load. */
#tlSpine button.tl-action, #tlSpine button.tl-compact, #tlChips button.tl-chip, #tlYearSheet button.tl-sheet-year,
button#tlBackNow, button#tlMobileChip, #tlYearSheet button.tl-action {
  background: transparent; background-image: none; box-shadow: none; transform: none; text-transform: none; letter-spacing: normal;
  line-height: 1.2; overflow: visible; position: relative; }
#tlSpine button.tl-action::before, #tlSpine button.tl-compact::before, #tlChips button.tl-chip::before, #tlYearSheet button.tl-sheet-year::before,
button#tlBackNow::before, button#tlMobileChip::before, #tlYearSheet button.tl-action::before { content: none; display: none; }
#tlSpine button.tl-action, #tlYearSheet button.tl-action { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--border); color: var(--fg-muted); font-size: var(--text-xs); font-weight: 500; border-radius: var(--radius-pill, 999px); }
#tlSpine button.tl-action:hover, #tlYearSheet button.tl-action:hover { background: var(--surface-2); color: var(--fg); border-color: var(--border-strong, var(--border)); }
#tlSpine button.tl-action-danger:hover { color: var(--danger); border-color: var(--danger); }
#tlSpine button.tl-action[aria-pressed="true"] { color: var(--fg); border-color: var(--accent-blue); box-shadow: inset 0 0 0 1px var(--accent-blue); }
#tlSpine button.tl-compact { display: flex; width: 100%; align-items: center; justify-content: flex-start; gap: 10px; min-height: 40px; padding: 6px 10px;
  border: 0; border-radius: var(--radius-md, 10px); color: var(--fg); font-size: var(--text-base); font-weight: 500; text-align: left; }
#tlSpine button.tl-compact:hover { background: var(--surface-2); }
#tlChips button.tl-chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--border); color: var(--fg-muted);
  font-size: var(--text-sm); font-weight: 500; border-radius: var(--radius-pill, 999px); }
#tlChips button.tl-chip:hover { color: var(--fg); border-color: var(--border-strong, var(--border)); }
#tlChips button.tl-chip.is-active { background: var(--accent-blue); border-color: var(--accent-blue); color: #0b1220 /* dark ink on the blue fill: white was 3.2:1 (reviewer 2026-09-03) */; }
#tlYearSheet button.tl-sheet-year { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md, 10px); color: var(--fg); font-weight: 500; }
#tlYearSheet button.tl-sheet-year.is-today { border-color: var(--accent-blue); }
button#tlBackNow { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid var(--accent-blue);
  border-radius: var(--radius-pill, 999px); background: var(--surface-raised, var(--surface-1)); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-lg); }
button#tlMobileChip { display: none; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: var(--radius-pill, 999px); background: var(--surface-raised, var(--surface-1)); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-sm); }
.tl-page .tl-sheet[hidden], button#tlBackNow[hidden], .tl-page .tl-media[hidden] { display: none; }
@media (max-width: 900px) {
  button#tlMobileChip { display: inline-flex; min-height: 44px; }
  #tlSpine button.tl-action, #tlSpine button.tl-compact, #tlChips button.tl-chip { min-height: 44px; }
}
html[data-ux-mode="cozy"] #tlChips button.tl-chip.is-active { background: var(--surface-2); color: var(--fg-strong, var(--fg)); border-color: var(--accent-rose, var(--accent-blue)); box-shadow: inset 0 0 0 1px var(--accent-rose, var(--accent-blue)); }
html[data-ux-mode="cozy"] #tlSpine button.tl-action[aria-pressed="true"], html[data-ux-mode="cozy"] .tl-action[aria-pressed="true"] { border-color: var(--accent-rose, var(--accent-blue)); box-shadow: inset 0 0 0 1px var(--accent-rose, var(--accent-blue)); }
