:root {
  --backdrop: #dfdfdf; /* the light gray Paperless Post opens envelopes on */
  --paper: #fdfbf7;
  --ink: #2f2c28;
  --ink-soft: #4a4640;
  --accent: #b9432c;
  --link: #3f63c4;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }
html.locked, html.locked body { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

/* ---------- 3D stage ---------- */

#stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 480px;
  overflow: hidden;
  background: var(--backdrop);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.8s ease;
}
#scene.ready { opacity: 1; }

.pill {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
  transform: translateX(-50%);
  padding: 11px 22px;
  border: 1px solid rgba(47, 44, 40, 0.18);
  border-radius: 999px;
  background: rgba(253, 251, 247, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  animation: breathe 2.4s ease-in-out infinite;
  transition: opacity 0.4s ease;
}
.pill.gone { opacity: 0; pointer-events: none; }

@keyframes breathe {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}

#after {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: fade-up 0.8s ease both;
}
#after[hidden] { display: none; }

.cue {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
}
.cue svg { animation: nudge 1.8s ease-in-out infinite; }

.link {
  border: 0;
  background: none;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Details ---------- */

#details {
  max-width: 980px;
  margin: 0 auto;
  padding: 72px 24px calc(80px + env(safe-area-inset-bottom));
  text-align: center;
}

h1 {
  margin: 0 0 48px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(44px, 9vw, 84px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.to {
  margin: 0 0 32px;
  font-family: var(--serif);
  font-size: 22px;
}

.label {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.question p:not(.label) {
  margin: 0 0 24px;
  font-size: 19px;
  color: var(--ink-soft);
}

.button {
  display: inline-block;
  padding: 16px 22px;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}
.button:hover, .button:focus-visible { background: var(--ink); color: var(--paper); }

.message {
  margin: 80px auto 0;
  max-width: 720px;
  font-size: 19px;
  line-height: 1.75;
  color: var(--ink-soft);
}
.message p { margin: 0 0 28px; }

.meta {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  margin-top: 88px;
  padding: 0 4%;
  text-align: left;
}
.meta > div:last-child { text-align: right; }
.meta .label { margin-bottom: 22px; }
.value {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
}
.date {
  text-decoration: none;
  border-bottom: 2px solid var(--link);
  padding-bottom: 3px;
}

@media (max-width: 600px) {
  #details { padding-top: 56px; }
  h1 { margin-bottom: 36px; }
  .message { margin-top: 56px; font-size: 17px; }
  .message br.wide { display: none; }
  .meta { flex-direction: column; align-items: center; gap: 36px; margin-top: 56px; text-align: center; }
  .meta > div:last-child { text-align: center; }
  .meta .label { margin-bottom: 12px; }
  .value { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .pill, .cue svg { animation: none; }
}

/* ---------- Website button ---------- */

.message .button { margin-top: 12px; }
.button.solid { background: var(--ink); color: var(--paper); }
.button.solid:hover, .button.solid:focus-visible { background: #000; }
button.button { background: none; cursor: pointer; font-family: var(--sans); }

/* ---------- Respond sheet ---------- */

html.sheet-open, html.sheet-open body { overflow: hidden; }

.sheet {
  --line: #e4dfd6;
  --label: #8f897f;
  --err: #b3362a;
  width: min(480px, calc(100% - 32px));
  max-width: none;
  max-height: min(820px, calc(100svh - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(40, 35, 30, 0.28);
}
/* the sheet takes focus itself on open, so no ring lands on the close button */
.sheet:focus { outline: none; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.45s cubic-bezier(.2,.9,.25,1); }
.sheet.closing { animation: sheet-out 0.22s ease-in forwards; }
.sheet::backdrop {
  background: rgba(60, 55, 50, 0.28);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  animation: fade-in 0.35s ease;
}
.sheet.closing::backdrop { animation: fade-out 0.22s ease-in forwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(10px) scale(0.985); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* `1 1 auto`, not `flex: 1`: Safari collapses a 0-basis flex child to zero height inside the
   auto-height dialog, which made the whole sheet invisible there */
.sheet form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.sheet form[hidden] { display: none; }

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 40px 32px 8px;
}
/* contents drift in one after another */
.sheet[open] .sheet-body > * { animation: rise-in 0.5s cubic-bezier(.2,.9,.25,1) both; animation-delay: calc(var(--i, 0) * 50ms + 80ms); }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }

.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(253, 251, 247, 0.85);  /* stays legible over the form as it scrolls */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.sheet-close:hover { background: #efebe4; color: var(--ink); }
.sheet-close svg { width: 20px; height: 20px; }

.sheet-head { margin-bottom: 28px; text-align: center; }
.sheet-title { margin: 0 0 6px; font: 400 32px/1.1 var(--serif); }
.sheet-sub { margin: 0; color: var(--ink-soft); font-size: 15px; }

/* Floating-label fields (16px text so iPhones don't zoom in) */
.field { position: relative; margin-bottom: 12px; }
.field[hidden] { display: none; }
.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  height: 54px;
  padding: 22px 14px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 16px/1.3 var(--sans);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { height: auto; min-height: 100px; padding-top: 26px; resize: none; }
.field label {
  position: absolute;
  top: 17px;
  left: 15px;
  max-width: calc(100% - 30px);
  overflow: hidden;
  color: var(--label);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.18s ease, color 0.18s;
}
.field label span { color: #b6b0a6; }
.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field textarea:focus + label,
.field textarea:not(:placeholder-shown) + label,
.field.filled label,
.field select:focus + label { transform: translateY(-9px) scale(0.75); }
.field input:focus + label,
.field textarea:focus + label,
.field select:focus + label { color: var(--ink-soft); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #d6d0c5; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(47, 44, 40, 0.07); }
.field input:-webkit-autofill { -webkit-box-shadow: 0 0 0 40px #fff inset; -webkit-text-fill-color: var(--ink); }

.field.select select { padding-right: 36px; cursor: pointer; }
.field.select::after {
  content: "";
  position: absolute;
  top: 22px;
  right: 17px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--label);
  border-bottom: 1.5px solid var(--label);
  transform: rotate(45deg);
  pointer-events: none;
}

.field.invalid input, .field.invalid select { border-color: var(--err); box-shadow: 0 0 0 4px rgba(179, 54, 42, 0.07); }
.field .err {
  display: block;
  max-height: 0;
  overflow: hidden;
  color: var(--err);
  font-size: 13px;
  transition: max-height 0.2s, margin 0.2s;
}
.field.invalid .err { max-height: 20px; margin-top: 6px; }

.addr { min-width: 0; margin: 0; padding: 0; border: 0; }
.addr-title {
  margin: 0 0 10px;
  padding: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.addr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.addr-row .city { grid-column: 1 / -1; }

/* Family: "Someone lives at a different address?" */
.elsewhere { margin: 2px 0 18px; }
.text-btn {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: rgba(47, 44, 40, 0.3);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: text-decoration-color 0.2s;
}
.text-btn:hover { text-decoration-color: currentColor; }
.hint { margin: 12px 0 0; color: var(--ink-soft); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 4px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.chip span:hover { border-color: #cfc8bc; }
.chip input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.chip input:disabled + span { opacity: 0.4; cursor: default; }

/* Smooth open/close for revealed sections */
.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.35s cubic-bezier(.2,.9,.25,1), opacity 0.25s; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal > div { min-height: 0; overflow: hidden; }
#separate-blocks .addr { padding: 8px 0 6px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.sheet-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 32px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(47, 44, 40, 0.06);
}
.sheet-error { margin: 0; color: var(--err); font-size: 14px; text-align: center; }
.sheet-error:empty { display: none; }

.sheet-submit {
  position: relative;
  height: 52px;
  border: 0;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
  font: 500 16px var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.sheet-submit:hover { background: #000; }
.sheet-submit:active { transform: scale(0.985); }
.sheet-submit.loading { color: transparent; pointer-events: none; }
.sheet-submit.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid rgba(253, 251, 247, 0.35);
  border-top-color: var(--paper);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sheet-submit.ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.sheet-submit.ghost:hover { background: rgba(47, 44, 40, 0.04); }

/* Confirmation */
.sheet-thanks { padding: 48px 32px 32px; padding-bottom: max(32px, env(safe-area-inset-bottom)); text-align: center; overflow-y: auto; }
.sheet-thanks[hidden] { display: none; }
.sheet-thanks:not([hidden]) > * { animation: rise-in 0.5s cubic-bezier(.2,.9,.25,1) both; }
.sheet-thanks:not([hidden]) > :nth-child(2) { animation-delay: 0.25s; }
.sheet-thanks:not([hidden]) > :nth-child(3) { animation-delay: 0.3s; }
.sheet-thanks:not([hidden]) > :nth-child(4) { animation-delay: 0.38s; }
.sheet-thanks:not([hidden]) > :nth-child(5) { animation-delay: 0.45s; }
.check {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.6s 0.1s ease forwards; }
.check path { stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw 0.35s 0.55s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.thanks-address {
  max-width: 320px;
  margin: 16px auto 28px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 15px;
  line-height: 1.55;
  text-align: left;
  white-space: pre-line;
}
.thanks-address strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.thanks-address .one + .one { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sheet-thanks .sheet-submit { width: 100%; max-width: 320px; }

/* Phones: a bottom sheet that slides up */
@media (max-width: 600px) {
  .sheet {
    width: 100%;
    max-height: 94svh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }
  .sheet[open] { animation: sheet-up 0.45s cubic-bezier(.2,.9,.25,1); }
  .sheet.closing { animation: sheet-down 0.22s ease-in forwards; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  @keyframes sheet-down { to { transform: translateY(100%); } }
  .sheet-body { padding: 36px 20px 4px; }
  .sheet-footer { padding: 12px 20px 20px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .sheet-title { font-size: 28px; }
  .sheet-thanks { padding: 40px 20px 24px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet::backdrop, .sheet-body > *, .sheet-thanks > *, .reveal, .check * { animation: none !important; transition: none !important; }
  .check circle, .check path { stroke-dashoffset: 0; }
}
