/* ============================================================
   style.css — Syed Mahir Ahamed, personal academic site
   ------------------------------------------------------------
   TABLE OF CONTENTS
   1. Design tokens (colors, fonts, spacing) — CSS custom properties
   2. Reset & base styles
   3. Typography helpers (kickers, headings)
   4. Layout helpers (.container, .section)
   5. Navigation
   6. Scroll-reveal & motion utilities
   (Section-specific styles — hero, about, research, etc. — are
   appended further down as the site grows.)
   ============================================================ */

/* ------------------------------------------------------------
   1. DESIGN TOKENS
   The whole palette lives in CSS variables so the "theme shift
   on scroll" only has to swap these values. `body.theme-dark`
   is toggled by JS when a dark section reaches mid-viewport.
   ------------------------------------------------------------ */
:root {
  /* Light ("paper") theme — warm cream, ink, rust accent.
     Slightly muted/darkened off pure cream so it doesn't glare. */
  --bg:            #EFE9DB;   /* page background: warm paper    */
  --bg-raised:     #F8F3E6;   /* cards / raised surfaces        */
  --ink:           #201D1A;   /* primary text: warm near-black  */
  --ink-soft:      #5C564E;   /* secondary / muted text         */
  --accent:        #A73E22;   /* rust — links, highlights       */
  --accent-strong: #85301A;   /* darker rust for hover states   */
  --line:          rgba(32, 29, 26, 0.16);  /* hairline borders */
  --ink-halo:      rgba(0, 0, 0, 0);  /* legibility outline; JS-driven, see initThemeShift */
  --on-accent:     #F6F1E7;  /* text/icons on a solid --accent surface; JS-driven, hard-flips with --ink */

  /* Type stacks */
  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "IBM Plex Mono", "SF Mono", Menlo, monospace;

  /* Fluid spacing: clamp(min, preferred, max) scales with viewport */
  --space-section: clamp(5rem, 14vh, 9rem);
  --container-max: 1100px;
}

/* The dark palette isn't a class toggle: js/main.js (initThemeShift)
   continuously interpolates each variable above from its light value
   to a dark target as you scroll past the About→Research boundary,
   then holds at full dark for the rest of the page. */

/* ------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;   /* animate anchor jumps (#about etc.) */
  scroll-padding-top: 5rem;  /* stop anchors hiding under fixed nav */
}

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;      /* 17px — a touch larger for readability */
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* background-color deliberately has NO transition: initThemeShift in
     main.js already eases it continuously every scroll frame, so a CSS
     transition on top would just lag behind the true scroll position.
     `color` is different: initThemeShift flips --ink as a hard step (for
     legibility — see the comment in main.js), and this short transition
     just softens that one discrete flip so it reads as a quick, deliberate
     change rather than a snap, without ever lagging behind a moving
     background. */
  transition: color 0.15s ease;
  /* A soft outline in the opposite tone, invisible (alpha 0) outside the
     mid-scroll transition zone — see the long comment on --ink-halo in
     main.js. This is what keeps text readable through the one stretch of
     the fade where the background itself is too mid-toned for any single
     ink color to contrast against reliably. */
  text-shadow:
    0 0 1px var(--ink-halo),
    0 0 1px var(--ink-halo);
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}
a:hover { color: var(--accent-strong); }

/* Visible focus ring for keyboard users (accessibility) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip link is visually hidden until focused via keyboard */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--on-accent);
  border-radius: 4px;
}
.skip-link:focus { top: 1rem; }

/* ------------------------------------------------------------
   3. TYPOGRAPHY HELPERS
   ------------------------------------------------------------ */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

/* "Kicker": the small mono label above each section heading,
   e.g. "01 / About". A recurring editorial motif. */
.kicker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  display: block;
  margin-bottom: 1rem;
}

.section-title {
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-bottom: 1.5rem;
}

/* ------------------------------------------------------------
   4. LAYOUT HELPERS
   ------------------------------------------------------------ */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 2.5rem);
}

.section {
  padding-block: var(--space-section);
  position: relative;
}

/* ------------------------------------------------------------
   5. NAVIGATION
   Fixed to the top; transparent over the hero, then picks up a
   translucent blurred background once you scroll (JS adds .scrolled).
   ------------------------------------------------------------ */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

.site-nav.scrolled {
  background-color: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 1rem;
}

.nav-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.nav-name:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  list-style: none;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
}
.nav-links a:hover { color: var(--accent); }

