/* Optimized Mobile Styles */
@media only screen and (max-width: 768px) {
  /* Base styles */
  html, body {
    overflow-x: hidden;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }

  #main-content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin-top: 60px;
  }

  /* Splash Screen */
  #splash {
    background-color: #2A2A2A !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    position: relative;
  }

  #splash-title {
    font-size: 32px !important;
    margin-bottom: 15px !important;
    text-align: center;
  }

  #splash-presents {
    font-size: 24px !important;
    font-family: 'Great Vibes', cursive !important;
    margin: 10px 0 !important;
    text-align: center;
  }

  #splash-name {
    font-size: 28px !important;
    margin-top: 15px !important;
    text-align: center;
  }

  #splash video {
    object-position: center 20%;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    opacity: 0.1;
  }
  
  #filmgrain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    opacity: 0.1;
  }

  .loading-indicator {
    bottom: 25% !important;
    position: absolute;
  }

  .loading-circle {
    width: 30px !important;
    height: 30px !important;
    border-width: 3px !important;
  }

  /* Header */
  .header {
    height: 65px;
    min-height: 65px;
    padding: 15px 0;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: fixed;
  }
  
  /* Header video (eyes) */
  #header-video {
    position: absolute;
    top: 50%;
    left: 50%;
    width: auto;
    height: 400px;
    transform: translate(calc(-50% + 145px), calc(-50% + 20px));
    opacity: 0.5;
    z-index: 1;
  }
  
  /* Film grain overlay */
  .grain-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
  }
  
  #header-grain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.25;
    mix-blend-mode: overlay;
    z-index: 2;
  }
  
  /* Film grain container */
  #film-grain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
  }
  
  #film-grain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.1;
  }

  .header-content {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 5px 10px;
    text-align: left !important;
    height: 40px;
    position: relative;
    width: 100%;
  }

  .logo-text {
    display: inline-block;
    margin: 0 5px 0 0 !important;
    font-size: 14px;
    text-align: left !important;
  }

  .header .sub-text {
    display: inline-block !important;
    margin: 0 0 0 -10px !important;
    font-size: 18px !important;
    text-align: left !important;
    padding-left: 10px !important;
    position: relative !important;
    padding-top: 4px !important;
  }

  .header .separator {
    display: inline-block !important;
    margin: 0 3px 0 -2px !important;
    font-size: 12px !important;
    transform: translateY(-1px) !important;
  }

  .header-title {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
  }

  .header-title span.divider {
    display: none;
  }

  .alter-ego-title {
    display: block;
    font-size: 18px;
    letter-spacing: 1px;
    margin-bottom: 2px;
    line-height: 1.2;
  }

  .karl-title {
    display: block;
    font-size: 14px;
    opacity: 0.9;
    text-align: left;
    padding-left: 6px;
  }

  /* Panels */
  .panels-wrapper {
    padding: 8px 6px 0;
    width: 100%;
    position: relative;
  }

  .panels-container {
    margin-top: 10px;
    margin-bottom: 0;
    padding: 0 !important;
    width: 100%;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-padding: 16px;
    scroll-snap-type: none;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    position: relative;
    will-change: scroll-position;
    -webkit-overflow-scrolling: touch;
  }

  .panels-container:has(.panel.active) {
    scroll-snap-type: x mandatory;
  }

  .nav-panels {
    gap: 8px !important;
    margin-left: 8px !important;
    margin-bottom: 0 !important;
    display: flex !important;
    padding-right: 8px !important;
    padding-bottom: 0 !important;
    animation: none !important;
    transform: none !important;
    justify-content: flex-start !important;
    transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1);
    width: max-content;
    min-width: 100%;
    position: relative;
  }

  .panel {
    flex: 0 0 100px !important;
    width: 100px !important;
    min-width: 10px !important;
    max-width: 100px !important;
    height: 280px;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
    z-index: 1;
    will-change: width, transform;
  }

  .panel.active {
    flex: 0 0 420px !important;
    width: 420px !important;
    min-width: 420px !important;
    max-width: 420px !important;
    position: relative;
    z-index: 10;
    margin: 0 !important;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-font-smoothing: subpixel-antialiased;
    filter: none;
    opacity: 1;
  }
  
  .panel.active video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    filter: none;
    opacity: 1;
  }
  
  .panel.active.centered {
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
  }

  .panel.active .panel-content {
    opacity: 0;
  }

  .nav-panels .panel:not(.active) {
    transform: scale(0.95);
    opacity: 1;
  }

  .panel-content {
    padding: 10px 8px 10px 2px;
    width: 100%;
    max-width: 100%;
    text-align: left;
  }

  .panel-title,
  .panel .panel-title {
    font-size: 11px !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
    padding-right: 6px !important;
    padding-left: 0 !important;
    margin-left: -2px !important;
  }

  .panel-subtitle,
  .panel .panel-subtitle {
    font-size: 9px !important;
    line-height: 1.2 !important;
    opacity: 0.8 !important;
    padding-right: 6px !important;
    padding-left: 0 !important;
    margin-left: -2px !important;
  }

  .panel img {
    width: 100%;
    height: auto;
  }

  /* Timeline Categories */
  .timeline-categories {
    display: flex !important;
    justify-content: center !important;
    gap: 8px !important;
    margin: -100px auto 0 !important;
    padding: 0 !important;
    position: relative !important;
    flex-wrap: wrap;
    width: 100%;
  }

  .timeline-category,
  .resume-btn {
    font-size: 14px !important;
    padding: 5px 10px !important;
    min-width: 0 !important;
    width: auto !important;
    margin: 0 !important;
    font-family: 'Bebas Neue', sans-serif !important;
    color: #666 !important;
    text-transform: uppercase !important;
    letter-spacing: normal !important;
    font-weight: normal !important;
    display: inline-block !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
  }
  
  .timeline-category.active,
  .resume-btn:hover {
    color: #fff !important;
  }

  .timeline-category::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--accent-color, #8bc34a);
    transition: width 0.3s, left 0.3s;
  }

  .timeline-category.active::after {
    width: 100%;
    left: 0;
  }

  .timeline-category.active {
    color: var(--accent-color, #8bc34a) !important;
  }

  /* Timeline Section */
  .timeline-section {
    padding: 0 10px 40px;
    margin-top: 15px;
  }
  
  .timeline {
    max-width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
  }

  /* Background static line */
  .timeline::after {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1;
    transform: none !important;
    transition: none !important;
  }
  
  /* Animated green line that draws down */
  .timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    height: 0;
    width: 2px;
    background: var(--accent-color, #8bc34a);
    z-index: 1;
    transform: none !important;
    transition: none !important;
  }
  
  .timeline.animate-line::before {
    animation: drawLineDown 1.8s cubic-bezier(0.76, 0, 0.24, 1) forwards;
  }
  
  @keyframes drawLineDown {
    0% {
      height: 0;
    }
    20% {
      height: 15%;
    }
    40% {
      height: 30%;
    }
    60% {
      height: 50%;
    }
    80% {
      height: 75%;
    }
    100% {
      height: 100%;
    }
  }

  /* Override the alternating left/right pattern from main CSS */
  .timeline-item,
  .timeline-item:nth-child(odd),
  .timeline-item:nth-child(even) {
    margin: 0 0 30px 0;
    padding-left: 30px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    left: 0 !important; /* Override main CSS */
    text-align: left !important; /* Override main CSS */
    transform: none !important; /* Prevent any transforms from main CSS */
  }
  
  /* Override desktop timeline behavior completely in mobile */
  .timeline-item.shift-left .timeline-dot,
  .timeline-item.shift-right .timeline-dot {
    left: 11px !important;
    right: auto !important;
  }
  
  /* Override the desktop timeline line movement */
  .timeline:has(.timeline-item:nth-child(odd) .timeline-content.active)::before,
  .timeline:has(.timeline-item:nth-child(even) .timeline-content.active)::before {
    transform: none !important;
    left: 15px !important;
  }
  
  /* Override the desktop timeline background line movement */
  .timeline:has(.timeline-item:nth-child(odd) .timeline-content.active)::after,
  .timeline:has(.timeline-item:nth-child(even) .timeline-content.active)::after {
    transform: none !important;
    left: 15px !important;
  }
  
  /* Center the timeline content in mobile view */
  .timeline-content,
  .timeline-item:nth-child(odd) .timeline-content,
  .timeline-item:nth-child(even) .timeline-content {
    margin: 0;
    left: 15px;
    width: 365px;
    position: relative;
    right: auto; /* Override right alignment */
    transform: none !important; /* Prevent any transforms from main CSS */
  }
  
  /* Consistent dot positioning */
  .timeline-dot,
  .timeline-item:nth-child(odd) .timeline-dot,
  .timeline-item:nth-child(even) .timeline-dot {
    left: 11px;
    transform: none !important; /* Prevent any transforms from main CSS */
  }

  .timeline-dot {
    position: absolute;
    left: 11px;
    top: 60px;
    width: 8px;
    height: 8px;
    background-color: #222;
    border-radius: 50%;
    z-index: 3;
    transform: scale(1);
    opacity: 1;
    transition: background-color 0.3s ease;
  }
  
  .timeline.animate-line .timeline-item:nth-child(1) .timeline-dot {
    animation: dotAppear 0.3s ease forwards;
    animation-delay: 0.3s;
  }
  
  .timeline.animate-line .timeline-item:nth-child(2) .timeline-dot {
    animation: dotAppear 0.3s ease forwards;
    animation-delay: 0.5s;
  }
  
  .timeline.animate-line .timeline-item:nth-child(3) .timeline-dot {
    animation: dotAppear 0.3s ease forwards;
    animation-delay: 0.7s;
  }
  
  .timeline.animate-line .timeline-item:nth-child(4) .timeline-dot {
    animation: dotAppear 0.3s ease forwards;
    animation-delay: 0.9s;
  }
  
  .timeline.animate-line .timeline-item:nth-child(5) .timeline-dot {
    animation: dotAppear 0.3s ease forwards;
    animation-delay: 1.1s;
  }
  
  .timeline.animate-line .timeline-item:nth-child(6) .timeline-dot {
    animation: dotAppear 0.3s ease forwards;
    animation-delay: 1.3s;
  }
  
  @keyframes dotAppear {
    0% {
      background-color: #222;
      box-shadow: none;
    }
    50% {
      transform: scale(1.2);
      background-color: var(--accent-color, #8bc34a);
      box-shadow: 0 0 12px var(--accent-color, #8bc34a);
    }
    100% {
      transform: scale(1);
      background-color: var(--accent-color, #8bc34a);
      box-shadow: 0 0 6px var(--accent-color, #8bc34a);
    }
  }

  /* Date positioning to align with banners */
  .timeline-date,
  .timeline-item:nth-child(odd) .timeline-date,
  .timeline-item:nth-child(even) .timeline-date {
    position: relative;
    left: 15px;
    margin-top: 8px;
    width: 365px;
    font-size: 12px;
    color: #888;
    padding-left: 0;
    display: block;
    text-align: left;
    margin-left: 0;
    margin-right: auto;
    transform: none !important;
  }


  
  .timeline-content {
    padding: 0;
    width: 365px;
    max-width: 100%;
    background: #222;
    border-radius: 6px;
    overflow: hidden;
    height: 120px;
    margin: 0;
    position: relative;
    transition: all 1s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
  }

  .timeline-content h3,
  .timeline-item .timeline-content h3 {
    font-size: 15.4px !important;
    margin: 0 !important;
    color: #fff !important;
    padding: 0 5px !important;
    position: absolute !important;
    bottom: 38px !important;
    width: 200px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8) !important;
  }
  
  /* Odd items (1st, 3rd, 5th, 7th, 9th) - right aligned */
  .timeline-item:nth-child(odd) .timeline-content h3 {
    text-align: right !important;
    right: 5px !important;
    left: auto !important;
  }
  
  /* Even items (2nd, 4th, 6th, 8th, 10th) - left aligned */
  .timeline-item:nth-child(even) .timeline-content h3 {
    text-align: left !important;
    left: 5px !important;
    right: auto !important;
  }

  .timeline-content p:first-of-type {
    font-size: 10px !important;
    margin: 0 !important;
    color: #fff !important;
    padding: 0 5px !important;
    position: absolute !important;
    bottom: 25px !important;
    width: 200px !important;
    line-height: 1.3 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8) !important;
    font-weight: 500 !important;
  }
  
  .timeline-content p:last-of-type {
    font-size: 10px !important;
    margin: 0 !important;
    color: #fff !important;
    padding: 0 5px !important;
    position: absolute !important;
    bottom: 10px !important;
    width: 200px !important;
    line-height: 1.3 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8) !important;
    font-weight: 500 !important;
  }
  
  /* Odd items (1st, 3rd, 5th, 7th, 9th) - right aligned */
  .timeline-item:nth-child(odd) .timeline-content p {
    text-align: right !important;
    right: 5px !important;
    left: auto !important;
  }
  
  /* Even items (2nd, 4th, 6th, 8th, 10th) - left aligned */
  .timeline-item:nth-child(even) .timeline-content p {
    text-align: left !important;
    left: 5px !important;
    right: auto !important;
  }

  .timeline-content .timeline-banner {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    border-radius: 6px;
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    transform-origin: center center;
  }
  
  .timeline-content h3,
  .timeline-content p {
    position: relative;
    z-index: 4;
    transition: opacity 0.3s ease;
  }

  .timeline-content.active h3,
  .timeline-content.active p {
    opacity: 0;
  }

  .timeline-content video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none; /* Prevent interaction with inactive videos */
  }

  .timeline-content.active {
    width: 320px;
    height: 180px;
    z-index: 10;
    background: #000;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  
  .timeline-content.active .timeline-banner {
    transform: scale(1.15);
    opacity: 0;
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    transition-delay: 0s, 0.7s;
    pointer-events: none;
  }
  
  .timeline-content.active video {
    opacity: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: auto; /* Enable interaction with active videos */
    transition: opacity 0.8s ease;
    transition-delay: 0.3s;
  }

  /* Video Overlay */
  .timeline-content.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,1);
    z-index: 5;
    opacity: 1;
    transition: opacity 0.3s ease;
    transition-delay: 0.7s;
  }

  /* Remove unused video container styles */

  /* Contact modal padding adjustments */
  .contact-modal-content p {
    margin-bottom: 10px;
  }

  /* Logo and Contact */
  #logo-container {
    position: fixed;
    bottom: 855px;
    right: -20px;
    transform: scale(0.7);
    transform-origin: bottom right;
    transition: transform 1.1s ease;
    z-index: 700;
  }

  #logo {
    width: 25px;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 700;
  }

  .logo-contact-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .contact-link {
    font-size: 10px;
    color: #fff;
    opacity: 0.8;
    text-decoration: none;
    background-color: rgba(0,0,0,0.3);
    border-radius: 3px;
    padding: 3px 5px;
  }

  /* Modal styles */
  .modal {
    padding: 0;
  }

  .modal-content {
    width: 95%;
    height: 95%;
    margin: 2.5% auto;
    border-radius: 10px;
    padding: 15px;
  }

  .close {
    top: 15px;
    right: 15px;
    font-size: 24px;
  }

  /* Contact Modal - Mobile Specific */
  .contact-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
  }
  
  .contact-modal-content {
    width: 80%;
    max-width: 300px;
    padding: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(76, 175, 80, 0.3);
    margin: 0;
    z-index: 10001;
    opacity: 1 !important;
  }
  
  #resumeModal .modal-content {
    padding: 10px;
  }

  .resume-container {
    flex-direction: column;
    padding: 10px;
  }

  .resume-left-column,
  .resume-right-column {
    width: 100%;
    padding: 10px 0;
  }

  /* Effects */
  #bokeh-background {
    transform: scale(0.7);
  }
}