/* ==========================================================================
   Ahmed Falah Al-Qahtani — portfolio page styles
   Consumes the Nocturne design system (_ds/.../styles.css) for all tokens.
   Layout uses CSS logical properties so one rule set serves LTR and RTL.
   ========================================================================== */

/* --- Local Arabic face ---------------------------------------------------- */
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('/uploads/woff2/thmanyahsans-Light.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('/uploads/woff2/thmanyahsans-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('/uploads/woff2/thmanyahsans-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('/uploads/woff2/thmanyahsans-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('/uploads/woff2/thmanyahsans-Black.woff2') format('woff2');
  font-weight: 900; font-style: normal; font-display: swap;
}

/* --- Page-level tokens ---------------------------------------------------- */
:root {
  --font-ar: 'Thmanyah Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-en: 'Space Grotesk', var(--font-heading);
  --shell-max: 1120px;
  --shell-pad: 32px;
}

/* --- Light theme ---------------------------------------------------------- */
html[data-theme='light'] {
  --color-bg: #f3f5fe;
  --color-surface: #e4e7f5;
  --color-text: #292b31;
  --color-divider: color-mix(in srgb, #292b31 18%, transparent);
  --color-accent: #5d5294;
  --color-accent-100: #423a6a;
  --color-accent-200: #423a6a;
  --color-accent-300: #5d5294;
  --color-accent-800: #e0dcf6;
  --color-neutral-100: #292b31;
  --color-neutral-300: #595d6c;
  --color-neutral-400: #4a4e5b;
  --color-neutral-500: #75798c;
  --color-neutral-600: #75798c;
  --color-neutral-800: #dcdfef;
  --shadow-sm: 0 0 0 1px #cfd3e5;
  --shadow-md: 0 0 0 1px #cfd3e5, 0 6px 18px rgba(41, 43, 49, 0.10);
}

/* --- Base ----------------------------------------------------------------- */
html, body { margin: 0; padding: 0; background: var(--color-bg); }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-en);
  min-height: 100vh;
  overflow-x: clip;
  transition: background .35s ease, color .35s ease;
  -webkit-font-smoothing: antialiased;
}
html[lang='ar'] body { font-family: var(--font-ar); }

a { color: var(--color-accent-300); text-decoration: none; }
a:hover { color: var(--color-accent-200); }

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

.shell {
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--shell-pad);
}

/* Accessible skip link ----------------------------------------------------- */
.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 200;
  padding: 10px 16px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  font-size: 14px;
}
.skip-link:focus { inset-inline-start: 12px; top: 12px; }

/* Scroll-reveal — only active once JS confirms it can undo it --------------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .7s cubic-bezier(.2, .7, .2, 1), transform .7s cubic-bezier(.2, .7, .2, 1);
}
.js [data-reveal][data-in] { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js [data-reveal],
  .js [data-reveal][data-in] { opacity: 1; transform: none; transition: none; }
}

/* --- Header --------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0;
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  font-family: var(--font-en);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: .01em;
}
html[lang='ar'] .brand { font-family: var(--font-ar); letter-spacing: normal; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 13px;
  color: var(--color-neutral-500);
}
html[lang='ar'] .site-nav { font-size: 14px; }

.site-nav a { color: inherit; }
.site-nav a:hover { color: var(--color-accent-300); }

.btn-lang,
.btn-theme {
  font: inherit;
  cursor: pointer;
  background: transparent;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.btn-lang {
  font-family: var(--font-ar);
  border: 1px solid var(--color-accent-600);
  color: var(--color-accent-300);
  padding: 6px 14px;
}
html[lang='ar'] .btn-lang { font-family: 'Inter', var(--font-body); }
.btn-lang:hover {
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent-200);
}

.btn-theme {
  border: 1px solid var(--color-divider);
  color: var(--color-text);
  padding: 6px 12px;
  gap: 7px;
}
html[lang='ar'] .btn-theme { font-family: var(--font-ar); }
.btn-theme:hover {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border-color: var(--color-accent-600);
}
.btn-theme .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 10px var(--color-accent-600);
  display: inline-block;
  flex: none;
}

/* --- Rules ---------------------------------------------------------------- */
.rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(to right, transparent, var(--color-divider) 48px,
              var(--color-divider) calc(100% - 48px), transparent);
}

