/* Stats (docs/ANALYTICS.md). One series colour (the link blue), a grey for
   the previous period, status colours only for speed ratings and changes. */
:root {
  --stat-series: #0060d1;
  --stat-prev: #a8a8a8;
  --stat-wash: rgba(0, 96, 209, .10);
  --stat-bar: rgba(0, 96, 209, .09);
  --stat-good: #0f7b3d; --stat-fair: #a35c00; --stat-poor: #c62a2f;
}
[data-theme="dark"] {
  --stat-series: #3987e5;
  --stat-prev: #6e6e6e;
  --stat-wash: rgba(57, 135, 229, .14);
  --stat-bar: rgba(57, 135, 229, .16);
  --stat-good: #5fd88b; --stat-fair: #f5b454; --stat-poor: #ff8a8f;
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stat-head { align-items: baseline; }
.stat-head-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.stat-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
.stat-custom { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.stat-custom input[type=date] { padding: .3rem .45rem; font-size: .82rem; width: auto; }
.stat-custom .button-outline { padding: .3rem .7rem; font-size: .82rem; }
.stat-setup { margin-bottom: 1rem; }
.stat-setup h2 { margin-top: 0; font-size: 1rem; }

/* headline tiles */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .8rem 1rem .6rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0;
}
.stat-tile-label { font-size: .8rem; color: var(--fg-muted); }
.stat-tile-value { font-size: 1.6rem; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.stat-change { font-size: .78rem; font-weight: 550; font-variant-numeric: tabular-nums; }
.stat-change.is-good { color: var(--stat-good); }
.stat-change.is-bad { color: var(--stat-poor); }
.stat-change.is-flat { color: var(--fg-muted); font-weight: 400; }
.stat-spark { width: 100%; height: 26px; margin-top: .3rem; overflow: visible; }
.stat-spark polyline { stroke: var(--stat-series); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; opacity: .7; }

/* the main chart */
.stat-main { margin-bottom: 1.25rem; }
.stat-main-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-right: 1rem; }
.stat-main-head .metabox-title { border-bottom: 0; }
.stat-legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--fg-muted); }
.stat-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.key-line { display: inline-block; width: 16px; height: 2px; border-radius: 1px; background: var(--stat-series); }
.key-line.is-prev { background: var(--stat-prev); height: 1.5px; }
.stat-main-body { padding: 1rem 1rem .75rem; }
.stat-chart { margin: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: 220px auto; column-gap: .6rem; }
.stat-chart-y { position: relative; min-width: 2.2rem; font-size: .72rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.stat-chart-y span { position: absolute; right: 0; transform: translateY(-50%); line-height: 1; }
.stat-chart-plot { position: relative; }
.stat-chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.stat-chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.stat-chart-svg .area { fill: var(--stat-wash); }
.stat-chart-svg .line { fill: none; stroke: var(--stat-series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.stat-chart-svg .prev { fill: none; stroke: var(--stat-prev); stroke-width: 1.5; stroke-linejoin: round; }
.stat-chart-svg .crosshair { stroke: var(--fg-muted); stroke-width: 1; }
.stat-chart-dot, .stat-chart-hover {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--stat-series); box-shadow: 0 0 0 2px var(--panel); pointer-events: none;
}
.stat-chart-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  padding: .45rem .6rem; font-size: .78rem; white-space: nowrap; line-height: 1.45;
}
.stat-chart-tip strong { font-size: .95rem; }
.stat-chart-tip .tip-row { display: flex; align-items: center; gap: .45rem; }
.stat-chart-tip .tip-date { color: var(--fg-muted); }
.stat-chart-x { grid-column: 2; position: relative; height: 1.5rem; font-size: .72rem; color: var(--fg-muted); }
.stat-chart-x span { position: absolute; top: .4rem; transform: translateX(-50%); white-space: nowrap; }
.stat-chart-x span:first-child { transform: none; }
.stat-chart-x span:last-child { transform: translateX(-100%); }
.stat-table { margin-top: .5rem; font-size: .82rem; }
.stat-table summary { cursor: pointer; color: var(--fg-muted); }
.stat-table table { margin-top: .5rem; box-shadow: none; }
.stat-table th, .stat-table td { padding: .35rem .7rem; display: table-cell !important; }
.stat-table .num, .stat-list .num { text-align: right; font-variant-numeric: tabular-nums; }

/* panels */
.stat-section { font-size: 1rem; margin: 1.6rem 0 .7rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 1rem; align-items: start; }
.stat-wide { grid-column: 1 / -1; }
.stat-list { padding: .35rem .5rem .5rem; }
.stat-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--cols), minmax(3.6rem, auto)); gap: .75rem; align-items: center; padding: 0 .5rem; min-height: 2rem; font-size: .85rem; }
.stat-row-head { min-height: 1.8rem; font-size: .72rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-label { position: relative; min-width: 0; padding: .3rem .45rem; margin-left: -.45rem; }
.stat-bar { position: absolute; inset: 1px auto 1px 0; background: var(--stat-bar); border-radius: 0 4px 4px 0; }
.stat-label-text { position: relative; display: block; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.stat-link { color: var(--fg); text-decoration: none; }
.stat-link:hover { color: var(--link); text-decoration: underline; }
.stat-sub { font-size: .74rem; color: var(--fg-muted); font-weight: 400; }
.stat-label-text .stat-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-flag { font-size: 1rem; line-height: 1; }
.stat-empty { padding: .5rem; margin: 0; }
.stat-note { padding: 0 1rem .8rem; margin: 0; font-size: .78rem; }
.stat-list code { font-size: .8rem; }
.stat-row + .stat-row:not(.stat-row-head) { border-top: 1px solid transparent; }

/* conversions */
.stat-conv { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 1rem; padding: .6rem .6rem 0; align-items: start; }
.stat-conv-figures { display: flex; flex-direction: column; gap: .8rem; padding: .4rem .5rem; }
.stat-conv-figures > div { display: flex; flex-direction: column; }
.stat-conv-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .5rem 1rem; border-top: 1px solid var(--border); margin: .6rem .6rem 0; padding-top: .3rem; }

/* speed */
.stat-vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-vital .stat-tile-label { min-height: 2.4em; }
.stat-rating { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; }
.stat-rating i { font-style: normal; display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; font-size: .68rem; color: #fff; }
.stat-rating.is-good { color: var(--stat-good); } .stat-rating.is-good i { background: var(--stat-good); }
.stat-rating.is-fair { color: var(--stat-fair); } .stat-rating.is-fair i { background: var(--stat-fair); }
.stat-rating.is-poor { color: var(--stat-poor); } .stat-rating.is-poor i { background: var(--stat-poor); }
[data-theme="dark"] .stat-rating i { color: #0a0a0a; }
.stat-foot { margin: 2rem 0 1rem; max-width: 60rem; font-size: .8rem; }

/* settings */
.stat-settings { display: grid; gap: 1.25rem; max-width: 52rem; }
.stat-goals { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-goals li + li { border-top: 1px solid var(--border); }
.stat-goals summary { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; padding: .6rem .8rem; cursor: pointer; list-style: none; }
.stat-goals summary::-webkit-details-marker { display: none; }
.stat-goals summary .linkish { margin-left: auto; }
.stat-goals details[open] { padding-bottom: .8rem; }
.stat-goals details > form, .stat-goals details > form + form { padding: 0 .8rem; }
.stat-goal-form { max-width: none; }
.stat-kind { flex-direction: row; flex-wrap: wrap; gap: .4rem 1.2rem; }
.stat-kind legend { font-weight: 550; padding: 0 .3rem; }
.stat-kind label.inline { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; }
.stat-subhead { font-size: .9rem; margin: .6rem 0 0; }

@media (max-width: 700px) {
  .stat-head-actions { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-conv { grid-template-columns: 1fr; }
  .stat-chart { grid-template-rows: 180px auto; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .stat-tile-value { font-size: 1.35rem; }
}

/* The dashboard widget */
.stat-glance { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stat-glance div { display: flex; flex-direction: column; }
.stat-glance strong { font-size: 1.25rem; }
