/* Chelmsford Summer Series - 2027 priority access
   Palette sampled from the site's own dusk photograph of Central Park
   (fairy-lit trees, the lit viaduct on the horizon). Type is Fraunces +
   DM Sans - both SIL OFL, self-hosted - carried over from chelmsford.live
   so the page reads as the same brand.

   Signature element: the "horizon" rule under the title - a hairline that
   draws outward from a warm centre point, echoing the lit bridge at the
   photograph's vanishing point, carrying SEE YOU IN 2027 across it. */

/* ---------- Tokens ---------- */
:root {
  --night:       #0E0B18;   /* deepest sky / foreground - page base */
  --night-2:     #171226;   /* panel base */
  --dusk:        #24325E;   /* mid sky - edge light */
  --cream:       #F5EFE3;   /* brand text */
  --cream-mute:  rgba(245, 239, 227, 0.70);
  --cream-faint: rgba(245, 239, 227, 0.42);
  --amber:       #E5B66A;   /* brand accent - the fairy lights */
  --amber-deep:  #C8963A;

  --field-bg:    rgba(245, 239, 227, 0.055);
  --field-flat:  #1A1720;   /* field stack flattened opaque - autofill shadow */
  --line:        rgba(245, 239, 227, 0.14);

  --panel-w:     26.5rem;
  --ease:        cubic-bezier(0.22, 0.61, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

/* html carries the base colour; body stays transparent so it can never
   paint over the fixed background layers (gotcha 16). */
html {
  background: var(--night);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: transparent;
  color: var(--cream);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-variation-settings: "opsz" 14;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ---------- Fonts (SIL OFL 1.1 - see assets/fonts/OFL.txt) ---------- */
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/Fraunces-var.woff2?v=20260831-6") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/Fraunces-Italic-var.woff2?v=20260831-6") format("woff2-variations");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/assets/fonts/DMSans-var.woff2?v=20260831-6") format("woff2-variations");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

/* ---------- Background ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--night);
}
.bg__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 58%;
  display: block;
}
/* Scrim: darkens the foreground so the panel and footer stay legible,
   and keeps the lit horizon showing through the middle. */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom,
      rgba(14, 11, 24, 0.62) 0%,
      rgba(14, 11, 24, 0.28) 26%,
      rgba(14, 11, 24, 0.40) 52%,
      rgba(14, 11, 24, 0.86) 100%);
}

/* ---------- Shell ---------- */
.sheet {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: clamp(1.1rem, 3.4vw, 2.2rem);
}
.wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.4vh, 1.5rem);
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;              /* auto at EVERY breakpoint (gotcha 10) */
  padding: clamp(0.5rem, 1.2vh, 0.9rem) 0;
}

