/* ==========================================================================
   TRAFFIC, the funnel page.

   Self-contained apart from the design tokens. It borrows .panel and .label
   from components.css and admin.css because this page sits inside the same
   admin shell as the dashboard, and everything else it needs is defined here
   so that nothing on the storefront has to carry the weight of a page only
   the owner ever opens.

   Bars are plain divs with a percentage width. No chart library: a funnel is
   eight horizontal rectangles, and shipping a drawing framework to the owner
   of a coffee shop to draw eight rectangles would be absurd.
   ========================================================================== */

/* --- The toolbar at the top ------------------------------------------------ */
.traffic__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: var(--rule);
}

.traffic__range { display: flex; gap: 0.5rem; }

.traffic__rangebtn {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: var(--rule);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: color 120ms linear, border-color 120ms linear;
}

.traffic__rangebtn:hover { color: var(--text); border-color: var(--rule-color-strong); }

.traffic__rangebtn[aria-pressed="true"] {
  color: var(--c-black);
  background: var(--text);
  border-color: var(--text);
}

.traffic__total,
.traffic__hint {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: var(--lh-mono);
  color: var(--text-faint);
  margin: 0;
}

.traffic__hint { margin-top: 0.75rem; }

.traffic__empty {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-faint);
  margin: 0;
}

/* --- Headline numbers ----------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1px;
  background: var(--rule-color);
  border: var(--rule);
  margin-bottom: 1.5rem;
}

.tile { background: var(--bg); padding: 1.25rem 1rem; }

.tile__n {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-h3);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
  margin: 0;
}

.tile__l {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0.4rem 0 0;
}

/* --- The funnel ----------------------------------------------------------- */
.funnel { list-style: none; margin: 0; padding: 0; }

.funnel__row { padding: 0.9rem 0; border-bottom: var(--rule); }
.funnel__row:last-child { border-bottom: 0; }

.funnel__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.funnel__label {
  font-family: var(--font-body);
  font-size: var(--fs-small);
  color: var(--text);
}

.funnel__count {
  font-family: var(--font-mono);
  font-weight: var(--fw-medium);
  font-size: var(--fs-body);
  color: var(--text);
}

.funnel__track { height: 0.5rem; background: var(--c-porcelain-08); }

.funnel__bar {
  height: 100%;
  background: var(--text);
  /* The bar is the only moving part, so it is the only thing that animates.
     A funnel redrawn on a range change should read as the same chart with
     different numbers, not as a new page. */
  transition: width 240ms ease-out;
}

.funnel__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: 0.45rem;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-faint);
}

.funnel__lost { color: var(--accent); }

/* --- Two-column comparisons ----------------------------------------------- */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  background: var(--rule-color);
  border: var(--rule);
}

.split__col { background: var(--bg); padding: 1.25rem 1rem; }

.split__title {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.75rem;
}

.split__big {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-h3);
  line-height: var(--lh-tight);
  margin: 0 0 0.5rem;
}

.split__sub,
.split__note {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: var(--lh-mono);
  margin: 0.2rem 0 0;
  color: var(--text-muted);
}

.split__note { color: var(--text-faint); }

/* --- The written reading -------------------------------------------------- */
.verdict {
  font-family: var(--font-body);
  font-size: var(--fs-small);
  line-height: var(--lh-snug);
  color: var(--text-muted);
  margin: 1.25rem 0 0;
  padding-left: 0.85rem;
  border-left: 2px solid var(--rule-color-strong);
}

.verdict strong { color: var(--text); }
.verdict code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  color: var(--text);
  /* Long enough to wrap on a phone, and it must wrap rather than widen the
     page: this is the one place a URL is printed in full. */
  word-break: break-all;
}

.verdict--bad { border-left-color: var(--accent); }
.verdict--good { border-left-color: var(--text); }
.verdict--thin { border-left-style: dashed; color: var(--text-faint); }

/* --- Ranked lists, used for sources and products -------------------------- */
.ranks { list-style: none; margin: 0; padding: 0; }

.ranks__row {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: var(--rule);
}

.ranks__row:last-child { border-bottom: 0; }

.ranks__name {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranks__track { height: 0.4rem; background: var(--c-porcelain-08); }
.ranks__bar { display: block; height: 100%; background: var(--text); }

.ranks__n {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-muted);
  min-width: 2.5ch;
  text-align: right;
}

/* --- Day by day ----------------------------------------------------------- */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 5rem;
  border-bottom: var(--rule);
}

.spark__col { flex: 1 1 0; min-width: 2px; display: flex; align-items: flex-end; height: 100%; }
.spark__bar { width: 100%; background: var(--text); }

@media (max-width: 30rem) {
  .ranks__row { grid-template-columns: minmax(4.5rem, 7rem) 1fr auto; }
  .traffic__bar { flex-direction: column; align-items: stretch; }
}
