/* Results, Posts and Weekly report (docs/design/SPEC.md sections 9 and 10.5). Colours only from tokens. */

.results-panel { gap: var(--sp-5); }
.results-period { gap: var(--sp-2); }
.nonfollower { font-weight: 600; color: var(--heading); }
.kpi-gone, .small-sample { display: flex; gap: var(--sp-1); align-items: flex-start; font-size: var(--fs-small); color: var(--text-soft); }
.kpi-gone .ico, .small-sample .ico { margin-top: 3px; flex: none; }

/* chart cards */
.charts-grid { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); container-type: inline-size; }
@container (min-width: 900px) {
  .charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .chart-wide { grid-column: 1 / -1; }
}
.chart-card { margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); container-type: inline-size; }
.chart-q { font-size: var(--fs-h3); }
.chart-sub, .chart-note { font-size: var(--fs-small); color: var(--text-soft); }
.chart-body { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }

.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "y plot" ". x"; column-gap: var(--sp-2); font-size: var(--fs-small); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.chart-bars { grid-template-columns: minmax(0, 1fr); grid-template-areas: "plot" "x"; }
.chart-plot { grid-area: plot; position: relative; height: 180px; }
.chart-y { grid-area: y; position: relative; min-width: 3.2em; height: 180px; }
.chart-y span { position: absolute; right: 0; transform: translateY(-50%); line-height: 1; white-space: nowrap; }
.chart-x { grid-area: x; display: flex; justify-content: space-between; gap: var(--sp-2); padding-top: var(--sp-1); }
.chart-x span { white-space: nowrap; }
.chart-x-cols { justify-content: flex-start; gap: 2px; }
.chart-x-cols span { flex: 1 1 0; min-width: 0; overflow: visible; }

.line-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.grid-line { stroke: var(--op-line-soft); stroke-width: 1; }
.line-path { stroke: var(--op-navy); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.line-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--op-navy); }
.line-last { position: absolute; right: 0; transform: translateY(-160%); font-weight: 700; color: var(--op-navy); background: var(--card); padding: 0 2px; }

.bars { display: flex; align-items: flex-end; gap: 2px; padding-top: 24px; box-sizing: border-box; border-bottom: 1px solid var(--op-line); }
.bar-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar { display: block; width: 100%; border-radius: 3px 3px 0 0; }
.bar-top { background: var(--op-navy); }
.bar-rest { background: var(--op-line); }
.bar-value { position: absolute; top: -22px; white-space: nowrap; font-weight: 700; color: var(--op-navy); }
.chart-hours .chart-plot { height: 140px; }

/* so-what toggle (SPEC 3.5: height and opacity, --dur-2) */
.sowhat { border-top: 1px solid var(--op-line-soft); padding-top: var(--sp-1); }
.sowhat-toggle { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: var(--tap); padding: 0; border: 0; background: transparent; color: var(--link); font: inherit; font-weight: 700; font-size: var(--fs-small); text-align: left; cursor: pointer; }
.sowhat-chev { width: 18px; height: 18px; transition: transform var(--dur-2) var(--ease-out); }
.sowhat-toggle[aria-expanded="true"] .sowhat-chev { transform: rotate(90deg); }
.sowhat-text { animation: sowhat-in var(--dur-2) var(--ease-out); }
@keyframes sowhat-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.chart-body { cursor: pointer; }
.chart-body button, .chart-body a { cursor: pointer; }

