/* Inner pages (focus areas, quiz, 404) in the same identity as the stories homepage:
   full-width bands that alternate dark and light, large bold type, gold and green actions. */

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

html {
  scroll-padding-top: calc(80px + env(safe-area-inset-top));
  background: #0b2119;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-width: 320px;
  background: #0b2119;
  color: #ffffff;
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img {
  display: block;
  max-width: 100%;
}

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

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

button,
input {
  font: inherit;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

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

.skip-link {
  position: absolute;
  z-index: 100;
  top: -120px;
  inset-inline-start: 16px;
  padding: 10px 16px;
  border-radius: 10px;
  background: #f2c46b;
  color: #241602;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #f2c46b;
  outline-offset: 3px;
}

[data-tone="light"] a:focus-visible,
[data-tone="light"] button:focus-visible,
[data-tone="light"] [tabindex]:focus-visible {
  outline-color: #0e7054;
}

/* ---------- Tones ---------- */

.tone-forest { background: #0b2119; }
.tone-mint { background: #e9f0ec; }
.tone-deep { background: #094b3a; }
.tone-paper { background: #f4f7f5; }
.tone-green { background: #0e7054; }
.tone-night { background: #07150f; }
.tone-sand { background: #f3e8d6; }

[data-tone="dark"] { color: #ffffff; }
[data-tone="light"] { color: #07150f; }

/* ---------- Header ---------- */

.site-top {
  position: sticky;
  z-index: 50;
  top: 0;
  padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-bars {
  display: flex;
  gap: 4px;
}

.top-bar {
  flex: 1 1 0;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.32);
}

.top-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
  transform: scaleX(0);
  transform-origin: right center;
}

html[dir="ltr"] .top-bar-fill {
  transform-origin: left center;
}

/* Quiz phases: the quiz script marks the bars it shares with the step guide. */
.top-bar.is-complete .top-bar-fill { transform: none; }
.top-bar.is-active .top-bar-fill { transform: none; background: #f2c46b; }

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
}

.top-brand {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.top-brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.top-nav {
  display: none;
}

.top-nav a {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  color: #e6f1ec;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.top-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.top-nav a.is-current {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.round-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.round-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.round-button svg {
  width: 20px;
  height: 20px;
}

.menu-button .icon-close { display: none; }
.menu-button[aria-expanded="true"] .icon-open { display: none; }
.menu-button[aria-expanded="true"] .icon-close { display: block; }

.top-contact {
  display: none;
}

.top-menu {
  padding: 4px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.top-menu[hidden] {
  display: none;
}

.top-menu a {
  min-height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.top-menu a.is-current {
  background: rgba(255, 255, 255, 0.14);
}

.top-menu .top-menu-contact {
  justify-content: center;
  background: #f2c46b;
  color: #241602;
}

/* The assistant button stays out of the way while the phone menu is open. */
.menu-open .kh-fab {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ---------- Bands ---------- */

.band {
  position: relative;
  overflow: hidden;
  /* clip, unlike hidden, keeps sticky children (quiz buttons, step guide) working. */
  overflow: clip;
  padding: 52px 24px;
}

.wrap {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
}

.kicker {
  font-size: 15px;
  font-weight: 700;
}

[data-tone="dark"] .kicker { color: #f2c46b; }
[data-tone="light"] .kicker { color: #8a5a12; }

.band-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.45;
}

.band-text {
  font-size: 19px;
  line-height: 1.95;
}

[data-tone="dark"] .band-text { color: #e6f1ec; }
[data-tone="light"] .band-text { color: #10231c; }

.rule {
  display: block;
  width: 56px;
  height: 5px;
  border-radius: 3px;
  background: #b98842;
}

.ghost {
  position: absolute;
  top: -30px;
  inset-inline-end: -18px;
  font-size: 190px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

[data-tone="dark"] .ghost { color: rgba(255, 255, 255, 0.12); }
[data-tone="light"] .ghost { color: rgba(14, 112, 84, 0.10); }

.breadcrumb {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: #cfe3da;
  font-size: 14px;
  font-weight: 600;
}

.breadcrumb a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-underline-offset: 4px;
}

/* ---------- Buttons ---------- */

.btn {
  min-height: 56px;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-gold { background: #f2c46b; color: #241602; }
.btn-gold:hover:not(:disabled) { background: #f6d38c; }
.btn-green { background: #0e7054; color: #ffffff; }
.btn-green:hover:not(:disabled) { background: #0b5e46; }
.btn-outline { border: 2px solid rgba(255, 255, 255, 0.6); background: transparent; color: #ffffff; }
.btn-outline:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.btn-outline-ink { border: 2px solid #07150f; background: transparent; color: #07150f; }
.btn-outline-ink:hover:not(:disabled) { background: rgba(7, 21, 15, 0.06); }

/* ---------- Footer ---------- */

.site-foot {
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.foot-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.foot-brand {
  align-self: flex-start;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.3;
}

.foot-quote {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.7;
}

.foot-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.foot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #42564d;
  font-size: 14px;
  font-weight: 600;
}

.back-to-top {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #07150f;
  font-weight: 700;
}

/* ---------- Focus area page ---------- */

.domain-hero {
  padding-top: 36px;
  padding-bottom: 56px;
}

.domain-hero-layout {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.domain-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.domain-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: #f2c46b;
  font-size: 15px;
  font-weight: 700;
}

.domain-title {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.35;
}

.domain-intro {
  color: #e6f1ec;
  font-size: 19px;
  line-height: 1.95;
}

.topic-panel {
  display: none;
}

.topic-number {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}

.domain-stats {
  padding-top: 48px;
  padding-bottom: 48px;
}

.stats-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat-item {
  padding: 22px 0;
  border-top: 1px solid rgba(7, 21, 15, 0.14);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.stat-item:last-child {
  padding-bottom: 0;
}

.stat-number {
  align-self: flex-start;
  color: #0e7054;
  font-size: 15px;
  font-weight: 800;
}

.stat-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.5;
}

.stat-text {
  color: #10231c;
  font-size: 17px;
  line-height: 1.85;
}

.topics-band {
  padding-bottom: 56px;
}

.topics-band .band-title {
  margin: 4px 0 18px;
}

.topic-list {
  display: flex;
  flex-direction: column;
}

.topic-row {
  min-height: 64px;
  padding: 10px 0;
  border-top: 1px solid rgba(7, 21, 15, 0.14);
  display: flex;
  align-items: center;
  gap: 14px;
  color: #07150f;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.topic-row:last-child {
  border-bottom: 1px solid rgba(7, 21, 15, 0.14);
}

.topic-row .topic-number {
  background: #0e7054;
  color: #ffffff;
}

.topic-row-label {
  flex: 1 1 auto;
}

.topic-arrow {
  color: #0e7054;
  font-size: 20px;
}

.domain-section {
  padding-top: 56px;
  padding-bottom: 56px;
}

.section-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-number {
  position: absolute;
  top: -82px;
  inset-inline-end: -32px;
  font-size: 150px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

[data-tone="dark"] .section-number { color: rgba(255, 255, 255, 0.12); }
[data-tone="light"] .section-number { color: rgba(14, 112, 84, 0.10); }

.section-count {
  position: relative;
  align-self: flex-start;
  font-size: 15px;
  font-weight: 700;
}

[data-tone="dark"] .section-count { color: #f2c46b; }
[data-tone="light"] .section-count { color: #8a5a12; }
.tone-green .section-count { color: #ffffff; }

.section-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.45;
}

.tone-green .band-text { color: #f4fbf8; }

.domain-section.is-conclusion .band-text {
  font-size: 21px;
  font-weight: 600;
}

.related-band {
  padding-top: 56px;
  padding-bottom: 56px;
}

.related-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.related-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.related-grid {
  display: flex;
  flex-direction: column;
}

.related-card {
  position: relative;
  overflow: hidden;
  min-height: 72px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "code copy arrow";
  align-items: center;
  column-gap: 14px;
  color: #ffffff;
  text-decoration: none;
}

.related-code {
  grid-area: code;
  width: 52px;
  height: 52px;
  border: 1px solid #2f5a48;
  border-radius: 14px;
  background: #10271e;
  color: #7fddb9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
}

.related-code.is-warm {
  color: #f2c46b;
}

.related-copy {
  grid-area: copy;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related-eyebrow {
  display: none;
  align-self: flex-start;
  color: #a9c9bb;
  font-size: 15px;
  font-weight: 600;
}

.related-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}

.related-arrow {
  grid-area: arrow;
  position: relative;
  color: #7fddb9;
  font-size: 20px;
}

.related-pill {
  align-self: flex-start;
  padding: 2px 12px;
  border-radius: 999px;
  background: #f2c46b;
  color: #241602;
  font-size: 14px;
  font-weight: 700;
}

.related-ghost {
  display: none;
}

.related-card.is-next {
  margin-bottom: 8px;
  padding: 22px 22px 20px;
  border-bottom: 0;
  border-radius: 24px;
  background: #0e7054;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "copy arrow";
  align-items: end;
}

.related-card.is-next .related-code {
  display: none;
}

.related-card.is-next .related-ghost {
  position: absolute;
  top: -18px;
  inset-inline-end: -6px;
  display: block;
  color: rgba(255, 255, 255, 0.14);
  font-size: 110px;
  font-weight: 800;
  line-height: 1;
}

.related-card.is-next .related-eyebrow {
  display: block;
  color: #cdeee1;
}

.related-card.is-next .related-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.4;
}

.related-card.is-next .related-arrow {
  color: #ffffff;
  font-size: 24px;
}

.related-back {
  width: 100%;
}

/* ---------- 404 ---------- */

.error-band {
  min-height: calc(100vh - 140px);
  min-height: calc(100svh - 140px);
  display: flex;
  align-items: center;
}

.error-layout {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.error-layout .btn {
  margin-top: 8px;
}

/* ---------- Larger screens ---------- */

@media (min-width: 900px) {
  html { scroll-padding-top: 104px; }

  .site-top {
    padding-inline: clamp(16px, 3vw, 28px);
    gap: 12px;
  }

  .top-brand { font-size: 16px; }
  .top-brand img { width: 38px; height: 38px; }
  .top-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .menu-button { display: none; }
  .top-menu,
  .top-menu[hidden] { display: none; }

  .top-contact {
    min-height: 44px;
    padding: 0 20px;
    border-radius: 14px;
    background: #f2c46b;
    color: #241602;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
  }

  .top-contact:hover { background: #f6d38c; }

  .band {
    padding: clamp(56px, 6vw, 96px) clamp(24px, 5vw, 64px);
  }

  .kicker { font-size: 16px; }
  .band-title { font-size: clamp(30px, 3.4vw, 48px); line-height: 1.4; }
  .band-text { font-size: clamp(19px, 1.6vw, 23px); }
  .rule { width: 64px; }
  .ghost { top: -40px; inset-inline-end: -30px; font-size: clamp(190px, 24vw, 360px); }
  .breadcrumb { font-size: 15px; }

  .domain-hero { padding-top: clamp(48px, 6vw, 88px); padding-bottom: clamp(48px, 6vw, 96px); }

  .domain-hero-layout {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 40px 56px;
  }

  .domain-hero-copy { flex: 999 1 560px; min-width: 0; gap: 18px; }
  .domain-meta { font-size: 17px; }
  .domain-title { font-size: clamp(42px, 6vw, 80px); line-height: 1.25; }
  .domain-intro { max-width: 760px; font-size: clamp(19px, 1.7vw, 24px); line-height: 1.9; }

  .topic-panel {
    flex: 1 1 320px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .topic-panel-label {
    margin-bottom: 6px;
    color: #7fddb9;
    font-size: 15px;
    font-weight: 700;
  }

  .topic-panel a {
    min-height: 56px;
    padding: 0 8px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
    text-decoration: none;
  }

  .topic-panel a:hover { background: rgba(255, 255, 255, 0.06); }

  .topic-panel .topic-number {
    width: 38px;
    height: 38px;
    border: 1px solid #2f5a48;
    background: #10271e;
    color: #7fddb9;
    font-size: 14px;
  }

  .topic-panel a.is-current .topic-number {
    border-color: #f2c46b;
    background: #f2c46b;
    color: #241602;
  }

  .domain-stats { padding-top: clamp(40px, 5vw, 72px); padding-bottom: clamp(40px, 5vw, 72px); }

  .stats-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px 40px;
  }

  .stat-item,
  .stat-item:first-child,
  .stat-item:last-child {
    padding: 18px 0 0;
    border-top: 3px solid #0e7054;
    gap: 8px;
  }

  .stat-title { font-size: clamp(22px, 2vw, 28px); line-height: 1.45; }
  .stat-text { font-size: 18px; }

  .topics-band { display: none; }

  .domain-section { padding-top: clamp(48px, 6vw, 96px); padding-bottom: clamp(48px, 6vw, 96px); }

  .section-layout {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 56px;
  }

  .section-side { flex: 1 1 240px; gap: 4px; }

  .section-number {
    position: static;
    align-self: flex-start;
    font-size: clamp(80px, 9vw, 150px);
  }

  [data-tone="dark"] .section-number { color: rgba(255, 255, 255, 0.16); }
  [data-tone="light"] .section-number { color: rgba(14, 112, 84, 0.16); }
  .section-count { font-size: 16px; }
  .domain-section.is-conclusion .section-side { gap: 14px; }

  .section-body { flex: 999 1 560px; min-width: 0; max-width: 820px; gap: 16px; }
  .section-title { font-size: clamp(30px, 3.4vw, 48px); line-height: 1.4; }
  .domain-section.is-conclusion .band-text { font-size: clamp(21px, 1.9vw, 27px); line-height: 1.9; }

  .related-band { padding-top: clamp(48px, 6vw, 96px); padding-bottom: clamp(48px, 6vw, 96px); }
  .related-layout { gap: 28px; }

  .related-head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 48px;
  }

  .related-head-copy { display: flex; flex-direction: column; gap: 10px; }
  .related-head .band-text { max-width: 520px; font-size: 18px; line-height: 1.9; }

  .related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
  }

  .related-card,
  .related-card.is-next {
    min-height: 200px;
    margin: 0;
    padding: 24px;
    border: 1px solid #2f5a48;
    border-radius: 24px;
    background: #10271e;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "code code" "copy arrow";
    align-content: space-between;
    align-items: end;
    row-gap: 16px;
  }

  .related-card:hover { border-color: #7fddb9; }

  .related-card.is-next {
    border-color: #0e7054;
    background: #0e7054;
    grid-template-areas: "copy arrow";
    align-content: end;
  }

  .related-card.is-next:hover { border-color: #f2c46b; }

  .related-code {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #0b2119;
    font-size: 18px;
  }

  .related-eyebrow { display: block; }
  .related-title { font-size: 22px; font-weight: 800; line-height: 1.4; }
  .related-card.is-next .related-title { font-size: 24px; }

  .related-back { width: auto; align-self: flex-start; padding: 0 28px; }

  .site-foot { padding-bottom: clamp(40px, 5vw, 72px); }

  .foot-layout {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px 48px;
  }

  .foot-copy { display: flex; flex-direction: column; gap: 8px; }
  .foot-brand { font-size: clamp(30px, 3vw, 40px); }
  .foot-quote { font-size: clamp(22px, 2vw, 28px); line-height: 1.6; }

  .foot-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
  }

  .foot-actions .btn { padding: 0 28px; }

  .error-layout .btn { align-self: flex-start; padding: 0 28px; }
}

@media (max-height: 640px) and (max-width: 899px) {
  .domain-title { font-size: 36px; }
}

@media print {
  .site-top,
  .topics-band,
  .related-band {
    display: none;
  }

  .band {
    background: #ffffff !important;
    color: #000000 !important;
  }
}
