/* Visual language matches the live OrderlyMeds Ontraport flow
   (patients.orderlymeds.com/eligibility) so speed comparisons are like for like. */
:root {
  --page-bg: #ffffff;
  --text-main: #2a2a2a;
  --text-muted: #5b6770;
  --border: #ced9dd;
  --primary: #0a3f56;
  --primary-dark: #072e3f;
  --primary-tint: #eaf3f6;
  --accent: #0e7c86;
  --btn-disabled: #c8c8c8;
  --btn-text-disabled: #767676;
}

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

body.elig-page {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--page-bg);
  color: var(--text-main);
  line-height: 1.4;
}

/* header: full-width bar with a hairline, logo on the left */

.elig-header {
  height: 55px;
  display: flex;
  align-items: center;
  padding: 0 21px;
  border-bottom: 1px solid var(--border);
}

.elig-logo {
  height: 34px;
  width: auto;
}

/* main layout */

.elig-main {
  max-width: 600px;
  margin: 24px auto 40px;
  padding: 0 24px;
}

.elig-card {
  max-width: 560px;
}

/* "Your medication" with a Change link, on every page after the medication choice. */
.med-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  padding: 10px 14px;
  background: var(--primary-tint);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
}
.med-bar-text { min-width: 0; }
.med-bar-label { display: block; font-size: .8rem; color: var(--text-muted); }
.med-bar strong { color: var(--primary); }
.med-bar-detail { color: var(--text-muted); white-space: nowrap; }
.med-bar-change {
  flex-shrink: 0;
  color: var(--primary);
  font-weight: 600;
  border: 1px solid var(--accent, var(--primary));
  border-radius: 999px;
  padding: 4px 14px;
  background: #fff;
  text-decoration: none;
}
.med-bar-change:hover { background: var(--primary); color: #fff; }

.elig-title {
  font-size: 1.75rem;
  line-height: 1.3;
  margin: 10px 0 12px;
  font-weight: 600;
  color: var(--primary);
}

.elig-subtitle {
  margin: 0 0 24px;
  font-size: 1rem;
  color: var(--text-main);
}

.elig-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.elig-link:hover {
  text-decoration: underline;
}

/* Top-of-page back navigation (arrow + "Go back"), shared by any step that wants it. */
.back-link { display:flex; align-items:center; gap:6px; margin-bottom:20px; }
.back-link a { color:#111; text-decoration:none; font-size:0.9rem; }

/* groups */

.elig-group {
  margin-bottom: 20px;
}

.field {
  margin-bottom: 14px;
}

.input {
  width: 100%;
  height: 52px;
  border-radius: 4px;
  border: 1px solid var(--border);
  padding: 0 16px;
  font: inherit;
  font-size: 1rem;
  color: var(--text-main);
  background: #fff;
  outline: none;
}

.input::placeholder {
  color: #8a8a8a;
}

/* .input's height:52px + padding:0 16px centers a single-line <input>'s text natively, but a
   <textarea> never auto-centers its content -- with no vertical padding the cursor sits pinned
   at the very top of the (taller, rows=3) box instead of having normal breathing room. */
textarea.input {
  height: auto;
  min-height: 90px;
  padding: 14px 16px;
  line-height: 1.4;
}

.input:focus {
  border-color: var(--primary);
}

/* row */

.row {
  display: flex;
  gap: 24px;
}

.row .half {
  flex: 1 1 0;
}

/* section labels */

.section-label {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  margin: 0 0 10px;
}

/* checkboxes */

.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  margin: 12px 0 4px;
}

.checkbox-line input {
  margin-top: 1px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.sms-note {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-main);
}

/* yes/no toggle */

.toggle-row {
  display: flex;
  gap: 16px;
}

.toggle-btn {
  flex: 1 1 0;
  height: 46px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-main);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.toggle-btn.selected {
  background: var(--primary-tint);
  border: 2px solid var(--primary);
  color: var(--primary);
}

/* footer button: full-width navy pill */

.elig-footer {
  margin-top: 32px;
}

.primary-btn {
  width: 100%;
  min-height: 50px;
  border: none;
  border-radius: 50px;
  padding: 12px 16px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--btn-disabled);
  color: var(--btn-text-disabled);
}

/* Back + continue pinned to the bottom of the viewport, split left/right, at every width -- a
   tall form puts the button off-screen on desktop just as easily as mobile. Opt-in -- add
   "nav-footer" alongside "elig-footer" on the button row, and "has-nav-footer" on <body> so
   .elig-main gets clearance for the bar. Pages that don't opt in are untouched. */
