/* ============================================================
   common.css — Shared styles for 灵秀峨眉·艺创潮玩 IP Showcase
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&display=swap');

/* ----------------------------------------------------------
   1. CSS Variables
   ---------------------------------------------------------- */
:root {
  /* DPXX × HP brand colors — kept in sync with event.json theme */
  --primary: #1A1A1A;
  --primaryLight: #024AD8;
  --primaryLighter: #296EF9;
  --primaryBg: #F7F7F7;

  /* Accent / prize colors */
  --gold: #D4A843;
  --silver: #8C9BAE;
  --bronze: #B87333;
  --merit: #6B7280;

  /* Text */
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;

  /* Surfaces */
  --white: #FFFFFF;
  --bg-alt: #F9FAFB;
  --bg-dark: #1F2937;

  /* Spacing scale (4px base) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Shared DPXX type and geometry scale */
  --text-h1: clamp(1.75rem, 5vw, 3rem);
  --text-h2: clamp(1.75rem, 4vw, 2.5rem);
  --text-h3: clamp(1.125rem, 2vw, 1.375rem);
  --text-body: clamp(1rem, 1.2vw, 1.0625rem);
  --text-body-sm: clamp(0.875rem, 1vw, 0.9375rem);
  --text-label: 0.75rem;
  --text-caption: clamp(0.75rem, 1vw, 0.8125rem);
  --text-button: clamp(0.9375rem, 1vw, 1.0625rem);
  --text-micro: 0.6875rem;
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-xl: 16px;
  --radius-card: 16px;
  --radius-control: 4px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.15);

  /* Fonts */
  --font-display: 'Noto Serif SC', 'Songti SC', serif;
  --font-body: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;

  /* Transitions */
  --ease-out: cubic-bezier(.25, .46, .45, .94);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --duration: 0.3s;

  /* Layout */
  --nav-height: 78px;
}

/* ----------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--white);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration) var(--ease-out);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol { list-style: none; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primaryLighter);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

/* ----------------------------------------------------------
   3. Scroll Progress Bar
   ---------------------------------------------------------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--primaryLight), var(--primaryLighter));
  z-index: 10000;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ----------------------------------------------------------
   4. Navigation
   ---------------------------------------------------------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 9999;
  height: var(--nav-height);
  padding: 0 var(--sp-8);
  background: var(--primary);
  box-shadow: 0 4px 18px rgba(6,31,61,.18);
  transition: background var(--duration) var(--ease-out),
              box-shadow var(--duration) var(--ease-out);
}

.site-nav__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-8);
}

.site-nav__logo {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--white);
  transition: color var(--duration) var(--ease-out);
}

.site-nav__logo-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.52);
  border-radius: var(--radius-sm);
  color: #F7FAF2;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.site-nav__logo-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.3;
}

.site-nav__logo-title {
  display: block;
  overflow: hidden;
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-nav__logo-subtitle {
  display: block;
  overflow: hidden;
  color: #DDEACF;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-nav__links {
  flex: 0 0 auto;
  display: flex;
  gap: var(--sp-8);
}

.site-nav__links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255,255,255,.9);
  position: relative;
  transition: color var(--duration) var(--ease-out);
}

.site-nav__links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primaryLighter);
  transition: width var(--duration) var(--ease-out);
}

.site-nav__links a:hover::after {
  width: 100%;
}

/* Scrolled state (index page adds class via JS) */
.site-nav--scrolled {
  background: #0B2D56;
  box-shadow: 0 5px 20px rgba(6,31,61,.24);
}

.site-nav--scrolled .site-nav__logo {
  color: var(--white);
}

.site-nav--scrolled .site-nav__links a {
  color: rgba(255,255,255,.9);
}

/* Hamburger Toggle */
.site-nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  color: #FFFFFF;
  z-index: 10001;
}
.site-nav__toggle span {
  width: 24px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.3s var(--ease-out);
  transform-origin: center;
}
.site-nav__toggle.is-active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.site-nav__toggle.is-active span:nth-child(2) {
  opacity: 0;
}
.site-nav__toggle.is-active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}
@media (max-width: 768px) {
  :root { --nav-height: 84px; }
  .site-nav__logo {
    max-width: calc(100% - 48px);
    gap: 10px;
  }
  .site-nav__logo-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  .site-nav__logo-title {
    font-size: 0.88rem;
  }
  .site-nav__logo-subtitle {
    font-size: 0.64rem;
  }
  .site-nav__toggle { display: flex; }
  .site-nav__links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: #F7FBFF;
    flex-direction: column;
    padding: var(--sp-6);
    gap: var(--sp-4);
    transform: translateY(-120%);
    opacity: 0;
    transition: all 0.3s var(--ease-out);
    box-shadow: var(--shadow-md);
    pointer-events: none;
  }
  .site-nav__links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .site-nav__links a {
    color: var(--primary);
    font-size: 1.1rem;
    padding: var(--sp-3) 0;
    border-bottom: 1px solid #f0f0f0;
  }
  .site-nav--detail .site-nav__logo {
    max-width: calc(100% - 82px);
  }
  .site-nav--detail .site-nav__links {
    position: static;
    width: auto;
    background: transparent;
    flex-direction: row;
    padding: 0;
    gap: 0;
    transform: none;
    opacity: 1;
    box-shadow: none;
    pointer-events: auto;
  }
  .site-nav--detail .site-nav__links a {
    color: #FFFFFF;
    font-size: 0.78rem;
    padding: var(--sp-2);
    border: 1px solid rgba(255,255,255,.32);
    border-radius: var(--radius-sm);
  }
  .site-nav--detail .site-nav__divider,
  .site-nav--detail .site-nav__current {
    display: none;
  }
}

