/* ==========================================================================
   Dr. Ali H Alqarni — site styles
   Palette inspired by the Saudi DGA "Platforms Code" design system.
   ========================================================================== */

:root {
  /* Royal herbal green */
  --green-50: #f2f6ef;
  --green-100: #e1ebdb;
  --green-600: #2e6b43;
  --green-700: #275c39;
  --green-800: #1e4a2d;
  --green-900: #14331f;
  /* Royal gold */
  --gold-100: #f7f0de;
  --gold-300: #e3cb8c;
  --gold-500: #c9a24a;
  --gold-600: #a8822e;
  --gold-800: #6f531a;

  --bg: #ffffff;
  --bg-soft: #fbf8f0;
  --border: #e9e2cf;
  --text: #1c2420;
  --muted: #55615b;

  --radius: 12px;
  --radius-sm: 8px;
  --container: 960px;
  --header-h: 68px;

  --font-en: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(201, 162, 74, 0.18);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh; /* iPhone: account for Safari's collapsing toolbars */
  overflow-x: hidden;
  overflow-wrap: break-word;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  color: var(--green-900);
  line-height: 1.3;
  font-weight: 700;
}
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

a {
  color: var(--green-700);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--green-900); }

:focus-visible {
  outline: 3px solid var(--green-600);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  /* Respect the iPhone notch / rounded corners in landscape */
  padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right));
}

.skip-link {
  position: absolute;
  inset-inline-start: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--green-800);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 12px; color: #fff; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.97);
  border-top: 4px solid var(--green-800);
  border-image: linear-gradient(90deg, var(--green-800) 0%, var(--green-600) 35%, var(--gold-500) 50%, var(--green-600) 65%, var(--green-800) 100%) 1;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(201, 162, 74, 0.25);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
}
.brand {
  margin-inline-end: auto;
  color: var(--green-900);
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--green-700); }

.site-nav ul {
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 14px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.site-nav a:hover { color: var(--green-800); background: var(--green-50); }
.site-nav a[aria-current="page"] {
  color: var(--green-800);
  background: var(--green-50);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--gold-500);
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  place-items: center;
}
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--green-900);
  border-radius: 2px;
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; inset-inline-start: 0; }
.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Page structure ---------- */
main { flex: 1; }

.page-head {
  background: rgba(251, 248, 240, 0.82);
  border-bottom: 1px solid var(--border);
  padding-block: 40px 36px;
}
.page-head h1 { font-size: 2rem; }

.section { padding-block: 40px; }
.section + .section { padding-top: 0; }
.section h2 {
  font-size: 1.25rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---------- Home ---------- */
body[data-page="home"] main {
  display: flex;
  align-items: center;
}
.profile {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 36px;
  align-items: start;
  padding-block: 56px;
}
.profile-photo {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 28%;
  background: var(--bg-soft);
  border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px var(--gold-300), 0 0 0 5px var(--gold-100), 0 0 0 6px var(--gold-300);
}
.profile h1 { font-size: 2rem; }
.profile-title {
  margin-top: 6px;
  color: var(--green-700);
  font-weight: 600;
  font-size: 1.0625rem;
}
.profile-affiliation {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9375rem;
}
.profile-bio {
  margin-top: 20px;
  max-width: 62ch;
}
.profile .social { margin-top: 24px; }
.founder {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9375rem;
}
.founder a { font-weight: 600; font-family: var(--font-en); }

/* ---------- Social icon buttons ---------- */
.social {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.social-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--green-700);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.social-btn:hover {
  background: var(--green-600);
  border-color: var(--green-600);
  color: #fff;
}
.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: none;
}

/* ---------- Research ---------- */
.interests {
  display: grid;
  gap: 10px;
}
.interests li {
  position: relative;
  padding-block: 12px;
  padding-inline: 20px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--gold-500);
  border-radius: var(--radius-sm);
}

.education { display: grid; }
.education li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 24px;
  align-items: baseline;
  padding-block: 14px;
  border-bottom: 1px solid var(--border);
}
.education li:first-child { padding-top: 0; }
.education li:last-child { border-bottom: 0; }
.edu-degree { font-weight: 600; color: var(--green-900); }
.edu-school { grid-column: 1; color: var(--muted); font-size: 0.9375rem; }
.edu-year {
  grid-column: 2;
  grid-row: 1;
  color: var(--green-700);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-en);
}