/* ---------- Brand block ---------- */
.brand {
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.brand__lockup {
  width: min(21rem, 78vw);
  height: auto;
  display: block;
  opacity: 0;
  animation: rise 1s var(--ease) 0.05s forwards;
}
.brand__title {
  margin: clamp(1.1rem, 3.2vh, 1.9rem) 0 0;
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-variation-settings: "opsz" 144, "wght" 400, "SOFT" 0, "WONK" 0;
  font-weight: 400;
  font-size: clamp(1.9rem, 6.4vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.005em;
  text-wrap: balance;          /* never nowrap a display title (gotcha 8) */
  opacity: 0;
  animation: rise 1s var(--ease) 0.18s forwards;
}
.brand__title em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 400, "SOFT" 0, "WONK" 1;
}

/* --- Signature: the horizon rule --- */
.horizon {
  margin: clamp(1rem, 2.8vh, 1.5rem) 0 0;
  width: min(32rem, 96%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(0.75rem, 3vw, 1.15rem);
}
.horizon__hair {
  height: 1px;
  background: linear-gradient(to var(--dir, right),
    rgba(229, 182, 106, 0.55), rgba(245, 239, 227, 0.06));
  transform-origin: var(--origin, left);
  animation: draw 1.1s var(--ease) 0.5s both;
}
.horizon__hair--l { --dir: left;  --origin: right; }
.horizon__hair--r { --dir: right; --origin: left;  }
.horizon__year {
  font-family: "DM Sans", sans-serif;
  font-variation-settings: "opsz" 14, "wght" 600;
  font-size: clamp(1rem, 3.8vw, 1.45rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  white-space: nowrap;
  /* the warm point on the horizon - the lit viaduct in the photograph */
  text-shadow: 0 0 22px rgba(229, 182, 106, 0.45);
  opacity: 0;
  animation: rise 0.9s var(--ease) 0.42s forwards;
}
.brand__line {
  margin: clamp(0.5rem, 1.3vh, 0.75rem) auto 0;
  max-width: 32rem;
  font-size: clamp(0.95rem, 3.4vw, 1.05rem);
  line-height: 1.6;
  color: var(--cream-mute);
  text-wrap: pretty;
  opacity: 0;
  animation: rise 1s var(--ease) 0.32s forwards;
}

/* ---------- Panel ---------- */
.signup {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
}
.panel {
  position: relative;
  isolation: isolate;          /* keeps the country dropdown above the frame (gotcha 5) */
  width: min(var(--panel-w), 100%);
  margin: 0 auto;
  padding: clamp(1.35rem, 4.6vw, 1.85rem);
  border-radius: 18px;
  background: rgba(11, 8, 18, 0.78);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  box-shadow:
    inset 0 0 0 1px rgba(245, 239, 227, 0.10),
    inset 0 1px 0 rgba(245, 239, 227, 0.16),
    0 26px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  animation: rise 1s var(--ease) 0.44s forwards;
}
.panel > * { position: relative; z-index: 1; }

/* one state visible at a time */
.panel__state { display: none; }
.panel[data-form-state="idle"]    .panel__idle,
.panel[data-form-state="otp"]     .panel__otp,
.panel[data-form-state="success"] .panel__success { display: block; }

.panel__eyebrow {
  margin: 0 0 0.5rem;
  font-variation-settings: "opsz" 14, "wght" 600;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
}
.panel__title {
  margin: 0 0 0.5rem;
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 144, "wght" 400, "SOFT" 0, "WONK" 0;
  font-weight: 400;
  font-size: clamp(1.35rem, 5vw, 1.6rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
}
/* state-scoped p rules must not out-specific the eyebrow (gotcha 7) */
.panel__lede,
.panel__state p:not(.panel__eyebrow):not(.form__error):not(.form__resend) {
  margin: 0 0 1.1rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--cream-mute);
}

/* ---------- Form ---------- */
.form__row { margin: 0 0 0.85rem; }
.form__label {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.form__input {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--field-bg);
  color: var(--cream);
  font-family: inherit;
  font-size: 1rem;             /* 16px min - stops iOS zoom-on-focus */
  line-height: 1.3;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease),
              box-shadow 0.2s var(--ease);
}
.form__input::placeholder { color: var(--cream-faint); }
.form__input:hover { border-color: rgba(245, 239, 227, 0.24); }
.form__input:focus {
  outline: none;
  border-color: var(--amber);
  background: rgba(245, 239, 227, 0.085);
  box-shadow: 0 0 0 3px rgba(229, 182, 106, 0.20);
}
.form__input--otp {
  text-align: center;
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 60, "wght" 500;
  font-size: 1.6rem;
  letter-spacing: 0.36em;
  text-indent: 0.36em;         /* re-centres against the trailing letter-space */
}

/* Chrome autofill: :-webkit-autofill ignores background - the inset shadow
   is the only override, and it must be the FLATTENED opaque equivalent of
   field-over-panel-over-photo, not the field's own rgba (gotcha 30). */
.form__input:-webkit-autofill,
.form__input:-webkit-autofill:hover,
.form__input:-webkit-autofill:focus,
.form__input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--field-flat) inset !important;
          box-shadow: 0 0 0 1000px var(--field-flat) inset !important;
  -webkit-text-fill-color: var(--cream) !important;
  caret-color: var(--cream);
  transition: background-color 9999s ease-in-out 0s;
}

/* Honeypot - display:none ONLY. Off-screen positioning gets autofilled by
   Chrome/Edge and silently blocks real signups (gotcha 2). */
.hp-row { display: none !important; }

