/**
 * tr-cta — the contextual newsletter CTA above the footer (CTA-01 / CTA-02)
 * ----------------------------------------------------------------------------
 * Left: a title and one supporting line. Right: the newsletter form inside a
 * card. One purpose, one control, and nothing else in the section.
 *
 * FOUR SURFACES, NOT TWO (CTA-02)
 * ----------------------------------------------------------------------------
 * The first pass removed the card and gave the form a hairline frame directly on
 * the section. That fixed the invisible field but flattened the whole block —
 * an input floating on the footer background. The depth is back, and it is built
 * from four real token surfaces so it holds in both themes:
 *
 *   1  .tr-cta          --surface-sunken   the recess, under the page and the footer
 *   2  .tr-cta__card    --surface-card     a panel lifted out of it, with a border
 *   3  .ff-el-form-control  --surface-sunken + --tiorai-field-border, inset in the panel
 *   4  .ff-btn-submit   --color-primary    the one lime thing in the section
 *
 * Levels 3 and 4 are NOT set here. They come from
 * `assets/css/integrations/fluentform.css`, the adapter every FluentForm on the
 * site shares, and this file's job is to stop overriding them. The first pass
 * forced the field transparent and borderless so it would disappear into a
 * frame; removing that override is what gives the field its own boundary back.
 * Colours, focus rings, hover, the loading state and reduced motion for both
 * controls stay with the adapter — the same division CLAUDE.md §9.22 states for
 * the share dock: render the owning component, style placement only.
 *
 * THE FORM'S OWN CUSTOM CSS IS OVERRIDDEN, DELIBERATELY
 * ----------------------------------------------------------------------------
 * Form 3 carries a `_custom_form_css` entry saved against it in FluentForm,
 * which prints inline:
 *   `.fluent_form_3 .top_merged.ff_submit_btn_wrapper { position:absolute; top:5px; right:5px }`
 * That absolutely positions the submit over the field. It is fine over a field
 * as wide as the form and catastrophic otherwise: measured at 390px the button
 * covered most of a 181px input, and at 320px it covered all of it, so the field
 * could not be typed into. The inline style cannot be edited from the theme, so
 * the wrapper is returned to the flow with `position: static !important` and the
 * two groups are laid out here at every width.
 *
 * @package TiorAI
 * @since 4.22.0
 */

/* ============================================================================
   SECTION — surface 1
   ========================================================================== */

/*
 * `--surface-sunken` rather than a translucent white wash. The pre-CTA-01
 * container painted `linear-gradient(rgba(255,255,255,.05), …)` over a
 * `backdrop-filter: blur(20px)` — a full-width blurred band that composited on
 * every page of the site to produce a barely visible tint. The recess token has
 * a real value in both themes and costs nothing to paint.
 *
 * The section renders inside <footer>, which is `--surface-card`, so the recess
 * separates it from the footer below as well as from the page above.
 */
.tr-cta {
  position: relative;
  background: var(--surface-sunken);
  border-block: 1px solid var(--border-default);
  /*
   * `theme-unified.css` declares `section { padding: 70px 0 }` as a global
   * element primitive. This component sets its own vertical rhythm on
   * `.tr-cta__inner`, so inheriting that as well added 140px of empty band —
   * measured 374px tall for 232px of content. Zeroed here rather than by
   * dropping back to a `<div>`: the element is a labelled region and should say
   * so.
   */
  padding-block: 0;
  /* The header is `position: sticky; top: 0` and ~65px tall, and both the rail
     item and the blog CTA navigate to this section by its id. Without this the
     anchor parks the heading underneath the header. */
  scroll-margin-top: 5rem;
}

/* One brand hairline, on the section's own top edge so it spans the full width
   rather than stopping at the content column. The pre-CTA-01 layout drew this
   gradient twice, above and below, on a container that already had a border. */
.tr-cta::before {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  opacity: 0.6;
}

.tr-cta__inner {
  max-width: 1200px;
  margin-inline: auto;
  padding-block: var(--space-10);
  padding-inline: var(--space-4);
  display: grid;
  gap: var(--space-8);
  text-align: center;
  justify-items: center;
}

/* ============================================================================
   COPY
   ========================================================================== */

.tr-cta__copy {
  max-width: 46ch;
}

