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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 28px);
}

body,
h1, h2, h3, h4, h5, h6,
p, ul, ol, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol { padding: 0; list-style: none; }

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

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

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

:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(14, 21, 18, .42);
}

/* ========== 2. Tokens ========== */
:root {
  --red: #E63946;
  --red-deep: #B32430;
  --green: #1D3B2A;
  --green-mid: #2F5D3F;
  --lime: #F4FF5E;
  --ink: #0E1512;
  --cream: #F7F4EC;
  --cream-deep: #EDE8DB;
  --line: #D9D4C7;
  --muted: #6E756B;
  --white: #FFFFFF;
  --teal: #7FD1C1;

  --font-sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --fs-12: 12px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-20: 20px;
  --fs-28: 28px;
  --fs-40: 40px;
  --fs-64: 64px;
  --fs-96: 96px;
  --fs-160: 160px;

  --header-h: 76px;
  --wrap: 1320px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow-1: 0 2px 6px rgba(14, 21, 18, .06);
  --shadow-2: 0 18px 42px rgba(14, 21, 18, .18);
  --pill: 999px;
}

@media (max-width: 640px) {
  :root { --header-h: 64px; }
}

/* ========== 3. Base typography ========== */
body {
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  font-weight: 400;
  line-height: 1.75;
  color: var(--green);
  background: var(--cream);
  padding-top: var(--header-h);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--green);
}

h1 { font-size: clamp(38px, 5.4vw, 76px); }
h2 { font-size: clamp(26px, 3.2vw, 40px); }
h3 { font-size: var(--fs-20); font-weight: 700; }
h4 { font-size: var(--fs-16); font-weight: 700; }

p { max-width: 68ch; }

#main-content:focus { outline: none; }

.mono {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  letter-spacing: .16em;
  color: var(--muted);
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--red);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ========== 4. Skip link ========== */
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 400;
  padding: 10px 20px;
  border-radius: var(--pill);
  background: var(--lime);
  color: var(--ink);
  font-size: var(--fs-14);
  font-weight: 700;
  transform: translateY(-180%);
  transition: transform .18s var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ========== 5. Header ========== */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .18s var(--ease), background .18s var(--ease);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-1);
  background: var(--white);
}

.header-inner {
  width: 100%;
  max-width: var(--wrap);
  height: var(--header-h);
  margin-inline: auto;
  padding-inline: clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 24px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
}

.brand-mark {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -.02em;
  color: var(--green);
  white-space: nowrap;
}

.brand-mark::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  background: var(--red);
  vertical-align: 2px;
}

.brand-sub {
  font-size: 10px;
  line-height: 1;
  letter-spacing: .32em;
  color: var(--muted);
  white-space: nowrap;
}

.nav-shell {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline: auto;
  padding: 5px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--pill);
  box-shadow: var(--shadow-1);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border-radius: var(--pill);
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1;
  color: var(--green);
  white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease);
}

.nav-link:hover {
  background: var(--cream-deep);
}

.nav-link[aria-current="page"] {
  background: var(--red);
  color: var(--white);
  font-weight: 700;
}

.nav-link[aria-current="page"]:hover {
  background: var(--red-deep);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--pill);
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}

.tool-pill--switch {
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--green);
}

.tool-pill--switch:hover {
  border-color: var(--green-mid);
  background: var(--cream-deep);
}

.tool-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lime);
  border: 1px solid var(--green-mid);
  flex: 0 0 auto;
}

.tool-pill--cta {
  background: var(--green);
  color: var(--cream);
  font-weight: 700;
}

.tool-pill--cta:hover {
  background: var(--red);
  color: var(--white);
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: var(--white);
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--green);
}

.nav-toggle-bars {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 16px;
}

