/* ============================================================
   Muhammad Zareii Portfolio — Shared Stylesheet
   Brand: Navy #003366 · Times New Roman / IEEE serif
   ============================================================ */

:root {
  --brand:   #003366;
  --brand2:  #004488;
  --ink:     #1a1a2e;
  --bg:      #fafafa;
  --card:    #ffffff;
  --muted:   #556;
  --rule:    #dde3ee;
  --accent:  #aaddff;
  --accent2: #e8f4fd;
  --tag-bg:  #e3edf7;
  --code-bg: #f0f4f8;
  --green:   #2a7a4b;
  --warn:    #7a4b00;
  --radius:  8px;
  --shadow:  0 2px 10px rgba(0,51,102,0.10);
  --shadow2: 0 4px 20px rgba(0,51,102,0.15);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Times New Roman', Times, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 1.05rem;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--brand2); }

img { max-width: 100%; height: auto; display: block; border-radius: var(--radius); }

/* ─── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: 'Times New Roman', Times, serif; line-height: 1.3; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 1em; }
p:last-child { margin-bottom: 0; }

ul, ol { padding-left: 1.4em; margin-bottom: 1em; }
li { margin-bottom: .3em; }

code {
  font-family: 'Courier New', monospace;
  font-size: .88em;
  background: var(--code-bg);
  padding: .1em .35em;
  border-radius: 4px;
  color: #1a3a5c;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.6;
  margin-bottom: 1.2em;
}

pre code { background: none; padding: 0; }

/* ─── Layout ────────────────────────────────────────────────── */
.container { max-width: 980px; margin: 0 auto; padding: 0 1.25rem; }
.wide      { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }

section { padding: 3rem 0; }
section + section { border-top: 1px solid var(--rule); }

/* ─── Header / Nav ──────────────────────────────────────────── */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 1rem 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header .logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
  font-family: 'Times New Roman', Times, serif;
}

.site-header .logo span { color: var(--accent); }

.site-nav { display: flex; gap: .2rem; flex-wrap: wrap; }

.site-nav a {
  color: rgba(255,255,255,.85);
  padding: .35rem .7rem;
  border-radius: 5px;
  font-size: .88rem;
  font-family: 'Times New Roman', Times, serif;
  transition: background .2s, color .2s;
}

.site-nav a:hover,
.site-nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}

/* ─── Hero (index page) ─────────────────────────────────────── */
.hero {
  background: var(--brand);
  color: #fff;
  padding: 3.5rem 0 3rem;
}

.hero-flex {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.hero-photo {
  width: 160px; height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,.5);
  box-shadow: var(--shadow2);
  flex-shrink: 0;
}

.hero-text h1 { font-size: 2.4rem; margin-bottom: .3rem; }
.hero-text .subtitle { font-size: 1.1rem; color: var(--accent); margin-bottom: .7rem; }

.hero-links { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .9rem;
  font-family: 'Times New Roman', Times, serif;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
  text-decoration: none;
}

.btn-light {
  background: #fff; color: var(--brand);
  border: 2px solid #fff;
}
.btn-light:hover { background: var(--accent); border-color: var(--accent); text-decoration: none; }

.btn-ghost {
  background: transparent; color: #fff;
  border: 2px solid rgba(255,255,255,.5);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); border-color: #fff; text-decoration: none; color: #fff; }

.btn-brand {
  background: var(--brand); color: #fff;
  border: 2px solid var(--brand);
}
.btn-brand:hover { background: var(--brand2); border-color: var(--brand2); text-decoration: none; }

.btn-sm { padding: .3rem .7rem; font-size: .82rem; }

/* ─── Breadcrumb ────────────────────────────────────────────── */
.breadcrumb {
  background: var(--brand);
  padding: .7rem 0;
  font-size: .88rem;
}

