/* ========== 1. Reset ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  margin: 0;
  min-height: 100vh;
}

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

ul,
ol {
  list-style: none;
}

a {
  text-decoration: none;
  color: inherit;
}

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

input,
textarea,
select {
  font: inherit;
}

/* ========== 2. Design Tokens ========== */
:root {
  --paper: #F4EFE6;
  --ink: #1C2530;
  --ink-soft: #3E4652;
  --blue-deep: #16324F;
  --blue-bright: #2C5FA8;
  --gold: #B08C2D;
  --gold-light: #DBBF6B;
  --red: #A62C2C;
  --white: #FFFFFF;
  --gray-muted: #7A7F87;

  --font-heading: "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-body: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Courier New", monospace;

  --font-display: clamp(2.5rem, 7vw, 5rem);
  --font-h1: clamp(2rem, 5vw, 3.5rem);
  --font-h2: clamp(1.5rem, 4vw, 2.5rem);
  --font-h3: 1.25rem;
  --font-caption: 0.875rem;
  --font-label: 0.7rem;

  --container-max: 1200px;
  --container-pad: clamp(1rem, 4vw, 2rem);
  --transition: 0.25s ease;
  --radius: 4px;
}

/* ========== 3. Base Typography & Layout ========== */
body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

h1 { font-size: var(--font-h1); }
h2 { font-size: var(--font-h2); }
h3 { font-size: var(--font-h3); }
p { overflow-wrap: break-word; }

::selection {
  background: var(--gold);
  color: var(--ink);
}

.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.section {
  padding: clamp(2rem, 6vw, 4rem) 0;
}

.section__index {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--font-label);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.375rem;
}

.section__heading {
  font-size: var(--font-h2);
  margin-bottom: 0.5rem;
}

.section__desc {
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 60ch;
}

.content-grid {
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: start;
}

/* ========== 4. Accessibility ========== */
:focus-visible {
  outline: 3px solid var(--blue-bright);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 2000;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: top 0.2s ease;
}

.skip-link:focus-visible {
  top: 0;
  outline: 3px solid var(--gold-light);
  outline-offset: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .scroll-progress {
    display: none;
  }
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ========== 5. Scroll Progress ========== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1500;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  pointer-events: none;
}

/* ========== 6. Header ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--paper);
  box-shadow: 0 2px 12px rgba(28, 37, 48, 0.06);
}

/* Announcement bar */
.announcement-bar {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 2px solid var(--gold);
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.announcement-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.375rem;
  padding-block: 0.3125rem;
}

.announcement-bar__text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--gold-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.announcement-bar__badge {
  display: inline-block;
  background: var(--red);
  color: var(--white);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.06rem 0.45rem;
  margin-right: 0.5rem;
  border-radius: 2px;
  vertical-align: 0.06rem;
}

.announcement-bar__utility {
  display: flex;
  gap: 0.125rem;
  flex-shrink: 0;
}

.announcement-bar__utility a {
  display: block;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.625rem;
  border-left: 1px solid rgba(244, 239, 230, 0.2);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.announcement-bar__utility a:hover,
.announcement-bar__utility a:focus-visible {
  color: var(--ink);
  background: var(--gold-light);
}

/* Masthead */
.masthead {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0px,
    transparent 7px,
    rgba(176, 140, 45, 0.055) 7px,
    rgba(176, 140, 45, 0.055) 8px
  );
  border-bottom: 1px solid var(--gold);
  padding: 1.5rem 0;
  transition: padding 0.3s ease;
}

.masthead__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  z-index: 1100;
}

.nav-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
  transform: translateY(0.32rem) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
  transform: translateY(-0.32rem) rotate(-45deg);
}

.masthead__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  text-decoration: none;
  padding: 0 0.5rem;
}

.masthead__brand-cn {
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 5vw, 3.25rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
  color: var(--ink);
}

.masthead__brand-en {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 0.15rem;
  padding-left: 0.38em;
}

