/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --bg-card: #141414;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.18);
  --text: #f0ede8;
  --text-muted: #8a867f;           /* was #7a7670 — lifted slightly to pass WCAG AA contrast (4.5:1) */
  --accent: #c8f04a;
  --accent-dim: rgba(200, 240, 74, 0.12);
  --accent-glow: rgba(200, 240, 74, 0.25);
  --danger: #ff5f57;
  --mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 12px;
  --nav-h: 64px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h);
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html.no-scroll { overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  counter-reset: section;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* ===== SELECTION ===== */
::selection { background: var(--accent); color: #000; }

/* ===== ACCESSIBILITY ===== */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 300;
  padding: 0.6rem 1rem; border-radius: 6px;
  background: var(--accent); color: #000;
  font-family: var(--mono); font-size: 0.8rem; text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--transition);
}
.skip-link:focus { transform: none; }
[hidden] { display: none !important; }
[tabindex="-1"]:focus { outline: none; }

/* ===== UTILITY ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 2rem; }
.mono { font-family: var(--mono); }
.section { padding: 120px 0; }
.noscript-note { color: var(--text-muted); margin-top: 1.5rem; }
.noscript-note a { color: var(--accent); }

/* section numbers are generated, so hiding a section (e.g. no certificates) never leaves a gap */
.section-label {
  counter-increment: section;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.section-label::before { content: counter(section, decimal-leading-zero) " — "; }

.section-title {
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.15;
  margin-bottom: 2rem;
  color: var(--text);
  overflow-wrap: break-word;
}
.section-title em {
  font-style: italic;
  color: var(--accent);
}

/* ===== BUTTONS ===== */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.75rem 1.75rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  letter-spacing: 0.05em;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 500;
}
.btn-primary:hover {
  background: #d8ff55;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}
.btn:disabled { cursor: not-allowed; opacity: 0.7; transform: none; box-shadow: none; }
.full-width { width: 100%; justify-content: center; }

/* ===== NAV ===== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 100;
  transition: background var(--transition), border-bottom var(--transition);
  border-bottom: 1px solid transparent;
}
.nav.scrolled,
.nav.menu-open {
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}
.nav-logo {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-decoration: none;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 2.5rem;
}
.nav-links a {
  position: relative;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.08em;
  padding: 0.5rem 0;
  transition: color var(--transition);
}
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease-out);
}
.nav-links a:hover,
.nav-links a.active { color: var(--accent); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }
.nav-toggle { display: none; }

/* ===== HERO ===== */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding-top: var(--nav-h);
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  will-change: transform;
}
.orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(200,240,74,0.3), transparent 70%);
  top: -150px; right: -100px;
  animation: orb-float 8s ease-in-out infinite;
}
.orb-2 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(200,240,74,0.15), transparent 70%);
  bottom: 100px; left: -50px;
  animation: orb-float 10s ease-in-out infinite reverse;
}
@keyframes orb-float {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 2rem;
  max-width: 560px;
  margin-left: calc((100vw - 1100px) / 2);
  animation: hero-in 1s cubic-bezier(0.4,0,0.2,1) both;
}
@media (max-width: 1140px) { .hero-content { margin-left: 2rem; } }

@keyframes hero-in {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 100px;
  background: var(--accent-dim);
}
.hero-label::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: blink 1.5s ease-in-out infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; }
  50% { opacity: 0; }
}

.hero-name {
  font-family: var(--serif);
  font-size: clamp(3.5rem, 8vw, 6.5rem);
  line-height: 0.95;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}
.hero-name em {
  font-style: italic;
  color: var(--accent);
}

.hero-role {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
  min-height: 1.7em;
  transition: opacity 0.3s, transform 0.3s;
}
.hero-role.swapping { opacity: 0; transform: translateY(6px); }

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.75;
  margin-bottom: 2.5rem;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* hero code card */
