/* =========================================================================
   Component — cards and panels
   ========================================================================= */

/* The SIDES panel (ADR-0167): the card surface, radius 6, 16px inside, 8px
   between its parts. The hairline stays until R6/R7 move cards that sit on
   another surface, where a white panel on white would lose its edge. */
.card {
  background: var(--doc-panel);
  border: var(--border-w) solid var(--doc-line);
  border-radius: var(--radius);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Paired with `[hidden]`, because `display` above defeats it otherwise: the OAuth
   user's create form is a card, put away by its `hidden` attribute once the
   secret is on screen, and it stayed visible under the panel (U-1722). */
.card[hidden] {
  display: none;
}

/* NO LIFT ON HOVER. DESIGN_TOKENS.md §9.1 names this one by its property:
   "neither does a hover that lifts an element (`transform: translateY(-2px)` is
   elevation by another name)". Depth is the three grounds, and a card is not
   floating above the document whether or not a pointer is over it. What says
   "this whole card is a link" is the border turning to the accent — which it
   already did, under the lift — and the arrow beside the heading. */
.card-link {
  transition: border-color .15s;
}

.card-link:hover {
  border-color: var(--sd-secondary);
  text-decoration: none;
}

.card > h3 {
  margin: 0;
}

.card > p {
  margin: 0;
  font-size: 14px;
  color: var(--doc-ink-soft);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* A card's closing link with its arrow (U-2282): the way on, at the card's
   foot whatever the text above it costs. The arrow is drawn, not read. */
.card > .card-more {
  margin-top: auto;
  font-weight: 600;
}

.card-tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sd-secondary);
}

/* --- Stat strip ---------------------------------------------------------- */

/* FOUR FIGURES IN ONE PANEL ARE FOUR CELLS, AND THE GUTTER IS THE LINE
   (DESIGN_TOKENS.md §9.2). The strip was one padded box with four floating
   columns 20 px apart — nothing said where one figure ended and the next
   began, which is the whole question a row of numbers asks.
 *
 * The technique is the reference's and it is named in §9.2: the CONTAINER's
 * background is the line colour, the cells sit on it with `gap: 1px`, and every
 * gutter is then exactly one pixel with no edge drawn twice. `overflow: hidden`
 * is what makes the cells' square corners honour the container's radius.
 *
 * `--sd-divider` and not `--doc-line`: these gutters separate four parts of one
 * strip, which is that token's role.
 *
 * A CELL'S MINIMUM IS ITS WIDEST WORD, NOT A ROUND NUMBER (U-1799). The strip
 * was `repeat(auto-fit, minmax(150px, 1fr))`, which counts columns from that
 * minimum alone and never from the content, so a value box 111–157 px wide held
 * words up to 186 px: „Professional" broke as „Profession / al" at 340–400,
 * 500–620 and 660–1270 px — at every column step, not at one width.
 *
 * The minimum is 7.2 times the value's size plus the cell's padding. 7.2 IS A
 * MEASUREMENT OF TODAY'S STRINGS, not a design constant: „wiederkehrend" („nicht
 * wiederkehrend", a free subscription's period) is 7.15 of them at weight 700,
 * the widest word any tile carries in DE or EN, tier names included. A longer
 * word — a new tier name, a new state — breaks again at some width, through the
 * `word-break` on `.stat-value` below; measure it and raise the factor. The size
 * steps down to 20 px on a narrow screen so two tiles still stand side by side
 * at 390 px.
 *
 * Flex and not a grid: a grid of four cells at three columns leaves an empty
 * cell showing the divider colour (U-1086), and `auto-fit` cannot be told to
 * skip three. A wrapped flex row lets its short last row take the full width. */
