/* ============================================================
   PREM MALLAH — PORTFOLIO
   premmallah.com
   
   Crisp, white, professional engineering aesthetic.
   Production-ready release.
   ============================================================ */

/* ── THEME TOKENS ─────────────────────────────────────────── */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --fs-4xl: 3rem;
  --fs-hero: clamp(2.5rem, 5vw + 1rem, 4.5rem);
  --fs-metric: clamp(3rem, 8vw, 6rem);

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;
  --sp-32: 8rem;
  --section-gap: clamp(4rem, 8vw, 6rem);

  --t-fast: 200ms ease;
  --t-theme: 300ms ease;

  --container: 1200px;
  --container-narrow: 800px;
  --nav-h: 70px;
}

[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-subtle: #F7F7F7;
  --fg: #111111;
  --fg-secondary: #666666;
  --fg-muted: #999999;
  --border: #E6E6E6;
  --border-strong: #CCCCCC;
  --accent: #0D66D0;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-subtle: #1A1A1A;
  --fg: #F7F7F7;
  --fg-secondary: #A0A0A0;
  --fg-muted: #777777;
  --border: #333333;
  --border-strong: #444444;
  --accent: #0D66D0;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background var(--t-theme), color var(--t-theme);
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent); }

/* Sliding underline for links */
.text-link {
  position: relative;
  font-weight: 500;
  color: var(--fg);
}
.text-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-fast);
}
.text-link:hover { color: var(--accent); }
.text-link:hover::after { transform: scaleX(1); }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul, ol { list-style: none; }
strong { font-weight: 600; color: var(--fg); }

::selection { background: var(--border-strong); color: var(--fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--sp-6); }
.container--narrow { max-width: var(--container-narrow); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.section { position: relative; padding-top: var(--section-gap); padding-bottom: calc(var(--section-gap) / 2); }
.divider { width: 100%; height: 1px; background: var(--border); }

/* ── NAVIGATION ──────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  z-index: 1000; background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-theme), border-color var(--t-theme);
}
.nav__inner { max-width: var(--container); margin: 0 auto; padding: 0 var(--sp-6); height: 100%; display: flex; align-items: center; justify-content: space-between; }
.nav__brand { font-weight: 600; font-size: var(--fs-sm); letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg); padding: 10px 0; }

.nav__links { display: flex; align-items: center; gap: var(--sp-6); }
.nav__link {
  font-size: var(--fs-sm); color: var(--fg-secondary); font-weight: 500;
  transition: color var(--t-fast);
  padding: 10px 0; /* Touch target */
}
.nav__link:hover { color: var(--fg); }

.nav__actions { display: flex; align-items: center; margin-left: var(--sp-6); }
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-secondary); transition: color var(--t-fast);
  width: 44px; height: 44px; /* Touch target */
}
.theme-toggle:hover { color: var(--fg); }
.theme-toggle svg { width: 18px; height: 18px; }

[data-theme="dark"] .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: block; }
[data-theme="light"] .theme-toggle__sun { display: block; }
[data-theme="light"] .theme-toggle__moon { display: none; }

.nav__mobile { display: none; }
.nav__hamburger { display: none; }

@media (max-width: 767px) {
  .nav__links { display: none; }
  .nav__actions { display: none; }
  .nav__hamburger {
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 44px; height: 44px; color: var(--fg); align-items: flex-end;
  }
  .nav__hamburger span {
    display: block; width: 24px; height: 1px; background: currentColor;
    transition: var(--t-fast);
  }
  .nav__mobile {
    position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
    background: var(--bg); padding: var(--sp-6);
    display: flex; flex-direction: column; gap: var(--sp-6);
    opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
    z-index: 999;
  }
  .nav--open .nav__mobile { opacity: 1; pointer-events: auto; }
  
  .nav__mobile .nav__link {
    font-size: var(--fs-xl); color: var(--fg); font-weight: 500;
    opacity: 0; transform: translateY(10px); transition: var(--t-fast);
    padding: 10px 0;
  }
  .nav--open .nav__mobile .nav__link { opacity: 1; transform: translateY(0); }
  /* Stagger */
  .nav--open .nav__mobile .nav__link:nth-child(1) { transition-delay: 40ms; }
  .nav--open .nav__mobile .nav__link:nth-child(2) { transition-delay: 80ms; }
  .nav--open .nav__mobile .nav__link:nth-child(3) { transition-delay: 120ms; }
  .nav--open .nav__mobile .nav__link:nth-child(4) { transition-delay: 160ms; }
  .nav--open .nav__mobile .nav__link:nth-child(5) { transition-delay: 200ms; }
}

