/* =============================================================================
   Aperture research router — styles
   -----------------------------------------------------------------------------
   Extends the apex /assets/css/style.css. Inherits palette tokens (--bg,
   --umber, --fg, etc.), typography (--serif, --sans), animation (rise),
   and the brand baseline. This file adds router-only screens and one
   experimental token: --darkroom-red.

   DARKROOM RED EXPERIMENT (per John 2026-04-21):
   The brand says umber is the single accent. The router experiments with
   a second accent — a deep darkroom red — applied narrowly:
     - Primary submit on /respond  (.btn-darkroom)
     - Focus ring on text inputs  (focus state inherits from brand; here
       we override only inside the router via the selectors below)
   If this feels like brand inflation in review, drop .btn-darkroom and
   the focus override; everything else falls back to umber.
   ============================================================================= */

:root {
  --darkroom-red:    #8a2e19;
  --darkroom-red-hi: #a13a20;
  --darkroom-red-dim: #4a1a0e;
}

/* The apex stylesheet centers everything in a flex container; for the
   router we want a single column that grows top-to-bottom. */
.router-body {
  display: block;
  padding: 0;
}

main#app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2rem);
}

.screen-host {
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Screen baseline ---------- */

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  width: 100%;
  opacity: 0;
  animation: rise 600ms ease-out 0ms forwards;
}

.screen-heading {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.85rem, 4.5vw, 2.5rem);
  line-height: 1.15;
  margin: 0;
  color: var(--fg);
}

.screen-subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--fg-mute);
  margin: 0;
  letter-spacing: 0.01em;
}

.screen-prose {
  font-family: var(--sans);
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  line-height: 1.65;
  color: var(--fg);
  max-width: 56ch;
  margin: 0;
}

.screen-prose em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--fg-mute);
}

.screen-closer {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--fg-mute);
  margin: 0.5rem 0 0;
}

/* ---------- Splash ---------- */

.screen-splash {
  padding: clamp(2rem, 6vw, 4rem) 0;
}

.splash-iris {
  width: clamp(96px, 14vw, 132px);
  height: auto;
  margin-bottom: 0.5rem;
  opacity: 0;
  animation: rise 900ms ease-out 100ms forwards;
}

.screen-splash .wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--fg);
  opacity: 0;
  animation: rise 900ms ease-out 250ms forwards;
}

/* Compact prompt that sits just above a button row. Lower visual weight
   than .screen-prose so the buttons read as the primary action. */
.screen-action-prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--fg-mute);
  margin: 0.25rem 0 -0.25rem;
  letter-spacing: 0.01em;
}

/* ---------- Buttons ---------- */

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.screen-actions-stack {
  flex-direction: column;
  align-items: stretch;
  max-width: 320px;
  width: 100%;
}

/* Secondary actions row — sits below the primary row with lighter weight.
   Used on /respond for the "No — I'm done for today" early-exit button. */
.screen-actions-secondary {
  margin-top: 0.25rem;
  opacity: 0.75;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  min-width: 0;
}

.btn {
  font: 500 0.95rem/1.2 var(--sans);
  letter-spacing: 0.02em;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--fg-dim);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
  min-width: 8rem;
}

.btn:hover:not(:disabled) {
  border-color: var(--fg-mute);
  background-color: rgba(236, 230, 220, 0.04);
}

.btn:focus-visible {
  outline: 2px solid var(--umber-hi);
  outline-offset: 2px;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--umber);
  border-color: var(--umber);
  color: var(--fg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--umber-hi);
  border-color: var(--umber-hi);
}

.btn-secondary {
  background: transparent;
  border-color: var(--umber);
  color: var(--fg);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(107, 74, 43, 0.08);
}

.btn-ghost {
  background: transparent;
  border-color: var(--fg-dim);
  color: var(--fg-mute);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--fg-mute);
  color: var(--fg);
  background-color: rgba(236, 230, 220, 0.04);
}

/* The darkroom-red experiment lives ONLY on the /respond submit. */
.btn-darkroom {
  background: var(--darkroom-red);
  border-color: var(--darkroom-red);
  color: var(--fg);
}

.btn-darkroom:hover:not(:disabled) {
  background: var(--darkroom-red-hi);
  border-color: var(--darkroom-red-hi);
}

.btn-darkroom:focus-visible {
  outline: 2px solid var(--darkroom-red-hi);
  outline-offset: 2px;
}

/* ---------- Forms ---------- */

.form-step {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.5rem);
}

/* The HTML `hidden` attribute should hide the element, but the
   `.form-step { display: flex }` rule above silently overrode it via
   specificity — both consent and demographics rendered together. This
   selector matches `.form-step[hidden]` and explicitly re-applies
   display:none. Higher-specificity than the bare `.form-step` rule. */
.form-step[hidden] {
  display: none;
}

.form-step form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row > span,
.form-row > legend {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--fg);
  letter-spacing: 0.01em;
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
  background: transparent;
  border: 1px solid var(--fg-dim);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  color: var(--fg);
  font: 400 0.95rem/1.45 var(--sans);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.form-row textarea {
  resize: vertical;
  min-height: 5rem;
}

.form-row input:hover,
.form-row select:hover,
.form-row textarea:hover {
  border-color: var(--fg-mute);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--darkroom-red-hi);
  background-color: rgba(138, 46, 25, 0.05);
  box-shadow: 0 0 0 2px rgba(161, 58, 32, 0.22);
}

.field-hint {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--fg-dim);
  line-height: 1.45;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--fg);
  cursor: pointer;
  /* iOS Safari paint fix: nested flex labels sometimes skip painting the
     text span on first render; forcing a compositing layer avoids it. */
  transform: translateZ(0);
}