.nav-toggle-bars span {
  display: block;
  height: 1.5px;
  background: currentColor;
  transition: transform .18s var(--ease), opacity .18s var(--ease);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:nth-child(1) {
  transform: translateY(4.5px) rotate(45deg);
}

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

.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:nth-child(3) {
  transform: translateY(-4.5px) rotate(-45deg);
}

.header-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* ---- header: tablet ---- */
@media (max-width: 1240px) {
  .nav-link {
    padding: 8px 12px;
    font-size: 13px;
  }
  .tool-pill {
    height: 36px;
    padding: 0 13px;
  }
  .nav-toggle {
    height: 36px;
  }
}

/* ---- header: mobile drawer ---- */
@media (max-width: 1040px) {
  .brand-sub { display: none; }

  .nav-toggle { display: inline-flex; }

  .nav-shell {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    left: clamp(12px, 3vw, 24px);
    right: clamp(12px, 3vw, 24px);
    z-index: 120;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    padding: 12px;
    border-radius: 20px;
    box-shadow: var(--shadow-2);
    max-height: calc(100vh - var(--header-h) - 34px);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity .18s var(--ease), transform .24s var(--ease), visibility .18s linear;
  }

  .nav-shell[data-open] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-link {
    justify-content: flex-start;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: var(--fs-16);
  }

  .nav-shell[data-open] .nav-link[aria-current="page"] {
    background: var(--red);
    color: var(--white);
  }
}

@media (max-width: 640px) {
  .tool-pill--switch {
    width: 36px;
    padding: 0;
  }
  .tool-text { display: none; }
  .tool-pill--cta {
    padding: 0 14px;
    font-size: 13px;
  }
  .nav-toggle-text { display: none; }
  .nav-toggle { padding: 0 12px; }
  .brand-mark { font-size: 18px; }
}

/* ========== 6. Footer ========== */
.site-footer {
  position: relative;
  background: var(--green);
  color: var(--cream);
  overflow: hidden;
}

.turf-strip {
  height: 12px;
  background: repeating-linear-gradient(
    90deg,
    var(--green-mid) 0 28px,
    #22452F 28px 56px
  );
  border-bottom: 1px solid rgba(244, 255, 94, .14);
}

.footer-inner {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding: clamp(44px, 6vw, 76px) clamp(20px, 4vw, 56px) 26px;
}

.footer-top {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.35fr .85fr;
  gap: clamp(24px, 3vw, 48px);
}

.footer-block { min-width: 0; }

.footer-mark {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--cream);
  max-width: none;
}

.footer-slogan {
  margin-top: 10px;
  font-size: var(--fs-14);
  letter-spacing: .24em;
  color: var(--lime);
  max-width: none;
}

.footer-versions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.version-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  max-width: 232px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(247, 244, 236, .13);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: rgba(247, 244, 236, .68);
}

.version-row b {
  font-weight: 500;
  color: var(--cream);
}

.footer-title {
  margin-bottom: 16px;
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--lime);
}

.footer-links {
  display: flex;
  flex-direction: column;
}

.footer-links a {
  display: block;
  padding: 8px 0;
  font-size: var(--fs-14);
  color: rgba(247, 244, 236, .78);
  border-bottom: 1px solid rgba(247, 244, 236, .08);
  transition: color .18s var(--ease), border-color .18s var(--ease);
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--lime);
  border-bottom-color: rgba(244, 255, 94, .45);
}

.footer-links--meta a {
  font-size: 13px;
}

.footer-contact-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-contact-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: var(--fs-14);
}

.contact-key {
  flex: 0 0 auto;
  min-width: 40px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  letter-spacing: .1em;
  color: var(--teal);
}

.contact-val {
  color: rgba(247, 244, 236, .88);
  word-break: break-word;
}

.footer-note {
  margin-top: 16px;
  padding-left: 12px;
  border-left: 3px solid var(--lime);
  font-size: var(--fs-12);
  line-height: 1.7;
  color: rgba(247, 244, 236, .62);
  max-width: 34ch;
}

.footer-bottom {
  margin-top: clamp(32px, 4vw, 52px);
  padding-top: 18px;
  border-top: 1px solid rgba(247, 244, 236, .14);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: rgba(247, 244, 236, .55);
}

