/* App pages (auth + builder) — "devotional editorial" pass.
   Uses the shared tokens from styles.css. Squared, letterpress-quiet, gold hairlines,
   large ghosted numerals, ornament rules, keepsake summary, wax-seal success. */

:root { --app-line: rgba(51, 48, 42, 0.16); --app-gold: #9a7b3f; }

/* Warm atmosphere behind everything (sits above the shared grain) */
body.app-body {
  background:
    radial-gradient(120% 80% at 12% -8%, rgba(154, 123, 63, 0.10), transparent 55%),
    radial-gradient(120% 90% at 100% 0%, rgba(94, 115, 89, 0.09), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* ===== App bar (matches the landing's flat beige line) ===== */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(18px, 5vw, 48px);
  background: var(--bg-2);
  border-bottom: 1px solid var(--app-line);
}
.app-bar .brand { text-decoration: none; gap: 11px; }
.app-bar .brand-mark { width: 46px; height: 46px; border-radius: 9px; overflow: hidden; background: transparent; }
.app-bar .brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.app-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: "Mulish", system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
}
.save-state {
  font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 10px;
  padding: 5px 10px; border: 1px solid var(--app-line); color: var(--muted);
}
.save-state.saved { color: var(--sage); border-color: rgba(94, 115, 89, 0.4); }

/* Reusable ornament + gold rule */
.ornament {
  font-family: "Cormorant Garamond", serif; color: var(--app-gold);
  letter-spacing: 0.5em; font-size: 18px; line-height: 1;
}

/* ===== Auth ===== */
/* Auth page fits the viewport exactly — no scrolling. */
body.auth-page { height: 100svh; overflow: hidden; display: flex; flex-direction: column; }
body.auth-page .auth-wrap { flex: 1 1 auto; min-height: 0; }
.auth-wrap {
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vh, 44px) 20px;
}
.auth-card {
  position: relative;
  width: min(460px, 100%);
  background: var(--paper);
  border: 1px solid var(--app-line);
  box-shadow: var(--shadow);
  padding: clamp(34px, 5vw, 52px) clamp(28px, 5vw, 46px);
  text-align: center;
}
.auth-card::before { /* gold top rule */
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--app-gold) 30%, var(--sage) 70%, transparent);
}
.auth-card .ornament { display: block; margin-bottom: 18px; }
.auth-card h1 {
  font-size: clamp(36px, 5.4vw, 50px);
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.auth-sub {
  font-family: "Lora", Georgia, serif;
  font-size: 15px;
  color: var(--ink-2);
  margin-bottom: 30px;
  line-height: 1.6;
}
.auth-tabs {
  display: inline-flex;
  gap: 26px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--app-line);
}
.auth-tab {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0 2px 12px;
  font: 700 11px/1 "Mulish", system-ui, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}
.auth-tab::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--app-gold), var(--sage));
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-tab.active { color: var(--ink); }
.auth-tab.active::after { right: 0; }
.auth-form { text-align: left; }
.auth-note {
  margin-top: 16px;
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: 15px;
  color: var(--ink);
  text-align: center;
}