.masthead__brand::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--gold);
  margin: 0.4rem auto 0;
}

.masthead__meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--gray-muted);
  white-space: nowrap;
}

.masthead__meta-item {
  text-transform: uppercase;
}

.masthead__meta-item--hide-mobile {
  display: inline;
}

/* Primary nav */
.primary-nav {
  background: var(--blue-deep);
  border-bottom: 2px solid var(--gold);
  position: relative;
}

.primary-nav__inner {
  padding-block: 0;
}

.primary-nav__list {
  display: flex;
  justify-content: center;
  align-items: stretch;
  margin: 0;
  padding: 0;
}

.primary-nav__list a {
  display: block;
  padding: 0.875rem 1.375rem;
  color: var(--paper);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.primary-nav__list a:hover,
.primary-nav__list a:focus-visible {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
  background: rgba(219, 191, 107, 0.08);
}

.primary-nav__list a[aria-current="page"] {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
  background: rgba(176, 140, 45, 0.12);
}

/* Header scrolled state */
.site-header.is-scrolled .announcement-bar {
  max-height: 0;
  border-bottom-color: transparent;
}

.site-header.is-scrolled .masthead {
  padding: 0.625rem 0;
}

.site-header.is-scrolled .masthead__brand-cn {
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.site-header.is-scrolled .masthead__brand-en {
  display: none;
}

.site-header.is-scrolled .masthead__brand::after {
  display: none;
}

.site-header.is-scrolled .masthead__meta {
  font-size: 0.6rem;
}

/* ========== 7. Footer ========== */
.site-footer {
  background: var(--blue-deep);
  color: var(--paper);
  border-top: 4px solid var(--gold);
  margin-top: clamp(2rem, 6vw, 4rem);
  position: relative;
}

.site-footer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: clamp(6rem, 12vw, 12rem);
  height: clamp(2.5rem, 6vw, 4rem);
  background: linear-gradient(135deg, transparent 49%, rgba(219, 191, 107, 0.35) 50%, rgba(219, 191, 107, 0.35) 100%);
  pointer-events: none;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.4fr;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  padding: clamp(2.5rem, 6vw, 4rem) 0 2rem;
}

.footer-brand__cn {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--white);
  margin-bottom: 0.25rem;
}

.footer-brand__en {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 1rem;
}

.footer-brand__desc {
  font-size: 0.875rem;
  line-height: 1.75;
  color: rgba(244, 239, 230, 0.75);
  margin-bottom: 1rem;
  max-width: 38ch;
}

.footer-brand__trust {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.7;
  color: rgba(219, 191, 107, 0.75);
  border-left: 2px solid var(--gold);
  padding-left: 0.75rem;
  max-width: 42ch;
}

.footer-col__title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(219, 191, 107, 0.25);
}

.footer-col__list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.footer-col__list a {
  color: rgba(244, 239, 230, 0.8);
  font-size: 0.875rem;
  transition: color 0.2s ease, padding-left 0.2s ease;
}

.footer-col__list a:hover,
.footer-col__list a:focus-visible {
  color: var(--gold-light);
  padding-left: 0.25rem;
}

.footer-col__list li {
  color: rgba(244, 239, 230, 0.8);
  font-size: 0.875rem;
  line-height: 1.5;
}

.footer-contact__note {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: rgba(219, 191, 107, 0.6);
  margin-top: 0.75rem;
  line-height: 1.6;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 0;
  border-top: 1px solid rgba(244, 239, 230, 0.12);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(244, 239, 230, 0.55);
}

.footer-bottom__icp {
  letter-spacing: 0.08em;
}

/* ========== 8. Shared Components ========== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn--primary {
  background: var(--ink);
  color: var(--paper);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

.btn--ghost {
  border-color: var(--gold);
  color: var(--ink);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  background: var(--gold-light);
  border-color: var(--gold-light);
}

/* Cards */
.card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(28, 37, 48, 0.06);
}

