/* ===== Design tokens ===== */
:root {
  --bg: #0f172a;
  --bg-alt: #111c33;
  --surface: #1a2745;
  --surface-2: #22315a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --border: rgba(148, 163, 184, 0.16);
  --max: 1120px;
  --radius: 14px;
  --shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
}

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
.muted { color: var(--muted); }

a { color: inherit; text-decoration: none; }

/* Media never overflows its container on any device */
img, svg, video { max-width: 100%; height: auto; }
:where(img)[width][height] { height: auto; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.8rem 1.6rem; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn--primary { background: var(--accent); color: #04283b; }
.btn--primary:hover { background: #5fccfb; }
.btn--ghost { border-color: var(--accent); color: var(--accent); }
.btn--ghost:hover { background: rgba(56, 189, 248, 0.1); }
.btn--sm { padding: 0.55rem 1.25rem; font-size: 0.92rem; font-weight: 700; letter-spacing: 0.01em; background: #ffffff; color: #0b1324; }
.btn--sm:hover { background: #e2e8f0; transform: none; }

/* ===== Nav ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background .3s ease, padding .3s ease;
}
.nav.scrolled { border-color: var(--border); background: rgba(15, 23, 42, 0.9); }
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.nav__logo { font-weight: 900; font-size: 1.35rem; letter-spacing: -0.02em; }
.nav__logo span { color: var(--accent); }
.nav__links { display: flex; align-items: center; gap: 1.75rem; }
.nav__links a { font-size: 0.92rem; font-weight: 500; color: var(--muted); transition: color .18s ease; position: relative; }
.nav__links a:not(.btn):hover, .nav__links a.active { color: var(--text); }
.nav__links a:not(.btn)::after {
  content: ""; position: absolute; left: 0; bottom: -6px; height: 2px; width: 0;
  background: var(--accent); transition: width .22s ease;
}
.nav__links a:not(.btn):hover::after, .nav__links a.active::after { width: 100%; }

.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; padding: 6px; }
.nav__toggle span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s ease, opacity .25s ease; }
.nav__toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.open span:nth-child(2) { opacity: 0; }
.nav__toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Hero ===== */
.hero { position: relative; min-height: 100vh; min-height: 100svh; display: flex; align-items: center; overflow: hidden; }
.hero__bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(600px circle at 15% 20%, rgba(56, 189, 248, 0.18), transparent 45%),
    radial-gradient(700px circle at 85% 75%, rgba(129, 140, 248, 0.16), transparent 45%),
    linear-gradient(135deg, #0f172a 0%, #0b1324 100%);
}
.hero__bg::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 40%, black, transparent 75%);
  opacity: 0.5;
}
.hero__inner {
  position: relative; z-index: 1; padding: 7rem 1.5rem 5rem;
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 3rem; align-items: center;
}
.hero__content { max-width: 640px; }
.hero__eyebrow { color: var(--accent); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.85rem; margin-bottom: 1.25rem; }

/* ===== Hero portrait ===== */
.hero__portrait { display: flex; justify-content: center; }
.portrait { position: relative; width: min(340px, 80vw); aspect-ratio: 3 / 4; }
.portrait__frame {
  position: absolute; inset: 0; border-radius: 20px; overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: var(--shadow);
  transform: rotate(-3deg);
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
  z-index: 2;
}
.portrait:hover .portrait__frame { transform: rotate(0deg) scale(1.02); }
.portrait__frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait__ring {
  position: absolute; inset: -14px; border-radius: 26px; z-index: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2), transparent 70%);
  padding: 2px; opacity: 0.55;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transform: rotate(-3deg);
  animation: ringspin 14s linear infinite;
}
@keyframes ringspin {
  0% { background: linear-gradient(0deg, var(--accent), var(--accent-2), transparent 70%); }
  100% { background: linear-gradient(360deg, var(--accent), var(--accent-2), transparent 70%); }
}
.portrait__glow {
  position: absolute; inset: -30px; z-index: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.35), transparent 65%);
  filter: blur(28px); animation: pulse 5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.55; transform: scale(1); } 50% { opacity: 0.85; transform: scale(1.06); } }