/* ===== Forms (shared) ===== */
.field { margin-bottom: 20px; }
.field > label,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-family: "Mulish", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: #fffdf8;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  padding: 13px 15px;
  font: 400 16px "Lora", Georgia, serif;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field input::placeholder, .field textarea::placeholder { color: #b3a890; }
.field textarea { min-height: 140px; line-height: 1.7; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--sage);
  box-shadow: inset 0 0 0 1px var(--sage), 0 0 0 3px rgba(94, 115, 89, 0.14);
  background: #fff;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.field-hint { margin-top: 6px; font-family: "Mulish", system-ui, sans-serif; font-size: 12px; color: var(--muted); }
.field-error { color: var(--rose); }

.btn-full { width: 100%; }
/* squared, letterpress button */
.button.button-solid {
  background: var(--sage); color: #fff8ea; border: 1px solid var(--sage); border-radius: 0;
  min-height: 52px; letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.button.button-solid:hover { background: #54684f; border-color: #54684f; transform: translateY(-1px); }

.auth-alt {
  margin-top: 22px;
  font-family: "Mulish", system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.auth-alt button { background: none; border: 0; color: var(--sage); font-weight: 700; cursor: pointer; }

/* ===== Builder ===== */
.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 370px);
  gap: clamp(24px, 4vw, 52px);
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(34px, 6vw, 64px) clamp(18px, 5vw, 48px) 90px;
  align-items: start;
}
@media (max-width: 920px) { .builder-layout { grid-template-columns: 1fr; } }

.builder-head { margin-bottom: 34px; }
.builder-head .eyebrow { color: var(--sage); }
.builder-head h1 { font-size: clamp(40px, 6vw, 68px); line-height: 1.0; letter-spacing: -0.02em; margin-top: 12px; }
.builder-head p { margin-top: 14px; color: var(--ink-2); max-width: 56ch; font-size: 16px; }
.builder-head .note {
  margin-top: 10px; font-family: "Caveat", cursive; font-size: 22px; color: var(--walnut);
}

.form-card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--app-line);
  border-radius: 0;
  box-shadow: var(--shadow-soft);
  padding: clamp(26px, 3.6vw, 40px);
  margin-bottom: 22px;
  overflow: hidden;
}
.form-card::before { /* gold left spine */
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--app-gold), var(--sage));
  opacity: 0.85;
}
.form-card .step {
  display: block;
  font-family: "Mulish", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--app-gold);
}
.form-card .step[data-step]::after { /* large ghost numeral */
  content: attr(data-step);
  position: absolute;
  top: 8px; right: 18px;
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: clamp(70px, 9vw, 104px);
  line-height: 1;
  color: rgba(154, 123, 63, 0.12);
  pointer-events: none;
}
.form-card > h2 { font-size: clamp(28px, 3.4vw, 36px); margin-top: 8px; letter-spacing: -0.01em; }
.form-card .card-intro { color: var(--muted); margin: 8px 0 24px; font-size: 15px; font-family: "Lora", serif; }

/* subdomain */
.subdomain {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  overflow: hidden;
  background: #fffdf8;
}
.subdomain input { border: 0; border-radius: 0; flex: 1; min-width: 0; box-shadow: none; background: transparent; }
.subdomain input:focus { box-shadow: none; }
.subdomain:focus-within { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(94,115,89,0.14); }
.subdomain .suffix {
  display: flex; align-items: center; padding: 0 15px;
  background: var(--bg-2); border-left: 1px solid var(--app-line);
  font: 600 14px "Mulish", system-ui, sans-serif; color: var(--muted); white-space: nowrap;
}
.avail { margin-top: 9px; font-family: "Mulish", system-ui, sans-serif; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.avail.ok { color: var(--sage); } .avail.ok::before { content: "✓ "; }
.avail.no { color: var(--rose); }

/* template cards */
.template-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .template-choice { grid-template-columns: 1fr; } }
.template-choice label {
  position: relative; display: block; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: 0; padding: 18px;
  background: #fffdf8; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.template-choice label:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }
.template-choice input { position: absolute; opacity: 0; pointer-events: none; }
.template-choice label:has(input:checked) {
  border-color: var(--sage); box-shadow: inset 0 0 0 1px var(--sage);
}
.template-choice label:has(input:checked)::after {
  content: "✓"; position: absolute; top: 10px; right: 12px;
  width: 22px; height: 22px; display: grid; place-items: center;
  background: var(--sage); color: #fff8ea; font-size: 12px;
}
.tpl-name { font-family: "Cormorant Garamond", serif; font-size: 26px; color: var(--ink); }
.tpl-swatch { display: flex; gap: 5px; margin: 12px 0 10px; }
.tpl-swatch span { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.06); }
.tpl-desc { font-family: "Mulish", system-ui, sans-serif; font-size: 12px; color: var(--muted); line-height: 1.55; }

