/* =========================================================
   Hamed Hasan — Portfolio
   Design tokens
   ========================================================= */
:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --ink: #12202B;
  --ink-soft: #55677A;
  --ink-faint: #8B99A6;
  --teal: #146B6B;
  --teal-deep: #0E4F4F;
  --teal-soft: #EEF4F4;
  --copper: #B5652E;
  --line: #DCE3E8;
  --line-strong: #C3CCD3;

  --font-display: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

  --nav-w: 236px;
  --content-max: 760px;
  --wide-max: clamp(1040px, 78vw, 1240px);

  --radius: 3px;
  --shadow-card: 0 1px 2px rgba(18, 32, 43, 0.06), 0 1px 1px rgba(18, 32, 43, 0.04);

  color-scheme: light;
}

/* ---- Dark theme ----
   Toggled by JS via [data-theme="dark"] on <html>. Deep blue-charcoal
   surface with a brighter mint teal and warm copper for accents so
   contrast (text and accent-on-surface) stays comfortably above WCAG AA. */
html[data-theme="dark"] {
  --bg: #0A1216;
  --surface: #101A20;
  --ink: #E9F1F2;
  --ink-soft: #A6B7BF;
  --ink-faint: #6E828B;
  --teal: #4FD6C4;
  --teal-deep: #7FE6D8;
  --teal-soft: #14262A;
  --copper: #F0A05F;
  --line: #1E2C32;
  --line-strong: #2E4149;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
html[data-theme="dark"] .btn-primary { background: var(--teal); color: #06201C; }
html[data-theme="dark"] .btn-primary:hover { background: var(--teal-deep); }
html[data-theme="dark"] .grid-texture { opacity: 0.35; }
html[data-theme="dark"] .hero-trace path { stroke: var(--ink-soft); }

body, .topbar, .mobile-nav, .btn, .form-field input, .form-field textarea,
.nav-links a, .social-icon {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* =========================================================
   Reset
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; color: var(--ink); font-weight: 600; }
p { margin: 0 0 1em; color: var(--ink-soft); }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@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; }
}

/* =========================================================
   Background texture — faint perf-board dot grid
   ========================================================= */
.grid-texture {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

/* =========================================================
   Shell layout: top nav + main content
   ========================================================= */
.shell {
  position: relative;
  z-index: 1;
}

/* ---- Top nav ---- */
#home, #about, #skills, #interests, #portfolio, #blog, #contact {
  scroll-margin-top: 84px;
}
.section-page {
  border-top: 1px solid var(--line);
  margin-top: 56px;
  padding-top: 48px;
}

.site-header-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 56px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.topbar-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.01em;
  color: var(--ink);
  flex-shrink: 0;
}
.topbar-brand span {
  display: block;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  margin-top: 2px;
}

.nav-links.topbar-links {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}
.nav-links.topbar-links a {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  border-left: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.nav-links.topbar-links a:hover {
  color: var(--ink);
  background: var(--bg);
}
.nav-links.topbar-links a.active {
  color: var(--teal-deep);
  border-bottom-color: var(--teal);
  background: var(--teal-soft);
  font-weight: 500;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.theme-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }
.theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: block; }
html[data-theme="dark"] .theme-toggle .moon { display: none; }
.theme-toggle:hover { border-color: var(--teal); color: var(--teal-deep); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ---- Social icons (icon-only circles) ---- */
.social-row {
  display: flex;
  gap: 10px;
  margin-bottom: 40px;
}
.social-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.social-icon svg { width: 17px; height: 17px; }
.social-icon:hover { color: var(--teal-deep); border-color: var(--teal); background: var(--teal-soft); }
.mobile-nav-social {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 16px 4px 4px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  width: 38px;
  height: 34px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.menu-btn span { width: 16px; height: 1.5px; background: var(--ink); display: block; }

.mobile-nav {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 8px 20px 18px;
}
.mobile-nav.open { display: block; }
.mobile-nav > a {
  display: block;
  padding: 10px 4px;
  font-size: 15px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.mobile-nav > a:last-child { border-bottom: none; }
.mobile-nav > a.active { color: var(--teal-deep); font-weight: 500; }

/* =========================================================
   Main content
   ========================================================= */
.main {
  min-width: 0;
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 56px 56px 100px;
}
.page-head {
  max-width: var(--content-max);
  margin-bottom: 56px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--copper);
  margin-bottom: 12px;
  display: block;
}
.page-head h1 {
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.page-head .lede {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 620px;
  margin: 0;
}

.section {
  max-width: var(--content-max);
  margin-bottom: 56px;
}
.section.wide { max-width: var(--wide-max); }
.section h2 {
  font-size: 20px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.section p { max-width: 640px; }

/* =========================================================
   Hero (home page)
   ========================================================= */
.hero {
  max-width: var(--wide-max);
  margin: 0 auto 64px;
  display: flex;
  align-items: center;
  gap: 56px;
}
.hero-copy { flex: 1; min-width: 0; max-width: 640px; }

.hero-photo {
  flex-shrink: 0;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 5px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.hero-photo::before,
.hero-photo::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
}
.hero-photo::before { top: -4px; right: -4px; }
.hero-photo::after { bottom: -4px; left: -4px; }
.hero-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  background: var(--teal-soft);
}
.hero-photo-img[hidden] { display: none; }
.hero-photo-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--teal-soft), var(--surface));
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--teal-deep);
  letter-spacing: 0.05em;
}
.hero-photo-fallback.show { display: flex; }
@media (max-width: 900px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 28px; }
  .hero-photo { width: 190px; height: 190px; margin: 0 auto; }
}
.hero-trace {
  width: 100%;
  max-width: 340px;
  height: auto;
  margin-bottom: 28px;
}
.hero-trace path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 480;
  stroke-dashoffset: 480;
  animation: draw 1.4s ease forwards 0.15s;
}
.hero-trace circle { fill: var(--teal); opacity: 0; animation: fadeIn 0.4s ease forwards 1.3s; }
.hero-trace circle.copper { fill: var(--copper); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }

