/* =========================================================================
   M.O.B. Jihad — portfolio
   Design system: "Warm Sand" — warm light default + espresso-night dark toggle.
   Elegant serif display (Instrument Serif), clean sans (Inter), mono labels (IBM Plex Mono).
   ========================================================================= */

/* ----- Theme tokens ----- */
:root {
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --maxw: 1140px;
  --pad: clamp(1.15rem, 4vw, 2.5rem);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Warm Sand (default) — cozy, premium, light */
[data-theme="light"] {
  --bg: #f4efe6;            /* sand */
  --bg-2: #ece4d6;          /* deeper sand for alt sections */
  --bg-elev: #fbf8f2;       /* cream for cards */
  --line: rgba(43, 37, 32, 0.12);
  --line-strong: rgba(43, 37, 32, 0.24);
  --ink: #2b2520;           /* espresso */
  --ink-soft: #5c5347;
  --ink-faint: #6b6052;
  --accent: #a04727;        /* deep terracotta (AA-legible as text on sand) */
  --accent-2: #7d5d34;      /* warm ochre/bronze */
  --accent-ink: #fdf7f1;
  --glow: rgba(160, 71, 39, 0.13);
  --shadow: 0 24px 50px -30px rgba(70, 45, 25, 0.30);
  --card: #fbf8f2;
  color-scheme: light;
}

/* Warm dark (toggle) — "espresso night" */
[data-theme="dark"] {
  --bg: #1c1814;
  --bg-2: #221d18;
  --bg-elev: #2a241e;
  --line: rgba(255, 247, 235, 0.09);
  --line-strong: rgba(255, 247, 235, 0.18);
  --ink: #f0e9dd;           /* warm parchment */
  --ink-soft: #c3b6a4;
  --ink-faint: #9b9080;
  --accent: #e07a4f;        /* terracotta, brightened for dark bg */
  --accent-2: #d9a85a;      /* warm ochre/gold */
  --accent-ink: #2a1a10;
  --glow: rgba(224, 122, 79, 0.16);
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.7);
  --card: rgba(255, 247, 235, 0.035);
  color-scheme: dark;
}

/* Light theme needs real elevation — a faint fill on a warm bg reads as flat without it */
[data-theme="light"] .paper,
[data-theme="light"] .rcard,
[data-theme="light"] .skillgroup,
[data-theme="light"] .article {
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04), 0 14px 30px -24px rgba(20, 30, 50, 0.5);
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
em { font-style: italic; }

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }
.mono { font-family: var(--font-mono); font-size: 0.72em; letter-spacing: 0.08em; text-transform: uppercase; }

.skip-link {
  position: absolute; left: 50%; top: -60px; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink); padding: 0.6rem 1.1rem;
  border-radius: 0 0 10px 10px; font-weight: 600; z-index: 200; transition: top 0.2s;
}
.skip-link:focus { top: 0; }

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

/* ----- Reveal-on-scroll (gated behind .js so content stays visible without JS) ----- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
/* light stagger for grid children so cards don't animate in lockstep */
.js .skills .reveal:nth-child(2), .js .writing .reveal:nth-child(2), .js .projects .reveal:nth-child(2) { transition-delay: 0.06s; }
.js .skills .reveal:nth-child(3), .js .writing .reveal:nth-child(3), .js .projects .reveal:nth-child(3) { transition-delay: 0.12s; }
.js .skills .reveal:nth-child(n+4), .js .writing .reveal:nth-child(n+4) { transition-delay: 0.18s; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } }

/* =========================================================================
   NAV
   ========================================================================= */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), backdrop-filter 0.3s;
  border-bottom: 1px solid transparent;
}
.nav.is-stuck {
  background: var(--bg);                                       /* fallback if color-mix unsupported */
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-color: var(--line);
}
.nav__inner {
  max-width: var(--maxw); margin-inline: auto; padding: 0.85rem var(--pad);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 600; letter-spacing: -0.01em; }
.brand__mark { color: var(--accent); display: inline-flex; }
.brand__name { font-size: 1.02rem; }

