/* Language switcher and Arabic (right-to-left) refinements.
   rtl.css (generated) mirrors the layout; this file holds the hand-written parts. */

/* ------------------------------------------------------------------ *
 * Arabic typeface. Archivo has no Arabic letters, so Arabic text uses
 * Noto Sans Arabic (self-hosted, SIL Open Font License, see
 * assets/NotoSansArabic-LICENSE.txt). The browser only downloads it when
 * Arabic text is on the page. 'Arabic UI' is a scaled system-font fallback
 * for the moment before it loads, and the label of the switcher in English.
 * ------------------------------------------------------------------ */
@font-face {
  font-family: 'Noto Sans Arabic';
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/noto-sans-arabic.woff2') format('woff2');
  size-adjust: 110%;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Arabic UI';
  font-weight: 400;
  src:
    local('Segoe UI'), local('SegoeUI'), local('SF Arabic'), local('SFArabic-Regular'),
    local('Geeza Pro'), local('GeezaPro'), local('Noto Sans Arabic'),
    local('NotoSansArabic-Regular'), local('Tahoma');
  size-adjust: 112%;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Arabic UI';
  font-weight: 500 700;
  src:
    local('Segoe UI Semibold'), local('SegoeUI-Semibold'), local('Segoe UI Bold'),
    local('SF Arabic Semibold'), local('SFArabic-Semibold'), local('Geeza Pro Bold'),
    local('GeezaPro-Bold'), local('Noto Sans Arabic SemiBold'),
    local('NotoSansArabic-SemiBold'), local('Tahoma Bold'), local('Tahoma-Bold');
  size-adjust: 112%;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

html[dir='rtl'] {
  --font: Archivo, 'Noto Sans Arabic', 'Arabic UI', 'Segoe UI', Tahoma, sans-serif;
}
/* Arabic and Kurdish letters join up; any letter-spacing breaks the words apart. */
html[dir='rtl'] *,
html[dir='rtl'] *::before,
html[dir='rtl'] *::after {
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  font-style: normal;
}
/* Arabic and Kurdish need more vertical room than the tight Latin display lines allow:
   the marks on the letters reach well past the letter body. Kurdish is the tallest: the
   V above ڵ ێ ۆ, and the V and dots below ڕ ی ێ, can reach 1.4 to 1.7 times the font size
   in total, so two stacked lines of display type would touch at the Latin line height.
   `tools/ink-audit.js` measures this (see the README). */
html[lang='ar'] h1,
html[lang='ar'] h2,
html[lang='ar'] h3 {
  line-height: 1.42;
}
html[lang='ckb'] h1,
html[lang='ckb'] h2,
html[lang='ckb'] h3 {
  line-height: 1.55;
}
/* The one heading that carries both ڵ and ڕ in the same sentence ("Dr. Dlbrin explains"). */
html[lang='ckb'] .guide-heading h2,
html[lang='ckb'] #about-title {
  line-height: 1.75;
}
html[lang='ckb'][dir='rtl'] :is(.guide-topic-name, .treatment-index-name) {
  line-height: 1.75;
}
/* Page titles that wrap to two lines on the narrowest phones. */
html[lang='ar'] #results-title,
html[lang='ar'] #testimonials-title,
html[lang='ar'] #treatments-title {
  line-height: 1.6;
}
html[lang='ckb'] #results-title,
html[lang='ckb'] #testimonials-title,
html[lang='ckb'] #treatments-title {
  line-height: 1.75;
}
/* The hospital name on the contact page wraps on the narrowest phones. */
html[dir='rtl'] .contact-visit h3 {
  line-height: 1.65;
}
/* Treatment names that wrap to two lines, and the call to action on the Testimonials page. */
html[lang='ar'] .treatment-description h3 {
  line-height: 1.72;
}
html[lang='ckb'] .treatment-description h3 {
  line-height: 1.72;
}
/* The small line above the hero name: the V on ڵ would touch it on the narrowest phones. */
html[dir='rtl'] .hero-specialty {
  padding-bottom: 6px;
}
/* Smaller stacked text: names in lists, accordions, quotes, captions and notes. */
html[dir='rtl'] :is(.guide-topic-name, .treatment-index-name) {
  line-height: 1.65;
}
html[dir='rtl'] blockquote p {
  line-height: 1.6;
}
html[dir='rtl'] figcaption {
  line-height: 1.85;
}
html[dir='rtl'] .clinical-note {
  line-height: 2.1;
}
/* Final results and ear surgery on the homepage: captions that wrap on narrow phones, and the
   two-line key beside the heading. */
