/* --- Media Queries & Responsiveness --- */

/* Hamburger toggle: hidden on desktop, revealed in mobile query below */
.nav-toggle {
  display: none;
}

/* Anchor scroll offset — accounts for fixed navbar + 6px flag stripe */
html {
  scroll-padding-top: 66px;
}

/* ─── Tablet (≤ 992px) ─────────────────────────────────────── */
@media (max-width: 992px) {
  #navbar {
    padding: 10px 20px;
  }
}

/* ─── Mobile (≤ 768px) ─────────────────────────────────────── */
@media (max-width: 768px) {

  /* Scroll offset increase — mobile navbar is slightly taller */
  html {
    scroll-padding-top: 76px;
  }

  /* ── Navbar ── */
  #navbar {
    flex-wrap: wrap;
    padding: 12px 20px;
    gap: 0;
    justify-content: space-between;
    align-items: center;
    height: auto;
  }

  /* Hamburger button */
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: 1px solid var(--neon-cyan);
    border-radius: 4px;
    padding: 8px 10px;
    cursor: pointer;
    order: 2;         /* sits beside the logo on the first row */
    flex-shrink: 0;
  }

  .nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--neon-cyan);
    border-radius: 1px;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  /* Animate bars → × when menu is open */
  #navbar.nav-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  #navbar.nav-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }
  #navbar.nav-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Nav links: collapsed by default, drop to full row below logo + button */
  .nav-links {
    order: 3;
    flex-direction: column;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease, margin 0.35s ease;
    gap: 0;
  }

  #navbar.nav-open .nav-links {
    max-height: 400px;
    margin-top: 12px;
    padding: 12px 0;
    border-top: 1px solid rgba(0, 242, 255, 0.2);
  }

  .nav-links a {
    font-size: 0.95rem;
    padding: 10px 4px;
    border-bottom: 1px solid rgba(0, 242, 255, 0.08);
    width: 100%;
  }

  /* CV button inside the collapsed menu */
  .nav-cv-btn {
    font-size: 0.8rem;
    padding: 10px 4px;
    border: none;
    border-radius: 0;
    border-bottom: none;
    margin: 4px 0 0;
    max-width: unset;
    width: 100%;
  }

  /* ── Welcome / Hero ── */
  #welcome-section {
    /* svh = "small viewport height" — excludes mobile browser chrome */
    min-height: 100svh;
    padding-top: 80px;
  }

  .glitch-title {
    font-size: 2.8rem;
  }

  .welcome-subtitle {
    font-size: 1.4rem;
  }

  .welcome-prefix {
    font-size: 1rem;
  }

  .welcome-tagline {
    font-size: 1.1rem;
  }

  .scroll-indicator span {
    font-size: 2rem;
  }

  .hero-cta {
    flex-direction: column;
    gap: 1rem;
  }

  .hero-cta-btn {
    width: 100%;
    text-align: center;
  }

  /* ── Sections ── */
  .section-title {
    font-size: 2rem;
    margin-bottom: 40px;
  }

  #projects,
  #skills,
  #contact {
    padding: 60px 20px;
  }

  /* ── Projects ── */
  .projects-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 0 10px;
  }

  .projects-explorer {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    justify-content: center;
  }

  .sort-wrap {
    justify-content: center;
  }

  .project-actions {
    flex-direction: column;
  }

  /* Reduce the lift effect — hover fires on tap on touch screens */
  .project-tile:hover {
    transform: translateY(-6px);
  }

  /* ── Contact ── */
  .contact-text {
    font-size: 1.1rem;
  }

  .contact-links {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .contact-btn {
    width: 100%;
    max-width: 300px;
    font-size: 0.95rem;
    padding: 14px 24px;
    justify-content: center;
  }
}

/* ─── Small mobile (≤ 480px) ───────────────────────────────── */
@media (max-width: 480px) {
  #navbar {
    padding: 10px 12px;
  }

  .glitch-title {
    font-size: 2rem;
  }

  .welcome-subtitle {
    font-size: 1.1rem;
  }

  .welcome-tagline {
    font-size: 1rem;
  }

  .section-title {
    font-size: 1.6rem;
    margin-bottom: 30px;
  }

  .contact-btn {
    font-size: 0.85rem;
    padding: 12px 20px;
  }

  .contact-text {
    font-size: 1rem;
  }

  /* Reduce project image height to save vertical space */
  .project-image {
    height: 180px;
  }

  /* Filter buttons: smaller text, still tappable */
  .filter-btn,
  .sort-select {
    font-size: 0.75rem;
    padding: 6px 10px;
  }
}

