/* ============================================
   common.css — Shared base styles
   Site-wide design tokens + nav + mobile menu + search overlay
   ============================================ */

/* Design Tokens */
:root {
  --bg: #FAF7F2;
  --bg-alt: #F4EFE7;
  --bg-dark: #1C1A17;
  --fg: #1C1A17;
  --fg-soft: #3D3934;
  --accent: #C0512F;
  --accent-soft: rgba(192, 81, 47, 0.08);
  --forest: #2F5B4F;
  --forest-soft: rgba(47, 91, 79, 0.1);
  --muted: #8A817A;
  --muted-light: #B8AFA8;
  --surface: #FFFFFF;
  --border: rgba(28, 26, 23, 0.08);
  --border-strong: rgba(28, 26, 23, 0.15);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --radius: 12px;
  --radius-lg: 20px;
}

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

/* Base */
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Focus Visible (accessibility) */
*:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================
   Mobile Nav (Hamburger Menu)
   ============================================ */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--fg);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-mobile {
  display: none;
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-link { display: none; }
  .nav-mobile {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 9997;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  .nav-mobile.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-mobile a {
    padding: 16px 24px;
    font-size: 15px;
    color: var(--fg-soft);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    font-family: var(--sans);
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
  }
  .nav-mobile a:active { background: var(--bg-alt); }
  .nav-mobile a.nav-mobile-cta {
    text-align: center;
    background: var(--fg);
    color: var(--bg);
    font-weight: 600;
    margin-top: 4px;
  }
}

/* ============================================
   Search Overlay
   ============================================ */
#searchOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 23, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  padding: 80px 20px 20px;
}
#searchOverlay.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.search-panel {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(28,26,23,0.06);
}
.search-input-wrap svg {
  flex-shrink: 0;
  color: #8A817A;
}
#searchInput {
  flex: 1;
  border: none;
  outline: none;
  font-size: 17px;
  background: transparent;
  font-family: inherit;
  color: #1C1A17;
}
#searchInput::placeholder { color: #B8AFA8; }
#searchClose {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 13px;
  color: #8A817A;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.2s;
  font-family: inherit;
}
#searchClose:hover { background: #F4EFE7; color: #1C1A17; }
#searchResults {
  max-height: 60vh;
  overflow-y: auto;
}
#searchResults:empty { display: none; }
.sr-item {
  display: block;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(28,26,23,0.04);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.sr-item:hover { background: #FAF7F2; }
.sr-item:last-child { border-bottom: none; }
.sr-item-cat {
  font-size: 11px;
  font-weight: 500;
  color: #C0512F;
  margin-bottom: 3px;
  letter-spacing: 0.05em;
}
.sr-item-title {
  font-size: 15px;
  font-weight: 600;
  color: #1C1A17;
  line-height: 1.4;
}
.sr-item-desc {
  font-size: 13px;
  color: #8A817A;
  margin-top: 3px;
  line-height: 1.5;
}
.sr-empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 15px;
  color: #8A817A;
}
.sr-empty-hint {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: #B8AFA8;
}
.sr-loading {
  padding: 30px 20px;
  text-align: center;
  font-size: 14px;
  color: #8A817A;
}
mark { background: #fde68a; color: inherit; }

@media (max-width: 600px) {
  #searchOverlay { padding: 60px 12px 12px; }
  .search-panel { border-radius: 14px; }
  #searchInput { font-size: 16px; }
  .sr-item { padding: 12px 16px; }
}
