/* =================================================================
   Achmad Bayhaqy — Portfolio (v2 · White / Red / Black)
   Palette: White background · Red accent (#B91C1C) · Black body
   Typography: Inter (sans) + Source Serif 4 (display italics)
   Mobile-first, flexible layouts, executive-but-warmer feel.
   ================================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Color — white / red / black (LIGHT THEME — default) */
  --red-700:    #B91C1C;   /* primary accent */
  --red-800:    #991B1B;   /* hover */
  --red-900:    #7F1D1D;   /* strong */
  --red-50:     #FEF2F2;   /* tint background */

  --ink:        #111111;   /* near-black body text */
  --ink-soft:   #1F2937;   /* gray-800 */
  --ink-mute:   #6B7280;   /* gray-500 metadata */
  --ink-faint:  #9CA3AF;   /* gray-400 */

  --line:       #E5E7EB;   /* gray-200 dividers */
  --line-soft:  #F3F4F6;   /* gray-100 */
  --paper:      #FFFFFF;
  --paper-alt:  #FAFAFA;   /* off-white section bg */

  /* Header bg (semi-transparent for blur) */
  --header-bg:        rgba(255, 255, 255, 0.92);
  --header-bg-scrolled: rgba(255, 255, 255, 0.96);

  /* Footer */
  --footer-bg:    #111111;
  --footer-text:  #9CA3AF;
  --footer-accent: #D1D5DB;

  /* Selection */
  --selection-bg: var(--red-700);
  --selection-fg: #FFFFFF;

  /* Type scale */
  --fs-xs:   0.78rem;
  --fs-sm:   0.875rem;
  --fs-base: 1rem;
  --fs-md:   1.125rem;
  --fs-lg:   1.375rem;
  --fs-xl:   1.75rem;
  --fs-2xl:  2.25rem;
  --fs-3xl:  3rem;
  --fs-4xl:  3.75rem;

  /* Spacing */
  --space-section: clamp(3.5rem, 7vw, 6.5rem);
  --container:     1140px;

  /* Radius / shadow */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(17,17,17,0.04), 0 1px 3px rgba(17,17,17,0.05);
  --shadow:    0 4px 14px rgba(17,17,17,0.06), 0 2px 6px rgba(17,17,17,0.04);
  --shadow-lg: 0 20px 40px -16px rgba(17,17,17,0.18);

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --ink:        #F1F5F9;   /* light text on dark bg */
  --ink-soft:   #CBD5E1;   /* slate-300 */
  --ink-mute:   #94A3B8;   /* slate-400 */
  --ink-faint:  #64748B;   /* slate-500 */

  --line:       #334155;   /* slate-700 dividers */
  --line-soft:  #1E293B;   /* slate-800 */
  --paper:      #0F172A;   /* slate-900 main bg */
  --paper-alt:  #1E293B;   /* slate-800 alt bg */

  --red-50:     rgba(185, 28, 28, 0.12);  /* dark tint */

  --header-bg:        rgba(15, 23, 42, 0.92);
  --header-bg-scrolled: rgba(15, 23, 42, 0.97);

  --footer-bg:    #020617;   /* slate-950 */
  --footer-text:  #94A3B8;
  --footer-accent: #CBD5E1;

  --selection-bg: var(--red-700);
  --selection-fg: #FFFFFF;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 14px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 40px -16px rgba(0,0,0,0.6);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a {
  color: var(--red-700);
  text-decoration: none;
  transition: color .2s var(--ease);
}
a:hover { color: var(--red-900); }
h1, h2, h3, h4 {
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.6em;
  font-weight: 700;
}
p { margin: 0 0 1.1em; color: var(--ink-soft); }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; }
::selection { background: var(--selection-bg); color: var(--selection-fg); }

