/* ==========================================================================
   BOCO-24477 - SMS Opt-in Landing Page (/texts)
   Mobile-first. Built against Figma "1079_06 SMS Opt-in LP", section "FINAL"
   (10973:64123). All type and colour values below are measured from the file,
   not estimated.
   ========================================================================== */

:root {
  /* Colour tokens */
  --rws-red: #ff0033; /* required-field asterisk */
  --rw-red: #fe0032; /* CTA background */
  --grey-2: #c2c9cf;
  --grey-3: #8a919e; /* placeholder text, resting input border */
  --grey-4: #211e25; /* Grey 4 - body copy, headings, checkbox chrome, confirmation panel */
  --black: #000000;
  --white: #ffffff;

  /* Error treatment (measured from 10973:64126) */
  --error-border: #b10224;
  --error-bar-bg: #e4b1bb;
  --error-checkbox-border: #d1212f;

  /* Type tokens. Letter-spacing is included deliberately - the ticket's token
       list omits it and it is clearly visible in Arkitekt if dropped. */
  --font-regular: "ArkitektRegular", Arial, sans-serif;
  --font-medium: "ArkitektMedium", Arial, sans-serif;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

/* Removes an element visually while leaving it in the accessibility tree.
   Same clip technique already used for the native checkbox inputs below. */
.smsoptin-visuallyhidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */

header {
  display: flex;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid var(--grey-2);
}
body {
  margin: 0;
  background: var(--white);
  color: var(--grey-4);
  font-family: var(--font-regular);
  -webkit-font-smoothing: antialiased;
}

.smsoptin-page {
  display: flex;
  flex-direction: column;
  background: var(--white);
}

/* --------------------------------------------------------------------------
   Band 1 - hero copy
   Mobile: 32px top / 20px bottom / 24px sides, 12px gap (10973:64125)
   -------------------------------------------------------------------------- */

.smsoptin-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px 24px 20px;
  background: var(--white);
}

.smsoptin-hero__headline {
  margin: 0;
  font-family: var(--font-medium);
  font-weight: normal;
  font-size: 48px;
  line-height: 0.8;
  letter-spacing: -1.44px;
  text-transform: uppercase;
  color: var(--grey-4);
  overflow-wrap: break-word;
}

.smsoptin-hero__subhead {
  margin: 0;
  font-family: var(--font-regular);
  font-size: 14px;
  line-height: normal;
  letter-spacing: 0.14px;
  color: var(--grey-4);
}

/* --------------------------------------------------------------------------
   Band 3 - hero imagery
   Mobile: below the form. This ordering is what makes FR-2 (form above the
   fold) achievable - treat it as a constraint, not an incidental choice.
   -------------------------------------------------------------------------- */

.smsoptin-heroimage {
  display: block;
  width: 100%;
  height: auto;
}

.smsoptin-heroimage--desktop {
  display: none;
}

/* --------------------------------------------------------------------------
   Footer region (FR-4a, Open Question 12)
   Intentionally empty and isolated. Nothing above depends on it, so footer
   content can land here later without touching the rest of the page.
   -------------------------------------------------------------------------- */

.smsoptin-footer {
  background: var(--white);
}

/* --------------------------------------------------------------------------
   Desktop - two columns, hero imagery right, copy + form left
   Hero band is 892px tall; imagery 754px wide pinned right; copy column
   624px wide with 128px left padding, vertically centred (10973:64610).
   -------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  .smsoptin-page {
    position: relative;
    min-height: 892px;
    display: block;
  }

  .smsoptin-heroimage--mobile {
    display: none;
  }

  .smsoptin-heroimage--desktop {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    width: 754px;
    max-width: 50%;
    height: 892px;
    object-fit: cover;
    object-position: left center;
  }

  .smsoptin-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 624px;
    max-width: 100%;
    box-sizing: border-box;
    padding: 48px 24px 48px 128px;
    min-height: 892px;
    justify-content: center;
    background-color: white;
  }

  .smsoptin-hero {
    padding: 0;
    gap: 20px;
  }

  .smsoptin-hero__headline {
    font-size: 56px;
    line-height: 0.9;
    letter-spacing: -1.12px;
    color: var(--grey-4);
  }

  .smsoptin-hero__subhead {
    max-width: 345px;
  }
}

/* --------------------------------------------------------------------------
   Band 2 - opt-in form
   Mobile: 24px sides, 24px between groups, 16px label-to-control,
   15px input padding (10973:64126 / 10973:64610).
   -------------------------------------------------------------------------- */