.portrait__badge {
  position: absolute; z-index: 3; display: inline-flex; align-items: center; gap: 0.45rem;
  background: rgba(26, 39, 69, 0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.5rem 0.9rem; font-size: 0.78rem; font-weight: 600; color: var(--text);
  box-shadow: 0 10px 25px -12px rgba(0,0,0,.7);
  animation: float 6s ease-in-out infinite;
}
.portrait__badge--top { top: 6%; left: -12%; }
.portrait__badge--bottom { bottom: 8%; right: -14%; border-radius: 12px; animation-delay: 1.5s; }
.portrait__badge--bottom strong { color: var(--accent); margin-right: 0.15rem; }
.portrait__badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2); }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.portrait__shape { position: absolute; z-index: 0; }
.portrait__shape--a { width: 70px; height: 70px; border: 2px solid rgba(56,189,248,.35); border-radius: 14px; top: -8%; right: -6%; transform: rotate(18deg); animation: float 7s ease-in-out infinite; }
.portrait__shape--b { width: 46px; height: 46px; border: 2px solid rgba(129,140,248,.4); border-radius: 50%; bottom: -4%; left: -10%; animation: float 8s ease-in-out infinite reverse; }
.hero__title { font-size: clamp(2.6rem, 8vw, 5rem); font-weight: 900; line-height: 1.02; letter-spacing: -0.03em; margin-bottom: 1.5rem; }
.hero__title span {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__lead { font-size: clamp(1.05rem, 2.2vw, 1.3rem); color: var(--muted); max-width: 640px; margin-bottom: 2.25rem; }
.hero__lead strong { color: var(--text); font-weight: 600; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 2.5rem; }
.hero__socials { display: flex; gap: 1.5rem; }
.hero__socials a { color: var(--muted); font-size: 0.9rem; font-weight: 500; transition: color .18s ease; }
.hero__socials a:hover { color: var(--accent); }
.hero__scroll { position: absolute; bottom: 1.75rem; left: 50%; transform: translateX(-50%); z-index: 1; color: var(--muted); font-size: 1.3rem; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 8px); } }

/* ===== Sections ===== */
.section { padding: 6rem 0; }
.section--alt { background: var(--bg-alt); }
.section__head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 2.75rem; }
.section__num { color: var(--accent); font-weight: 700; font-size: 1rem; font-family: ui-monospace, "SF Mono", monospace; }
.section__head h2 { font-size: clamp(1.75rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; }
.section__intro { max-width: 640px; margin-bottom: 2.5rem; margin-top: -1.5rem; }

/* ===== About ===== */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 3rem; align-items: start; }
.about__text p { margin-bottom: 1.15rem; color: var(--muted); }
.about__text strong { color: var(--text); font-weight: 600; }
.about__facts { display: grid; gap: 0.85rem; }
.fact { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.95rem 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.fact__k { color: var(--muted); font-size: 0.85rem; }
.fact__v { font-weight: 600; font-size: 0.92rem; text-align: right; }

/* ===== Skills ===== */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.75rem; }
.skills__group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; }
.skills__group h3 { font-size: 1.05rem; margin-bottom: 1.1rem; }
.skills__group h3 .muted { font-size: 0.8rem; font-weight: 400; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tags li { font-size: 0.85rem; padding: 0.4rem 0.85rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; color: var(--text); }

/* ===== Timeline ===== */
.timeline { position: relative; margin-left: 0.5rem; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl { position: relative; padding: 0 0 2.25rem 2.25rem; }
.tl:last-child { padding-bottom: 0; }
.tl__dot { position: absolute; left: 0; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15); }
.tl__top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.tl__top h3 { font-size: 1.15rem; }
.tl__date { color: var(--faint); font-size: 0.85rem; font-family: ui-monospace, monospace; }
.tl__org { color: var(--accent); font-weight: 500; font-size: 0.95rem; margin: 0.15rem 0 0.75rem; }
.tl__body ul { list-style: none; display: grid; gap: 0.5rem; }
.tl__body li { position: relative; padding-left: 1.15rem; color: var(--muted); font-size: 0.95rem; }
.tl__body li::before { content: "▹"; position: absolute; left: 0; color: var(--accent); }

/* ===== Projects ===== */
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; display: flex; flex-direction: column; gap: 0.75rem; transition: transform .2s ease, border-color .2s ease; }
.card:hover { transform: translateY(-5px); border-color: rgba(56, 189, 248, 0.4); }
.card__tag { align-self: flex-start; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); font-weight: 700; }
.card h3 { font-size: 1.15rem; }
.card p { color: var(--muted); font-size: 0.92rem; flex-grow: 1; }
.card__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.card__tags span { font-size: 0.75rem; color: var(--faint); background: var(--surface-2); padding: 0.25rem 0.6rem; border-radius: 6px; }
.card__link { color: var(--accent); font-weight: 600; font-size: 0.9rem; }

