/* ============================================================================
   MedLab-inspired portfolio — Alind Hakeem
   Design system: "Clinical Blue" (see branding/colors.md)
   Built with ui-ux-pro-max rules: AA contrast, semantic tokens, light+dark,
   reduced-motion support, 4/8px spacing scale, one primary + one accent.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------- */
:root {
  /* Brand */
  --primary:        #1E5AA8;
  --primary-deep:   #0E3A6B;
  --primary-soft:   #E8F0FA;
  --accent:         #17B0A6;
  --accent-deep:    #0E8C84;
  --critical:       #E11D48;

  /* Neutral / surface (light) */
  --ink:            #0F172A;
  --muted:          #52627A;
  --surface:        #F7FAFC;
  --surface-2:      #EEF3F8;
  --card:           #FFFFFF;
  --border:         #DCE4EE;
  --bg:             #FFFFFF;

  /* Semantic */
  --ring:           #1E5AA8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .06);
  --shadow-lg: 0 18px 48px rgba(14, 58, 107, .16);

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;

  /* Spacing scale (4/8) */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem;
  --s-6: 2rem;  --s-7: 3rem;  --s-8: 4rem;  --s-9: 6rem;

  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --maxw: 1120px;
  --nav-h: 64px;
}

:root[data-theme="dark"] {
  --primary:        #5B9BE0;
  --primary-deep:   #8FC0F0;
  --primary-soft:   #17263B;
  --accent:         #34D2C6;
  --accent-deep:    #7BE7DE;
  --critical:       #FB7185;

  --ink:            #E9EEF6;
  --muted:          #98A6BC;
  --surface:        #0F1723;
  --surface-2:      #16202F;
  --card:           #16202F;
  --border:         #26344A;
  --bg:             #0B111A;

  --ring:           #5B9BE0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 22px 54px rgba(0,0,0,.5);
}

/* ---- Reset-ish ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth; -webkit-text-size-adjust: 100%;
  background: var(--bg); /* base color; the fixed .site-bg layers sit on top */
  transition: background-color .3s ease;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: transparent; /* let the global background show through */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: color .3s ease;
}

/* ============================================================================
   GLOBAL BACKGROUND SYSTEM + z-index scale
   Layer order (low → high):
     -2  .site-bg base / aurora / particles / veil  (fixed, decorative)
      0  section washes & decorative glows           (behind section content)
      1  section content                              (default flow)
    100  sticky navigation
   1000  modals / overlays (reserved)
   ========================================================================== */
.site-bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.site-bg > * { position: absolute; inset: 0; }

/* Animated aurora / gradient mesh (GPU-friendly: transform + opacity only). */
.site-bg__aurora {
  inset: -25%;
  background:
    radial-gradient(38% 40% at 18% 22%, color-mix(in srgb, var(--primary) 20%, transparent), transparent 70%),
    radial-gradient(34% 44% at 82% 14%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(46% 42% at 62% 88%, color-mix(in srgb, var(--primary-deep) 16%, transparent), transparent 72%);
  filter: blur(28px);
  will-change: transform;
  animation: aurora-drift 30s ease-in-out infinite alternate;
}
:root[data-theme="dark"] .site-bg__aurora {
  background:
    radial-gradient(38% 40% at 18% 22%, color-mix(in srgb, var(--primary) 26%, transparent), transparent 70%),
    radial-gradient(34% 44% at 82% 14%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
    radial-gradient(46% 42% at 62% 88%, color-mix(in srgb, var(--primary-deep) 34%, transparent), transparent 72%);
}
@keyframes aurora-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(2%, -1.5%, 0) scale(1.06); }
  100% { transform: translate3d(-1.5%, 1.5%, 0) scale(1.03); }
}

/* Particle layer. Glow is a soft drop-shadow bloom (Linear/Vercel-style) applied
   to the canvas pixels — nodes and links get a halo without touching the library.
   Kept small-radius for 60fps; tuned per theme. Transitions smooth theme swaps. */