.nav__links { display: flex; gap: 0.35rem; }
.nav__links a {
  font-size: 0.92rem; color: var(--ink-soft); padding: 0.45rem 0.7rem; border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.nav__links a:hover { color: var(--ink); background: var(--card); }

.nav__actions { display: flex; align-items: center; gap: 0.6rem; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); cursor: pointer; display: grid; place-items: center;
  transition: border-color 0.2s, transform 0.2s, color 0.2s;
}
.theme-toggle:hover { transform: rotate(18deg); border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.92rem;
  padding: 0.7rem 1.25rem; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; transition: transform 0.18s var(--ease), background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.btn--solid { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 0 var(--glow); }
.btn--solid:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -12px var(--glow); }
.btn--ghost { border-color: var(--line-strong); color: var(--ink); background: var(--card); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.nav__cv { padding: 0.5rem 1rem; font-size: 0.88rem; }

.nav__burger { display: none; width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--card); cursor: pointer; flex-direction: column; gap: 5px; align-items: center; justify-content: center; }
.nav__burger span { width: 18px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.25s, opacity 0.2s; }

/* =========================================================================
   HERO
   ========================================================================= */
.hero { position: relative; min-height: 100svh; display: flex; align-items: center;
  padding-top: 6rem; padding-bottom: 4rem; overflow: hidden; }
.hero__sky { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero::after { /* radial vignette + glow */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 80% at 75% 12%, var(--glow), transparent 55%),
    radial-gradient(100% 70% at 0% 100%, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 60%);
}
.hero__inner { position: relative; z-index: 2; }

.eyebrow { display: inline-flex; align-items: center; gap: 0.6rem; font-family: var(--font-mono);
  font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft);
  border: 1px solid var(--line); background: var(--card); padding: 0.4rem 0.85rem; border-radius: 999px; }
.eyebrow__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.6s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }

.hero__name {
  font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.02em; line-height: 0.98;
  font-size: clamp(3.2rem, 11vw, 8rem); margin: 1.4rem 0 0.4rem;
  font-optical-sizing: auto; text-wrap: balance;
}
.hero__tagline { font-family: var(--font-serif); font-weight: 400; font-size: clamp(1.35rem, 3.4vw, 2.1rem);
  line-height: 1.25; color: var(--ink); max-width: 22ch; }
.hero__tagline em { color: var(--accent); font-style: italic; }
.hero__lede { margin-top: 1.5rem; max-width: 56ch; color: var(--ink-soft); font-size: 1.06rem; }

.hero__cta { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 2rem; }
.hero__meta { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1.8rem; margin-top: 2.5rem; }
.hero__meta li { font-size: 0.95rem; color: var(--ink); }
.hero__meta .mono { display: block; color: var(--ink-faint); margin-bottom: 0.15rem; }

.hero__scroll { position: absolute; bottom: 1.8rem; left: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem; color: var(--ink-faint); }
.hero__scroll-line { width: 1px; height: 38px; background: linear-gradient(var(--accent), transparent); }
.hero__scroll .mono { font-size: 0.62rem; }

/* =========================================================================
   SECTIONS
   ========================================================================= */
.section { padding: clamp(4.5rem, 10vw, 8rem) 0; position: relative; }
.section--alt { background: var(--bg-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.section__label { color: var(--accent); display: inline-flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.section__label span { color: var(--ink-faint); }
.section__title { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.02em;
  font-size: clamp(1.9rem, 4.6vw, 3rem); line-height: 1.08; max-width: 24ch; text-wrap: balance; }
.section__intro { margin-top: 1.2rem; max-width: 60ch; color: var(--ink-soft); font-size: 1.08rem; }

/* ----- About ----- */
.about { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
.about__photo { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--bg-elev); box-shadow: var(--shadow); aspect-ratio: 4 / 5; }
.about__photo img { width: 100%; height: 100%; object-fit: cover; }
.about__callsign { position: absolute; bottom: 0.8rem; left: 0.8rem; background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--accent); border: 1px solid var(--line-strong);
  padding: 0.3rem 0.7rem; border-radius: 8px; letter-spacing: 0.14em; }
.about__prose { margin-top: 1.4rem; display: grid; gap: 1rem; color: var(--ink-soft); }
.about__prose strong { color: var(--ink); font-weight: 600; }
.about__facts { list-style: none; padding: 1.4rem 0 0; margin-top: 1.4rem; border-top: 1px solid var(--line); display: grid; gap: 0.7rem; }
.about__facts li { font-size: 0.96rem; color: var(--ink); }
.about__facts .mono { color: var(--ink-faint); margin-right: 0.7rem; display: inline-block; min-width: 5.2rem; }

/* ----- Research ----- */
.research-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 1.4rem; margin-top: 2.6rem; }
.paper { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.4rem, 3vw, 2.1rem); position: relative; overflow: hidden; }
.paper::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--accent), var(--accent-2)); }
.paper__tag { color: var(--accent); margin-bottom: 1rem; }
.paper__title { font-family: var(--font-serif); font-weight: 400; font-size: 1.5rem; line-height: 1.15; }
.paper__authors { font-size: 0.86rem; color: var(--ink-soft); margin-top: 0.7rem; line-height: 1.5; }
.paper__authors strong { color: var(--accent); }
.paper__desc { margin-top: 1rem; color: var(--ink-soft); font-size: 0.98rem; }
.paper__desc strong { color: var(--ink); }
.paper__links { margin-top: 1.2rem; }

