html, body {
  overflow-x: hidden !important;
  max-width: 100vw;
}

.section { overflow-x: hidden; }

/* ── 2. PRELOADER — center + clamp text so it never bleeds ───── */
#preloader {
  padding: 0 1.5rem;
  text-align: center;
}

/* The glitch wrapper must be centered and contained */
.pre-logo {
  font-size: clamp(1.6rem, 7.5vw, 6rem);   /* shrinks aggressively on narrow screens */
  letter-spacing: .1em;
  text-align: center;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;                       /* keep on one line */
  overflow: hidden;
}

/* Glitch pseudo-elements inherit, so they stay inside the same box */
.pre-logo.glitch::before,
.pre-logo.glitch::after {
  white-space: nowrap;
  overflow: hidden;
}

.pre-sub {
  text-align: center;
  width: 100%;
  letter-spacing: .15em;
  font-size: clamp(.62rem, 2.5vw, .75rem);
  white-space: nowrap;
  overflow: hidden;
}

.pre-bar-wrap {
  width: min(300px, 80vw);
}

@media (max-width: 480px) {
  .pre-logo {
    font-size: clamp(1.4rem, 8vw, 2.8rem);
    letter-spacing: .06em;
  }

  .pre-sub {
    letter-spacing: .1em;
    font-size: .62rem;
  }
}

/* ── 3. NAV — always sits ABOVE the mobile menu ──────────────── */
#nav {
  z-index: 700;               /* above mob-menu (690) */
}

@media (max-width: 768px) {
  #nav,
  #nav.solid {
    padding: 1rem 1.2rem;
  }
}

/* When mobile menu is OPEN: keep logo + X visible but strip nav bg  */
body:has(#mob-menu.open) #nav {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-bottom-color: transparent !important;
  box-shadow: none !important;
}

/* The hamburger/X lives in nav (z-index 700) — always visible */
.hamburger {
  position: relative;
  z-index: 710;
  display: none;            /* hidden by default, shown via existing CSS */
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
}

/* ── 4. MOBILE MENU ──────────────────────────────────────────── */
#mob-menu {
  z-index: 690;             /* below nav (700) so hamburger X stays visible */
  padding-top: 5rem;        /* breathing room below logo area */
}

#mob-menu a {
  font-size: clamp(1.8rem, 7vw, 3rem);
}

/* ── 5. HERO — correct mobile layout ────────────────────────── */
@media (max-width: 768px) {
  #hero {
    min-height: 100svh;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 80px 1.2rem 6vh !important;
  }

  /* Always hide scroll indicator — it overlaps stats on mobile */
  .hero-scroll { display: none !important; }

  /* hero-inner: stack photo → text vertically, centred */
  .hero-inner {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    grid-template-columns: unset !important;
    gap: 1.4rem !important;
    width: 100%;
  }

  /* Photo first, centred */
  .hero-photo-wrap {
    display: flex !important;
    order: -1 !important;
    width: 150px !important;
    height: 150px !important;
    align-self: center;
    flex-shrink: 0;
  }

  .hero-photo-img {
    width: 150px !important;
    height: 150px !important;
  }

  .hero-photo-ring:nth-child(1) { inset: -10px; }
  .hero-photo-ring:nth-child(2) { inset: -20px; }
  .hero-photo-ring:nth-child(3) { inset: -30px; }

  /* hero-left: centred column */
  .hero-left {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-eyebrow {
    justify-content: center;
    margin-bottom: .9rem;
  }

  .hero-eyebrow span {
    font-size: .68rem;
    letter-spacing: .1em;
  }

  .hero-name {
    font-size: clamp(2.8rem, 15vw, 5.5rem);
    text-align: center;
  }

  /* Typewriter — contained, wraps cleanly */
  .typewriter {
    display: block;
    text-align: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    font-size: clamp(.8rem, 3.5vw, 1rem);
    min-height: 2.5em;
    margin-top: .35rem;
  }

  /* Buttons: full-width stack */
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 360px;
    margin: 1rem auto 0;
    gap: .7rem;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: .9rem 1rem;
  }

  /* Stats row */
  .hero-left > div[style*="border-top"] {
    justify-content: center !important;
    gap: 4vw !important;
    flex-wrap: wrap !important;
    margin-top: 1.5rem !important;
    padding-top: 1.2rem !important;
    width: 100% !important;
  }

  /* Hide decorative right column */
  .hero-right { display: none !important; }
}

