/* Hub traffic board — one dark instrument panel on the cream hub home.
   Matches the portfolio skin (cream/ink/signal red) and stays readable in
   both the light page and the dark chart panel. */

.hub-traffic {
  padding: 48px 0 12px;
  border-top: 1px solid #d6cbbc;
  background:
    radial-gradient(46% 40% at 92% 0%, rgba(255, 77, 46, .09), transparent 70%),
    #f2ece2;
}

/* The three chart blocks are stacked by the page gutters; zero the shared
   .wrap padding here so each gap is exactly the 12px step below. */
.hub-traffic .wrap { padding-bottom: 0; }
.hub-audience .wrap { padding-top: 0; }

.traffic-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.traffic-intro .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: #6b625b !important;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.traffic-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9beb1;
  box-shadow: 0 0 0 0 rgba(255, 77, 46, .5);
}

.traffic-pulse.is-live {
  background: #ff4d2e;
  animation: traffic-pulse 2.4s ease-out infinite;
}

@keyframes traffic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 46, .45); }
  70% { box-shadow: 0 0 0 9px rgba(255, 77, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 46, 0); }
}

.traffic-intro h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 .16em;
  margin: 0;
  font-size: clamp(34px, 4.6vw, 62px);
  line-height: .94;
  letter-spacing: -.045em;
  font-weight: 800;
}

.traffic-intro h2 em {
  font-family: "Instrument Serif", Georgia, serif !important;
  font-style: italic;
  font-weight: 400;
  color: #ff4d2e !important;
}

.traffic-ranges {
  display: inline-flex;
  border: 1px solid #171310;
  border-radius: 2px;
  overflow: hidden;
  background: #fffaf1;
}

