/* ==========================================================================
   Skygarden Tenant Questionnaire
   Brand reference: eclat.com — warm off-white ground, black ink, high-contrast
   serif display, uppercase sans UI, square corners, hairline rules.
   ========================================================================== */

/* --- Fonts ---------------------------------------------------------------
   Austin and Circular XX are licensed typefaces (Commercial Type / Lineto).
   Drop the licensed web font files into src/fonts/ and these rules pick them
   up. Until then the stack falls back to Playfair Display / Plus Jakarta Sans,
   both open licence, which hold the same proportions closely enough.
   See README "Fonts" before going live.
   ------------------------------------------------------------------------ */
@font-face {
  font-family: 'Austin Roman';
  src: url('fonts/Austin-Roman.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Circular XX';
  src: url('fonts/CircularXXWeb-Book.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Circular XX';
  src: url('fonts/CircularXXWeb-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #F6F4F3;
  --surface:   #FFFFFF;
  --ink:       #000000;
  --muted:     #69727D;
  --line:      rgba(0, 0, 0, 0.14);
  --line-firm: rgba(0, 0, 0, 0.34);
  --danger:    #A32020;
  --danger-bg: #FBF0EF;

  --display: 'Austin Roman', 'Playfair Display', Georgia, 'Times New Roman', serif;
  --ui: 'Circular XX', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --gap: clamp(1.5rem, 4vw, 2.75rem);
  --shell: 60rem;
  --tap: 44px;               /* minimum touch target */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-underline-offset: 0.2em; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

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

.skip-link {
  position: absolute; left: 0; top: -4rem;
  background: var(--ink); color: #fff;
  padding: 0.75rem 1.25rem; z-index: 20;
  font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.skip-link:focus { top: 0; }

/* --- Layout --------------------------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 3rem);
}

main.shell { flex: 1; padding-block: var(--gap) clamp(3rem, 8vw, 6rem); }

.masthead {
  border-bottom: 1px solid var(--line);
  padding-block: 1.25rem;
  background: var(--bg);
}
.masthead .shell {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo img { width: clamp(88px, 12vw, 120px); }
.masthead__meta {
  font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}

.footer {
  border-top: 1px solid var(--line);
  padding-block: 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.footer .shell { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* --- Type ----------------------------------------------------------------- */
h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.25rem, 7vw, 3.75rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-block: 0.25rem 1rem;
}
h2.step__title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.625rem, 4.5vw, 2.375rem);
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.eyebrow {
  font-size: 0.6875rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
.lede {
  font-family: var(--display);
  font-size: clamp(1.125rem, 2.6vw, 1.5rem);
  line-height: 1.4;
  margin-bottom: 1rem;
  max-width: 34ch;
}
.body { max-width: 62ch; margin-bottom: 1rem; }
.body--muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.panel { animation: rise 0.35s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* --- Progress ------------------------------------------------------------- */
.progress { margin-bottom: clamp(2rem, 5vw, 3rem); }

.progress__steps {
  display: none;                     /* numbered rail is desktop only */
  list-style: none; padding: 0;
  gap: 0.25rem; margin-bottom: 0.875rem;
}
.progress__steps li {
  flex: 1;
  font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.625rem;
  border-top: 2px solid var(--line);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.progress__steps li[data-state='done'] { border-top-color: var(--line-firm); color: var(--muted); }
.progress__steps li[data-state='current'] { border-top-color: var(--ink); color: var(--ink); }

.progress__bar {
  height: 2px; background: var(--line); position: relative; overflow: hidden;
}
.progress__bar span {
  position: absolute; inset: 0 auto 0 0;
  background: var(--ink); width: 0;
  transition: width 0.45s var(--ease);
}
.progress__label {
  margin-top: 0.75rem;
  font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}

@media (min-width: 48em) {
  .progress__steps { display: flex; }
  .progress__bar { display: none; }
  .progress__label { display: none; }
}

/* --- Step body ------------------------------------------------------------ */
.step__intro { color: var(--muted); max-width: 58ch; margin-bottom: 2rem; }

.field { padding-block: clamp(1.25rem, 3vw, 1.75rem); border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; padding-top: 0; }

.field__label {
  display: block;
  font-size: 1.0625rem;
  line-height: 1.4;
  margin-bottom: 0.375rem;
}
.field__label .req { color: var(--muted); font-weight: 400; }
.field__help { color: var(--muted); font-size: 0.875rem; margin-bottom: 0.75rem; }

legend.field__label { padding: 0; }
fieldset { border: 0; padding: 0; min-width: 0; }

/* Conditional fields signal that they appeared because of a prior answer. */
.field--conditional {
  border-left: 2px solid var(--ink);
  padding-left: clamp(1rem, 3vw, 1.5rem);
  margin-left: 0;
  animation: reveal 0.3s var(--ease) both;
}
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }

/* --- Inputs --------------------------------------------------------------- */
input[type='text'], input[type='email'], input[type='number'], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-firm);
  border-radius: 0;
  padding: 0.8125rem 0.9375rem;
  min-height: var(--tap);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  appearance: none;
}
textarea { resize: vertical; line-height: 1.5; }
input:hover, textarea:hover { border-color: var(--ink); }
input:focus, textarea:focus {
  outline: 0;
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
input[aria-invalid='true'], textarea[aria-invalid='true'] { border-color: var(--danger); }

::placeholder { color: var(--muted); opacity: 1; }

/* Choice controls — rendered as bordered tiles, not default widgets. */
.choices { display: grid; gap: 0.5rem; }
.choices--inline { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }

.choice {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.8125rem 0.9375rem;
  min-height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--line-firm);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.choice:hover { border-color: var(--ink); }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }

.choice__mark {
  flex: 0 0 auto;
  width: 1.125rem; height: 1.125rem;
  margin-top: 0.1875rem;
  border: 1px solid var(--line-firm);
  background: transparent;
  display: grid; place-items: center;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.choice--radio .choice__mark { border-radius: 50%; }
.choice__mark::after {
  content: '';
  width: 0.5rem; height: 0.5rem;
  background: var(--surface);
  transform: scale(0);
  transition: transform 0.18s var(--ease);
}
.choice--radio .choice__mark::after { border-radius: 50%; }

.choice input:checked ~ .choice__mark { background: var(--ink); border-color: var(--ink); }
.choice input:checked ~ .choice__mark::after { transform: scale(1); }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 3px; }

.choice__text { line-height: 1.4; }

/* --- Matrix ---------------------------------------------------------------
   Mobile: one card per row, options as a wrapping pill set.
   Desktop: a grid that reads as a table, with a sticky-feeling header row.
   Semantics stay as fieldset/radio at every width.
   ------------------------------------------------------------------------ */
.matrix { display: grid; gap: 0.75rem; }
.matrix__head { display: none; }

.matrix__row {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.9375rem;
}
.matrix__rowlabel { display: block; margin-bottom: 0.625rem; line-height: 1.35; }
.matrix__opts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.375rem;
}
.matrix:not([style*='--matrix-cols']) .matrix__opts,
.matrix[style*='--matrix-cols:3'] .matrix__opts { grid-template-columns: repeat(3, 1fr); }
.matrix[style*='--matrix-cols:2'] .matrix__opts { grid-template-columns: repeat(2, 1fr); }

.matrix__opt {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 0.375rem;
  min-height: var(--tap);
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--line-firm);
  font-size: 0.875rem; text-align: center; line-height: 1.2;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
              border-color 0.18s var(--ease);
}
.matrix__opt:hover { border-color: var(--ink); }
.matrix__opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.matrix__opt:has(input:checked) {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
.matrix__opt:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 3px; }

@media (min-width: 46em) {
  .matrix { gap: 0; }
  .matrix__head {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) repeat(var(--matrix-cols, 4), minmax(5.5rem, 1fr));
    gap: 0.375rem;
    padding: 0 0.9375rem 0.625rem;
    border-bottom: 1px solid var(--line-firm);
  }
  .matrix__head span {
    font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted); text-align: center;
  }
  .matrix__head span:first-child { text-align: left; }

  .matrix__row {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) repeat(var(--matrix-cols, 4), minmax(5.5rem, 1fr));
    align-items: center;
    gap: 0.375rem;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    padding: 0.5rem 0.9375rem;
  }
  .matrix__row:nth-child(even) { background: rgba(0, 0, 0, 0.02); }
  .matrix__rowlabel { margin: 0; font-size: 0.9375rem; }
  .matrix__opts { display: contents; }
  /* Cell chrome drops away — the column header carries the meaning and the
     whole cell stays clickable. */
  .matrix__opt { font-size: 0; gap: 0; border: 0; padding: 0.625rem; }
  .matrix__opt:hover { background: rgba(0, 0, 0, 0.05); }
  .matrix__opt .matrix__opt-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .matrix__opt::before {
    content: '';
    width: 1rem; height: 1rem; border-radius: 50%;
    border: 1px solid var(--line-firm);
    transition: background 0.18s var(--ease), box-shadow 0.18s var(--ease);
  }
  .matrix__opt:has(input:checked) { background: transparent; }
  .matrix__opt:has(input:checked)::before {
    background: var(--ink); border-color: var(--ink);
    box-shadow: inset 0 0 0 3px var(--surface);
  }
}

