/* ==========================================================
   Alaa Odat — base: tokens, reset, typography, shared UI
   ========================================================== */

:root {
  /* Light (default) */
  --bg: #f4f0e8;
  --bg-2: #ece6da;
  --bg-3: #e2dbcc;
  --ink: #1a1916;
  --ink-2: #5a554c;
  --ink-3: #8a8478;
  --line: rgba(26, 25, 22, 0.14);
  --brass: #9b7339;
  --brass-2: #b8894a;
  --bg-rgb: 244, 240, 232;
  --cursor-ring: rgba(26, 25, 22, 0.35);
  --grain-opacity: 0.035;
  --error: #b5452f;

  --serif: "Fraunces", "Times New Roman", serif;
  --sans: "Manrope", system-ui, -apple-system, sans-serif;

  --gutter: clamp(16px, 4vw, 56px);
  --max: 1320px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  --bg: #0d0d0c;
  --bg-2: #141412;
  --bg-3: #1c1b18;
  --ink: #ece8e1;
  --ink-2: #a8a39a;
  --ink-3: #6b675f;
  --line: rgba(236, 232, 225, 0.12);
  --brass: #c9a46a;
  --brass-2: #e3c48f;
  --bg-rgb: 13, 13, 12;
  --cursor-ring: rgba(236, 232, 225, 0.35);
  --grain-opacity: 0.05;
  --error: #e08a7a;
}

/* Smooth color crossfade only while the theme is switching */
.theme-switching,
.theme-switching * {
  transition: background-color 0.6s var(--ease), color 0.6s var(--ease), border-color 0.6s var(--ease) !important;
}

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

html { -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-loading { overflow: hidden; }

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
::selection { background: var(--brass); color: var(--bg); }

:focus-visible { outline: 1px solid var(--brass); outline-offset: 4px; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.section { padding: clamp(96px, 14vw, 180px) 0; position: relative; }

/* ---------- Typography ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 28px;
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--brass);
}
.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 0 rgba(201, 164, 106, 0.6);
  animation: pulse 2.4s infinite;
}
.hero-eyebrow::before { display: none; }

@keyframes pulse {
  70% { box-shadow: 0 0 0 10px rgba(201, 164, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 164, 106, 0); }
}

.section-title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(36px, 5.4vw, 76px);
  line-height: 1.04;
  letter-spacing: -0.02em;
}
.section-title em,
.contact-title em,
.hero-title em {
  font-style: italic;
  color: var(--brass);
}
.split-lines .split-line { overflow: hidden; padding-bottom: 0.08em; }

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

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 18px 34px;
  border: 1px solid var(--brass);
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow: hidden;
  isolation: isolate;
  transition: color 0.5s var(--ease);
}
.button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brass);
  transform: translateY(101%);
  border-radius: inherit;
  transition: transform 0.5s var(--ease);
  z-index: -1;
}
.button:hover { color: var(--bg); }
.button:hover::before { transform: translateY(0); }
.button:disabled { opacity: 0.6; cursor: wait; }

/* ---------- Preloader ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.loader-inner { display: flex; align-items: baseline; gap: 24px; }
.loader-mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--brass);
}
.loader-count {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(64px, 12vw, 160px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
}
.loader-bar {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 48px;
  height: 1px;
  background: var(--line);
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--brass);
  transform-origin: left;
  transform: scaleX(0);
}

/* ---------- Cursor & grain ---------- */

.cursor { display: none; }
@media (hover: hover) and (pointer: fine) {
  .cursor { display: block; }
  .cursor span {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 90;
    pointer-events: none;
    border-radius: 50%;
  }
  .cursor-dot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: var(--brass);
  }
  .cursor-ring {
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 1px solid var(--cursor-ring);
    transition: width 0.35s var(--ease), height 0.35s var(--ease), margin 0.35s var(--ease),
      background-color 0.35s var(--ease), border-color 0.35s var(--ease);
  }
  .cursor.is-hover .cursor-ring {
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    border-color: var(--brass);
    background: rgba(201, 164, 106, 0.08);
  }
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 80;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(8) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -1%); }
}

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

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 22px var(--gutter);
  transition: background-color 0.5s var(--ease), padding 0.5s var(--ease), transform 0.5s var(--ease);
}
.nav.is-scrolled {
  background: rgba(var(--bg-rgb), 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.nav.is-hidden { transform: translateY(-100%); }

.nav-logo {
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: -0.02em;
}
.nav-logo em { color: var(--brass); }

.nav-links { display: flex; gap: 34px; margin-left: auto; }
.nav-links a {
  position: relative;
  display: inline-block;
  overflow: hidden;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.4;
}
.nav-links a::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 100%;
  color: var(--ink);
}
.nav-links a > * , .nav-links a { transition: color 0.3s; }
.nav-links a:hover { color: transparent; }
.nav-links a:hover::after { transform: translateY(-100%); }
.nav-links a::after { transition: transform 0.45s var(--ease); }
.nav-links a.is-active { color: var(--ink); }

.nav-cta {
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  transition: border-color 0.3s, color 0.3s;
}
.nav-cta:hover { border-color: var(--brass); color: var(--brass); }

.theme-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  overflow: hidden;
  transition: border-color 0.3s, color 0.3s;
}
.theme-toggle:hover { border-color: var(--brass); color: var(--brass); }
.theme-toggle svg {
  position: absolute;
  width: 18px;
  height: 18px;
  transition: transform 0.6s var(--ease), opacity 0.4s;
}
/* Show the icon of the theme you'd switch TO */
.theme-toggle .icon-sun { transform: translateY(140%) rotate(-90deg); opacity: 0; }
:root[data-theme="dark"] .theme-toggle .icon-sun { transform: none; opacity: 1; }
:root[data-theme="dark"] .theme-toggle .icon-moon { transform: translateY(-140%) rotate(90deg); opacity: 0; }

.nav-toggle { display: none; width: 40px; height: 40px; position: relative; margin-left: auto; }
.nav-toggle span {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 1px;
  background: var(--ink);
  transition: transform 0.4s var(--ease);
}
.nav-toggle span:first-child { top: 16px; }
.nav-toggle span:last-child { top: 24px; }
.nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-cta { display: none; }
  .nav-toggle { display: block; margin-left: 0; }
  .theme-toggle { margin-left: auto; }
  .nav-links {
    position: fixed;
    inset: 0;
    z-index: -1;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    padding: 0 var(--gutter);
    background: var(--bg);
    clip-path: inset(0 0 100% 0);
    transition: clip-path 0.7s var(--ease);
  }
  .nav-links a { font-family: var(--serif); font-size: 44px; color: var(--ink); }
  .nav.is-open .nav-links { clip-path: inset(0 0 0 0); }
}

/* ---------- Fallback when animation libraries fail to load ---------- */

.no-motion .about-img-wrap { clip-path: none; }
.no-motion .about-img-wrap img { transform: none; height: 100%; }
.no-motion .skill-bar span { transform: scaleX(0.92); }
.no-motion .hero-role-words span:not(:first-child) { display: none; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .grain { animation: none; }
}
