/* ==========================================================================
   companies.css — styles only the companies page uses
   ========================================================================== */

.companies {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 32px;
  padding-bottom: 64px;
}

/* Text that screen readers announce but nobody sees */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Shown on phones only; see the media query at the bottom */
.phone-only {
  display: none;
}

/* ---------- Title row ---------- */
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.page-note {
  font-size: 13px;
  color: var(--fg-3);
}

.page-footnote {
  font-size: 12px;
  color: var(--fg-3);
}

/* ---------- Filter box and sector chips ---------- */
.tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.filter {
  width: 100%;
  max-width: 320px;
}

.filter input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  font-size: 13px;
  outline: none;
}

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

.filter input:focus {
  border-color: var(--accent);
}

.chips {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chip {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-3);
  font-size: 13px;
  line-height: 18px;
  white-space: nowrap;
}

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

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

/* ---------- The table ----------
   Columns: company, ticker, sector, latest revenue + changes, last report, arrow */
.company-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.company-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px 120px 240px 180px 20px;
  align-items: center;
  gap: 20px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

a.company-row:hover {
  background: var(--hover);
  text-decoration: none;
}

.company-row-head {
  min-height: 36px;
  font-size: 12px;
  color: var(--fg-3);
}

.co-name {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.co-name-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.co-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
}

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

.co-ticker-inline {
  font-size: 13px;
  color: var(--fg-3);
}

.co-sub {
  font-size: 12px;
  color: var(--fg-3);
}

/* The amount, its change on the quarter before, its change on a year before.
   Each has its own column, so the figures line up down the page and sit
   under their headings. */
.co-revenue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 64px;
  justify-items: end;
  align-items: baseline;
  gap: 12px;
}

.co-revenue .amount {
  font-size: 15px;
  font-weight: 500;
}

.co-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
}

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

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

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

.co-report {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg-2);
}

.co-arrow {
  color: var(--fg-3);
}

/* ---------- Loading, nothing found, couldn't load ---------- */
.company-row .skeleton {
  height: 14px;
}

.company-row .skeleton.name {
  width: 170px;
}

.company-row .skeleton.ticker {
  width: 40px;
}

.company-row .skeleton.sector {
  width: 76px;
}

.company-row .skeleton.revenue {
  width: 110px;
  justify-self: end;
}

.company-row .skeleton.report {
  width: 100px;
}

.company-message {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-2);
}

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

/* ---------- Narrow window ----------
   Not enough room for every column, so the last report (the fifth) goes
   and the company name gets its space */
@media (max-width: 900px) {
  .company-row {
    grid-template-columns: minmax(0, 1fr) 80px 120px 240px 20px;
  }

  .company-row > :nth-child(5) {
    display: none;
  }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  .companies {
    padding-top: 20px;
    padding-bottom: 48px;
  }

  /* nowrap matters: a wrapping column lets the chips row grow to its full
     width and push the page wider than the screen */
  .tools {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  /* company (with ticker, sector and report date beneath), revenue, arrow */
  .company-row {
    grid-template-columns: minmax(0, 1fr) auto 16px;
    gap: 12px;
    min-height: 64px;
  }

  /* no headings on a phone, so only the amount and the change on a year before */
  .co-revenue {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  .not-phone {
    display: none !important;
  }

  .phone-only {
    display: flex;
  }
}