.smsoptin-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 24px 16px;
  background: var(--white);
}

.smsoptin-form.disable {
  opacity: 0.6;
  pointer-events: none;
}

.smsoptin-field {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  border: 0;
}

.smsoptin-label {
  display: block;
  padding: 0;
  font-family: var(--font-medium);
  font-size: 18px;
  line-height: normal;
  color: var(--grey-4);
}

.smsoptin-req {
  color: var(--rws-red);
}

/* Inputs -------------------------------------------------------------- */

.smsoptin-input {
  display: flex;
  align-items: center;
  gap: 0;
  box-sizing: border-box;
  width: 100%;
  padding: 15px;
  background: var(--white);
  border: 1px solid var(--grey-3);
}

.smsoptin-input input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--font-medium);
  /* 18px, comfortably over the 16px floor below which iOS Safari zooms on focus. */
  font-size: 18px;
  line-height: normal;
  color: var(--grey-4);
}

.smsoptin-input input::placeholder {
  /* Placeholder stays on the Regular face so it reads as a prompt rather than
     as entered text, which is Medium (BOCO-24924). */
  font-family: var(--font-regular);
  color: var(--grey-3);
  opacity: 1;
}

.smsoptin-prefix {
  flex: 0 0 auto;
  font-family: var(--font-medium);
  font-size: 18px;
  line-height: normal;
  color: var(--grey-4);
}

.smsoptin-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 18px;
  margin: 0 12px;
  background: var(--grey-3);
}

/* Checkbox group ------------------------------------------------------ */

.smsoptin-checkrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 1rem;
}

.smsoptin-checkgroup {
  display: flex;
  align-items: center;
  gap: 24px;
}

.smsoptin-check {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  cursor: pointer;
}

/* The native control stays in the accessibility tree and keeps keyboard behaviour;
   it is visually replaced by the 12px square from the design. */
.smsoptin-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.smsoptin-check__box {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border: 1px solid var(--grey-4);
  background: var(--white);
}

.smsoptin-check input:checked + .smsoptin-check__box {
  background: var(--grey-4);
  box-shadow: inset 0 0 0 2px var(--white);
}

.smsoptin-check input:focus-visible + .smsoptin-check__box {
  outline: 2px solid var(--black);
}

.smsoptin-check__text {
  font-family: var(--font-medium);
  font-size: 18px;
  line-height: normal;
  color: var(--grey-4);
}

/* Error treatment ----------------------------------------------------- */

.smsoptin-erricon {
  display: none;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-left: 12px;
  background: url("../images/SMSOptin/error-icon.svg") no-repeat center /
    contain;
}

.has-error .smsoptin-erricon {
  display: block;
}

.has-error .smsoptin-input {
  border: 2px solid var(--error-border);
  /* Keep the control box the same height as the resting state despite the
       heavier border, so the form does not jump when an error appears. */
  padding: 14px;
}

.smsoptin-errmsg {
  display: none;
  margin: 0;
  padding: 4px;
  background: var(--error-bar-bg);
  font-family: var(--font-regular);
  font-size: 14px;
  line-height: normal;
  color: var(--black);
}

/* The design puts a 2px gap between an errored control and its message. The
   field's own 16px gap is collapsed for the message only. */
.smsoptin-field.has-error {
  gap: 16px;
}

.has-error .smsoptin-input + .smsoptin-errmsg,
.has-error .smsoptin-checkrow + .smsoptin-errmsg {
  margin-top: -14px;
}

.has-error .smsoptin-check__box {
  border-color: var(--error-checkbox-border);
}

.smsoptin-errmsg--form {
  margin-top: 8px;
}

/* Microcopy, disclaimer, CTA ------------------------------------------ */