/* followers online: day chips + 24 bars on phone, 7 x 24 heat grid when the card is wide */
.online-wide { display: none; }
.online-phone .chips { margin-bottom: var(--sp-3); }
.online-phone .chip { padding: 0 12px; }
@container (min-width: 560px) {
  .online-phone { display: none; }
  .online-wide { display: block; }
}
.heat { display: grid; grid-template-columns: 3em repeat(24, minmax(0, 1fr)); gap: 2px; font-size: var(--fs-small); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.heat-hour { text-align: left; white-space: nowrap; overflow: visible; }
.heat-day { align-self: center; }
.heat-cell { aspect-ratio: 1; min-height: 16px; border-radius: 3px; background: var(--op-navy); }
.heat-cell.lv0 { background: var(--op-paper-soft); box-shadow: inset 0 0 0 1px var(--op-line-soft); }
.heat-cell.lv1 { opacity: .2; }
.heat-cell.lv2 { opacity: .4; }
.heat-cell.lv3 { opacity: .6; }
.heat-cell.lv4 { opacity: .8; }
.heat-cell.lv5 { opacity: 1; }
.heat-cell.heat-faint { opacity: .4; }

/* row charts: formats, slots, hashtags, audience */
.fmt-list, .slot-list, .tag-list, .hbar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.fmt-row, .tag-row { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.fmt-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-1) var(--sp-3); }
.tag-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-3); align-items: center; }
.tag-row .hbar-track, .tag-row .metric { grid-column: 1 / -1; }
.tag-name { font-weight: 700; overflow-wrap: anywhere; }
.hbar-track { display: block; height: 12px; border-radius: var(--r-pill); background: var(--op-line-soft); overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--op-navy); border-radius: var(--r-pill); }
.slot-list { gap: var(--sp-3); }
.slot-row { display: flex; flex-direction: column; gap: 2px; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--op-line-soft); }
.slot-row:last-child { border-bottom: 0; padding-bottom: 0; }
.slot-when { font-weight: 700; color: var(--heading); }
.slot-row .metric, .fmt-row .metric, .tag-row .metric { font-size: var(--fs-small); color: var(--text-soft); }
.aud-group { display: flex; flex-direction: column; gap: var(--sp-3); }
.aud-group + .aud-group { border-top: 1px solid var(--op-line-soft); padding-top: var(--sp-4); }
.aud-group h3 { font-size: var(--fs-body); }
.hbar-list { gap: var(--sp-3); }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-small); }
.hbar-label { overflow-wrap: anywhere; }
.hbar .hbar-track { grid-column: 1 / -1; }

/* Posts segment */
.posts-controls .chips { margin-top: var(--sp-1); }
/* S9: the sort and post-count selects keep a readable width on wide screens. */
.posts-controls .select { max-width: 320px; }
.post-grid { gap: 0 var(--sp-5); }
.post-grid .post-main { display: contents; }
.post-grid .thumb { grid-row: span 2; }
.post-grid .post-meta, .post-grid .post-caption { grid-column: 2; }
.post-grid .metrics { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-1) var(--sp-3); }
@container (min-width: 520px) {
  .post-grid .post:nth-child(2) { border-top: 0; padding-top: 0; }
}
.table-card { padding: var(--sp-3); }
.posts-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.posts-table th, .posts-table td { padding: var(--sp-2) 6px; vertical-align: top; text-align: left; border-bottom: 1px solid var(--op-line-soft); }
.posts-table th { color: var(--text-soft); font-weight: 600; vertical-align: bottom; hyphens: none; word-break: normal; overflow-wrap: normal; }
.posts-table .num { text-align: right; font-variant-numeric: tabular-nums; min-width: 6ch; }
.posts-table .td-text { max-width: 28ch; }
.posts-table td:first-child { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-1); white-space: nowrap; }
.th-sort { display: inline-flex; align-items: flex-end; gap: 2px; min-height: var(--tap); min-width: var(--tap); padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; text-align: inherit; cursor: pointer; }
.posts-table th.num .th-sort { justify-content: flex-end; }
.posts-table th[aria-sort="ascending"], .posts-table th[aria-sort="descending"] { color: var(--op-navy); }
.td-text { min-width: 12em; }
.td-post { display: flex; gap: var(--sp-3); align-items: flex-start; }
.td-post .thumb { width: 56px; height: 56px; flex: none; }

/* Weekly report */
.report-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-body); line-height: var(--lh-body); }

@media (prefers-reduced-motion: reduce) {
  .sowhat-chev { transition: none; }
  .sowhat-text { animation: sowhat-fade var(--dur-1) linear; }
  @keyframes sowhat-fade { from { opacity: 0; } to { opacity: 1; } }
}