.research-side { display: grid; gap: 1.4rem; align-content: start; }
.rcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.6rem;
  transition: border-color 0.25s, transform 0.25s; }
.rcard:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.rcard__title { font-family: var(--font-serif); font-weight: 400; font-size: 1.2rem; margin-bottom: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: baseline; }
.rcard p { color: var(--ink-soft); font-size: 0.96rem; }
.rcard strong { color: var(--ink); }
.chip { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent-2); border: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent); padding: 0.18rem 0.5rem; border-radius: 999px; }

.link-arrow { color: var(--accent); font-weight: 600; font-size: 0.92rem; display: inline-flex; gap: 0.4rem; align-items: center; }
.link-arrow span { transition: transform 0.2s var(--ease); }
.link-arrow:hover span { transform: translateX(5px); }

/* ----- Projects ----- */
.projects { display: grid; gap: clamp(2.5rem, 5vw, 4.5rem); margin-top: 3rem; }
.project { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: center; }
.project--flip .project__shot { order: 2; }
.project__shot { display: block; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--bg-elev); box-shadow: var(--shadow); transition: transform 0.4s var(--ease), border-color 0.3s; }
.project__shot img { width: 100%; height: auto; transition: transform 0.6s var(--ease); }
.project__shot:hover { border-color: var(--line-strong); }
.project__shot:hover img { transform: scale(1.03); }
.project__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1rem; }
.project__title { font-family: var(--font-serif); font-weight: 400; font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -0.01em; }
.project__kind { color: var(--accent); }
.project__desc { margin-top: 1rem; color: var(--ink-soft); }
.project__desc strong { color: var(--ink); font-weight: 600; }
.project__desc code { font-family: var(--font-mono); font-size: 0.85em; background: var(--card); padding: 0.1em 0.4em; border-radius: 5px; border: 1px solid var(--line); }
.tags { list-style: none; padding: 0; margin-top: 1.3rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tags li { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.03em; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 7px; padding: 0.32rem 0.6rem; background: var(--card); }
.project__links { display: flex; flex-wrap: wrap; gap: 1.4rem; margin-top: 1.4rem; }

/* ----- Skills ----- */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1.2rem; margin-top: 2.8rem; }
.skillgroup { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.6rem;
  transition: border-color 0.25s, transform 0.25s; }
