:root {
  --paper: #f6f4f0;
  --ink: #121212;
  --muted: #77736c;
  --line: #dcd7cf;
  --danger: #9b2c2c;
  --serif: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(0.16, 0.84, 0.24, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}
html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
p {
  margin: 0;
}

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

::selection {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: 500 13px/1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 18px 40px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, transform 0.3s var(--ease-out);
}
.btn:hover {
  background: transparent;
  color: var(--ink);
}
.btn:active {
  transform: scale(0.97);
}
.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- the page: one screen ---------- */

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
}
.hero-lily {
  height: min(58svh, 640px, 170vw);
  aspect-ratio: 1100 / 2507;
  margin-bottom: clamp(16px, 4svh, 40px);
}
.eyebrow {
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-left: 0.42em; /* optically centre tracked caps */
}
h1 {
  font: 400 clamp(52px, min(11vw, 12svh), 112px)/0.95 var(--serif);
  letter-spacing: -0.01em;
  margin-bottom: clamp(24px, 4.5svh, 44px);
}

/* ---------- lily ---------- */

[data-lily] img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- apply dialog ---------- */

dialog {
  width: min(100% - 32px, 520px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 40px 120px -40px rgb(0 0 0 / 0.35);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
dialog[open] {
  animation: rise 0.6s var(--ease-out);
}
dialog::backdrop {
  background: rgb(246 244 240 / 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
dialog[open]::backdrop {
  animation: fade 0.4s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
}
@keyframes fade {
  from { opacity: 0; }
}
.sheet {
  --pad: clamp(24px, 6vw, 48px);
  padding: var(--pad) var(--pad) 0;
  position: relative;
}
.icon-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.sheet h2 {
  font: 400 44px/1 var(--serif);
  margin-bottom: 8px;
}
.sheet .sub {
  color: var(--muted);
  margin-bottom: 28px;
}
.field {
  display: block;
  margin-bottom: 20px;
}
.field > span {
  display: block;
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.field > span i {
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.7;
}
.field input {
  width: 100%;
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 17px/1.4 var(--sans); /* ≥16px: no iOS zoom on focus */
  padding: 10px 0;
  transition: border-color 0.25s;
}
.field input::placeholder {
  color: #b2ada5;
}
.field input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}
.field input[aria-invalid="true"] {
  border-bottom-color: var(--danger);
}
/* gender: one full-width two-part switch */
fieldset.field {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
  min-width: 0;
}
.choice legend {
  padding: 0;
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.2s;
}
.seg label {
  position: relative;
}
.seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.seg span {
  display: block;
  text-align: center;
  line-height: 37px; /* switch is 45px tall overall, same as the birth-year field next to it */
  border-radius: 999px;
  font-size: 15px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.seg input:hover + span {
  color: var(--ink);
}
.seg input:checked + span {
  background: var(--ink);
  color: var(--paper);
}
.seg input:focus-visible + span {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}
.choice[aria-invalid="true"] .seg {
  border-color: var(--danger);
}
/* gender + birth year on one line: wider switch, narrow year; labels and bottoms line up */
.row-gy {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 0 20px;
  align-items: start;
}
.row-gy .field > span {
  margin-bottom: 8px;
}
.row-gy .field input {
  height: 45px;
}
.field small {
  display: block;
  min-height: 0;
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
}
.field small:empty {
  display: none;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
@media (max-width: 340px) {
  .row {
    grid-template-columns: 1fr;
  }
}
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
/* The submit bar stays pinned to the bottom while there is more form to scroll,
   with a fade above it so it's clear the fields continue underneath. */
.form-foot {
  position: sticky;
  bottom: 0;
  margin-top: 4px;
  padding: 12px 0 var(--pad);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-foot::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 56px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--paper) 0%, transparent), var(--paper) 85%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
dialog.has-more .form-foot::before {
  opacity: 1;
}
dialog.has-more .form-foot {
  box-shadow: 0 -1px 0 var(--line);
}
.form-foot .btn {
  width: 100%;
}
.fine {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.form-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}
.form-error:empty {
  display: none;
}

.done {
  display: none;
  text-align: center;
  padding: 24px 0 var(--pad);
}
.done-lily {
  height: 220px;
  aspect-ratio: 1100 / 2507;
  margin: 0 auto 24px;
}
.done p {
  color: var(--muted);
  margin: 4px 0 32px;
}
dialog.is-done form {
  display: none;
}
dialog.is-done .done {
  display: block;
}

/* phones: tighter spacing so the whole form fits on most screens */
@media (max-width: 560px) {
  dialog {
    width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
  }
  .sheet h2 {
    font-size: 36px;
    margin-bottom: 6px;
  }
  #apply-title {
    padding-right: 36px; /* keep the form title clear of the × button */
  }
  .sheet .sub {
    font-size: 15px;
    line-height: 1.45;
    margin-bottom: 18px;
  }
  .field,
  fieldset.field {
    margin-bottom: 14px;
  }
  .field input {
    padding: 7px 0;
  }
  .choice legend,
  .row-gy .field > span {
    margin-bottom: 6px;
  }
  .row-gy {
    gap: 0 14px;
  }
  .row {
    gap: 0 14px;
  }
  .form-foot {
    gap: 10px;
  }
  .icon-btn {
    top: 12px;
    right: 10px;
  }
}

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