/* Survey player styling — cards, inputs, buttons, progress bar.
   Mobile-first with a 720px max-width column. No build step: plain CSS. */

:root {
  --ink: #161e30;
  --muted: #6a7390;
  --line: #e4e8f2;
  --line-strong: #d5dcec;
  --accent: #2f5bea;
  --accent-strong: #1e46cf;
  --accent-soft: #eef2ff;
  --accent-line: #cdd8fb;
  --accent-ink: #ffffff;
  --primary: #1b2338;
  --primary-hover: #242e49;
  /* Gradient top stop for primary buttons; themes recolour it with --primary. */
  --primary-top: #2b3550;
  --primary-top-hover: #354060;
  --bg: #f5f7fc;
  --card: #ffffff;
  --error: #c62828;
  --warn: #b45309;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-xs: 0 1px 2px rgba(20, 29, 57, 0.06);
  --shadow-sm: 0 1px 3px rgba(20, 29, 57, 0.08), 0 1px 2px rgba(20, 29, 57, 0.04);
  --shadow-md: 0 10px 24px rgba(20, 29, 57, 0.12);
  --ring: 0 0 0 3px rgba(47, 91, 234, 0.22);
}

/* Survey themes -------------------------------------------------------------
   A theme overrides the colour tokens above; everything else (radii, layout,
   the submit button's green) stays shared. The fixed list lives in
   src/lib/theme.ts and the server validates every value before it is stored.

   `data-theme` is set on <html> for the public form, on the builder's preview
   pane for live previews, and on the picker's swatches — the selector is
   intentionally not tied to :root so all three keep working.

   `--ink` must stay readable on `--bg`/`--card` and `--accent-ink` on
   `--accent`; keep new themes at WCAG AA for body text. */

[data-theme="lagoon"] {
  --ink: #12272b;
  --muted: #557073;
  --line: #dceceb;
  --line-strong: #c7e1de;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e9f8f5;
  --accent-line: #a7e3da;
  --accent-ink: #ffffff;
  --primary: #123633;
  --primary-hover: #18453f;
  --primary-top: #1c4a45;
  --primary-top-hover: #215750;
  --bg: #f2faf9;
  --card: #ffffff;
  --ring: 0 0 0 3px rgba(15, 118, 110, 0.22);
}

[data-theme="sand"] {
  --ink: #2b2118;
  --muted: #756354;
  --line: #ece0d3;
  --line-strong: #ddcbb8;
  --accent: #a44f0a;
  --accent-strong: #8a3f06;
  --accent-soft: #fdf3e7;
  --accent-line: #f0d5ae;
  --accent-ink: #ffffff;
  --primary: #3a2a1c;
  --primary-hover: #4a3624;
  --primary-top: #4a3826;
  --primary-top-hover: #5a452f;
  --bg: #faf6f0;
  --card: #ffffff;
  --ring: 0 0 0 3px rgba(164, 79, 10, 0.22);
}

[data-theme="forest"] {
  --ink: #1a2a20;
  --muted: #55705f;
  --line: #dfe9e0;
  --line-strong: #ccdccd;
  --accent: #2f7d4f;
  --accent-strong: #256640;
  --accent-soft: #edf7ef;
  --accent-line: #bfe0c6;
  --accent-ink: #ffffff;
  --primary: #1e3327;
  --primary-hover: #284434;
  --primary-top: #2b4a38;
  --primary-top-hover: #355944;
  --bg: #f4f9f4;
  --card: #ffffff;
  --ring: 0 0 0 3px rgba(47, 125, 79, 0.22);
}

[data-theme="orchid"] {
  --ink: #2a1f33;
  --muted: #6b5c7a;
  --line: #ece2f2;
  --line-strong: #ddcde7;
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: #f5efff;
  --accent-line: #ddc9fb;
  --accent-ink: #ffffff;
  --primary: #2e2140;
  --primary-hover: #3d2c55;
  --primary-top: #40305a;
  --primary-top-hover: #4d3a69;
  --bg: #faf6ff;
  --card: #ffffff;
  --ring: 0 0 0 3px rgba(124, 58, 237, 0.22);
}

[data-theme="rose"] {
  --ink: #2c1c22;
  --muted: #74606b;
  --line: #f2e2e8;
  --line-strong: #e8ccd6;
  --accent: #be185d;
  --accent-strong: #9d174d;
  --accent-soft: #fff1f5;
  --accent-line: #fbcfe0;
  --accent-ink: #ffffff;
  --primary: #3f1f2b;
  --primary-hover: #522837;
  --primary-top: #552b3a;
  --primary-top-hover: #673547;
  --bg: #fff7f9;
  --card: #ffffff;
  --ring: 0 0 0 3px rgba(190, 24, 93, 0.22);
}

* {
  box-sizing: border-box;
}

/* Chromium/Firefox add a default bottom margin to forms; the layout uses
   flex/grid gaps instead, so reset it once here. */