/* --- Hero ----------------------------------------------------------------- */
.hero { position: relative; padding: 112px 0 96px; }
.hero__glow {
  position: absolute;
  inset: 0 40% 30% -30%;
  background: radial-gradient(50% 60% at 20% 40%,
              color-mix(in srgb, var(--color-accent) 22%, transparent), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
[dir='rtl'] .hero__glow {
  inset: 0 -30% 30% 40%;
  background: radial-gradient(50% 60% at 80% 40%,
              color-mix(in srgb, var(--color-accent) 22%, transparent), transparent 70%);
}
.hero__inner { position: relative; max-width: 860px; }

.hero__kicker {
  margin: 0 0 26px;
  font-family: var(--font-en);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--color-accent-300);
}
html[lang='ar'] .hero__kicker {
  margin-block-end: 24px;
  font-family: var(--font-ar);
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: none;
}

.hero__title {
  margin: 0;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-wrap: pretty;
}
html[lang='ar'] .hero__title {
  font-family: var(--font-ar);
  font-size: clamp(34px, 5.4vw, 58px);
  line-height: 1.3;
  letter-spacing: normal;
}

.hero__lede {
  margin: 32px 0 0;
  max-width: 580px;
  font-family: var(--font-en);
  font-size: 17px;
  line-height: 1.7;
  color: var(--color-neutral-400);
  text-wrap: pretty;
}
html[lang='ar'] .hero__lede {
  max-width: 600px;
  font-family: var(--font-ar);
  line-height: 1.95;
}

.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; }
html[lang='ar'] .hero__actions .btn { font-family: var(--font-ar); }

/* --- Stat band ------------------------------------------------------------ */
.stats-section { padding: 0 0 104px; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--color-divider);
  border-block: 1px solid var(--color-divider);
}
.stat { background: var(--color-bg); padding: 28px 4px; }
.stat__num {
  margin: 0 0 8px;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.02em;
}
html[lang='ar'] .stat__num { font-family: 'Inter', var(--font-body); font-size: 32px; }
.stat__num small { font-size: 17px; color: var(--color-neutral-500); }
.stat__label {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-neutral-500);
}
html[lang='ar'] .stat__label { font-family: var(--font-ar); line-height: 1.7; }

/* --- Section scaffolding -------------------------------------------------- */
.section { padding: 0 0 104px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 36px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}
html[lang='ar'] .section-head h2 {
  font-family: var(--font-ar);
  font-size: 14px;
  letter-spacing: .06em;
  text-transform: none;
}
.section-head__rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--color-divider), transparent);
}
[dir='rtl'] .section-head__rule {
  background: linear-gradient(to left, var(--color-divider), transparent);
}

/* --- Selected work -------------------------------------------------------- */
.work-list { display: grid; gap: 16px; }

.project {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg,
              color-mix(in srgb, var(--color-surface) 70%, transparent), transparent 70%);
  overflow: hidden;
}
[dir='rtl'] .project {
  background: linear-gradient(200deg,
              color-mix(in srgb, var(--color-surface) 70%, transparent), transparent 70%);
}

.project__toggle {
  width: 100%;
  text-align: start;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-family: inherit;
  color: inherit;
  padding: 32px 34px 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
  transition: background .2s ease;
}
.project__toggle:hover { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.project__toggle:focus-visible { outline-offset: -3px; }

.project__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.project__tags .tag { white-space: nowrap; }
html[lang='ar'] .project__tags .tag { font-family: var(--font-ar); }

.project__title {
  margin: 0 0 10px;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
html[lang='ar'] .project__title {
  font-family: var(--font-ar);
  font-size: 25px;
  line-height: 1.4;
  letter-spacing: normal;
}

.project__desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-neutral-400);
}
html[lang='ar'] .project__desc { font-family: var(--font-ar); line-height: 1.85; }

.project__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}
[dir='rtl'] .project__meta { align-items: flex-start; }

.project__year {
  font-size: 13px;
  color: var(--color-neutral-500);
  white-space: nowrap;
}
/* Without JS every panel stays open, so the open/close cue would lie. */
.project__cue { display: none; }
.js .project__cue { display: inline; }
.project__cue {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-accent-300);
  white-space: nowrap;
}
html[lang='ar'] .project__cue {
  font-family: var(--font-ar);
  font-size: 13px;
  letter-spacing: normal;
  text-transform: none;
}

.project__panel { padding: 0 34px 34px; }
.project__panel[hidden] { display: none; }
.project__panel-rule {
  height: 1px;
  background: linear-gradient(to right, var(--color-divider), var(--color-divider) 70%, transparent);
  margin-bottom: 26px;
}
[dir='rtl'] .project__panel-rule {
  background: linear-gradient(to left, var(--color-divider), var(--color-divider) 70%, transparent);
}

.project__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 36px;
  margin: 0 0 6px;
  max-width: 860px;
}

.col__label {
  margin: 0 0 16px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--color-accent-300);
}
html[lang='ar'] .col__label {
  font-family: var(--font-ar);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: none;
}

.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 16px; }
.bullets li {
  position: relative;
  padding-inline-start: 28px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-neutral-300);
}
.bullets li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 11px;
  width: 14px;
  height: 1px;
  background: var(--color-accent);
}
html[lang='ar'] .bullets li { font-family: var(--font-ar); line-height: 1.95; }
html[lang='ar'] .bullets li::before { top: 14px; }

