/* Knee Xpert - Sahaj Knee Score quiz
   Brand tokens are the ones the live site already uses: #264796 / #1DB0D0. */

:root {
  --primary: #264796;
  --primary-dark: #1a3575;
  --secondary: #1db0d0;
  --ink: #343a40;
  --muted: #6c757d;
  --line: #dfe4ec;
  --bg: #f4f6fa;
  --white: #fff;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(38, 71, 150, 0.09);
  --shadow-lg: 0 10px 34px rgba(38, 71, 150, 0.16);
  --green: #1a7f4b;
  --amber: #b8860b;
  --red: #c0392b;
  --green-bg: #eaf9f0;
  --amber-bg: #fdf5e0;
  --red-bg: #fdeeec;
}

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

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1rem; }

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

/* ---------------- top bar ---------------- */
.topbar { background: var(--white); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 68px; }
.brand img { height: 44px; width: auto; display: block; }

.lang { display: flex; align-items: center; gap: .5rem; margin: 0; }
.lang label { font-size: .875rem; color: var(--muted); }
.lang select {
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer;
}
.lang select:focus-visible { outline: 2px solid var(--secondary); outline-offset: 1px; }

/* ---------------- hero ---------------- */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white); border-radius: var(--radius);
  padding: 2rem 1.5rem; margin: 1.5rem 0; text-align: center;
}
.hero h1 { margin: 0 0 .35rem; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.25; }
.hero p { margin: 0; opacity: .93; }

/* ---------------- card ---------------- */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 2.5rem;
}

h2.section {
  background: var(--secondary); color: var(--white);
  padding: .7rem 1.1rem; border-radius: 10px;
  margin: 2rem 0 1rem; font-size: 1.05rem; font-weight: 600;
}
h2.section:first-of-type { margin-top: 0; }
.intro { margin: 0 0 1.25rem; color: var(--muted); }