/* Nav name: full name normally, "SMA" monogram on narrow screens
   so the nav stays on one uncrowded line */
.nav-name-short { display: none; }

@media (max-width: 640px) {
  .nav-name-full  { display: none; }
  .nav-name-short { display: inline; letter-spacing: 0.06em; }
  .nav-links { gap: 1.1rem; }
  .nav-links a { font-size: 0.78rem; }
}

/* ------------------------------------------------------------
   6. SCROLL-REVEAL & MOTION
   Elements with .reveal start invisible and slide up when JS's
   IntersectionObserver adds .visible. Users who prefer reduced
   motion see everything immediately (see media query below).
   ------------------------------------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.visible {
  opacity: 1;
  transform: none;
}
/* Stagger: later siblings in the same group wait slightly longer */
.reveal[data-delay="1"] { transition-delay: 0.12s; }
.reveal[data-delay="2"] { transition-delay: 0.24s; }
.reveal[data-delay="3"] { transition-delay: 0.36s; }

/* Screen-reader-only text: visually hidden, still announced */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------
   7. BUTTONS
   ------------------------------------------------------------ */
.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  padding: 0.8rem 1.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, transform 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background-color: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
}
.btn-primary:hover {
  background-color: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------------------
   8. HERO
   Full-viewport intro. The canvas sits behind the text (z-index)
   and is painted by js/main.js.
   ------------------------------------------------------------ */
.hero {
  min-height: 100svh;  /* svh = small viewport height, stable on mobile */
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;    /* keep the canvas from spilling out */
}

#matrix-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hero-inner {
  position: relative;
  z-index: 1;          /* text above the canvas */
  padding-block: 6rem; /* breathing room under the fixed nav */
}

.hero-name {
  font-size: clamp(3rem, 10vw, 6.5rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin-bottom: 1.75rem;
}

.hero-pitch {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  max-width: 34em;
  color: var(--ink-soft);
  margin-bottom: 2.5rem;
}
.hero-pitch strong { color: var(--ink); font-weight: 600; }
.hero-pitch em { font-family: var(--font-display); }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Scroll cue pinned to the bottom center of the hero */
.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--ink-soft);
}
.scroll-cue:hover { color: var(--accent); }

.scroll-cue-formula {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}
.scroll-cue-formula sub,
.scroll-cue-formula sup { font-size: 0.65em; }

.scroll-cue-arrow {
  font-size: 1.1rem;
  animation: bob 2.2s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(6px); }
}

/* ------------------------------------------------------------
   9. ABOUT
   Two columns on desktop (bio + facts card), stacked on mobile.
   ------------------------------------------------------------ */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  margin-bottom: 3.5rem;
}

.about-bio p + p { margin-top: 1.25rem; }
.about-bio strong { font-weight: 600; }

