/*
 * Equity research home — coverage triage composition.
 *
 * Loaded by index.html only, because the profile homes render there. Kept
 * out of research.css deliberately: that sheet is loaded by every page in
 * the workspace, and this composition is markup only one of them draws.
 *
 * Three widths, three shapes. At laptop width and above the inbox is a
 * rail, a list and a reader side by side. Between 1024px and 1279px the
 * rail flattens into a toolbar so the list and the reader keep their room.
 * Below 768px the three become one column, and opening a filing swaps the
 * list out for a full-height reader rather than squeezing both.
 */

/* ------------------------------------------------------------- provenance */

.er-provenance {
  font-size: 11px;
  color: var(--muted);
  margin: -14px 0 18px;
  line-height: 1.6;
}
.er-provenance a {
  color: var(--accent);
}
.er-note {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
  margin: 14px 0 0;
}
.er-note.is-strong {
  padding: 10px 12px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

/* ------------------------------------------------------------- state line */

.er-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted);
}
.er-state i {
  color: var(--border);
  font-style: normal;
}
.er-state-item {
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  min-height: 32px;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.er-state-item:hover {
  color: var(--ink);
  background: var(--surface-soft);
}
.er-state-item.is-active {
  background: var(--tint);
  border-color: var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------------------------ inbox */

.er-inbox {
  display: grid;
  grid-template-columns: 224px minmax(250px, 0.9fr) minmax(0, 1.5fr);
  grid-template-areas: "rail list reader";
  padding: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------- the rail */

.er-rail {
  grid-area: rail;
  padding: 18px;
  border-inline-end: 1px solid var(--border);
  min-width: 0;
}
.er-rail h2 {
  font-size: 14px;
  margin-bottom: 12px;
}
.er-rail h3 {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 6px;
}
.er-rail-group {
  margin-top: 18px;
}
.er-lookback {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.er-lookback select {
  margin-top: 5px;
  width: 100%;
}
.er-anchor-note {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 0 0;
}

.er-rail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: start;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  padding: 7px 8px;
  font-size: 12px;
  min-height: 36px;
}
.er-rail-row:hover {
  background: var(--surface-soft);
}
.er-rail-row.selected {
  background: var(--tint);
  color: var(--accent);
}
.er-rail-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.er-rail-name small {
  display: block;
  font-size: 10px;
  color: var(--muted);
}
.er-rail-row.selected .er-rail-name small {
  color: inherit;
  opacity: 0.8;
}
.er-rail-count {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 20px;
  text-align: end;
}
/* A pending count is the one number in the rail a reader acts on, so it
 * carries weight and a shape of its own rather than only a colour. */
.er-rail-count.has-pending {
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--radius-pill);
  padding: 2px 6px;
  font-weight: 700;
  text-align: center;
}

.er-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.er-facet {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  padding: 5px 9px;
  min-height: 30px;
}
.er-facet span {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}
.er-facet:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.er-facet.selected {
  background: var(--tint);
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------- the list */

.er-list {
  grid-area: list;
  padding: 18px 0 18px 18px;
  border-inline-end: 1px solid var(--border);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.er-list:dir(rtl) {
  padding: 18px 18px 18px 0;
}
.er-list h2 {
  font-size: 14px;
  margin-bottom: 10px;
  padding-inline-end: 18px;
}
.er-list-scroll {
  overflow-y: auto;
  max-height: 560px;
  padding-inline-end: 12px;
}
.er-day h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 0 5px;
  margin: 0;
}

.er-item {
  display: block;
  width: 100%;
  text-align: start;
  border: 0;
  border-inline-start: 2px solid transparent;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--ink);
  padding: 10px 8px;
}
.er-item:hover {
  background: var(--surface-soft);
}
.er-item.selected {
  background: var(--tint);
  border-inline-start-color: var(--accent);
}
.er-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.er-item-title {
  display: block;
  margin: 5px 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
  /* Three lines is enough to tell two filings apart; the reader carries the
   * whole title, and a Saudi Exchange headline can run to forty words. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.er-item.is-reviewed .er-item-title {
  font-weight: 500;
  color: var(--muted);
}
.er-item-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
}
.er-unread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.er-reviewed-mark {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--positive);
}

.er-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
/* The three categories a reader scans for first get the accent edge. Every
 * chip still carries its name in words, so colour adds emphasis and never
 * carries the meaning by itself. */
.er-chip.cat-results,
.er-chip.cat-dividend,
.er-chip.cat-costInput {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--tint);
}
.er-chip.is-routine {
  opacity: 0.75;
}

/* ------------------------------------------------------------- the reader */

.er-reader {
  grid-area: reader;
  padding: 22px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.er-reader:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}
.er-back {
  display: none;
  margin-bottom: 12px;
}
.er-reader-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.er-review {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.er-review.is-reviewed {
  background: var(--surface-soft);
  color: var(--muted);
  border-color: var(--border);
}
.er-reader-title {
  font-size: 19px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.er-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
}
.er-meta dt {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.er-meta dd {
  margin: 4px 0 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.er-meta dd small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.er-source-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 12px;
}
.er-reader .source-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  min-height: 36px;
}

.er-facts {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.er-facts h3 {
  font-size: 13px;
  margin: 0 0 12px;
}
.er-facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.er-fact {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.er-fact > span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.er-fact strong {
  display: block;
  font-size: 22px;
  margin: 6px 0;
  font-variant-numeric: tabular-nums;
}
.er-fact strong small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  margin-inline-start: 4px;
}
.er-fact-moves {
  display: flex;
  gap: 10px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.er-fact-moves em {
  font-style: normal;
  font-weight: 700;
}
.er-facts.is-unavailable p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 8px;
}

/* ---------------------------------------------------------- the evidence */

.er-evidence,
.er-cohort,
.er-ahead,
.er-sector {
  padding: 20px;
  margin-top: 18px;
}
.er-evidence h2,
.er-cohort h2,
.er-ahead h2,
.er-sector h2 {
  font-size: 15px;
}
.er-evidence .panel-heading p,
.er-cohort .panel-heading p,
.er-ahead .panel-heading p,
.er-sector .panel-heading p {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}

/* Chronological, so it stays left-to-right in both locales. */
.er-trend {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  margin-top: 16px;
  direction: ltr;
}
.er-trend i {
  flex: 1;
  min-width: 0;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
  transition: opacity var(--dur-fast) var(--ease);
}
.er-trend i:hover {
  opacity: 1;
}
.er-trend i.is-loss {
  background: var(--negative);
}
/* A quarter the snapshot never reported is drawn as an outline, not as a
 * zero-height bar that would read as "no revenue". */
.er-trend i.is-gap {
  align-self: stretch;
  background: repeating-linear-gradient(
    135deg,
    var(--border) 0 2px,
    transparent 2px 5px
  );
  opacity: 0.6;
}
.er-trend-axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  margin-top: 6px;
  direction: ltr;
}
.er-details {
  margin-top: 14px;
}
.er-details summary {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.er-quarter-table {
  width: 100%;
  margin-top: 10px;
  font-size: 11px;
  border-collapse: collapse;
}
.er-quarter-table caption {
  text-align: start;
  font-size: 10px;
  color: var(--muted);
  padding-bottom: 8px;
}
.er-quarter-table th,
.er-quarter-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.er-quarter-table th[scope="row"],
.er-quarter-table thead th:first-child {
  text-align: start;
  font-weight: 600;
}

/* ----------------------------------------------------------- the cohort */

.er-table-scroll {
  overflow-x: auto;
  margin-top: 14px;
}
.er-cohort-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 11px;
}
.er-cohort-table th,
.er-cohort-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  text-align: start;
}
.er-cohort-table thead th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.er-cohort-table thead th button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  padding: 4px 0;
  min-height: 30px;
}
.er-cohort-table thead th button:hover {
  color: var(--ink);
}
.er-cohort-table th[aria-sort="ascending"] button,
.er-cohort-table th[aria-sort="descending"] button {
  color: var(--accent);
}
.er-cohort-table th[aria-sort="descending"] .icon {
  transform: rotate(180deg);
}
.er-cohort-table td.num,
.er-cohort-table th.num {
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.er-cohort-table tbody th[scope="row"] button {
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0;
  text-align: start;
  min-height: 28px;
}
.er-cohort-table tbody th[scope="row"] button:hover {
  color: var(--accent);
}
.er-cohort-table tbody th[scope="row"] small {
  display: block;
  font-size: 9px;
  color: var(--muted);
}
.er-cohort-table tbody tr.selected {
  background: var(--tint);
}
.er-cohort-table .positive {
  color: var(--positive);
}
.er-cohort-table .negative {
  color: var(--negative);
}
.er-fact-moves .positive,
.er-quarter-table .positive {
  color: var(--positive);
}
.er-fact-moves .negative,
.er-quarter-table .negative {
  color: var(--negative);
}
.er-fact-moves .muted,
.er-quarter-table .muted {
  color: var(--muted);
}

/* --------------------------------------------------- forward-looking ---- */

.er-ahead-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}
.er-ahead-list li {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.er-ahead-list time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.er-ahead-list small {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.er-sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.er-sector-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.er-sector-metric > span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.er-sector-metric strong {
  display: block;
  font-size: 22px;
  margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;
}
.er-sector-metric strong small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  margin-inline-start: 4px;
}
.er-sector-metric em {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.er-sector-metric .positive {
  color: var(--positive);
}
.er-sector-metric .negative {
  color: var(--negative);
}
.er-sector-metric .muted {
  color: var(--muted);
}

/* ------------------------------------------------------------ responsive */

/* Ordinary desktop: the rail flattens into a toolbar so the list and the
 * reader keep the width they need. */
@media (max-width: 1279px) {
  .er-inbox {
    grid-template-columns: minmax(240px, 0.95fr) minmax(0, 1.4fr);
    grid-template-areas:
      "rail rail"
      "list reader";
  }
  .er-rail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
  }
  .er-rail h2 {
    margin: 0;
  }
  .er-rail h3 {
    display: none;
  }
  .er-rail-group {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
    padding-bottom: 2px;
  }
  .er-lookback {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }
  .er-lookback select {
    margin-top: 0;
    width: auto;
  }
  .er-anchor-note {
    flex-basis: 100%;
    margin: 0;
  }
  .er-rail-row {
    width: auto;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 5px 10px;
    flex: none;
  }
  .er-rail-name small {
    display: none;
  }
  .er-facets {
    flex-wrap: nowrap;
  }
}

@media (max-width: 900px) {
  .er-inbox {
    grid-template-columns: 1fr;
    grid-template-areas:
      "rail"
      "list"
      "reader";
  }
  .er-list {
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
    padding: 18px;
  }
  .er-list-scroll {
    max-height: 340px;
    padding-inline-end: 0;
  }
  .er-ahead-list li {
    grid-template-columns: 96px 1fr;
  }
  .er-ahead-list small {
    grid-column: 2;
  }
}

/* Phone: opening a filing replaces the list with a full-height reader
 * rather than stacking two scroll areas the reader has to fight. */
@media (max-width: 768px) {
  .er-inbox.is-reading .er-rail,
  .er-inbox.is-reading .er-list {
    display: none;
  }
  .er-inbox.is-reading .er-back {
    display: inline-flex;
  }
  .er-reader {
    padding: 18px;
  }
  .er-reader-title {
    font-size: 17px;
  }
  .er-review {
    margin-inline-start: 0;
  }
  .er-state {
    font-size: 11px;
  }
}

/* Reduced motion removes the transitions without removing any state: the
 * selected, hovered and reviewed treatments are all still visible. */
@media (prefers-reduced-motion: reduce) {
  .er-state-item,
  .er-trend i {
    transition: none;
  }
}