/* ---------- Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 1.5rem;
}
.section {
  padding-block: var(--space-section);
  background: var(--paper);
  scroll-margin-top: 140px;
}
.section-alt { background: var(--paper-alt); }
.section-head { margin-bottom: 3rem; max-width: 760px; }
.section-eyebrow {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red-700);
  margin: 0 0 0.8em;
}
.section-eyebrow::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--red-700);
  vertical-align: middle;
  margin-right: 0.7em;
  margin-bottom: 4px;
}
.section-title {
  font-size: clamp(var(--fs-xl), 3.5vw, var(--fs-2xl));
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.5em;
}
.section-sub {
  color: var(--ink-mute);
  font-size: var(--fs-md);
  margin: 0;
}
.inline-link {
  color: var(--red-700);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}
.inline-link:hover { border-color: var(--red-700); }

/* ---------- Card primitive ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .25s var(--ease);
}
.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--ink-faint);
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.site-header.scrolled {
  border-bottom-color: var(--line);
  background: var(--header-bg-scrolled);
}
.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 68px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-weight: 700;
}
.brand:hover { color: var(--ink); }
.brand-logo {
  height: 38px;
  width: auto;
  border-radius: 6px;
  display: block;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  /* Hide logo with dark outline when in dark theme; show light variant */
}
[data-theme="dark"] .brand-logo { mix-blend-mode: normal; }
.brand:hover .brand-logo {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--footer-accent);
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  color: var(--footer-accent);
  font-size: var(--fs-xs);
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  letter-spacing: 0.02em;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--footer-text);
  color: #FFFFFF;
}
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { font-size: 14px; line-height: 1; }
.theme-toggle .theme-toggle-label { font-size: var(--fs-xs); font-weight: 500; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Nav extras (hamburger only now) */
.nav-extras {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-links a {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.nav-links a:hover { color: var(--ink); background: var(--line-soft); }
.nav-links a.active {
  color: var(--red-700);
  position: relative;
}
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0.8rem; right: 0.8rem; bottom: 0.2rem;
  height: 2px;
  background: var(--red-700);
}
.nav-cta {
  background: var(--red-700);
  color: var(--paper) !important;
  padding: 0.55rem 1.1rem !important;
  border-radius: 6px;
  margin-left: 0.4rem;
}
.nav-cta:hover { background: var(--red-900); color: var(--paper) !important; }
.nav-cta::after { display: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  background: var(--paper);
  padding-block: clamp(3rem, 7vw, 5.5rem) clamp(2.5rem, 5vw, 4.5rem);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 140px;
}
.hero::before {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 50%;
  background:
    radial-gradient(circle at 80% 20%, rgba(185, 28, 28, 0.05), transparent 60%);
  pointer-events: none;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 380px);
  gap: 3rem;
  align-items: start;
  position: relative;
  z-index: 1;
}
.eyebrow {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red-700);
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.eyebrow::before {
  content: "";
  width: 32px;
  height: 2px;
  background: var(--red-700);
}
.hero-title {
  font-size: clamp(var(--fs-2xl), 6vw, var(--fs-4xl));
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: 0 0 0.4rem;
  color: var(--ink);
  line-height: 1.05;
}
.hero-title-accent {
  color: var(--red-700);
}
.hero-tagline {
  font-size: clamp(var(--fs-md), 2.2vw, var(--fs-lg));
  font-weight: 500;
  color: var(--ink-soft);
  margin: 0 0 1.6rem;
  letter-spacing: -0.005em;
}
.hero-summary {
  font-size: var(--fs-md);
  color: var(--ink-soft);
  max-width: 60ch;
  margin-bottom: 2rem;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.4rem;
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all .2s var(--ease);
  border: 1.5px solid transparent;
  text-decoration: none;
}
.btn-primary {
  background: var(--red-700);
  color: var(--paper);
  border-color: var(--red-700);
}
.btn-primary:hover {
  background: var(--red-900);
  border-color: var(--red-900);
  color: var(--paper);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-primary svg { stroke: currentColor; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper);
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
}
.hero-meta li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
}
.hero-meta li:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -0.75rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 1px;
  background: var(--line);
}
.meta-num {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.meta-num::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: var(--red-700);
  margin-top: 0.35rem;
}
.meta-label {
  font-size: var(--fs-xs);
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
  margin-top: 0.3rem;
}

