/* ===========================================================================
   Borked PC — Right Fit Questionnaire, brand build
   Direction: Bone & Oxblood

   Same markup and same engine as the Typeform-matched build. Only the skin
   changes. Everything here references semantic tokens from tokens.css, never
   a literal hex, and it follows the three rules that file sets out:

     1. Red is a rule, an underline, a mark or one small button. It is never a
        field behind type, so the question counter and the choice key are
        accent-coloured marks rather than filled red chips.
     2. Outside a single accent rule, red stays below 24px.
     3. Dark theme comes free, because only the semantic tokens move.
   =========================================================================== */

* { box-sizing: border-box; }

html {
  color-scheme: light dark;
  height: 100%;
}

body {
  position: relative;
  margin: 0;
  height: 100%;
  background: var(--bpc-surface-ground);
  color: var(--bpc-text-primary);
  font-family: var(--bpc-font-body);
  font-size: var(--bpc-size-body-m);
  line-height: var(--bpc-lh-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Paper grain. Fixed so it does not travel with a scrolling screen. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--bpc-texture-grain);
  background-repeat: repeat;
  opacity: 0.5;
}

.rf {
  position: relative;
  z-index: 1;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- progress ---------- */

.rf-progress {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 40;
  padding: 0;
}

.rf-progress-track {
  height: var(--bpc-border-width-rule);
  background: var(--bpc-border-hairline);
}

.rf-progress-fill {
  height: 100%;
  width: 0;
  background: var(--bpc-accent);
  transition: width var(--bpc-motion-slow) var(--bpc-ease);
}

/* ---------- logo ---------- */

.rf-logo {
  position: absolute;
  top: var(--bpc-space-6);
  left: var(--bpc-space-6);
  z-index: 40;
  display: block;
  line-height: 0;
}

.rf-logo img {
  width: 44px;
  height: auto;
  display: block;
}

/* ---------- stage ---------- */

.rf-stage {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
}

.rf-screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  justify-content: center;
}

.rf-screen-in { animation: rf-in var(--bpc-motion-slow) var(--bpc-ease) both; }
.rf-screen-in-back { animation: rf-in-back var(--bpc-motion-slow) var(--bpc-ease) both; }
.rf-screen-out { animation: rf-out var(--bpc-motion-base) var(--bpc-ease) both; }
.rf-screen-out-back { animation: rf-out-back var(--bpc-motion-base) var(--bpc-ease) both; }

@keyframes rf-in       { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes rf-in-back  { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
@keyframes rf-out      { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-24px); } }
@keyframes rf-out-back { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(24px); } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .rf-screen-in, .rf-screen-in-back, .rf-screen-out, .rf-screen-out-back { animation-duration: 0.01s; }
}

.rf-block {
  width: 100%;
  max-width: 820px;
  padding: var(--bpc-space-13) var(--bpc-space-12) var(--bpc-space-11);
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: var(--bpc-space-8);
  border: 0;
}

.rf-block--centered { align-items: center; text-align: center; }

/* ---------- question head ---------- */

/* Measures are set on the elements that own the font size they are counted
   in. A ch unit on this container would be counted in 16px body text and
   choke a 44px display line down to a column. */
.rf-head {
  display: flex;
  flex-direction: column;
  gap: var(--bpc-space-4);
}

.rf-head .rf-title { max-width: 22ch; }
.rf-head .rf-description { max-width: var(--bpc-measure-reading); }

.rf-title-row {
  display: flex;
  align-items: baseline;
  gap: var(--bpc-space-4);
}

/* The counter is a mono mark, not a filled chip. Rule 1. */
.rf-counter { flex: 0 0 auto; padding: 0; }