.tr-cta__title {
  margin: 0;
  font-size: var(--font-size-2xl, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.tr-cta__text {
  margin: var(--space-3) 0 0;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

/* ============================================================================
   THE CARD — surface 2
   ========================================================================== */

.tr-cta__card {
  width: 100%;
  max-width: 30rem;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-default);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

/* Visually hidden, defined here rather than borrowed. `.sr-only` is declared by
   the header module and `.screen-reader-text` by a job-module stylesheet; a
   shared component reaching into either would break the moment that module
   stopped loading on a route. */
.tr-cta__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------------------
   FIELD + BUTTON LAYOUT — surfaces 3 and 4 keep their own styling
   -------------------------------------------------------------------------- */

.tr-cta__card fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

/* No `gap` on the fieldset. FluentForm's screen-reader `<legend>` is a flex item
   with zero width, and a gap would still open a space before the field; the two
   real groups carry margins instead. */
.tr-cta__card .ff-el-group {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0 !important;
}

.tr-cta__card .ff-el-input--content {
  width: 100%;
}

/* Stacked by default: full-width field, full-width button under it. This is the
   phone layout, and it is a real second control rather than a hidden field. */
.tr-cta__card .ff_submit_btn_wrapper {
  position: static !important;
  flex: 0 0 100%;
  margin-block-start: var(--space-2) !important;
}

.tr-cta__card .ff-btn-submit {
  width: 100%;
}

/* The success and error states render inside the card once the form is gone. */
.tr-cta__card .ff-message-success {
  margin: 0 !important;
  text-align: center;
}

/* The validation and server-error stack, which FluentForm renders as a sibling
   of the form and therefore inside the card. `role="alert"` is the plugin's and
   is left alone; only the spacing is ours. */
.tr-cta__card .ff-errors-in-stack:not(:empty) {
  padding-block-start: var(--space-2);
}

/* ============================================================================
   RESPONSIVE
   ========================================================================== */

/*
 * Merged row, from the large-phone boundary up. A-13 complement pair with the
 * implicit max-width: 480px above it — chosen over 641 because a full-width
 * Subscribe button measured 470px at a 600px viewport, which reads as a banner
 * rather than a control.
 *
 * `nowrap` is what makes the row a row. Flex wraps BEFORE it shrinks, so with
 * `wrap` still set the field's auto basis (its content width) plus the button
 * overflowed the line and the button dropped underneath — measured at 1440px, a
 * 342px field with a 116px button beneath it. `min-width: 0` on the group is
 * what then lets the field give way instead of overflowing.
 */
@media (min-width: 481px) {

  .tr-cta__card fieldset {
    flex-wrap: nowrap;
  }

  .tr-cta__card .ff-el-group {
    flex: 1 1 auto;
  }

  .tr-cta__card .ff_submit_btn_wrapper {
    flex: 0 0 auto;
    margin-block-start: 0 !important;
    margin-inline-start: var(--space-2) !important;
  }

  .tr-cta__card .ff-btn-submit {
    width: auto;
  }
}

@media (min-width: 769px) {

  .tr-cta__inner {
    padding-inline: var(--space-8);
  }
}

/* Two columns, copy left, card right — the composition the pre-CTA-01 design
   had and the one this section is strongest in. Below this the copy reads
   better centred above the card than squeezed beside it. */
@media (min-width: 1024px) {

  .tr-cta__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: var(--space-12);
    padding-block: var(--space-12);
    text-align: start;
  }

  /* No cap here. The grid column already bounds the measure at roughly 36ch,
     and a `ch` cap set on the 1rem wrapper is far narrower than the 2rem title
     needs — it wrapped "Discover better AI tools" onto two lines at 1440px. */
  .tr-cta__copy {
    max-width: none;
  }

  .tr-cta__title {
    font-size: var(--font-size-3xl, 2rem);
  }

  .tr-cta__card {
    max-width: none;
    justify-self: end;
    padding: var(--space-6);
  }
}

/* ============================================================================
   FORCED COLOURS, CONTRAST & MOTION
   ========================================================================== */

@media (forced-colors: active) {

  .tr-cta__card {
    border: 1px solid CanvasText;
  }
}

/*
 * Moved here from modules/footer/assets/css/footer.css with the markup it
 * describes. That file's rule widened the outline on every interactive control
 * in the footer, the FluentForm field and submit included; those two are now
 * this component's, so the rule follows them rather than being narrowed away.
 */
@media (prefers-contrast: high) {

  .tr-cta__card .ff-el-form-control,
  .tr-cta__card .ff-btn-submit {
    outline-width: 2px;
  }
}

@media print {

  .tr-cta {
    display: none;
  }
}