.traffic-range {
  appearance: none;
  border: 0;
  border-right: 1px solid #d6cbbc;
  background: transparent;
  color: #6b625b;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 6px 10px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.traffic-range:last-child { border-right: 0; }
.traffic-range:hover { background: #f7ddcb; color: #171310; }
.traffic-range:focus-visible { outline: 2px solid #ff4d2e; outline-offset: -2px; }
.traffic-range[aria-pressed="true"] { background: #171310; color: #fffaf1; }

.traffic-notice {
  margin: 0 0 18px;
  padding: 10px 14px;
  border: 1px solid #e33d21;
  background: #fff3ee;
  color: #8c2c17;
  font-size: 13.5px;
}

.traffic-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.traffic-stat {
  background: #fffaf1;
  border: 1px solid #171310;
  border-radius: 2px;
  padding: 11px 14px 10px;
}

.traffic-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.traffic-stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #6b625b;
}

.traffic-trend {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .02em;
  padding: 2px 6px;
  border-radius: 2px;
  background: #efe7db;
  color: #6b625b;
  white-space: nowrap;
}

.traffic-trend-up { background: #e3f0e6; color: #1e6b45; }
.traffic-trend-down { background: #fbe6e0; color: #a93418; }

.traffic-stat-value {
  margin: 6px 0 2px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  color: #171310;
}

.traffic-unit { font-size: .55em; margin-left: 2px; letter-spacing: 0; }

.traffic-stat-sub { margin: 0; font-size: 11.5px; color: #6b625b; }

/* ---- the chart panel -------------------------------------------------- */

.hub-traffic.is-loading .traffic-panel,
.hub-traffic.is-loading .traffic-stats { opacity: .55; transition: opacity .12s ease; }

.traffic-panel {
  margin: 0;
  padding: 15px 18px 12px;
  background: #171310;
  border: 1px solid #171310;
  border-radius: 2px;
  color: #f2ece2;
}

.traffic-panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.traffic-panel-title h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #f2ece2;
}

.traffic-scope {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .04em;
  color: #9c9186;
}

.traffic-legend {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: #c9beb1;
}

.traffic-legend li { display: inline-flex; align-items: center; gap: 7px; }

/* Range buttons sit in each chart's top-right corner, left of its legend. */
.traffic-panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

/* That control is on a dark instrument panel, so it inverts. */
.traffic-panel .traffic-ranges,
.audience-panel .traffic-ranges {
  border-color: rgba(242, 236, 226, .28);
  background: transparent;
}

.traffic-panel .traffic-range,
.audience-panel .traffic-range {
  border-right-color: rgba(242, 236, 226, .18);
  color: #c9beb1;
}

.traffic-panel .traffic-range:hover,
.audience-panel .traffic-range:hover {
  background: rgba(242, 236, 226, .14);
  color: #fffaf1;
}

.traffic-panel .traffic-range[aria-pressed="true"],
.audience-panel .traffic-range[aria-pressed="true"] {
  background: #fffaf1;
  color: #171310;
}

/* The chart and the most-viewed column share one row. */
.traffic-panel-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  column-gap: 22px;
  align-items: start;
}

.traffic-most {
  margin-top: 12px;
  padding-left: 18px;
  border-left: 1px solid rgba(242, 236, 226, .14);
  min-width: 0;
}

.traffic-most-title {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #9c9186;
}

/* One compact line per page: site, path, hits. */
.traffic-most .traffic-page-list {
  min-width: 0;
}

.traffic-most .traffic-page-list li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  padding: 3px 0;
  border-bottom-color: rgba(242, 236, 226, .1);
}

.traffic-most .traffic-page-site {
  flex: 0 0 auto;
  color: #ff8a72;
  font-size: 8.5px;
}

.traffic-most .traffic-page-path {
  flex: 1 1 auto;
  min-width: 0;
  color: #f2ece2;
  font-size: 11px;
}

.traffic-most .traffic-page-hits {
  flex: 0 0 auto;
  color: #9c9186;
  font-size: 10.5px;
}

.traffic-most-note {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  color: #8d8278;
}

.traffic-swatch {
  display: inline-block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.traffic-swatch-visits { background: #ff4d2e; }
.traffic-swatch-visitors { background: #f2ece2; }

.traffic-chart {
  display: block;
  margin-top: 12px;
}

/* ECharts owns the plot: one canvas, axes and grid drawn inside it. The CSP
   forbids inline style attributes, so every size comes from these classes. */
.echart {
  width: 100%;
  height: 260px;
}

.echart-audience { height: 180px; }

.hub-traffic.is-loading .echart,
.hub-audience.is-loading .echart {
  opacity: .55;
  transition: opacity .2s ease;
}

.chart-tip {
  display: block;
  min-width: 132px;
  color: #171310;
  font: 12px/1.5 system-ui, sans-serif;
}

.chart-tip-date {
  display: block;
  margin-bottom: 5px;
  font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6b625b;
}

.chart-tip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 2px 0;
  white-space: nowrap;
}

.chart-tip-row b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.chart-tip-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

.chart-tip-dot.is-visits { background: #ff5b3c; }
.chart-tip-dot.is-visitors { background: #f2ece2; box-shadow: inset 0 0 0 1px rgba(23, 19, 16, .35); }
.chart-tip-dot.is-facebook { background: #7aa7ff; }
.chart-tip-dot.is-youtube { background: #ff5b3c; }

@media (max-width: 720px) {
  .echart { height: 210px; }
  .echart-audience { height: 150px; }
}

.traffic-yaxis {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  min-height: 150px;
}

/* Fixed tick slots: five rows (0/25/50/75/100%) and six columns. The hub CSP
   forbids inline styles, so positions come from nth-child, not from HTML. */
.traffic-yaxis span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: #8d8278;
  font-variant-numeric: tabular-nums;
}

.traffic-yaxis span:nth-child(1) { top: 0; transform: translateY(0); }
.traffic-yaxis span:nth-child(2) { top: 25%; }
.traffic-yaxis span:nth-child(3) { top: 50%; }
.traffic-yaxis span:nth-child(4) { top: 75%; }
.traffic-yaxis span:nth-child(5) { top: 100%; transform: translateY(-100%); }

.traffic-plot {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  height: clamp(160px, 13vw, 190px);
  touch-action: pan-y;
}

.traffic-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.traffic-gridlines line {
  stroke: rgba(242, 236, 226, .13);
  stroke-width: 1;
}

.traffic-area { fill: url(#trafficFill); stroke: none; }

.traffic-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.traffic-line-visits { stroke: #ff5b3c; stroke-width: 2.4; }
.hub-traffic.is-loading .traffic-line { opacity: .5; }
.traffic-line-visitors { stroke: #f2ece2; stroke-width: 1.6; opacity: .9; }

.traffic-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(242, 236, 226, .38);
  pointer-events: none;
}

.traffic-marker {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: 2px solid #171310;
}

.traffic-marker-visits { background: #ff5b3c; }
.traffic-marker-visitors { background: #f2ece2; width: 7px; height: 7px; }

.traffic-tip {
  position: absolute;
  z-index: 3;
  min-width: 148px;
  padding: 9px 11px;
  background: #fffaf1;
  border: 1px solid #171310;
  border-radius: 2px;
  color: #171310;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -118%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}

.traffic-tip-date {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6b625b;
}

.traffic-tip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 2px 0;
  font-size: 12px;
}

.traffic-tip-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

.traffic-xaxis {
  position: relative;
  grid-column: 2;
  grid-row: 2;
}

.traffic-xaxis span {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: #8d8278;
  white-space: nowrap;
}

.traffic-xaxis span:nth-child(1) { left: 0; transform: translateX(0); }
.traffic-xaxis span:nth-child(2) { left: 20%; }
.traffic-xaxis span:nth-child(3) { left: 40%; }
.traffic-xaxis span:nth-child(4) { left: 60%; }
.traffic-xaxis span:nth-child(5) { left: 80%; }
.traffic-xaxis span:nth-child(6) { left: 100%; transform: translateX(-100%); }

.traffic-datanote {
  margin: 10px 0 0;
  padding: 6px 9px;
  border-left: 2px solid #ff4d2e;
  background: rgba(255, 77, 46, .08);
  font-size: 11px;
  line-height: 1.45;
  color: #c9beb1;
}

.traffic-datanote span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #ff8a72;
  margin-right: 6px;
}

.traffic-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(242, 236, 226, .14);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: #9c9186;
}

.traffic-caption b { color: #f2ece2; font-weight: 600; }

/* ---- page rows -------------------------------------------------------- */

.traffic-links li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 7px 0;
  border-bottom: 1px solid #ece2d3;
}

.traffic-links li:last-child { border-bottom: 0; }

.traffic-page-site {
  grid-column: 1;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #a93418;
}

.traffic-page-path {
  grid-column: 1;
  font-size: 12px;
  color: #171310;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.traffic-page-hits {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #6b625b;
  font-variant-numeric: tabular-nums;
}

/* ---- data table ------------------------------------------------------- */

.traffic-details {
  margin-top: 12px;
  border-top: 1px solid #d6cbbc;
  padding-top: 10px;
}

.traffic-details summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #6b625b;
}

.traffic-details summary:hover { color: #171310; }

.traffic-table-wrap { max-height: 340px; overflow: auto; margin-top: 12px; }

.traffic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.traffic-table caption {
  caption-side: top;
  text-align: left;
  padding-bottom: 8px;
  font-size: 11px;
  color: #6b625b;
}

.traffic-table th,
.traffic-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e7dccd;
  text-align: right;
}

.traffic-table th:first-child,
.traffic-table td:first-child { text-align: left; }

.traffic-table thead th {
  position: sticky;
  top: 0;
  background: #f2ece2;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6b625b;
  font-weight: 600;
}

.traffic-table tbody th { font-weight: 500; color: #171310; }

.traffic-fade { animation: traffic-fade .35s ease; }

@keyframes traffic-fade {
  from { opacity: .35; }
  to { opacity: 1; }
}

@media (max-width: 980px) {
  .traffic-panel-body { grid-template-columns: 1fr; }
  .traffic-most {
    margin-top: 10px;
    padding: 10px 0 0;
    border-left: 0;
    border-top: 1px solid rgba(242, 236, 226, .14);
  }
  .traffic-most .traffic-page-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
  }
}

@media (max-width: 780px) {
  .hub-traffic { padding: 40px 0 12px; }
  .traffic-head { flex-direction: column; align-items: stretch; gap: 18px; }
  .traffic-intro h2 { display: block; }
  .traffic-title-lead { display: block; }
  .traffic-ranges { width: auto; }
  .traffic-range { flex: 0 0 auto; text-align: center; }
  .traffic-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .traffic-panel { padding: 13px 12px 10px; }
  .traffic-chart { grid-template-columns: 34px minmax(0, 1fr); column-gap: 8px; }
  .traffic-yaxis { min-height: 130px; }
  .traffic-plot { height: 150px; }
  .traffic-range { padding: 5px 7px; }
  .traffic-panel-tools { gap: 8px; }
  .traffic-legend { gap: 12px; }
  .traffic-most .traffic-page-list { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  /* Three x labels only: 0%, 40%, 80% — the rest would collide. */
  .traffic-xaxis span:nth-child(2),
  .traffic-xaxis span:nth-child(4),
  .traffic-xaxis span:nth-child(6) { display: none; }
}

@media (max-width: 560px) {
  .traffic-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .traffic-stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .traffic-pulse.is-live { animation: none; }
  .traffic-fade { animation: none; }
}
