/* ============================================================
   salmanalfares.com — design system
   One stylesheet, two scripts (RTL Arabic / LTR English via
   logical properties). Theme: dark "قبل الفجر", hue-230 family,
   LOCKED 2026-06-12 after the bake-off.
   Fonts: Alexandria only (Arabic + Latin), self-hosted.
   ============================================================ */

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Alexandria";
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/alexandria-400-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/alexandria-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/alexandria-500-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/alexandria-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/alexandria-700-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/alexandria-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 800;
  font-display: swap;
  src: url("/assets/fonts/alexandria-800-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Alexandria";
  font-weight: 800;
  font-display: swap;
  src: url("/assets/fonts/alexandria-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Structural tokens (theme-independent) ---------- */
:root {
  /* type scale, ratio ~1.3; display capped well under 6rem */
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: clamp(1.4rem, 1.2rem + 1vw, 1.75rem);
  --text-2xl: clamp(1.7rem, 1.35rem + 1.8vw, 2.35rem);
  --text-display: clamp(2.1rem, 1.5rem + 3.2vw, 3.8rem);

  /* 4pt-base spacing scale */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;
  --space-section: clamp(4rem, 3rem + 5vw, 7rem);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-pill: 999px;

  --container: 68rem;
  --measure: 65ch;

  /* z scale */
  --z-nav: 10;
  --z-toggle: 20;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 280ms;

  /* per-script line heights, overridden on /en.
     Arabic display leading: pixel-measured 2026-06-12. Alexandria 800
     final-yeh dots (أبني) hung EXACTLY mid-gap between the lines
     (5.7px to own body vs 6.3px to the line below at 1.62) — reading
     as overlap. 1.78 puts the dots ~1:2.5 (own line : next line). */
  --lh-body: 1.8;
  --lh-display: 1.78;
  --lh-heading: 1.55;
}
:lang(en) {
  --lh-body: 1.65;
  --lh-display: 1.12;
  --lh-heading: 1.25;
}

/* ---------- Theme: dark — "قبل الفجر" (harbor before dawn) ----------
   LOCKED 2026-06-12 (bake-off closed: dark won, light deleted).
   Brand-tinted near-black; depth via lighter surfaces and soft dawn
   light; the CTA is the one luminous element on the page. */
:root {
  color-scheme: dark;
  --bg: oklch(0.16 0.018 230);
  --surface: oklch(0.205 0.02 230);
  --surface-2: oklch(0.25 0.022 230);
  --ink: oklch(0.965 0.005 230);
  --text: oklch(0.875 0.012 230);
  --muted: oklch(0.71 0.022 230);
  --accent: oklch(0.78 0.115 225);
  --on-accent: oklch(0.17 0.02 230);
  --accent-text: oklch(0.82 0.09 225);
  --frost: oklch(0.86 0.055 225);
  --border: oklch(0.31 0.02 230);
  --shadow: none;
  --hero-glow:
    radial-gradient(55% 40% at 50% 0%, oklch(0.235 0.032 228) 0%, transparent 62%),
    radial-gradient(60% 45% at 50% 108%, oklch(0.42 0.09 228) 0%, transparent 70%);
  --thumb-fill: oklch(0.25 0.022 230);
  --marquee-bg: oklch(0.185 0.02 230);
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Alexandria", "Segoe UI", Tahoma, sans-serif;
  font-size: var(--text-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,
h2,
h3 {
  color: var(--ink);
  text-wrap: balance;
  margin: 0;
}
p {
  margin: 0;
  max-width: var(--measure);
}
a {
  color: var(--accent-text);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
img,
svg {
  display: block;
  max-width: 100%;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

/* ---------- Horizon motif: section separator ----------
   A hairline with a rising glow dot. The site's one repeating
   signature; replaces eyebrow/numbered section grammar. */
.horizon {
  position: relative;
  border: 0;
  height: 1px;
  margin: 0 auto;
  max-width: var(--container);
  background: linear-gradient(to var(--horizon-dir, right), var(--border) 0%, var(--border) 78%, transparent 100%);
}
[dir="rtl"] .horizon {
  --horizon-dir: left;
}
.horizon::after {
  content: "";
  position: absolute;
  inset-block-start: -3.5px;
  inset-inline-start: clamp(1.25rem, 4vw, 2.5rem);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--frost);
  box-shadow: 0 0 8px oklch(0.78 0.115 225 / 0.6);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: var(--bg);
  border-block-end: 1px solid var(--border);
}
.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.75rem;
}
.wordmark {
  font-weight: 800;
  font-size: var(--text-lg);
  color: var(--ink);
  letter-spacing: 0;
}
.wordmark:hover {
  text-decoration: none;
}
.lang-switch {
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.lang-switch:hover {
  color: var(--ink);
  border-color: var(--accent);
  text-decoration: none;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding-block: clamp(4.5rem, 3rem + 8vw, 8.5rem) var(--space-section);
}
/* layer ladder: video (-3) → dawn glow (-2) → legibility overlay (-1) → content */
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 22% 30%; /* keep the figure in frame when cropping: face side, biased up so the hair survives short heroes */
  z-index: -3;
}
html[dir="ltr"] .hero-video {
  transform: scaleX(-1); /* face baked into the left of the frame; mirror so it sits opposite the LTR text */
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--hero-glow);
  pointer-events: none;
}
.hero::after {
  /* text-side darkening + bottom fade into the page background */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to top, oklch(0.16 0.018 230) 0%, oklch(0.16 0.018 230 / 0) 36%),
    linear-gradient(to right, oklch(0.16 0.018 230 / 0.22) 0%, oklch(0.16 0.018 230 / 0.66) 52%, oklch(0.16 0.018 230 / 0.92) 100%);
}
html[dir="ltr"] .hero::after {
  background:
    linear-gradient(to top, oklch(0.16 0.018 230) 0%, oklch(0.16 0.018 230 / 0) 36%),
    linear-gradient(to left, oklch(0.16 0.018 230 / 0.22) 0%, oklch(0.16 0.018 230 / 0.66) 52%, oklch(0.16 0.018 230 / 0.92) 100%);
}
@media (prefers-reduced-motion: reduce) {
  .hero-video {
    display: none;
  }
  .hero {
    background-image: url("/assets/video/hero-poster.jpg");
    background-size: cover;
    background-position: 22% 30%;
  }
}
.hero .container {
  position: relative;
  display: grid;
  gap: var(--space-lg);
  justify-items: start;
}
.hero h1 {
  font-size: var(--text-display);
  font-weight: 800;
  line-height: var(--lh-display);
  max-width: 17ch;
}
.hero .lede {
  font-size: var(--text-lg);
  color: var(--muted);
  max-width: 38ch;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md) var(--space-lg);
  margin-block-start: var(--space-xs);
}

/* entrance: enhances an always-visible default (animation, not gated) */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.hero h1 {
  animation: rise 0.6s var(--ease-out) both;
}
.hero .lede {
  animation: rise 0.6s var(--ease-out) 0.12s both;
}
.hero .hero-actions {
  animation: rise 0.6s var(--ease-out) 0.22s both;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: inherit;
  font-weight: 700;
  font-size: var(--text-base);
  line-height: 1;
  padding: 0.95rem 1.8rem;
  border-radius: var(--radius-pill);
  border: 0;
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out), filter var(--dur) var(--ease-out);
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow);
}
.btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  text-decoration: none;
}
.btn-primary:active {
  transform: none;
}
.link-secondary {
  font-weight: 500;
  color: var(--muted);
}
.link-secondary:hover {
  color: var(--ink);
}

