/* ============================================================================
   LIVING PROFILE - COMPONENTS
   Layout and components only. No raw colors, fonts or sizes here:
   everything comes from theme.css. To restyle, edit theme.css.
   ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }

/* --- Top tab bar ------------------------------------------------------- */
.tabs {
  display: flex; align-items: center; gap: var(--space-1);
  background: var(--bg-tab); border-bottom: 1px solid var(--line);
  padding: 0 var(--space-3); overflow-x: auto;
}
.tab { padding: 10px 14px; font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; }
.tab.is-active {
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.tabs .spacer { flex: 1; }
.sync { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; padding-right: var(--space-2); }
.sync .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); margin-right: 6px; animation: pulse 2.4s ease-in-out infinite; }

/* --- Three-column shell ------------------------------------------------ */
.shell { display: flex; flex-wrap: wrap; align-items: stretch; }
.sidebar {
  flex: 0 1 var(--sidebar-width); min-width: 200px;
  background: var(--bg-sunken); border-right: 1px solid var(--line);
  padding: var(--space-3) var(--space-2); font-size: var(--text-sm);
}
.note { flex: 999 1 560px; min-width: 0; padding-bottom: var(--space-8); }
.rail {
  flex: 0 1 var(--rail-width); min-width: 240px;
  background: var(--bg-sunken); border-left: 1px solid var(--line);
  padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-4);
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .rail { border-left: 0; border-top: 1px solid var(--line); flex-basis: 100%; }
}

/* --- File tree --------------------------------------------------------- */
.label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }
.tree .label { padding: 0 var(--space-2) var(--space-2); display: block; }
.tree-row { display: flex; justify-content: space-between; gap: var(--space-2); padding: 4px var(--space-2); border-radius: var(--radius-sm); color: var(--text); }
.tree-row.child { padding-left: calc(var(--space-2) + 16px); color: var(--text-muted); }
.tree-row.is-current { background: var(--bg-raised); color: var(--text-strong); }
.tree-row .count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--graph-node); }

/* --- Banner & title ---------------------------------------------------- */
.banner { position: relative; height: var(--banner-height); }   /* no overflow:hidden, so the avatar can hang below */
.banner::after { z-index: 1; }
.banner img.cover { width: 100%; height: 100%; object-fit: cover; object-position: var(--banner-focus); opacity: .92; display: block; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--bg) 100%); }
.banner img.avatar {
  position: absolute; left: 48px; bottom: calc(var(--avatar-size) * -0.32); z-index: 2;
  width: var(--avatar-size); height: var(--avatar-size); border-radius: 50%;
  object-fit: cover; object-position: center 25%; border: 4px solid var(--bg);
}
.page { max-width: var(--content-width); margin: 0 auto; padding: calc(var(--space-8) + var(--space-4)) var(--space-8) 0; }
.crumb { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
h1.title { margin: 6px 0 var(--space-4); font-family: var(--font-display); font-weight: 600; font-size: var(--text-h1); color: var(--text-strong); line-height: 1.1; }
h1.title .caret { color: var(--accent); animation: blink 1s step-end infinite; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-h2); color: var(--text-strong); margin: var(--space-8) 0 var(--space-2); }

/* --- Properties -------------------------------------------------------- */
.props {
  display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 10px 0; margin-bottom: var(--space-6); font-size: var(--text-sm);
}
.props dt { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); margin: 0; }
.props dd { margin: 0; }
@media (max-width: 560px) { .props { grid-template-columns: 1fr; } .props dd { margin-bottom: 6px; } }

/* --- Callout ----------------------------------------------------------- */
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius-md) var(--radius-md) 0; padding: 12px 16px; margin-bottom: var(--space-6); }
.callout-title { font-weight: 600; color: var(--accent-text); font-size: var(--text-sm); }

/* --- Lists, tables ----------------------------------------------------- */
ul.bullets { margin: 0; padding-left: 20px; }
ul.bullets li { margin: 4px 0; }
.query { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); margin-bottom: 6px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; padding: 8px; border-bottom: 1px solid var(--line-strong); color: var(--text-muted); font-weight: 500; }
table.data td { padding: 8px; border-bottom: 1px solid var(--line); }
table.data .num { text-align: right; font-family: var(--font-mono); }

