/* =========================================================
   Quantic · Components
   ========================================================= */

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: transform var(--t-slow) var(--ease), background-color var(--t-slow) var(--ease);
}
.site-header.is-hidden { transform: translateY(-100%); }

.site-header__inner {
  height: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;   /* logo | nav centered in the free space | actions */
  align-items: center;
  gap: 24px;
}
.site-header__inner .nav { justify-self: center; }
.site-header__logo { width: 150px; }
.site-header__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Nav ---------- */
.nav__list { display: flex; gap: 40px; }
.nav__link {
  position: relative;
  display: inline-block;
  padding: 6px 0;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--t-base) var(--ease);
}
.nav__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 2px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--t-base) var(--ease);
}
.nav__link:hover,
.nav__link.is-active { color: var(--text); }
.nav__link:hover::after,
.nav__link.is-active::after { transform: scaleX(1); transform-origin: left; }

/* ---------- Language switch ---------- */
.lang { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.lang__item { color: var(--text-soft); font-weight: 500; transition: color var(--t-base) var(--ease); }
.lang__item.is-active { color: var(--text); font-weight: 600; }
.lang__item:hover { color: var(--red); }
.lang__sep { width: 1px; height: 14px; background: currentColor; opacity: 0.3; }

/* ---------- Language switch (EN / عربي) ----------
   A segmented pill next to the theme button; the current language is filled. */
.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding: 4px;
  border: 1.5px solid color-mix(in srgb, var(--text) 22%, transparent);
  border-radius: 999px;
  transition: border-color var(--t-base) var(--ease);
}
.lang-switch:hover { border-color: var(--red); }
.lang-switch__opt {
  display: grid;
  place-items: center;
  min-width: 46px;
  height: 100%;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.lang-switch__opt[lang="ar"] { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif; font-size: 15px; }
.lang-switch__opt:hover { color: var(--red); }
.lang-switch__opt.is-active { background: var(--text); color: var(--bg); }

/* ---------- Theme button ----------
   One round button: a sun that turns into a moon (the cut circle slides over it).
   The page switches with a circular reveal that starts from the button (JS). */
.theme-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 16px 0 10px;
  border: 1.5px solid color-mix(in srgb, var(--text) 22%, transparent);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  transition: border-color var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
}
.theme-btn:hover { border-color: var(--red); }
.theme-btn__icon {
  width: 24px; height: 24px;
  overflow: visible;
  color: var(--red);
  transition: transform 600ms var(--ease);
}
.theme-btn__rays path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}
.theme-btn__rays { transform-origin: 12px 12px; transition: transform 600ms var(--ease), opacity 400ms var(--ease); }
.theme-btn__core { fill: currentColor; transform-origin: 12px 12px; transition: transform 600ms var(--ease); }
.theme-btn__cut  { fill: var(--bg); opacity: 0; transform: translate(14px, -14px) scale(1.15); transform-origin: 12px 12px; transition: transform 600ms var(--ease), opacity 300ms var(--ease), fill var(--t-slow) var(--ease); }
.theme-btn:hover .theme-btn__rays { transform: rotate(45deg); }

[data-theme="dark"] .theme-btn__icon { transform: rotate(-30deg); color: #FFFBF5; }
[data-theme="dark"] .theme-btn__rays { transform: scale(0.4) rotate(90deg); opacity: 0; }
[data-theme="dark"] .theme-btn__core { transform: scale(1.65); }
[data-theme="dark"] .theme-btn__cut  { opacity: 1; transform: translate(4px, -4px) scale(1.35); }
[data-theme="dark"] .theme-btn:hover .theme-btn__icon { transform: rotate(-10deg); }

/* "Light" / "Dark" word that rolls */
.theme-btn__label { position: relative; display: block; height: 1.2em; overflow: hidden; line-height: 1.2; }
.theme-btn__label span { display: block; transition: transform 500ms var(--ease); }
[data-theme="dark"] .theme-btn__label span { transform: translateY(-100%); }

/* circular reveal between themes (View Transitions API, where supported) */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 1000; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 13px 22px;
  border-radius: var(--radius);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              gap var(--t-base) var(--ease), scale var(--t-fast) var(--ease);
}
.btn--lg { padding: 17px 28px; }
.btn--primary { background: var(--red); color: var(--on-red); }
.btn--light { background: #FFFBF5; color: var(--red); }

/* the arrow slides in on hover */
.btn__arrow {
  display: inline-block;
  width: 0;
  opacity: 0;
  transform: translateX(-8px);
  transition: width var(--t-base) var(--ease), opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.btn:hover { gap: 10px; }
.btn:hover .btn__arrow { width: 1em; opacity: 1; transform: none; }
.btn--primary:hover { background: var(--red-strong); }
.btn--light:hover { background: #FFFFFF; }
.btn:active { scale: 0.98; }

/* ---------- Text link with arrow ---------- */
.link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-small);
  font-weight: 500;
  padding-bottom: 4px;
}
.link__arrow { color: var(--red); transition: transform var(--t-base) var(--ease); }
.link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--t-base) var(--ease);
}
.link:hover .link__arrow,
a:hover > .link--static .link__arrow { transform: translateX(6px); }
.link:hover::after,
a:hover > .link--static::after { transform: scaleX(1); transform-origin: left; }