.nav-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--border);
}
/* On desktop the bar's contents line up with the 600px .elig-main column (552px inside its 24px
   padding) instead of stretching the Continue pill across the whole screen. */
@media (min-width: 601px) { .nav-footer { padding-inline: max(24px, calc(50% - 276px)); } }
.nav-footer .back-link { margin: 0; flex: 0 0 auto; }
/* primary-btn's own width:100% would otherwise become its flex-basis and force a wrap onto its
   own line -- a pre-existing bug (#58) only visible now that this bar is wide enough to show it. */
.nav-footer .primary-btn { flex: 1 1 0; width: auto; }
.nav-footer .status { flex-basis: 100%; order: 3; }
body.has-nav-footer .elig-main { padding-bottom: 92px; }

/* Bouncing arrow above the pinned bar while there's unseen content below it -- scroll_hint.js
   toggles .visible on the dot itself (built in JS, no markup per page) once the page is taller
   than the viewport and the patient hasn't reached the bottom yet. */
.scroll-hint {
  display: none; position: fixed; right: 16px; bottom: 104px;
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  align-items: center; justify-content: center; pointer-events: none;
}
.scroll-hint.visible { display: flex; }

.primary-btn:not(:disabled) {
  background: var(--primary);
  color: #ffffff;
}

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

/* Working: the button stays navy (it is busy, not unavailable) and shows a spinner beside its
   label. Scripts set aria-busy="true" while a request is in flight (payment.js busy()). */
.primary-btn[aria-busy="true"]:not([hidden]) {
  background: var(--primary);
  color: #ffffff;
  cursor: progress;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.primary-btn[aria-busy="true"]::after {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .primary-btn[aria-busy="true"]::after { animation-duration: 2.4s; }
}

.status {
  margin-top: 8px;
  font-size: 0.8rem;
}

.status.error {
  color: #b91c1c;
}

.status.success {
  color: #047857;
}

/* a11y label helpers */

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

/* responsive */

@media (max-width: 600px) {
  .elig-main {
    padding: 0 16px;
  }
  .elig-card {
    max-width: 100%;
  }
  .elig-title {
    font-size: 1.5rem;
  }
}
.choice-row {
  border: 1px solid #ced9dd;
  border-radius: 4px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  margin-bottom: 8px;
  cursor: pointer;
}

.choice-row .label {
  font-size: 0.9rem;
  color: #111827;
}

/* hide the native checkbox and use the .box as the visual control */
.choice-row .additive-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-row .box {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid #9ca3af;
  flex-shrink: 0;
}

/* when checked, color the box */
.choice-row .additive-checkbox:checked + .box {
  border-color: #0a3f56;
  background: #0a3f56;
}
.required-note {
  font-size: .85rem;
  color: #6b7280;
  margin: -6px 0 16px;
}

.error-summary {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 12px 0;
}

.input.error {
  border-color: #dc2626;
  background: #fff1f2;
}

.field-error {
  color: #b91c1c;
  font-size: .8rem;
  margin-top: 6px;
}

.toggle-row.error .toggle-btn {
  border-color: #dc2626;
}
.req-star { color:#dc2626; margin-left:4px; font-weight:700; }
/* State and Zip share a row (the address page). */
.field-row { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; }
.field-row > .field { min-width: 0; }

/* Phones: fit each step on one screen where the content allows (long checklists still scroll).
   Measured at 390x664, an iPhone's visible area in Safari. Every rule here only tightens spacing;
   wording, order and controls are unchanged. */
@media (max-width: 600px) {
  .elig-header { height: 44px; padding: 0 16px; }
  .elig-logo { height: 26px; }
  .elig-main { margin: 10px auto 12px; }
  .med-bar { margin: 0 0 8px; padding: 6px 6px 6px 12px; font-size: .9rem; }
  .med-bar-label { display: none; }
  .med-bar-change { padding: 3px 12px; font-size: .85rem; }
  .elig-title { font-size: 1.3rem; margin: 4px 0 6px; }
  .elig-subtitle { margin: 0 0 12px; font-size: .95rem; }
  .elig-group { margin-bottom: 14px; }
  .field { margin-bottom: 10px; }
  .input { height: 46px; }
  .section-label { font-size: 1rem; margin: 0 0 6px; }
  .elig-footer { margin-top: 12px; }
  .primary-btn { min-height: 48px; padding: 10px 16px; }
  .sms-note { margin: 4px 0 8px; font-size: .85rem; }
}