html[dir='rtl'] :is(.finals-caption, .finals-key, .finals-note, .ears-case figcaption, .ears-text, .ears-note, .contact-hours) {
  line-height: 1.95;
}
/* "About Dr. Dlbrin" on the slider card wraps to two lines on the narrowest phones (ڵ). */
html[lang='ckb'] .explore-title {
  line-height: 1.68;
}
/* Testimonials page: the name above its place line, the quote, and the call to action. */
html[dir='rtl'] .testimonial-card blockquote p {
  line-height: 1.75;
}
html[dir='rtl'] .testimonial-card figcaption strong {
  margin-bottom: 3px;
}
html[dir='rtl'] .testimonial-card figcaption span:not(.testimonial-initial),
html[dir='rtl'] .testimonial-note {
  line-height: 2;
}
html[dir='rtl'] .page-cta h2 {
  line-height: 1.65;
}
html[lang='ckb'] .page-cta h2 {
  line-height: 1.8;
}
html[dir='rtl'] .explore-text {
  line-height: 1.95;
}

/* ------------------------------------------------------------------ *
 * Language menu: a button showing the current language, opening a
 * list of English, Arabic and Kurdish.
 * ------------------------------------------------------------------ */
.lang-switch {
  position: relative;
  flex-shrink: 0;
  margin-inline-start: 4px;
}
.lang-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.lang-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 11px;
  background: #eef4ed;
  border: 1px solid #9db5a5;
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.lang-trigger:hover {
  background: #e2ece0;
  border-color: #7f9d8a;
}
.lang-switch.is-open .lang-trigger {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #5b765126;
}
.lang-trigger:focus-visible,
.lang-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lang-flag {
  display: block;
  width: 20px;
  height: 14px;
  flex: none;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px #00000026;
}
.lang-chevron {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}
.lang-switch.is-open .lang-chevron {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  min-width: 190px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fafbf7;
  border: 1px solid #d3ddd4;
  border-radius: 12px;
  box-shadow: 0 14px 34px #263b3324;
  animation: lang-menu-in 0.16s ease-out;
}
.lang-menu[hidden] {
  display: none;
}
@keyframes lang-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  background: transparent;
  color: #385346;
  font-size: 14px;
  text-align: start;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.lang-option:hover {
  background: #eef4ed;
  color: var(--ink);
}
.lang-option[aria-pressed='true'] {
  background: #e6ecdf;
  color: var(--ink);
  font-weight: 600;
}
.lang-name {
  flex: 1;
}
.lang-option[lang='ar'] .lang-name,
.lang-option[lang='ckb'] .lang-name {
  font-size: 15px;
}
.lang-check {
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.lang-option[aria-pressed='true'] .lang-check {
  opacity: 1;
}
/* In English the Arabic and Kurdish names must not trigger the font download. */
.lang-option[lang='ar'],
.lang-option[lang='ckb'] {
  font-family: Archivo, 'Arabic UI', 'Segoe UI', Tahoma, sans-serif;
}
html[dir='rtl'] .lang-option[lang='ar'],
html[dir='rtl'] .lang-option[lang='ckb'] {
  font-family: var(--font);
}

/* Small laptops, tablets and phones: the button shows only the flag. */
@media (max-width: 1100px) {
  .lang-current {
    display: none;
  }
  .lang-trigger {
    gap: 7px;
    padding: 0 10px;
  }
}
@media (max-width: 850px) {
  .lang-trigger {
    height: 34px;
  }
}
/* Kurdish labels are longer than English ones, so the narrowest tablet header needs
   slightly tighter spacing. */
@media (min-width: 700.02px) and (max-width: 800px) {
  html[lang='ckb'] .site-header {
    gap: 12px;
  }
  html[lang='ckb'] .site-header nav {
    gap: 11px;
  }
  html[lang='ckb'] .site-header .header-book {
    min-width: 0;
    gap: 10px;
  }
}
@media (max-width: 700px) {
  html .site-header .lang-switch {
    margin-inline: auto 0;
    /* The menu lines up with the header's edge, so it stays on screen. */
    position: static;
  }
  .lang-menu {
    top: calc(100% + 8px);
  }
  html .site-header .header-book {
    margin-inline: 0;
    min-width: 0;
    gap: 9px;
  }
  .lang-trigger {
    height: 32px;
    gap: 6px;
    padding: 0 8px;
    border-radius: 7px;
  }
  .lang-trigger .lang-flag {
    width: 18px;
    height: 12px;
  }
}

/* ------------------------------------------------------------------ *
 * Right-to-left adjustments that cannot be generated
 * ------------------------------------------------------------------ */
/* Arrows point the other way when the page reads right to left. */
html[dir='rtl'] .icon-arrow {
  scale: -1 1;
}
/* Phone numbers and handles always read left to right. */
bdi[dir='ltr'] {
  unicode-bidi: isolate;
}
/* Counters such as "01 / 05" keep the order the design shows. */
#treatment-count,
#case-count,
#dialog-count,
#journey-counter,
#guide-video-number,
#explore-count,
.finals-count,
.finals-viewer-count {
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}
/* The offset outline behind the portrait leans the other way. */
html[dir='rtl'] .portrait-shell:before {
  transform: rotate(2deg);
}

/* ------------------------------------------------------------------ *
 * Phone header: the logo, language button, Contact button and menu
 * button share one very narrow row, and Arabic and Kurdish text is wider
 * than English, so the spacing is tightened in steps.
 * ------------------------------------------------------------------ */
@media (max-width: 700px) {
  html .site-header {
    gap: 9px;
  }
  html .site-header .header-book {
    flex-shrink: 0;
    gap: 8px;
    padding: 10px;
  }
  html .site-header .menu-toggle {
    margin-inline: 0;
  }
  html[dir='rtl'] .site-header .wordmark {
    font-size: 21px;
  }
}
@media (max-width: 400px) {
  html .site-header {
    gap: 8px;
    padding-inline: 13px;
  }
}
/* On the very narrowest phones the small arrow in the Contact button is dropped. */
@media (max-width: 340px) {
  html .site-header .header-book > span {
    display: none;
  }
  html .site-header .wordmark {
    font-size: 19px;
  }
  html[dir='rtl'] .site-header .wordmark {
    font-size: 18px;
  }
}

/* ------------------------------------------------------------------ *
 * Line breaking for Arabic and Kurdish: balanced headings and labels, and
 * stranded words are avoided too.
 * ------------------------------------------------------------------ */
html[dir='rtl'] :is(h1, h2, h3, .treatment-index-name, .guide-topic-name, .case-choice > span, .folio-label, .journey-origin h3) {
  text-wrap: balance;
}
/* No single stranded word at the end of a paragraph, in any language. */
:is(p, address, figcaption, blockquote, .guide-topic-copy, .treatment-copy, .clinical-note) {
  text-wrap: pretty;
}

/* The Kurdish patient-stories heading is longer than the English one, so it is set a
   little smaller where the column is narrow. */
@media (max-width: 1100px) {
  html[lang='ckb'] .journey-copy h2 {
    font-size: 38px;
  }
}
@media (max-width: 700px) {
  html[lang='ckb'] .journey-copy h2 {
    font-size: 34px;
  }
}
@media (max-width: 370px) {
  html[lang='ckb'] .journey-copy h2 {
    font-size: 30px;
  }
}

/* The quote cards on the Testimonials thumbnail. */
html[dir='rtl'] .explore-note-text {
  line-height: 1.6;
}
html[lang='ckb'] .explore-note-text {
  line-height: 1.8;
}
html[dir='rtl'] .explore-note-by {
  line-height: 1.9;
}

/* The small count under a gallery group name ("4 types") needs room for the marks above it. */
html[dir='rtl'] .case-group-meta {
  line-height: 1.9;
}

/* Before and after slider, right to left. The slider is mirrored so it reads the way the page
   does: "Before" on the right and "After" on the left, in the same order as the Show before /
   Show after buttons under it. --split is still the share of the photograph that shows the
   BEFORE image, but it is measured from the right edge. The invisible range control on top
   uses the page direction as well (its minimum is on the right), so touch, mouse and keyboard
   all move the divider the same way the finger or key points. app.js measures the pointer
   from the right edge in this case. */
html[dir='rtl'] .after-image {
  clip-path: inset(0 var(--split) 0 0);
}
html[dir='rtl'] .comparison-divider {
  left: auto;
  right: var(--split);
}
html[dir='rtl'] .before-label {
  left: auto;
  right: 20px;
}
html[dir='rtl'] .after-label {
  right: auto;
  left: 20px;
}
html[dir='rtl'] .enlarge-button {
  right: auto;
  left: 18px;
}
@media (max-width: 650px) {
  html[dir='rtl'] .before-label {
    right: 11px;
  }
  html[dir='rtl'] .after-label {
    left: 11px;
  }
  html[dir='rtl'] .enlarge-button {
    left: 10px;
  }
}

/* Phone menu: the short underline of the active link starts at the start of the text, which
   is the right-hand edge in Arabic and Kurdish. (The generated mirror left both sides "auto",
   which put the line in the middle of the row.) */
@media (max-width: 700px) {
  html[dir='rtl'] .site-header nav a:after {
    left: auto;
    right: 0;
    transform-origin: right;
  }
}

/* ------------------------------------------------------------------ *
 * Phones: small print that was too small to read, and tap areas that
 * were too small for a finger. Only the items an audit found are changed.
 * Tap areas grow with an invisible ::before, so nothing moves or looks
 * different; the 10 to 11px section labels keep their size on purpose.
 * ------------------------------------------------------------------ */
@media (max-width: 700px) {
  /* Text under 10px that carries information. */
  .hero-phone small,
  .enlarge-button span,
  #case-count,
  .clinical-note,
  .footer-bottom,
  .footer-bottom a,
  .contact-footer,
  .contact-footer a,
  .swipe-hint,
  #treatment-count {
    font-size: 11px;
  }
  .hero-portrait figcaption,
  .globe-figure figcaption,
  .globe-figure figcaption span,
  .treatment-study figcaption,
  .treatment-study figcaption span,
  .treatment-index-number {
    font-size: 10px;
  }
  /* The small buttons named in the audit: from 10px to 11px. */
  .header-book,
  .hero-actions .solid-button,
  .hero-comparison-link,
  .view-buttons button,
  .view-buttons span {
    font-size: 11px;
    white-space: nowrap;
  }
  /* Arabic and Kurdish letters are smaller than Latin ones at the same size. */
  html[dir='rtl'] :is(.hero-phone small, .enlarge-button span, .clinical-note, .swipe-hint,
      .hero-actions .solid-button, .hero-comparison-link, .view-buttons button) {
    font-size: 12px;
  }
  html[dir='rtl'] :is(.hero-portrait figcaption, .globe-figure figcaption span, .treatment-study figcaption) {
    font-size: 11px;
  }

  /* Larger tap areas. */
  .wordmark,
  .lang-trigger,
  .menu-toggle,
  .view-buttons button,
  .case-navigation button,
  #guide-source,
  #journey-source,
  .footer-bottom a,
  .footer-whatsapp,
  .footer-address a,
  .contact-footer a,
  .back-link,
  .treatment-contact {
    position: relative;
  }
  /* :where keeps this rule at zero specificity, so the sizes below can adjust it. */
  :where(.wordmark, .lang-trigger, .menu-toggle, .view-buttons button, .case-navigation button,
      .enlarge-button, #guide-source, #journey-source, .footer-bottom a, .footer-whatsapp,
      .footer-address a, .contact-footer a, .back-link, .treatment-contact)::before {
    content: '';
    position: absolute;
    inset-block: -9px;
    inset-inline: -4px;
  }
  /* Short items need more height; the gallery arrows sit 11px from the photo. */
  :is(.footer-bottom a, .contact-footer a)::before {
    inset-block: -15px;
  }
  .case-navigation button::before {
    inset-block: -5px;
    inset-inline: -6px;
  }
  .menu-toggle::before,
  .lang-trigger::before {
    inset-block: -6px;
  }
  .wordmark::before,
  .back-link::before {
    inset-block: -11px;
  }
  .enlarge-button::before {
    inset: -8px;
  }
}

/* The longer Arabic video descriptions need a little more line room so their marks never touch. */
html[lang='ar'] .guide-topic-copy {
  line-height: 1.95;
}
