/* ============================================================
   Portfolio — Ahmed Sameh
   Editorial minimalism with a warm terracotta accent.
   ============================================================ */

:root {
  /* tokens — overridden by tweaks at runtime */
  --bg:        #f6f3ec;
  --bg-soft:   #efeae0;
  --bg-card:  rgba(255, 255, 255, 0.55);
  --ink:       #1a1816;
  --ink-soft:  #4a4540;
  --muted:     #8a8278;
  --line:      rgba(26, 24, 22, 0.12);
  --line-soft: rgba(26, 24, 22, 0.06);
  --accent:    oklch(0.58 0.14 28);     /* terracotta */
  --accent-ink: oklch(0.42 0.14 28);
  --accent-bg: oklch(0.94 0.04 28);

  --serif:   "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --sans:    "DM Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "VT323", "JetBrains Mono", monospace;   /* pixel display font — always on for big titles */

  /* gem / achievement palette — terminal green, not accent */
  --gem:    oklch(0.68 0.18 145);
  --gem-bg: oklch(0.94 0.04 145);

  --max:  1180px;
  --pad:  clamp(20px, 4vw, 56px);

  --radius: 14px;
  --radius-lg: 22px;
}

/* dark theme */
html[data-theme="dark"] {
  --bg:       #14110e;
  --bg-soft:  #1c1814;
  --bg-card:  rgba(255, 255, 255, 0.04);
  --ink:      #f3ede1;
  --ink-soft: #c5bdae;
  --muted:    #7a7163;
  --line:      rgba(243, 237, 225, 0.12);
  --line-soft: rgba(243, 237, 225, 0.06);
  --accent-bg: oklch(0.30 0.08 28);
  --gem-bg:    oklch(0.22 0.06 145);
}

/* accents */
html[data-accent="terracotta"] { --accent: oklch(0.60 0.14 28);  --accent-ink: oklch(0.45 0.14 28);  --accent-bg: oklch(0.94 0.04 28); }
html[data-accent="forest"]     { --accent: oklch(0.55 0.10 155); --accent-ink: oklch(0.40 0.10 155); --accent-bg: oklch(0.94 0.04 155); }
html[data-accent="indigo"]     { --accent: oklch(0.55 0.14 265); --accent-ink: oklch(0.40 0.14 265); --accent-bg: oklch(0.94 0.04 265); }
html[data-accent="mono"]       { --accent: var(--ink);            --accent-ink: var(--ink);          --accent-bg: var(--bg-soft); }

html[data-theme="dark"][data-accent="terracotta"] { --accent: oklch(0.70 0.14 28); --accent-bg: oklch(0.30 0.08 28); }
html[data-theme="dark"][data-accent="forest"]     { --accent: oklch(0.70 0.10 155); --accent-bg: oklch(0.30 0.06 155); }
html[data-theme="dark"][data-accent="indigo"]     { --accent: oklch(0.72 0.14 265); --accent-bg: oklch(0.30 0.08 265); }
html[data-theme="dark"][data-accent="mono"]       { --accent: var(--ink); --accent-bg: var(--bg-soft); }

/* base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02";
  transition: background-color 0.55s ease, color 0.55s ease;
}

/* Animate color-bound chrome together with theme toggle */
.nav, .nav-cta, .theme-toggle, .card, .feature, .course, .avatar-card, .chip, .social,
.tl-row, .gem-toast, .gems-modal .panel, .nav-links a, .gems-count, .nav-brand .dot,
.hero-meta .value .dot, .feature::before, .nav-brand,
.eyebrow, .eyebrow .num, .section-head, .section-head h2, .feature h3, .feature .blurb,
.feature li, .feature li::before, .proj h3 .yr, .proj p, .course .name, .course .by, .course .tag,
.contact .lead, .contact .email-link, .tl-when, .tl-when .now, .tl-body h3, .tl-body .role, .tl-body p,
.about-side .row, .about-side .row .k, .about-side .row .v, .about-grid .body p,
.edu-item .school, .edu-item .deg, .edu-item .when,
.cert-item .name, .cert-item .meta, .cert-item .when,
.tl-toggle {
  transition: background-color 0.55s ease, color 0.55s ease, border-color 0.55s ease, box-shadow 0.55s ease;
}
.avatar-card { transition: background 0.55s ease, border-color 0.55s ease, box-shadow 0.55s ease; }