/* Detail page nav variant */
.site-nav--detail {
  background: var(--primary);
  box-shadow: 0 4px 18px rgba(6,31,61,.18);
}
.site-nav--detail .site-nav__logo { color: var(--white); }
.site-nav--detail .site-nav__links a { color: rgba(255,255,255,.9); }
.site-nav__divider {
  color: rgba(255,255,255,.45);
  margin: 0 var(--sp-2);
}
.site-nav__current {
  color: var(--primaryLighter);
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------
   5. Footer
   ---------------------------------------------------------- */
.site-footer {
  background: var(--bg-dark);
  color: var(--white);
  padding: var(--sp-16) var(--sp-8) var(--sp-8);
  font-size: 0.9rem;
  line-height: 1.8;
}
 
.site-footer a {
  color: var(--primaryLighter);
  transition: color var(--duration) var(--ease-out);
}
.site-footer a:hover { color: var(--primaryLighter, #a8e06c); }
.site-footer__inner {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr;
  gap: var(--sp-10);
  padding-bottom: var(--sp-10);
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: var(--sp-6);
}
.site-footer__brand { text-align: left; }
.site-footer__logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: var(--sp-3);
}
.site-footer__logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primaryLight);
  color: var(--white);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.site-footer__tagline {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.site-footer__desc {
  color: var(--text-light);
  font-size: 0.85rem;
}
.site-footer__links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.site-footer__links a {
  color: var(--text-light);
}
.site-footer__links a:hover { color: var(--primaryLighter); }
.site-footer__info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
}
.site-footer__col h4 {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.site-footer__col p {
  font-size: 0.9rem;
}
.site-footer__bottom {
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
}
@media (max-width: 768px) {
  .site-footer__inner { grid-template-columns: 1fr; gap: var(--sp-8); }
  .site-footer__info { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------
   6. Back to Top
   ---------------------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: var(--sp-8);
  right: var(--sp-8);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--primaryLight);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--duration) var(--ease-out),
              transform var(--duration) var(--ease-out),
              background var(--duration) var(--ease-out),
              visibility var(--duration);
  z-index: 999;
}

.back-to-top.back-to-top--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--primary);
  transform: translateY(-2px);
}

/* ----------------------------------------------------------
   7. Container & Section Title
   ---------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.section-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: var(--sp-12);
  position: relative;
  padding-bottom: var(--sp-4);
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 3px;
  background: linear-gradient(90deg, var(--primaryLight), var(--primaryLighter));
  border-radius: var(--radius-full);
}

.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-top: calc(-1 * var(--sp-8));
  margin-bottom: var(--sp-12);
}

/* ----------------------------------------------------------
   8. Lightbox
   ---------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s var(--ease-out), visibility .35s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox.lightbox--active {
  opacity: 1;
  visibility: visible;
}

.lightbox__img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  transform: scale(.92);
  transition: transform .35s var(--ease-spring);
}

.lightbox.is-active .lightbox__img {
  transform: scale(1);
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: absolute;
  background: rgba(255,255,255,.15);
  color: var(--white);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: background var(--duration) var(--ease-out);
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  background: rgba(255,255,255,.3);
}

.lightbox__close { top: var(--sp-6); right: var(--sp-6); }
.lightbox__prev  { left: var(--sp-6); top: 50%; transform: translateY(-50%); }
.lightbox__next  { right: var(--sp-6); top: 50%; transform: translateY(-50%); }

/* ----------------------------------------------------------
   9. Utility: transitions on interactive elements
   ---------------------------------------------------------- */
a, button, input, select, textarea,
.work-card, .filter-btn, .badge,
.lightbox__close, .lightbox__prev, .lightbox__next,
.back-to-top {
  transition: all var(--duration) var(--ease-out);
}

/* ----------------------------------------------------------
   10. Responsive helpers
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .section-title { font-size: 1.6rem; }
  .container { padding: 0 var(--sp-4); }
  .site-nav { padding: 0 var(--sp-4); }
  .site-nav__links { gap: var(--sp-4); }
  .site-nav__links a { font-size: 0.85rem; }
}

@media (max-width: 480px) {
  .section-title { font-size: 1.35rem; }
}

/* ----------------------------------------------------------
   11. Dark Mode
   ---------------------------------------------------------- */
[data-theme="dark"] {
  --text-primary: #F9FAFB;
  --text-secondary: #9CA3AF;
  --text-light: #6B7280;
  --white: #111827;
  --bg-alt: #1F2937;
  --bg-dark: #0F172A;
  --primaryBg: color-mix(in srgb, var(--primary) 25%, black);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.3);
}

[data-theme="dark"] .site-nav--scrolled,
[data-theme="dark"] .site-nav--detail {
  background: #061F3D;
}

[data-theme="dark"] .work-card__img-wrap {
  background: #374151;
}

[data-theme="dark"] .about__feature {
  background: #1F2937;
}

[data-theme="dark"] .about__stat {
  background: linear-gradient(135deg, #1F2937 0%, var(--primaryBg) 100%);
}

[data-theme="dark"] .detail-emoji-item {
  background: #374151;
}

/* ─── Site Toolbar (bottom-right: theme + lang toggle) ──── */
.site-toolbar {
  position: fixed;
  bottom: var(--sp-8);
  right: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 999;
}

.site-toolbar__btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border, #E5E7EB);
  background: var(--white);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--duration) var(--ease-out);
}

.site-toolbar__btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.site-toolbar__btn--lang {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
}

[data-theme="dark"] .site-toolbar__btn {
  background: #374151;
  border-color: #4B5563;
  color: #F9FAFB;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print */
@media print {
  .site-nav, .back-to-top, .scroll-progress, .lightbox { display: none !important; }
}