/* ─── Very small screens (≤ 360px) ─────────────────────────── */
@media (max-width: 360px) {
  .glitch-title {
    font-size: 1.7rem;
  }

  .hero-cta-btn {
    font-size: 0.75rem;
    padding: 0.65rem 1rem;
  }

  .filter-btn {
    font-size: 0.7rem;
    padding: 5px 8px;
  }
}

/* ─── Landscape mobile ──────────────────────────────────────── */
/* Short viewport in landscape — hero would fill 2 screens tall */
@media (max-height: 500px) and (orientation: landscape) {
  #welcome-section {
    min-height: auto;
    padding: 100px 20px 60px;
  }

  .glitch-title {
    font-size: 2.2rem;
    margin: 10px 0;
  }

  .welcome-subtitle {
    font-size: 1.1rem;
    margin: 10px 0;
  }

  .scroll-indicator {
    display: none;
  }
}

/* ─── Touch devices: disable hover lift entirely ────────────── */
/* hover: none = device has no hover pointer (phones, tablets)  */
@media (hover: none) and (pointer: coarse) {
  .project-tile:hover {
    transform: none;
    border-color: rgba(0, 242, 255, 0.3);
    box-shadow: none;
  }

  .project-tile:hover .project-image img {
    transform: none;
    filter: brightness(0.7);
  }

  .project-tile:hover .project-overlay {
    opacity: 0;
  }

  .contact-btn:hover {
    transform: none;
  }

  .skill-card:hover {
    transform: none;
  }
}

/* ─── Touch target minimum sizes (WCAG 2.5.5) ──────────────── */
@media (pointer: coarse) {
  .filter-btn,
  .sort-select,
  .project-visit-btn,
  .project-inspect-btn,
  .project-share-btn,
  .nav-toggle {
    min-height: 44px;
    min-width: 44px;
  }

  .project-visit-btn,
  .project-inspect-btn,
  .project-share-btn {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ─── About section ─────────────────────────────────────────── */
@media (max-width: 768px) {
  #about {
    padding: 60px 20px;
  }

  .about-container {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 32px;
  }

  .about-avatar-wrap {
    margin: 0 auto;
    width: 160px;
    height: 160px;
  }

  .about-tags {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .about-bio {
    font-size: 1rem;
  }
}

/* ─── Skills badge grid ─────────────────────────────────────── */
@media (max-width: 768px) {
  #skills {
    padding: 60px 20px;
  }

  .skills-categories {
    grid-template-columns: 1fr;
  }
}

/* ─── Contact form ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .contact-form {
    padding: 0 4px;
  }

  .contact-form-submit {
    align-self: stretch;
    text-align: center;
  }
}

/* ─── Back-to-top touch target ──────────────────────────────── */
@media (pointer: coarse) {
  .back-to-top {
    width: 3rem;
    height: 3rem;
  }
}

/* ─── WCAG #22: Filter row at 320px (WCAG 1.4.10 reflow) ───── */
@media (max-width: 360px) {
  .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;        /* Firefox */
    padding-bottom: 4px;
    justify-content: flex-start;
  }

  .filter-group::-webkit-scrollbar {
    display: none;                /* Chrome/Safari */
  }

  .filter-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* ─── Currently learning widget ─────────────────────────────── */
@media (max-width: 480px) {
  .currently-learning__topic {
    font-size: 1rem;   /* Orbitron can be wide; scale down on phones */
  }

  .currently-learning__card {
    padding: 14px;
  }
}

/* ─── Contact links — wrap at tablet before stacking at mobile ─ */
@media (max-width: 860px) and (min-width: 769px) {
  .contact-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  .contact-btn {
    flex: 1 1 140px;
    max-width: 200px;
    justify-content: center;
  }
}

/* ─── Touch: disable hover on skill categories / about ──────── */
@media (hover: none) and (pointer: coarse) {
  .skill-category:hover {
    border-color: rgba(157, 0, 255, 0.3);
    box-shadow: none;
  }

  .about-tag:hover {
    background: transparent;
    box-shadow: none;
  }

  .back-to-top:hover {
    transform: none;
  }
}
