/* ==========================================================================
   Baht — Brand Alignment Index form
   ========================================================================== */

:root {
  --mint: #c4f3df; /* matches the background baked into img/bg-hero.svg */
  --green: #06c98b;
  --primary: #ffc43c;
  --primary-hover: #edb02b;
  --primary-ink: #2b2f33;
  --blue: #0a5cff;
  --blue-soft: #cfe0fb;
  --blue-tint: #f2f7ff;
  --ink: #2b2f33;
  --muted: #5d6670;
  --line: #dfe4e9;
  --danger: #c62828;
  --danger-tint: #fdf1f1;
  --warning-tint: #fff7e0;
  --warning-line: #e6c65c;
  --white: #fff;

  --sidebar-width: 26vw;
  --content-width: 700px;
  --gutter: 40px;
  --gutter-left: clamp(40px, 8vw, 115px);
  --radius: 10px;

  --font: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--mint);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  background-image: url(../img/bg.jpg);
}

h1, h2, h3, h4, p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Layout
   ========================================================================== */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.sidebar__logo {
  display: block;
  margin: 16px 0 0 32px;
}

.sidebar__hero {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  object-position: left bottom;
  padding:30px;
}

.main {
  margin-left: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-padding-top: 120px;
  background: var(--white);
  border-radius: 48px 0 0 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 28px var(--gutter) 0 var(--gutter-left);
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.progress,
.content {
  max-width: var(--content-width);
  margin: 0;
}

.content {
  box-sizing: content-box;
  padding: 56px var(--gutter) 72px var(--gutter-left);
}

/* Progress navigation
   ========================================================================== */

.progress__list {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 -3px;
  padding: 22px 0 0;
  list-style: none;
}

.progress__step {
  display: block;
  width: 100%;
  padding: 12px 0 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.progress__step:disabled {
  cursor: default;
}

/* Only the current step's label is visible; the others are exposed via aria-label. */
.progress__label {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
}

.progress__step.is-current .progress__label {
  display: block;
  color: var(--blue);
  font-weight: 600;
}

.progress__bar {
  position: relative;
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--blue-soft);
  overflow: hidden;
}

.progress__bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 3px;
  background: var(--blue);
}

.progress__step.is-current .progress__bar::after {
  width: 50%;
}

.progress__step.is-done .progress__bar::after {
  width: 100%;
}

/* Steps & questions
   ========================================================================== */

.step__title {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 700;
}

.step__title:focus {
  outline: none;
}

.step__intro {
  margin-top: 16px;
  display: grid;
  gap: 14px;
  font-size: 1.0625rem;
}

.step__intro .is-note {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--blue-tint);
  font-size: 0.9375rem;
}

.step__required-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

.step__questions {
  display: grid;
  gap: 40px;
  margin-top: 32px;
}

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

legend {
  padding: 0;
}

.field {
  min-width: 0;
}

.field__label {
  display: block;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.35;
}

.field__required {
  color: var(--danger);
}

.field__hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.field__control {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  padding: 11px 14px;
  border: 1px solid #b9c1c9;
  border-radius: var(--radius);
  background: var(--white);
}

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

.field__control::placeholder {
  color: #8a939c;
}

.field__control:focus-visible {
  outline-offset: 0;
  border-color: var(--blue);
}

.field__control[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-tint);
}

.field__error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.9375rem;
  font-weight: 600;
}

.field__error::before {
  content: "⚠ ";
}

.field__status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.field__status.is-warning {
  padding: 10px 14px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius);
  background: var(--warning-tint);
  color: var(--ink);
  font-weight: 600;
}

/* Composite questions (respondent, competitors, links) */

.field-group__body {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.field-group .field-group__body .field__label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.field-group .field-group__body .field__control {
  margin-top: 6px;
}

.field-group--pairs .field-group__body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
}

/* Choice options */

.options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.options--compact {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.option-group {
  margin-top: 24px;
}

.option-group__title {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
}

.option:hover {
  border-color: #aeb8c2;
}

.option input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.option input:focus-visible {
  outline: none;
}

.option:has(input:focus-visible) {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.option:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-tint);
}

.option__text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.option__text strong {
  font-weight: 600;
}

/* Limit reached: remaining options look unavailable but stay clickable so the
   explanation can be shown. */
.is-capped .option:not(:has(input:checked)) {
  background: #f6f7f8;
  color: var(--muted);
}

.option-other {
  margin-top: 8px;
}

.option-other .field__control {
  margin-top: 0;
}

/* Review
   ========================================================================== */

.review {
  margin-top: 24px;
}

.review__section {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.review__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.review__heading {
  font-size: 1rem;
  font-weight: 700;
}

.review__list {
  margin: 12px 0 0;
}

.review__list dt {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.review__list dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.review__list dd.is-empty {
  color: var(--muted);
  font-style: italic;
}

/* Buttons, notices, footer
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 24px;
  border: 2px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--primary::after {
  content: ">";
}

.btn--secondary {
  border-color: #b9c1c9;
  background: var(--white);
}

.btn--secondary:hover {
  border-color: var(--ink);
}

.btn--danger {
  background: var(--danger);
  color: var(--white);
}

.btn-link {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}

.actions .btn--primary {
  margin-left: auto;
}

.form[data-step="0"] .actions .btn--primary {
  margin-left: 0;
}

.notice {
  margin-top: 32px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.notice--warning {
  border-color: var(--warning-line);
  background: var(--warning-tint);
}

.notice--success {
  border-color: var(--green);
  background: #e9fbf4;
}

.notice--error {
  border-color: var(--danger);
  background: var(--danger-tint);
}

.form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-top: 56px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 28px;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.dialog::backdrop {
  background: rgba(20, 30, 28, 0.5);
}

.dialog__title {
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Mobile (below 991px)
   ========================================================================== */

@media (max-width: 990.98px) {
  :root {
    --gutter: 20px;
    --gutter-left: 20px;
  }

  html {
    scroll-padding-top: 96px;
  }

  .sidebar {
    position: static;
    width: auto;
    padding: 16px var(--gutter);
  }

  .sidebar__logo {
    margin: 0;
  }

  .sidebar__hero {
    display: none;
  }

  .main {
    margin-left: 0;
    height: auto;
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
    overflow: visible;
    border-radius: 24px 24px 0 0;
  }

  .topbar {
    padding-top: 18px;
    border-radius: 24px 24px 0 0;
  }

  .progress__list {
    gap: 8px;
  }

  .content {
    padding: 32px var(--gutter) 48px var(--gutter-left);
  }

  .step__title {
    font-size: 1.3125rem;
  }

  .step__questions {
    gap: 32px;
  }

  .review__section {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .field-group--pairs .field-group__body {
    grid-template-columns: 1fr;
  }

  /* Keep each competitor's name and website visually paired when stacked. */
  .field-group--pairs .field:nth-child(even) {
    margin-top: -8px;
    margin-bottom: 8px;
  }

  .options--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions .btn {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .option {
    transition: background-color 0.12s, border-color 0.12s;
  }
}