.smsoptin-submit {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.smsoptin-microcopy {
  margin: 0;
  font-family: var(--font-regular);
  font-size: 16px;
  line-height: normal;
  letter-spacing: 0.16px;
  color: var(--grey-4);
}

.smsoptin-disclaimer {
  margin: 0;
  font-family: var(--font-regular);
  font-size: 12px;
  line-height: normal;
  letter-spacing: 0.24px;
  color: var(--grey-4);
}

.smsoptin-disclaimer a {
  color: var(--grey-4);
  text-decoration: underline;
}

.smsoptin-cta {
  box-sizing: border-box;
  width: 100%;
  padding: 14px 24px;
  border: 0;
  border-radius: 2px;
  background: var(--rw-red);
  font-family: var(--font-medium);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0.24px;
  color: var(--white);
  text-align: center;
  cursor: pointer;
}

.smsoptin-cta:hover {
  background: var(--rws-red);
}

/* Visible focus for keyboard traversal.
   Focus is BLACK. Red is reserved for the error state, so a focused field and an
   errored field stay tellable apart - including a focused field that is also in
   error, which shows a red border inside a black ring. */
.smsoptin-input:focus-within,
.smsoptin-cta:focus-visible,
.smsoptin-disclaimer a:focus-visible {
  outline: 2px solid var(--black);
}

/* Anything whose focus ring is drawn by a wrapper or a stand-in element must not
   draw its own, or the field shows two outlines. Applies to the text inputs (ring
   on .smsoptin-input) and to the visually hidden checkbox (ring on .__box). */
.smsoptin-input input:focus,
.smsoptin-input input:focus-visible,
.smsoptin-check input:focus,
.smsoptin-check input:focus-visible {
  outline: none;
}

/* --------------------------------------------------------------------------
   Confirmation panel (10973:64596)
   Dark full-bleed panel replacing the form. Built here, wired in Phase 6.
   -------------------------------------------------------------------------- */

/* A class rule setting display would otherwise beat the user-agent [hidden] rule,
   so the hidden state has to be restated here or the panel renders on page load. */
.smsoptin-confirm[hidden],
.smsoptin-form[hidden] {
  display: none !important;
}

.smsoptin-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  box-sizing: border-box;
  min-height: 493px;
  padding: 32px 24px;
  background: var(--grey-4);
  text-align: center;
}

.smsoptin-confirm__icon {
  display: block;
  width: 75px;
  height: 75px;
}

.smsoptin-confirm__headline {
  margin: 0;
  font-family: var(--font-medium);
  font-size: 24px;
  line-height: normal;
  color: var(--white);
}

.smsoptin-confirm__body {
  margin: 0;
  font-family: var(--font-regular);
  font-size: 16px;
  line-height: normal;
  color: var(--white);
}

/* Hero imagery is removed once the confirmation is showing - at BOTH breakpoints.
   Verified against the confirmation frames: 10978:76370 (mobile) and 10978:77349
   (desktop). The desktop frame goes hero copy -> full-width panel -> site footer,
   with no imagery, so this is not a mobile-only rule. */
.smsoptin-confirmed .smsoptin-heroimage {
  display: none;
}

/* --------------------------------------------------------------------------
   Desktop overrides for the form
   -------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  .smsoptin-form {
    padding: 0;
    gap: 24px;
  }

  /* The desktop CTA is not full width - it hugs its label (10973:61388). */
  .smsoptin-cta {
    width: auto;
    align-self: flex-start;
  }

  /* On confirmation the desktop hero imagery is gone, so the content column stops
       being a 624px left column and the panel spans the full content width with
       symmetric 128px insets - matching 10978:77349. */
  .smsoptin-confirmed .smsoptin-content {
    width: 100%;
    padding-right: 128px;
  }

  /* Only the panel widens. The hero copy keeps the measure it has in the
       two-column state, so the H1 wraps identically before and after submit. */
  .smsoptin-confirmed .smsoptin-hero {
    max-width: 472px;
  }

  .smsoptin-confirm {
    /* Same 493px panel height as mobile, measured from the desktop frame. */
    min-height: 493px;
  }
}