/* Hero photo */
.hero-photo {
  position: relative;
  justify-self: end;
}
.hero-photo img {
  width: 100%;
  max-width: 380px;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 50% 15%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: block;
}
/* Red accent frame */
.hero-photo::before {
  content: "";
  position: absolute;
  top: 14px;
  left: -14px;
  right: 14px;
  bottom: -14px;
  border: 2px solid var(--red-700);
  border-radius: var(--radius-lg);
  z-index: -1;
}
.hero-photo-tag {
  position: absolute;
  left: -1.25rem;
  bottom: 1.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red-700);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 220px;
}
.tag-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--red-700);
  font-weight: 600;
}
.tag-value {
  font-size: var(--fs-sm);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.35;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  gap: 3rem;
  align-items: start;
}
.about-body p { font-size: var(--fs-md); }
.about-body p:last-child { margin-bottom: 0; }
.about-quote {
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  font-size: var(--fs-md);
  color: var(--ink);
  border-left: 3px solid var(--red-700);
  padding-left: 1.25rem;
  margin-top: 1.5rem;
}
.about-side {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.about-side h3 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  margin-bottom: 1rem;
}
.stat-card { border-left: 3px solid var(--red-700); }
.impact-list, .focus-list { display: flex; flex-direction: column; gap: 0.85rem; }
.impact-list li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 0.85rem;
  align-items: baseline;
}
.impact-num {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--red-700);
  letter-spacing: -0.02em;
}
.impact-text {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.5;
}
.focus-list li {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  padding-left: 1.1rem;
  position: relative;
}
.focus-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  background: var(--red-700);
  border-radius: 50%;
}

/* ---------- Timeline / Experience ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 200px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--line);
}
.timeline-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 194px;
  top: 8px;
  width: 14px;
  height: 14px;
  background: var(--paper);
  border: 2px solid var(--red-700);
  border-radius: 50%;
  z-index: 1;
  box-shadow: 0 0 0 4px var(--paper);
}
.timeline-item:hover::before {
  background: var(--red-700);
}
.timeline-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 4px;
}
.timeline-period {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--red-700);
  letter-spacing: 0.01em;
}
.timeline-org {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  line-height: 1.45;
}
.timeline-body { padding-left: 1rem; }
.role-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
.role-period {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  font-style: italic;
  margin-bottom: 0.85rem;
}
.timeline-body p { font-size: var(--fs-base); }
.role-bullets {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.role-bullets li {
  position: relative;
  padding-left: 1.25rem;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.55;
}
.role-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  background: var(--red-700);
  border-radius: 50%;
}

/* ---------- Expertise ---------- */
.expertise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}
.expertise-card {
  position: relative;
  border-top: 3px solid var(--red-700);
}
.expertise-card h3 {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.expertise-card p {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}

.tech-stack {
  border-top: 1px solid var(--line);
  padding-top: 2rem;
}
.tech-stack-title {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  margin-bottom: 1rem;
  font-weight: 600;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-list li {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--paper);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
  border: 1px solid var(--line);
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.tag-list li:hover {
  border-color: var(--red-700);
  color: var(--red-700);
}

/* ---------- Education ---------- */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.edu-subhead {
  margin-top: 2.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.edu-subhead:first-of-type { margin-top: 0; }
.edu-subhead-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
}
.edu-subhead-note {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  margin: 0;
  max-width: 60ch;
}
.edu-subhead-note .inline-link { color: var(--red-700); text-decoration: none; border-bottom: 1px solid currentColor; }
.edu-subhead-note .inline-link:hover { color: var(--red-900); }
.edu-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-left: 3px solid var(--red-700);
}
.edu-period {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--red-700);
}
.edu-card h3 { font-size: var(--fs-md); color: var(--ink); margin: 0.1rem 0 0; }
.edu-school { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0; font-weight: 500; }
.edu-note { font-size: var(--fs-sm); color: var(--ink-mute); margin-top: 0.6rem; font-style: italic; }

