@layer layout;

/* Header - Sticky Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: hsla(0,0%,100%,0.98);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid hsla(0,0%,0%,0.08);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) clamp(1rem, 4vw, 1.5rem);
  gap: var(--space-xs);
  max-width: 120rem;
  margin-inline: auto;
}

.logo a {
  font-size: clamp(1.125rem, 3vw, 1.375rem);
  font-weight: 800;
  color: var(--navy);
  text-decoration: none;
  position: relative;
}

.logo a::after {
  content: '';
  position: absolute;
  bottom: -0.25rem;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gold);
  transition: width 0.3s ease;
}

.logo a:hover::after {
  width: 100%;
}

/* Main Navigation */
.main-nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  align-items: center;
}

.main-nav a {
  font-size: clamp(0.875rem, 2.2vw, 0.95rem);
  font-weight: 600;
  color: var(--navy-light);
  padding: var(--space-xs) 0;
  position: relative;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.main-nav a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--gold);
  transition: width 0.3s ease;
}

.main-nav a:hover::before,
.main-nav a:focus-visible::before {
  width: 100%;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  color: var(--navy);
}

/* Header CTA */
.header-cta {
  display: flex;
  gap: clamp(0.5rem, 1.5vw, 0.75rem);
  align-items: center;
}

/* Mobile Nav Toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: clamp(0.5rem, 1.5vw, 0.75rem);
  border-radius: var(--radius-md);
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: var(--z-nav);
}

.nav-toggle span {
  width: 1.5rem;
  height: 2px;
  background: var(--navy);
  border-radius: 1px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 4px);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Sections */
.section {
  padding-block: clamp(3rem, 8vw, 4rem);
}

.section-light {
  background: var(--cream);
}

.section-highlight {
  background: var(--navy);
  color: hsla(0,0%,90%,0.95);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}

.two-column {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .two-column {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }
}

/* FAB Container (Floating Actions) */
.fab-container {
  position: fixed;
  bottom: var(--space-sm);
  right: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: var(--z-fab);
}

.fab {
  width: clamp(3.5rem, 9vw, 4rem);
  height: clamp(3.5rem, 9vw, 4rem);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  text-decoration: none;
  box-shadow: var(--shadow-xl);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(20px);
}

.fab svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .header-inner {
    padding-inline: clamp(1rem, 4vw, 1.25rem);
  }
  
  .main-nav {
    position: fixed;
    inset: 0;
    top: 100%;
    right: 0;
    background: hsla(0,0%,100%,0.995);
    backdrop-filter: blur(30px);
    border-top-left-radius: var(--radius-xl);
    width: min(90vw, 320px);
    height: calc(100dvh - 100%);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
  }
  
  .main-nav.is-open {
    max-height: 100dvh;
    padding-top: var(--space-md);
  }
  
  .main-nav ul {
    flex-direction: column;
    padding: var(--space-md) var(--space-lg);
    gap: var(--space-lg);
  }
  
  .main-nav a {
    font-size: clamp(1.1rem, 3.5vw, 1.25rem);
    padding: var(--space-md) 0;
    border-bottom: 1px solid hsla(0,0%,0%,0.05);
  }
  
  .header-cta {
    display: none;
  }
  
  .nav-toggle {
    display: flex;
  }
  
  .fab-container {
    bottom: clamp(1rem, 3vw, 1.25rem);
    right: clamp(1rem, 3vw, 1.25rem);
  }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
  .fab-container {
    flex-direction: row;
    bottom: var(--space-xs);
    right: var(--space-xs);
  }
}

/* Accessibility Enhancements */
.nav-toggle:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .main-nav,
  .nav-toggle span,
  .fab {
    transition: none;
  }
}

/* Print */
@media print {
  .site-header {
    position: static;
    box-shadow: none;
  }
  
  .main-nav {
    position: static;
  }
}