/* ------------------------------------------------------------------
   Mohrati – shared styles (every page links this file)
   Theme is driven by <html data-theme="light|dark"> (set by site.js)
   Direction is driven by <html dir="ltr|rtl"> – use logical properties.
------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --ink: #231f20;
  --muted: rgba(35, 31, 32, 0.68);
  --gold: #a67f2e;

  /* glass used by the two small buttons */
  --glass: rgba(255, 255, 255, 0.6);
  --glass-solid: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(35, 31, 32, 0.12);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 6px 18px -8px rgba(35, 31, 32, 0.25);

  --font-latin: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d0b09;
  --ink: #f2ede4;
  --muted: rgba(242, 237, 228, 0.7);
  --gold: #c9a54f;

  --glass: rgba(255, 255, 255, 0.07);
  --glass-solid: rgba(40, 35, 30, 0.95);
  --glass-border: rgba(255, 255, 255, 0.16);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 18px -8px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  transition: background-color 0.35s ease;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-latin);
  font-weight: 300;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* top padding leaves room for the fixed buttons */
  padding:
    calc(max(14px, env(safe-area-inset-top)) + 54px)
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

html[lang="ar"] body,
html[lang="ar"] button,
html[lang="ar"] a { font-family: var(--font-ar); }
[lang="ar"] { font-family: var(--font-ar); }

/* Arabic letters must stay connected – never letter-space them. */
html[lang="ar"] *,
[lang="ar"] { letter-spacing: 0 !important; }

/* ---------- Top-right buttons (always the physical top-right corner) ---------- */
.controls {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  direction: ltr; /* keep the buttons' own order identical in EN and AR */
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

.ctl {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 0.85rem;            /* same size for "EN" and "ع" */
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.ctl [lang] { font-size: inherit; font-weight: inherit; line-height: 1; }
.ctl:hover { transform: translateY(-1px); }
.ctl:active { transform: scale(0.94); }

/* sun <-> moon swap */
.ctl svg {
  position: absolute;
  width: 17px;
  height: 17px;
  transition: transform 0.5s cubic-bezier(0.3, 1.2, 0.5, 1), opacity 0.25s ease;
}
.ctl .i-moon { opacity: 0; transform: rotate(-70deg) scale(0.5); }
:root[data-theme="dark"] .ctl .i-sun { opacity: 0; transform: rotate(70deg) scale(0.5); }
:root[data-theme="dark"] .ctl .i-moon { opacity: 1; transform: none; }

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

/* ---------- Page ---------- */
.page {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 6vh, 56px);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s ease, transform 1s cubic-bezier(0.2, 0.7, 0.2, 1);
}
html[data-ready] .page { opacity: 1; transform: none; }

.logo-wrap { width: min(100%, 540px); }
.logo { display: block; width: 100%; height: auto; max-height: 48vh; max-height: 48dvh; object-fit: contain; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

.copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.rule { width: 56px; height: 1px; background: var(--gold); }

/* "COMING SOON" */
.soon {
  font-weight: 300;
  font-size: clamp(0.85rem, 2.4vw, 1.1rem);
  letter-spacing: 0.5em;
  padding-inline-start: 0.5em; /* balances the trailing letter-spacing */
  text-transform: uppercase;
  color: var(--gold);
}
html[lang="ar"] .soon { font-size: clamp(1.25rem, 3.4vw, 1.6rem); font-weight: 400; padding-inline-start: 0; }

.copy p {
  color: var(--muted);
  font-size: clamp(0.85rem, 2vw, 1rem);
  letter-spacing: 0.08em;
  text-wrap: balance;
}
html[lang="ar"] .copy p { font-size: clamp(0.95rem, 2.4vw, 1.15rem); }

/* ---------- 404 page ---------- */
.code {
  font-size: clamp(4rem, 16vw, 7rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--gold);
}
.page h1:not(.soon) {
  font-weight: 300;
  font-size: clamp(1.3rem, 3.4vw, 1.9rem);
  line-height: 1.25;
  text-wrap: balance;
}
.home {
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 1px solid currentColor;
}
.home:hover { opacity: 0.75; }

/* ---------- Small screens ---------- */
@media (max-width: 380px) {
  .soon { letter-spacing: 0.38em; padding-inline-start: 0.38em; }
}

/* Landscape phones: logo beside the text instead of stacked */
@media (orientation: landscape) and (max-height: 520px) {
  body { padding-top: calc(max(12px, env(safe-area-inset-top)) + 46px); }
  .page {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(24px, 5vw, 48px);
    max-width: 900px;
    text-align: start;
  }
  .logo { max-height: 62vh; max-height: 62dvh; }
  .copy { align-items: flex-start; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .page { transform: none; transition: opacity 0.2s ease; }
  .ctl, .ctl svg { transition: none; }
}
