/* /stock/{TICKER}: one company's factor profile. Uses the site's tokens; blue (--more) leans
   toward a factor, ochre (--less) away from it, as on /portfolio and /market. */

.sp {
  padding-bottom: var(--space-12);
}

.sp .container {
  max-width: 72rem;
}

.sp-head {
  padding-top: var(--space-6);
}

.sp-crumb {
  margin: 0 0 var(--space-3);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.sp-crumb a {
  color: inherit;
}

.sp-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.sp-head h1 {
  margin: 0;
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

.sp-ticker {
  margin-right: var(--space-2);
  color: var(--fg-muted);
  font-size: 0.7em;
  font-weight: 600;
  vertical-align: 0.12em;
}

.sp-meta {
  margin: var(--space-1) 0 0;
  color: var(--fg-muted);
}

.sp-actions {
  display: flex;
  gap: var(--space-2);
}

.sp-lead {
  max-width: 48rem;
  margin: var(--space-4) 0 0;
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

.sp-stats {
  display: flex;
  flex-wrap: wrap;
  margin: var(--space-5) 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Each cell draws its left and top rules; the strip's own border covers the edges. */
.sp-stats > div {
  flex: 1 1 9.5rem;
  margin: -1px 0 0 -1px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.sp-stats dt {
  color: var(--fg-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.sp-stats dd {
  margin: var(--space-1) 0 0;
  font-family: var(--font-figures, inherit);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}

.sp-section {
  padding-top: var(--space-10);
}

.sp-section h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xl);
}

.sp-h-note {
  margin-left: var(--space-2);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 400;
}

.sp-section-head p {
  max-width: 52rem;
}

.sp-note {
  margin: var(--space-2) 0 0;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.sp-lead-line {
  margin: 0 0 var(--space-3);
}

.more {
  --tone: var(--more);
}

.less {
  --tone: var(--less);
}

.sp .num.more,
.sp dd.more,
.sp-z.more,
.sp-chg.more {
  color: color-mix(in srgb, var(--more) 85%, var(--fg));
}

.sp .num.less,
.sp dd.less,
.sp-z.less,
.sp-chg.less {
  color: color-mix(in srgb, var(--less) 85%, var(--fg));
}

.sp-chg.flat,
.sp-z.flat {
  color: var(--fg-muted);
}

/* ---- chart ---- */
.sp-chart {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  margin: 0;
}

.sp-chart svg {
  display: block;
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 13rem;
  overflow: visible;
  touch-action: pan-y;
}

.sp-chart-empty {
  height: 14.25rem;
}

.sp-line {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.sp-area {
  fill: color-mix(in srgb, var(--fg) 6%, transparent);
}

.sp-chart-y {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-left: var(--space-2);
  color: var(--fg-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.sp-chart-x {
  position: relative;
  grid-column: 1;
  height: 1.25rem;
  color: var(--fg-faint);
  font-size: var(--text-xs);
}

.sp-chart-x span {
  position: absolute;
  top: var(--space-1);
  transform: translateX(-50%);
  white-space: nowrap;
}

.sp-chart-tip {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0.2em 0.5em;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.sp-chart-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--fg);
  pointer-events: none;
}

.sp-chart-empty {
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--fg-muted);
}

/* ---- factor rows ---- */
.sp-factor-head,
.sp-factor {
  display: grid;
  grid-template-columns: minmax(12rem, 1.3fr) minmax(8rem, 1fr) 15rem 5.5rem;
  gap: var(--space-2) var(--space-4);
  align-items: center;
}

.sp-factor-head {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-strong);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.sp-hist-head {
  text-align: right;
}

.sp-factors {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-factor {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.sp-factor[role="button"] {
  cursor: pointer;
}

.sp-factor[role="button"]:hover {
  background: color-mix(in srgb, var(--fg) 3%, transparent);
}

.sp-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sp-name a {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}

.sp-name a:hover {
  text-decoration: underline;
}

.sp-words {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.sp-missing {
  font-style: italic;
}

.sp-why {
  color: var(--fg-faint);
  font-size: var(--text-xs);
}

.sp-bar {
  position: relative;
  display: block;
  height: 0.625rem;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.sp-bar::after {
  content: "";
  position: absolute;
  inset-block: -3px;
  left: 50%;
  width: 1px;
  background: var(--border-strong);
}

.sp-bar-fill {
  position: absolute;
  inset-block: 0;
  border-radius: var(--radius-sm);
  background: var(--tone, var(--neutral));
}

.sp-nums {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sp-factor-head .sp-nums {
  font-variant-numeric: normal;
  white-space: nowrap;
}

.sp-hist {
  text-align: right;
}

.sp-hist svg {
  overflow: visible;
}

.sp-hist path {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.4;
}

.sp-hist circle {
  fill: var(--fg);
}

.sp-hist .zero {
  stroke: var(--border-strong);
  stroke-dasharray: 2 2;
}

.sp-drivers {
  display: none;
  grid-column: 1 / -1;
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.sp-factor[aria-expanded="true"] .sp-drivers,
.sp-factor:not([role]) .sp-drivers:not(:empty) {
  display: block;
}

/* Free visitors: the history column is the lock below the list. */
.sp:not(.sp-has-history) .sp-hist,
.sp:not(.sp-has-history) .sp-hist-head {
  visibility: hidden;
}

/* ---- Investor locks (the /portfolio pattern) ---- */
.sp-investor {
  margin-top: var(--space-4);
}

.sp-locked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
}

.sp-locked-art {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 1.75rem;
}

.sp-locked-art span {
  width: 6px;
  border-radius: 2px;
  background: var(--border-strong);
}

.sp-locked-art span:nth-child(1) { height: 40%; }
.sp-locked-art span:nth-child(2) { height: 90%; }
.sp-locked-art span:nth-child(3) { height: 65%; }

.sp-locked-copy {
  flex: 1 1 16rem;
  display: flex;
  flex-direction: column;
}

.sp-locked-copy span {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.sp-impact {
  display: grid;
  gap: var(--space-1);
  max-width: 32rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-impact li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  font-variant-numeric: tabular-nums;
}

/* ---- peers ---- */
.sp-peers {
  width: 100%;
  /* Separate borders: with collapsed ones the cells scrolling under the sticky company
     column show through its row rules. */
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.sp-peers th,
.sp-peers td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sp-peers thead th {
  min-width: 4.5rem;
  max-width: 6rem;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  vertical-align: bottom;
  white-space: normal;
}

.sp-peers thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
}

/* A fade at the right edge says the grid scrolls; it goes once the end is reached. */
.sp-peers-wrap {
  position: relative;
}

.sp-peers-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2.5rem;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
  transition: opacity 150ms;
}

.sp-peers-wrap.at-end::after {
  opacity: 0;
}

.sp-peers thead th:first-child {
  text-align: left;
}

.sp-peers tbody th,
.sp-peers thead th:first-child {
  box-shadow: 1px 0 0 var(--border);
}

.sp-peers tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 9rem;
  max-width: 13rem;
  background: var(--bg);
  text-align: left;
  font-weight: 600;
}

.sp-peers tbody th a {
  color: var(--fg);
}

.sp-peer-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 400;
}

.sp-self th,
.sp-self td {
  border-top: 2px solid var(--fg);
  border-bottom: 2px solid var(--fg);
}

.sp-median th,
.sp-median td {
  border-top: 1px solid var(--border-strong);
  color: var(--fg-muted);
}

.sp-cap {
  color: var(--fg-muted);
  text-align: right;
}

.sp-cell {
  min-width: 3.25rem;
  text-align: center;
  background: color-mix(in srgb, var(--tone, transparent) var(--a, 0%), transparent);
}

.sp-cell.none,
.sp-cell.flat {
  color: var(--fg-faint);
}

/* ---- insiders and alerts ---- */
.sp-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--space-10);
}

.sp-two .sp-stats > div {
  flex-basis: 40%;
}

/* No alerts: the insider block takes the row and the alerts are one line under it. */
.sp-two:has(> .sp-no-alerts) {
  grid-template-columns: 1fr;
}

.sp-two:has(> .sp-no-alerts) .sp-stats {
  max-width: 40rem;
}

.sp-no-alerts {
  grid-column: 1 / -1;
  margin-top: var(--space-6);
}

.sp-alerts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-alerts a {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  text-decoration: none;
}

.sp-alerts a:hover span:last-child {
  text-decoration: underline;
}

.sp-alert-when {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.sp-foot {
  padding-top: var(--space-10);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

/* ---- search page ---- */
.sp-find-form {
  display: flex;
  gap: var(--space-2);
  max-width: 36rem;
  margin-top: var(--space-6);
}

.sp-find-form input {
  flex: 1;
  min-width: 0;
  height: 2.75rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-size: max(16px, var(--text-md));
}

.sp-find-results {
  max-width: 36rem;
  margin-top: var(--space-2);
  border-radius: var(--radius);
}

.sp-find-results:not(:empty) {
  border: 1px solid var(--border);
}

.sp-swipe {
  display: none;
}

/* ---- phones ---- */
@media (max-width: 899.98px) {
  .sp-swipe {
    display: block;
  }
  .sp-two {
    grid-template-columns: 1fr;
  }
  .sp-factor-head,
  .sp-factor {
    grid-template-columns: 1fr 10.5rem;
    gap: var(--space-1) var(--space-3);
  }
  .sp-factor-head > span:nth-child(2),
  .sp-hist-head {
    display: none;
  }
  .sp-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .sp-nums {
    grid-column: 2;
    grid-row: 1;
  }
  .sp-factor-head {
    align-items: end;
  }
  .sp-factor-head .sp-nums {
    white-space: normal;
    align-items: end;
  }
  .sp-hist {
    grid-column: 1 / -1;
    text-align: left;
  }
  .sp:not(.sp-has-history) .sp-hist {
    display: none;
  }
  .sp-chart svg {
    height: 9rem;
  }
  .sp-chart-empty {
    height: 10.25rem;
  }
  .sp-head h1 {
    font-size: var(--text-2xl);
  }
  .sp-actions {
    width: 100%;
  }
  .sp-actions .button {
    flex: 1;
    justify-content: center;
  }
  .sp-stats > div {
    flex-basis: 40%;
  }
  .ss-list li a,
  .sp-find-results li a {
    grid-template-columns: 5.5rem 1fr;
  }
}