/* --- Commit chart ------------------------------------------------------ */
.bars { height: 110px; display: flex; gap: 3px; align-items: flex-end; border-bottom: 1px solid var(--line-strong); }
.bars span { flex: 1; background: var(--chart-bar); border-radius: 2px 2px 0 0; transform-origin: bottom; animation: rise 1.1s cubic-bezier(.2,.8,.2,1) both; }
.bars span.quiet { background: var(--chart-bar-quiet); }
.bars-legend { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; }

/* --- Timeline ---------------------------------------------------------- */
.timeline .row { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 5px 0; }
.timeline .year { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); }

/* --- Right rail -------------------------------------------------------- */
.graph svg { width: 100%; height: 240px; display: block; }
.graph .edge { stroke: var(--graph-edge); stroke-width: 1; }
.graph .node { fill: var(--graph-node); }
.graph .node.hot { fill: var(--graph-node-hot); }
.graph .center { fill: var(--accent); }
.graph text { fill: var(--text-muted); font-family: var(--font-body); font-size: 8.5px; }
.graph .float { animation: float 4s ease-in-out infinite; }
.backlink { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.backlink .ctx { color: var(--text-muted); font-size: 12px; }
.pulse-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.pulse-cell { background: var(--bg-raised); border-radius: var(--radius-sm); padding: var(--space-2); }
.pulse-cell .v { font-size: 20px; color: var(--text-strong); }
.pulse-cell .l { font-size: var(--text-xs); color: var(--text-muted); }

/* --- Help exchange (off by default in config) -------------------------- */
.hx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-3); }
.hx-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); }
.hx-row { display: flex; justify-content: space-between; gap: var(--space-2); padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.hx-row .bounty { color: var(--accent-2); font-family: var(--font-mono); }


/* --- Stat strip -------------------------------------------------------- */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; margin-bottom: var(--space-6); }
.stat { background: var(--bg); padding: var(--space-3) var(--space-2); }
.stat .v { font-size: 22px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.stat .l { font-size: var(--text-xs); color: var(--text-muted); }
.small { font-size: var(--text-sm); margin: 0 0 var(--space-2); }

/* --- Activity heatmap -------------------------------------------------- */
.heat-wrap { overflow-x: auto; }
.heat { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; }
.heat i, .heat-legend i { width: 12px; height: 12px; border-radius: 2px; display: block; background: var(--heat-0); }
.heat i.l1, .heat-legend i.l1 { background: var(--heat-1); }
.heat i.l2, .heat-legend i.l2 { background: var(--heat-2); }
.heat i.l3, .heat-legend i.l3 { background: var(--heat-3); }
.heat i.l4, .heat-legend i.l4 { background: var(--heat-4); }
.heat-legend { display: flex; gap: 4px; align-items: center; justify-content: flex-end; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); margin-top: 6px; }

