/*
 * These pages are plain HTML served from public/, so they cannot import the
 * SPA's stylesheet. The tokens below therefore mirror src/index.css by hand:
 * change one and change the other, or the legal pages drift out of the design
 * system again. The fonts are self-hosted for the same reason the SPA
 * self-hosts them: no third-party font origin, and no CSP exception for one.
 */
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/CormorantGaramond-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Kufam';
  src: url('/fonts/Kufam-Regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Kufam';
  src: url('/fonts/Kufam-SemiBold.woff2') format('woff2');
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
}

:root {
  --mosaic: #12333d;
  --mosaic-deep: #0b2831;
  --smalt: #507c8b;
  --bright-grey: #ebedf0;
  --brandy: #e4ca78;
  --paper: #f7f6f2;
  --white: #ffffff;
  --ink: #102d36;
  --muted: #5e6e73;
  --line: color-mix(in srgb, var(--mosaic) 16%, transparent);
  --line-dark: rgba(255, 255, 255, 0.16);

  --font-body: 'Avenir Next', Avenir, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-arabic: -apple-system, BlinkMacSystemFont, 'Geeza Pro', 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-arabic-display: 'Kufam', var(--font-arabic);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;
  --space-9: 3.5rem;
  --space-10: 4rem;
  --space-11: 5rem;

  /* See the same token in src/index.css for why headings reserve this. */
  --display-em-box: 1.21;
  --space-heading-body: var(--space-4);
  --space-content-group: var(--space-8);

  --content: min(
    82rem,
    calc(100vw - 3rem - env(safe-area-inset-left) - env(safe-area-inset-right))
  );
  --reading: 44rem;

  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

html {
  min-width: 20rem;
  min-height: 100%;
  background: var(--mosaic-deep);
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 20rem;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
}

::selection {
  background: var(--brandy);
  color: var(--mosaic-deep);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--mosaic);
  outline-offset: 3px;
}

.site-footer a:focus-visible,
.site-footer button:focus-visible {
  outline-color: var(--brandy);
}

@media (forced-colors: active) {
  a:focus-visible,
  button:focus-visible {
    outline-color: Highlight;
  }
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: 999px;
  background: var(--brandy);
  color: var(--mosaic-deep);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  overflow: clip;
  background: var(--paper);
}

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

.site-nav {
  position: sticky;
  z-index: 40;
  inset-block-start: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-6);
  width: var(--content);
  min-height: 6rem;
  margin-inline: auto;
  border-block-end: 1px solid var(--line);
  background: var(--paper);
  color: var(--mosaic);
  direction: ltr;
}

.site-nav__brand {
  display: inline-flex;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  direction: ltr;
}

.brand-mark__wordmark {
  width: 4.5rem;
  height: auto;
  object-fit: contain;
}

.site-nav__links {
  display: flex;
  justify-content: center;
  gap: clamp(var(--space-5), 2.4vw, var(--space-7));
  font-size: 0.82rem;
}

.site-nav__links a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 180ms ease;
}

.site-nav__links a:hover,
.site-nav__links a[aria-current='page'] {
  color: var(--mosaic);
}

.site-nav__links a[aria-current='page'] {
  font-weight: 700;
}

.site-nav__actions {
  --header-control-height: 3.2rem;
  display: flex;
  align-items: center;
  justify-content: end;
  gap: var(--space-3);
  direction: ltr;
}

.lang-toggle {
  display: inline-flex;
  height: var(--header-control-height);
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  direction: ltr;
}

.lang-toggle__btn {
  min-width: 2.75rem;
  height: 100%;
  padding-inline: var(--space-2);
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

/* Not on the active button: its ground is already --mosaic. */
.lang-toggle__btn:hover:not(.lang-toggle__btn--active) {
  color: var(--mosaic);
}

.lang-toggle__btn--active {
  background: var(--mosaic);
  color: var(--bright-grey);
}

.nav-cta {
  display: inline-flex;
  height: var(--header-control-height);
  min-inline-size: 11.5rem;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding-inline: var(--space-4);
  border: 0;
  border-radius: 999px;
  background: var(--brandy);
  color: var(--mosaic-deep);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 180ms ease;
}

.nav-cta:hover {
  background: #f0d98d;
}

.nav-cta svg {
  width: 0.8rem;
  height: 1rem;
  flex: 0 0 auto;
}

/* Page head --------------------------------------------------------------- */

.page-main {
  flex: 1 0 auto;
}

.page-main:focus {
  outline: none;
}

.page-hero {
  width: var(--content);
  margin-inline: auto;
  padding-block: clamp(var(--space-9), 7vw, var(--space-11)) 0;
  text-align: start;
}

.page-title {
  max-width: 20ch;
  margin: 0;
  color: var(--mosaic);
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 6vw, 5.25rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  text-wrap: balance;
  --display-leading: 0.95;
  line-height: var(--display-leading);
  padding-block-end: calc((var(--display-em-box) - var(--display-leading)) / 2 * 1em);
}

.page-meta,
.page-lead {
  max-width: var(--reading);
  margin-block: var(--space-heading-body) 0;
  color: var(--muted);
}

.page-meta {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums lining-nums;
}

.page-lead {
  font-size: 1.05rem;
  line-height: 1.7;
  text-wrap: pretty;
}

/* Long-form legal copy ---------------------------------------------------- */

.legal-document {
  width: var(--content);
  margin-inline: auto;
  padding-block: var(--space-content-group) clamp(var(--space-10), 9vw, var(--space-11));
  overflow-wrap: break-word;
  text-align: start;
  border-block-start: 1px solid var(--line);
  margin-block-start: var(--space-content-group);
}

.legal-document > * {
  max-width: var(--reading);
}

.legal-document[lang='ar'] {
  font-family: var(--font-arabic);
}

.legal-document h2 {
  --display-leading: 1.1;
  scroll-margin-block-start: 8rem;
  margin: var(--space-8) 0 var(--space-heading-body);
  color: var(--mosaic);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2.6vw, 2.25rem);
  font-weight: 400;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.02em;
  line-height: var(--display-leading);
  padding-block-end: calc((var(--display-em-box) - var(--display-leading)) / 2 * 1em);
  text-wrap: balance;
}

