/* =========================================================================
   LISTING LAUNCHPAD / PORCHLYTE FORM TOOLS — SHARED DESIGN SYSTEM
   -------------------------------------------------------------------------
   This stylesheet is the cohesive base for every form tool in the suite.
   When building a new tool, reuse this file as-is and only add tool-specific
   rules at the bottom. Do not change the tokens, buttons, fields, or result
   cards without meaning to change them everywhere.

   Palette: white + cream surfaces, dark brown type, rust as an accent only.
   Type:    Chapza (display, falls back to Playfair Display) + Inter (body/UI).
   ========================================================================= */

/* ---- Chapza web font ----
   Playfair Display (loaded in the page <head>) is the fallback. If you have a
   Chapza web font file, drop it in /public and uncomment this block. It is
   then used automatically anywhere the display font is set.

@font-face {
  font-family: "Chapza";
  src: url("/chapza.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
*/

:root {
  /* Brand palette */
  --cream: #efeae3;      /* page + section backgrounds */
  --white: #ffffff;      /* cards, tool surfaces, form fields */
  --tan: #d7c8ba;        /* secondary panels, hover, dividers, pills */
  --brown: #2b1f1b;      /* body text + headings, dark modules */
  --rust: #80441e;       /* accent only: buttons, active state, underlines */

  --text: var(--brown);
  --text-soft: #6f6157;  /* muted brown for sub text */
  --border: #e4dacd;     /* soft warm border */
  --error: #80441e;

  --font-display: "Chapza", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(43, 31, 27, 0.04), 0 6px 20px rgba(43, 31, 27, 0.05);

  --content-width: 760px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules like flex/grid. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 40px 24px 96px;
}

.screen { display: none; }
.screen.active {
  display: block;
  animation: fadein 0.35s var(--ease);
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== TOOL HEADER (reusable shell — same on every form) ===== */
.tool-header {
  text-align: center;
  margin: 0 0 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.tool-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--brown);
  margin: 0 0 12px;
}
.tool-tagline {
  margin: 0 auto;
  max-width: 540px;
  color: var(--text-soft);
  font-size: 16px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--rust);
  color: #fff;
  border: 1px solid var(--rust);
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.01em;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: 0 2px 8px rgba(128, 68, 30, 0.18);
}
.btn-primary:hover {
  background: #6c3818;
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(128, 68, 30, 0.24);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--brown);
  color: #fff;
  border: 1px solid var(--brown);
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease);
}
.btn-secondary:hover { background: #1c1512; transform: translateY(-1px); }

/* Quiet Copy button — tan pill */
.btn-copy {
  background: var(--tan);
  color: var(--brown);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.btn-copy:hover { background: #cbb9a8; }
.btn-copy.is-copied { background: var(--rust); color: #fff; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ===== FORM ===== */
#form, #loading, #results {
  margin: 0 auto;
}
.form-note {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rust);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 0 0 28px;
  color: var(--text-soft);
  font-size: 14.5px;
}
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.form-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.form-section-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--rust);
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.field-row {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field > span,
.field > legend {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-soft);
  text-align: left;
  padding-left: 2px;
}
.field > span em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--tan);
  margin-left: 6px;
}
.field input,
.field select {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  font: inherit;
  color: inherit;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--rust);
  box-shadow: 0 0 0 3px rgba(128, 68, 30, 0.15);
}

/* Stacked feature inputs */
fieldset.field {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  background: var(--white);
  margin: 0;
}
fieldset.field input {
  margin-bottom: 10px;
  background: var(--cream);
}
fieldset.field input:last-child { margin-bottom: 0; }

.form-actions {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 4px;
}
.form-actions .microcopy { text-align: center; }
.microcopy {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0;
}
.form-error {
  color: var(--error);
  font-size: 14px;
  margin: 8px 0 0;
  font-weight: 500;
}

/* ===== SCREEN HEADERS (used on the results screen) ===== */
.screen-header {
  text-align: left;
  margin: 8px 0 28px;
}
.screen-header.center {
  text-align: center;
}
.screen-header h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1.05;
  color: var(--brown);
  margin: 0 0 12px;
}
.screen-header.center h2.underline { display: inline-block; }
.screen-header.center h2.underline::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  background: var(--rust);
  border-radius: 2px;
  margin: 14px auto 0;
}
.screen-sub {
  margin: 0;
  color: var(--text-soft);
  font-size: 16px;
}