/* ---------- Featured credential cards (with badge images) ---------- */
.cert-featured {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}
.cert-featured-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.cert-featured-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--red-700);
}
.cert-featured-img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f4f4f4;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.cert-featured-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s var(--ease);
}
.cert-featured-card:hover .cert-featured-img img { transform: scale(1.03); }
.cert-featured-body {
  padding: 1.25rem 1.4rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}
.cert-featured-tag {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red-700);
}
.cert-featured-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.cert-featured-desc {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  line-height: 1.55;
  margin: 0;
}
.verify-link {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--red-700);
  text-decoration: none;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  transition: color .2s var(--ease);
}
.verify-link:hover { color: var(--red-900); }
.inline-text { font-weight: 600; color: var(--ink-soft); }

/* ---------- Certifications ---------- */
.cert-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.cert-group h3 {
  font-size: var(--fs-md);
  color: var(--ink);
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--red-700);
  display: inline-block;
}
.cert-group ul { display: flex; flex-direction: column; gap: 0.5rem; }
.cert-group li {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  padding-left: 1.4rem;
  position: relative;
  line-height: 1.5;
}
.cert-group li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 8px;
  height: 8px;
  border: 2px solid var(--red-700);
  border-radius: 2px;
  transform: rotate(45deg);
}
/* Clickable cert links */
.cert-group li a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .2s var(--ease);
  padding: 0.15rem 0;
}
.cert-group li a:hover { color: var(--red-700); }
.cert-group li a .cert-ext {
  font-size: 0.85em;
  color: var(--ink-faint);
  transition: color .2s var(--ease), transform .2s var(--ease);
}
.cert-group li a:hover .cert-ext {
  color: var(--red-700);
  transform: translate(2px, -2px);
}

/* ---------- Publications (cards with inline PDF viewer) ---------- */
.pub-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.pub-card {
  padding: 1.4rem 1.5rem;
  border-left: 3px solid var(--red-700);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.pub-card:hover {
  box-shadow: var(--shadow);
}
.pub-card-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.pub-card-num {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: -0.02em;
  flex-shrink: 0;
  min-width: 2.4rem;
  line-height: 1;
  padding-top: 0.15rem;
}
.pub-card-meta { flex: 1; min-width: 0; }
.pub-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.35rem;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.pub-card-title a {
  color: inherit;
  text-decoration: none;
  transition: color .2s var(--ease);
}
.pub-card-title a:hover { color: var(--red-700); }
.pub-card-venue {
  font-size: var(--fs-xs);
  color: var(--ink-mute);
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pub-card-body {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.6;
}
.pub-card-body p { margin: 0; }
.pub-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.pub-toggle {
  cursor: pointer;
  font-family: inherit;
  background: transparent;
}
.pub-toggle .toggle-icon {
  display: inline-block;
  transition: transform .25s var(--ease);
  font-size: 0.85em;
}
.pub-toggle[aria-expanded="true"] .toggle-icon { transform: rotate(180deg); }
.pub-toggle[aria-expanded="true"] .toggle-text::before { content: "Hide "; }

.pub-pdf-wrap {
  margin-top: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-alt);
}
.pub-pdf-wrap[hidden] { display: none; }

/* ---------- AWS image-card grid (image evidence cards) ---------- */
.cert-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.cert-image-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.cert-image-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--red-700);
}
.cert-image-img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f4f4f4;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.cert-image-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #ffffff;
  transition: transform .35s var(--ease);
}
.cert-image-card:hover .cert-image-img img { transform: scale(1.03); }
.cert-image-body {
  padding: 1rem 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.cert-image-tag {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red-700);
}
.cert-image-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.005em;
  line-height: 1.35;
}
.pub-pdf-wrap iframe {
  width: 100%;
  height: 70vh;
  min-height: 480px;
  max-height: 800px;
  border: 0;
  display: block;
  background: #525659;
}
.pub-pdf-fallback {
  display: block;
  padding: 0.65rem 1rem;
  font-size: var(--fs-xs);
  color: var(--ink-mute);
  background: var(--paper);
  border-top: 1px solid var(--line);
  text-decoration: none;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.pub-pdf-fallback:hover {
  color: var(--red-700);
  background: var(--red-50);
}

/* ---------- Contact (editorial split layout) ---------- */
.contact-section {
  background: var(--paper);
  position: relative;
  overflow: hidden;
}
.contact-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 60% at 100% 0%, var(--red-50), transparent 60%);
  pointer-events: none;
}
.contact-section .container { position: relative; z-index: 1; }