@media (max-width: 380px) {
  #hero { padding: 70px 1rem 5vh !important; }

  .hero-name { font-size: clamp(2.5rem, 17vw, 4rem); }

  .hero-photo-wrap { width: 120px !important; height: 120px !important; }
  .hero-photo-img  { width: 120px !important; height: 120px !important; }

  .hero-photo-ring:nth-child(1) { inset: -8px; }
  .hero-photo-ring:nth-child(2) { inset: -16px; }
  .hero-photo-ring:nth-child(3) { inset: -24px; }
}

/* ── 6. MARQUEE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .marquee-item { padding: .7rem .9rem; gap: .45rem; }
  .marquee-item span { font-size: .88rem; }
}

/* ── 7. SECTION SIZES ────────────────────────────────────────── */
@media (max-width: 768px) {
  .section { padding: 3.5rem 1.2rem; }
  .s-title { font-size: clamp(2rem, 9vw, 3.5rem); }
}

@media (max-width: 380px) {
  .section { padding: 2.8rem 1rem; }
  .s-title { font-size: clamp(1.8rem, 10vw, 3rem); }
  .s-index { font-size: .72rem; }
}

/* ── 8. ABOUT ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .about-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .about-statement { font-size: clamp(1.1rem, 4vw, 1.4rem); }
  .about-body { font-size: .9rem; }

  .edu-timeline { padding-left: 1.8rem; }
  .edu-timeline::before { left: 0; }
  .edu-tl-dot { left: -2.15rem; width: 13px; height: 13px; }
  .edu-tl-card { padding: 1.1rem 1.2rem; }
  .edu-tl-card:hover { transform: translateX(4px); }
}

@media (max-width: 480px) {
  .edu-timeline { padding-left: 1.5rem; }
  .edu-tl-dot { left: -1.85rem; width: 11px; height: 11px; }
  .about-stat-num { font-size: 1.6rem; }
  .about-stat { padding: .7rem .4rem; min-width: 50px; }
  .about-tag { font-size: .72rem; padding: .26rem .65rem; }
}

/* ── 9. SKILLS ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .skills-layout { grid-template-columns: 1fr; gap: 2.5rem; }
  .tools-mosaic { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .tools-mosaic { grid-template-columns: repeat(2, 1fr); }
  .tool-box { font-size: .74rem; padding: .65rem .5rem; }
}

/* ── 10. PROJECTS ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Kill the hover left-shift that causes horizontal scroll */
  .proj-row:hover { padding-left: 0 !important; }
  .proj-row::before { left: 0 !important; right: 0 !important; border-radius: 0; }

  .proj-row { display: flex; flex-direction: column; padding: 1.4rem 0; gap: .5rem; }
  .proj-num { font-size: 2rem; min-width: auto; }
  .proj-name { font-size: clamp(1.4rem, 6.5vw, 2.2rem); }
  .proj-stack { flex-wrap: wrap; gap: .3rem; }
  .proj-pill { font-size: .7rem; padding: .16rem .48rem; }
  .proj-right { display: none; }
  .proj-detail { padding-left: 0; }
  .proj-row.expanded .proj-detail { max-height: 600px; }
  .proj-actions { flex-wrap: wrap; gap: .45rem; }
  .proj-live-btn, .proj-gh-btn { font-size: .74rem; padding: .44rem .9rem; }
}

/* ── 11. DOMAIN CARDS ────────────────────────────────────────── */
@media (max-width: 768px) {
  .shell { padding: 20px 14px; border-radius: 10px; margin-top: 2rem; }
  .dgrid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .dc { padding: 14px 12px 12px; }
}

@media (max-width: 400px) {
  .dgrid { grid-template-columns: 1fr; }
}