.rf-counter span {
  display: inline-block;
  background: none;
  color: var(--bpc-accent-sm);
  font-family: var(--bpc-font-mono);
  font-size: var(--bpc-size-label);
  font-weight: 500;
  letter-spacing: var(--bpc-track-label);
  line-height: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.rf-counter span::after { content: '.'; }

/* Typeform's little arrow glyph has no place in this system. */
.rf-counter svg { display: none; }

.rf-title {
  margin: 0;
  font-family: var(--bpc-font-display);
  font-size: var(--bpc-size-display-m);
  font-weight: var(--bpc-display-weight);
  line-height: var(--bpc-lh-display-m);
  letter-spacing: var(--bpc-track-display);
  color: var(--bpc-text-primary);
}

.rf-title strong { font-weight: 500; }

.rf-required {
  padding-left: 2px;
  color: var(--bpc-accent-sm);
  font-family: var(--bpc-font-body);
  font-size: var(--bpc-size-body-m);
  vertical-align: super;
}

.rf-description {
  margin: 0;
  font-size: var(--bpc-size-body-l);
  line-height: var(--bpc-lh-body);
  color: var(--bpc-text-secondary);
  max-width: var(--bpc-measure-reading);
}

.rf-description strong {
  font-weight: 600;
  color: var(--bpc-text-primary);
}

/* ---------- media ---------- */

.rf-media {
  width: fit-content;
  max-width: 100%;
  line-height: 0;
  border: var(--bpc-border-width-hairline) solid var(--bpc-border-hairline);
  border-radius: var(--bpc-radius-md);
  overflow: hidden;
  box-shadow: var(--bpc-shadow-sm);
}

.rf-media img {
  max-width: 100%;
  max-height: 42vh;
  object-fit: contain;
  display: block;
}

.rf-media--video {
  width: 100%;
  max-width: 620px;
  aspect-ratio: 16 / 9;
  box-shadow: var(--bpc-shadow-md);
}

.rf-media--video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.rf-answer {
  display: flex;
  flex-direction: column;
  gap: var(--bpc-space-8);
}

/* ---------- choices ---------- */

.rf-choices {
  display: flex;
  flex-direction: column;
  gap: var(--bpc-space-3);
  align-items: stretch;
  width: 100%;
  max-width: 620px;
  border: 0;
  padding: 0;
  margin: 0;
}

.rf-choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--bpc-space-4);
  width: 100%;
  padding: var(--bpc-space-4) var(--bpc-space-5);
  border: var(--bpc-border-width-hairline) solid var(--bpc-border-hairline);
  border-left-width: var(--bpc-border-width-accent);
  border-left-color: transparent;
  border-radius: var(--bpc-radius-md);
  background: var(--bpc-surface-raised);
  box-shadow: var(--bpc-shadow-sm);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--bpc-motion-base) var(--bpc-ease),
              box-shadow var(--bpc-motion-base) var(--bpc-ease),
              transform var(--bpc-motion-fast) var(--bpc-ease);
  -webkit-appearance: none;
  appearance: none;
}

/* app.js paints a tint layer here; the brand build keeps it out of the way. */
.rf-choice::before { content: none; }

.rf-choice:hover {
  border-color: var(--bpc-border-strong);
  border-left-color: var(--bpc-accent);
  box-shadow: var(--bpc-shadow-md);
}

.rf-choice:focus-visible {
  outline: 2px solid var(--bpc-accent);
  outline-offset: 3px;
}

/* Selected reads as an accent rule down the edge, which is how red is
   allowed to behave here, plus a hairline in the same colour. */
.rf-choice[aria-checked='true'],
.rf-choice[aria-checked='true']:hover {
  border-color: var(--bpc-border-accent);
  border-left-color: var(--bpc-accent);
  box-shadow: var(--bpc-shadow-md);
}

.rf-choice-key {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-top: 5px;
}

.rf-choice-key span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--bpc-space-2);
  border: var(--bpc-border-width-hairline) solid var(--bpc-border-hairline);
  border-radius: var(--bpc-radius-sm);
  background: var(--bpc-surface-sunk);
  color: var(--bpc-text-secondary);
  font-family: var(--bpc-font-mono);
  font-size: var(--bpc-size-label);
  font-weight: 500;
  letter-spacing: var(--bpc-track-label);
  line-height: 1;
  transition: color var(--bpc-motion-base) var(--bpc-ease),
              border-color var(--bpc-motion-base) var(--bpc-ease);
}

.rf-choice:hover .rf-choice-key span { color: var(--bpc-text-primary); }

.rf-choice[aria-checked='true'] .rf-choice-key span {
  border-color: var(--bpc-border-accent);
  color: var(--bpc-accent-sm);
}

