/* ---------------------------------------------------------------------------
   TWS newsletter sign-up block — all seven brands
   No JS. Sizing uses container queries, so the block responds to the width of
   ITS OWN wrapper, not the viewport: it behaves the same in a narrow article
   column or a full-width footer area.

   Per-brand values arrive as inline custom properties from PHP:
     --twsnl-accent        brand colour (button fill, top rule, underlines)
     --twsnl-accent-text   darkened accent for the small kicker (contrast)
     --twsnl-on-accent     text colour on the button
        --twsnl-font-display  headline face      (Merriweather, Oswald, Playfair…)
     --twsnl-font-accent   kicker + button face
     --twsnl-font-body     body/label/input face
     --twsnl-title-size    headline size, tuned per face
     --twsnl-standfirst-size  standfirst size (19px for the EB Garamond brands)
   --------------------------------------------------------------------------- */
/* The query container must be an ANCESTOR — an element cannot respond to its own
   container query. PHP wraps every block in .twsnl-wrap; without it the block
   still works, it just stays in its narrow layout. */
.twsnl-wrap { container-type: inline-size; }

.twsnl {
  --twsnl-accent: #CE0F1F;
  --twsnl-accent-text: #B10D1A;
  --twsnl-on-accent: #ffffff;
  --twsnl-font-display: 'Source Serif 4', Georgia, serif;
  --twsnl-font-accent: 'Barlow Condensed', sans-serif;
  --twsnl-font-body: Barlow, Helvetica, Arial, sans-serif;
  --twsnl-title-size: 34px;
  --twsnl-standfirst-size: 17px;
  --twsnl-ink: #14140f;
  --twsnl-body: #43403a;
  --twsnl-muted: #6b665c;
  --twsnl-bg: #ededed;
  --twsnl-phone: clamp(170px, 23cqi, 280px);

  overflow: hidden;                /* crops the phone at the bottom edge */
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* narrow first; the phone column is added below */
  gap: 40px;
  margin: 28px 0 0;
  background: var(--twsnl-bg);
  border: 1px solid #dcd8cf;
  border-top: 4px solid var(--twsnl-accent);
  padding: 22px 16px;
  font-family: var(--twsnl-font-body);
  color: var(--twsnl-body);
  -webkit-text-size-adjust: 100%;
}

/* phone visual ------------------------------------------------------------- */
.twsnl__phone {
  display: none;                        /* shown once there's room — see below */
  align-self: stretch;
  margin-bottom: -90px;                 /* runs past the card, which crops it */
  min-height: 260px;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--twsnl-ink);
  border-radius: 34px 34px 0 0;
  padding: 9px 9px 0;
  box-shadow: 0 14px 30px rgba(20, 20, 15, 0.16);
}
.twsnl__notch {
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.twsnl__notch span {
  display: block;
  width: 26%;
  height: 15px;
  background: #000;
  border-radius: 8px;
}
.twsnl__screen {
  flex: 1;
  min-height: 0;
  position: relative;                   /* the image must not size the row */
  border-radius: 26px 26px 0 0;
  overflow: hidden;
  background: #fff;
}
.twsnl__screen img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
}

/* columns ------------------------------------------------------------------ */
.twsnl__cols {
  display: flex;
  flex-direction: column;   /* stacked by default; goes side-by-side below */
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}
.twsnl__text {
  flex: 0 0 auto;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.twsnl__kicker {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}
.twsnl__strapline {
  white-space: nowrap;
  font-family: var(--twsnl-font-accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  color: var(--twsnl-muted);
  padding-left: 12px;
  border-left: 1px solid currentColor;
}
.twsnl__eyebrow {
  white-space: nowrap;
  font-family: var(--twsnl-font-accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 14px;
  color: var(--twsnl-accent-text);
}
.twsnl__title {
  margin: 0;
  font-family: var(--twsnl-font-display);
  font-weight: 700;
  font-size: var(--twsnl-title-size);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--twsnl-ink);
}
.twsnl__standfirst {
  margin: 0;
  font-size: var(--twsnl-standfirst-size);
  line-height: 1.5;
  text-wrap: pretty;
}

.twsnl__button[disabled] {
  opacity: 0.55;
  cursor: progress;
}
.twsnl__success {
  margin: 0;
  font-family: var(--twsnl-font-accent);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.45;
  color: var(--twsnl-ink);
  padding: 14px 16px;
  background: #f4f2ee;
  border-left: 4px solid var(--twsnl-accent);
  outline: none;
  text-wrap: pretty;
}

/* form -------------------------------------------------------------------- */
.twsnl__form {
  flex: 0 0 auto;
  min-width: 200px;
  max-width: 420px;   /* stacked: don't let the field run the full width */
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.twsnl__label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--twsnl-muted);
}
.twsnl__input {
  font-family: inherit;
  font-size: 17px;
  padding: 14px 16px;
  min-height: 50px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #b9b9b9;
  border-radius: 0;
  background: #fff;
  color: var(--twsnl-ink);
  outline: none;
}
.twsnl__input:focus { border-color: var(--twsnl-ink); }
.twsnl__input::placeholder { color: #8a8579; }

.twsnl__consent {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}
.twsnl__consent input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--twsnl-ink);
}

