/* ============================================
   Component: Opening
   View: dashboards/summary/show.html.erb
   Partials: dashboards/_opening.html.erb, dashboards/_opening_metric.html.erb, parts/_figure.html.erb,
             parts/_table.html.erb
   Stimulus: none
   ============================================ */
/* A leader's opening (#619, #663, KPI-01, INIT-01), above the Summary's cards, numbers first (D-223): the number
   under its name, with its figure, its lines and its tables, the figures beside it and its lead metrics; then the
   initiatives, a short list; then one closed panel holding everything that explains. Phone first: each part reads
   one beneath another, and from 600px each detail's label and value sit side by side. A table scrolls in its own box
   (components/table.css), so the page never scrolls sideways. */

/* The opening, its parts one beneath another, then the Summary's cards beneath it. */
.opening {
  display: grid;
  gap: var(--spacing-lg);
  margin: var(--spacing-lg) 0 var(--spacing-xl);
}

/* The number's part and the initiatives': its heading, then what is under it, one beneath another, each starting at
   the part's left. */
.opening-number,
.opening-initiatives {
  display: grid;
  gap: var(--spacing-md);
}

.opening-number > h2,
.opening-initiatives > h2 {
  margin: 0;
  font-size: var(--font-size-lg);
}

/* One metric: its figure or the line in its place, its lines and its tables, one beneath another. */
.opening-metric {
  display: grid;
  gap: var(--spacing-sm);
}

/* The lead metrics: their heading, their line and each lead metric, one beneath another. */
.opening-lead {
  display: grid;
  gap: var(--spacing-md);
}

.opening-lead > h3 {
  margin: 0;
  font-size: var(--font-size-md);
}

/* Each metric after the first, and the lead metrics, set apart from what is above them by a rule. */
.opening-metric + .opening-metric,
.opening-metric + .opening-lead,
.opening-lead > .opening-metric {
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

/* Each figure on a card's surface, the width of a row on a phone and of a column on a wide screen; it lays itself out
   by its own width (components/figure.css). The period so far's, in the panel, the same. */
.opening-metric > .figure-container,
.opening-panel-metric > .figure-container {
  justify-self: start;
  width: 100%;
  max-width: 40rem;
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

/* A metric's name, where no heading or figure's label carries it, then the line in its figure's place. */
.opening-metric-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

/* Muted, each a line of words among the figures: the line in a figure's place, the lead metrics' line, the line
   beneath the number's trend where its class gives one (#644), and the line in the initiatives' place. */
.opening-metric-line,
.opening-lead-line,
.opening-trend-note,
.opening-empty {
  margin: 0;
  color: var(--color-muted);
}

/* A metric's lines, each label above its value on a phone, and beside it from 600px: its baseline and its target
   once set, beside its figure, and what it is, in the panel. */
.opening-details {
  display: grid;
  gap: var(--spacing-xs) var(--spacing-md);
  margin: 0;
}

.opening-details > dt {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.opening-details > dd { margin: 0; }

@media (min-width: 600px) {
  .opening-details { grid-template-columns: minmax(8rem, max-content) 1fr; }
}

/* A table's box fits its table, and is never wider than the page: a wider table scrolls sideways in its own box. */
.opening-metric > .table-scroll {
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}

/* The initiatives, a short list in order, each on a card's surface: its name, its status, and its next action while
   it is under way, one beneath another. */
.opening-initiative-list {
  display: grid;
  gap: var(--spacing-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.opening-initiative {
  display: grid;
  gap: var(--spacing-xs);
  max-width: 40rem;
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.opening-initiative > h3 {
  margin: 0;
  font-size: var(--font-size-md);
}

/* Its status in words; at risk in the warning colour beside them, never in their place. */
.opening-initiative-status { font-weight: 600; }

.opening-initiative-status.is-at-risk { color: var(--color-warning); }

/* The panel beneath the opening, holding everything that explains, behind a closed tap, as SKU performance's words
   are: a <details> opens with no JavaScript and no hover, its summary at least the tap target's height. */
.opening-panel { font-size: var(--font-size-sm); }

.opening-panel > summary {
  display: flex;
  align-items: center;
  gap: 0 var(--spacing-sm);
  min-height: var(--tap-target);
  color: var(--color-link);
  cursor: pointer;
  list-style: none;
}

/* A flex summary loses its marker, so it draws its own: closed, then open */
.opening-panel > summary::-webkit-details-marker { display: none; }

.opening-panel > summary::before { content: "▸"; }

.opening-panel[open] > summary::before { content: "▾"; }

/* Inside it, one beneath another: the decision, KPI-01's part, INIT-01's part and the words. */
.opening-panel-body {
  display: grid;
  gap: var(--spacing-lg);
  padding-top: var(--spacing-sm);
}

/* Each part: its question or its heading, its line, then each metric's or each initiative's lines, one beneath
   another. */
.opening-panel-part {
  display: grid;
  gap: var(--spacing-md);
}

.opening-panel-part > h3 {
  margin: 0;
  font-size: var(--font-size-md);
}

/* One metric's or one initiative's: its name, then its lines, one beneath another. */
.opening-panel-metric,
.opening-panel-initiative {
  display: grid;
  gap: var(--spacing-xs);
}

.opening-panel-metric > h4,
.opening-panel-initiative > h4 {
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.opening-decision,
.opening-panel-line,
.opening-initiative-due,
.opening-initiative-quarter {
  margin: 0;
  color: var(--color-muted);
}

/* Each word, then its definition beneath it. */
.opening-word-list {
  display: grid;
  gap: var(--spacing-xs);
  margin: 0;
}

.opening-word-list > dt {
  color: var(--color-text);
  font-weight: 600;
}

.opening-word-list > dd { margin: 0 0 var(--spacing-xs); }
