/* Written Answers: structural CSS with plain defaults. Brand it with the variables below.
 * States on .wa[data-state]: loading, idle, answer, choose, none, error. .wa[data-full] when the
 * question hits 300 characters.
 * Must keep: input font-size at 16px or more (stops iPhone zoom), visible focus rings, the spacing
 * that keeps text blocks apart, and [hidden] really hiding things.
 * Default look: Written Answers graphite and amber, with the lockup as the header
 * (written-answers-logo.svg next to this file). Light look: add data-theme="light" to .wa.
 */
.wa {
  --wa-bg: #3b3a38;
  --wa-fg: #f8f7f4;
  --wa-muted: #bfbdbb;
  --wa-line: #535250;
  --wa-accent: #e0a23a;        /* focus ring and link underline */
  --wa-rule: #e0a23a;          /* left rule */
  --wa-arrow: #e0a23a;         /* question arrows */
  --wa-button-bg: #e0a23a;
  --wa-button-fg: #1f1e1c;
  --wa-button-line: #e0a23a;
  --wa-input-bg: transparent;
  --wa-font: inherit;
  --wa-radius: 6px;
  --wa-gap: 0.85rem;
  display: block;
  max-width: 40rem;
  margin: 1.5rem 0;
  color: var(--wa-fg);
  font-family: var(--wa-font);
  font-size: 1rem;
  line-height: 1.5;
}
.wa *, .wa *::before, .wa *::after { box-sizing: border-box; }
.wa [hidden] { display: none !important; }

.wa-card {
  background: var(--wa-bg);
  border: 1px solid var(--wa-line);
  border-radius: var(--wa-radius);
  padding: 1.5rem 1.5rem 1.5rem calc(1.25rem + 3px + 1.25rem);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--wa-gap);
  overflow-wrap: anywhere;
}
.wa-card::before {             /* accent is a rule, never body text color */
  content: '';
  position: absolute;
  left: 1.25rem;
  top: 1.25rem;
  bottom: 1.25rem;
  width: 3px;
  background: var(--wa-rule);
}
.wa p, .wa ul { margin: 0; }
.wa ul { list-style: none; padding: 0; }

.wa-head { display: flex; flex-direction: column; gap: 0.25rem; }
/* The lockup takes the place of the kicker text. The text stays for screen readers.
 * The SVG has padding around the art, so the margins pull it back to the art's edges. */
.wa-kicker {
  --wa-logo-w: 13rem;
  width: var(--wa-logo-w);
  max-width: 100%;
  aspect-ratio: 327.1856 / 144;
  margin: calc(var(--wa-logo-w) * -0.0934) 0 calc(var(--wa-logo-w) * -0.1036) calc(var(--wa-logo-w) * -0.0312);
  background: url('written-answers-logo.svg?v=1') left center / contain no-repeat;
  overflow: hidden;
  white-space: nowrap;
  text-indent: 110%;
  color: transparent;
}
.wa[data-theme="light"] .wa-kicker { background-image: url('written-answers-logo-light.svg?v=1'); }
.wa-head { gap: 0.9rem; }
.wa-intro { color: var(--wa-fg); font-weight: 700; font-size: 1.05rem; }
.wa-foot, .wa-badge, .wa-limit, .wa-status, .wa-starters-label, .wa-asked-label { color: var(--wa-muted); font-size: 0.9rem; }

.wa-form { display: flex; flex-direction: column; gap: 0.4rem; }
.wa-label { font-weight: 600; color: var(--wa-fg); }
.wa-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.wa-input {
  flex: 1 1 14rem;
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 16px;            /* 16px or more: iPhone will not zoom on focus */
  color: var(--wa-fg);
  background: var(--wa-input-bg);
  border: 0;
  border-bottom: 2px solid var(--wa-fg);
  border-radius: 0;
}
.wa-input::placeholder { color: var(--wa-muted); opacity: 1; }
.wa button, .wa a { font: inherit; }
.wa-submit, .wa-reset, .wa-q-button {
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  border-radius: var(--wa-radius);
  border: 1px solid var(--wa-fg);
  background: transparent;
  color: var(--wa-fg);
  cursor: pointer;
  text-align: left;
}
.wa-submit { font-weight: 700; flex: 0 0 auto; padding-inline: 1.1rem; background: var(--wa-button-bg); color: var(--wa-button-fg); border-color: var(--wa-button-line); }
.wa-input:focus-visible, .wa button:focus-visible, .wa a:focus-visible, .wa-result:focus-visible {
  outline: 2px solid var(--wa-accent);
  outline-offset: 2px;
}
.wa-result:focus:not(:focus-visible) { outline: none; }

.wa-questions { display: flex; flex-direction: column; gap: 0.5rem; }
.wa-q-button {
  max-width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: flex-end;
  gap: 0.45em;
  padding: 0.5rem 0 0.3rem;
  border: 0;
  border-bottom: 1px dashed var(--wa-muted);
  border-radius: 0;
}
.wa-q-button::before { content: '\2192'; color: var(--wa-arrow); flex: 0 0 auto; }
.wa-questions { gap: 0.25rem; }
.wa-starters { display: flex; flex-direction: column; gap: 0.25rem; }
.wa-foot { padding-top: var(--wa-gap); border-top: 1px solid var(--wa-line); }

.wa-result {
  display: flex;
  flex-direction: column;
  gap: var(--wa-gap);
  padding-top: var(--wa-gap);
  border-top: 1px solid var(--wa-line);
}
.wa-asked { font-weight: 700; margin-top: -0.6rem; }
.wa-answer { display: flex; flex-direction: column; gap: 0.6rem; }
.wa-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.wa-link { color: var(--wa-fg); text-decoration: underline; text-decoration-color: var(--wa-accent); text-underline-offset: 3px; }
.wa-choose-lead, .wa-none-note { font-weight: 600; }
.wa-reset { align-self: flex-start; border-color: var(--wa-line); }

.wa[data-state="error"] .wa-status { color: var(--wa-fg); }

/* Light look */
.wa[data-theme="light"] {
  --wa-bg: #f8f7f4;
  --wa-fg: #1f1e1c;
  --wa-muted: #535250;
  --wa-line: #bfbdbb;
  --wa-accent: #906102;
  --wa-rule: #b27901;
  --wa-arrow: #906102;
  --wa-button-bg: #e0a23a;
  --wa-button-fg: #1f1e1c;
  --wa-button-line: #906102;
}
.wa[data-full] .wa-input { border-color: var(--wa-fg); }

@media (max-width: 480px) {
  .wa-card { padding: 1.1rem 1rem 1.1rem calc(0.9rem + 3px + 0.9rem); }
  .wa-card::before { left: 0.9rem; top: 1rem; bottom: 1rem; }
  .wa-kicker { --wa-logo-w: 11.5rem; }
  .wa-submit { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .wa * { transition: none !important; } }