.rf-choice-label {
  padding: 0;
  font-family: var(--bpc-font-body);
  font-size: var(--bpc-size-body-l);
  line-height: var(--bpc-lh-tight);
  color: var(--bpc-text-primary);
}

/* ---------- inputs ---------- */

.rf-fields {
  display: flex;
  flex-direction: column;
  gap: var(--bpc-space-7);
  max-width: 620px;
}

.rf-field { display: flex; flex-direction: column; gap: var(--bpc-space-2); }

.rf-label {
  font-family: var(--bpc-font-mono);
  font-size: var(--bpc-size-label);
  font-weight: 500;
  letter-spacing: var(--bpc-track-label);
  text-transform: uppercase;
  line-height: 1.6;
  color: var(--bpc-text-secondary);
}

.rf-label .rf-required { vertical-align: baseline; }

/* Small print under the contact fields (privacy line). */
.rf-note {
  margin: var(--bpc-space-6) 0 0;
  font-size: var(--bpc-size-body-s);
  line-height: var(--bpc-lh-body);
  color: var(--bpc-text-secondary);
  max-width: 620px;
}

.rf-description a,
.rf-note a {
  color: var(--bpc-accent-sm);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rf-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rf-input-wrap {
  display: flex;
  align-items: center;
  border-bottom: var(--bpc-border-width-hairline) solid var(--bpc-border-strong);
  box-shadow: none;
  transition: border-color var(--bpc-motion-base) var(--bpc-ease);
}

.rf-input-wrap:focus-within { border-bottom-color: var(--bpc-accent); }

.rf-input {
  flex: 1 1 auto;
  width: 100%;
  padding: var(--bpc-space-3) 0;
  border: 0;
  background: transparent;
  color: var(--bpc-text-primary);
  font-family: var(--bpc-font-body);
  font-size: var(--bpc-size-heading-l);
  line-height: 1.5;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.rf-input::placeholder { color: var(--bpc-text-muted); }

.rf-country {
  flex: 0 0 auto;
  padding: var(--bpc-space-3) var(--bpc-space-3) var(--bpc-space-3) 0;
  margin-right: var(--bpc-space-2);
  border: 0;
  background: transparent;
  color: var(--bpc-text-secondary);
  font-family: var(--bpc-font-mono);
  font-size: var(--bpc-size-body-s);
  outline: none;
  cursor: pointer;
}

.rf-error {
  display: flex;
  align-items: center;
  gap: var(--bpc-space-3);
  align-self: flex-start;
  padding: var(--bpc-space-3) var(--bpc-space-4);
  border: var(--bpc-border-width-hairline) solid var(--bpc-status-critical);
  border-left-width: var(--bpc-border-width-accent);
  border-radius: var(--bpc-radius-sm);
  background: var(--bpc-surface-raised);
  color: var(--bpc-status-critical);
  font-size: var(--bpc-size-body-s);
  font-weight: 600;
  line-height: 1.4;
}

.rf-error span:first-child {
  font-family: var(--bpc-font-mono);
  font-weight: 500;
}

/* ---------- buttons ---------- */

.rf-actions {
  display: flex;
  align-items: center;
  gap: var(--bpc-space-5);
  flex-wrap: wrap;
}

.rf-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--bpc-space-3);
  padding: var(--bpc-space-4) var(--bpc-space-7);
  border: 0;
  border-radius: var(--bpc-radius-md);
  background: var(--bpc-accent);
  color: var(--bpc-text-on-accent);
  font-family: var(--bpc-font-body);
  cursor: pointer;
  transition: background var(--bpc-motion-base) var(--bpc-ease);
  -webkit-appearance: none;
  appearance: none;
}

.rf-button::before { content: none; }

.rf-button:hover { background: var(--bpc-accent-hover); }

.rf-button:focus-visible {
  outline: 2px solid var(--bpc-accent);
  outline-offset: 3px;
}

.rf-button span {
  position: relative;
  padding: 0;
  font-size: var(--bpc-size-heading-s);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: .01em;
}

.rf-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--bpc-space-2);
  font-family: var(--bpc-font-mono);
  font-size: var(--bpc-size-label);
  font-weight: 400;
  letter-spacing: .06em;
  color: var(--bpc-text-muted);
  opacity: 1;
}

