/* ---------- Tokens ---------- */
:root {
  --bg: #f7f7f8;
  --hover: #eeeff2;
  --border: #e3e4e8;
  --gridline: #e9eaee;
  --fg: #15171c;
  --fg-2: #5b6070;
  --fg-3: #656a7e; /* axis labels */
  --accent: #2b63d9;
  --series-2: #c98a3a;
  --up: #25794d;
  --down: #b4463a;
  --skeleton: #e6e7eb;
  --field: #ffffff;
  --tooltip-up: #5bbe86; /* change colours inside the dark tooltip */
  --tooltip-down: #e07a6a;

  --radius: 6px;
  --gutter: 48px;
  --header-h: 56px;
  --max-width: 1200px;
}

/* Dark mode is designed, not inverted: same token names, new values */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141519;
    --hover: #1c1e24;
    --border: #26282f;
    --gridline: #22242b;
    --fg: #edeef1;
    --fg-2: #a4a8b4;
    --fg-3: #8a8f9c;
    --accent: #6e96f2;
    --series-2: #e0a45a;
    --up: #5bbe86;
    --down: #e07a6a;
    --skeleton: #23252c;
    --field: #1c1e24;
    --tooltip-up: #25794d;
    --tooltip-down: #b4463a;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 24px;
  }
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: "Geist", sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  font-variant-numeric: tabular-nums; /* every number lines up */
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.logo:hover {
  text-decoration: none;
}

.header-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.header-nav a {
  color: var(--fg-2);
  white-space: nowrap;
}

.header-nav a:hover {
  color: var(--fg);
  text-decoration: none;
}

/* the page you are on */
.header-nav a[aria-current="page"] {
  color: var(--fg);
  font-weight: 500;
}

/* Search in the middle of the header (company and companies pages) */
.header-search {
  flex: 0 1 320px;
  margin: 0 auto;
}

.header-search + .header-nav {
  margin-left: 0;
}

.sign-up {
  border: 1px solid rgba(227, 228, 232, 0.5);
  padding: 10px 12px;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.button:hover {
  background: var(--hover);
}

.button.icon-only {
  width: 32px;
  padding: 0;
  justify-content: center;
}

/* ---------- Segmented toggles (Quarterly / Annual, 3Y / 5Y ...) ---------- */
.toggle-group {
  display: flex;
  gap: 2px;
}

.toggle {
  border: none;
  background: transparent;
  color: var(--fg-2);
  font-size: 13px;
  padding: 3px 9px;
  border-radius: var(--radius);
}

.toggle:hover {
  color: var(--fg);
}

.toggle[aria-pressed="true"] {
  background: var(--hover);
  color: var(--fg);
}

.range-select {
  display: none; /* phone only — see media query */
  border: none;
  background: transparent;
  color: var(--fg-2);
  font-size: 13px;
}

/* ---------- Search ---------- */
.search {
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box svg {
  color: var(--fg-3);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--fg-3);
}

/* hide the browser's own "x" on type="search" */
.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-box kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--fg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}

.search-results[hidden] {
  display: none;
}

.search-results li a {
  display: grid;
  grid-template-columns: 1fr 56px 88px;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 4px;
  color: var(--fg);
  font-size: 13px;
}

.search-results li a:hover,
.search-results li a[aria-selected="true"] {
  background: var(--hover);
  text-decoration: none;
}

.search-results .ticker,
.search-results .sector {
  color: var(--fg-2);
}

.search-results .empty {
  padding: 7px 8px;
  font-size: 13px;
  color: var(--fg-2);
}

/* ---------- Tag: a small label (a sector, "This week") ---------- */
.tag {
  padding: 3px 8px;
  border-radius: var(--radius);
  background: var(--gridline);
  color: var(--fg-2);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Chart frame ----------
   Order is always: name + controls row, headline row, plot, source line. */
.chart-frame {
  position: relative;
}

.chart-top {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 28px;
}

.chart-name {
  font-size: 15px;
  font-weight: 500;
}

.chart-name .meta {
  margin-left: 6px;
  font-weight: 400;
  font-size: 13px;
  color: var(--fg-2);
}

.chart-note {
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-2);
}

