/* ==================================================================
   METTA HEADER FOOTER STYLES
   Shared styles for sticky header and footer — used across ALL pages
   ================================================================== */

/* ===== CSS Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

/* ===== Design tokens ===== */
:root {
  --mt-bg-primary: #2a2a2a;
  --mt-bg-secondary: #1a1a1a;
  --mt-bg-header: #1a1710;
  --mt-text-primary: #f5f5f5;
  --mt-text-secondary: #cccccc;
  --mt-accent: #b8860b;
  --mt-accent-hover: #9c6f08;
  --mt-border: rgba(184, 134, 11, 0.2);
  --mt-maxw: 1080px;
  --mt-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
  :root {
    --mt-bg-primary: #f8f5f0;
    --mt-bg-secondary: #f0ebe0;
    --mt-bg-header: #f5f0e6;
    --mt-text-primary: #333333;
    --mt-text-secondary: #666666;
    --mt-accent: #8b6d0b;
    --mt-accent-hover: #6d5306;
    --mt-border: rgba(139, 109, 11, 0.15);
    --mt-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  }
}

/* ===== Sticky Header ===== */
.metta-sticky-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 9999;
  background: var(--mt-bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--mt-border);
  box-shadow: var(--mt-shadow);
  width: 100%;
}

.metta-header-container {
  max-width: var(--mt-maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  gap: 1rem;
}

.metta-logo a {
  color: var(--mt-text-primary);
  text-decoration: none;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.metta-logo .han {
  color: var(--mt-accent);
  font-family: 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

/* ===== Navigation ===== */
.metta-nav ul {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.metta-nav a {
  color: var(--mt-text-secondary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: clamp(0.85rem, 1.5vw, 0.95rem);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.metta-nav a:hover,
.metta-nav a:focus-visible {
  color: var(--mt-text-primary);
  background: rgba(184, 134, 11, 0.12);
  outline: none;
}

.metta-nav a.active {
  color: var(--mt-accent);
  background: rgba(184, 134, 11, 0.2);
}

/* ===== EN/CH content-page language toggle ===== */
.mt-lang-toggle {
  display: inline-block;
  margin-left: 1rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--mt-accent, #b8860b);
  border-radius: 999px;
  color: var(--mt-accent, #b8860b);
  background: rgba(184, 134, 11, 0.08);
  font-size: clamp(0.8rem, 1.3vw, 0.9rem);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.mt-lang-toggle:hover,
.mt-lang-toggle:focus-visible {
  color: #fff;
  background: var(--mt-accent, #b8860b);
  outline: none;
}

/* ===== Sticky Spacer (pushes content below header) ===== */
.metta-sticky-spacer {
  height: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.metta-main-content {
  flex: 1;
  width: 100%;
}

/* ===== Sticky Footer ===== */
.metta-sticky-footer {
  margin-top: auto;
  padding: 2rem 1rem;
  border-top: 1px solid var(--mt-border);
  background: var(--mt-bg-primary);
  width: 100%;
}

.metta-footer-container {
  max-width: var(--mt-maxw);
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.metta-footer-nav a {
  color: var(--mt-text-secondary);
  text-decoration: none;
  font-size: clamp(0.8rem, 1.5vw, 0.9rem);
  transition: color 0.2s ease;
}

.metta-footer-nav a:hover {
  color: var(--mt-accent);
}

.metta-copy-han {
  color: var(--mt-text-secondary);
  font-size: clamp(0.75rem, 1.2vw, 0.8rem);
  letter-spacing: 0.03em;
}

.metta-lang-current {
  color: var(--mt-text-secondary);
  font-size: clamp(0.75rem, 1.2vw, 0.8rem);
}

/* ===== Mobile First (max-width: 768px) ===== */
@media (max-width: 768px) {
  .metta-nav ul {
    display: none;
  }

  .metta-nav.metta-nav-open ul {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
  }

  .metta-menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
  }

  .metta-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--mt-text-primary);
    transition: all 0.2s ease;
  }

  .metta-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--mt-bg-header);
    border: 1px solid var(--mt-border);
    border-radius: 8px;
    margin-top: 0.5rem;
    box-shadow: var(--mt-shadow);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
  }

  .metta-nav.metta-nav-open {
    max-height: 500px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .metta-hero-actions {
    margin-top: 1rem;
  }
}

/* ===== iPad (769px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
  .metta-header-container {
    padding: 0.8rem 1.5rem;
  }
}

/* ===== Desktop (1024px+) ===== */
@media (min-width: 1024px) {
  .metta-header-container {
    padding: 1rem 2rem;
  }
}

/* ===== Safari/Chrome/iOS optimizations ===== */
@supports (-webkit-appearance: none) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .metta-sticky-header {
    -webkit-backdrop-filter: blur(12px);
  }
}

.metta-sticky-header,
.metta-sticky-footer {
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

/* ===== Accessibility ===== */
*:focus-visible {
  outline: 2px solid var(--mt-accent);
  outline-offset: 2px;
}