/* ---------- Section label & titles ---------- */
.section-label {
  display: flex;
  gap: 14px;
  font-size: var(--fs-small);
  font-weight: 500;
}
.section-label__no { color: var(--red); }

.section-title {
  margin-top: 16px;
  font-size: var(--fs-h2);
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: var(--tracking-tight);
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: clamp(40px, 5vw, 64px);
}
.section-intro {
  max-width: 30rem;
  font-size: var(--fs-body);
  color: var(--text-muted);
}

/* ---------- Service row ---------- */
.services__list {
  margin-top: clamp(40px, 5vw, 64px);
  border-top: 2px solid var(--line-strong);
  border-bottom: 2px solid var(--line-strong);
}
.services__list li + li { border-top: 1px solid var(--line); }

.service-row {
  --pad: 40px;
  position: relative;
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) minmax(0, 440px) 40px;
  align-items: center;
  column-gap: 40px;
  min-height: 120px;
  padding: 24px var(--pad);
  overflow: hidden;
  isolation: isolate;
}
.service-row__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--red);
  /* JS sets data-from to "left" or "right" so the red wipes in from the side the mouse entered */
  clip-path: inset(0 100% 0 0);
  transition: clip-path var(--t-slow) var(--ease);
}
.service-row[data-from="right"] .service-row__fill { clip-path: inset(0 0 0 100%); }
.service-row__no { font-size: var(--fs-body); font-weight: 500; color: var(--red); }
.service-row__name {
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  transition: transform var(--t-slow) var(--ease);
}
.service-row__desc { font-size: var(--fs-body); color: var(--text-muted); line-height: 1.5; }
.service-row__arrow {
  justify-self: end;
  font-size: 24px;
  color: var(--text-soft);
  transition: transform var(--t-slow) var(--ease), color var(--t-base) var(--ease);
}
.service-row__no,
.service-row__desc { transition: color var(--t-base) var(--ease); }

.service-row:hover .service-row__fill,
.service-row:focus-visible .service-row__fill { clip-path: inset(0 0 0 0); }
.service-row:hover .service-row__name { transform: translateX(10px); }
.service-row:hover :is(.service-row__no, .service-row__name, .service-row__arrow) { color: var(--on-red); }
.service-row:hover .service-row__desc { color: rgba(255, 251, 245, 0.9); }
.service-row:hover .service-row__arrow { transform: rotate(-45deg); }

/* ---------- Stacked project showcase ----------
   One project card is in front; the next two peek out underneath
   with their names, like a deck. JS sets data-pos on each item:
   0 = front, 1 / 2 = peeking behind, "out" = already seen, "hidden" = further back. */
.stack-stage {
  --card-h: clamp(460px, calc(100svh - var(--header-h) - 210px), 600px);
  --peek: 36px;
  position: relative;
  height: calc(var(--card-h) + var(--peek) * 2);
}
.stack { position: relative; height: 100%; }
.stack__item {
  position: absolute;
  inset: 0 0 auto;
  height: var(--card-h);
  transform-origin: 50% 100%;
  transition: transform 800ms var(--ease), opacity 600ms var(--ease), filter 800ms var(--ease);
  will-change: transform;
}
.stack__item[data-pos="0"]      { z-index: 3; transform: none; }
.stack__item[data-pos="1"]      { z-index: 2; transform: translateY(var(--peek)) scale(0.96); filter: brightness(0.72); }
.stack__item[data-pos="2"]      { z-index: 1; transform: translateY(calc(var(--peek) * 2)) scale(0.92); filter: brightness(0.5); }
.stack__item[data-pos="hidden"] { z-index: 0; transform: translateY(calc(var(--peek) * 2)) scale(0.92); opacity: 0; }
.stack__item[data-pos="out"]    { z-index: 4; transform: translateY(-48px) scale(1.02); opacity: 0; pointer-events: none; }
.stack__item:not([data-pos="0"]) .stack-card { pointer-events: none; }

