/* ==========================================================================
   Mobile Responsive Overrides — phtrann.com
   Professional mobile-first optimization
   Breakpoints: 768px (tablet), 480px (phone)
   ========================================================================== */

/* ==========================================================================
   NAVIGATION — Hamburger Menu (Mobile)
   ========================================================================== */

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 10001;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2.5px;
  background: #3d2b1f;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hamburger → X animation when open */
.nav-hamburger.is-open .hamburger-line:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.nav-hamburger.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.nav-hamburger.is-open .hamburger-line:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

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

  .nav-inner {
    position: relative;
  }

  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(250, 247, 242, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    padding: 4rem 2rem !important;
    border: none !important;
    border-radius: 0 !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 9999;
  }

  .nav-links.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
  }

  .nav-links li {
    width: 100%;
    text-align: center;
  }

  .nav-links a {
    display: block !important;
    font-size: 1.4rem !important;
    padding: 1.2rem 2rem !important;
    border-radius: 12px !important;
    color: #3d2b1f !important;
    font-weight: 500 !important;
  }

  .nav-links a:hover,
  .nav-links a.is-active {
    background: rgba(139, 111, 84, 0.12) !important;
    color: #6B4226 !important;
    font-weight: 700 !important;
  }

  .language-toggle {
    z-index: 10001;
  }
}

/* ==========================================================================
   HERO SECTION — Stack vertically on mobile
   ========================================================================== */

@media (max-width: 768px) {
  .hero-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    padding: 0 !important;
  }

  #hero {
    min-height: auto !important;
    padding: 2rem 1.2rem !important;
  }

  /* Image first, smaller */
  .hero-image-animated {
    margin-top: 0 !important;
    order: -1;
  }

  .hero-image-animated img {
    max-width: 280px !important;
    margin: 0 auto;
    display: block;
  }

  /* Text content */
  .hero-grid > div:last-child {
    align-items: center !important;
    text-align: center;
  }

  .hero-grid > div:last-child h1 {
    font-size: clamp(2rem, 8vw, 2.8rem) !important;
    text-align: center;
  }

  .hero-grid > div:last-child p {
    text-align: center !important;
    font-size: 1rem !important;
  }

  .hero-buttons-animated {
    justify-content: center !important;
    align-self: center !important;
    flex-wrap: wrap;
  }

  .hero-buttons-animated a {
    font-size: 1rem !important;
    padding: 0.65rem 1.5rem !important;
  }
}

@media (max-width: 480px) {
  .hero-image-animated img {
    max-width: 220px !important;
  }

  .hero-grid > div:last-child h1 {
    font-size: clamp(1.8rem, 7vw, 2.2rem) !important;
  }
}

/* ==========================================================================
   ABOUT SECTION — Stack vertically
   ========================================================================== */

@media (max-width: 768px) {
  .about-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .about-grid > div:first-child img {
    max-width: 300px;
    margin: 0 auto;
    display: block;
  }

  #about {
    margin-top: -40px !important;
  }

  #about > div:first-child {
    padding: 1.5rem 0 !important;
    margin-bottom: 2rem !important;
  }

  #about > div:first-child h2 {
    font-size: 2rem !important;
  }

  #about > div:nth-child(2) {
    padding: 0 1.2rem !important;
  }
}

/* ==========================================================================
   EXPERIENCE / TIMELINE — Vertical on mobile
   ========================================================================== */

@media (max-width: 768px) {
  .exp-edu-section {
    padding: 2rem 1.2rem !important;
  }

  .exp-section-title {
    font-size: 2rem !important;
    text-align: center !important;
  }

  .timeline-wrapper {
    padding-top: 2rem !important;
  }

  .timeline-container {
    flex-direction: column !important;
    gap: 2.5rem !important;
    padding: 0 !important;
    align-items: flex-start !important;
  }

  .timeline-container::before {
    top: 0 !important;
    bottom: 0 !important;
    left: 12px !important;
    width: 2px !important;
    height: 100% !important;
    transform: none !important;
  }

  .timeline-item {
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 1.2rem;
    padding-left: 0;
  }

  .timeline-dot {
    width: 20px !important;
    height: 20px !important;
    margin-bottom: 0 !important;
    flex-shrink: 0;
    margin-top: 3px;
  }

  .timeline-content {
    max-width: none !important;
  }

  .timeline-title {
    font-size: 1.1rem !important;
  }

  .timeline-period {
    font-size: 1rem !important;
  }
}

