/* Main Stylesheet - Guilherme Ferreira Portfolio */

/* CSS Variables and Reset */
@import url('./utilities/variables.css');
@import url('./utilities/reset.css');

/* Component Styles */
@import url('./components/header.css');
@import url('./components/bottom-nav.css');
@import url('./components/hero.css');
@import url('./components/island-canvas.css');
@import url('./components/about-island-canvas.css');
@import url('./components/gallery-liquid.css');
@import url('./components/mini-gallery.css');
@import url('./components/about.css');
@import url('./components/contact.css');
@import url('./components/footer.css');
@import url('./components/project-content.css');
@import url('./components/media-controls.css'); /* UNIFIED MEDIA CONTROLS */
@import url('./components/loading-enhanced.css'); /* ENHANCED LOADING SYSTEM */
@import url('./components/error-404.css'); /* 404 ERROR OVERLAY */

/* Utility Classes */
@import url('./utilities/common.css');
@import url('./utilities/accessibility.css');
@import url('./utilities/animations.css');
@import url('./utilities/liquid-morphing.css');

/* Global Styles */
html {
  scroll-behavior: smooth;
  box-sizing: border-box;
  /* Prevent horizontal scrolling at root level */
  overflow-x: hidden;
  max-width: 100vw;
  /* Account for fixed header when scrolling to sections */
  scroll-padding-top: var(--header-height); /* Use header height variable */
}

/* Override reset.css target margin to use our header height */
:target {
  scroll-margin-block: var(--header-height) 0; /* Top margin for header, no bottom margin */
}

/* Ensure sections align perfectly with navigation */
#home,
#projects,
#about,
#contact {
  scroll-margin-top: var(--header-height); /* Precise header height alignment */
}

/* Mobile scroll offset adjustment - account for content shift when header is hidden */
@media (max-width: 767px) {
  /* When header is hidden, reduce scroll margin since content shifted up by 72px */
  body.header-hidden #home,
  body.header-hidden #projects,
  body.header-hidden #about,
  body.header-hidden #contact {
    scroll-margin-top: -2px; /* Small negative margin to account for content shift */
  }
  
  /* Also adjust global scroll padding */
  body.header-hidden {
    scroll-padding-top: -2px;
  }
}

*,
*::before,
*::after {
  box-sizing: inherit;
  /* Ensure no element can cause horizontal scroll */
  max-width: 100%;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary-white);
  background-color: var(--bg-main-dark);
  overflow-x: hidden;
  /* Additional safety for mobile */
  max-width: 100vw;
  position: relative;
}

/* Main Layout */
.main-content {
  position: relative; /* Enable transforms */
  padding-top: var(--header-height);
  min-height: 100vh;
  min-height: -webkit-fill-available; /* iOS Safari fix */
  min-height: 100dvh; /* Use dynamic viewport height for better mobile support */
}

/* Section Base Styles */
section {
  padding: var(--space-3xl) var(--space-md);
  max-width: var(--max-width);
  margin: 0 auto;
}

@media (min-width: 768px) {
  section {
    padding: var(--space-4xl) var(--space-lg);
  }
}

@media (min-width: 1024px) {
  section {
    padding: var(--space-5xl) var(--space-xl);
  }
}

/* Container Base Styles */
.hero-container,
.gallery-container,
.about-container,
.contact-container,
.footer-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (min-width: 768px) {
  .hero-container,
  .gallery-container,
  .about-container,
  .contact-container,
  .footer-container {
    padding: 0 var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .hero-container,
  .gallery-container,
  .about-container,
  .contact-container,
  .footer-container {
    padding: 0 var(--space-xl);
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  font-family: var(--font-bold);
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

@media (min-width: 768px) {
  h1 {
    font-size: var(--text-4xl);
  }
  
  h2 {
    font-size: var(--text-3xl);
  }
  
  h3 {
    font-size: var(--text-2xl);
  }
}

@media (min-width: 1024px) {
  h1 {
    font-size: var(--text-5xl);
  }
  
  h2 {
    font-size: var(--text-4xl);
  }
}

p {
  margin-bottom: var(--space-md);
}

/* Links */
a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
  /* Accessibility: outline handled by accessibility.css */
}

a:hover {
  color: var(--accent-yellow);
}

/* Note: a:focus outline styles handled by accessibility.css */
a:focus {
  color: var(--accent-yellow);
  /* Note: Focus outlines centrally managed by accessibility.css */
}

/* Buttons */
button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.2s ease;
  /* Accessibility: outline handled by accessibility.css */
}

/* Note: button:focus styles handled by accessibility.css */

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Screen Reader Only - Basic accessibility for console warnings */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Error Message Styles */
/* Error Message Styles */
.error-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-main-dark);
  z-index: var(--z-error);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-primary);
}

.error-content {
  text-align: center;
  padding: 2rem;
  max-width: 400px;
}

.error-content h2 {
  color: var(--text-primary-white);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.error-content p {
  color: var(--text-muted-grey);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.error-retry-btn {
  background: var(--text-primary-white);
  color: var(--bg-main-dark);
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--font-primary);
  transition: background-color 0.2s ease;
}

.error-retry-btn:hover {
  background: var(--accent-yellow);
  color: var(--text-primary-white);
}

/* Mobile overflow prevention */
@media (max-width: 768px) {
  /* Ensure all main sections respect viewport width */
  .hero-section,
  .gallery-section,
  .about-section,
  .contact-section,
  .footer,
  .header {
    padding: var(--space-3xl) 0;
    max-width: 100vw;
    overflow-x: hidden;
  }
  
  /* Ensure images don't cause overflow */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Ensure pre-formatted text doesn't cause overflow */
  pre, code {
    max-width: 100%;
    overflow-x: auto;
  }
}

/* Mobile Content Offset System - DIRECT APPROACH */
@media (max-width: 767px) {
  /* Add smooth transition for content movement */
  .main-content {
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  }
  
  /* When header is hidden on mobile, move content up by header height */
  body.header-hidden .main-content {
    transform: translateY(-72px) !important;
  }
  
  /* Footer positioning - move up when bottom nav is active */
  body.header-hidden footer {
    transform: translateY(-72px);
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  }
  
  /* Reduce gap between contact section and footer on mobile */
  #contact {
    margin-bottom: 0; /* Remove gap completely */
    padding-bottom: var(--space-sm); /* Minimal padding instead of default --space-3xl (64px) */
  }
}

/* Desktop Content Offset System - Smooth return animation */
@media (min-width: 768px) {
  /* Add smooth transition for content when switching back to desktop */
  .main-content {
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  }
  
  /* Ensure content returns to normal position on desktop */
  body.header-hidden .main-content,
  .main-content {
    transform: translateY(0px);
  }
  
  /* Footer returns to normal position on desktop */
  footer {
    transform: translateY(0px);
    transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  }
}

/* Desktop - content offset handled by base styles */

/* ==========================================================================
   CONTENT OFFSET SAFETY GUARDS
   ========================================================================== */

/* Prevent content offset conflicts with reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .main-content {
    transition: none !important;
  }
  
  /* Disable content offset animation for users who prefer reduced motion */
  body.header-hidden .main-content {
    transform: translateY(0px) !important; /* Keep content in place */
  }
}

/* Ensure content offset doesn't affect print styles */
@media print {
  .main-content {
    transform: none !important;
    padding-top: 0 !important;
  }
  
  body.header-hidden .main-content {
    transform: none !important;
  }
}
