/* ============================================
   RESPONSIVE — COMPREHENSIVE MOBILE OVERHAUL
   E-Portfolio PPG Prajabatan 2026
   ============================================ */

/* ============================================
   0. GLOBAL TOUCH-FRIENDLY & TYPOGRAPHY
   ============================================ */
* {
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100%; /* Use 100% instead of 100vw to avoid scrollbar width issues */
  overflow-x: hidden !important; /* Force prevent horizontal scroll/cropping */
  position: relative;
}

/* Adaptive Typography (all screens) */
h1, .hero-name        { font-size: clamp(1.8rem, 5vw, 3rem); }
h2, .section-title     { font-size: clamp(1.4rem, 4vw, 2rem); }
h3                     { font-size: clamp(1.1rem, 3vw, 1.5rem); }
body                   { font-size: clamp(0.9rem, 2.5vw, 1rem); }

/* Base Container Override */
.container {
  width: 100%;
  max-width: 100%;
}

/* ============================================
   DESKTOP (min-width: 1024px)
   Keep default layouts — no changes
   ============================================ */
@media (min-width: 1024px) {
  .portfolio-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .skill-cards-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   1. TABLET (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
  .hero .container {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 32px;
  }
  .hero-content {
    order: 2;
    justify-self: center;
    width: min(100%, 680px);
    padding: 8px 0 0;
  }
  .hero-content::before {
    left: 50%;
    top: -28px;
    width: 440px;
    height: 440px;
    opacity: 0.18;
    transform: translateX(-50%);
  }
  .hero-image   { order: 1; }
  .hero-desc    { margin: 0 auto 32px; }
  .hero-actions { justify-content: center; }
  .hero-social  { justify-content: center; }
  .hero-image-wrapper { width: 280px; height: 280px; }

  .about-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .about-grid {
    gap: 36px;
  }
  .about-image {
    max-width: 620px;
    padding-bottom: 0;
  }
  .about-image-card {
    aspect-ratio: 16 / 9;
  }
  .about-image-card img {
    height: 100%;
  }
  .about-stats {
    position: static;
    transform: none;
    width: 100%;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap; /* Ensure stats wrap and don't overflow horizontally */
    gap: 12px;
  }
  .about-stat {
    flex: 1 1 calc(33.333% - 12px);
    min-width: 80px;
    padding: 12px;
  }
  .about-stat .number {
    font-size: 1.4rem;
  }
  .philosophy-pillars {
    grid-template-columns: 1fr 1fr;
  }

  /* Portfolio: 3 → 2 columns */
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Skills: 4 → 3 columns */
  .skill-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Certs: 3 → 2 columns */
  .cert-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Gallery: 3 → 2 columns */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* ============================================
   2. TABLET (max-width: 768px)
   Navbar, Timeline, Contact, Footer
   ============================================ */
@media (max-width: 768px) {
  /* Hide scroll indicator on mobile to prevent overlapping with social icons */
  .scroll-indicator {
    display: none !important;
  }

  .section {
    padding: 60px 0;
  }
  .section-header {
    margin-bottom: 36px;
  }
  html {
    scroll-padding-top: 72px;
  }

  /* --- NAVBAR: hide links, show hamburger --- */
  .navbar .container {
    gap: 10px;
  }
  .nav-actions {
    gap: 8px;
  }
  .hamburger {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    min-width: 44px;
  }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 0;
    overflow: hidden;
    flex-direction: column;
    gap: 0;
    background: var(--white);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1),
                padding 0.3s ease;
    padding: 0 24px;
    z-index: 999;
    border-bottom: 3px solid var(--accent, #39BDEB);
  }
  .nav-links.open {
    max-height: 100vh;
    padding: 20px 24px 28px;
  }
  .nav-links li {
    list-style: none;
  }
  .nav-links a {
    display: block;
    padding: 14px 0;
    font-size: 1.05rem;
    font-weight: 600;
    border-bottom: 1px solid var(--gray-100, #eee);
    min-height: 44px;
  }
  
  /* --- Prevent Horizontal Scroll from Animations --- */
  .reveal-right, 
  .reveal-left {
    transform: translateY(40px); /* Override X translation to Y to prevent width overflow */
  }
  .reveal-right.visible, 
  .reveal-left.visible {
    transform: translateY(0);
  }

  .nav-links li:last-child a {
    border-bottom: none;
  }
  [data-theme="dark"] .nav-links {
    background: rgba(13, 17, 23, 0.98);
    border-bottom-color: var(--accent, #39BDEB);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  }
  [data-theme="dark"] .nav-links a {
    color: rgba(255, 255, 255, 0.84);
    border-bottom-color: rgba(255,255,255,0.06);
  }
  [data-theme="dark"] .nav-links a:hover,
  [data-theme="dark"] .nav-links a.active {
    color: var(--accent-light, #7DD3FC);
  }
  [data-theme="dark"] .nav-links::after {
    background: linear-gradient(135deg, #0F5EA8, #39BDEB);
    color: #fff;
  }
  [data-theme="dark"] .hamburger span {
    background: var(--gray-700);
  }

  /* --- TIMELINE (Education) --- */
  .timeline::before { left: 20px; }
  .timeline-item:nth-child(odd),
  .timeline-item:nth-child(even) {
    padding-left: 52px;
    padding-right: 0;
    justify-content: flex-start;
  }
  .timeline-dot { left: 20px; }

  /* --- CONTACT: 2 cols → 1 col stack --- */
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .contact-info {
    order: 1;
  }
  .contact-form {
    order: 2;
    padding: 24px;
    width: 100%;
  }
  /* Prevent iOS auto-zoom on input focus */
  .contact-form input,
  .contact-form textarea,
  .form-group input,
  .form-group textarea,
  .form-group.floating input,
  .form-group.floating textarea {
    font-size: 16px !important;
  }

  /* --- PORTFOLIO grid at tablet --- */
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  /* --- SKILLS: 3 → 2 columns --- */
  .skill-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  /* --- CERTIFICATES: 2 → 1 column --- */
  .cert-grid {
    grid-template-columns: 1fr;
  }

  /* --- MODEL GURU (Philosophy pillars) --- */
  .philosophy-pillars {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
  }

  /* --- GALLERY: keep 2 columns --- */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* --- MINI TIMELINE (Life Steps) --- */
  .life-timeline-track {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  .life-step-line {
    display: none;
  }

  /* Hero float badges */
  .hero-float { display: none; }

  /* About info list */
  .about-info-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .profil-narasi {
    padding: 16px 18px;
  }
  .profil-quote {
    padding: 22px 22px 22px 52px;
  }

  /* Footer */
  .footer-top {
    flex-direction: column;
    gap: 32px;
    text-align: center;
  }
  .footer-brand {
    text-align: center;
  }
  .footer-social {
    justify-content: center;
  }
  .footer-sitemap ul {
    columns: 2;
  }
  .footer-bottom {
    text-align: center;
  }
}


/* ============================================
   3. MOBILE LARGE (max-width: 640px)
   Hero stack, Filters scroll, Portfolio 1-col
   ============================================ */
@media (max-width: 640px) {
  /* --- HERO SECTION: stack vertical --- */
  .hero {
    padding-top: 120px !important; /* Larger padding to clear navbar */
    align-items: flex-start !important; /* Stop vertical centering so it doesn't push up */
    min-height: auto !important;
    padding-bottom: 60px;
  }
  .hero .container {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 24px;
  }
  .hero-content {
    order: 2;
    width: 100%;
    padding: 0;
  }
  .hero-content::before {
    width: 320px;
    height: 320px;
    top: -12px;
    opacity: 0.12;
  }
  .hero-image {
    order: 1;
  }
  .hero-image-wrapper {
    width: 200px !important;
    height: 200px !important;
    margin: 0 auto;
  }
  .hero-name {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
  }
  .hero-desc {
    margin: 0 auto 24px;
    font-size: 0.92rem;
    max-width: 100%;
  }

  /* CTA buttons: stack vertical, full width */
  .hero-actions {
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: stretch;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Badges: smaller */
  .hero-badges > div {
    font-size: 0.78rem !important;
    padding: 6px 12px !important;
  }
  .hero-badges {
    gap: 8px !important;
  }

  /* --- MINI TIMELINE: compact 4 items --- */
  .life-timeline-track {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    justify-content: flex-start;
    padding-bottom: 12px;
    scrollbar-width: none;
  }
  .life-timeline-track::-webkit-scrollbar {
    display: none;
  }
  .life-step {
    scroll-snap-align: center;
    flex: 0 0 auto;
    min-width: 70px;
  }
  .life-step-line {
    display: block;
    flex: 0 0 20px;
    min-width: 20px;
  }
  .life-step-label {
    font-size: 0.72rem;
  }
  .life-step-label span {
    font-size: 0.65rem;
  }
  .life-timeline {
    padding: 18px 16px;
  }

  /* --- PORTFOLIO FILTER: horizontal scroll --- */
  .portfolio-filter,
  .portfolio-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    gap: 8px;
    justify-content: flex-start;
    padding-bottom: 8px;
    position: relative;
    /* Gradient fade hint on right */
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }
  .portfolio-filter::-webkit-scrollbar,
  .portfolio-tabs::-webkit-scrollbar {
    display: none;
  }
  .filter-btn,
  .tab-btn {
    scroll-snap-align: start;
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 16px;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  /* --- PORTFOLIO GRID: 1 column --- */
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .penilaian-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .portfolio-card-body {
    padding: 20px;
  }

  /* --- SKILLS TABS: scroll horizontal --- */
  .skills-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    gap: 8px;
    padding-bottom: 8px;
  }
  .skills-tabs::-webkit-scrollbar { display: none; }
  .skills-tab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 40px;
  }

  /* --- SKILL CARDS: 2 columns --- */
  .skill-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .skill-item-card {
    padding: 20px 12px;
  }
  .skill-item-icon {
    font-size: 2rem;
  }
  .skill-item-name {
    font-size: 0.85rem;
  }

  /* --- CERTIFICATES: 1 column --- */
  .cert-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* --- MODEL GURU: 1 column --- */
  .philosophy-pillars {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .pillar-card {
    width: 100%;
  }
  .philosophy-card blockquote {
    font-size: 1rem;
  }

  /* --- GALLERY: 2 columns compact --- */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .gallery-grid .gallery-item {
    height: 160px;
  }

  /* --- ACCORDION (Penilaian) --- */
  .accordion-header {
    padding: 14px 16px;
    font-size: 0.88rem;
  }
  .accordion-header span:first-child {
    font-size: 0.85rem;
  }
  .accordion-row {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start !important;
  }

  /* --- SECTION spacing --- */
  .section {
    padding: 40px 0;
  }
  section {
    scroll-margin-top: 72px;
  }
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}


/* ============================================
   4. MOBILE SMALL (max-width: 480px)
   Fine-tuning for smallest screens
   ============================================ */
@media (max-width: 480px) {
  .hero-content::before {
    width: 260px;
    height: 260px;
    opacity: 0.08;
  }
  .hero-image-wrapper {
    width: 180px !important;
    height: 180px !important;
  }
  .hero-name {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }
  .hero-role {
    font-size: 0.9rem;
  }

  /* Buttons: ensure touch-friendly */
  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
    min-height: 44px;
  }

  /* Section titles */
  .section-title {
    font-size: clamp(1.3rem, 5vw, 1.6rem);
  }
  .section-subtitle {
    font-size: 0.85rem;
  }
  .section-badge {
    font-size: 0.78rem;
  }

  /* Portfolio card image */
  .portfolio-card-img {
    height: 180px;
  }

  /* Skills: 2 col stays but tighter */
  .skill-cards-grid {
    gap: 10px;
  }
  .skill-item-card {
    padding: 16px 10px;
    border-radius: 12px;
  }
  .skill-item-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
  }
  .skill-item-name {
    font-size: 0.8rem;
  }
  .skill-item-badge {
    font-size: 0.68rem;
    padding: 3px 10px;
  }

  /* Certificate cards: tighter padding */
  .cert-card {
    padding: 18px;
    gap: 12px;
  }

  /* Gallery: 2 col, shorter */
  .gallery-grid .gallery-item {
    height: 120px;
  }

  /* About stats */
  .about-stats {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }
  .about-stat {
    flex-basis: calc(33.333% - 10px);
    padding: 12px 10px;
  }
  .about-stat .number {
    font-size: 1.4rem;
  }

  /* About info items */
  .about-info-item {
    align-items: flex-start;
    padding: 12px;
  }

  /* Penilaian Card Padding */
  .penilaian-card {
    padding: 16px;
  }

  /* Portfolio Card Body Padding */
  .portfolio-card-body {
    padding: 16px;
  }

  /* Footer */
  .footer {
    padding: 24px 0 16px;
  }
  .footer-sitemap ul {
    columns: 1;
  }

  /* Modal: full width on small screens */
  .modal-container {
    max-width: 100%;
    margin: 8px;
    border-radius: 12px;
  }
  .modal-content {
    padding: 20px 12px;
  }

  /* Navbar mobile: tighter */
  .nav-links a {
    padding: 10px 0;
    font-size: 0.9rem;
  }
  .nav-actions {
    gap: 6px;
  }
  .nav-actions .theme-toggle,
  .nav-actions .hamburger {
    width: 44px;
    height: 44px;
  }

  /* Container */
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  
  /* Section Spacing */
  .section {
    padding: 32px 0;
  }
}


/* ============================================
   5. TOUCH-FRIENDLY GLOBAL ENHANCEMENTS
   ============================================ */

/* All interactive elements min 44px tap target */
a, button, .btn, .filter-btn, .tab-btn, .skills-tab-btn,
.form-submit, .card-link, .cert-btn, .btn-download-new,
.accordion-header, .hamburger, .theme-toggle, .back-to-top {
  min-height: 44px;
}

/* Horizontal scroll areas: smooth momentum */
.portfolio-filter,
.portfolio-tabs,
.skills-tabs,
.life-timeline-track {
  -webkit-overflow-scrolling: touch;
}

/* Ensure images don't overflow on any screen */
img {
  max-width: 100%;
  height: auto;
}

/* Prevent horizontal scroll on body */
html, body {
  overflow-x: hidden;
}

/* Lightbox: full-screen on mobile */
@media (max-width: 640px) {
  .lightbox-content img {
    max-width: 95vw;
    max-height: 80vh;
    object-fit: contain;
  }
  .lightbox-close {
    top: 10px;
    right: 10px;
  }
  .lightbox-prev,
  .lightbox-next {
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
  }
}