.legal-document > *:first-child {
  margin-block-start: 0;
}

.legal-document p,
.legal-document ul,
.legal-document ol {
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.8;
}

.legal-document ul,
.legal-document ol {
  padding-inline-start: var(--space-5);
}

.legal-document li {
  margin-block-end: var(--space-2);
  padding-inline-start: var(--space-1);
}

.legal-document strong {
  color: var(--mosaic);
  font-weight: 650;
}

.legal-document a,
.support-card a:not(.support-button),
.support-legal-links a {
  color: var(--mosaic);
  text-decoration-line: underline;
  text-decoration-color: var(--smalt);
  text-decoration-thickness: from-font;
  text-underline-offset: 0.18em;
  transition: text-decoration-color 180ms ease;
}

.legal-document a:hover,
.support-card a:not(.support-button):hover,
.support-legal-links a:hover {
  text-decoration-color: currentColor;
}

/* Support ----------------------------------------------------------------- */

.support-wrap {
  width: var(--content);
  margin-inline: auto;
  padding-block: var(--space-content-group) clamp(var(--space-10), 9vw, var(--space-11));
  margin-block-start: var(--space-content-group);
  border-block-start: 1px solid var(--line);
  text-align: start;
}

.support-card {
  max-width: 46rem;
  padding: clamp(var(--space-6), 5vw, var(--space-9));
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--white);
}

.support-card__icon {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 0 var(--space-6);
  place-items: center;
  border-radius: 50%;
  background: var(--mosaic);
  color: var(--bright-grey);
}

.support-card__icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.support-card h2 {
  --display-leading: 1.05;
  margin: 0;
  color: var(--mosaic);
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 2.6vw, 2.35rem);
  font-weight: 400;
  line-height: var(--display-leading);
  padding-block-end: calc((var(--display-em-box) - var(--display-leading)) / 2 * 1em);
  text-wrap: balance;
}

.support-card p {
  max-width: 34rem;
  margin: var(--space-heading-body) 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.8;
  text-wrap: pretty;
}

.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-block-start: var(--space-6);
}

.support-button {
  display: inline-flex;
  min-height: 3.4rem;
  align-items: center;
  justify-content: center;
  padding-inline: var(--space-5);
  border: 0;
  border-radius: 999px;
  background: var(--brandy);
  color: var(--mosaic-deep);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
  transition: background-color 180ms ease;
}

.support-button:hover {
  background: #f0d98d;
}

.support-button--secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mosaic);
}

.support-button--secondary:hover {
  background: color-mix(in srgb, var(--mosaic) 6%, transparent);
}

.support-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin-block-start: var(--space-6);
  font-size: 0.88rem;
}

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

.site-footer {
  display: grid;
  grid-template-areas:
    'brand links'
    'made contact'
    'drawer drawer';
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--space-4) var(--space-8);
  padding-block: var(--space-7) max(var(--space-7), env(safe-area-inset-bottom));
  padding-inline: max(1.5rem, calc((100vw - var(--content)) / 2));
  border-block-start: 1px solid var(--line-dark);
  background: var(--mosaic-deep);
  color: rgba(235, 237, 240, 0.67);
  text-align: start;
}

.site-footer__brand {
  grid-area: brand;
  justify-self: start;
  color: var(--bright-grey);
  text-decoration: none;
}

.site-footer__contact-trigger {
  grid-area: contact;
  justify-self: end;
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  touch-action: manipulation;
}

.site-footer__contact-trigger:hover,
.site-footer__contact-trigger[aria-expanded='true'] {
  color: var(--white);
}

.site-footer__contact-chevron {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.site-footer__contact-trigger[aria-expanded='true'] .site-footer__contact-chevron {
  rotate: 180deg;
}

.site-footer__links {
  grid-area: links;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: end;
  gap: var(--space-2) var(--space-5);
  font-size: 0.76rem;
}

.site-footer__links a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  transition: color 180ms ease;
}