.site-bg__particles { opacity: .85; transition: opacity .5s ease; }
.site-bg__particles canvas {
  display: block;
  /* Light: elegant, restrained blue glow so deep-blue nodes stay crisp on white. */
  filter: drop-shadow(0 0 1.5px color-mix(in srgb, var(--primary) 45%, transparent));
  transition: filter .5s ease;
}
:root[data-theme="dark"] .site-bg__particles { opacity: .95; }
:root[data-theme="dark"] .site-bg__particles canvas {
  /* Dark: two-stop cyan bloom — noticeable, premium, never neon. */
  filter: drop-shadow(0 0 2px color-mix(in srgb, #7FD8F5 75%, transparent))
          drop-shadow(0 0 6px color-mix(in srgb, #56CCF2 30%, transparent));
}
@media (prefers-reduced-motion: reduce) {
  .site-bg__particles, .site-bg__particles canvas { transition: none; }
}

/* Readability veil: keeps text legible over the aurora/particles in both themes. */
.site-bg__veil {
  background:
    radial-gradient(120% 80% at 50% 0%, transparent, color-mix(in srgb, var(--bg) 55%, transparent) 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent), transparent 22%, transparent 78%, color-mix(in srgb, var(--bg) 45%, transparent));
}

@media (prefers-reduced-motion: reduce) {
  .site-bg__aurora { animation: none; }
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .4em; font-weight: 700; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
p { margin: 0 0 1rem; }

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

/* ---- Utilities ----------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s-5); }
.section { padding-block: clamp(3.5rem, 8vw, 6rem); position: relative; z-index: 1; }
.section > .wrap { position: relative; z-index: 1; }

/* Translucent section wash — dims the global background for text-dense sections
   while masking its top/bottom edges, so sections melt into one another
   (no hard lines) instead of stacking as opaque blocks. Works in both themes. */
.section--wash { isolation: isolate; }
.section--wash::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: .8rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 var(--s-3);
  display: inline-flex; align-items: center; gap: .5rem;
}
.eyebrow::before { content: ""; width: 20px; height: 2px; background: var(--accent); display: inline-block; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.mono { font-family: var(--font-mono); }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--primary); color: #fff; padding: .7rem 1.1rem;
  border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  font: inherit; font-weight: 600;
  min-height: 46px; padding: 0 1.25rem;
  border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-deep); box-shadow: var(--shadow-md); }
:root[data-theme="dark"] .btn-primary { color: #08121f; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn svg { width: 18px; height: 18px; }

/* ---- Navbar -------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  backdrop-filter: saturate(160%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-family: var(--font-mono); font-weight: 700; font-size: .95rem;
}
:root[data-theme="dark"] .brand-mark { color: #08121f; }
.nav-links { display: flex; align-items: center; gap: var(--s-2); }
.nav-links a { color: var(--muted); font-weight: 500; font-size: .95rem; padding: .5rem .7rem; border-radius: 8px; }
.nav-links a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav-links .nav-desktop { display: none; }
@media (min-width: 860px) { .nav-links .nav-desktop { display: inline-block; } }

.theme-toggle {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.theme-toggle:hover { border-color: var(--primary); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- Hero ---------------------------------------------------------------- */
.hero { position: relative; overflow: hidden; padding-block: clamp(3.5rem, 9vw, 7rem); }
/* Subtle focal glow over the global background; fades out into the next section. */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(55% 50% at 15% 5%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%),
    radial-gradient(45% 45% at 100% 15%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
          mask-image: linear-gradient(180deg, #000 55%, transparent);
}
.hero > .wrap { position: relative; z-index: 1; }
.hero-grid { display: grid; gap: var(--s-7); align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.35fr .9fr; gap: var(--s-8); } }

.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin-bottom: .35em; text-wrap: balance; }
.hero h1 .grad {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-tagline { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: var(--muted); max-width: 54ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }
.hero-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-top: var(--s-6); color: var(--muted); font-size: .9rem; }
.hero-meta span { display: inline-flex; align-items: center; gap: .45rem; }
.hero-meta svg { width: 16px; height: 16px; color: var(--accent-deep); }

/* Portrait / placeholder */
.portrait {
  position: relative; aspect-ratio: 4 / 5; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface-2);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.placeholder {
  display: grid; place-content: center; gap: .6rem; text-align: center;
  height: 100%; padding: var(--s-5); color: var(--muted);
  background:
    repeating-linear-gradient(45deg, transparent, transparent 12px,
      color-mix(in srgb, var(--primary) 6%, transparent) 12px,
      color-mix(in srgb, var(--primary) 6%, transparent) 24px);
  border: 2px dashed var(--border); border-radius: inherit;
}
.placeholder svg { width: 34px; height: 34px; margin-inline: auto; color: var(--primary); opacity: .7; }
.placeholder .ph-title { font-weight: 700; color: var(--ink); }
.placeholder code { font-family: var(--font-mono); font-size: .78rem; color: var(--primary); word-break: break-all; }

/* ---- Stat strip ---------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); margin-top: var(--s-7); }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: var(--s-4) var(--s-5); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat .num { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat .lbl { font-size: .85rem; color: var(--muted); }

/* ---- Section header ------------------------------------------------------ */
.sec-head { max-width: 60ch; margin-bottom: var(--s-7); }

/* ---- Skills -------------------------------------------------------------- */
.skills-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.skill-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-5); box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease; }
.skill-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.skill-card h3 { display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; }
.skill-card h3 svg { width: 20px; height: 20px; color: var(--primary); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: var(--s-3); }
.chip { font-family: var(--font-mono); font-size: .78rem; padding: .3rem .6rem; border-radius: 7px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.chip.proven { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.legend { margin-top: var(--s-5); font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .5rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* ---- Featured project ---------------------------------------------------- */
.project-head { display: grid; gap: var(--s-5); align-items: end; margin-bottom: var(--s-6); }
@media (min-width: 820px) { .project-head { grid-template-columns: 1.6fr 1fr; } }
.badge-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge { font-size: .78rem; font-weight: 600; padding: .3rem .65rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-deep); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); }
:root[data-theme="dark"] .badge { color: var(--primary-deep); }
.badge.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* screenshots */
.shots { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-block: var(--s-6); }
.shot-fig { margin: 0; display: grid; gap: var(--s-3); }
.shot { aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-md); background: #0b1420; transition: transform .2s ease, box-shadow .2s ease; }
.shot-fig:hover .shot { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.shot-fig figcaption { font-size: .88rem; color: var(--muted); font-weight: 500; line-height: 1.4; }
.shot .placeholder { border-radius: 0; height: 100%; }
.shot .placeholder .cap { font-weight: 600; color: var(--ink); font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { .shot { transition: none; } .shot-fig:hover .shot { transform: none; } }

/* feature blocks */
.feature-cols { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.feature-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-5); box-shadow: var(--shadow-sm); }
.feature-block h3 { display: flex; align-items: center; gap: .55rem; }
.feature-block h3 svg { width: 20px; height: 20px; color: var(--accent-deep); flex: none; }
.list { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: .55rem; }
.list li { position: relative; padding-left: 1.6rem; color: var(--ink); font-size: .95rem; }
.list li::before { content: ""; position: absolute; left: 0; top: .55em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.list.security li::before { background: var(--critical); }

/* tech table */
.tech-table { width: 100%; border-collapse: collapse; margin-top: var(--s-4); font-size: .92rem; overflow: hidden; border-radius: var(--radius); }
.tech-table th, .tech-table td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.tech-table thead th { font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
.tech-table tbody tr:hover { background: var(--surface-2); }
.tech-table td:first-child { font-weight: 600; }
.tech-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

/* ---- Timeline / education ------------------------------------------------ */
.timeline { position: relative; margin-top: var(--s-6); display: grid; gap: var(--s-5); }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-left: var(--s-6); }
.tl-item::before { content: ""; position: absolute; left: 2px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 3px solid var(--primary); }
.tl-item .when { font-family: var(--font-mono); font-size: .8rem; color: var(--accent-deep); }
.tl-item h3 { margin: .2rem 0 .3rem; font-size: 1.1rem; }

/* ---- About --------------------------------------------------------------- */
.about-grid { display: grid; gap: var(--s-7); align-items: start; }
@media (min-width: 860px) { .about-grid { grid-template-columns: 1fr 1fr; } }
.callout { border-left: 3px solid var(--accent); padding: var(--s-2) 0 var(--s-2) var(--s-5); color: var(--muted); font-style: italic; }

/* ---- Contact ------------------------------------------------------------- */
.contact { background: linear-gradient(160deg, var(--primary-deep), var(--primary)); color: #fff; border-radius: var(--radius-lg); padding: clamp(2rem, 5vw, 3.5rem); box-shadow: var(--shadow-lg); text-align: center; }
.contact h2 { color: #fff; }
.contact p { color: color-mix(in srgb, #fff 82%, transparent); max-width: 52ch; margin-inline: auto; }
.contact .btn-primary { background: #fff; color: var(--primary-deep); }
.contact .btn-primary:hover { background: #eef4fb; }
.contact .btn-ghost { color: #fff; border-color: color-mix(in srgb, #fff 40%, transparent); }
.contact .btn-ghost:hover { border-color: #fff; color: #fff; background: color-mix(in srgb, #fff 12%, transparent); }
.contact-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: center; margin-top: var(--s-6); }
.social { display: flex; gap: var(--s-3); justify-content: center; margin-top: var(--s-6); }
.social a { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1px solid color-mix(in srgb, #fff 35%, transparent); color: #fff; }
.social a:hover { background: color-mix(in srgb, #fff 14%, transparent); text-decoration: none; }
.social a[data-placeholder="true"] { opacity: .5; }
.social svg { width: 20px; height: 20px; }

/* ---- Footer -------------------------------------------------------------- */
.footer { padding-block: var(--s-6); border-top: 1px solid var(--border); color: var(--muted); font-size: .88rem; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: space-between; align-items: center; }

/* ---- Draft / placeholder note ------------------------------------------- */
.draft-note {
  position: relative;
  background: color-mix(in srgb, var(--critical) 8%, var(--card));
  border: 1px dashed color-mix(in srgb, var(--critical) 45%, var(--border));
  border-radius: var(--radius); padding: var(--s-4) var(--s-5);
  font-size: .9rem; color: var(--ink); margin-top: var(--s-5);
}
.draft-note strong { color: var(--critical); font-family: var(--font-mono); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }

/* ---- Scroll reveal ------------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none; }
  .btn, .skill-card, .theme-toggle { transition: none; }
}