/* ── HERO ────────────────────────────────────────────────── */
.hero { min-height: 90vh; display: flex; align-items: center; padding: calc(var(--nav-h) + var(--sp-12)) 0 var(--sp-16); overflow: hidden; }
.hero__inner { display: grid; grid-template-columns: 1fr; gap: var(--sp-12); align-items: center; overflow: hidden; }
@media (min-width: 900px) { .hero__inner { grid-template-columns: 0.85fr 1.15fr; gap: var(--sp-16); } }

.hero__content { display: flex; flex-direction: column; gap: var(--sp-6); min-width: 0; overflow: hidden; }
.hero__pre { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; color: var(--fg-secondary); letter-spacing: 0.05em; text-transform: uppercase; }
.hero__heading { font-size: var(--fs-hero); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; color: var(--fg); overflow-wrap: break-word; word-break: break-word; }
.hero__sub { font-size: var(--fs-lg); color: var(--fg-secondary); max-width: 520px; line-height: 1.6; }

.hero__links { display: flex; gap: var(--sp-8); margin-top: var(--sp-2); font-size: var(--fs-sm); }
.hero__links .text-link { padding-bottom: 2px; }

.hero__visual { display: flex; justify-content: flex-end; align-items: center; min-width: 0; }

.hero__image { width: 100%; max-width: 100%; height: auto; display: block; border-radius: 4px; }

/* ── TECH STRIP ──────────────────────────────────────────── */
.tech-strip { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-subtle); overflow: hidden; padding: var(--sp-3) 0; }
.tech-strip__inner { display: flex; gap: var(--sp-6); flex-wrap: wrap; justify-content: center; font-family: var(--font-mono); font-size: 11px; color: var(--fg-secondary); font-weight: 500; }
.tech-strip__inner span { white-space: nowrap; }

/* ── PROJECT INTRO ───────────────────────────────────────── */
.project-intro { margin-bottom: var(--sp-16); }
.project-intro__header { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-secondary); margin-bottom: var(--sp-6); }
.project-intro__title { font-size: var(--fs-4xl); font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--sp-6); line-height: 1.1; }
.project-intro__desc { font-size: var(--fs-xl); color: var(--fg-secondary); max-width: 650px; line-height: 1.5; margin-bottom: var(--sp-12); }

.project-metrics { display: flex; flex-wrap: wrap; gap: var(--sp-8); column-gap: var(--sp-16); border-top: 1px solid var(--border); padding-top: var(--sp-8); }
.metric { display: flex; flex-direction: column; }
.metric__val { font-size: var(--fs-metric); font-weight: 700; letter-spacing: -0.02em; color: var(--fg); line-height: 1; }
.metric__lbl { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-secondary); margin-top: var(--sp-2); }

/* ── CASE STUDY NARRATIVE ────────────────────────────────── */
.case-study__step { display: grid; grid-template-columns: 1fr; gap: var(--sp-6); padding: var(--sp-16) 0; border-top: 1px solid var(--border); }
@media (min-width: 768px) { .case-study__step { grid-template-columns: 320px 1fr; gap: var(--sp-16); } }

.case-study__header { display: flex; flex-direction: column; }
.case-study__num { font-family: var(--font-mono); font-size: var(--fs-base); color: var(--fg-muted); margin-bottom: var(--sp-2); }
.case-study__heading { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.case-study__content { font-size: var(--fs-lg); color: var(--fg-secondary); }
.case-study__content p { margin-bottom: var(--sp-8); }

/* Architecture Diagrams */
.case-study__diagram {
  margin-bottom: var(--sp-8); padding: var(--sp-8); border: 1px solid var(--border); background: var(--bg-subtle);
  font-family: var(--font-mono); font-size: var(--fs-xs); display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-4);
}
.cs-node {
  padding: var(--sp-2) var(--sp-4); border: 1px solid var(--border-strong); background: var(--bg); color: var(--fg); font-weight: 500;
  transition: border-color var(--t-fast), color var(--t-fast); cursor: default; white-space: nowrap;
}
.cs-node:hover { border-color: var(--accent); color: var(--accent); }
.diagram-grid { display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; width: 100%; padding: var(--sp-8); border: 1px solid var(--border); background: var(--bg-subtle); border-radius: 4px; }
.cs-arrow { font-size: 1.2rem; color: var(--fg-muted); display: flex; align-items: center; justify-content: center; }

.cs-flex-row { display: flex; flex-direction: column; gap: var(--sp-4); align-items: center; width: 100%; }
.cs-flex-row .cs-arrow { transform: rotate(90deg); margin: var(--sp-2) 0; }
@media (min-width: 600px) {
  .cs-flex-row { flex-direction: row; justify-content: flex-start; width: auto; }
  .cs-flex-row .cs-arrow { transform: none; margin: 0; }
}