/* Avatar frame becomes a relative container so the two images can stack */
.avatar-frame { position: relative; }

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
::selection { background: var(--accent); color: var(--bg); }

/* layout helpers */
.wrap { max-width: var(--max); margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow .num {
  color: var(--accent);
  font-weight: 600;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
  margin-bottom: 36px;
}
.section-head h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(44px, 5.5vw, 74px);
  line-height: 1;
  letter-spacing: 0;
  margin: 8px 0 0;
}
.section-head .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.nav-brand .dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent-bg);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.nav-links {
  display: flex;
  gap: 4px;
}
.nav-links a {
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border-radius: 8px;
  transition: background 0.18s, color 0.18s;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--ink); }
.nav-links a.active { color: var(--accent); }
.nav-links a.active::before { content: "·  "; color: var(--accent); }
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  overflow: hidden;
  transition: color 0.25s, border-color 0.25s, background 0.25s, transform 0.25s;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.theme-toggle:active { transform: translateY(0) scale(0.92); }
.theme-toggle .icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: transform 0.5s cubic-bezier(.34,1.56,.64,1), opacity 0.35s ease;
}
.theme-toggle .icon.sun  { transform: rotate(0deg) scale(1); opacity: 1; }
.theme-toggle .icon.moon { transform: rotate(0deg) scale(1); opacity: 1; }
.theme-toggle .icon.is-out.sun  { transform: rotate(180deg) scale(0.4); opacity: 0; }
.theme-toggle .icon.is-out.moon { transform: rotate(-180deg) scale(0.4); opacity: 0; }

/* ripple effect on click */
.theme-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}
.theme-toggle.toggling::after {
  animation: ripple 0.55s ease-out;
}
@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.3; }
  100% { transform: scale(2.2); opacity: 0; }
}
html[data-pixel="on"] .theme-toggle { border-radius: 0; }
.nav-cta {
  padding: 9px 16px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  transition: transform 0.18s ease, background 0.18s ease;
}
.nav-cta:hover { transform: translateY(-1px); }
@media (max-width: 760px) { .nav-links { display: none; } }

/* HERO */
.hero {
  padding-top: clamp(24px, 4vw, 48px);
  padding-bottom: clamp(60px, 9vw, 120px);
  position: relative;
  overflow: hidden;
  scroll-margin-top: 64px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  column-gap: clamp(32px, 5vw, 80px);
  row-gap: 0;
  align-items: start;
}
/* Desktop: eyebrow (row 1), h1 (row 2), tail (row 3), avatar spans all rows in col 2 */
.hero-eyebrow { grid-column: 1; grid-row: 1; }
.hero-grid > h1  { grid-column: 1; grid-row: 2; }
.hero-tail       { grid-column: 1; grid-row: 3; }
.hero-grid > .avatar-card { grid-column: 2; grid-row: 1 / 4; align-self: center; }

/* Mobile: eyebrow full-width (row 1), h1 + avatar side-by-side (row 2), tail full-width (row 3) */
@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr min(130px, 26vw);
    column-gap: 14px;
    row-gap: 18px;
  }
  .hero-eyebrow { grid-column: 1 / 3; grid-row: 1; }
  .hero-grid > h1 { grid-column: 1; grid-row: 2; }
  .hero-grid > .avatar-card {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    padding: 6px;
    margin: 0;
  }
  .hero-grid > .avatar-card .caption { display: none; }
  .hero-tail { grid-column: 1 / 3; grid-row: 3; }
  /* h1 size alongside the avatar */
  .hero h1 { font-size: clamp(48px, 12vw, 72px); }
  html[data-pixel="on"] .hero h1 { font-size: clamp(50px, 12.5vw, 76px); }
  /* Hide terminal title bar on the compact mobile avatar */
  html[data-pixel="on"] .hero-grid > .avatar-card::before { display: none; }
  html[data-pixel="on"] .hero-grid > .avatar-card { padding-top: 6px; box-shadow: 3px 3px 0 var(--ink); }
}

