/* Inline components.
 *
 * EVERY COLOUR IS A TOKEN. These render inside any publication's prose, so a
 * literal here is one publisher's palette in everybody else's paragraphs. The
 * same rule, and the same guard test, as static/css/my-business.css.
 *
 * Sized in `em` rather than `px` throughout: a component sits inside running
 * text and should take the size of the sentence it is in, not impose one. That
 * is the whole difference between an inline component and a widget.
 */

.ic {
  font-family: inherit;
}

/* — an action ———————————————————————————————————————————————— */

/* ---------------------------------------------------------------------------
 * The BLOCK placement's wrapper.
 *
 * This did not exist. `component.html` emitted
 * `component-widget--left|center|right` and nothing anywhere defined those
 * classes, so the alignment control was wired up end to end and did nothing.
 *
 * A flex row rather than `text-align`, because the three component templates
 * have different display types: an action is an inline-flex `<a>`, a fact is
 * a `<span>`, and the call-back box is a block `<div>` that `text-align`
 * would centre the CONTENTS of rather than the box itself.
 *
 * `width: 100%` is load-bearing. `.widget-placement` is itself a flex
 * container, so without it this is a flex ITEM sized to its content, there is
 * no spare room along the main axis, and `justify-content` has nothing to
 * justify -- the same shape as the 455px-inside-1200px bug on the pitch page.
 * ------------------------------------------------------------------------ */
.component-widget {
  display: flex;
  width: 100%;
  /* `justify-content` is set inline per placement, from
   * `component_style.ALIGNMENTS`, so an unstyled one still aligns. */
}

/* `!important` on the paint, and only on the paint. A component sits inside
 * somebody else's prose, and every prose stylesheet on the platform styles its
 * links with a selector that out-ranks a class -- the text widget's
 * `#text-widget-N .text-widget-content a`, the article body's `.article-body a`
 * -- so without it a button took the LINK colour on the ACCENT background:
 * green on green wherever the two are the same green. The block placement's
 * own colours (`component_style.style_rules`) are `!important` too, and win on
 * their id. */
.ic-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.1em;
  border-radius: var(--kit-radius-button, 6px);
  background: var(--brand-accent) !important;
  /* The theme's text-on-accent, chosen by WCAG in _design_tokens.html, so a
   * light accent gets dark text. The paper colour is the fallback for a page
   * rendered without the publication's tokens. */
  color: var(--brand-on-accent, var(--brand-background)) !important;
  font-weight: var(--kit-button-weight, 600);
  line-height: 1.2;
  text-decoration: none !important;
  transition: background-color 0.15s ease;
}
.ic-action:hover {
  background: color-mix(in srgb, var(--brand-accent) 85%, var(--brand-text)) !important;
  color: var(--brand-on-accent, var(--brand-background)) !important;
}

/* Quieter, for a second action beside a primary one. */
.ic-action--secondary {
  background: transparent !important;
  color: var(--brand-text) !important;
  border: 1px solid var(--brand-border-color);
}
.ic-action--secondary:hover {
  background: color-mix(in srgb, var(--brand-text) 7%, transparent) !important;
  color: var(--brand-text) !important;
}

/* Mid-sentence: no box at all, or it breaks the line it sits in. */
.ic-action--plain,
.ic-action--inline {
  display: inline;
  padding: 0;
  background: none !important;
  border: 0;
  color: var(--brand-accent) !important;
  text-decoration: underline !important;
  font-weight: inherit;
}
.ic-action--plain:hover,
.ic-action--inline:hover {
  background: none !important;
  color: var(--brand-link-hover, var(--brand-accent)) !important;
}

/* — a fact ———————————————————————————————————————————————————— */

.ic-fact__value {
  font-family: var(--brand-font-heading);
  font-weight: var(--kit-heading-weight, 700);
}
/* Set large when it is the whole point of its line, as in a masthead rule. */
.ic-fact--display .ic-fact__value {
  display: block;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1;
}
.ic-fact--display .ic-fact__unit {
  display: block;
  margin-top: 0.4em;
  font-size: 1rem;
  color: var(--brand-text-muted, var(--brand-muted));
}

/* — call me back ——————————————————————————————————————————————— */

.ic-callback {
  display: block;
  margin: 1.2em 0;
}
.ic-callback__label {
  display: block;
  margin-bottom: 0.4em;
  font-size: 0.9em;
  color: var(--brand-text-muted, var(--brand-muted));
}
.ic-callback__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  align-items: flex-end;
}
.ic-callback__input {
  flex: 1 1 12em;
  min-width: 0;
  min-height: 2.9em;
  padding: 0.6em 0.9em;
  font: inherit;
  color: var(--brand-text);
  background: var(--brand-background);
  border: 1px solid var(--brand-border-color);
  border-radius: var(--kit-radius-md, 6px);
}
.ic-callback__input::placeholder {
  /* Measured: the browser default grey misses 4.5:1 on most grounds. */
  color: color-mix(in srgb, var(--brand-text) 62%, transparent);
  opacity: 1;
}
.ic-callback__input:focus-visible { border-color: var(--brand-accent); }
.ic-callback__go {
  flex: 0 0 auto;
  min-height: 2.9em;
  padding: 0.6em 1.2em;
  font: inherit;
  font-weight: var(--kit-button-weight, 600);
  cursor: pointer;
  color: var(--brand-on-accent, var(--brand-background)) !important;
  background: var(--brand-accent) !important;
  border: 0;
  border-radius: var(--kit-radius-button, 6px);
}
.ic-callback__go:disabled { opacity: 0.55; cursor: default; }
.ic-callback__said { margin: 0.6em 0 0; font-weight: 600; }
.ic-callback__error {
  margin: 0.6em 0 0;
  color: var(--brand-text);
  font-size: 0.9em;
}

@media (prefers-reduced-motion: reduce) {
  .ic-action, .ic-callback__go { transition: none; }
}