.site-footer__links a:hover,
.site-footer__links a[aria-current='page'] {
  color: var(--white);
}

.site-footer__made {
  grid-area: made;
  margin: 0;
  font-size: 0.72rem;
}

/*
 * The drawer appears twice: in the dark footer, where it is a grid item, and
 * inside the support card, where it is a flex item that has to claim its own
 * row. Each context ignores the other's property.
 */
.contact-drawer {
  grid-area: drawer;
  display: grid;
  flex: 1 1 100%;
  grid-template-rows: 0fr;
}

.contact-drawer[data-open='true'] {
  grid-template-rows: 1fr;
}

.contact-drawer__clip {
  min-height: 0;
  overflow: hidden;
}

.contact-drawer__tray {
  padding-block-start: var(--space-4);
  border-block-start: 1px solid var(--line-dark);
}

.contact-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-chip-item {
  display: flex;
  min-width: 0;
}

/* The phone number is the one contact that is not an address; give it a row. */
.contact-chip-item--phone {
  flex-basis: 100%;
  margin-block-start: var(--space-1);
}

.contact-chip {
  display: inline-flex;
  min-height: 2.7rem;
  max-width: 100%;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding-inline: var(--space-4);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--mosaic);
  cursor: pointer;
  font-size: 0.72rem;
  text-decoration: none;
  touch-action: manipulation;
  transition:
    border-color 180ms ease,
    color 180ms ease;
}

.contact-chip:hover {
  border-color: color-mix(in srgb, var(--mosaic) 38%, transparent);
}

.contact-chip[data-copied='true'] {
  border-color: color-mix(in srgb, var(--smalt) 70%, transparent);
  color: var(--smalt);
}

.site-footer .contact-chip {
  border-color: var(--line-dark);
  color: rgba(235, 237, 240, 0.78);
}

.site-footer .contact-chip:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--white);
}

.site-footer .contact-chip[data-copied='true'] {
  border-color: color-mix(in srgb, var(--brandy) 55%, transparent);
  color: var(--brandy);
}

.contact-chip__value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.contact-chip__icons {
  position: relative;
  display: inline-grid;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  place-items: center;
}

.contact-chip__icon {
  position: absolute;
  display: grid;
  place-items: center;
  opacity: 1;
  transition: opacity 150ms ease;
}

.contact-chip__icon svg {
  width: 1rem;
  height: 1rem;
}

.contact-chip__icon[data-visible='false'] {
  opacity: 0;
}

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

@media (prefers-reduced-motion: no-preference) {
  .contact-drawer {
    transition: grid-template-rows 260ms cubic-bezier(0.2, 0, 0, 1);
  }

  .site-footer__contact-chevron {
    transition: rotate 200ms cubic-bezier(0.2, 0, 0, 1);
  }
}

/* Arabic ------------------------------------------------------------------ */

html[lang='ar'] {
  --display-em-box: 1.3;
}

html[lang='ar'] body {
  font-family: var(--font-arabic);
}

html[lang='ar'] .page-title,
html[lang='ar'] .legal-document h2,
html[lang='ar'] .support-card h2 {
  font-family: var(--font-arabic-display);
  letter-spacing: 0;
}

html[lang='ar'] .page-title {
  --display-leading: 1.18;
  font-size: clamp(2.35rem, 5.2vw, 4.5rem);
}

html[lang='ar'] .legal-document h2 {
  --display-leading: 1.35;
}

html[lang='ar'] .support-card h2 {
  --display-leading: 1.3;
}

/* Narrow ------------------------------------------------------------------ */

@media (max-width: 68rem) {
  .site-nav {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--space-3);
    padding-block: var(--space-4);
    text-align: center;
  }

  .site-nav__actions .nav-cta {
    display: none;
  }
}

@media (max-width: 44rem) {
  /* Everything lines up on the content's left edge, like the page title. */
  .site-nav {
    min-height: 0;
    justify-items: start;
    text-align: start;
  }

  .site-nav__links {
    width: 100%;
    justify-content: flex-start;
    gap: var(--space-4);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .site-nav__links::-webkit-scrollbar {
    display: none;
  }

  .site-nav__links a {
    flex: 0 0 auto;
  }

  .page-title {
    font-size: clamp(2.4rem, 12vw, 3.4rem);
  }

  html[lang='ar'] .page-title {
    font-size: clamp(2.1rem, 10vw, 3rem);
  }

  .support-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .site-footer {
    grid-template-areas:
      'brand'
      'links'
      'contact'
      'made'
      'drawer';
    grid-template-columns: 1fr;
    align-items: start;
  }

  .site-footer__links,
  .site-footer__contact-trigger {
    justify-self: start;
    justify-content: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .lang-toggle,
  .nav-cta,
  .support-card,
  .support-button,
  .contact-chip {
    border: 1px solid CanvasText;
  }
}