/* ---------------- fields ---------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; }
.field label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }

input[type=text], input[type=number], input[type=tel], select {
  font: inherit; color: var(--ink); background: var(--white);
  padding: .7rem .8rem; border: 1px solid #ced4da; border-radius: 8px; width: 100%;
}
input:focus-visible, select:focus-visible {
  outline: none; border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(29, 176, 208, .22);
}
input:user-invalid { border-color: var(--red); }

.phone { display: flex; }
.phone .prefix {
  display: flex; align-items: center; padding: 0 .7rem;
  background: #eef1f6; border: 1px solid #ced4da; border-right: 0;
  border-radius: 8px 0 0 8px; font-weight: 600; color: var(--muted);
}
.phone input { border-radius: 0 8px 8px 0; }

.height { display: flex; gap: .5rem; }
.height select { flex: 1 1 0; min-width: 0; }

.hint { margin: .3rem 0 0; font-size: .75rem; color: var(--muted); line-height: 1.4; }
.field--wide { grid-column: 1 / -1; }

/* ---------------- symptom checkboxes ---------------- */
.checks {
  border: 0; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem;
}
.check {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.check:hover { border-color: var(--secondary); }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; flex: none; cursor: pointer; }
.check:has(input:checked) { border-color: var(--primary); background: #f2f6ff; font-weight: 600; }
.check:has(input:focus-visible) { outline: 2px solid var(--secondary); outline-offset: 1px; }

/* ---------------- activity cards ---------------- */
.activities { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.activity {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; transition: box-shadow .2s, border-color .2s;
}
.activity:hover { box-shadow: var(--shadow); border-color: #c9d6ea; }
.activity h3 {
  margin: 0 0 .6rem; font-size: 1rem; color: var(--primary);
  display: flex; align-items: center; gap: .5rem;
}
.qnum {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: #eef2fa; color: var(--primary);
  font-size: .78rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.activity picture { display: block; }
.activity img {
  width: 100%; height: auto; display: block; aspect-ratio: 1 / 1;
  border-radius: 8px; margin-bottom: .75rem; background: #f0f2f6;
}
.activity.is-answered { border-color: var(--primary); background: #fbfcff; }
.activity.is-answered .qnum { background: var(--primary); color: #fff; }

/* Pain level: five tap targets instead of a native picker. On a phone this is one tap rather
   than tap -> scroll wheel -> confirm, seven times over. */
.levels { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
/* Chips size to their own text and wrap to a new row when they run out of space. A fixed
   five-across grid cannot hold the translated labels - Tamil's "extreme" is two long words - and
   forcing it produced mid-word breaks like "Moderat e". */
.level { flex: 1 1 auto; }
.level input {
  position: absolute; opacity: 0; width: 1px; height: 1px;
  pointer-events: none; margin: 0;
}
.level span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: .45rem .7rem;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: .8rem; line-height: 1.2; font-weight: 600; color: var(--muted);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.level span:hover { border-color: var(--secondary); }
.level input:checked + span { color: #fff; border-color: transparent; }
/* Colour runs green -> red, so the scale reads at a glance without needing to be read. */
.level--none     input:checked + span { background: #3cb878; }
.level--mild     input:checked + span { background: #8cc63f; }
.level--moderate input:checked + span { background: #f5c33b; color: #4a3b00; }
.level--severe   input:checked + span { background: #f08b4b; }
.level--extreme  input:checked + span { background: #e5544b; }
.level input:focus-visible + span { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* ---------------- actions ---------------- */
.actions { margin-top: 2rem; text-align: center; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 50px; padding: .85rem 2.2rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  transition: background .2s, transform .12s, box-shadow .2s;
}
.btn:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: var(--white); box-shadow: var(--shadow); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-primary:disabled { opacity: .65; cursor: progress; transform: none; }
.btn-ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost:hover { background: var(--primary); color: var(--white); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: var(--white);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.privacy { margin: .9rem 0 0; font-size: .8rem; color: var(--muted); }

.error {
  margin-top: 1.25rem; padding: .85rem 1rem;
  background: var(--red-bg); border-left: 4px solid var(--red);
  border-radius: 0 8px 8px 0; color: #8e2b20; font-weight: 500;
}

/* ---------------- result ---------------- */
.result { text-align: center; padding: .5rem 0 1.5rem; }
.result-head { display: flex; align-items: center; justify-content: center; gap: .7rem; }
.result-head h2 { margin: 0; font-size: 1.3rem; color: var(--primary); }
.result-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--muted); flex: none; }
.result.green .result-dot { background: #3cb878; }
.result.amber .result-dot { background: #f5c33b; }
.result.red   .result-dot { background: #e5544b; }

.result-score { font-size: 3.6rem; font-weight: 700; line-height: 1.1; margin: .6rem 0 .2rem; color: var(--primary); }
.result-max { font-size: 1.3rem; color: var(--muted); font-weight: 600; margin-left: .2rem; }
.result-percent { display: block; font-size: 1rem; font-weight: 600; color: var(--muted); }

.result-meter { height: 12px; background: #e9edf4; border-radius: 50px; overflow: hidden; margin: 1rem auto; max-width: 460px; }
.result-bar { height: 100%; width: 0; border-radius: 50px; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.result.green .result-bar { background: linear-gradient(90deg, #6cd39a, #3cb878); }
.result.amber .result-bar { background: linear-gradient(90deg, #f8d976, #f5c33b); }
.result.red   .result-bar { background: linear-gradient(90deg, #f08b83, #e5544b); }

.result-band { font-size: 1.15rem; font-weight: 600; margin: .5rem 0; }
.result.green .result-band { color: var(--green); }
.result.amber .result-band { color: var(--amber); }
.result.red   .result-band { color: var(--red); }
.result-bmi { color: var(--muted); margin: .2rem 0 1rem; }
.result-note {
  max-width: 460px; margin: 0 auto 1.5rem; padding: .8rem 1rem;
  background: #f2f8fc; border-radius: 10px; color: var(--primary); font-weight: 500;
}

/* ---------------- footer ---------------- */
.footer { background: var(--primary); color: var(--white); padding: 2rem 0; margin-top: auto; }
.footer-inner { text-align: center; }
.footer p { margin: 0 0 .75rem; }
.footer a { color: var(--white); text-decoration: underline; text-underline-offset: 2px; }
.footer a:hover { color: #9fd8ea; }
.footer-contact { font-weight: 600; }
.footer .disclaimer, .footer .copyright { font-size: .8rem; opacity: .82; }
.footer .disclaimer { max-width: 760px; margin: 1.25rem auto .75rem; }

@media (max-width: 600px) {
  .card { padding: 1rem; }
  .hero { padding: 1.5rem 1rem; }
  .btn-primary { width: 100%; }
  .brand img { height: 36px; }
  .result-score { font-size: 2.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Language switcher fallback button. Hidden by quiz.js when JavaScript is available, because the
   select then switches on change; without JS this is the only way to submit. */
.lang-go {
  font: inherit; font-size: .85rem; padding: .4rem .9rem; cursor: pointer;
  border: 1px solid var(--primary); border-radius: 50px;
  background: var(--primary); color: var(--white);
}
.lang-go[hidden] { display: none; }

/* ---------------- progress ---------------- */
/* The form is nearly seven screens long on a phone; this sets expectations without changing the
   order of anything. Sits directly under the sticky header. */
.progress {
  position: sticky; top: 68px; z-index: 15;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: .5rem 0;
}
.progress-inner { display: flex; align-items: center; gap: .75rem; }
.progress-track { flex: 1; height: 6px; background: #e9edf4; border-radius: 50px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0; border-radius: 50px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  transition: width .35s ease;
}
.progress-label { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.progress-label b { color: var(--primary); font-size: .9rem; }

/* ---------------- floating contact bar ---------------- */
/* Always a way to reach the clinic. Hidden by quiz.js whenever the submit button is on screen, so
   it can never sit on top of the primary action. */
.floating {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: .5rem;
  padding: .55rem .75rem calc(.55rem + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(38, 71, 150, .09);
  transition: transform .25s ease, opacity .2s ease;
}
.floating.is-hidden { transform: translateY(110%); opacity: 0; pointer-events: none; }
.floating-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 46px; border-radius: 50px; font-weight: 700; font-size: .92rem;
  text-decoration: none; color: #fff;
}
.floating-btn--wa { background: #25d366; }
.floating-btn--call { background: var(--primary); }
.floating-btn:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.floating .ico { font-size: 1.05rem; }

/* Keep the bar from covering the footer's own links. */
.footer { padding-bottom: 5.5rem; }

/* ---------------- result actions ---------------- */
.result-headline { font-weight: 700; font-size: 1.05rem; margin: 1rem 0 .35rem; color: var(--ink); }
.result-cta-text { margin: 0 auto 1rem; max-width: 460px; color: var(--muted); }

.result-urgent {
  max-width: 460px; margin: 1rem auto; padding: .8rem 1rem; text-align: left;
  background: var(--red-bg); border-left: 4px solid var(--red); border-radius: 0 8px 8px 0;
}
.result-urgent b { color: var(--red); display: block; margin-bottom: .2rem; }
.result-urgent p { margin: 0; font-size: .9rem; }

.result-actions {
  display: flex; flex-direction: column; gap: .6rem;
  max-width: 420px; margin: 0 auto 1.25rem;
}
.btn-whatsapp, .btn-call {
  text-decoration: none; min-height: 52px; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: 50px; font-weight: 700; padding: .8rem 1.5rem;
}
.btn-whatsapp { background: #25d366; color: #fff; box-shadow: 0 4px 14px rgba(37, 211, 102, .32); }
.btn-whatsapp:hover { background: #1fb857; }
.btn-call { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-call:hover { background: var(--primary); color: #fff; }
/* Red's guidance is same-day urgency, so the call is promoted above WhatsApp for that band. */
.result.call-first .result-actions { flex-direction: column-reverse; }
.result.call-first .btn-call { background: var(--red); border-color: var(--red); color: #fff; }
.result.call-first .btn-call:hover { background: #a93226; }
.result.call-first .btn-whatsapp { background: transparent; color: #1fa855; border: 2px solid #25d366; box-shadow: none; }

.linklike {
  background: none; border: 0; padding: .5rem; font: inherit; font-size: .88rem;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}
.linklike:hover { color: var(--primary); }

/* ---------------- mobile ---------------- */
@media (max-width: 600px) {
  .topbar-inner { min-height: 56px; }
  .brand img { height: 32px; }
  .progress { top: 56px; }
  .hero { padding: 1.25rem 1rem; margin: 1rem 0; }
  .hero-meta { font-size: .82rem; opacity: .85; margin-top: .4rem; }
  .level span { min-height: 46px; font-size: .82rem; }
  /* the floating bar sits over the page, so the form must not end underneath it */
  .actions { padding-bottom: 4.5rem; }
}

.hero-meta { margin-top: .5rem; font-size: .85rem; opacity: .9; }

@media (min-width: 601px) {
  /* On a desktop the floating bar is unnecessary chrome - the footer is already reachable. */
  .floating { display: none; }
  .footer { padding-bottom: 2rem; }
}

/* ---------------- patient testimonials ---------------- */
/* Facade cards: a self-hosted thumbnail with a play button. The YouTube iframe is only inserted
   when one is tapped, so a visitor who never plays costs nothing and contacts nobody. */
.stories { margin: 2rem 0 1.25rem; text-align: left; }
.stories h3 {
  font-size: .95rem; color: var(--primary); text-align: center;
  margin: 0 0 .9rem; font-weight: 700;
}
.story-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .85rem; }

.story {
  display: block; width: 100%; padding: 0; text-align: left; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  font: inherit; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.story:hover { border-color: var(--secondary); box-shadow: var(--shadow); transform: translateY(-2px); }
.story:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

.story-thumb { position: relative; display: block; background: #e9edf4; }
.story-thumb img { width: 100%; height: auto; display: block; aspect-ratio: 16 / 9; object-fit: cover; }

.story-play {
  position: absolute; inset: 0; margin: auto;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
/* the triangle */
.story-play::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 0; height: 0;
  border-left: 15px solid #fff;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  transform: translateX(2px);
}
.story:hover .story-play { background: #e5544b; }

.story-time {
  position: absolute; right: .4rem; bottom: .4rem;
  background: rgba(0, 0, 0, .78); color: #fff;
  font-size: .68rem; font-weight: 600; padding: .1rem .35rem; border-radius: 3px;
}

.story-title {
  display: block; padding: .55rem .6rem .65rem;
  font-size: .78rem; line-height: 1.35; color: var(--ink); font-weight: 600;
}

/* Once played, the card becomes the player and stops behaving like a button. */
.story.is-playing { cursor: default; border-color: var(--primary); transform: none; }
.story.is-playing:hover { transform: none; box-shadow: none; }
.story-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.story-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.story-more {
  display: block; text-align: center; margin-top: .9rem;
  font-size: .82rem; color: var(--muted); text-decoration: underline; text-underline-offset: 2px;
}
.story-more:hover { color: var(--primary); }

@media (max-width: 600px) {
  .story-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .story-title { font-size: .72rem; padding: .45rem .5rem .55rem; }
  .story-play { width: 38px; height: 38px; }
  .story-play::after { border-left-width: 12px; border-top-width: 7px; border-bottom-width: 7px; }
}
