/* ═══════════════════════════════════════════════════════════════
   Michael Mansour — editorial identity
   Design tokens are the ONLY block that differs between the
   founder (dark) and academic (light) branches. Everything else
   is shared structural CSS.
   ═══════════════════════════════════════════════════════════════ */
:root {
  /* — theme (academic / light) — */
  --bg:            #F4F1EA;
  --bg-2:          #FBFAF6;
  --bg-3:          #FFFFFF;
  --text:          #16151A;
  --text-muted:    rgba(22, 21, 26, 0.66);
  --text-dim:      rgba(22, 21, 26, 0.42);
  --border:        rgba(22, 21, 26, 0.12);
  --border-strong: rgba(22, 21, 26, 0.24);
  --accent:        #C6552B;
  --accent-strong: #A8431F;
  --accent-ink:    #FBFAF6;
  --accent-soft:   rgba(198, 85, 43, 0.12);
  --grain-opacity: 0.03;
  --shadow:        rgba(54, 40, 30, 0.18);

  /* — shared — */
  --wrap: 1180px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-sans:    'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Fixed grain overlay — never on a scrolling container (perf). */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

a { color: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

/* ── Layout primitives ─────────────────────────── */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 4rem);
}

/* Home is a single screen: hero fills the viewport, marquee pins to the bottom edge. */
main {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kicker .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .kicker .dot { animation: breathe 2.6s var(--ease) infinite; }
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); opacity: 1; }
  50%      { box-shadow: 0 0 0 6px transparent; opacity: 0.7; }
}

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.9rem 1.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  will-change: transform;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease),
              color 0.3s var(--ease), border-color 0.3s var(--ease),
              box-shadow 0.3s var(--ease);
}

.btn .arrow { transition: transform 0.3s var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }
.btn:active { transform: translateY(1px) scale(0.98); }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 14px 30px -12px var(--accent-soft);
}

.btn-ghost { color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--text); background: var(--bg-2); }

/* ── Hero ──────────────────────────────────────── */
.hero {
  flex: 1;
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.2rem, 11vw, 7rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  margin: 1.4rem 0 1.6rem;
}

.hero-title .accent { color: var(--accent); }

.hero-bio {
  max-width: 46ch;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  line-height: 1.55;
  color: var(--text-muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 2rem 0 1.6rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.hero-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0;
  transition: color 0.25s var(--ease);
}

.hero-links a:hover { color: var(--accent); }

/* Portrait */
.hero-portrait { position: relative; justify-self: end; width: 100%; max-width: 360px; }

.portrait-frame {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  aspect-ratio: 4 / 5;
  will-change: transform;
  transform-style: preserve-3d;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
  box-shadow: 0 30px 60px -30px var(--shadow);
}

.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.15) contrast(1.02);
}

.portrait-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, transparent 55%, var(--accent-soft));
  pointer-events: none;
}

.portrait-tag {
  position: absolute;
  bottom: 0.9rem;
  left: 0.9rem;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Marquee ───────────────────────────────────── */
.marquee {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  padding: 1.1rem 0;
  background: var(--bg-2);
  --marquee-mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: var(--marquee-mask);
  mask-image: var(--marquee-mask);
}

.marquee-track {
  display: flex;
  gap: 2.5rem;
  width: max-content;
  will-change: transform;
  animation: marquee 34s linear infinite;
}

.marquee-track span {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.marquee-track span.mk { color: var(--accent); }

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── Page intro (inner pages) ──────────────────── */
.page-intro {
  padding-block: clamp(3rem, 8vw, 6rem) clamp(2rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  margin: 1.2rem 0 0;
}

.page-sub {
  margin-top: 1.3rem;
  max-width: 52ch;
  font-size: 1.08rem;
  color: var(--text-muted);
}

/* ── Projects (editorial index) ────────────────── */
.projects { padding-block: clamp(1.5rem, 4vw, 3rem) 4rem; }

.project {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: clamp(2rem, 5vw, 3.4rem) 0;
  border-top: 1px solid var(--border);
}

.project:last-child { border-bottom: 1px solid var(--border); }

.project-index {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
  padding-top: 0.35rem;
}

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.project-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 3.5vw, 2.6rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  transition: color 0.3s var(--ease);
}

.project:hover .project-title { color: var(--accent); }

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
}

.project-tags li {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

.project-desc {
  margin: 1.1rem 0 1.3rem;
  max-width: 68ch;
  color: var(--text-muted);
  font-size: 1rem;
}

.project-when { display: block; margin-top: 0.5rem; color: var(--text-muted); }

.project-points { padding-left: 1.1rem; display: grid; gap: 0.5rem; }

.back {
  display: block;
  width: fit-content;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.25s var(--ease);
}

.back:hover { color: var(--accent); }

.project-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.4rem; }

.project-links a:not(.btn) {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  color: var(--text);
  padding-bottom: 2px;
  transition: color 0.25s var(--ease);
}

.project-links a:not(.btn)::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}