.footer-copy,
.footer-icp {
  max-width: none;
  letter-spacing: .04em;
}

@media (max-width: 1024px) {
  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 36px;
  }
}

@media (max-width: 620px) {
  .footer-top { grid-template-columns: 1fr; gap: 32px; }
  .footer-mark { font-size: 22px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}

/* ========== 7. Layout helpers ========== */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 56px);
}

.grid {
  display: grid;
  gap: clamp(16px, 2.4vw, 28px);
}

.grid--12 {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }

@media (max-width: 900px) {
  .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 12; }
}

/* ========== 8. Section index numerals ========== */
.section-num {
  display: block;
  font-family: var(--font-mono);
  font-weight: 200;
  font-size: clamp(64px, 9vw, 160px);
  line-height: .82;
  letter-spacing: -.05em;
  color: rgba(14, 21, 18, .12);
  user-select: none;
}

.section-num--inverse {
  color: rgba(247, 244, 236, .16);
}

/* ========== 9. Buttons & chips ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: var(--pill);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.1;
  transition: background .18s var(--ease), color .18s var(--ease),
              border-color .18s var(--ease), transform .18s var(--ease);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--red {
  background: var(--red);
  color: var(--white);
}
.btn--red:hover { background: var(--red-deep); }

.btn--green {
  background: var(--green);
  color: var(--cream);
}
.btn--green:hover { background: var(--green-mid); }

.btn--lime {
  background: var(--lime);
  color: var(--ink);
}
.btn--lime:hover { background: #E7F23F; }

.btn--ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--green);
}
.btn--ghost:hover {
  border-color: var(--green-mid);
  background: var(--white);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: var(--white);
  font-size: var(--fs-12);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: .08em;
  color: var(--muted);
}

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

.chip--lime {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--ink);
}

.chip--green {
  background: var(--green);
  border-color: var(--green);
  color: var(--cream);
}

/* ========== 10. Breadcrumb ========== */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  letter-spacing: .08em;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--muted);
  transition: color .18s var(--ease);
}

.breadcrumb a:hover { color: var(--red); }

.breadcrumb li + li::before {
  content: "/";
  margin-right: 8px;
  color: var(--line);
}

/* ========== 11. Media containers ========== */
.media {
  position: relative;
  overflow: hidden;
  background: var(--green-mid);
  border: 1px solid var(--line);
}

.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s var(--ease);
}

.media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(29, 59, 42, .12), rgba(14, 21, 18, .32));
  pointer-events: none;
}

.media--wide { aspect-ratio: 16 / 9; }
.media--pano { aspect-ratio: 21 / 9; }
.media--portrait { aspect-ratio: 3 / 4; }
.media--square { aspect-ratio: 1 / 1; }

.media:hover img { transform: scale(1.03); }

/* ========== 12. Slant cuts ========== */
.slant {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 26px), 0 100%);
}

.slant--rev {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - 26px));
}

/* ========== 13. Anchor legend ========== */
.anchor-legend {
  position: fixed;
  right: clamp(10px, 2vw, 26px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.anchor-legend a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  letter-spacing: .06em;
  color: var(--muted);
  transition: color .18s var(--ease);
}

.anchor-legend a::after {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: .45;
  transition: width .18s var(--ease), opacity .18s var(--ease);
}

.anchor-legend a:hover {
  color: var(--green);
}

.anchor-legend a.is-current,
.anchor-legend a[aria-current="true"] {
  color: var(--red);
}

.anchor-legend a.is-current::after,
.anchor-legend a[aria-current="true"]::after {
  width: 30px;
  opacity: 1;
}

@media (max-width: 1100px) {
  .anchor-legend { display: none; }
}

/* ========== 14. Reveal ========== */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .32s var(--ease), transform .32s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ========== 15. Motion preferences ========== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .media:hover img { transform: none; }

  .btn:hover,
  .btn:active { transform: none; }
}