.twsnl__button {
  font-family: var(--twsnl-font-accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 19px;
  color: var(--twsnl-on-accent);
  background: var(--twsnl-accent);
  border: none;
  border-radius: 0;
  padding: 15px 22px;
  min-height: 52px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.twsnl__button:hover { filter: brightness(0.9); }
.twsnl__button:focus-visible { outline: 3px solid var(--twsnl-ink); outline-offset: 2px; }
.twsnl__button span { font-family: var(--twsnl-font-body); font-size: 17px; }

.twsnl__smallprint { margin: 0; font-size: 12px; line-height: 1.45; color: var(--twsnl-muted); }
.twsnl__smallprint a,
.twsnl a {
  color: var(--twsnl-body);
  text-decoration: underline;
  text-decoration-color: var(--twsnl-accent);
  text-underline-offset: 2px;
}
.twsnl__smallprint a:hover,
.twsnl a:hover { color: var(--twsnl-accent-text); }

/* Three states, narrow first:
   1. stacked (everything above this comment)
   2. >=780px  two text columns, no phone
   3. >=940px  phone alongside them (type grows again at 1400 and 1700)
   Widths are the BLOCK's own width, not the viewport. ------------------------ */
.twsnl__label { font-size: 0; gap: 0; }
.twsnl__input { font-size: 16px; }
.twsnl__button { min-height: 48px; padding: 13px 20px; }
.twsnl__smallprint { font-size: 12px; }
.twsnl__title { font-size: calc(var(--twsnl-title-size) - 6px); line-height: 1.12; }
.twsnl__standfirst { font-size: calc(var(--twsnl-standfirst-size) - 1px); }
.twsnl__input { font-size: 16px; }     /* stops iOS zooming on focus */

/* 2. two columns of text, still no phone */
@container (min-width: 780px) {
  .twsnl { margin-top: 40px; padding: 40px 32px; }
  .twsnl__cols { flex-direction: row; gap: 40px; }
  .twsnl__text { gap: 12px; }
  .twsnl__form { gap: 13px; }
  .twsnl__label { font-size: 13px; gap: 7px; }
  .twsnl__button { min-height: 52px; padding: 15px 22px; }
  .twsnl__smallprint { font-size: 12.5px; }
  .twsnl__text { flex: 1 1 300px; max-width: 420px; }   /* keeps the measure readable AND
                                                          keeps the step into the phone
                                                          layout small */
  .twsnl__form { flex: 1 1 300px; width: auto; max-width: 360px; }
  .twsnl__title { font-size: var(--twsnl-title-size); line-height: 1.08; }
  .twsnl__standfirst { font-size: var(--twsnl-standfirst-size); }
}

/* 3. widest: phone alongside the two text columns. Set high enough that the
   headline column is never narrower here than it was in state 2. */
@container (min-width: 940px) {
  .twsnl {
    min-height: 300px;                 /* the phone needs room to read as a phone */
    /* Everything here grows CONTINUOUSLY with the block. Stepping the phone,
       gutters, padding and form width at a breakpoint took width away from the
       headline column at the very moment it should have gained some. */
    --twsnl-phone: clamp(140px, 15cqi, 260px);
    grid-template-columns: var(--twsnl-phone) minmax(0, 1fr);
    gap: clamp(28px, 2.4cqi, 40px);
    padding: clamp(40px, 3.2cqi, 52px) clamp(30px, 3.2cqi, 48px);
  }
  .twsnl__phone { display: flex; }
  .twsnl__cols { gap: clamp(28px, 2.4cqi, 40px); }
  .twsnl__text { max-width: none; }
  .twsnl__form { max-width: clamp(320px, 25cqi, 360px); }
}

/* plenty of room: give the phone and the gutters their full size */
/* Type only — no geometry — so the column never loses width here. */
@container (min-width: 1400px) {
  .twsnl__eyebrow { font-size: 15px; }
  .twsnl__title { font-size: calc(var(--twsnl-title-size) + 4px); }
  .twsnl__standfirst { font-size: calc(var(--twsnl-standfirst-size) + 1px); }
}

@container (min-width: 1700px) {
  .twsnl__eyebrow { font-size: 16px; }
  .twsnl__strapline { font-size: 13px; }
  .twsnl__title { font-size: calc(var(--twsnl-title-size) + 9px); }
  .twsnl__standfirst { font-size: calc(var(--twsnl-standfirst-size) + 2px); }
}

/* A block rendered without its screenshot must not reserve the phone column. */
.twsnl:not(:has(.twsnl__phone)) { grid-template-columns: minmax(0, 1fr); }

/* fallback for browsers without container queries -------------------------- */
@supports not (container-type: inline-size) {
  @media (min-width: 900px) {
    .twsnl { margin-top: 40px; padding: 40px 32px; }
    .twsnl__cols { flex-direction: row; gap: 40px; }
    .twsnl__text { flex: 1 1 300px; }
    .twsnl__form { flex: 1 1 300px; width: auto; max-width: 360px; }
    .twsnl__title { font-size: var(--twsnl-title-size); }
    .twsnl__standfirst { font-size: var(--twsnl-standfirst-size); }
  }
  @media (min-width: 1250px) {
    .twsnl {
      min-height: 300px;
      grid-template-columns: 260px minmax(0, 1fr);
      padding: 48px 44px;
    }
    .twsnl__phone { display: flex; }
  }
}