.hero h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(72px, 12vw, 168px);
  line-height: 0.9;
  letter-spacing: 0;
  margin: 18px 0 24px;
}
.hero h1 em {
  font-style: normal;  /* VT323 has no italic */
  color: var(--accent);
}
.hero .tagline {
  font-size: clamp(18px, 1.6vw, 22px);
  color: var(--ink-soft);
  max-width: 42ch;
  text-wrap: pretty;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 36px;
  margin-top: 36px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.hero-meta .label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}
.hero-meta .value {
  color: var(--ink);
}
.hero-meta .value .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: oklch(0.65 0.14 145);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px color-mix(in srgb, oklch(0.65 0.14 145) 25%, transparent);
}

/* avatar frame */
.avatar-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.18), 0 1px 0 rgba(255,255,255,0.4) inset;
  width: 100%;          /* fills the grid column — no artificial cap on desktop */
  justify-self: end;
}
/* avatar-card mobile sizing handled by .hero-grid > .avatar-card rule above */

.avatar-frame {
  background: var(--bg-soft);
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  position: relative;
  background-image:
    linear-gradient(135deg, transparent 49.5%, var(--line-soft) 49.5%, var(--line-soft) 50.5%, transparent 50.5%),
    linear-gradient(45deg, transparent 49.5%, var(--line-soft) 49.5%, var(--line-soft) 50.5%, transparent 50.5%);
  background-size: 14px 14px;
}
.avatar-frame img,
.avatar-frame .avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(.2,.8,.2,1), filter 0.55s ease;
}
.avatar-frame .avatar-img.shown {
  opacity: 1;
  transform: scale(1);
}
.avatar-frame .avatar-img.hidden {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}
.avatar-card .caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.avatar-card .caption .live {
  color: var(--accent);
}

/* generic section */
section {
  padding: clamp(20px, 2.5vw, 28px) 0 clamp(56px, 7vw, 88px);
  scroll-margin-top: 64px;
}

/* ABOUT */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(32px, 5vw, 80px);
}
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } }
.about-grid .body p {
  font-size: clamp(20px, 1.7vw, 24px);
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 1em;
  text-wrap: pretty;
}
.about-grid .body p + p { color: var(--ink-soft); }
.about-side {
  display: grid;
  gap: 18px;
  align-content: start;
}
.about-side .row {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  letter-spacing: 0.02em;
}
.about-side .row .k { color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; }
.about-side .row .v { color: var(--ink); text-align: right; }

/* EXPERIENCE */
.timeline {
  display: grid;
  gap: 0;
}
.tl-row {
  display: grid;
  grid-template-columns: 155px 1fr;
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--line-soft);
  position: relative;
  transition: background 0.3s;
}
.tl-row:first-child { border-top: 0; }
.tl-row:hover { background: var(--bg-soft); border-radius: 12px; padding-left: 12px; padding-right: 12px; }
.tl-row.current::before {
  content: "";
  position: absolute;
  left: -10px; top: 18px; bottom: 18px;
  width: 4px; height: auto;
  background: var(--accent);
  border-radius: 2px;
}
@media (max-width: 660px) {
  .tl-row { grid-template-columns: 1fr; gap: 4px; padding: 14px 0; }
  .tl-body h3 { font-size: clamp(18px, 4.5vw, 22px); }
  /* Hide left accent bar on mobile — "Now" badge already indicates current role */
  .tl-row.current::before { display: none; }
}