/* --- Ranking --------------------------------------------------------------
   Position in the list is the rank. Up/down buttons are the primary control
   (keyboard and touch accessible); pointer drag is an enhancement on top.
   ------------------------------------------------------------------------ */
.rank { list-style: none; padding: 0; display: grid; gap: 0.5rem; counter-reset: rank; }

.rank__item {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line-firm);
  padding: 0.625rem 0.75rem;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease),
              opacity 0.2s var(--ease);
}
.rank__item[draggable='true'] { cursor: grab; }
.rank__item.is-dragging { opacity: 0.35; cursor: grabbing; }
.rank__item.is-over { box-shadow: inset 0 2px 0 var(--ink); }
.rank__item.just-moved { box-shadow: inset 0 0 0 1px var(--ink); }

.rank__num {
  font-family: var(--display);
  font-size: 1.375rem;
  line-height: 1;
  text-align: center;
  color: var(--ink);
}
.rank__num::before { counter-increment: rank; content: counter(rank); }

.rank__label { line-height: 1.35; }
.rank__specify { margin-top: 0.5rem; }
.rank__specify input { font-size: 0.9375rem; padding: 0.5rem 0.625rem; min-height: 2.25rem; }

.rank__moves { display: flex; gap: 0.25rem; }
.rank__move {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.875rem;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.rank__move:hover:not(:disabled) { border-color: var(--ink); background: var(--bg); }
.rank__move:disabled { opacity: 0.25; cursor: not-allowed; }
.rank__move svg { width: 0.875rem; height: 0.875rem; fill: currentColor; }

/* --- Consent -------------------------------------------------------------- */
.consent { background: var(--surface); border: 1px solid var(--line-firm); padding: 1rem; }
.consent .choice { border: 0; padding: 0; background: transparent; }
.consent .choice:has(input:checked) { box-shadow: none; }
.consent__link { display: inline-block; margin-top: 0.75rem; font-size: 0.875rem; color: var(--muted); }

/* --- Errors --------------------------------------------------------------- */
.field__error {
  display: flex; align-items: flex-start; gap: 0.4375rem;
  margin-top: 0.5rem;
  color: var(--danger);
  font-size: 0.875rem;
}
.field__error::before { content: '\2715'; font-size: 0.75rem; line-height: 1.5; }

.errorsummary {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.errorsummary__title {
  font-family: var(--ui);
  font-size: 0.875rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--danger);
  margin-bottom: 0.5rem;
}
.errorsummary ul { margin: 0; padding-left: 1.125rem; font-size: 0.9375rem; }
.errorsummary a { color: var(--danger); }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  font: inherit;
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1rem 2rem;
  min-height: var(--tap);
  border-radius: 0;
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
              opacity 0.2s var(--ease);
}
.btn--primary { background: var(--ink); color: var(--surface); }
.btn--primary:hover:not(:disabled) { background: transparent; color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-firm); }
.btn--ghost:hover:not(:disabled) { border-color: var(--ink); background: var(--surface); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[hidden] { display: none; }

.btn.is-busy { position: relative; color: transparent; }
.btn.is-busy::after {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 1rem; height: 1rem;
  border: 2px solid currentColor;
  border-top-color: var(--surface);
  border-radius: 50%;
  color: var(--surface);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.linkbtn {
  background: none; border: 0; padding: 0;
  font: inherit; color: inherit; text-decoration: underline;
  cursor: pointer;
}

#intro .btn, #done .btn, #fatal .btn { margin-top: 1rem; }

.actions {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.actions .btn { flex: 1 1 auto; }
@media (min-width: 34em) {
  .actions { justify-content: flex-end; }
  .actions .btn { flex: 0 0 auto; min-width: 10rem; }
  #back { margin-right: auto; }
}

/* --- Spam controls -------------------------------------------------------- */
.hp {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px; overflow: hidden;
}
.turnstile { margin-top: 1.5rem; }
.turnstile:empty { margin-top: 0; }

/* --- Print ---------------------------------------------------------------- */
@media print {
  .progress, .actions, .masthead, .footer, .turnstile { display: none; }
  body { background: #fff; }
  .field { break-inside: avoid; }
}
