/* Khutwa — base styles
   Palette: sea-glass background, white paper, deep teal ink.
   Hip = teal, knee = indigo, today/milestone = amber. */

:root {
  --bg: #eef4f2;
  --paper: #ffffff;
  --ink: #16302f;
  --muted: #5a6c6b;
  --line: #d3e0dd;
  --teal: #1f5f63;
  --teal-dark: #174a4d;
  --hip: #3f9a94;
  --knee: #5b6fb0;
  --amber: #c98a2b;
  --amber-soft: #fbf1dd;
  --danger: #a33d2a;
  --radius: 14px;
  --font-latin: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 18px;
  line-height: 1.55;
}
html[dir="rtl"] body { font-family: var(--font-arabic); }

a { color: var(--teal); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

/* ----- header ----- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  max-width: 680px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: var(--teal-dark);
}
.brand .brand-ar { font-family: var(--font-arabic); font-weight: 600; font-size: 1.35rem; }
.brand .brand-en { font-weight: 500; font-size: 1rem; letter-spacing: .01em; color: var(--muted); }
.lang-toggle {
  border: 1.5px solid var(--teal);
  background: transparent;
  color: var(--teal);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
}
.lang-toggle:hover { background: var(--teal); color: #fff; }

/* ----- nav ----- */
.site-nav {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .95rem;
  white-space: nowrap;
}
.site-nav a[aria-current="page"] { background: var(--paper); color: var(--teal-dark); font-weight: 600; }

/* ----- layout ----- */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px 72px;
}
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 1.3rem; line-height: 1.25; margin: 32px 0 10px; font-weight: 600; }
h3 { font-size: 1.1rem; margin: 0 0 6px; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 14px;
}

/* ----- home hero ----- */
.hero { padding: 24px 0 8px; }
.hero .greeting-ar {
  font-family: var(--font-arabic);
  font-size: 2.3rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--teal-dark);
  margin: 0 0 4px;
}
.hero .greeting-en {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0 0 22px;
}
.hero .invite {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 16px;
}

/* ----- the step form ----- */
.joint-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
}
.joint-choice input { position: absolute; opacity: 0; pointer-events: none; }
.joint-choice label {
  display: block;
  text-align: center;
  padding: 16px 10px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1rem;
}
.joint-choice input:focus-visible + label { outline: 3px solid var(--amber); outline-offset: 2px; }
.joint-choice input[value="hip"]:checked + label { border-color: var(--hip); color: var(--hip); background: #eaf5f4; }
.joint-choice input[value="knee"]:checked + label { border-color: var(--knee); color: var(--knee); background: #eef0f8; }

.field { margin: 0 0 16px; }
.field label { display: block; font-weight: 600; margin: 0 0 6px; }
.field .hint { color: var(--muted); font-size: .95rem; margin: 6px 0 0; }
input[type="date"] {
  width: 100%;
  font: inherit;
  font-size: 1.2rem;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  min-height: 56px;
}

.btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  background: var(--teal);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 16px 20px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--teal-dark); }
.btn-secondary {
  background: transparent;
  color: var(--teal);
  border: 2px solid var(--teal);
}
.btn-secondary:hover { background: #e6f0ef; }
.btn-row { display: grid; gap: 10px; margin-top: 12px; }

.error { color: var(--danger); font-weight: 500; margin: 8px 0 0; display: none; }
.error.show { display: block; }

.privacy-note {
  font-size: .95rem;
  color: var(--muted);
  margin-top: 20px;
}

/* ----- plan page ----- */
.today {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px 16px;
  margin-bottom: 14px;
}
.today .day-count {
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--teal-dark);
  margin: 0;
}
.today .phase-name { font-size: 1.2rem; font-weight: 600; margin: 6px 0 2px; }
.today .phase-span { color: var(--muted); margin: 0 0 14px; }
.joint-pill {
  display: inline-block;
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 10px;
}
.joint-pill.hip { background: var(--hip); }
.joint-pill.knee { background: var(--knee); }

/* the path of steps — weeks since surgery */
.path { margin: 8px 0 4px; }
.path-track {
  position: relative;
  height: 44px;
}
.path-line {
  position: absolute;
  inset-inline: 0;
  top: 21px;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
.path-fill {
  position: absolute;
  inset-inline-start: 0;
  top: 21px;
  height: 3px;
  background: var(--teal);
  border-radius: 2px;
}
.path-mark {
  position: absolute;
  top: 14px;
  width: 16px;
  height: 16px;
  margin-inline-start: -8px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--line);
}
.path-mark.done { border-color: var(--teal); background: var(--teal); }
.path-mark.now {
  top: 10px;
  width: 24px;
  height: 24px;
  margin-inline-start: -12px;
  border-color: var(--amber);
  background: var(--amber);
}
.path-labels {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--muted);
  margin-top: 2px;
}

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.checklist li:first-child { border-top: 0; }
.checklist .dot {
  flex: 0 0 10px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--teal);
  margin-top: 10px;
}

.milestones { list-style: none; padding: 0; margin: 0; }
.milestones li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.milestones li:first-child { border-top: 0; }
.milestones .when { color: var(--muted); font-size: .95rem; white-space: nowrap; }
.milestones li.passed { color: var(--muted); }
.milestones li.passed .when { color: var(--hip); }
.milestones li.next { background: var(--amber-soft); margin: 0 -18px; padding-inline: 18px; border-radius: 8px; }

.warn {
  background: var(--amber-soft);
  border-inline-start: 4px solid var(--amber);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
}

.links-grid { display: grid; gap: 10px; margin-top: 10px; }
.link-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.link-card strong { display: block; color: var(--teal-dark); }
.link-card span { color: var(--muted); font-size: .95rem; }