.hero-code {
  position: absolute;
  right: max(2rem, calc((100vw - 1100px)/2));
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  animation: code-in 1.1s 0.3s cubic-bezier(0.4,0,0.2,1) both;
}
@keyframes code-in {
  from { opacity: 0; transform: translateY(-40%) translateX(30px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
.code-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 340px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) inset;
}
.code-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.red    { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green  { background: #28c840; }
.code-filename {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}
.code-body {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.8;
  padding: 1.25rem 1.25rem 1.5rem;
  color: #bbb;
  white-space: pre;
  overflow-x: auto;
}
.kw  { color: #c792ea; }
.fn  { color: #82aaff; }
.st  { color: #c3e88d; }
.cm  { color: var(--accent); }

.scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  animation: scroll-hint 1.5s 2s both;
}
@keyframes scroll-hint {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.scroll-line {
  width: 1px;
  height: 50px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  animation: scroll-line 2s ease-in-out infinite;
}
@keyframes scroll-line {
  0%,100% { transform: scaleY(1); opacity: 0.6; }
  50% { transform: scaleY(1.2); opacity: 1; }
}

/* ===== ABOUT ===== */
.about {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5rem;
  align-items: center;
}
.about-text p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
}
.about-stats {
  display: flex;
  gap: 2.5rem;
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.stat-num {
  display: block;
  font-family: var(--serif);
  font-size: 2.5rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.about-visual { display: flex; justify-content: center; }
.avatar-wrap {
  position: relative;
  width: 240px;
  height: 240px;
}
.avatar-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #1a1a1a 0%, #222 100%);
  border: 2px solid var(--border);
}
.avatar-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px dashed rgba(200,240,74,0.3);
  animation: ring-spin 20s linear infinite;
}
@keyframes ring-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ===== SECTION BACKGROUNDS ===== */
.projects { background: var(--bg-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.certificates { border-bottom: 1px solid var(--border); }

/* ===== CONTACT ===== */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5rem;
  align-items: start;
  margin-top: 1rem;
}
.contact-left p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
}
.contact-links { display: flex; flex-direction: column; gap: 0.85rem; }
.contact-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 32px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition), transform var(--transition);
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}
.contact-item:hover { color: var(--accent); transform: translateX(4px); }
.contact-icon { color: var(--accent); font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

/* ===== FOOTER ===== */
.footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
}
.footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.footer-logo {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.footer-copy {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .section { padding: 100px 0; }
  .hero-code { display: none; }
  .hero-content { margin-left: 0; max-width: 100%; padding: 2rem; }
  .about-grid { grid-template-columns: 1fr; gap: 3rem; }
  .about-visual { order: -1; }
  .contact-grid { grid-template-columns: 1fr; gap: 3rem; }
}

/* Hamburger menu from tablet-portrait down — six links no longer fit in one row below this */
@media (max-width: 820px) {
  .nav { padding: 0 1.25rem; }
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px; height: 44px;
    margin-right: -8px;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    display: block;
    transition: transform 0.3s var(--ease), opacity 0.2s;
  }
  .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); }

  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 1.25rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    max-height: calc(100vh - var(--nav-h));
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    /* closed state: not focusable, not clickable */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0s linear 0.25s;
  }
  .nav-links.open {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition-delay: 0s;
  }
  .nav-links li { border-bottom: 1px solid var(--border); }
  .nav-links li:last-child { border-bottom: none; }
  .nav-links a {
    display: flex;
    align-items: center;
    min-height: 52px;
    font-size: 0.9rem;
  }
  .nav-links a::after { display: none; }
}

@media (max-width: 600px) {
  .container { padding: 0 1.25rem; }
  .section { padding: 80px 0; }
  .hero-content { padding: 1.5rem 1.25rem; }
  .hero-cta { flex-direction: column; align-items: stretch; }
  .hero-cta .btn { width: 100%; }
  .about-stats { flex-wrap: wrap; gap: 1.5rem; }
  .avatar-wrap { width: 180px; height: 180px; }
}

@media (max-height: 700px) {
  .scroll-hint { display: none; }
}