.tl-when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  white-space: nowrap;
}
.tl-when .now {
  display: inline-block;
  margin-top: 0;
  padding: 3px 9px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tl-body h3 {
  font-family: var(--serif);
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0 0 3px;
}
.tl-body .role {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.tl-body p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 14px;
  max-width: 60ch;
}
.exp-bullets {
  margin: 0 0 10px;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 14px;
  max-width: 60ch;
}
.exp-bullets li { margin-bottom: 4px; }
.tl-company-link {
  cursor: pointer;
  transition: color 0.2s;
}
.tl-company-link:hover { color: var(--accent); }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* EDU + CERTS */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.card h3 {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 22px;
}
.edu-item, .cert-item {
  padding: 16px 0;
  border-top: 1px solid var(--line-soft);
}
.edu-item:first-of-type, .cert-item:first-of-type { border-top: 0; padding-top: 0; }
.edu-clickable {
  cursor: pointer;
  border-radius: 8px;
  margin: 0 -10px;
  padding-left: 10px;
  padding-right: 10px;
  transition: background 0.2s ease;
}
.edu-clickable:hover { background: var(--bg-soft); }
.edu-clickable:hover .school { color: var(--accent); }
.edu-item .school {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.2;
  margin-bottom: 4px;
}
.edu-item .deg, .cert-item .meta { font-size: 14px; color: var(--ink-soft); }
.edu-item .when, .cert-item .when {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.cert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cert-item .name {
  font-family: var(--serif);
  font-size: 22px;
}
.cert-item .right { text-align: right; }
.cert-clickable {
  cursor: pointer;
  border-radius: 8px;
  margin: 0 -10px;
  padding-left: 10px;
  padding-right: 10px;
  transition: background 0.2s ease;
}
.cert-clickable:hover { background: var(--bg-soft); }
.cert-clickable:hover .name { color: var(--accent); }
.cert-preview-hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 4px;
}

/* CERTIFICATE PREVIEW MODAL */
.cert-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: color-mix(in srgb, var(--ink) 65%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.cert-modal.show { opacity: 1; pointer-events: auto; }
.cert-modal-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: min(860px, 100%);
  max-height: calc(100svh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.35);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
}
.cert-modal.show .cert-modal-panel { transform: translateY(0) scale(1); }
html[data-pixel="on"] .cert-modal-panel { border-radius: 0; box-shadow: 10px 10px 0 var(--ink); }
.cert-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.cert-modal-name {
  font-family: var(--serif);
  font-size: clamp(18px, 2.5vw, 24px);
  line-height: 1.2;
}
.cert-modal-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-top: 3px;
}
.cert-modal-close {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 20px;
  color: var(--muted);
  line-height: 1;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.cert-modal-close:hover { color: var(--ink); border-color: var(--ink); background: var(--bg-soft); }
html[data-pixel="on"] .cert-modal-close { border-radius: 0; }
.cert-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.cert-modal-iframe-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: clamp(400px, 60svh, 700px);
}
.cert-modal-iframe-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 142.86%;   /* 1 / 0.70 — compensates for scale below */
  height: 142.86%;
  transform: scale(0.70);
  transform-origin: top left;
  border: 0;
  display: block;
}
.cert-modal-empty {
  flex: 1;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 48px;
  min-height: 200px;
}

/* FEATURED PROJECTS */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 860px) { .feature-grid { grid-template-columns: 1fr; } }
.feature {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.feature:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.feature::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}
.feature:hover::before { transform: scaleX(1); }
.feature .top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.feature .num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.feature .year {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.feature h3 {
  font-family: var(--serif);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 400;
  margin: 4px 0 0;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.feature .sponsor {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.feature .blurb {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0;
}
.feature ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.feature li {
  font-size: 14px;
  color: var(--ink-soft);
  padding-left: 18px;
  position: relative;
}
.feature li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--mono);
}

/* PROJECTS GRID */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border-top: 1px solid var(--line-soft);
}
@media (max-width: 760px) { .proj-grid { grid-template-columns: 1fr; } }
.proj {
  padding: 26px 0;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  cursor: default;
}
.proj-grid .proj:nth-child(odd) { padding-right: 28px; border-right: 1px solid var(--line-soft); }
.proj-grid .proj:nth-child(even) { padding-left: 28px; }
@media (max-width: 760px) {
  .proj-grid .proj:nth-child(odd) { padding-right: 0; border-right: 0; }
  .proj-grid .proj:nth-child(even) { padding-left: 0; }
}
.proj h3 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.proj h3 .yr {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.proj p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 56ch;
}
.proj-right {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
/* toggle indicator — hidden on desktop, shown on mobile */
.proj-toggle { display: none; }

/* COURSES */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.course {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 16px;
  background: var(--bg-card);
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.course:hover { border-color: var(--accent); transform: translateY(-2px); }
.course-clickable { cursor: pointer; }
.course .tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.course .name {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  margin-bottom: 8px;
}
.course .by {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* CONTACT */
.contact {
  padding: clamp(56px, 7vw, 88px) 0 clamp(60px, 8vw, 120px);
}
.contact .lead {
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 24px 0 36px;
  font-weight: 400;
  text-wrap: balance;
}
.contact .lead em {
  font-style: italic;
  color: var(--accent);
}
.contact .email-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 52px);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.contact .email-link:hover { color: var(--accent); border-color: var(--accent); }
.contact .email-link .arrow { transition: transform 0.2s ease; }
.contact .email-link:hover .arrow { transform: translate(4px, -4px); }

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 48px;
}
.social {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.social:hover { border-color: var(--accent); color: var(--accent); }

/* FOOTER */
.foot {
  border-top: 1px solid var(--line-soft);
  padding: 16px 16px;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 8px;
}

/* PIXEL MODE — scanlines + squared corners + terminal chrome.
   VT323 headlines are now always-on; pixel mode adds the rest. */
html[data-pixel="on"] body {
  background-image:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.018) 0 1px, transparent 1px 4px);
}