.contact-editorial {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}
.contact-invite {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.contact-lead {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: clamp(var(--fs-md), 2vw, var(--fs-lg));
  line-height: 1.55;
  color: var(--ink);
  margin: 0;
  font-style: italic;
}
.contact-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-start;
}
.contact-note {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  margin: 0;
  line-height: 1.5;
}

.contact-links {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.contact-links li {
  border-bottom: 1px solid var(--line);
}
.contact-links li a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.25rem;
  color: var(--ink);
  transition: padding-left .25s var(--ease), color .2s var(--ease);
  text-decoration: none;
}
.contact-links li a:hover {
  padding-left: 0.75rem;
  color: var(--red-700);
}
.cl-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--red-700);
  font-weight: 700;
  flex-shrink: 0;
  width: 80px;
}
.cl-value {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-soft);
  flex: 1;
  word-break: break-word;
}
.cl-arrow {
  font-size: var(--fs-md);
  color: var(--ink-faint);
  transition: transform .25s var(--ease), color .2s var(--ease);
  flex-shrink: 0;
}
.contact-links li a:hover .cl-arrow {
  transform: translateX(4px);
  color: var(--red-700);
}
.contact-links-static {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.25rem;
}
.contact-links-static .cl-value { color: var(--ink-soft); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-accent);
  padding-block: 1.5rem;
  border-top: 3px solid var(--red-700);
}
.footer-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}
.footer-copy {
  font-size: var(--fs-xs);
  color: var(--footer-text);
  margin: 0;
  letter-spacing: 0.02em;
  text-align: left;
}
@media (max-width: 540px) {
  .footer-wrap { justify-content: center; text-align: center; }
  .footer-copy { text-align: center; width: 100%; }
}

/* ---------- Responsive (mobile-first adjustments) ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero-photo {
    justify-self: start;
    max-width: 320px;
  }
  .hero-photo img { max-width: 320px; }
  .hero-photo-tag { left: 1rem; right: auto; max-width: 200px; }

  .about-grid { grid-template-columns: 1fr; gap: 2rem; }

  /* Timeline collapses */
  .timeline::before { display: none; }
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line-soft);
  }
  .timeline-item:last-child { border-bottom: 0; }
  .timeline-item::before { display: none; }
  .timeline-body { padding-left: 0; }
  .timeline-meta {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    padding-top: 0;
  }
  .timeline-period::after {
    content: "·";
    margin-left: 0.6rem;
    color: var(--ink-faint);
  }

  .hero-meta { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
  .hero-meta li:not(:last-child)::after { display: none; }
}