/* The facts card: a raised surface with a hairline border */
.about-facts {
  background-color: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.75rem;
  /* Short on purpose: --bg-raised now hard-flips (see initThemeShift in
     main.js) rather than fading with scroll, so this just softens that
     one discrete flip into a quick, decisive flick instead of a snap. */
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.fact + .fact {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.fact dt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}

.fact dd { font-size: 0.98rem; }

/* Coursework chips */
.coursework-title {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;   /* pill shape */
  color: var(--ink-soft);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

/* Stack the two About columns on narrow screens */
@media (max-width: 720px) {
  .about-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------
   10. RESEARCH
   A stack of project cards. All colors come from the theme
   variables, so the cards restyle automatically when the page
   shifts into the dark palette.
   ------------------------------------------------------------ */
.section-lede {
  max-width: 40em;
  color: var(--ink-soft);
  margin-bottom: 3rem;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.project {
  display: grid;
  grid-template-columns: 130px 1fr;  /* meta column | content */
  gap: 2rem;
  background-color: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  /* background-color shortened from 0.7s for the same reason as
     .about-facts above: --bg-raised now hard-flips instead of fading. */
  transition: background-color 0.25s ease, border-color 0.3s ease,
              transform 0.3s ease, box-shadow 0.3s ease;
}
.project:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Meta column: big editorial index numeral + status badge */
.project-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.project-index {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 400;
  line-height: 1;
  color: var(--ink-soft);
  opacity: 0.55;
}

/* Status badges */
.badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-progress {
  border: 1px solid var(--accent);
  color: var(--accent);
}
.badge-accepted {
  background-color: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
}
.badge-award {
  border: 1px solid var(--accent);
  color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Content column */
.project-title {
  font-size: clamp(1.3rem, 2.5vw, 1.6rem);
  margin-bottom: 0.35rem;
}

.project-people {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}

.project-desc {
  max-width: 44em;
  margin-bottom: 1.25rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
}

.project-link {
  display: inline-block;
  margin-top: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
}

/* On phones, the meta column becomes a horizontal row above the text */
@media (max-width: 600px) {
  .project { grid-template-columns: 1fr; gap: 1rem; }
  .project-meta {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }
  .project-index { font-size: 1.6rem; }
}

/* ------------------------------------------------------------
   11. CV
   A short, centered call-out band.
   ------------------------------------------------------------ */
.cv-inner {
  text-align: center;
  max-width: 640px;
}

.cv-blurb {
  color: var(--ink-soft);
  margin-bottom: 2rem;
}

/* ------------------------------------------------------------
   12. CONTACT
   Email on the left, calendar booking on the right.
   ------------------------------------------------------------ */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.contact-email p {
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
  max-width: 26em;
}

/* The email itself, set large so it's the focal point */
.email-link {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 600;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  overflow-wrap: anywhere; /* prevents overflow on tiny screens */
}

/* Placeholder box until the real Calendly embed goes in */
.calendar-placeholder {
  border: 2px dashed var(--line);
  border-radius: 10px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 2rem;
  color: var(--ink-soft);
}

.calendar-placeholder-icon { font-size: 2rem; }

@media (max-width: 720px) {
  .contact-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------
   13. FLOATING GLYPHS (parallax decoration)
   Oversized, near-invisible math symbols behind sections. JS
   moves them slower than the scroll for gentle depth.
   ------------------------------------------------------------ */
.float-glyph {
  position: absolute;
  top: 10%;
  right: 4vw;
  z-index: 0;
  font-family: var(--font-display);
  font-size: clamp(10rem, 22vw, 18rem);
  line-height: 1;
  color: var(--ink);
  opacity: 0.045;
  pointer-events: none;   /* never intercept clicks */
  user-select: none;
  will-change: transform; /* hint: this element animates */
}
/* Keep sections' content above the glyphs */
.section > .container { position: relative; z-index: 1; }

/* ------------------------------------------------------------
   14. FOOTER
   ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2.5rem 2rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.footer-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
}

.footer-role {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}
.footer-links a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.footer-meta p {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------
   15. METAMORPHOSIS MASCOT
   One fixed creature that JS moves around the viewport as you
   scroll, cross-fading between three forms. This block covers
   the box, the stacked SVG stages, and their idle "alive"
   animations. The scroll-driven position/opacity live in JS.
   ------------------------------------------------------------ */
#mascot {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;               /* under the nav (50), over the page */
  width: var(--mascot-size, 132px);
  height: var(--mascot-size, 132px);
  pointer-events: none;      /* never block clicks on the real page */
  /* JS writes translate() into --mx/--my every frame; keeping the
     transform here (not inline) lets the browser cheaply composite it. */
  transform: translate3d(var(--mx, 24px), var(--my, 70vh), 0)
             rotate(var(--mrot, 0deg));
  will-change: transform;
}

/* The box is the shared stage; each form is absolutely stacked inside
   and centered, so cross-fading never shifts the silhouette. */
.mascot-box {
  position: relative;
  width: 100%;
  height: 100%;
}

.mascot-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;                 /* limbs can spill the box */
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.16));
}

/* --- the figure rig ---
   All motion (hang → slip → fall → land, and the Superman flight back
   up) is driven from JS, which rotates the joint groups every frame.
   CSS only handles the face cross-fade and the cape flutter. */
#hero-face-fall, #hero-face-land, #hero-face-hang { transition: opacity 0.25s ease; }

/* Cape flutter (only visible while flying — JS controls its opacity). */
#hero-cape {
  transform-box: view-box;
  transform-origin: 100px 98px;      /* pivots at the shoulders */
  animation: cape-flutter 2.1s ease-in-out infinite;
}
@keyframes cape-flutter {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

/* The thread (#hero-rope) lives inside the figure's SVG now, so it needs
   no positioning CSS — its endpoints are set per-frame in JS. */

/* A touch smaller on phones so it stays a garnish, not a blocker */
@media (max-width: 640px) {
  #mascot { width: 92px; height: 92px; }
}

/* Respect the OS-level "reduce motion" setting: kill animations,
   show content instantly, disable smooth scrolling. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
  /* The mascot still appears and still changes form with scroll —
     it just holds each pose still instead of crawling/flapping. */
}