/* Slightly larger headline sizes in full pixel mode */
html[data-pixel="on"] .hero h1        { font-size: clamp(76px, 13vw, 188px); }
html[data-pixel="on"] .section-head h2 { font-size: clamp(46px, 6.5vw, 84px); }
/* contact lead uses serif — no pixel-mode size bump needed */

/* squared corners across the board for the pixel feel */
html[data-pixel="on"] .card,
html[data-pixel="on"] .feature,
html[data-pixel="on"] .course,
html[data-pixel="on"] .avatar-card,
html[data-pixel="on"] .avatar-frame,
html[data-pixel="on"] .nav-cta,
html[data-pixel="on"] .social,
html[data-pixel="on"] .chip,
html[data-pixel="on"] .nav-links a,
html[data-pixel="on"] .tl-row:hover,
html[data-pixel="on"] .nav-brand .dot,
html[data-pixel="on"] .hero-meta .value .dot { border-radius: 0 !important; }

html[data-pixel="on"] .nav-brand .dot { box-shadow: 0 0 0 3px var(--accent-bg); }

/* Terminal / Windows XP window chrome on the avatar card */
html[data-pixel="on"] .avatar-card {
  border: 2px solid var(--ink);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.45),   /* raised-edge highlight */
    inset -1px -1px 0 rgba(0,0,0,0.15),        /* inner shadow edge */
    6px 6px 0 var(--ink);                       /* hard offset drop shadow */
  overflow: hidden;
  padding-top: 36px;                            /* room for title bar */
}

/* Terminal title bar via ::before */
html[data-pixel="on"] .avatar-card::before {
  content: "ahmed@portfolio — avatar.png";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 7px 10px 0;
  line-height: 1;
  z-index: 2;
}

/* ============================================================
   HIDDEN GEMS — easter eggs
   ============================================================ */

/* Toast / achievement popup */
.gem-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: var(--bg);
  border: 2px solid var(--gem);
  padding: 14px 22px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1), opacity 0.4s;
  pointer-events: none;
  box-shadow: 6px 6px 0 var(--gem);
}
.gem-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.gem-toast .badge {
  width: 28px; height: 28px;
  background: var(--gem);
  color: #0a0a0a;
  display: inline-grid;
  place-items: center;
  font-weight: 600;
}
.gem-toast .label { display: block; font-size: 10px; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.16em; margin-bottom: 2px; }
.gem-toast .name { font-size: 14px; }

/* Avatar wiggle on click */
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20% { transform: rotate(-4deg) scale(1.03); }
  40% { transform: rotate(3deg) scale(1.02); }
  60% { transform: rotate(-2deg) scale(1.04); }
  80% { transform: rotate(2deg) scale(1.01); }
}
.avatar-frame img {
  cursor: pointer;
  transition: filter 0.3s;
}
.avatar-frame.wiggle img { animation: wiggle 0.6s ease; }
.avatar-frame.glitch img { filter: hue-rotate(45deg) saturate(1.4) contrast(1.2); }