.project-links a:not(.btn):hover { color: var(--accent); }
.project-links a:not(.btn):hover::after { transform: scaleX(1); }

/* horizontal media strip */
.media-strip {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.7rem;
  padding-bottom: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.media-strip img {
  height: clamp(150px, 22vw, 230px);
  width: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  object-fit: contain;
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: transform 0.4s var(--ease), border-color 0.3s var(--ease);
}

.media-strip img:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
}

/* ── Experience (indexed rows) ─────────────────── */
.timeline { padding-block: clamp(1.5rem, 4vw, 3rem) 4rem; }

.xp {
  display: grid;
  grid-template-columns: minmax(84px, 150px) 1fr;
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.8rem, 4vw, 2.8rem) 0;
  border-top: 1px solid var(--border);
}

.xp:last-child { border-bottom: 1px solid var(--border); }

.xp-year {
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--accent);
  letter-spacing: -0.01em;
  padding-top: 0.2rem;
}

.xp-role {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.xp-org {
  margin: 0.5rem 0 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.xp-org .tag {
  color: var(--accent);
}

.xp-note {
  color: var(--text-muted);
  font-size: 0.98rem;
  margin-top: 0.4rem;
  max-width: 70ch;
}

.xp-note a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent);
  transition: color 0.25s var(--ease);
}

.xp-note a:hover { color: var(--accent); }

/* ── CV panels ─────────────────────────────────── */
.cv { padding-block: clamp(2rem, 5vw, 3.5rem) 4rem; }

.cv-panels {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.cv-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: clamp(1.6rem, 3vw, 2.4rem);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-2);
  text-decoration: none;
  color: var(--text);
  min-height: 220px;
  transition: transform 0.4s var(--ease), border-color 0.3s var(--ease),
              box-shadow 0.4s var(--ease);
}

.cv-panel:hover {
  transform: translateY(-5px);
  border-color: var(--border-strong);
  box-shadow: 0 28px 50px -30px var(--shadow);
}

.cv-panel:active { transform: translateY(-1px) scale(0.995); }

.cv-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
}

.cv-arrow {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--accent);
  transition: transform 0.35s var(--ease);
}

.cv-panel:hover .cv-arrow { transform: translate(4px, -4px); }

.cv-panel h3 {
  margin-top: auto;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.02em;
}

.cv-panel p { color: var(--text-muted); font-size: 0.95rem; }

/* ── Scroll reveal ─────────────────────────────── */
body.js-motion [data-reveal] {
  opacity: 0;
  transform: translateY(22px);
}

body.js-motion [data-reveal].in-view {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: calc(var(--reveal-i, 0) * 70ms);
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .hero-portrait {
    justify-self: start;
    max-width: 260px;
    order: -1;
  }
}

/* Short laptop viewports: shrink the hero so it still fits one screen. */
@media (min-width: 861px) and (max-height: 700px) {
  .hero { padding-block: 1.5rem; }
  .hero-title { font-size: clamp(3.2rem, 9vw, 5.5rem); }
  .hero-portrait { max-width: 300px; }
}

@media (max-width: 620px) {
  .project { grid-template-columns: 1fr; gap: 0.5rem; }
  .project-index { padding-top: 0; }
  .xp { grid-template-columns: 1fr; gap: 0.5rem; }
  .cv-panels { grid-template-columns: 1fr; }
}

/* ── Reduced motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .marquee-track { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