/* ----- exercises page ----- */
.joint-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 12px;
}
.joint-btn {
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}
.joint-btn.hip.active { border-color: var(--hip); color: var(--hip); background: #eaf5f4; }
.joint-btn.knee.active { border-color: var(--knee); color: var(--knee); background: #eef0f8; }

.phase-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 16px;
  padding: 4px 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.phase-tabs::-webkit-scrollbar { display: none; }
.phase-tab {
  flex: 0 0 auto;
  font: inherit;
  font-size: .95rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.phase-tab.active { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }

.exercise {
  background: var(--paper);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--hip);
  border-radius: var(--radius);
  margin: 0 0 14px;
  overflow: hidden;
}
.exercise.knee { border-inline-start-color: var(--knee); }
.ex-figure {
  margin: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.ex-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
}
.ex-body { padding: 14px 16px 12px; }
.ex-body h3 { font-size: 1.15rem; margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; }
.ex-code {
  flex: 0 0 auto;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
}
.ex-body p { margin: 0 0 8px; }
.ex-tag {
  display: inline-block;
  font-size: .85rem;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 1px 10px;
}
.ex-dose { color: var(--teal-dark); font-weight: 600; font-size: .95rem; }
.ex-why { color: var(--muted); font-size: .95rem; font-style: italic; }
html[dir="rtl"] .ex-why { font-style: normal; }
.ex-flag { color: var(--danger); font-size: .95rem; }
.note-card { margin-top: 24px; }

@media (min-width: 560px) {
  .exercise { display: grid; grid-template-columns: 220px 1fr; }
  .ex-figure { border-bottom: 0; border-inline-end: 1px solid var(--line); display: flex; align-items: center; }
  .ex-figure img { max-height: none; }
}

/* ----- content pages (daily life, questions, week by week, about) ----- */
.content-page h2 {
  margin: 36px 0 10px;
  padding-top: 12px;
  border-top: 2px solid var(--teal);
}
.content-page p, .content-page ul { max-width: 62ch; }
.content-page ul { padding-inline-start: 20px; margin: 0 0 12px; }
.content-page li { margin-bottom: 5px; }
.content-page .lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 22px; }
.pair { display: grid; gap: 12px; margin: 12px 0 18px; }
.content-page .card.hip { background: #e8f1ef; border-inline-start: 4px solid var(--hip); }
.content-page .card.knee { background: #eef0f7; border-inline-start: 4px solid var(--knee); }
.content-page .card p, .content-page .card ul { max-width: none; }
.content-page .card p:last-child, .content-page .card ul:last-child { margin-bottom: 0; }
.unlock {
  display: inline-block;
  font-size: .82rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  margin: 0 0 8px;
  color: var(--muted);
}
.note {
  background: var(--amber-soft);
  border-inline-start: 4px solid var(--amber);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 14px 0;
}
.flag {
  background: #fbe9e4;
  border-inline-start: 4px solid #e0a08f;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 14px 0;
}
.flag strong { display: block; margin-bottom: 4px; }
.tag {
  display: inline-block;
  font-size: .72rem;
  border-radius: 999px;
  padding: 1px 8px;
  margin-inline-start: 6px;
  vertical-align: middle;
  color: #fff;
  font-weight: 500;
}
.tag.hip { background: var(--hip); }
.tag.knee { background: var(--knee); }
.tag.both { background: var(--muted); }
.phase {
  background: var(--paper);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--hip);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.phase h3 { margin-top: 0; }
.phase.current { border-color: var(--amber); border-inline-start-color: var(--amber); background: #fffaf0; }
.you-are-here {
  display: inline-block;
  background: var(--amber);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 8px;
}
.content-page table { border-collapse: collapse; width: 100%; font-size: .95rem; margin: 8px 0 14px; }
.content-page th, .content-page td { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.content-page th { color: var(--muted); font-weight: 600; }
.content-page small { color: var(--muted); }
.lang-block[hidden] { display: none; }
@media (min-width: 600px) { .pair { grid-template-columns: 1fr 1fr; } }

/* ----- footer ----- */
.site-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: .9rem;
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 0 0 6px; }

/* ----- utilities ----- */
.hidden { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .path-fill { transition: width .6s ease; }
}
@media (min-width: 560px) {
  body { font-size: 19px; }
  .btn-row { grid-template-columns: 1fr 1fr; }
}

/* ----- week-by-week: folded stages and jump strip ----- */
.jump-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 8px;
  padding: 6px 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.jump-strip::-webkit-scrollbar { display: none; }
.jump-strip a {
  flex: 0 0 auto;
  text-decoration: none;
  font-size: .9rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  white-space: nowrap;
}
.jump-strip a.stage-link { border-color: var(--teal); color: var(--teal-dark); }
.jump-strip a.stage-link.here { background: var(--amber); border-color: var(--amber); color: #fff; font-weight: 600; }
details.stage {
  background: var(--paper);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--hip);
  border-radius: 8px;
  margin: 0 0 10px;
  scroll-margin-top: 64px;
}
details.stage.current { border-color: var(--amber); border-inline-start-color: var(--amber); background: #fffaf0; }
details.stage summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 1.05rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
details.stage summary::-webkit-details-marker { display: none; }
details.stage summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.3rem; }
details.stage[open] summary::after { content: "–"; }
details.stage summary .you-are-here { margin: 0; margin-inline-start: auto; }
details.stage .phase { border: 0; background: transparent; margin: 0; padding: 0 14px 12px; }
.content-page h2 { scroll-margin-top: 64px; }
.site-footer p:last-child { margin-top: 10px; font-size: .82rem; }