.hero h1 {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.12;
  letter-spacing: -0.015em;
  max-width: 780px;
  margin-bottom: 20px;
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 8vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.hero-role {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(15px, 1.6vw, 18px);
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  max-width: 560px;
  margin-bottom: 22px;
}
.hero .lede {
  font-size: 17px;
  max-width: 560px;
  margin-bottom: 32px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--teal-deep); }
.btn-secondary { border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--teal); color: var(--teal-deep); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  max-width: 640px;
}
.stat {
  background: var(--surface);
  padding: 20px;
}
.stat b {
  display: block;
  font-family: var(--font-mono);
  font-size: 26px;
  color: var(--teal-deep);
  margin-bottom: 4px;
}
.stat span { font-size: 13px; color: var(--ink-soft); }

/* =========================================================
   Focus / interest cards
   ========================================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}
.focus-card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 20px;
  border-radius: var(--radius);
}
.focus-card .mark {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--copper);
  margin-bottom: 10px;
  display: block;
}
.focus-card h3 { font-size: 16px; margin-bottom: 8px; }
.focus-card p { font-size: 14px; margin: 0; }

/* =========================================================
   Timeline (about page)
   ========================================================= */
.timeline { border-left: 1px solid var(--line); padding-left: 26px; max-width: 640px; }
.tl-item { position: relative; padding-bottom: 30px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -30.5px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--teal);
}
.tl-date { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-faint); margin-bottom: 4px; }
.tl-item h4 { font-size: 15.5px; margin-bottom: 4px; }
.tl-item p { font-size: 14.5px; margin: 0; }

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 32px;
  max-width: 640px;
}
.fact dt { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin-bottom: 3px; }
.fact dd { margin: 0; font-size: 14.5px; }

/* =========================================================
   Skills page
   ========================================================= */
.skill-group { margin-bottom: 40px; }
.skill-group h3 {
  font-size: 15px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-bottom: 14px;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 9px; }
.tag {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
}
.tag.strong { border-color: var(--teal); color: var(--teal-deep); background: var(--teal-soft); }

/* =========================================================
   Portfolio page
   ========================================================= */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 26px;
  max-width: var(--wide-max);
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.project-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }

.project-media {
  position: relative;
  height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--surface);
  overflow: hidden;
}
.project-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.35) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 0.15;
}
.project-art { width: 88%; height: 78%; position: relative; z-index: 1; }
.media-cv     { background: linear-gradient(135deg, var(--teal-deep), var(--ink)); }
.media-iot    { background: linear-gradient(135deg, var(--copper), var(--ink)); }
.media-web    { background: linear-gradient(135deg, #1E2C32, var(--teal-deep)); }
.media-vlsi   { background: linear-gradient(135deg, var(--ink), #2E4149); }
.media-signal { background: linear-gradient(135deg, var(--teal-deep), var(--copper)); }
.media-analog { background: linear-gradient(135deg, var(--copper), #6E4322); }

.project-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  background: rgba(10, 18, 22, 0.55);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  backdrop-filter: blur(2px);
}

.project-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.project-body h3 { font-size: 16.5px; line-height: 1.3; margin-bottom: 8px; }
.project-body p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 16px; flex: 1; }
.project-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.project-tags span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
}
.project-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--teal-deep);
  border: 1px solid var(--teal);
  padding: 8px 14px;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.project-link:hover { background: var(--teal); color: #fff; }
.project-link span { transition: transform 0.15s ease; }
.project-link:hover span { transform: translateX(2px); }
.project-note {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-style: italic;
  margin: 0;
}

/* =========================================================
   Blog page
   ========================================================= */
.post-list { display: flex; flex-direction: column; }
.post {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 20px;
}
.post:first-child { padding-top: 0; }
.post-date { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-faint); padding-top: 3px; }
.post h3 { font-size: 17px; margin-bottom: 6px; }
.post p { font-size: 14.5px; margin: 0 0 8px; }
.post-tag { font-family: var(--font-mono); font-size: 11.5px; color: var(--teal-deep); }

/* =========================================================
   Contact page
   ========================================================= */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 48px;
  max-width: var(--wide-max);
}
.contact-info .fact { margin-bottom: 20px; }
.contact-info dd a { color: var(--teal-deep); border-bottom: 1px solid var(--line-strong); }
.contact-info dd a:hover { border-bottom-color: var(--teal); }

.cv-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-card);
}
.cv-card-text h3 { font-size: 15.5px; margin-bottom: 3px; }
.cv-card-text p { margin: 0; font-size: 13.5px; }
.btn-icon { width: 15px; height: 15px; }

.form-field { margin-bottom: 18px; }
.form-field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.form-field input, .form-field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 14.5px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
.form-field input:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--teal);
}
.form-msg { font-size: 13.5px; margin-top: 10px; min-height: 18px; }
.form-msg.success { color: var(--teal-deep); }
.form-msg.error { color: #C0392B; }
html[data-theme="dark"] .form-msg.error { color: #E58C7D; }

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  max-width: var(--wide-max);
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-faint);
}
.site-footer a { color: var(--ink-faint); }
.site-footer a:hover { color: var(--teal-deep); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 880px) {
  .nav-links.topbar-links { display: none; }
  .menu-btn { display: flex; }
  .topbar { padding: 14px 20px; }
  .main { padding: 40px 22px 70px; }
  .contact-layout { grid-template-columns: 1fr; gap: 32px; }
  .stat-row { grid-template-columns: 1fr; max-width: 320px; }
  .fact-grid { grid-template-columns: 1fr; }
  .post { grid-template-columns: 1fr; gap: 6px; }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; gap: 12px; }
  .topbar-brand { font-size: 17px; }
  .topbar-brand span { font-size: 10px; }
  .theme-toggle { width: 34px; height: 34px; }
  .menu-btn { width: 34px; height: 30px; }
  .mobile-nav { padding: 6px 16px 14px; }
  .mobile-nav > a { padding: 12px 2px; font-size: 15px; }

  .main { padding: 32px 16px 56px; }
  .page-head { margin-bottom: 40px; }
  .page-head h1 { font-size: clamp(26px, 7vw, 34px); }
  .section, .section.wide { margin-bottom: 40px; }

  .hero { gap: 22px; margin-bottom: 44px; }
  .hero-photo { width: 150px; height: 150px; margin: 0 auto; }
  .hero-photo-img, .hero-photo-fallback { border-radius: 50%; }
  .hero-name { margin-bottom: 10px; }
  .hero-role { margin-bottom: 16px; }
  .hero .lede { font-size: 15.5px; margin-bottom: 24px; }
  .hero-actions { margin-bottom: 22px; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; text-align: center; }
  .social-row { gap: 8px; margin-bottom: 30px; }
  .social-icon { width: 36px; height: 36px; }
  .social-icon svg { width: 15px; height: 15px; }
  .stat { padding: 14px; }
  .stat b { font-size: 21px; }

  .card-grid { gap: 14px; }
  .focus-card { padding: 18px 16px; }

  .project-grid { gap: 18px; }
  .project-media { height: 140px; }
  .project-body { padding: 16px 18px 18px; }
  .project-body h3 { font-size: 15.5px; }

  .timeline { padding-left: 20px; }
  .tl-item::before { left: -24.5px; }

  .contact-layout { gap: 26px; }

  .site-footer { padding-top: 18px; }
}