/* ── 12. EXPERIENCE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .exp-timeline { padding-left: 2rem; }
  .exp-timeline::before { left: 0; }
  .exp-tl-node { left: -2.5rem; width: 18px; height: 18px; font-size: .55rem; }
  .exp-card { padding: 1.4rem 1.2rem; }
  .exp-role { font-size: 1.3rem; }
  .exp-pts li { font-size: .84rem; }
  .activities-grid { grid-template-columns: 1fr; gap: .7rem; }
  .school-grid { grid-template-columns: 1fr; }
  .subsection-title { font-size: clamp(1.4rem, 6vw, 2rem); margin-top: 2.5rem; margin-bottom: 1.2rem; }
}

@media (max-width: 480px) {
  .exp-timeline { padding-left: 1.7rem; }
  .exp-tl-node { left: -2.1rem; width: 15px; height: 15px; }
}

/* ── 13. CERTIFICATIONS ──────────────────────────────────────── */
@media (max-width: 768px) {
  .certs-grid { grid-template-columns: 1fr; gap: .85rem; }
  .cert-card { padding: 1.4rem 1.2rem; }
  .cert-3d-card { width: 230px; }
  .cert-img-wrap { height: 155px; }

  #certLightbox { padding: 1rem; }
  .lb-inner { max-width: 100%; }
  #lbImg { max-height: 70vh; border-radius: 10px; }
  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }
}

@media (max-width: 480px) {
  .cert-3d-card { width: 195px; }
  .cert-img-wrap { height: 130px; }
  .cert-info { padding: .85rem .95rem 1rem; }
  .cert-info-title { font-size: .84rem; }
}

/* ── 14. NOTION ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .notion-grid { grid-template-columns: 1fr; gap: 2rem; }
  .notion-headline { font-size: clamp(1.5rem, 6vw, 2.4rem); }
  .notion-quote { padding: 1rem 1.1rem; margin-bottom: 1.8rem; }
  .notion-quote p { font-size: .93rem; }
  .notion-cta { width: 100%; justify-content: center; }
}

/* ── 15. NEWSLETTER ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .nl-inner { grid-template-columns: 1fr; gap: 1.5rem; }
  .nl-right { min-width: unset !important; width: 100%; }
  .nl-form { flex-direction: column; }
  .nl-input { border-radius: 8px 8px 0 0; padding: .9rem 1rem; }
  .nl-btn { border-radius: 0 0 8px 8px; padding: .9rem 1rem; }
}

/* ── 16. CONTACT ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .contact-wrap { grid-template-columns: 1fr; gap: 2.5rem; }
  .contact-headline { font-size: clamp(2.5rem, 10vw, 4rem); }
  .contact-sub { max-width: 100%; }
  .contact-form-card { padding: 1.4rem 1.1rem; }
  .cf-grid { grid-template-columns: 1fr; gap: .55rem; }
  .cf-form-title { font-size: 1.6rem; }
  .cf-chip { font-size: .7rem; padding: .28rem .7rem; }
  .resume-card { padding: 1.1rem; }
  .rc-stats { gap: 1rem; }
}

/* ── 17. FOOTER ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  footer { flex-direction: column; align-items: flex-start; padding: 1.5rem 1.2rem; gap: 1rem; }
  footer::before { display: none; }
  .footer-socials { flex-wrap: wrap; gap: .4rem; }
  .footer-social { font-size: .7rem; padding: .36rem .72rem; }
}

/* ── 18. TOUCH — disable custom cursor ──────────────────────── */
@media (hover: none) and (pointer: coarse) {
  body { cursor: auto !important; }
  button, a { cursor: pointer !important; }
  #cur-target, #dragon-cursor, .fire-particle { display: none !important; }
}

/* ── 19. SAFE AREA — notch / Dynamic Island / home bar ───────── */
@supports (padding: env(safe-area-inset-top)) {
  #nav, #nav.solid {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }
  #hero {
    padding-top: calc(80px + env(safe-area-inset-top)) !important;
  }
  footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}