/* ==========================================================================
   SKILLS SECTION
   ========================================================================== */

@media (max-width: 768px) {
  .skills-section {
    padding: 2rem 1.2rem !important;
  }

  .skills-main-title {
    font-size: 2rem !important;
  }

  .skill-pills {
    justify-content: center !important;
  }

  .skill-pill {
    font-size: 0.9rem !important;
    padding: 0.5rem 1rem !important;
  }

  .education-cards-section {
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  .education-wrapper-with-title {
    width: 100% !important;
  }
}

/* ==========================================================================
   PROJECTS — Stats Grid (4 cols → 2 cols on mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .stats-grid-mobile {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
    max-width: 100% !important;
  }

  .stats-grid-mobile .stat-box {
    padding: 1.5rem 1rem !important;
  }

  .stats-grid-mobile .stat-number {
    font-size: 2rem !important;
  }

  .stats-grid-mobile .stat-box div:last-child {
    font-size: 0.9rem !important;
    white-space: normal !important;
  }
}

@media (max-width: 480px) {
  .stats-grid-mobile {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ==========================================================================
   PROJECTS — Social Channels Grid (2 cols → 1 col on mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .social-channels-grid {
    grid-template-columns: 1fr !important;
    gap: 1.2rem !important;
    margin: 2rem auto !important;
  }
}

/* ==========================================================================
   PROJECTS — Brand Logos (responsive)
   ========================================================================== */

@media (max-width: 768px) {
  .brand-logos {
    flex-direction: row !important;
    gap: 1.5rem !important;
  }

  .brand-logos img {
    max-width: 120px !important;
  }
}

/* ==========================================================================
   PROJECTS — Content Product Grid
   ========================================================================== */

@media (max-width: 768px) {
  .content-product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .brand-awareness-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

@media (max-width: 480px) {
  .content-product-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   PROJECTS — MacBook Mockup (scale down)
   ========================================================================== */

@media (max-width: 768px) {
  .macbook-mockup-container {
    transform: scale(0.85);
    transform-origin: center top;
    margin-bottom: -2rem;
  }

  .macbook-wrapper {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .macbook-mockup-container {
    transform: scale(0.7);
    margin-bottom: -4rem;
  }
}

/* ==========================================================================
   PROJECTS — Video Accordion (horizontal → vertical on mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .video-accordion {
    flex-direction: column !important;
    height: auto !important;
    gap: 0.5rem !important;
  }

  .video-accordion-item {
    min-height: 120px !important;
    border-radius: 12px !important;
  }

  .video-accordion__label {
    padding: 1rem !important;
  }

  .video-accordion__title {
    font-size: 1rem !important;
  }
}

/* ==========================================================================
   PROJECTS — POSM Gallery
   ========================================================================== */

@media (max-width: 768px) {
  .posm-gallery {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  .posm-col {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
  }
}

/* ==========================================================================
   PROJECTS — Card Stack (Campaign)
   ========================================================================== */

@media (max-width: 768px) {
  .card-stack-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .stack-card {
    border-radius: 8px !important;
  }
}

@media (max-width: 480px) {
  .card-stack-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
}

/* ==========================================================================
   PROJECTS — Marquee Gallery (smaller tiles on mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .marquee-section-images {
    gap: 0.5rem !important;
  }

  .marquee-tile {
    min-width: 200px !important;
    height: 150px !important;
  }

  .marquee-tile img {
    height: 150px !important;
  }
}

@media (max-width: 480px) {
  .marquee-tile {
    min-width: 160px !important;
    height: 120px !important;
  }

  .marquee-tile img {
    height: 120px !important;
  }
}

/* ==========================================================================
   PROJECTS — Growth Metrics
   ========================================================================== */

@media (max-width: 768px) {
  .growth-column-card {
    padding: 2rem 1.2rem !important;
  }

  .growth-column-title {
    font-size: 2rem !important;
  }

  .growth-metric-list {
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  .growth-metric-card {
    padding: 1.5rem !important;
  }

  .growth-metric-value {
    font-size: 2.5rem !important;
  }
}

/* ==========================================================================
   PROJECTS — Chabum Section
   ========================================================================== */

@media (max-width: 768px) {
  .chabum-two-columns {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .chabum-vision-mission-row {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .chabum-tab02-layout {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .chabum-tab03-layout {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .chabum-brand-dev-box,
  .chabum-content-marketing-box,
  .chabum-ecommerce-box,
  .chabum-operations-box {
    margin-top: 2.5rem !important;
  }

  .chabum-logo-container img {
    max-width: 200px !important;
  }

  .chabum-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }

  /* iPhone mockup */
  .iphone-mockup-container {
    max-width: 280px;
    margin: 0 auto;
  }

  /* Instagram slider */
  .chabum-instagram-slider {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .chabum-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .project-simple-container > div:first-child h3 {
    font-size: 2rem !important;
  }
}

/* ==========================================================================
   PROJECTS — Founder title & project headers
   ========================================================================== */

@media (max-width: 768px) {
  .project-title-italic {
    font-size: 2.2rem !important;
  }

  .project-simple-title {
    font-size: 1.5rem !important;
  }

  .project-simple-role {
    font-size: 1rem !important;
  }

  .project-desc {
    font-size: 1rem !important;
    text-align: left !important;
  }

  .project-header-no-bg h3 {
    font-size: 2.2rem !important;
  }

  .sow-pills-container {
    justify-content: center !important;
  }

  .sow-pill {
    font-size: 0.85rem !important;
    padding: 0.4rem 0.9rem !important;
  }

  .project-simple-container {
    padding: 0 1.2rem !important;
  }
}

/* ==========================================================================
   CONTACT SECTION — Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .contact-section-mobile {
    padding: 3rem 1.2rem !important;
    margin-top: 2rem !important;
  }

  .contact-section-mobile h2 {
    font-size: 2rem !important;
    margin-bottom: 2.5rem !important;
  }

  /* Stack label and value vertically */
  .contact-section-mobile div[style*="justify-content: space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }

  .contact-section-mobile a {
    font-size: 0.95rem !important;
    word-break: break-all;
  }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

@media (max-width: 768px) {
  footer {
    padding: 1.5rem 1.2rem !important;
    font-size: 0.85rem !important;
  }
}

/* ==========================================================================
   GENERAL — Typography & Spacing adjustments
   ========================================================================== */

@media (max-width: 768px) {
  #main-content {
    padding-top: 60px !important;
  }

  section {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
    padding-inline: 1.2rem !important;
  }

  /* Fix full-width background sections */
  #about > div:first-child {
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    left: 50% !important;
    right: 50% !important;
  }

  /* Smooth scroll fix for iOS */
  html {
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent horizontal overflow */
  body {
    overflow-x: hidden !important;
  }

  /* Improve tap targets */
  a, button {
    min-height: 44px;
    min-width: 44px;
  }

  /* Better text rendering on mobile */
  body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
}

/* ==========================================================================
   PRELOADER — Mobile adjustments
   ========================================================================== */

@media (max-width: 768px) {
  #preloaderCount {
    font-size: clamp(1.8rem, 5vw, 3rem) !important;
    padding: 0 1rem !important;
  }

  .preloader-line {
    letter-spacing: 0.08em !important;
  }
}

/* ==========================================================================
   PROJECTS SECTION — Overall container
   ========================================================================== */

@media (max-width: 768px) {
  .projects-section-simple {
    max-width: 100% !important;
    padding: 1rem 0 !important;
  }
}

/* ==========================================================================
   FEEDBACK MARQUEE — Smaller items on mobile
   ========================================================================== */

@media (max-width: 768px) {
  .feedback-item {
    min-width: 200px !important;
  }

  .feedback-item img {
    height: 260px !important;
    border-radius: 8px !important;
  }
}

@media (max-width: 480px) {
  .feedback-item {
    min-width: 160px !important;
  }

  .feedback-item img {
    height: 220px !important;
  }
}

/* ==========================================================================
   SMOOTH ANIMATIONS — Reduce on mobile for performance
   ========================================================================== */

@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  .hero-image-animated,
  .hero-name-animated,
  .hero-tagline-animated,
  .hero-buttons-animated {
    transition-duration: 0.4s !important;
  }
}

/* ==========================================================================
   LANDSCAPE PHONE — Special handling
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
  #hero {
    min-height: auto !important;
    padding: 1.5rem !important;
  }

  .hero-grid {
    grid-template-columns: 0.8fr 1.2fr !important;
    gap: 1.5rem !important;
  }

  .hero-image-animated img {
    max-width: 180px !important;
  }
}

/* ==========================================================================
   FINAL MOBILE POLISH — authoritative overrides for conflicting legacy rules
   ========================================================================== */

@media (max-width: 768px) {
  :root {
    --mobile-gutter: clamp(1rem, 4vw, 1.35rem);
  }

  /* Compact fixed navigation */
  .nav-inner {
    min-height: 64px;
    padding: 0.5rem var(--mobile-gutter) !important;
  }

  .nav-hamburger {
    padding: 0.4rem;
  }

  .language-toggle {
    gap: 0.2rem;
    padding: 0.2rem 0.55rem;
  }

  .lang-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
  }

  .lang-separator {
    font-size: 1rem;
  }

  #main-content {
    padding-top: 64px !important;
  }

  section {
    scroll-margin-top: 72px;
  }

  /* Hero: intentional breathing room without forcing a full viewport */
  #hero {
    min-height: auto !important;
    padding: 1.5rem var(--mobile-gutter) 3rem !important;
  }

  .hero-grid {
    gap: 1.35rem !important;
  }

  .hero-image-animated img {
    width: min(64vw, 250px) !important;
    max-width: none !important;
  }

  .hero-grid > div:last-child {
    gap: 1.25rem !important;
  }

  .hero-grid > div:last-child h1 {
    font-size: clamp(2rem, 8vw, 2.6rem) !important;
    line-height: 1.08 !important;
  }

  .hero-grid > div:last-child p {
    max-width: 32rem !important;
    font-size: 1rem !important;
    line-height: 1.6 !important;
  }

  .hero-buttons-animated {
    width: min(100%, 26rem);
    gap: 0.75rem !important;
    flex-wrap: nowrap !important;
  }

  .hero-buttons-animated a {
    flex: 1 1 0;
    padding: 0.7rem 0.8rem !important;
    white-space: nowrap;
    text-align: center;
  }

  /* Remove the negative overlap that glued About to Hero */
  #about {
    margin-top: 0 !important;
  }

  #about > div:first-child {
    padding: 1.75rem var(--mobile-gutter) !important;
    margin-bottom: 1.75rem !important;
  }

  #about > div:nth-child(2) {
    padding-inline: var(--mobile-gutter) !important;
  }

  /* Consistent project rhythm */
  .projects-section-simple {
    padding: 2rem var(--mobile-gutter) !important;
  }

  .project-simple-container {
    padding: 1.5rem 0 !important;
  }

  .project-content-section {
    margin-top: 2.5rem !important;
    padding-top: 1.5rem !important;
  }

  .project-simple-header {
    margin-bottom: 1.25rem !important;
    padding: 1.1rem 0.8rem !important;
    border-radius: 14px !important;
  }

  .project-simple-title {
    font-size: clamp(1.45rem, 6vw, 1.9rem) !important;
    line-height: 1.3 !important;
  }

  .project-desc {
    margin-bottom: 1.25rem !important;
    font-size: 1rem !important;
    line-height: 1.65 !important;
  }

  .skill-pills {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .skill-pill {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding: 0.65rem 0.5rem !important;
    font-size: 0.82rem !important;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }

  /* Portrait swipe carousel: the source videos are 9:16, not 16:9 */
  .video-accordion {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.75rem !important;
    width: calc(100% + var(--mobile-gutter)) !important;
    height: auto !important;
    margin: 1.5rem calc(var(--mobile-gutter) * -1) 0 0 !important;
    padding: 0 var(--mobile-gutter) 0.75rem 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .video-accordion::-webkit-scrollbar {
    display: none;
  }

  .video-accordion-item,
  .video-accordion-item:first-child,
  .video-accordion-item:not(:first-child) {
    flex: 0 0 min(72vw, 300px) !important;
    width: min(72vw, 300px) !important;
    min-height: 0 !important;
    aspect-ratio: 9 / 14 !important;
    border-radius: 16px !important;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .video-accordion__video {
    object-position: center center !important;
  }

  /* Growth cards must override the desktop !important 3-column grid */
  .growth-column-card {
    width: 100%;
    margin: 3rem auto 2rem !important;
    padding: 1.5rem var(--mobile-gutter) !important;
    overflow: hidden;
    scroll-margin-top: 80px;
  }

  .growth-column-title {
    margin-bottom: 1.25rem !important;
    font-size: clamp(1.9rem, 7vw, 2.35rem) !important;
  }

  .growth-metric-list {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.9rem !important;
    width: 100%;
  }

  .growth-metric-card {
    width: 100%;
    min-width: 0;
    padding: 1.4rem 1rem !important;
  }

  .growth-metric-value {
    font-size: clamp(2.15rem, 10vw, 2.7rem) !important;
  }

  /* Chabum: remove accumulated desktop margins and oversized gaps */
  .project-simple-container[style*="margin-top: 4rem"] {
    margin-top: 2rem !important;
    padding-top: 1rem !important;
    scroll-margin-top: 80px;
  }

  .project-simple-container[style*="margin-top: 4rem"] > div:first-child {
    margin-bottom: 1.75rem !important;
  }

  .project-simple-container[style*="margin-top: 4rem"] > div:first-child h3,
  [data-i18n="project.chabum.brandOverview"] {
    font-size: clamp(2rem, 8vw, 2.5rem) !important;
  }

  .chabum-brand-overview {
    padding: 0.5rem 0 1.5rem !important;
  }

  .chabum-section p {
    font-size: 1rem !important;
    line-height: 1.65 !important;
    text-align: left !important;
  }

  .chabum-two-columns,
  .chabum-vision-mission-row,
  .chabum-tab02-layout,
  .chabum-tab03-layout {
    gap: 1.4rem !important;
  }

  .chabum-vision-mission-box {
    padding: 1.4rem !important;
  }

  .chabum-brand-dev-box,
  .chabum-content-marketing-box,
  .chabum-ecommerce-box,
  .chabum-operations-box {
    margin-top: 2rem !important;
    padding: 3.2rem 1.4rem 1.4rem !important;
  }

  .chabum-logo-container {
    min-height: 0 !important;
    padding: 1.25rem !important;
  }

  .chabum-tab03-right {
    min-height: 0 !important;
    padding-block: 0.5rem 1rem;
  }

  .iphone-mockup-container {
    width: min(62vw, 240px) !important;
    max-width: none !important;
  }

  .iphone-device,
  .iphone-screen,
  .iphone-video {
    opacity: 1 !important;
  }

  .iphone-screen {
    transform: none !important;
  }

  .chabum-platform-logos-centered {
    margin-top: 1.25rem !important;
  }

  /* Avoid scaled mockups creating negative phantom spacing */
  .macbook-mockup-container {
    transform: none !important;
    margin: 1.5rem auto 0 !important;
  }

  .macbook-wrapper {
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .hero-image-animated img {
    width: min(60vw, 220px) !important;
  }

  .hero-buttons-animated a {
    font-size: 0.95rem !important;
  }

  .content-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .chabum-stats-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