/* Konami pixel-heart shower */
.gem-rain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 199;
  overflow: hidden;
}
.gem-rain .pix {
  position: absolute;
  top: -32px;
  width: 16px; height: 16px;
  font-family: var(--mono);
  font-size: 22px;
  color: var(--gem);
  animation: fall linear forwards;
  image-rendering: pixelated;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(360deg); }
}

/* Konami terminal */
.gem-term {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: min(380px, calc(100vw - 48px));
  background: #0a0a0a;
  color: #d8f7d8;
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid #2a4a2a;
  z-index: 201;
  transform: translateX(120%);
  transition: transform 0.5s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}
.gem-term.show { transform: translateX(0); }
.gem-term .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #131313;
  border-bottom: 1px solid #2a4a2a;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.gem-term .bar .lights { display: flex; gap: 5px; }
.gem-term .bar .lights span {
  width: 10px; height: 10px;
  background: #444;
  display: inline-block;
}
.gem-term .bar .lights span:nth-child(1) { background: #e06c5e; }
.gem-term .bar .lights span:nth-child(2) { background: #e5c45e; }
.gem-term .bar .lights span:nth-child(3) { background: #6ec56e; }
.gem-term .bar .close { cursor: pointer; color: #888; }
.gem-term .body {
  padding: 14px 14px 18px;
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 120px;
}
.gem-term .body .prompt { color: #6ec56e; }
.gem-term .body .accent { color: #6ec56e; }
.gem-term .body .cursor {
  display: inline-block;
  width: 7px;
  background: #d8f7d8;
  height: 1em;
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Gems counter — appears in nav once any are found */
.gems-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gem);
  border: 1px solid var(--gem);
  background: var(--gem-bg);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.2s;
}
.gems-count:hover { transform: translateY(-1px); }

/* Gems modal */
.gems-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: color-mix(in srgb, var(--ink) 60%, transparent);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.gems-modal.show { opacity: 1; pointer-events: auto; }
.gems-modal .panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  padding: 28px;
  position: relative;
}
html[data-pixel="on"] .gems-modal .panel { border-radius: 0; box-shadow: 8px 8px 0 var(--gem); }
.gems-modal h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  margin: 0 0 4px;
}
.gems-modal .sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 22px;
}
.gems-modal .gem {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}
.gems-modal .gem:first-of-type { border-top: 0; }
.gems-modal .gem .icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--muted);
}
.gems-modal .gem.found .icon { background: var(--gem); color: #0a0a0a; }
.gems-modal .gem .title { font-family: var(--serif); font-size: 18px; }
.gems-modal .gem .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.gems-modal .gem.found .hint { color: var(--ink-soft); }
.gems-modal .gem .stat {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.gems-modal .gem.found .stat { color: var(--gem); }
.gems-modal .close {
  position: absolute;
  top: 14px; right: 16px;
  font-family: var(--mono);
  font-size: 18px;
  color: var(--muted);
}
.gems-modal .close:hover { color: var(--ink); }

/* reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}

/* ============================================================
   MOBILE — responsive fine-tuning
   ============================================================ */

/* Nav: compact on very small phones */
@media (max-width: 420px) {
  .nav-inner { height: 56px; }
  .hero { scroll-margin-top: 56px; }
  .nav-cta { padding: 7px 10px; font-size: 11px; letter-spacing: 0.02em; }
  .nav-brand { font-size: 11px; gap: 8px; }
}

/* Section heads: stack when h2 + meta would fight for width */
@media (max-width: 540px) {
  .section-head { flex-direction: column; gap: 6px; align-items: flex-start; }
  .section-head .meta { white-space: normal; }
}

/* Hero: tighter vertical rhythm on mobile */
@media (max-width: 540px) {
  .hero { padding-top: 18px; padding-bottom: 48px; }
  .hero-meta { gap: 16px 20px; margin-top: 24px; }
}

/* Contact: prevent email from overflowing narrow viewports */
@media (max-width: 640px) {
  .contact .lead { font-size: clamp(30px, 8vw, 44px); }
  .contact .email-link {
    font-size: clamp(17px, 5vw, 28px);
    word-break: break-all;
    gap: 6px;
  }
  .socials { gap: 10px; margin-top: 32px; }
  .social { padding: 10px 16px; }
}

/* Display headline mobile clamps */
@media (max-width: 640px) {
  /* hero h1 now only shares row with avatar, eyebrow is above — more room for larger text */
  .hero h1          { font-size: clamp(52px, 13.5vw, 72px); }
  .section-head h2  { font-size: clamp(38px, 7vw, 44px); }
  html[data-pixel="on"] .hero h1        { font-size: clamp(54px, 14vw, 76px); }
  html[data-pixel="on"] .section-head h2 { font-size: clamp(40px, 7.5vw, 46px); }
}

/* Footer: stack left-aligned on tiny phones */
@media (max-width: 480px) {
  .foot { flex-direction: column; gap: 4px; align-items: flex-start; }
}

/* Expandable project cards on mobile */
@media (max-width: 760px) {
  .proj h3 { cursor: pointer; user-select: none; }
  .proj-toggle {
    display: inline-flex;
    align-items: center;
    font-family: var(--mono);
    font-size: 18px;
    color: var(--muted);
    line-height: 1;
    transition: color 0.2s;
  }
  .proj.open .proj-toggle { color: var(--accent); }
  .proj-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
  }
  .proj.open .proj-details { max-height: 320px; }
}

/* Expandable featured project cards on mobile */
.feature-toggle { display: none; }
@media (max-width: 860px) {
  .feature { cursor: pointer; }
  .feature-toggle {
    display: inline-flex;
    font-family: var(--mono);
    font-size: 16px;
    color: var(--muted);
    transition: color 0.2s;
  }
  .feature.open .feature-toggle { color: var(--accent); }
  .feature-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.45s ease;
  }
  .feature.open .feature-details { max-height: 600px; }
}