/* ===== LOADING ===== */
.loader {
  text-align: center;
  padding: 72px 0;
}
.loader h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 3.5vw, 32px);
  color: var(--brown);
  margin: 0 0 8px;
}
.sign-loader {
  display: flex;
  justify-content: center;
  margin: 0 auto 32px;
}
.sl-svg { width: 240px; height: auto; overflow: visible; }
.sl-ground { stroke: var(--tan); stroke-width: 2; stroke-linecap: round; }
.sl-stake, .sl-crossbar { stroke: var(--brown); stroke-width: 3; stroke-linecap: round; }
.sl-connector { stroke: var(--brown); stroke-width: 1.5; stroke-linecap: round; }
.sl-house-roof, .sl-house-body, .sl-house-chimney {
  fill: var(--white); stroke: var(--brown); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round;
}
.sl-house-door { fill: var(--white); stroke: var(--brown); stroke-width: 2; stroke-linejoin: round; }
.sl-house-arch { fill: var(--tan); stroke: var(--brown); stroke-width: 1.8; stroke-linejoin: round; }
.sl-house-arch-vert, .sl-house-arch-horiz { stroke: var(--brown); stroke-width: 1.5; }
.sl-house-window { fill: var(--tan); stroke: var(--brown); stroke-width: 1.8; }
.sl-house-window-cross-v, .sl-house-window-cross-h { stroke: var(--brown); stroke-width: 1.5; }
.sl-heart {
  fill: none; stroke: var(--rust); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transform-box: fill-box; transform-origin: center;
}
.sl-heart-1 { animation: sl-heart-rise 4s ease-out infinite 0s; }
.sl-heart-2 { animation: sl-heart-rise 4s ease-out infinite 1.3s; }
.sl-heart-3 { animation: sl-heart-rise 4s ease-out infinite 2.6s; }
@keyframes sl-heart-rise {
  0%   { transform: translate(0, 0) scale(0.6); opacity: 0; }
  12%  { transform: translate(0, -4px) scale(0.85); opacity: 0.9; }
  60%  { transform: translate(-1px, -22px) scale(1); opacity: 0.9; }
  100% { transform: translate(-3px, -42px) scale(1.1); opacity: 0; }
}
.sl-sold rect {
  fill: var(--rust); stroke: var(--brown); stroke-width: 2;
  animation: sl-sold-blink 1.4s ease-in-out infinite;
}
.sl-sold-text { fill: var(--white); font-family: var(--font-body); font-weight: 700; font-size: 11px; letter-spacing: 0.12em; }
@keyframes sl-sold-blink { 0%, 100% { fill: var(--rust); } 50% { fill: #a35a2b; } }
.sl-hanging-panel { transform-origin: 190px 148px; animation: sl-swing 3.4s ease-in-out infinite; }
@keyframes sl-swing { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.sl-hanging-panel rect:first-of-type { fill: var(--white); stroke: var(--brown); stroke-width: 2.5; }
.sl-icon-roof, .sl-icon-body { fill: var(--white); stroke: var(--brown); stroke-width: 1.8; stroke-linejoin: round; }
.sl-icon-window { fill: var(--tan); stroke: var(--brown); stroke-width: 1.2; }

/* ===== RESULTS ===== */
#results-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 8px;
}
.result-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.result-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--brown);
  color: #fff;
  padding: 12px 22px;
}
.result-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--tan);
}
.result-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: #fff;
}
.result-body { padding: 22px 22px 8px; }
.content-body {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--brown);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.result-card .card-actions { padding: 0 22px 20px; }

/* Carousel captions */
.caption-row {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.caption-row:first-child { border-top: none; padding-top: 0; }
.caption-tag {
  display: inline-block;
  background: var(--tan);
  color: var(--brown);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 8px;
}
.caption-text {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--brown);
}

.results-again {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}

/* Loading shimmer shown in each card until its batch returns */
.shimmer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 10px;
}
.shimmer span {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cream) 25%, #e7ddd0 37%, var(--cream) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.shimmer span:nth-child(1) { width: 100%; }
.shimmer span:nth-child(2) { width: 92%; }
.shimmer span:nth-child(3) { width: 70%; }
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .shimmer span { animation: none; }
}

/* Per-card error state (one piece failed) */
.card-error-msg {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
}

/* "Still writing the rest" indicator under the results as they stream in */
.results-writing {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}
.writing-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rust);
  animation: writing-pulse 1s ease-in-out infinite;
}
@keyframes writing-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .writing-dot { animation: none; }
}

/* A card that just landed gently fades in */
.result-card.just-arrived {
  animation: card-in 0.35s var(--ease);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 56px;
  padding: 26px 0 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer-disclaimer {
  font-size: 12px;
  color: var(--text-soft);
  margin: 0 auto;
  max-width: 620px;
  opacity: 0.9;
  line-height: 1.55;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  .app { padding: 28px 18px 80px; }
  .result-bar { padding: 11px 18px; }
  .result-body { padding: 18px 18px 6px; }
  .result-card .card-actions { padding: 0 18px 18px; }
}

/* =========================================================================
   TOOL-SPECIFIC OVERRIDES (Listing Launchpad only — not part of the shared base)
   ========================================================================= */

/* This form's primary action button is black instead of the suite default rust. */
#btn-generate {
  background: var(--brown);
  border-color: var(--brown);
  box-shadow: 0 2px 8px rgba(43, 31, 27, 0.18);
}
#btn-generate:hover {
  background: #1c1512;
  box-shadow: 0 5px 14px rgba(43, 31, 27, 0.24);
}
