/* ==========================================================================
   ESCAN — Base
   Reset + accessibility + shared primitives. RTL-ready: all layout-facing
   rules use logical properties; concepts must follow the same rule.
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* Lenis virtualizes scrolling — native smooth-scroll must stand down
   or anchor jumps fight the lerp every frame */
html.lenis, html.lenis body { scroll-behavior: auto !important; }

/* Fixed headers across all concepts — keep anchor targets clear of them */
[id] { scroll-margin-block-start: 7rem; }

body {
  font-family: var(--font-en);
  font-size: var(--fs-body);
  font-weight: var(--fw-light);
  line-height: var(--lh-body);
  color: var(--t-strong-on-light);
  background: var(--c-paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:lang(ar) {
  font-family: var(--font-ar);
}

img, picture, video, canvas, svg { display: block; max-inline-size: 100%; }
img, video { block-size: auto; }

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

button { background: none; border: 0; cursor: pointer; }

a { color: inherit; text-decoration: none; }

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

h1, h2, h3, h4 {
  font-weight: var(--fw-light);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-display);
  text-wrap: balance;
}

p { text-wrap: pretty; max-inline-size: var(--measure); }

/* ---- Accessibility ---------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--c-aqua);
  outline-offset: 3px;
  border-radius: 2px;
}

/* aqua fails non-text contrast on light surfaces — switch to teal there */
.surface-paper :focus-visible { outline-color: var(--c-teal); }

.skip-link {
  position: fixed;
  inset-block-start: var(--sp-3);
  inset-inline-start: var(--sp-3);
  z-index: calc(var(--z-loader) + 1);
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-charcoal);
  color: var(--t-strong-on-dark);
  border-radius: var(--radius-s);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* Global motion kill-switch. JS also checks this query before initing
   Lenis/GSAP choreography — this rule is the belt to that suspenders. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Layout primitives ------------------------------------------------ */

.container {
  inline-size: 100%;
  max-inline-size: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--sp-gutter);
}

.section { padding-block: var(--sp-section); }

/* Theme surfaces — concepts compose sections from these */
.surface-ink {
  background: var(--c-ink);
  color: var(--t-body-on-dark);
}
.surface-ink :is(h1, h2, h3, h4) { color: var(--t-strong-on-dark); }

.surface-paper {
  background: var(--c-paper);
  color: var(--t-body-on-light);
}
.surface-paper :is(h1, h2, h3, h4) { color: var(--t-strong-on-light); }

.surface-teal {
  background: var(--c-teal);
  color: var(--t-strong-on-dark);
}

/* ---- Shared atoms ------------------------------------------------------ */

/* Eyebrow/kicker: letterspaced caps, echoes the E S C A N wordmark */
.kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-label);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--c-aqua);
}

/* Diamond bullet — the logo's negative-space diamond as a brand atom */
.kicker::before {
  content: "";
  inline-size: 0.5em;
  block-size: 0.5em;
  rotate: 45deg;
  background: currentColor;
  flex: none;
}

.surface-paper .kicker { color: var(--c-teal); }

/* Chamfered corner panel — hexagon-edge signature cut (top-end corner) */
.chamfer {
  clip-path: polygon(
    0 0,
    calc(100% - var(--chamfer)) 0,
    100% var(--chamfer),
    100% 100%,
    0 100%
  );
}
[dir="rtl"] .chamfer {
  clip-path: polygon(
    var(--chamfer) 0,
    100% 0,
    100% 100%,
    0 100%,
    0 var(--chamfer)
  );
}

/* Buttons */
.btn {
  --btn-fg: var(--t-strong-on-dark);
  --btn-edge: rgba(244, 245, 243, 0.35);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.9em 1.6em;
  border: 1px solid var(--btn-edge);
  border-radius: var(--radius-pill);
  color: var(--btn-fg);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow: hidden;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c-aqua);
  translate: -101% 0;
  transition: translate var(--dur-med) var(--ease-in-out);
  z-index: -1;
}
[dir="rtl"] .btn::before { translate: 101% 0; }
.btn:hover::before, .btn:focus-visible::before { translate: 0 0; }
.btn:hover, .btn:focus-visible {
  color: var(--c-ink);
  border-color: var(--c-aqua);
}

.btn--solid {
  background: var(--c-aqua);
  border-color: var(--c-aqua);
  color: var(--c-ink);
}
.btn--solid::before { background: var(--c-paper); }

.surface-paper .btn {
  --btn-fg: var(--c-charcoal);
  --btn-edge: rgba(43, 43, 43, 0.3);
}
.surface-paper .btn:hover, .surface-paper .btn:focus-visible { color: var(--c-ink); }

/* Arrow glyph used inside buttons/links (inline SVG recommended);
   flips automatically in RTL */
.arrow { transition: translate var(--dur-fast) var(--ease-out); }
a:hover .arrow, .btn:hover .arrow { translate: 0.35em 0; }
[dir="rtl"] .arrow { rotate: 180deg; }
[dir="rtl"] a:hover .arrow, [dir="rtl"] .btn:hover .arrow { translate: -0.35em 0; }

/* Reveal-on-scroll primitives (motion.js drives these; safe when JS off) */
.reveal { opacity: 0; translate: 0 2.5rem; }
.reveal.is-inview, .no-js .reveal {
  opacity: 1;
  translate: 0 0;
  transition: opacity var(--dur-slow) var(--ease-out),
              translate var(--dur-slow) var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; translate: none; }
}

/* Elements that both reveal AND own hover transitions need the union of the
   two transition lists — otherwise .reveal.is-inview's shorthand clobbers
   their hover smoothness (transition is a single shorthand per element). */
.btn.reveal {
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              opacity var(--dur-slow) var(--ease-out),
              translate var(--dur-slow) var(--ease-out);
}