/* Always Learning: 2 cards per row on mobile */
@media (max-width: 640px) {
  .courses-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .course { padding: 12px 12px 10px; }
  .course .name { font-size: 16px; }
  .course .tag { margin-bottom: 6px; }
}

/* About: more compact on mobile */
@media (max-width: 760px) {
  #about { padding: clamp(32px, 5vw, 48px) 0; }
  .about-grid { gap: 20px; }
  .about-grid .body p { font-size: clamp(16px, 4.5vw, 20px); margin-bottom: 0.6em; }
  .about-side { gap: 0; }
  .about-side .row { padding: 8px 0; }
}

/* Expandable experience rows on mobile — same pattern as projects */
.tl-toggle { display: none; }

@media (max-width: 660px) {
  .tl-row { cursor: pointer; user-select: none; }
  /* Disable desktop hover highlight on touch */
  .tl-row:hover { background: none; border-radius: 0; padding-left: 0; padding-right: 0; }
  .tl-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }
  .tl-toggle {
    display: inline-flex;
    font-family: var(--mono);
    font-size: 18px;
    color: var(--muted);
    line-height: 1;
    flex-shrink: 0;
    padding-top: 2px;
    transition: color 0.2s;
  }
  .tl-row.open .tl-toggle { color: var(--accent); }
  .tl-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.38s ease;
  }
  .tl-row.open .tl-details { max-height: 500px; }
}

/* ============================================================
   MOBILE SCROLL SNAP — section-per-scroll paged layout
   ============================================================ */
@media (max-width: 760px) {
  .hero,
  section {
    scroll-snap-align: start;
    min-height: calc(100svh - 64px);
  }
  /* Hero: flex column so hero-grid can grow to full height */
  .hero {
    display: flex;
    flex-direction: column;
    padding-top: 0;
    padding-bottom: 0;
  }
  /* hero-grid IS .wrap — grows to fill hero, centers content vertically */
  .hero-grid {
    flex: 1;
    align-content: center;
    padding-top: clamp(32px, 6svh, 56px);
    padding-bottom: clamp(32px, 6svh, 56px);
  }
}