/* --- Two columns, growth line, horizontal bars ------------------------- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-6); }
.growth { width: 100%; height: auto; display: block; }
.growth .axis { stroke: var(--line-strong); }
.growth .area { fill: var(--accent-soft); }
.growth .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-dasharray: 2000; animation: draw 2.6s ease-out both; }
.growth .now { fill: var(--accent); animation: pulse 2s ease-in-out infinite; }
.growth text { fill: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 52px; gap: 10px; align-items: center; font-size: var(--text-sm); padding: 4px 0; }
.hbar .track { height: 8px; background: var(--bg-raised); border-radius: 4px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; transform-origin: left; animation: grow 1.2s cubic-bezier(.2,.8,.2,1) both; }
.hbar .fill.alt { background: var(--chart-alt); }
.hbar .num { text-align: right; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.cols { height: 120px; display: flex; gap: 4px; align-items: flex-end; border-bottom: 1px solid var(--line-strong); margin-top: var(--space-2); }
.cols span { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; align-items: center; }
.cols b { display: block; width: 100%; background: var(--chart-alt); border-radius: 2px 2px 0 0; transform-origin: bottom; animation: rise 1s cubic-bezier(.2,.8,.2,1) both; }
.cols em { font-style: normal; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

/* --- Topic cloud ------------------------------------------------------- */
.cloud { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.cloud span { color: var(--text-strong); line-height: 1.3; }
.cloud sup { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-left: 2px; }

@keyframes draw { from { stroke-dashoffset: 2000; } to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }


/* --- Daily journal ----------------------------------------------------- */
.journal { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-6); overflow: hidden; }
.j-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.j-title { flex: 1; text-align: center; }
.j-date { font-family: var(--font-display); font-size: 22px; color: var(--text-strong); }
.j-nav { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font-size: 22px; cursor: pointer; }
.j-nav:disabled { opacity: .3; cursor: default; }
.j-top { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; }
.ring-wrap { position: relative; width: 96px; height: 96px; flex: 0 0 96px; }
.ring { width: 96px; height: 96px; transform: rotate(-90deg); display: block; }
.ring .trk { fill: none; stroke: var(--line); stroke-width: 9; }
.ring .val { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.j-score { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.j-score .v { font-size: 26px; color: var(--text-strong); line-height: 1; }
.j-score .l { font-size: 10px; color: var(--text-muted); }
.j-delta { font-family: var(--font-mono); font-size: var(--text-xs); margin-bottom: 4px; }
.j-headline { flex: 1 1 260px; font-family: var(--font-display); font-size: 21px; color: var(--text-strong); line-height: 1.3; }
.j-themes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-family: var(--font-body); }
.j-themes span { font-size: var(--text-xs); color: var(--accent-text); background: var(--accent-soft); border-radius: var(--radius-round); padding: 2px 10px; }
.j-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; margin: var(--space-4) 0; }
.chip { background: var(--bg); padding: var(--space-2); }
.chip .v { font-size: 20px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.chip .l { font-size: var(--text-xs); color: var(--text-muted); }
.chip .dd { font-family: var(--font-mono); font-size: var(--text-xs); min-height: 1em; }
.up { color: var(--accent-2); } .down { color: var(--text-muted); } .flat { color: var(--text-muted); }
.j-lists ul { margin-top: 4px; }
.flip-l { animation: flipL .45s ease both; } .flip-r { animation: flipR .45s ease both; }
@keyframes flipL { from { opacity: 0; transform: translateX(-24px) rotateY(8deg); } to { opacity: 1; transform: none; } }
@keyframes flipR { from { opacity: 0; transform: translateX(24px) rotateY(-8deg); } to { opacity: 1; transform: none; } }

/* --- Scoreboard -------------------------------------------------------- */
.scoreboard { margin-bottom: var(--space-6); }
.sb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.sb-stat .v { font-size: 30px; color: var(--text-strong); line-height: 1.1; }
.sb-stat .v small { font-size: 14px; color: var(--text-muted); }
.sb-stat .l { font-size: var(--text-xs); color: var(--text-muted); }
.sb-bars { height: 90px; display: flex; gap: 3px; align-items: flex-end; border-bottom: 1px solid var(--line-strong); }
.sb-bars span { flex: 1; background: var(--chart-bar-quiet); border-radius: 2px 2px 0 0; transform-origin: bottom; animation: rise 1s cubic-bezier(.2,.8,.2,1) both; }
.sb-bars span.yday { background: var(--accent); }
.sb-bars span.today { background: repeating-linear-gradient(45deg, var(--chart-bar-quiet), var(--chart-bar-quiet) 3px, transparent 3px, transparent 6px); }
.sb-lower { margin-top: var(--space-4); }
.lb-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.lb-row .rank { font-family: var(--font-mono); color: var(--text-muted); }
.lb-row .num { font-family: var(--font-mono); }
.lb-row.me .who { color: var(--text-strong); font-weight: 600; }
.lb-row.empty a.who { color: var(--accent-text); border-color: var(--accent); text-decoration: none; } .lb-row.empty a.who:hover { background: var(--accent-soft); }
.lb-row.empty .who { color: var(--text-muted); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 2px 8px; justify-self: start; }
.sb-how { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); }
.sb-how summary { cursor: pointer; color: var(--accent-text); }

/* --- Footer ------------------------------------------------------------ */
.foot { margin-top: var(--space-8); padding-top: var(--space-3); border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }

/* --- Motion (respects reduced-motion) ---------------------------------- */
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(3px,-4px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

.note { max-width: 100%; }
.lede { font-size: var(--text-lg); color: var(--text-muted); margin: -8px 0 var(--space-6); }
.pnote { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.pn-title { font-family: var(--font-display); font-size: 19px; color: var(--text-strong); }
.pn-ex { color: var(--text); font-size: var(--text-sm); }
.pn-date { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