@media (max-width: 899px) {
  .diagram-grid .cs-arrow { transform: rotate(90deg); margin: var(--sp-2) 0; }
}

@media (min-width: 900px) {
  .diagram-grid { 
    display: grid; 
    grid-template-columns: 1fr auto 1fr auto 1fr;
    grid-template-areas:
      "n1 a1 n2 a2 n3"
      ".  .  .  .  a3"
      "n6 a5 n5 a4 n4";
    gap: var(--sp-4);
    align-items: center;
    justify-items: center;
  }
  .diagram-grid .cs-node { width: 100%; text-align: center; justify-content: center; margin: 0; }
  .diagram-grid .cs-arrow { margin: 0; }
  .diagram-grid .arr-r { transform: none; }
  .diagram-grid .arr-d { transform: rotate(90deg); margin: var(--sp-4) 0; }
  .diagram-grid .arr-l { transform: rotate(180deg); }
}

/* ── EXPERIENCE ──────────────────────────────────────────── */
.section__header { margin-bottom: var(--sp-16); }
.section__title { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; }

.exp-item { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); padding: var(--sp-8) 0; border-top: 1px solid var(--border); }
@media (min-width: 768px) { .exp-item { grid-template-columns: 250px 1fr; gap: var(--sp-12); } }

.exp-date { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--fg-secondary); }
.exp-company { font-size: var(--fs-xl); font-weight: 600; margin-bottom: var(--sp-1); }
.exp-role { font-size: var(--fs-lg); color: var(--fg-secondary); margin-bottom: var(--sp-6); }
.exp-desc { font-size: var(--fs-base); color: var(--fg); line-height: 1.8; margin-bottom: var(--sp-6); }
.exp-focus { font-size: var(--fs-sm); color: var(--fg-secondary); line-height: 1.6; }
.exp-focus-label { font-family: var(--font-mono); color: var(--fg); }

/* ── TECH STACK ──────────────────────────────────────────── */
.stack-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-12); padding-top: var(--sp-8); border-top: 1px solid var(--border); }
.stack-col:nth-child(6) { grid-column: 1 / -1; }

@media (min-width: 600px) { 
  .stack-grid { grid-template-columns: repeat(2, 1fr); } 
}
@media (min-width: 900px) { 
  .stack-grid { grid-template-columns: repeat(4, 1fr); gap: var(--sp-8); } 
  .stack-col:nth-child(6) { grid-column: span 2; }
}

.stack-col { display: flex; flex-direction: column; }
.stack-cat { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-secondary); margin-bottom: var(--sp-6); letter-spacing: 0.05em; text-transform: uppercase; }
.stack-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.tech-item {
  display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-lg); color: var(--fg);
  transition: transform var(--t-fast), color var(--t-fast); cursor: default;
  white-space: nowrap;
}
.tech-item:hover { transform: translateX(4px); color: var(--accent); }
.tech-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.5; transition: opacity var(--t-fast); }
.tech-item:hover svg { opacity: 1; }
.tech-icon-txt {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; border: 1px solid currentColor;
  opacity: 0.5; transition: opacity var(--t-fast);
}
.tech-item:hover .tech-icon-txt { opacity: 1; }


/* ── ABOUT ───────────────────────────────────────────────── */
.about-content { font-size: var(--fs-xl); color: var(--fg-secondary); max-width: 720px; line-height: 1.6; }
.about-content p { margin-bottom: var(--sp-8); }

/* ── CONTACT ─────────────────────────────────────────────── */
#contact { padding-top: var(--sp-12); }
.contact-block { padding-top: var(--sp-8); border-top: 1px solid var(--border); }
.contact-heading { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--sp-8); max-width: 600px; color: var(--fg); line-height: 1.1; }
.contact-sub { font-size: var(--fs-lg); color: var(--fg-secondary); margin-bottom: var(--sp-8); }
.contact-links { display: flex; flex-wrap: wrap; gap: var(--sp-8); font-size: var(--fs-base); }

/* ── FOOTER ──────────────────────────────────────────────── */
.footer { padding: var(--sp-8) 0; border-top: 1px solid var(--border); }
.footer__inner { display: flex; flex-direction: column; gap: var(--sp-4); justify-content: space-between; align-items: flex-start; font-size: var(--fs-sm); color: var(--fg-secondary); }
@media (min-width: 600px) { .footer__inner { flex-direction: row; align-items: center; } }
.footer__links { display: flex; flex-wrap: wrap; gap: var(--sp-6); }
.footer__link:hover { color: var(--fg); }

/* ── UTILS ───────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(4px); transition: opacity 400ms ease, transform 400ms ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; transition: none; }
  .cv-target::after, .cv-frame__rec::before { animation: none !important; display: none; }
}
