/*
 * Bring Home Good Fortune — Brooke Bond Red Label microsite
 * Layout is built from the 1080×1920 design: 1cqw = 10.8 design px.
 */
:root {
  --maroon: #3d0302;
  --maroon-deep: #240100;
  --green: #144323;
  --green-hover: #0d2f18;
  --ink: #353535;
  --red: #d41f26;
  --gold-card: #e0b779;
  --white: #ffffff;
  --error: #c4161c;
  --radius-input: 6px;
  --page-max: 540px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--maroon-deep);
  font-family: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

img { display: block; max-width: 100%; height: auto; }

/* ---------- Page column ---------- */
.page {
  container-type: inline-size;
  position: relative;
  width: 100%;
  max-width: var(--page-max);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background-color: var(--maroon);
  background-image: url('../img/bg.jpg');
  background-image: image-set(url('../img/bg.webp') type('image/webp'), url('../img/bg.jpg') type('image/jpeg'));
  background-position: center top;
  background-size: cover;
  background-repeat: no-repeat;
}

/* Wider screens: show the column on top of the same artwork, dimmed */
@media (min-width: 600px) {
  body {
    background-image: linear-gradient(rgba(20, 0, 0, .55), rgba(20, 0, 0, .55)), url('../img/bg.jpg');
    background-image: linear-gradient(rgba(20, 0, 0, .55), rgba(20, 0, 0, .55)),
      image-set(url('../img/bg.webp') type('image/webp'), url('../img/bg.jpg') type('image/jpeg'));
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
  }
  .page { box-shadow: 0 0 60px rgba(0, 0, 0, .55); }
}

/* ---------- Header (logo + title + diya divider) ---------- */
.brand {
  width: 58.7cqw;
  margin: 4.44cqw 0 0;
}
.brand a { display: block; }

/* ---------- Form card ---------- */
.card {
  position: relative;
  z-index: 2;
  width: calc(100% - 2 * max(12px, 3.9cqw));
  margin-top: 4.2cqw;
  padding: max(18px, 4cqw) max(16px, 4cqw) max(18px, 3.6cqw);
  background: var(--white);
  border: 2px solid var(--green);
  border-radius: max(12px, 2.2cqw);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.grid {
  display: grid;
  /* design columns are 492px / 372px */
  grid-template-columns: 1.32fr 1fr;
  column-gap: max(14px, 4.3cqw);
  row-gap: 4px;
}
.span-2 { grid-column: 1 / -1; }

@media (max-width: 359px) {
  .grid { grid-template-columns: 1fr; }
}

.field { min-width: 0; }

.field > label:not(.file):not(.check),
.field > .label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}
.req { color: var(--red); }

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"] {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-weight: 600;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--green);
  border-radius: var(--radius-input);
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus-visible { box-shadow: 0 0 0 3px rgba(20, 67, 35, .22); }

.error {
  min-height: 16px;
  margin: 3px 0 2px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--error);
}
.field.is-invalid input[type="text"],
.field.is-invalid input[type="tel"],
.field.is-invalid input[type="email"],
.field.is-invalid .file { border-color: var(--error); }

/* File upload */
.file {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 4px 0 12px;
  border: 1.5px solid var(--green);
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: box-shadow .15s ease;
}
.file input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.file:focus-within { box-shadow: 0 0 0 3px rgba(20, 67, 35, .22); }
.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: #8a8a8a;
}
.file.has-file .file-name { color: var(--ink); }
.file-btn {
  flex: none;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 800;
  color: var(--white);
  background: var(--green);
  border-radius: 4px;
}
.file:hover .file-btn { background: var(--green-hover); }

/* Terms checkbox */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: clamp(13px, 3.6cqw, 16px);
  font-weight: 800;
  line-height: 1.3;
  color: var(--ink);
  cursor: pointer;
}
.check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.check .box {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--green);
  border-radius: 3px;
  background: var(--white);
}
.check input:checked + .box { background: var(--green); }
.check input:checked + .box::after {
  content: '';
  position: absolute;
  left: 5.5px;
  top: 1.5px;
  width: 5px;
  height: 10px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(20, 67, 35, .25); }