/* ---------- Sections ---------- */
.section {
  padding-block: var(--space-section);
}
.section-head {
  display: grid;
  gap: var(--space-sm);
  margin-block-end: var(--space-xl);
}
.section-head h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: var(--lh-heading);
}
.section-head p {
  color: var(--muted);
}
.section-head-tight {
  margin-block-end: 0;
}

/* ---------- Platforms: 4 featured panels (2×2) + compact row ---------- */
.platforms {
  display: grid;
  gap: var(--space-lg);
}
.featured-grid {
  display: grid;
  gap: var(--space-lg);
}
@media (min-width: 640px) {
  .featured-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.panel {
  position: relative;
  display: grid;
  align-content: start;
  gap: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-xl) var(--space-lg);
  transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.panel::after {
  /* dawn light catching the top edge */
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 12%;
  height: 1px;
  background: linear-gradient(to right, transparent, oklch(0.86 0.055 225 / 0.32), transparent);
  pointer-events: none;
}
.panel:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.panel .icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  margin-block-end: var(--space-xs);
}
.panel h3 {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: var(--lh-heading);
}
.panel p {
  color: var(--muted);
}
.panel .panel-cta {
  font-weight: 700;
  margin-block-start: var(--space-xs);
}
.compact-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 500;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.7rem 1.2rem;
  transition: border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.pill:hover {
  border-color: var(--accent);
  color: var(--ink);
  text-decoration: none;
}
.pill .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}
.pill:hover .icon {
  color: var(--accent);
}
.pill small {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---------- Videos: snap row on mobile, grid on desktop ---------- */
.videos {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(78vw, 21rem);
  gap: var(--space-md);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-block-end: var(--space-sm);
  scrollbar-width: thin;
}
.videos > * {
  scroll-snap-align: start;
}
@media (min-width: 56rem) {
  .videos {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
  }
}
.video-card {
  display: grid;
  gap: var(--space-sm);
}
.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--thumb-fill);
  border: 1px solid var(--border);
}
.video-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.play-btn {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.play-btn .play-disc {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  transition: transform var(--dur) var(--ease-out);
}
.play-btn:hover .play-disc {
  transform: scale(1.08);
  box-shadow: 0 0 0 6px oklch(0.78 0.115 225 / 0.18);
}
.play-btn svg {
  width: 22px;
  height: 22px;
}
.video-card figcaption {
  font-weight: 500;
  color: var(--text);
}
.video-card .video-alt {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  gap: var(--space-xl);
  align-items: center;
}
@media (min-width: 56rem) {
  .about-grid {
    grid-template-columns: minmax(16rem, 2fr) 3fr;
  }
}
.portrait {
  position: relative;
  aspect-ratio: 1 / 1;
  width: min(100%, 20rem);
  margin-inline: auto;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.about-copy {
  display: grid;
  gap: var(--space-md);
}
.about-copy .fact {
  color: var(--text);
}
.about-copy .fact strong {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Footer ---------- */
.footer {
  border-block-start: 1px solid var(--border);
  padding-block: var(--space-2xl);
  background: var(--surface);
}
.footer .container {
  display: grid;
  gap: var(--space-lg);
}
.footer .contact {
  display: grid;
  gap: var(--space-2xs);
}
.footer .contact .label {
  font-size: var(--text-sm);
  color: var(--muted);
}
.footer .contact a {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--ink);
}
.social-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.social-row a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.social-row a:hover {
  color: var(--accent-text);
  border-color: var(--accent);
}
.social-row svg {
  width: 20px;
  height: 20px;
}
.footer .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---------- Tools marquee (ported from Pyxora, dark recolor) ---------- */
.tools-marquee-section {
  background: var(--marquee-bg);
  border-block: 1px solid var(--border);
  padding-block: 1.9rem;
}
.tools-marquee {
  /* direction pinned LTR even on the RTL page: in RTL flex the track
     anchors to the RIGHT edge, so the translateX loop runs out of
     content and the belt goes blank mid-cycle (Salman's bug report) */
  direction: ltr;
  width: 100%;
  overflow: hidden;
  display: flex;
  position: relative;
}
.tools-marquee::before,
.tools-marquee::after {
  content: "";
  position: absolute;
  top: 0;
  width: clamp(60px, 12vw, 160px);
  height: 100%;
  z-index: 2;
  pointer-events: none;
}
.tools-marquee::before {
  left: 0;
  background: linear-gradient(to right, var(--marquee-bg), transparent);
}
.tools-marquee::after {
  right: 0;
  background: linear-gradient(to left, var(--marquee-bg), transparent);
}
.tools-track {
  direction: ltr;
  display: flex;
  width: fit-content;
  animation: scroll-marquee 42s linear infinite;
}
.tools-marquee:hover .tools-track {
  animation-play-state: paused;
}
.tools-set {
  display: flex;
  align-items: center;
  gap: clamp(44px, 6.5vw, 80px);
  padding-right: clamp(44px, 6.5vw, 80px);
}
.tool-item {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
.tool-item img {
  width: 22px;
  height: 22px;
}
.tool-item span {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
}
@keyframes scroll-marquee {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* ---------- Scroll reveals (classes added by JS only; no-JS = visible) ---------- */
.will-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.will-reveal.revealed {
  opacity: 1;
  transform: none;
}
.featured-grid .will-reveal:nth-child(2),
.videos .will-reveal:nth-child(2) {
  transition-delay: 0.08s;
}
.featured-grid .will-reveal:nth-child(3),
.videos .will-reveal:nth-child(3) {
  transition-delay: 0.16s;
}
.featured-grid .will-reveal:nth-child(4) {
  transition-delay: 0.24s;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}