.chart-link {
  margin-left: auto;
  font-size: 13px;
}

.chart-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.chart-headline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 12px;
  margin: 2px 0 8px;
}

.chart-value {
  font-size: 48px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.chart-period {
  font-size: 13px;
  color: var(--fg-2);
}

.change {
  font-size: 13px;
  white-space: nowrap;
}

/* two changes side by side: on the quarter before, on a year before */
.chart-changes {
  display: inline-flex;
  gap: 12px;
}

.change.up {
  color: var(--up);
}

.change.down {
  color: var(--down);
}

.change.flat {
  color: var(--fg-2);
}

.chart-plot {
  position: relative;
  height: 280px;
}

.chart-source {
  margin-top: 8px;
  font-size: 12px;
  color: var(--fg-2);
}

/* Compact size used in the company-page grid */
.chart-frame.compact .chart-value {
  font-size: 32px;
}

.chart-frame.compact .chart-plot {
  height: 180px;
}

/* ---------- Chart states: loading / empty / error ---------- */
.skeleton {
  background: var(--skeleton);
  border-radius: 4px;
}

.skeleton-line {
  height: 12px;
}

.skeleton-value {
  height: 40px;
  width: 140px;
  margin: 10px 0 8px;
}

.skeleton-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100%;
  padding: 0 0 22px 48px;
}

.skeleton-bars span {
  flex: 1;
  background: var(--skeleton);
  border-radius: 2px;
}

.chart-message {
  position: absolute;
  inset: 0 0 22px 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--gridline);
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
  color: var(--fg-2);
}

.chart-message span {
  background: var(--bg);
  padding: 0 12px;
}

.chart-message button {
  border: none;
  background: none;
  padding: 0 0 0 4px;
  color: var(--accent);
}

.dash {
  display: block;
  width: 26px;
  height: 2px;
  margin: 26px 0 22px;
  background: var(--fg-3);
}

/* ---------- Chart tooltip ---------- */
.chart-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
}

.chart-tooltip .tt-period {
  opacity: 0.7;
}

.chart-tooltip .tt-value {
  font-size: 13px;
  font-weight: 500;
}

.chart-tooltip .change.up {
  color: var(--tooltip-up);
}

.chart-tooltip .change.down {
  color: var(--tooltip-down);
}

.chart-tooltip .change.flat {
  color: inherit;
  opacity: 0.7;
}

/* ---------- Footer ---------- */
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding-top: 32px;
  padding-bottom: 48px;
  font-size: 12px;
  color: var(--fg-2);
}

.site-footer nav {
  margin-left: auto;
  display: flex;
  gap: 16px;
}

.site-footer a {
  color: var(--fg-2);
}

/* ---------- Phone (the one breakpoint) ---------- */
@media (max-width: 640px) {
  .chart-value {
    font-size: 40px;
  }

  .chart-frame.compact .chart-value {
    font-size: 32px;
  }

  /* the two changes always take a line of their own, so a headline is the
     same height whatever figures it is showing */
  .chart-changes {
    flex: 0 0 100%;
    font-size: 13px;
  }

  /* even when there is no change to show (a loss a year ago, say): an
     invisible character keeps the line */
  .chart-changes:empty::before {
    content: "\200b";
  }

  .range-buttons {
    display: none;
  }

  .range-select {
    display: block;
  }

  .chart-plot {
    height: 220px;
  }

  .site-footer nav {
    margin-left: 0;
  }

  .site-header .container {
    gap: 16px;
  }

  .header-search {
    flex: 1;
    min-width: 0; /* let the box shrink to make room for the links beside it */
  }

  .header-search kbd {
    display: none;
  }

  .header-search .search-results li a {
    grid-template-columns: 1fr 56px;
  }

  .header-search .search-results .sector {
    display: none;
  }
}
