/*
  Mobile-First Main Layout Styles
  Design tokens and global layout patterns
*/

/* Custom Fonts */
@font-face {
  font-family: 'Flow';
  src: url('/fonts/Flow.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'NEUROPOL';
  src: url('/fonts/NEUROPOL.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  /* Darker than the brand orange (#c3760a, ~3.5:1) so white text clears WCAG AA
     4.5:1 when the link is focused/visible — #9c5e08 is ~5.2:1 (#34). */
  background: #9c5e08;
  color: #ffffff;
  padding: 8px 16px;
  text-decoration: none;
  font-family: 'Flow', sans-serif;
  font-size: 14px;
  z-index: 10000;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

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

:root {
  /* Color Tokens */
  --primary-action: #c3760a;
  --primary-hover: #a72424;
  --secondary-action: #7a92a5;
  --secondary-action-strong: #566b7c; /* filled share buttons: white text 5.54:1 (#136) */
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --background-primary: #1a1a1a;
  --background-overlay: rgba(0, 0, 0, 0.8);
  
  /* Spacing Tokens */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  
  /* Touch Target Sizing */
  --touch-target-min: 44px;
  --touch-target-comfortable: 48px;
  --touch-target-primary: 56px;
  
  /* Typography */
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-xxl: 24px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/*
  Touch behaviour for all controls. `touch-action: manipulation` drops the
  ~300ms tap delay and stops double-tap-to-zoom on the buttons, and we suppress
  the default grey tap-flash because every control already has its own :active
  feedback. Keeps taps feeling instant on phones.
*/
button,
.btn-primary,
.btn-secondary,
.btn-leave,
.btn-start-reading,
.btn-download,
.logo-link,
.skip-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Flow, sans-serif;
  
  /* Background image - matches legacy visual character */
  background-image: url('/img/landing_bk.jpg');
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: local;
  background-color: var(--background-primary); /* Fallback color */
  
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}

/* Main container uses flex layout */
#main-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#content-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Allow scrolling when age gate is active */
body.age-gate-active {
  overflow-y: auto;
}

/* Logo Bar - Responsive scaling to match legacy behavior exactly */
.logo-bar {
  width: 100%;
  margin-top: 45px; /* logo sits ~15px below the viewport top (was 77px) */
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  position: relative;
  display: flex;
  justify-content: center;
  z-index: 10;
  
  /* Mobile First (320px-479px): Compact scaling */
  height: 54px;
  background-image: url('/img/metal_bar_480.png');
}

.logo-link {
  position: absolute;
  top: -30px;
  left: 50%;
  text-decoration: none;
  cursor: pointer;
  display: block;

  /* Mobile First (320px-479px): Small logo */
  width: 174px;
  height: 100px;
  margin-left: -87px; /* Center positioning: 174px ÷ 2 */
}

.logo-link:hover .logo {
  opacity: 0.8;
}

.logo {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  transition: opacity 0.2s ease;
  background-image: url('/img/logo_480.png');
}

.logo .label-left,
.logo .label-right {
  font-family: NEUROPOL, sans-serif;
  color: #d0cfcd;
  position: absolute;
  top: 13px;
  white-space: nowrap;
  
  /* Mobile First (320px-479px): Small text */
  font-size: 10px;
}

.logo .label-left {
  left: -65px; /* Mobile positioning - slightly closer */
}

.logo .label-right {
  left: 160px; /* Mobile positioning - slightly further */
}

/* Standard Layout (480px+): Larger scaling - matches legacy exactly */
@media screen and (min-width: 480px) {
  .logo-bar {
    height: 72px; /* +33% larger */
    background-image: url('/img/metal_bar.png');
  }

  .logo-link {
    width: 232px; /* +33% larger */
    height: 133px; /* +33% larger */
    margin-left: -117px; /* Center positioning: 232px ÷ 2 */
  }

  .logo {
    background-image: url('/img/logo.png');
  }
  
  .logo .label-left,
  .logo .label-right {
    font-size: 16px; /* +60% larger */
  }
  
  .logo .label-left {
    left: -115px; /* Slightly closer - 10px adjustment */
  }

  .logo .label-right {
    left: 210px; /* Slightly further - 10px adjustment */
  }
}

/* 768px+ and 1200px+: Logo elements stay identical to 480px */
/* Only layout positioning changes at higher breakpoints */

/* XCOM Logo Bar - Shared between age gate and landing page */
.xcom-logo-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 30px 0;
  padding: 0 var(--space-md);
}

.xcom-logo-bar .x-com-logo {
  width: 160px; /* Larger to match legacy size */
  height: 139px; /* Maintain aspect ratio */
  background-image: url('/img/xcom_logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.xcom-logo-bar .x-com-logo:hover {
  opacity: 1;
}

/* Desktop Enhancements (1200px+) */
@media screen and (min-width: 1200px) {
  /* Enhanced Logo Styling */
  .logo-bar {
    margin-top: 50px; /* Slightly more space (was 85px) */
  }

  .xcom-logo-bar .x-com-logo {
    width: 180px; /* Slightly larger */
    height: 156px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  }

  .xcom-logo-bar .x-com-logo:hover {
    filter: drop-shadow(0 4px 8px rgba(195, 118, 10, 0.4));
    transform: scale(1.02);
    transition: all 0.3s ease;
  }
}

/* ==========================================================================
   Reduced motion (issue #35)
   Honour `prefers-reduced-motion: reduce`: collapse every transition/animation
   to near-instant so the scene cross-fade, hint/quote opacity fades, and
   zoom/pan tweening no longer animate. The !important duration overrides the
   inline `transition` strings app.js sets on faded elements; the state changes
   still happen, just without the motion. JS-driven motion (auto-fullscreen,
   quote auto-advance) is gated separately via prefersReducedMotion() in app.js.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