.skillgroup:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.skillgroup__title { font-family: var(--font-serif); font-weight: 400; font-size: 1.2rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.6rem; }
.skillgroup__title .mono { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-size: 0.7rem; }
.pills { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pills li { font-size: 0.84rem; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.65rem; }
.pills li em { color: var(--accent); font-style: normal; font-size: 0.9em; }

/* ----- Writing ----- */
.writing { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1.1rem; margin-top: 2.8rem; }
.article { display: flex; flex-direction: column; gap: 0.7rem; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.5rem 1.6rem; min-height: 190px;
  transition: border-color 0.25s, transform 0.25s, background 0.25s; }
.article:hover { border-color: var(--accent); transform: translateY(-4px); }
.article__pub { color: var(--accent); }
.article__title { font-family: var(--font-serif); font-weight: 400; font-size: 1.18rem; line-height: 1.25; flex: 1; }
.article__go { color: var(--ink-soft); font-size: 0.86rem; font-weight: 600; display: inline-flex; gap: 0.4rem; }
.article:hover .article__go { color: var(--accent); }

.outreach { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 2.4rem; }
.outreach__h { font-family: var(--font-serif); font-weight: 400; font-size: 1.4rem; margin-bottom: 1.4rem; }
.outreach__list { list-style: none; padding: 0; display: grid; gap: 0; }
.outreach__list li { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1.5rem; align-items: baseline;
  padding: 1rem 0; border-bottom: 1px solid var(--line); }
.outreach__role { font-weight: 600; color: var(--ink); }
.outreach__meta { color: var(--ink-faint); text-align: right; }
.outreach__note { grid-column: 1 / -1; color: var(--ink-soft); font-size: 0.94rem; }

/* ----- Timeline ----- */
.timeline { list-style: none; padding: 0; margin-top: 2.6rem; display: grid; gap: 0; }
.timeline__item { display: grid; grid-template-columns: 9rem 1fr; gap: 1.5rem; padding: 1.6rem 0; border-top: 1px solid var(--line);
  position: relative; }
.timeline__item:last-child { border-bottom: 1px solid var(--line); }
.timeline__when { color: var(--accent); padding-top: 0.3rem; }
.timeline__body h3 { font-family: var(--font-serif); font-weight: 400; font-size: 1.3rem; }
.timeline__body p { color: var(--ink-soft); margin-top: 0.4rem; font-size: 0.96rem; }

/* ----- Contact ----- */
.contact { text-align: center; }
.contact__inner { max-width: 760px; }
.contact__title { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.02em;
  font-size: clamp(2rem, 6vw, 3.6rem); line-height: 1.05; margin-top: 0.6rem; text-wrap: balance; }
.contact__lede { margin: 1.4rem auto 0; max-width: 52ch; color: var(--ink-soft); }
.contact__email { display: inline-block; margin-top: 2rem; font-family: var(--font-serif); font-style: italic;
  font-size: clamp(1.3rem, 4vw, 2rem); color: var(--accent); border-bottom: 1px solid transparent; transition: border-color 0.25s; }
.contact__email:hover { border-bottom-color: var(--accent); }
.contact__links { list-style: none; padding: 0; margin: 2.4rem 0 0; display: flex; flex-wrap: wrap; gap: 0.8rem; justify-content: center; }
.contact__links a { display: inline-flex; gap: 0.5rem; align-items: center; border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 0.6rem 1.1rem; font-size: 0.92rem; transition: border-color 0.2s, color 0.2s, transform 0.2s; }
.contact__links a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.contact__links .mono { color: var(--ink-faint); }
.contact__links a:hover .mono { color: var(--accent); }

/* ----- Footer ----- */
.footer { border-top: 1px solid var(--line); padding: 2rem 0; color: var(--ink-faint); font-size: 0.88rem; }
.footer__inner { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: space-between; align-items: center; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 920px) {
  .about { grid-template-columns: 1fr; }
  .about__media { max-width: 360px; }
  .research-grid { grid-template-columns: 1fr; }
  .project, .project--flip { grid-template-columns: 1fr; }
  .project--flip .project__shot { order: 0; }
}

@media (max-width: 760px) {
  .nav__links { display: none; }
  .nav__burger { display: flex; }
  .nav__cv { display: none; }

  /* mobile dropdown menu */
  .nav.is-open .nav__links {
    display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-2); border-bottom: 1px solid var(--line); padding: 0.6rem var(--pad) 1.2rem; gap: 0.2rem;
  }
  .nav.is-open .nav__links a { padding: 0.8rem 0.5rem; font-size: 1rem; border-bottom: 1px solid var(--line); }
  .nav.is-open .nav__burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav.is-open .nav__burger span:nth-child(2) { opacity: 0; }
  .nav.is-open .nav__burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .hero__meta { gap: 1.2rem; }
  .outreach__list li { grid-template-columns: 1fr; }
  .outreach__meta { text-align: left; }
  .timeline__item { grid-template-columns: 1fr; gap: 0.4rem; }
}