/* ===== Education ===== */
.edu { display: grid; grid-template-columns: 1.3fr 1fr; gap: 2.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.edu__main h3 { font-size: 1.35rem; margin-bottom: 0.35rem; }
.edu__degree { color: var(--accent); font-weight: 500; margin-bottom: 0.5rem; }
.edu__meta { list-style: none; display: grid; gap: 1rem; }
.edu__meta li { font-size: 0.92rem; }
.edu__meta .muted { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ===== Contact ===== */
.contact { text-align: center; }
.contact .section__head { justify-content: center; }
.contact__lead { font-size: clamp(1.1rem, 2.5vw, 1.5rem); max-width: 560px; margin: 0 auto 2rem; color: var(--muted); }
.contact__actions { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }

/* ===== Footer ===== */
.footer { border-top: 1px solid var(--border); padding: 1.75rem 0; }
.footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--faint); font-size: 0.88rem; }
.footer__top { color: var(--muted); transition: color .18s ease; }
.footer__top:hover { color: var(--accent); }

/* ===== Reveal animation ===== */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ===== Placeholder hint (dev only, subtle) ===== */
[data-placeholder] { position: relative; }

/* ===== Responsive ===== */
/* Large screens / 4K — widen the canvas and scale the portrait up a touch */
@media (min-width: 1440px) {
  :root { --max: 1240px; }
  .portrait { width: min(380px, 34vw); }
}
@media (min-width: 1920px) {
  :root { --max: 1360px; }
}

@media (max-width: 900px) {
  .hero__inner { grid-template-columns: 1fr; text-align: center; gap: 2.75rem; padding-top: 6.5rem; }
  .hero__content { max-width: 640px; margin: 0 auto; order: 2; }
  .hero__portrait { order: 1; }
  .hero__lead { margin-left: auto; margin-right: auto; }
  .hero__cta, .hero__socials { justify-content: center; }
  .portrait { width: min(280px, 68vw); }
  /* Straighten and center the portrait so it reads cleanly stacked */
  .portrait__frame, .portrait__ring { transform: rotate(0deg); }
  .portrait:hover .portrait__frame { transform: rotate(0deg) scale(1.02); }
  /* Tuck badges inside the photo corners instead of overhanging the screen edges */
  .portrait__badge { animation: none; }
  .portrait__badge--top { top: 0.85rem; left: 0.85rem; }
  .portrait__badge--bottom { bottom: 0.85rem; right: 0.85rem; }
  /* Drop the floating accent shapes to reduce clutter on small screens */
  .portrait__shape { display: none; }
}
@media (max-width: 860px) {
  .about, .skills, .projects, .edu { grid-template-columns: 1fr; }
  .projects { gap: 1.25rem; }
}
@media (max-width: 420px) {
  .portrait__badge { font-size: 0.72rem; padding: 0.45rem 0.75rem; }
  .portrait__badge--top { top: 0.7rem; left: 0.7rem; }
  .portrait__badge--bottom { bottom: 0.7rem; right: 0.7rem; }
}
@media (max-width: 720px) {
  .nav__toggle { display: flex; }
  .nav__links {
    position: fixed; inset: 68px 0 auto 0;
    flex-direction: column; align-items: flex-start; gap: 0.25rem;
    background: rgba(15, 23, 42, 0.98); backdrop-filter: blur(12px);
    padding: 1rem 1.5rem 1.75rem; border-bottom: 1px solid var(--border);
    transform: translateY(-120%); transition: transform .32s ease; box-shadow: var(--shadow);
  }
  .nav__links.open { transform: translateY(0); }
  .nav__links a { width: 100%; padding: 0.7rem 0; font-size: 1rem; }
  .nav__links .btn--sm { margin-top: 0.5rem; width: auto; }
  .section { padding: 4.5rem 0; }
}

/* Very small phones — tighten type + spacing so nothing overflows */
@media (max-width: 360px) {
  .hero__title { font-size: 2.35rem; }
  .section { padding: 3.75rem 0; }
  .skills__group, .card, .edu, .fact { padding: 1.25rem; }
  .btn { padding: 0.75rem 1.15rem; }
  .hero__cta { width: 100%; }
  .hero__cta .btn { flex: 1 1 auto; }
}

/* Landscape phones / short viewports — don't force a full-height hero */
@media (max-height: 560px) and (orientation: landscape) {
  .hero { min-height: auto; }
  .hero__inner { padding-top: 5.5rem; padding-bottom: 3rem; }
  .hero__scroll { display: none; }
}

/* Touch devices — guarantee comfortable tap targets */
@media (hover: none) and (pointer: coarse) {
  .nav__links a, .hero__socials a, .card__link, .footer__top { min-height: 44px; display: inline-flex; align-items: center; }
  .portrait:hover .portrait__frame { transform: rotate(-3deg); } /* no hover straighten on touch */
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero__scroll, .portrait__glow, .portrait__badge, .portrait__shape, .portrait__ring { animation: none; }
  .btn:hover, .card:hover { transform: none; }
}