.checkbox-row input[type="checkbox"] {
  margin-top: 0.18rem;
  accent-color: var(--umber);
  flex: 0 0 auto;
}

.consent-row {
  background: var(--bg-elev);
  border: 1px solid var(--fg-dim);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
}

.form-row-multi {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--fg-dim);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0;
}

.form-row-multi legend {
  padding: 0 0.4rem;
  margin-left: -0.4rem;
}

.qlabel em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--umber-hi);
  margin-right: 0.35rem;
  letter-spacing: 0.01em;
}

.form-status {
  min-height: 1.5em;
  font-size: 0.9rem;
  margin: 0;
  color: var(--fg-mute);
}

.form-status[data-state="error"]   { color: #c98b6b; }
.form-status[data-state="success"] { color: var(--umber-hi); font-style: italic; font-family: var(--serif); }
.form-status[data-state="info"]    { color: var(--fg-mute); }

/* ---------- Respond screen ---------- */

.screen-respond {
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

.respond-image-wrap {
  margin: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.respond-image {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  width: auto;
  border-radius: var(--radius);
  background: var(--bg-elev);
  object-fit: contain;
}

/* ---------- Match list (claim) ---------- */

.match-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.match-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: var(--bg-elev);
  border: 1px solid var(--fg-dim);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: left;
  cursor: pointer;
  color: var(--fg);
  transition: border-color 180ms ease, background-color 180ms ease;
  font-family: var(--sans);
}

.match-row:hover,
.match-row:focus-visible {
  outline: none;
  border-color: var(--umber-hi);
  background: rgba(107, 74, 43, 0.06);
}

.match-row .match-hint {
  font-size: 1rem;
}

.match-row .match-meta {
  font-size: 0.82rem;
  color: var(--fg-dim);
}

/* ---------- Footer ---------- */

.router-footer {
  width: 100%;
  max-width: 720px;
  margin: clamp(2rem, 5vw, 4rem) auto 1.5rem;
  /* Flex column centers the block children (iris + legal paragraph) even
     when .footer-legal's inherited max-width: 44ch makes it narrower than
     the footer. text-align: center alone wasn't enough — it centered the
     text inside the 44ch box but left the box itself left-aligned. */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-align: center;
}

.router-footer .footer-mark {
  width: 36px;
  height: 36px;
  opacity: 0.7;
}

.router-footer .footer-legal {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--fg-dim);
  line-height: 1.6;
  margin: 0;
  letter-spacing: 0.01em;
}

.router-footer .footer-legal a {
  color: var(--fg-mute);
  text-decoration: none;
  border-bottom: 1px solid var(--umber-dim);
  padding-bottom: 1px;
  transition: color 180ms ease, border-color 180ms ease;
}

.router-footer .footer-legal a:hover {
  color: var(--fg);
  border-bottom-color: var(--umber-hi);
}

/* ---------- Credits page ---------- */

/* Credits shares the router body (.router-body + main#app layout) but
   reads as a long-form document rather than a stepped session. Left-align,
   widen slightly, calmer spacing. */
.router-body.credits-body {
  display: block;
}

.credits-page {
  max-width: 760px;
  text-align: left;
  gap: clamp(1.25rem, 3vw, 2rem);
}

.credits-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.credits-meta {
  color: var(--fg-mute);
  font-size: 0.85rem;
  margin: 0;
}

.credits-intro p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--fg);
  margin: 0.4rem 0;
}

.credits-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  /* Speed bump against casual copy-paste scraping. Not a real defense —
     View Source / curl sees the same HTML — but raises the floor enough
     to deter low-effort harvesting. */
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Single-line entry: Title — Creator · License. Compact because the
   attribution-required list is the whole page now. */
.credits-entry {
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--fg-mute);
}

.credits-entry strong {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--fg);
}

.credits-entry a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--umber-dim);
  transition: border-color 180ms ease;
}

.credits-entry a:hover { border-bottom-color: var(--umber-hi); }

.credits-entry strong a { color: var(--fg); }

.credits-unknown-creator { font-style: italic; }

.credits-notice {
  color: var(--fg-mute);
  font-size: 0.95rem;
  padding: 1rem 0;
}

/* ---------- Cookie / localStorage notice ---------- */

.cookie-notice {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 560px;
  background: var(--bg-elev);
  border: 1px solid rgba(236, 230, 220, 0.14);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 100;
  font-family: var(--sans);
}

.cookie-notice[hidden] { display: none; }

.cookie-notice p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--fg);
  flex: 1 1 auto;
}

.cookie-notice a {
  color: var(--umber-hi);
  text-decoration: none;
  border-bottom: 1px solid var(--umber-dim);
}

.cookie-notice a:hover { border-bottom-color: var(--umber-hi); }

.cookie-notice-dismiss {
  flex: 0 0 auto;
  background: transparent;
  color: var(--fg);
  border: 1px solid rgba(236, 230, 220, 0.28);
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-family: var(--sans);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.cookie-notice-dismiss:hover {
  background: rgba(236, 230, 220, 0.06);
  border-color: rgba(236, 230, 220, 0.45);
}

.cookie-notice-dismiss:focus-visible {
  outline: 2px solid var(--umber-hi);
  outline-offset: 2px;
}

/* ---------- Mobile refinements ---------- */

@media (max-width: 480px) {
  main#app {
    padding: 1.25rem 1rem;
  }
  .screen-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .btn {
    width: 100%;
  }
  .respond-image {
    max-height: 55vh;
  }
}