@media (max-width: 720px) {
  .container { padding-inline: 1.25rem; }

  /* Shrink sticky header on mobile for more content space */
  .nav-wrap { height: 56px; }
  .brand-logo { height: 28px; }
  .nav-toggle { padding: 6px; }
  .nav-toggle span { width: 20px; }

  .nav-links {
    position: fixed;
    inset: 56px 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 1.25rem 1rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .3s var(--ease), visibility 0s linear .3s;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  .nav-links.open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform .3s var(--ease), visibility 0s linear 0s;
  }
  .nav-links a {
    padding: 0.9rem 0.5rem;
    border-radius: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .nav-links a:last-of-type { border-bottom: 0; }
  .nav-links a.active::after { display: none; }
  .nav-cta {
    text-align: center;
    margin-top: 0.6rem;
    border-radius: 6px;
    padding: 0.75rem 1rem !important;
  }
  .nav-toggle { display: flex; }

  /* On mobile, theme toggle is a clean icon-only circle */
  .nav-extras { gap: 0.35rem; }
  .theme-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 16px;
    border-radius: 999px;
  }
  .theme-toggle .theme-toggle-label { display: none; }
  .nav-games { display: none; }  /* hidden on mobile — shown in nav menu instead */

  .hero { padding-top: 4.5rem; padding-bottom: 2.5rem; }
  .hero-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .hero-actions .btn { width: 100%; }
  .hero-photo {
    max-width: 260px;
    margin-inline: auto;
  }
  .hero-photo::before {
    top: 10px;
    left: -10px;
    right: 10px;
    bottom: -10px;
  }
  .hero-photo-tag {
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
    bottom: 1rem;
  }

  .section-head { margin-bottom: 2rem; }

  /* Contact editorial: stack columns on small screens */
  .contact-editorial { grid-template-columns: 1fr; gap: 2rem; }
  .contact-lead { font-size: var(--fs-md); }
  .contact-invite { gap: 1.25rem; }
  .cl-label { width: 70px; }

  .footer-wrap { flex-direction: column; align-items: center; }
  .footer-copy { text-align: center; width: 100%; }
}

@media (max-width: 480px) {
  .hero-meta { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .pub-card { padding: 1.1rem 1.25rem; }
  .pub-card-head { gap: 0.75rem; }
  .pub-card-num { font-size: var(--fs-lg); min-width: 2rem; }
  .pub-pdf-wrap iframe { height: 55vh; min-height: 360px; }
  .card { padding: 1.25rem; }
  .section-title { font-size: var(--fs-xl); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .nav-toggle, .hero-actions, .site-footer { display: none; }
  .section { padding-block: 1.5rem; }
  .card { box-shadow: none; }
  body { color: #000; background: #fff; }
  a { color: #000; }
}

/* ---------- Reading progress bar ---------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--red-700), var(--red-900));
  z-index: 200;
  transition: width .1s linear;
  box-shadow: 0 0 8px rgba(185, 28, 28, 0.4);
}

/* ---------- Back to top button ---------- */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .3s var(--ease), transform .3s var(--ease), visibility .3s, background .2s, border-color .2s;
  z-index: 90;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--red-700);
  border-color: var(--red-700);
  transform: translateY(-3px);
}

/* ---------- Hero stat counter animation ---------- */
.meta-num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Magnetic button effect (applied via JS) ---------- */
.btn.magnetic {
  transition: transform .15s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease);
}

/* ---------- Tech stack tag hover pulse ---------- */
.tag-list li {
  cursor: default;
}
.tag-list li:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ---------- Section nav dots (right side) ---------- */
.section-dots {
  position: fixed;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  z-index: 80;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s var(--ease), visibility .3s;
}
.section-dots.visible {
  opacity: 1;
  visibility: visible;
}
.section-dots a {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  border: 2px solid transparent;
  transition: all .2s var(--ease);
  position: relative;
}
.section-dots a:hover { background: var(--ink-faint); transform: scale(1.2); }
.section-dots a.active {
  background: var(--red-700);
  border-color: var(--paper);
  box-shadow: 0 0 0 1px var(--red-700);
}
.section-dots a::after {
  content: attr(data-label);
  position: absolute;
  right: calc(100% + 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--fs-xs);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
  font-weight: 500;
}
.section-dots a:hover::after { opacity: 1; }

@media (max-width: 960px) {
  .section-dots { display: none; }
}
@media (max-width: 480px) {
  .back-to-top { right: 1rem; bottom: 1rem; width: 42px; height: 42px; }
}