form {
  margin: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.5;
}

.survey {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.survey-header {
  margin-bottom: 16px;
}

.survey-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  line-height: 1.25;
}

.survey-desc {
  margin: 0;
  color: var(--muted);
}

/* Progress bar ------------------------------------------------------------- */

.progress {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* Question card ------------------------------------------------------------- */

.q-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.q-count {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.q-label {
  margin: 0 0 4px;
  font-size: 1.2rem;
  line-height: 1.35;
}

.q-desc {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.q-widget,
.q-card > .choices,
.q-card > .select,
.q-card > .input,
.q-card > .textarea,
.q-card > .stars,
.q-card > .matrix {
  margin-top: 16px;
}

.q-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

/* Inline validation --------------------------------------------------------- */

.error {
  margin: 12px 0 0;
  color: var(--error);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.error:empty {
  min-height: 0;
}

/* Inputs -------------------------------------------------------------------- */

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.input:focus,
.select:focus,
.textarea:focus,
.choice:focus-within,
.star:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.textarea {
  resize: vertical;
}

/* Choice lists -------------------------------------------------------------- */

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

.choice:hover {
  border-color: var(--accent);
}

.choice input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
}

/* Star rating ---------------------------------------------------------------- */

.stars {
  display: flex;
  gap: 4px;
}

.star {
  border: none;
  background: none;
  font-size: 1.8rem;
  line-height: 1;
  padding: 2px;
  cursor: pointer;
  color: var(--line);
}

.star.is-active {
  color: #f5a623;
}

/* Matrix --------------------------------------------------------------------- */

.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.matrix th,
.matrix td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
}

.matrix-col,
.matrix-row {
  background: #f8fafc;
  font-weight: 600;
}

.matrix-row {
  text-align: left;
}

.matrix-corner {
  background: #f8fafc;
}

.matrix input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

/* Buttons ---------------------------------------------------------------------
   One shared language: pill-ish soft corners, an inked primary with a subtle
   top highlight, tinted "soft" secondary and quiet outlined "back" actions.
   Icons (Lucide) inherit currentColor and sit in the 7px flex gap. */

.icon {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  stroke-width: 2;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.2;
  padding: 9px 17px;
  min-height: 42px; /* matches a one-line .input, so forms line up */
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: linear-gradient(180deg, var(--primary-top) 0%, var(--primary) 100%);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: transform 0.12s ease, box-shadow 0.16s ease, background-color 0.16s ease,
    border-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn:not(:disabled):hover {
  background: linear-gradient(180deg, var(--primary-top-hover) 0%, var(--primary-hover) 100%);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.btn:not(:disabled):active {
  transform: translateY(0) scale(0.99);
  box-shadow: inset 0 2px 4px rgba(10, 16, 34, 0.28);
}

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

.btn:disabled {
  background: #f0f2f8;
  color: #9ba3b8;
  border-color: var(--line);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

/* Quiet secondary — back links, toolbar utilities, secondary actions. */
.btn-back {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.btn-back:not(:disabled):hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}

/* Tinted secondary — makes workflow links (e.g. Qualifiers) easy to spot. */
.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent-line);
  box-shadow: inset 0 1px 0 #fff, var(--shadow-xs);
}

.btn-soft:not(:disabled):hover {
  background: #e2e9ff;
  color: #173bb0;
  border-color: #b5c5f9;
  box-shadow: var(--shadow-sm);
}

/* Destructive action (survey delete) — quiet until hovered. */
.btn-danger {
  background: #fff5f5;
  color: #b42318;
  border-color: #f3c3c0;
  box-shadow: inset 0 1px 0 #fff, var(--shadow-xs);
}

.btn-danger:not(:disabled):hover {
  background: #fde8e7;
  color: #8f1b12;
  border-color: #e9a7a1;
  box-shadow: var(--shadow-sm);
}

.btn-submit {
  margin-left: auto;
  background: linear-gradient(180deg, #1c9a5e 0%, #14794a 100%);
  box-shadow: 0 1px 2px rgba(12, 60, 38, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-submit:not(:disabled):hover {
  background: linear-gradient(180deg, #22a767 0%, #178a52 100%);
  box-shadow: 0 4px 12px rgba(12, 60, 38, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

@media (max-width: 480px) {
  .q-card {
    padding: 16px;
  }

  .btn {
    flex: 1;
  }
}

/* Report summary bars (T29) -------------------------------------------------- */

.bar-track {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* Public page chrome (T07/T09) — error + thank-you pages.
   These pages are rendered by src/routes/public.ts, which loads only
   /styles.css, so they are styled here rather than in /admin.css. */

.thankyou,
.error-page {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 24px;
  text-align: center;
}

.thankyou h1 {
  max-width: 560px;
  margin: 0 auto;
  font-size: 1.5rem;
  line-height: 1.35;
}

.error-page p {
  margin: 0;
  padding: 24px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}
