/* Palette based on the ARABUSTA COFFEE logo: brown and gold. */
:root {
  --bg: #f7f1e8;
  --surface: #fffdf8;
  --fg: #2a160b;
  --muted: #7b6556;
  --accent: #6b3416;
  --accent-fg: #fffdf8;
  --accent-soft: #f0e2d0;
  --border: #e5d6c2;
  --gold: #b98232;
  --logo-fill: #5e2c12;
  --error: #b42318;
  --radius: 14px;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-logo: 'Cinzel', 'Playfair Display', Georgia, serif; /* Latin only (no Cyrillic) */
}

/* Dark theme (follows the phone's setting) mirrors the black version of the logo */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0a07;
    --surface: #1b130d;
    --fg: #f4ebdf;
    --muted: #b5a08c;
    --accent: #c9933f;
    --accent-fg: #0e0a07;
    --accent-soft: #2e2114;
    --border: #3a2a1c;
    --gold: #d7a24e;
    --logo-fill: #7a3d1a;
    --logo-small: var(--gold); /* plain brown blends into the black background */
    /* Light outline so the brown lettering of the logo reads on black, like the logo's dark version */
    --logo-outline: drop-shadow(0 0 0.6px #f4e6c8) drop-shadow(0 0 0.6px #f4e6c8);
    --error: #f97066;
    color-scheme: dark;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

img { max-width: 100%; height: auto; }

/* Component display rules must not override the hidden attribute */
[hidden] { display: none !important; }

/* Headings get programmatic focus on screen change; no visible ring needed */
[tabindex="-1"]:focus { outline: none; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---------- Screens ---------- */

.screen {
  padding: 24px 0 32px;
}

.screen--start {
  min-height: 80vh;
  min-height: 80dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.screen__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 16px;
}

.screen__header--center { justify-content: center; }

/* ---------- Logo ---------- */

/* Full logo image on the start and thank-you screens */
.logo-img {
  display: block;
  width: 220px;
  max-width: 70vw;
  height: auto;
  margin: 0 auto 32px;
  filter: var(--logo-outline, none);
}

/* Small text wordmark for screen headers (the full logo is too detailed at this size) */
.logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  color: var(--fg);
}

.logo__name {
  font-family: var(--font-logo);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  color: var(--logo-small, var(--logo-fill));
}

/* ---------- Typography ---------- */

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1, h2, .set__title, .sample-card__title { font-variant-numeric: lining-nums; }

h1 { font-size: 1.75rem; margin-bottom: 12px; }
h2 { font-size: 1.5rem; margin-bottom: 8px; }

.lead {
  color: var(--muted);
  margin-bottom: 24px;
}

.screen--start .lead { max-width: 340px; margin-bottom: 32px; }

/* Welcome text on the start screen */
.intro {
  max-width: 360px;
  margin-bottom: 32px;
  color: var(--muted);
}

.intro p + p { margin-top: 12px; }

.intro__accent {
  display: inline-block;
  margin-top: 4px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.intro__note {
  font-size: 0.875rem;
  opacity: 0.8;
}

.hint,
.optional {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 100px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 28px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
  width: 100%;
}

.screen--start .btn--primary { max-width: 320px; }

.btn--primary:active { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-back {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
}

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

.actions { margin-top: 32px; }

/* ---------- Fields ---------- */

.field { margin-bottom: 24px; }

h2 + .field { margin-top: 24px; }

.field__label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* at least 16px so iOS does not zoom in on focus */
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  appearance: none;
}

.input::placeholder { color: var(--muted); opacity: 0.7; }

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input--code {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  min-height: 56px;
}

.input--other { margin-top: 10px; }

.textarea { resize: vertical; min-height: 96px; }

.field__error {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--error);
}

.field__error:empty { display: none; }

.is-invalid .input,
.input.is-invalid { border-color: var(--error); }

/* ---------- Questions and options ---------- */

fieldset { border: 0; min-width: 0; }

.set + .set { margin-top: 48px; }

.set__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.question { margin-bottom: 28px; }

.question__title {
  font-weight: 600;
  margin-bottom: 12px;
  padding: 0;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.options--stack {
  flex-direction: column;
}

.option {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.option input,
.rating__scale input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.option span {
  display: flex;
  align-items: center;
  min-height: 44px;
  width: 100%;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.95rem;
  line-height: 1.2;
  user-select: none;
}

.options--stack .option span { border-radius: var(--radius); }

.option--sample span {
  justify-content: center;
  min-width: 64px;
  font-weight: 600;
}

.option input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.option input:focus-visible + span,
.rating__scale input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.is-invalid .option span,
.is-invalid .rating__scale span { border-color: var(--error); }

/* ---------- 1–5 ratings (5-sample set) ---------- */

.samples {
  display: grid;
  gap: 12px;
  margin-bottom: 32px;
}

.sample-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sample-card__title {
  float: left; /* pulls the legend out of the fieldset border */
  width: 100%;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.rating {
  clear: both;
  margin-top: 12px;
}

.rating:first-of-type { margin-top: 0; }

.rating__label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.rating__scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.rating__scale label {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rating__scale span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
  user-select: none;
}

.rating__scale input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* On wider screens: label and scale on one row */
@media (min-width: 420px) {
  .rating {
    display: grid;
    grid-template-columns: 104px 1fr;
    align-items: center;
    gap: 8px;
  }
  .rating__label { margin-bottom: 0; }
}

/* ---------- Demo mode banner ---------- */

.demo-banner {
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Submit status ---------- */

.form-status {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-status:empty { display: none; }
.form-status.is-error { color: var(--error); }

@media (prefers-reduced-motion: no-preference) {
  .option span,
  .rating__scale span,
  .input { transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
}