/* ---------- Publications ---------- */
.pub-year + .pub-year { margin-top: 32px; }
.pub-year h2 {
  font-family: var(--font-en);
  font-variant-numeric: tabular-nums;
}
.pubs { display: grid; gap: 14px; }
.pub {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.pub-type {
  display: block;
  width: fit-content;
  margin-bottom: 8px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--gold-100);
  color: var(--gold-800);
  border: 1px solid var(--gold-300);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.8;
}
.pub-body { line-height: 1.6; font-size: 0.9688rem; }
.pub-title { font-weight: 600; color: var(--text); }
.pub-title a { color: inherit; }
.pub-title a:hover { color: var(--green-700); }
.pub-meta { margin-top: 4px; color: var(--muted); }
.pub-meta strong { color: var(--text); font-weight: 600; }

.scholar-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 28px;
  padding-inline: 18px;
  border: 1px solid var(--green-600);
  border-radius: var(--radius-sm);
  color: var(--green-800);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.scholar-link:hover { background: var(--green-600); color: #fff; }

/* ---------- Contact ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.contact-card {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.contact-card h2 {
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
}
.contact-card p { color: var(--text); }
.contact-card .email {
  font-family: var(--font-en);
  font-size: 1.0625rem;
  font-weight: 600;
}
.contact-card .faculty-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
}

.profiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.profile-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.profile-link:hover { border-color: var(--green-600); background: var(--green-50); color: var(--text); }
.profile-link .icon-box {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 10px;
  background: var(--green-50);
  color: var(--green-700);
}
.profile-link:hover .icon-box { background: var(--green-600); color: #fff; }
.profile-name { display: block; font-weight: 600; font-family: var(--font-en); line-height: 1.3; }
.profile-handle {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
  font-family: var(--font-en);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* ---------- Arabic calligraphy name ---------- */
/* Background: the name repeated as a faint gold pattern (pre-rendered tile, transparent PNG) */
body {
  background-color: var(--bg);
  background-image: url("../assets/images/calligraphy-pattern.png");
  background-repeat: repeat;
  background-size: 560px 320px;
}

.calligraphy-signature {
  margin: 0;
  padding-top: 28px;
  text-align: center;
  font-family: "Aref Ruqaa", serif;
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1.4;
  color: var(--green-800);
  letter-spacing: 0;
}
.calligraphy-signature::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  margin: 6px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.875rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom)); /* clear the iPhone home indicator */
}
.footer-inner a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-en);
}

/* ---------- 404 ---------- */
.not-found {
  display: grid;
  place-items: center;
  padding: 64px 24px;
  text-align: center;
}
.not-found .not-found-code {
  font-family: var(--font-en);
  font-size: 3rem;
  font-weight: 700;
  color: var(--green-600);
  line-height: 1;
}
.not-found h1,
.not-found h2 { margin-top: 16px; font-size: 1.375rem; }
.not-found p { margin-top: 10px; color: var(--muted); }
.not-found .btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 24px;
  padding-inline: 20px;
  border-radius: var(--radius-sm);
  background: var(--green-600);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.not-found .btn:hover { background: var(--green-800); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  :root { --header-h: 60px; }
  .container { padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right)); }
  body { background-size: 640px 366px; } /* sparser pattern on phones so text stays clean */

  .nav-toggle { display: grid; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    inset-inline: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(14, 61, 41, 0.08);
  }
  .site-nav.is-open { display: block; }
  .site-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 20px 14px;
  }
  .site-nav a { min-height: 48px; }
  .site-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--gold-500); }

  .page-head { padding-block: 28px 24px; }
  .page-head h1 { font-size: 1.625rem; }
  .section { padding-block: 28px; }

  .profile {
    grid-template-columns: 1fr;
    gap: 20px;
    justify-items: center;
    text-align: center;
    padding-block: 36px;
  }
  .profile-photo { width: 128px; height: 128px; }
  .profile h1 { font-size: 1.625rem; }
  .profile-bio { text-align: start; }
  .profile .social { justify-content: center; }
  .founder { text-align: center; }

  .calligraphy-signature { font-size: 1.875rem; padding-top: 22px; }

  .contact-grid { grid-template-columns: 1fr; }
  .pub { padding: 14px 16px; }

  .footer-inner { flex-direction: column; justify-content: center; text-align: center; gap: 0; }
  .site-nav { max-height: calc(100dvh - var(--header-h)); overflow-y: auto; }
}

@media (max-width: 380px) {
  .brand { font-size: 0.9375rem; }
  .header-inner { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 0s !important;
  }
}