/* photo dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 36px; text-align: center;
  border: 1.5px dashed var(--rule-strong); border-radius: 0;
  background: #fffdf8; color: var(--muted); cursor: pointer;
  font-family: "Mulish", system-ui, sans-serif; font-size: 13px; font-weight: 600;
  letter-spacing: 0.04em; transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.dropzone:hover { border-color: var(--sage); color: var(--ink); background: #fff; }
.dropzone input { display: none; }
.photo-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 16px; }
.photo-thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--app-line); }

/* aside — keepsake summary */
.summary {
  position: sticky;
  top: 92px;
  background: var(--paper);
  border: 1px solid var(--app-line);
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 30px 28px;
}
.summary::before {
  content: "· · ·"; display: block; text-align: center; margin-bottom: 14px;
  font-family: "Cormorant Garamond", serif; color: var(--app-gold); letter-spacing: 0.4em;
}
.summary h3 { font-size: 26px; margin-bottom: 4px; text-align: center; }
.summary .summary-sub { font-family: "Mulish", system-ui, sans-serif; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 22px; text-align: center; }
.summary dl { display: grid; gap: 14px; margin: 0; padding-top: 18px; border-top: 1px solid var(--app-line); }
.summary dt { font: 700 10px/1 "Mulish", system-ui, sans-serif; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.summary dd { margin: 0; font-family: "Lora", serif; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.summary dd.empty { color: var(--muted); font-style: italic; }
.summary .button { margin-top: 24px; }
.summary-note { margin-top: 16px; font-family: "Mulish", system-ui, sans-serif; font-size: 11px; color: var(--muted); line-height: 1.55; text-align: center; }

/* success — wax seal */
.published {
  max-width: 700px; margin: 0 auto;
  padding: clamp(60px, 12vh, 130px) 24px; text-align: center;
}
.published .seal {
  width: 78px; height: 78px; margin: 0 auto 26px;
  display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(120% 120% at 32% 26%, #6f8568, var(--sage) 70%);
  color: #fff8ea; font-size: 30px;
  box-shadow: 0 0 0 1px rgba(154,123,63,0.5), 0 0 0 7px rgba(154,123,63,0.12), 0 12px 26px rgba(36,27,15,0.3);
}
.published h1 { font-size: clamp(42px, 7vw, 70px); margin-bottom: 18px; letter-spacing: -0.02em; }
.published p { color: var(--ink-2); max-width: 52ch; margin: 0 auto 12px; font-size: 16px; }
.published .live-address {
  display: inline-block; margin: 26px 0 30px; padding: 16px 26px;
  background: var(--paper); border: 1px solid var(--app-line); border-radius: 0;
  font: 700 clamp(15px,2.2vw,20px) "Mulish", system-ui, sans-serif; color: var(--walnut);
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-soft);
}
.hidden { display: none !important; }

/* === Entrance (uses syp-rise from styles.css) === */
.auth-card { opacity: 0; animation: syp-rise 0.9s cubic-bezier(0.2, 0.6, 0.2, 1) 0.1s forwards; }
.builder-head { opacity: 0; animation: syp-rise 0.8s cubic-bezier(0.2, 0.6, 0.2, 1) 0.08s forwards; }
.builder-layout .form-card { opacity: 0; animation: syp-rise 0.8s cubic-bezier(0.2, 0.6, 0.2, 1) forwards; }
.builder-layout .form-card:nth-of-type(1) { animation-delay: 0.18s; }
.builder-layout .form-card:nth-of-type(2) { animation-delay: 0.26s; }
.builder-layout .form-card:nth-of-type(3) { animation-delay: 0.34s; }
.builder-layout .form-card:nth-of-type(4) { animation-delay: 0.42s; }
.builder-layout .form-card:nth-of-type(5) { animation-delay: 0.50s; }
.builder-layout .form-card:nth-of-type(6) { animation-delay: 0.58s; }
.builder-layout aside { opacity: 0; animation: syp-rise 0.9s cubic-bezier(0.2, 0.6, 0.2, 1) 0.5s forwards; }
@media (prefers-reduced-motion: reduce) {
  .auth-card, .builder-head, .builder-layout .form-card, .builder-layout aside { opacity: 1; animation: none; }
}