/* --- About ---------------------------------------------------------------- */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 48px;
  max-width: 940px;
}
.about-grid p { margin: 0; text-wrap: pretty; }
.about__lead { font-size: 18px; line-height: 1.7; color: var(--color-text); }
.about__body { font-size: 16px; line-height: 1.75; color: var(--color-neutral-400); }
html[lang='ar'] .about__lead { font-family: var(--font-ar); line-height: 1.95; }
html[lang='ar'] .about__body { font-family: var(--font-ar); line-height: 2; }

/* --- Skills --------------------------------------------------------------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg);
}
.skill-card {
  background: var(--color-bg);
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 0 0 1px var(--color-divider);
}
.skill-card__label {
  margin: 0;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--color-accent-300);
}
html[lang='ar'] .skill-card__label {
  font-family: var(--font-ar);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: none;
}
.skill-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--color-neutral-300);
}
html[lang='ar'] .skill-list { font-family: var(--font-ar); }
.skill-list li { position: relative; padding-inline-start: 16px; }
.skill-list li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: .72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
  opacity: .75;
}

/* --- Contact -------------------------------------------------------------- */
.contact-section { padding: 0 0 120px; }
.contact-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  padding: 56px 44px;
  background: radial-gradient(120% 160% at 0% 0%,
              color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 60%);
}
[dir='rtl'] .contact-card {
  background: radial-gradient(120% 160% at 100% 0%,
              color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 60%);
}
.contact-card h2 {
  margin: 0 0 16px;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(26px, 3.5vw, 40px);
  letter-spacing: -0.02em;
  line-height: 1.15;
  max-width: 640px;
  text-wrap: pretty;
}
html[lang='ar'] .contact-card h2 {
  font-family: var(--font-ar);
  font-size: clamp(24px, 3.2vw, 36px);
  line-height: 1.45;
  letter-spacing: normal;
  max-width: 660px;
}
.contact__text {
  margin: 0 0 32px;
  max-width: 520px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-neutral-400);
}
html[lang='ar'] .contact__text { font-family: var(--font-ar); max-width: 540px; line-height: 1.95; }
.contact__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.contact__actions .btn { max-width: 100%; overflow-wrap: anywhere; }
.contact__note { margin: 30px 0 0; font-size: 13px; color: var(--color-neutral-500); }
html[lang='ar'] .contact__note { font-family: var(--font-ar); }

/* --- Footer --------------------------------------------------------------- */
.site-footer { padding: 0 0 60px; }
.site-footer .rule { margin-bottom: 24px; }
.site-footer p { margin: 0; font-size: 12px; color: var(--color-neutral-600); }
html[lang='ar'] .site-footer p { font-family: var(--font-ar); font-size: 13px; }

/* Live-site link inside a project panel. A class rather than an inline
   style attribute, because the CSP's style-src blocks those too. */
.project__link { margin: 22px 0 0; font-size: 15px; }

/* --- 404 ------------------------------------------------------------------ */
.notfound {
  position: relative;
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 0 96px;
}
.notfound__code {
  margin: 0 0 18px;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--color-accent-300);
}
.notfound__title {
  margin: 0;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.025em;
  max-width: 700px;
  text-wrap: pretty;
}
.notfound__text {
  margin: 24px 0 0;
  max-width: 520px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--color-neutral-400);
}
.notfound__text[lang='ar'] { font-family: var(--font-ar); line-height: 1.95; }
.notfound__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
  .skills-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  :root { --shell-pad: 20px; }

  /* A two-row sticky header eats too much of a short viewport. */
  .site-header {
    position: static;
    flex-wrap: wrap;
    gap: 14px;
    padding: 20px 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .brand { font-size: 17px; }
  .site-nav { flex-wrap: wrap; gap: 14px; font-size: 13px; }

  .hero { padding: 64px 0 64px; }
  .hero__lede { font-size: 16px; }
  .section, .stats-section { padding-bottom: 72px; }
  .contact-section { padding-bottom: 80px; }

  .stat { padding: 22px 4px; }
  .stat__num { font-size: 28px; }

  .project__toggle {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 24px 22px 22px;
  }
  .project__meta,
  [dir='rtl'] .project__meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
  }
  .project__title { font-size: 22px; }
  .project__panel { padding: 0 22px 26px; }
  .project__cols { gap: 28px; }

  .about-grid { gap: 32px; }
  .contact-card { padding: 36px 24px; }
  .contact__actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 400px) {
  .site-nav { gap: 10px; font-size: 12px; }
  .btn-lang, .btn-theme { padding: 5px 10px; }
}

/* --- Print ---------------------------------------------------------------- */
@media print {
  .site-header, .hero__glow, .skip-link { display: none !important; }
  .js [data-reveal] { opacity: 1 !important; transform: none !important; }
  .project__panel[hidden] { display: block !important; }
  body { background: #fff; color: #000; }
  .project, .contact-card, .skills-grid { break-inside: avoid; }
}