.form__check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.62rem;
  align-items: start;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--cream-mute);
  cursor: pointer;
}
.form__check input {
  appearance: none;
  -webkit-appearance: none;
  width: 1.06rem;
  height: 1.06rem;
  margin: 0.12rem 0 0;
  border: 1px solid rgba(245, 239, 227, 0.34);
  border-radius: 5px;
  background: var(--field-bg);
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.form__check input:checked {
  background: var(--amber);
  border-color: var(--amber);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpolyline points='2,6.2 4.7,8.9 10,3.2' fill='none' stroke='%230E0B18' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 78%;
  background-repeat: no-repeat;
  background-position: center;
}
.form__check input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.form__check a { color: var(--cream); text-underline-offset: 2px; }
.form__check a:hover { color: var(--amber); }

.form__error {
  margin: 0.42rem 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #F2A196;
}
.form__error--global { margin-top: 0.7rem; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  margin-top: 1.05rem;
  padding: 0.92rem 1.1rem;
  border: 0;
  border-radius: 11px;
  font-family: inherit;
  font-variation-settings: "opsz" 14, "wght" 700;
  /* shrink before wrapping - never let a CTA label break (gotcha 26) */
  font-size: clamp(0.8rem, 3.4vw, 0.92rem);
  letter-spacing: clamp(0.04em, 0.5vw, 0.11em);
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
              filter 0.2s var(--ease);
}
.btn--primary {
  color: #1A0F05;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep));
  box-shadow: 0 10px 26px rgba(229, 182, 106, 0.24);
}
.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 14px 32px rgba(229, 182, 106, 0.34);
}
.btn:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Secondary CTA, success panel only. Deliberately quieter than the amber
   primary: the sign-up is already done, so this is an invitation rather than
   the main action, and it must not compete with "check your inbox". */
.btn--whatsapp {
  margin-top: 0.95rem;
  background: rgba(229, 182, 106, 0.10);
  box-shadow: inset 0 0 0 1px rgba(229, 182, 106, 0.45);
  color: var(--amber);
}
.btn--whatsapp:hover {
  background: rgba(229, 182, 106, 0.18);
  transform: translateY(-1px);
}
.btn__icon { width: 20px; height: 20px; flex: 0 0 auto; }

.form__resend {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  text-align: center;
  color: var(--cream-mute);
}
.form__resend-btn {
  border: 0;
  padding: 0;
  background: none;
  color: var(--amber);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.form__resend-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Success ---------- */
.panel__thanks {
  width: 100%;
  height: auto;
  display: block;
  margin: 0.2rem 0 1rem;
}
.panel__success-note {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--cream);
}

/* ---------- Footer ---------- */
.foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "logos logos logos"
    "email email email"
    "built built built";
  justify-items: center;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  margin: 0;                   /* full-bleed across the sheet, not a centred column */
  padding-top: clamp(0.9rem, 2.4vh, 1.3rem);
  border-top: 1px solid rgba(245, 239, 227, 0.12);
  opacity: 0;
  animation: rise 1s var(--ease) 0.62s forwards;
}
.foot__logos { grid-area: logos; display: flex; align-items: center; }
.foot__logos img {
  height: clamp(24px, 3.4vh, 34px);
  width: auto;
  display: block;
}
.foot__email { grid-area: email; margin: 0; }
.foot__email a {
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 24, "wght" 400;
  font-style: italic;
  font-size: clamp(0.78rem, 3vw, 0.88rem);
  color: var(--cream-mute);
  text-decoration: none;
  border-bottom: 1px solid rgba(245, 239, 227, 0.18);
  padding-bottom: 2px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.foot__email a:hover { color: var(--amber); border-color: var(--amber); }
.site-built { grid-area: built; margin: 0; }
.site-built a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(245, 239, 227, 0.14);
  background: rgba(10, 6, 6, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: rgba(245, 239, 227, 0.82);
  text-decoration: none;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
              border-color 0.25s var(--ease);
}
.site-built a:hover {
  background: rgba(10, 6, 6, 0.75);
  color: var(--cream);
  border-color: rgba(229, 182, 106, 0.5);
}
.site-built img { height: 14px; width: auto; display: block; }

/* ---------- intl-tel-input ---------- */
/* Hidden state lives in the vendor stylesheet; until it loads the list would
   flash open on first paint (gotcha 19). */
.iti__dropdown-content.iti__hide { display: none !important; }
.iti { width: 100%; display: block; }
.iti__country-container { z-index: 3; }
.iti input.form__input { padding-left: calc(52px + 0.7rem); }  /* app.js re-measures */
.iti__dropdown-content {
  background: #16111F;
  border: 1px solid rgba(245, 239, 227, 0.16);
  border-radius: 12px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.6);
  color: var(--cream);
}
.iti__country-list { background: transparent; }
.iti__country { color: var(--cream); }
.iti__country.iti__highlight,
.iti__country:hover { background: rgba(229, 182, 106, 0.16); }
.iti__dial-code { color: var(--cream-faint); }
.iti__search-input {
  /* keep the vendor's horizontal reservation or the magnifier lands on the
     word "Search" - never use the padding shorthand alone (gotcha 33) */
  padding: 9px 30px 9px 32px;
  background: #16111F;
  color: var(--cream);
  border: 0;
  border-bottom: 1px solid rgba(245, 239, 227, 0.14);
  border-radius: 12px 12px 0 0;
  font-family: inherit;
}
.iti__search-input::placeholder { color: var(--cream-faint); }

