/**
 * Copyright (c) 2026 KDTech
 * Author: david@KDTech
 * All rights reserved.
 *
 * Tilefold website — base layer
 *
 * Reset, typography, layout helpers, the navigation bar, buttons, the scroll
 * progress line, scroll-reveal states, the footer and the reduced-motion
 * overrides shared by every section. Logical properties (inline/block) are
 * used throughout so the Arabic (RTL) translation mirrors correctly.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

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

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

::selection {
  background: rgb(124 92 255 / 0.45);
  color: #fff;
}

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

/* Skip link for keyboard users. */
.skip-link {
  position: absolute;
  inset-inline-start: 16px;
  inset-block-start: -100px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--text-1);
  color: var(--ink-1);
  font-weight: 600;
}

.skip-link:focus {
  inset-block-start: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.container {
  width: min(100% - 2 * var(--gutter), var(--page-max));
  margin-inline: auto;
}

.section {
  position: relative;
  padding-block: clamp(72px, 10vw, 136px);
}

.section-head {
  max-width: 760px;
  margin-block-end: clamp(40px, 6vw, 72px);
}

.section-head.center {
  margin-inline: auto;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--aurora);
  box-shadow: 0 0 18px rgb(124 92 255 / 0.6);
}

.h2 {
  margin: 0;
  font-size: clamp(34px, 5.4vw, 64px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 650;
  font-variation-settings: "opsz" 32;
}

.lede {
  margin: 20px 0 0;
  color: var(--text-2);
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.55;
}

.aurora-text {
  background: var(--aurora);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: aurora-pan 8s ease-in-out infinite alternate;
}

@keyframes aurora-pan {
  to {
    background-position: 100% 0;
  }
}

/* ---------- Scroll progress ---------- */

.scroll-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 60;
  height: 2px;
  background: var(--aurora);
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
}

[dir="rtl"] .scroll-progress {
  transform-origin: right center;
}

/* ---------- Navigation ---------- */

.nav {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 50;
  height: var(--nav-h);
  transition:
    background 300ms var(--ease-out),
    border-color 300ms var(--ease-out);
  border-block-end: 1px solid transparent;
}

.nav.is-scrolled {
  background: rgb(10 11 16 / 0.72);
  border-block-end-color: var(--line);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.brand svg {
  width: 26px;
  height: 26px;
  transition: transform 500ms var(--ease-spring);
}

.brand:hover svg {
  transform: rotate(-8deg) scale(1.08);
}

.nav-links {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition:
    color 120ms,
    background 120ms;
}

.nav-links a:hover {
  color: var(--text-1);
  background: rgb(255 255 255 / 0.05);
}

.nav-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-start: auto;
}

/* Language picker: a native select styled as a chip (keyboard + screen-reader friendly). */
.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lang-picker svg {
  position: absolute;
  inset-inline-start: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-3);
  pointer-events: none;
}

.lang-picker select {
  appearance: none;
  padding: 7px 12px;
  padding-inline-start: 31px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgb(255 255 255 / 0.03);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.lang-picker select:hover {
  border-color: var(--line-strong);
  color: var(--text-1);
}

.lang-picker option {
  background: var(--ink-3);
  color: var(--text-1);
}

/* ---------- Buttons ---------- */

.btn {
  --glow: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 160ms var(--ease-out),
    background 160ms,
    border-color 160ms,
    box-shadow 300ms var(--ease-out);
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--r-md);
}

.btn-lg {
  min-height: 54px;
  padding: 0 26px;
  font-size: 16px;
  border-radius: 14px;
}

/* Primary: light pill with an aurora halo on hover. */
.btn-primary {
  background: var(--text-1);
  color: var(--ink-1);
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.1),
    0 10px 30px -10px rgb(124 92 255 / calc(0.4 + var(--glow) * 0.4));
}

.btn-primary::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  background: var(--aurora);
  filter: blur(14px);
  opacity: 0;
  transition: opacity 300ms var(--ease-out);
}

.btn-primary:hover::before {
  opacity: 0.85;
}

.btn-ghost {
  border-color: var(--line-strong);
  background: rgb(16 18 26 / 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-1);
  box-shadow: var(--highlight);
}

.btn-ghost:hover {
  border-color: rgb(255 255 255 / 0.22);
  background: rgb(28 31 44 / 0.85);
}

/* Magnetic buttons are nudged toward the pointer by JS (pointer-fx). */
[data-magnetic] {
  transform: translate(var(--mx, 0), var(--my, 0));
}

/* ---------- Scroll reveal ---------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition:
    opacity 900ms var(--ease-out),
    transform 900ms var(--ease-out),
    filter 900ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 80ms);
}

[data-reveal].is-in {
  opacity: 1;
  transform: none;
  filter: none;
}

/* Without JS everything is simply visible. */
.no-js [data-reveal] {
  opacity: 1;
  transform: none;
  filter: none;
}

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

.footer {
  position: relative;
  padding-block: 56px 40px;
  border-block-start: 1px solid var(--line);
  color: var(--text-3);
  font-size: 14px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 32px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a:hover {
  color: var(--text-1);
}

.footer .lang-picker {
  margin-inline-start: auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .nav-links {
    display: none;
  }
}

@media (max-width: 520px) {
  .nav-end .btn {
    display: none;
  }

  .footer .lang-picker {
    margin-inline-start: 0;
  }
}

/* ---------- Reduced motion ---------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 100ms !important;
  }

  [data-reveal] {
    transform: none;
    filter: none;
  }

  [data-magnetic] {
    transform: none;
  }
}