.rf-hint kbd {
  font-family: var(--bpc-font-mono);
  font-size: var(--bpc-size-label);
  font-weight: 500;
  color: var(--bpc-text-secondary);
}

/* ---------- footer nav ---------- */

.rf-footer {
  position: relative;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--bpc-space-6) var(--bpc-space-6);
  pointer-events: none;
}

.rf-nav {
  display: flex;
  gap: var(--bpc-space-1);
  margin-left: auto;
  pointer-events: auto;
}

/* Left-pointing Back, for people who think back means left. 44px tall to be an easy tap target. */
.rf-back {
  display: inline-flex;
  align-items: center;
  gap: var(--bpc-space-1);
  min-height: 44px;
  padding: 0 var(--bpc-space-3) 0 var(--bpc-space-2);
  border: 0;
  background: none;
  font-family: var(--bpc-font-body);
  font-size: var(--bpc-size-body-s);
  color: var(--bpc-text-secondary);
  cursor: pointer;
  pointer-events: auto;
  transition: color var(--bpc-motion-base) var(--bpc-ease);
  -webkit-appearance: none;
  appearance: none;
}

.rf-back svg { width: 20px; height: 20px; fill: currentColor; }
.rf-back:hover { color: var(--bpc-accent); }
.rf-back:focus-visible { outline: 2px solid var(--bpc-accent); outline-offset: 3px; }
.rf-back[hidden] { display: none; }

.rf-nav-btn {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: var(--bpc-border-width-hairline) solid var(--bpc-border-hairline);
  border-radius: var(--bpc-radius-sm);
  background: var(--bpc-surface-raised);
  box-shadow: var(--bpc-shadow-sm);
  cursor: pointer;
  transition: border-color var(--bpc-motion-base) var(--bpc-ease);
  -webkit-appearance: none;
  appearance: none;
}

.rf-nav-btn::before { content: none; }

.rf-nav-btn:hover:not(:disabled) { border-color: var(--bpc-border-accent); }

.rf-nav-btn svg {
  position: relative;
  width: 18px;
  height: 18px;
  fill: var(--bpc-text-secondary);
}

.rf-nav-btn:hover:not(:disabled) svg { fill: var(--bpc-accent); }

.rf-nav-btn:disabled { cursor: default; }
.rf-nav-btn:disabled svg { fill: var(--bpc-text-muted); opacity: .5; }

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

.rf-footer[hidden] { display: none; }

/* ---------- welcome and endings ---------- */

.rf-welcome .rf-block,
.rf-ending .rf-block { align-items: center; text-align: center; }

.rf-welcome .rf-head,
.rf-ending .rf-head { align-items: center; }

.rf-welcome .rf-title,
.rf-ending .rf-title { max-width: var(--bpc-measure-display); }

.rf-welcome .rf-description,
.rf-ending .rf-description { max-width: var(--bpc-measure-caption); }

.rf-welcome .rf-title,
.rf-ending .rf-title {
  font-size: var(--bpc-size-display-l);
  line-height: var(--bpc-lh-display-l);
}

.rf-welcome .rf-actions,
.rf-ending .rf-actions { justify-content: center; }

/* ---------- responsive ---------- */

@media (max-width: 767px) {
  .rf-block {
    padding: var(--bpc-space-11) var(--bpc-gutter-min) var(--bpc-space-10);
    gap: var(--bpc-space-7);
  }
  .rf-title { font-size: var(--bpc-size-display-m); }
  .rf-description { font-size: var(--bpc-size-body-m); }
  .rf-input { font-size: var(--bpc-size-heading-m); }
  .rf-choice-label { font-size: var(--bpc-size-body-m); }
  .rf-choice { padding: var(--bpc-space-3) var(--bpc-space-4); }
  .rf-media img { max-height: 28vh; }
  .rf-logo { top: var(--bpc-space-5); left: var(--bpc-gutter-min); }
  .rf-logo img { width: 36px; }
  .rf-footer { padding: 0 var(--bpc-gutter-min) var(--bpc-space-5); }
}

/* Honeypot field: off-screen, never seen or tabbed to by people. */
.rf-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