.field.is-invalid .check .box { border-color: var(--error); }
.check a {
  color: var(--green);
  text-decoration: none;
}
.check a:hover { text-decoration: underline; }

/* Honeypot */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--error);
  text-align: center;
}
.form-error:not(:empty) { margin-bottom: 10px; }

.submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  margin-top: 6px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--green);
  border: 0;
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.submit:hover { background: var(--green-hover); }
.submit:active { transform: translateY(1px); }
.submit:focus-visible { outline: 3px solid rgba(20, 67, 35, .35); outline-offset: 2px; }
.submit[disabled] { opacity: .75; cursor: progress; }
.submit.is-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tagline + footer scene ---------- */
.tagline {
  position: relative;
  z-index: 2;
  width: 63.7cqw;
  margin: 5cqw 0 0;
}

.scene {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: auto;
  /* blend the cropped scene into the page background */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, rgba(0,0,0,.6) 14%, #000 30%);
  mask-image: linear-gradient(to bottom, transparent 0, rgba(0,0,0,.6) 14%, #000 30%);
}

/* ---------- Thank-you screen ---------- */
.thanks-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 2 * 11.2cqw);
  aspect-ratio: 837 / 570;
  margin-top: 8.4cqw;
  padding: 6cqw;
  background: var(--gold-card);
  border: max(2px, .46cqw) solid var(--red);
  border-radius: 4.6cqw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  animation: rise .5s ease-out both;
}
.thanks-card h1 { width: 68.3%; margin: 0; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.page--thanks .scene { margin-top: auto; padding-top: 6cqw; }

/* ---------- Terms content (page + popup) ---------- */
.terms { margin-bottom: 8cqw; font-size: 15px; line-height: 1.6; }
.terms h1 { margin: 0 0 6px; font-size: 21px; line-height: 1.3; color: var(--green); }
.terms-content { font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.terms-content h2 { margin: 20px 0 6px; font-size: 16px; font-weight: 800; color: var(--green); }
.terms-content h2:first-of-type { margin-top: 10px; }
.terms-content ul { margin: 0; padding-left: 20px; }
.terms-content li { margin: 0 0 6px; }
.terms-content li::marker { color: var(--green); }
.terms-content strong { font-weight: 800; }
.terms-content a { color: var(--green); font-weight: 800; word-break: break-word; }
.terms-updated { margin: 0; font-size: 13px; font-weight: 700; color: #7a7a7a; }
.terms-back { margin: 22px 0 0; }
.terms-back a { color: var(--green); font-weight: 800; }

/* ---------- Terms popup ---------- */
.terms-modal {
  width: min(560px, calc(100vw - 24px));
  max-height: min(86vh, 760px);
  max-height: min(86svh, 760px);
  padding: 0;
  border: 2px solid var(--green);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.terms-modal[open] {
  display: flex;
  flex-direction: column;
  animation: rise .25s ease-out both;
}
.terms-modal::backdrop { background: rgba(25, 2, 0, .72); }
.terms-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px 20px;
  border-bottom: 1px solid #e6e1da;
}
.terms-modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--green); }
.terms-modal-x {
  flex: none;
  width: 36px;
  height: 36px;
  font: inherit;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.terms-modal-x:hover { background: #f1eee9; }
.terms-modal-body {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px 20px 16px;
}
.terms-modal-body:focus { outline: none; }
.terms-loading { margin: 24px 0; text-align: center; color: #7a7a7a; font-weight: 700; }
.terms-modal-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e6e1da;
}
.terms-btn {
  flex: 1;
  height: 46px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  border-radius: var(--radius-input);
  cursor: pointer;
}
.terms-btn-ghost { color: var(--green); background: var(--white); border: 1.5px solid var(--green); }
.terms-btn-ghost:hover { background: #f2f7f3; }
.terms-btn-agree { flex: 1.4; color: var(--white); background: var(--green); border: 0; letter-spacing: .03em; }
.terms-btn-agree:hover { background: var(--green-hover); }
.terms-btn:focus-visible, .terms-modal-x:focus-visible { outline: 3px solid rgba(20, 67, 35, .35); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