.card::after {
  content: attr(data-index);
  position: absolute;
  top: -0.625rem;
  right: -0.5rem;
  background: var(--red);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.125rem 0.5rem;
  border-radius: 2px;
}

/* Tags */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.625rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
}

.tag--gold {
  background: var(--gold);
  color: var(--ink);
}

.tag--red {
  background: var(--red);
  color: var(--white);
}

/* Mono index */
.meta-index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gray-muted);
  padding: 1rem 0;
}

.breadcrumb a {
  color: var(--blue-bright);
}

.breadcrumb a:hover,
.breadcrumb a:focus-visible {
  color: var(--gold);
}

.breadcrumb__sep {
  color: var(--gold);
}

/* Page hero */
.page-hero {
  padding: clamp(2rem, 6vw, 4rem) 0;
  border-bottom: 1px solid var(--gold);
  position: relative;
  background: linear-gradient(135deg, rgba(176, 140, 45, 0.08) 0%, transparent 55%, rgba(22, 50, 79, 0.04) 100%);
}

.page-title {
  font-size: var(--font-h1);
  margin-bottom: 0.75rem;
}

.page-desc {
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 60ch;
}

/* Media frame */
.media-frame {
  position: relative;
  background: var(--blue-deep);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.media-frame--portrait {
  aspect-ratio: 4 / 5;
}

.media-frame--wide {
  aspect-ratio: 21 / 9;
}

.media-frame--diagonal {
  border-radius: var(--radius) 0 var(--radius) 0;
}

.media-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-frame figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.75rem;
}

/* Tabs */
.tabs {
  margin-bottom: 1.5rem;
}

.tabs__list {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gold);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

[data-tab-button] {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.625rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

[data-tab-button]:hover,
[data-tab-button]:focus-visible {
  color: var(--blue-bright);
  background: rgba(44, 95, 168, 0.06);
}

[data-tab-button][aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--red);
  background: rgba(166, 44, 44, 0.04);
}

[data-tab-panel] {
  padding: 1.5rem 0;
  outline: none;
}

[data-tab-panel][hidden] {
  display: none;
}

/* Reveal on scroll */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== 9. Responsive ========== */
@media (max-width: 1024px) {
  .primary-nav__list a {
    padding: 0.875rem 1rem;
    font-size: 0.825rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 768px) {
  .announcement-bar__utility {
    display: none;
  }

  .announcement-bar__text {
    white-space: normal;
    line-height: 1.5;
  }

  .masthead {
    padding: 0.875rem 0;
  }

  .masthead__inner {
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
  }

  .nav-toggle {
    display: flex;
  }

  .masthead__meta {
    gap: 0.375rem;
    font-size: 0.6rem;
  }

  .masthead__meta-item--hide-mobile {
    display: none;
  }

  .primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--blue-deep);
    border-top: 2px solid var(--gold);
    border-bottom-width: 0;
  }

  .primary-nav[data-open] {
    display: block;
    box-shadow: 0 12px 24px rgba(28, 37, 48, 0.2);
  }

  .primary-nav__list {
    flex-direction: column;
    padding: 0.4rem 0 0.7rem;
  }

  .primary-nav__list a {
    border-bottom: none;
    border-left: 3px solid transparent;
    padding: 0.75rem 1.25rem;
    color: var(--paper);
  }

  .primary-nav__list a:hover,
  .primary-nav__list a:focus-visible {
    border-bottom-color: transparent;
    border-left-color: var(--gold-light);
  }

  .primary-nav__list a[aria-current="page"] {
    border-left-color: var(--gold);
    background: rgba(176, 140, 45, 0.12);
    border-bottom: none;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .masthead__brand-cn {
    font-size: 1.375rem;
  }

  .masthead__brand-en {
    font-size: 0.55rem;
    letter-spacing: 0.25em;
  }

  .masthead__meta {
    font-size: 0.55rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding-top: 2rem;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }

  .footer-contact {
    grid-column: 1 / -1;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
  }
}
