/* ==========================================================================
   DESIGN TOKENS & VARIABLES
   ========================================================================== */
:root {
  /* Neutrals only: creamy + white + black + soft gray */
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #111111;
  --muted: #6f6f6f;
  --line: rgba(0, 0, 0, .08);

  --nav-bg: rgba(247, 245, 242, .84);
  --radius: 18px;
  --shadow: 0 10px 26px rgba(0, 0, 0, .06);
  --container: 1100px;
  
  /* Responsive Spacing */
  --section-padding: 56px;
  --grid-gap: 18px;
}

[data-theme="dark"] {
  --bg: #101010;
  --surface: #171717;
  --text: #f2f2f2;
  --muted: #bdbdbd;
  --line: rgba(255, 255, 255, .10);

  --nav-bg: rgba(16, 16, 16, .75);
  --shadow: 0 14px 34px rgba(0, 0, 0, .55);
}

/* ==========================================================================
   BASE STYLES (Mobile-First)
   ========================================================================== */
* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.25s ease;
}

/* Typography */
h1, h2, h3 {
  font-family: "Playfair Display", Georgia, serif;
  letter-spacing: .2px;
  margin: 0 0 12px;
  line-height: 1.25;
}

p {
  margin: 0 0 14px;
  color: var(--muted);
}

[data-i18n="about_p"] {
  white-space: pre-line;
}

.kicker {
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Layout Elements */
.container {
  width: min(var(--container), calc(100% - 40px));
  margin-inline: auto;
}

.section {
  padding: var(--section-padding) 0;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.brand {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: 20px;
  z-index: 1001;
}

/* Links Drawer (Mobile) */
.nav__links {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(320px, 85vw);
  height: 100vh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 100px 40px;
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.1);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  gap: 12px;
}

/* RTL Support for Mobile Menu */
html[lang="ar"] .nav__links {
  right: auto;
  left: -100%;
  box-shadow: 20px 0 40px rgba(0, 0, 0, 0.1);
}

.nav__links.is-active {
  right: 0;
}

html[lang="ar"] .nav__links.is-active {
  left: 0;
  right: auto;
}

.nav__links a {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s ease;
  transition-delay: calc(var(--i) * 0.08s);
}

.nav__links.is-active a {
  opacity: 1;
  transform: translateY(0);
}

.nav__controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Hide Contact/View Work button in header on mobile to prevent overflow */
.nav__controls > .btn {
  display: none;
}

/* Hamburger */
.nav__toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 28px;
  cursor: pointer;
  z-index: 1001;
  padding: 4px;
}

.nav__toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 9px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav__toggle.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.is-active span:nth-child(2) { opacity: 0; }
.nav__toggle.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.nav__overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: all 0.25s ease;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn--primary {
  background: var(--text);
  border-color: transparent;
  color: var(--surface);
}

[data-theme="dark"] .btn--primary {
  color: var(--bg);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  cursor: pointer;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: var(--bg);
}

/* Language Dropdown */
.lang-dropdown { position: relative; }
.lang-dropdown__menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  list-style: none;
  padding: 6px;
  margin: 0;
  z-index: 1010;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
}

html[lang="ar"] .lang-dropdown__menu { transform-origin: top left; }
.lang-dropdown.is-open .lang-dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.lang-dropdown__menu button {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

html[lang="ar"] .lang-dropdown__menu button { text-align: right; flex-direction: row-reverse; }
.lang-dropdown__menu button:hover,
.lang-dropdown__menu button.is-active {
  background: var(--bg);
  color: var(--text);
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: center;
}

.hero__text {
  text-align: center;
}

.hero__title {
  font-size: clamp(32px, 8vw, 48px);
  margin-top: 8px;
}

.hero__desc {
  font-size: 17px;
  max-width: 500px;
  margin-inline: auto;
}

.hero__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
}

.hero__img {
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  aspect-ratio: 1 / 1.1;
}

.hero__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: 1fr;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: transform 0.3s ease;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.list li {
  color: var(--muted);
  font-size: 14px;
}

.list li strong {
  color: var(--text);
  font-weight: 600;
}

/* Social Links */
.social-links {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 20px;
}

.social-links li a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.social-links li a:hover {
  background: var(--bg);
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

/* ==========================================================================
   WORK / PROJECTS
   ========================================================================== */
.project {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project__thumb {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 3;
}

.project__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project__title {
  font-size: 20px;
  margin: 0;
}

.project__meta {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
}

/* Carousel Inner Logic */
.carousel { position: relative; width: 100%; height: 100%; }
.carousel__viewport { overflow: hidden; width: 100%; height: 100%; }
.carousel__track { display: flex; height: 100%; transition: transform .3s ease; will-change: transform; }
.carousel__slide { flex: 0 0 100%; width: 100%; height: 100%; padding: 10px; display: flex; align-items: center; justify-content: center; }
.carousel__slide img { width: 100%; height: 100%; object-fit: contain; }

.carousel__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 20px;
}

[data-theme="dark"] .carousel__btn { background: rgba(30, 30, 30, 0.8); }
.carousel__btn--prev { left: 8px; }
.carousel__btn--next { right: 8px; }

/* ==========================================================================
   CERTIFICATES
   ========================================================================== */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.thumb {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background-color: var(--surface);
  aspect-ratio: 16 / 10;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.thumb__ph {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

/* Hide placeholder if image exists */
.thumb[style*="background-image"] .thumb__ph { display: none; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
  padding: 40px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

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

/* Utility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ==========================================================================
   MEDIA QUERIES (DESKTOP SCALING)
   ========================================================================== */
@media (min-width: 768px) {
  :root {
    --section-padding: 80px;
    --grid-gap: 24px;
  }

  /* Nav Desktop */
  .nav__inner { padding: 18px 0; }
  .nav__toggle { display: none; }
  .nav__links {
    position: static;
    height: auto;
    width: auto;
    flex-direction: row;
    padding: 0;
    box-shadow: none;
    background: transparent;
    gap: 24px;
  }
  .nav__links a {
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
    padding: 0;
    border: 0;
    opacity: 1;
    transform: none;
  }
  .nav__links a:hover { color: var(--text); }

  /* Restore Contact/View Work button in header on desktop */
  .nav__controls > .btn {
    display: inline-flex;
  }

  /* Hero Desktop */
  .hero {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 64px;
    text-align: left;
  }
  .hero__text { text-align: left; }
  .hero__desc { margin-inline: 0; }
  .hero__actions { justify-content: flex-start; }
  .hero__img { aspect-ratio: inherit; height: 460px; }

  /* Grids Desktop */
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }

  /* Footer Desktop */
  .footer__inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

@media (min-width: 1200px) {
  .hero__title { font-size: 56px; }
  .hero__img { height: 520px; }
}

/* Language specific font overrides */
html[lang="ar"] body { font-family: "Cairo", sans-serif; }
html[lang="en"] body { font-family: "Inter", sans-serif; }