.stack-card {
  --mx: 70%; --my: 50%;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  isolation: isolate;
  color: #FFFBF5;
  background: var(--red-deep);
  box-shadow: 0 30px 60px -20px rgba(20, 0, 3, 0.45);
}
/* drafting grid + light that follows the mouse */
.stack-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(520px circle at var(--mx) var(--my), rgba(225, 38, 44, 0.7), transparent 60%),
    linear-gradient(to right, rgba(225, 38, 44, 0.28) 1px, transparent 1px) 0 0 / var(--grid-size) var(--grid-size),
    linear-gradient(to bottom, rgba(225, 38, 44, 0.28) 1px, transparent 1px) 0 0 / var(--grid-size) var(--grid-size);
}
.stack-card__info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: clamp(28px, 4vw, 56px);
}
.stack-card__count {
  position: absolute;
  top: clamp(24px, 3vw, 48px);
  left: clamp(28px, 4vw, 56px);
  font-size: var(--fs-small);
  font-weight: 500;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.stack-card__category { font-size: var(--fs-body); font-weight: 500; opacity: 0.75; }
.stack-card__name {
  font-size: clamp(3rem, 2rem + 3.4vw, 5.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}
.stack-card__desc { max-width: 25rem; font-size: var(--fs-lead); line-height: 1.5; opacity: 0.82; }
.stack-card__btn { align-self: flex-start; margin-top: 20px; }
.stack-card:hover .stack-card__btn { gap: 10px; background: #FFFFFF; }
.stack-card:hover .stack-card__btn .btn__arrow { width: 1em; opacity: 1; transform: none; }

.stack-card__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 32px 0;
  min-height: 0;
  overflow: visible;
}
.stack-card__media img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 40px 60px rgba(10, 0, 2, 0.5));
  transform: translate3d(var(--dx, 0), var(--dy, 0), 0) rotate(var(--rot, 0deg));
  transition: transform 700ms var(--ease);
}
.stack-card:hover .stack-card__media img { transform: translate3d(var(--dx, 0), calc(var(--dy, 0px) - 10px), 0) scale(1.03); }

/* name strip shown only when the card is peeking from behind */
.stack-card__peek {
  position: absolute;
  inset: auto 0 0;
  height: var(--peek);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: clamp(24px, 3.5vw, 48px);
  font-size: var(--fs-small);
  background: var(--red-deep);
  border-top: 1px solid rgba(225, 38, 44, 0.35);
  z-index: 2;
  opacity: 0;
  transition: opacity 400ms var(--ease);
}
.stack-card__peek span:first-child { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.stack-card__peek span:last-child { opacity: 0.6; }
.stack__item[data-pos="1"] .stack-card__peek,
.stack__item[data-pos="2"] .stack-card__peek { opacity: 1; }

/* progress under the stack (clickable) */
.stack-progress {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-top: 40px;
}
.stack-progress__item {
  display: block;
  padding-bottom: 6px;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-soft);
  transition: color var(--t-base) var(--ease);
}
.stack-progress__item:hover { color: var(--text); }
.stack-progress__bar {
  display: block;
  height: 2px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  overflow: hidden;
}
.stack-progress__bar::after {
  content: "";
  display: block;
  height: 100%;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-slow) var(--ease);
}
.stack-progress__item.is-active,
.stack-progress__item.is-done { color: var(--text); }
.stack-progress__item.is-active .stack-progress__bar::after,
.stack-progress__item.is-done .stack-progress__bar::after { transform: scaleX(1); }

/* short laptop screens: tighten the card so everything fits */
@media (min-width: 1025px) and (max-height: 780px) {
  .stack-card__name { font-size: clamp(2.75rem, 1.6rem + 2.6vw, 4rem); }
  .stack-card__desc { font-size: var(--fs-body); }
  .stack-card__info { gap: 10px; padding-block: 72px 32px; }
  .stack-card__btn { margin-top: 12px; }
  .stack-card__count { top: 28px; }
}

/* narrower desktops: keep the header on one line */
@media (max-width: 1280px) {
  .nav__list { gap: 28px; }
  .theme-btn { width: 44px; padding: 0; justify-content: center; }
  .theme-btn__label { display: none; }
}

/* ---------- Brand red treatment for photos ----------
   Add .tint-red to the element that wraps an <img>: the photo turns into
   a deep-red duotone so every picture matches the site. */
.tint-red { position: relative; isolation: isolate; background: var(--red-deep); }
.tint-red img {
  filter: grayscale(1) contrast(1.15) brightness(1.05);
  mix-blend-mode: luminosity;
  opacity: 0.9;
}
.tint-red::before {            /* red light on the bright parts */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(120% 90% at 70% 30%, rgba(225, 38, 44, 0.55), transparent 70%);
  mix-blend-mode: screen;
}