/* ---------- Motion ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes draw {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

/* =========================================================
   Layout blocks.
   Aspect-ratio thresholds, not width alone, so squarish
   in-between windows never fall through a gap (gotcha 20).
   ========================================================= */

/* --- Desktop / landscape tablet: stacked and centred --- */
@media (min-width: 768px) and (min-aspect-ratio: 7/10) {
  .wrap { gap: clamp(1.1rem, 2.6vh, 1.7rem); }
  .brand__lockup { width: min(27rem, 46vw); }
  .brand__title  { font-size: clamp(2.4rem, 4vw, 3.15rem); }
  .horizon       { width: min(42rem, 84%); }
  .foot {
    grid-template-areas: "email logos built";
    justify-items: center;
    gap: 1rem 1.6rem;
  }
  .foot__email { justify-self: start; }
  .site-built  { justify-self: end; }
}

/* --- Landscape phone: almost no height, so this is the one shape where
       side-by-side beats stacked. Placed AFTER the desktop block so it wins
       at equal specificity (gotcha 27). --- */
@media (min-width: 640px) and (min-aspect-ratio: 7/10) and (max-height: 520px) {
  .sheet { padding: 0.7rem 1rem; }
  .wrap {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(1.2rem, 3.5vw, 2.2rem);
    max-width: 58rem;
    padding: 0.4rem 0;
    min-height: 0;
  }
  .brand {
    flex: 1 1 0;
    min-width: 0;
    text-align: left;
    align-items: flex-start;
  }
  .brand__lockup { width: min(18rem, 40vw); }
  .brand__title  { font-size: clamp(1.5rem, 3.2vw, 2rem); margin-top: 0.7rem; }
  .horizon       { width: 100%; margin-top: 0.6rem; }
  .horizon__year { font-size: clamp(0.85rem, 2.2vw, 1.05rem); }
  .brand__line   { margin: 0.55rem 0 0; font-size: 0.85rem; }
  .signup        { flex: 0 0 auto; width: auto; }
  .panel {
    width: 21.5rem;
    padding: 1rem 1.1rem;
    max-height: calc(100svh - 4rem);
    overflow-y: auto;
  }
  .panel__eyebrow { margin-bottom: 0.3rem; font-size: 0.62rem; }
  .panel__title  { font-size: 1.15rem; margin-bottom: 0.35rem; }
  /* The brand column already carries the pitch, so the idle panel drops its
     lede here - that is the ~70px that keeps the CTA above the fold at 390px. */
  .panel__idle .panel__lede { display: none; }
  .panel__otp .panel__lede  { font-size: 0.8rem; margin-bottom: 0.7rem; }
  .form__row     { margin-bottom: 0.5rem; }
  .form__input   { padding: 0.6rem 0.8rem; font-size: 0.95rem; }
  .form__check   { font-size: 0.72rem; }
  .btn           { margin-top: 0.65rem; padding: 0.7rem 1rem; }
  .panel__thanks { margin-bottom: 0.6rem; }
  .foot          { padding-top: 0.6rem; gap: 0.5rem 1.2rem; }
  .foot__logos img { height: 22px; }
}

/* --- Very short portrait phones --- */
@media (max-aspect-ratio: 7/10) and (max-height: 700px) {
  .brand__lockup { width: min(17rem, 66vw); }
  .brand__title  { font-size: clamp(1.6rem, 5.6vw, 2rem); }
  .wrap { gap: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .brand__lockup, .brand__title, .brand__line, .panel, .foot, .horizon__year {
    opacity: 1;
  }
  .horizon__hair { transform: none; }
}