.stat-strip {
  --stat-value-size: clamp(20px, 5vw, 26px);
  --stat-cell-pad: clamp(16px, 3vw, 24px);
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--sd-divider);
  border: 1px solid var(--doc-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* The admin overview's queues: three to a row, one per row below 640 px. The
   print rule in print.css pins the three and draws the separators this fixed
   grid makes addressable — change one, change the other.

   THREE, BECAUSE THE QUEUES ARE NINE. At four across the ninth stood alone in
   a third row, spanning it (U-1086), and the owner's walk named it an orphan
   (U-1711); three rows of three close. Should the count stop being a multiple
   of three, the last cell spans what is left of its row rather than leaving
   the divider colour showing as an empty cell.

   BELOW 640 PX ONE COLUMN, the figure beside its label: three figures and their
   labels do not fit 320 px, and any two-column grid of nine leaves one cell
   alone. Its cells hold counts, never words, and its columns are fixed, so it
   stays a grid and keeps the full size at every width when `.stat-strip` turned
   to flex (U-1799). */
.stat-strip-three {
  --stat-value-size: 26px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.stat-strip-three > :last-child:nth-child(3n+1) {
  grid-column: 1 / -1;
}

.stat-strip-three > :last-child:nth-child(3n+2) {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .stat-strip-three {
    --stat-value-size: 22px;
    grid-template-columns: 1fr;
  }

  /* The same specificity as the two rules above, so this resets them. */
  .stat-strip-three > :last-child:nth-child(n) {
    grid-column: auto;
  }
}

/* The row layout is the screen's alone: the query above is not screen-only,
   and print.css puts a narrow sheet back to three columns, where a figure
   beside its label would wrap the label into a third of the page. */
@media screen and (max-width: 640px) {
  /* A row: the figure, then its label on the same baseline. A cell that links
     its queue carries the figure in the link, so the link lays out the row. */
  .stat-strip-three > *,
  .stat-strip-three > * > .card-link {
    display: flex;
    align-items: baseline;
    gap: 12px;
  }

  .stat-strip-three > * {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .stat-strip-three .stat-value {
    min-width: 3ch;
  }

  .stat-strip-three .stat-key {
    margin-top: 0;
  }
}

/* A strip with notes under it: the frame is drawn once, around both, and the
   strip inside gives up its own (U-1730). The notes are no cells of the strip's
   grid, whose `auto-fit` would then keep every column a full-width row spans. */
.stat-strip-frame {
  display: grid;
  gap: 1px;
  background: var(--sd-divider);
  border: 1px solid var(--doc-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.stat-strip-frame > .stat-strip {
  border: 0;
  border-radius: 0;
}

.stat-strip-frame > .stat-strip-note {
  margin: 0;
  background: var(--doc-panel);
  padding: 16px clamp(16px, 3vw, 24px);
}

/* Each cell carries the surface, so the container's line colour shows only in
   the gutters. */
.stat-strip > * {
  flex: 1 1 min(100%, calc(7.2 * var(--stat-value-size) + 2 * var(--stat-cell-pad)));
  background: var(--doc-panel);
  padding: 20px var(--stat-cell-pad);
}

/* FOUR FIGURES: ALL FOUR IN ONE ROW, OR TWO BY TWO, OR ONE PER ROW — never three
   with the fourth alone under them (U-1828: the dashboard's and the billing
   page's subscription strip at 1280 px). The cell keeps the minimum above, so
   no word breaks; the basis switches between a quarter, a half and the whole
   row by the width the strip itself has, which a media query cannot know
   beside the portal's sidebar. The `* 999` is the switch: below the threshold
   the product is huge and the clamp takes its maximum, above it negative and
   the clamp takes its minimum. */
.stat-strip-four > * {
  --stat-cell-min: calc(7.2 * var(--stat-value-size) + 2 * var(--stat-cell-pad));
  flex-basis: clamp(calc(25% - 1px),
    calc((4 * var(--stat-cell-min) + 3px - 100%) * 999),
    clamp(calc(50% - 1px), calc((2 * var(--stat-cell-min) + 1px - 100%) * 999), 100%));
}

/* The figures are what this strip is for, so they line up as a column even
   when they sit in a row (DESIGN_TOKENS.md §9.5).

   `word-break` is the last resort for a catalogue name wider than the column's
   minimum above, and it is no repair: without it such a word is cut off at the
   strip's `overflow: hidden` instead of wrapped. Every word known today fits. */
/* A counter: 24/32 bold, the portal's own addition to the SIDES styles
   (ADR-0167). */
.stat-value {
  font-size: var(--stat-value-size, var(--text-counter));
  line-height: var(--text-counter-lh);
  font-weight: 700;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.stat-key {
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
  color: var(--doc-ink-soft);
  margin-top: 2px;
}

/* --- CTA band ------------------------------------------------------------ */

/* The closing band of a public page (U-2277): the brand gradient with the
   molecule as its accent, dark in both themes (DESIGN_TOKENS.md §8.2). The
   molecule is a background image, so it is decorative by construction and
   needs no `alt`; it sits in the lower right and runs off the band.
 *
 * Contrast is measured against the band's LIGHTER stop, `--band-from` #027261:
 * white 5.86:1, the lead ink #D0FBE2 5.19:1 (computed from the tokens; the
 * painted pixels under the molecule, where a narrow band can put text, are not
 * measured yet). */
.cta-band {
  position: relative;
  overflow: hidden;
  background:
    url("../../img/motif/molecule-band.svg") right -40px bottom -150px / 560px 560px no-repeat,
    linear-gradient(120deg, var(--band-from) 0%, var(--band-to) 100%);
  color: var(--brand-on-dark);
  border-radius: var(--radius);
  padding: 56px;
}

.cta-band h2 {
  max-width: 620px;
  margin: 0 0 12px;
  font: var(--font-display-md);
  color: var(--brand-on-dark);
}

.cta-band p {
  margin: 0 0 var(--space-lg);
  font: var(--font-lead);
  color: var(--band-ink-lead);
}

@media (max-width: 639px) {
  .cta-band {
    padding: var(--space-lg);
  }
}

.cta-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* `.card-link` is an <a>, so its heading inherits the link colour. Colour may
   not be the only signal that the whole card is clickable (audit rule E-4), so
   the heading carries an arrow as well.
 *
 * A REAL <span aria-hidden="true">, not `content` on a pseudo-element. The whole
 * card is one link, so its accessible name is already tag + heading + paragraph;
 * generated content is exposed by current screen readers, which would append
 * "right arrow" to every one of those. An element can be hidden from the
 * accessibility tree. A pseudo-element cannot. */
.card-arrow {
  display: inline-block;
  margin-left: 4px;
  transition: transform .15s;
}

.card-link:hover .card-arrow {
  transform: translateX(3px);
}
