/**
 * Econest - Layout
 * Header, footer, container, grid
 */

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: var(--section-padding-x);
  padding-right: var(--section-padding-x);
}

.container-narrow {
  max-width: var(--container-narrow);
}

/* Section */
.section {
  padding-top: var(--section-padding-y);
  padding-bottom: var(--section-padding-y);
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  background: transparent;
  transition: background var(--duration-normal), box-shadow var(--duration-normal);
}

.header.scrolled {
  background: rgba(245, 245, 240, 0.95);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .header.scrolled {
  background: rgba(10, 10, 10, 0.95);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
}

.logo {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--color-gold);
}

/* Nav */
.nav-desktop {
  display: none;
}

@media (min-width: 992px) {
  .nav-desktop {
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
  }
}

.nav-desktop a {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
}

.nav-desktop a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 1px;
  background: var(--color-gold);
  transition: width var(--duration-normal) var(--ease-out-expo);
}

.nav-desktop a:hover::after,
.nav-desktop a.active::after {
  width: 100%;
}

/* Mobile menu toggle */
.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 32px;
  height: 32px;
  padding: 0;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  transition: transform var(--duration-normal) var(--ease-out-expo),
    opacity var(--duration-normal);
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(4px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-4px) rotate(-45deg);
}

@media (min-width: 992px) {
  .menu-toggle {
    display: none;
  }
}

/* Mobile nav overlay - blur + semi-transparent */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 98;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nav-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Mobile nav - right drawer 280-320px */
.nav-mobile {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  max-width: 320px;
  min-width: 280px;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  background: var(--color-bg);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  padding: calc(var(--header-height) + var(--space-xl)) var(--space-xl) var(--space-xl);
  padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.35s;
  visibility: hidden;
  z-index: 99;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.nav-mobile.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}

.nav-mobile a {
  display: block;
  font-size: var(--text-base);
  font-family: var(--font-body);
  font-weight: 500;
  padding: var(--space-md) 0;
  min-height: 44px;
  line-height: 1.4;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  white-space: normal;
  word-wrap: break-word;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.nav-mobile a:hover {
  color: var(--color-gold);
}

.nav-mobile a:last-child {
  border-bottom: none;
}

body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  left: 0;
}

@media (min-width: 992px) {
  .nav-mobile {
    display: none;
  }
}

/* Theme toggle */
.theme-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.theme-toggle:hover {
  background: var(--color-border);
}

/* Footer - theme-aware (light/dark) */
.footer {
  background: var(--color-dark);
  color: var(--color-white);
  padding: var(--space-5xl) 0 var(--space-2xl);
}

[data-theme="light"] .footer {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
}

[data-theme="light"] .footer-brand .logo {
  color: var(--color-black);
}

[data-theme="light"] .footer .section-subtitle,
[data-theme="light"] .footer .card-meta {
  color: var(--color-text-muted);
}

[data-theme="light"] .footer a {
  color: var(--color-text);
}

[data-theme="light"] .footer-bottom {
  border-top-color: var(--color-border);
  color: var(--color-text-muted);
}

.footer .section-subtitle,
.footer .card-meta {
  color: var(--color-light-gray);
}

/* Soften transition into footer on home page */
body.home .footer {
  background: linear-gradient(180deg, transparent, var(--color-dark));
}

[data-theme="light"] body.home .footer {
  background: linear-gradient(180deg, var(--color-bg), var(--color-bg-alt));
}

.footer a:hover {
  color: var(--color-gold);
}

.footer-grid {
  display: grid;
  gap: var(--space-3xl);
  margin-bottom: var(--space-4xl);
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.footer-brand .logo {
  color: var(--color-white);
  margin-bottom: var(--space-lg);
  display: block;
}

.footer-links h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold);
  margin-bottom: var(--space-lg);
}

.footer-links ul li {
  margin-bottom: var(--space-md);
}

.footer-bottom {
  padding-top: var(--space-2xl);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-light-gray);
}

/* Grid utilities */
.grid-2 {
  display: grid;
  gap: var(--space-2xl);
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.grid-3 {
  display: grid;
  gap: var(--space-2xl);
}

@media (min-width: 768px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grid-4 {
  display: grid;
  gap: var(--space-2xl);
}

@media (min-width: 768px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}