.breadcrumb .container { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { color: #fff; text-decoration: none; }
.breadcrumb span { color: rgba(255,255,255,.6); }
.breadcrumb .current { color: #fff; font-weight: 600; }

/* ─── Page header (for layer / project pages) ───────────────── */
.page-hero {
  background: var(--brand);
  color: #fff;
  padding: 2.5rem 0 2rem;
}

.page-hero h1 { font-size: 2rem; margin-bottom: .4rem; }
.page-hero p  { font-size: 1.05rem; color: rgba(255,255,255,.8); max-width: 650px; }

/* ─── Layer badge ───────────────────────────────────────────── */
.layer-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase;
  padding: .25rem .65rem;
  border-radius: 20px;
  margin-bottom: .8rem;
}

.layer-physical   { background: #d4edda; color: #1a5c30; }
.layer-circuit    { background: #fff3cd; color: #7a4b00; }
.layer-embedded   { background: #d1ecf1; color: #0c5460; }
.layer-intel      { background: #e2d9f3; color: #4a1f7a; }

/* ─── Domain / category label chips ─────────────────────────── */
.domain-tag {
  display: inline-flex; align-items: center;
  font-size: .73rem; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: 4px;
  margin-right: .3rem;
  margin-bottom: .3rem;
}

.domain-robotics   { background: #fde8d8; color: #b34300; }
.domain-bio        { background: #d8f0e8; color: #1a5c30; }
.domain-sensor     { background: #e8daf8; color: #4a1f7a; }
.domain-photonics  { background: #d8eaf8; color: #003366; }
.domain-signal     { background: #fdf8d8; color: #5c4a00; }
.domain-ai         { background: #f0d8f8; color: #5c0066; }
.domain-power      { background: #f8e8d8; color: #7a3300; }
.domain-comms      { background: #d8f8f8; color: #005c5c; }
.domain-quantum    { background: #dde8ff; color: #001a66; }
.domain-micro      { background: #e8f8dd; color: #2a5c00; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .15s;
}

.card:hover { box-shadow: var(--shadow2); transform: translateY(-2px); }

.card h3 { margin-bottom: .4rem; }
.card p  { color: var(--muted); font-size: .95rem; margin-bottom: .8rem; }

/* ─── Project Grid — strict 3 equal columns ─────────────────────── */
/* minmax(0,1fr) prevents any image or content from inflating columns */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem;
  margin-top: 1.4rem;
}

/* <a> wrappers: block, fill cell width AND height so all row cards match */
.project-grid > * {
  display: block;
  min-width: 0;
  width: 100%;
  height: 100%;     /* stretch to grid row height */
}

.project-grid > * > .project-card {
  height: 100%;     /* card fills the <a> wrapper */
}

@media (max-width: 860px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .project-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ─── Stretched link — whole card is clickable ───────────────────── */
/* The outer <a> was removed because <a><div> triggers the HTML        */
/* adoption agency algorithm, splitting them into sibling grid items.  */
/* Instead, the h3 title carries a .stretched-link whose ::after       */
/* pseudo-element overlays the entire card, making it fully clickable. */
.project-card {
  position: relative;    /* anchor for the stretched-link ::after     */
  width: 100%;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .15s;
  display: flex; flex-direction: column;
}

.project-card:hover { box-shadow: var(--shadow2); transform: translateY(-3px); cursor: pointer; }

/* Stretched link: the ::after pseudo-element covers the whole card */
.stretched-link {
  text-decoration: none;
  color: inherit;
}
.stretched-link::after {
  content: '';
  position: absolute;
  inset: 0;           /* top/right/bottom/left: 0 */
  z-index: 1;
}
/* Buttons and badges must sit above the overlay to remain clickable */
.project-card-footer,
.project-card .btn,
.project-card .layer-badge,
.project-card .tag {
  position: relative;
  z-index: 2;
}

.project-card-img {
  display: block;       /* kills inline baseline gap */
  width: 100%;
  max-width: 100%;      /* never wider than column */
  height: 175px;
  object-fit: cover;
  border-radius: 0;
}

.project-card-img-placeholder {
  width: 100%; height: 175px;
  background: var(--accent2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--brand);
}

.project-card-body {
  padding: 1rem 1.1rem 1.2rem;
  flex: 1;
  display: flex; flex-direction: column;
}

.project-card-body h3 { font-size: 1rem; margin-bottom: .35rem; }
.project-card-body p  { font-size: .88rem; color: var(--muted); flex: 1; margin-bottom: .8rem; }

.project-card-footer {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  margin-top: auto;
}

/* ─── Tags ───────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }

.tag {
  font-size: .75rem;
  background: var(--tag-bg);
  color: var(--brand);
  padding: .15rem .55rem;
  border-radius: 20px;
  font-family: 'Courier New', monospace;
  letter-spacing: .2px;
}

/* ─── Stats row ─────────────────────────────────────────────── */
.stats-row {
  display: flex; flex-wrap: wrap; gap: 1.2rem;
  background: var(--accent2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  margin: 1.2rem 0;
}

.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--brand); line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ─── Section headings ───────────────────────────────────────── */
.section-title {
  font-size: 1.35rem;
  border-left: 4px solid var(--brand);
  padding-left: .8rem;
  margin: 2rem 0 1rem;
  color: var(--brand);
}

.section-subtitle { color: var(--muted); font-size: .95rem; margin-top: -.6rem; margin-bottom: 1rem; }

/* ─── IEEE-style inline figure ───────────────────────────────── */
/* Full-width centered figure, used mid-text like a journal paper */
.ieee-fig {
  display: block;
  width: 100%;
  max-width: 680px;
  margin: 1.8rem auto 0.5rem;
  text-align: center;
}

.ieee-fig img,
.ieee-fig svg {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.ieee-fig .fig-num {
  display: block;
  font-weight: 700;
  font-size: .87rem;
  color: var(--brand);
  margin-top: .55rem;
}

.ieee-fig .fig-caption {
  display: block;
  font-size: .87rem;
  color: var(--muted);
  font-style: italic;
  margin-top: .15rem;
  margin-bottom: 1.6rem;
  line-height: 1.4;
}

/* Half-width float figure */
.ieee-fig-half {
  float: right;
  width: 45%;
  margin: 0 0 1.2rem 1.8rem;
  text-align: center;
}

.ieee-fig-half img {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.ieee-fig-half .fig-num {
  font-weight: 700; font-size: .82rem; color: var(--brand);
  display: block; margin-top: .4rem;
}

.ieee-fig-half .fig-caption {
  display: block;
  font-size: .82rem; color: var(--muted); font-style: italic;
  margin-top: .1rem; line-height: 1.4;
}

/* Legacy gallery grid (kept for compatibility) */
.fig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.2rem 0;
}

.fig-item { text-align: center; }

.fig-item img {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.fig-caption {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .4rem;
  font-style: italic;
}

/* clearfix for float figures */
.clearfix::after { content: ''; display: table; clear: both; }

/* ─── Info box ───────────────────────────────────────────────── */
.info-box {
  background: var(--accent2);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .9rem 1.2rem;
  margin: 1rem 0;
  font-size: .95rem;
}

.note-box {
  background: #fff8e8;
  border-left: 4px solid #e6a817;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .9rem 1.2rem;
  margin: 1rem 0;
  font-size: .95rem;
}

/* ─── Table ──────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .92rem; }
th { background: var(--brand); color: #fff; text-align: left; padding: .55rem .8rem; }
td { padding: .5rem .8rem; border-bottom: 1px solid var(--rule); }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--accent2); }

/* ─── Equation block ────────────────────────────────────────── */
.eq,
.equation-block {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .8rem 1.6rem;
  font-family: 'Times New Roman', Times, serif;
  font-size: 1.05rem;
  text-align: center;
  margin: 1.2rem 0;
  overflow-x: auto;
  font-style: italic;
}

.eq-label {
  float: right;
  font-style: normal;
  font-size: .88rem;
  color: var(--muted);
  margin-left: 1rem;
}

/* ─── GitHub link block ─────────────────────────────────────── */
.github-block {
  display: flex; align-items: center; gap: 1rem;
  background: #0d1117; color: #c9d1d9;
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.github-block svg { flex-shrink: 0; }
.github-block a { color: #58a6ff; font-weight: 700; }
.github-block a:hover { color: #79c0ff; }
.github-block p { font-size: .9rem; margin: 0; }

/* ─── Layer overview hero colors ────────────────────────────── */
.hero-physical { background: linear-gradient(135deg, #003366 60%, #1a6b3c); }
.hero-circuit  { background: linear-gradient(135deg, #003366 60%, #7a4b00); }
.hero-embedded { background: linear-gradient(135deg, #003366 60%, #0c5460); }
.hero-intel    { background: linear-gradient(135deg, #003366 60%, #4a1f7a); }

/* ─── About section ─────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

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

/* ─── Research interest cards ────────────────────────────────── */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.2rem;
  margin-top: 1.2rem;
}

.research-card {
  background: var(--card);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.research-card h3 { color: var(--brand); margin-bottom: .5rem; }
.research-card .ri-tag { color: var(--muted); font-size: .85rem; margin-bottom: .7rem; font-style: italic; }

/* ─── Experience timeline ────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: ''; position: absolute; left: .5rem; top: .5rem; bottom: .5rem;
  width: 2px; background: var(--brand);
}

.timeline-item { position: relative; margin-bottom: 2rem; }
.timeline-item::before {
  content: ''; position: absolute; left: -1.65rem; top: .45rem;
  width: 10px; height: 10px;
  background: var(--brand); border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--brand);
}

.timeline-date { font-size: .85rem; color: var(--muted); font-weight: 700; margin-bottom: .2rem; }
.timeline-title { font-size: 1.1rem; font-weight: 700; color: var(--brand); }
.timeline-org   { font-size: .95rem; color: var(--ink); margin-bottom: .5rem; }

/* ─── Skills chips ───────────────────────────────────────────── */
.skills-section .group { margin-bottom: 1.2rem; }
.skills-section .group-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin-bottom: .4rem; font-weight: 700;
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  background: var(--tag-bg); color: var(--brand);
  padding: .25rem .7rem; border-radius: 20px;
  font-size: .83rem; font-family: 'Courier New', monospace;
}

/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--brand);
  color: rgba(255,255,255,.7);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
  font-size: .88rem;
}

.site-footer a { color: var(--accent); }
.site-footer a:hover { color: #fff; text-decoration: none; }

/* ─── Project page specifics ────────────────────────────────── */
.project-summary-card {
  background: var(--accent2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin: 1.5rem 0;
}

.project-summary-card h2 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--brand); border: none; }

/* ─── SVG diagram wrapper ────────────────────────────────────── */
.diagram-wrap {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin: 1.2rem 0;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.diagram-wrap svg { display: block; margin: 0 auto; max-width: 100%; }
.diagram-wrap .caption { text-align: center; font-size: .82rem; color: var(--muted); margin-top: .6rem; font-style: italic; }

/* ─── Lightbox overlay ───────────────────────────────────────── */
#lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#lightbox-overlay.active { display: flex; }

#lightbox-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  cursor: default;
}

#lightbox-overlay .lb-close {
  position: absolute;
  top: 1.2rem; right: 1.5rem;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
  line-height: 1;
  opacity: .8;
  transition: opacity .15s;
  font-family: 'Times New Roman', serif;
  user-select: none;
}

#lightbox-overlay .lb-close:hover { opacity: 1; }

#lightbox-overlay .lb-caption {
  position: absolute;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.75);
  font-size: .9rem;
  font-style: italic;
  text-align: center;
  max-width: 80vw;
  pointer-events: none;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 700px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }
  .hero-flex { gap: 1.5rem; }
  .hero-photo { width: 120px; height: 120px; }
  .hero-text h1 { font-size: 1.8rem; }
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  .fig-grid { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .ieee-fig-half { float: none; width: 100%; margin: 1rem 0; }
}
