@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,300&display=swap');

:root {
  --ink: #192617;
  --ink-2: #1f3320;
  --lime: #87ff71;
  --gold: #ffce5c;
  --paper: #f2ffe9;
  --glass: rgba(135, 255, 113, 0.07);
  --glass-2: rgba(255, 206, 92, 0.09);
  --line: rgba(135, 255, 113, 0.34);
  --line-soft: rgba(242, 255, 233, 0.16);
  --r: 28px;
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Source Serif 4", Georgia, "Songti SC", "Noto Serif SC", serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--paper);
  background: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(135, 255, 113, 0.18) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.5;
}

body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
  top: -18vmax;
  right: -14vmax;
  width: 44vmax;
  height: 44vmax;
  border-radius: 46% 54% 38% 62% / 52% 41% 59% 48%;
  background: conic-gradient(from 40deg, var(--lime), var(--gold), var(--lime));
  opacity: 0.13;
  filter: blur(6px);
}

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

a { color: var(--lime); text-decoration: none; }

a:focus-visible,
button:focus-visible {
  outline: 2px dashed var(--gold);
  outline-offset: 3px;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(14px, 4vw, 34px) clamp(30px, 5vw, 60px);
}

/* ---------- top bar ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  background: rgba(25, 38, 23, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px dashed var(--line);
}

.rail {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar { display: none; }

.rail-r {
  justify-self: end;
  justify-content: flex-end;
}

.rail-in {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.rail-in::-webkit-scrollbar { display: none; }

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--paper);
  white-space: nowrap;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.pill:hover,
.pill:focus-visible {
  transform: rotate(-1.6deg) translateY(-1px);
  background: var(--lime);
  border-color: var(--lime);
  color: var(--ink);
}

.brand {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0 0.4rem;
  color: var(--lime);
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 900;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand .dot {
  width: 0.62em;
  height: 0.62em;
  background: var(--gold);
  transform: rotate(45deg);
  border-radius: 3px;
  flex: 0 0 auto;
}

.brand:hover .dot { background: var(--lime); }

.ring {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.ring:hover {
  background: var(--gold);
  color: var(--ink);
  transform: rotate(2deg);
}

/* ---------- lead / hero ---------- */
.lead {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) minmax(0, 372px);
  align-items: center;
  gap: clamp(18px, 3vw, 36px);
  min-height: 70vh;
  padding: clamp(22px, 4vw, 44px) 0 clamp(28px, 5vw, 56px);
  border-bottom: 2px dashed var(--line);
}

.side {
  align-self: start;
  padding: 16px 16px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--glass);
  backdrop-filter: blur(8px);
  margin-top: 6px;
}

.side-t {
  margin: 0 0 0.6em;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--gold);
}

main small {
  display: block;
  margin-bottom: 0.3rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  letter-spacing: 0.26em;
  color: var(--gold);
  text-transform: uppercase;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}

.toc li { counter-increment: toc; }

.toc a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.15rem 0;
  color: var(--paper);
  font-size: 1rem;
  line-height: 1.35;
  border-bottom: 1px dotted var(--line-soft);
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--lime);
  opacity: 0.8;
}

.toc a:hover { color: var(--lime); }

.hero {
  position: relative;
  text-align: center;
  overflow: hidden;
  padding: 8px 0;
}

.ghost {
  position: absolute;
  inset: auto 0 auto 0;
  top: 50%;
  transform: translateY(-52%);
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(6rem, 17vw, 12rem);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 206, 92, 0.34);
  pointer-events: none;
  user-select: none;
}

.hero h1 {
  position: relative;
  margin: 0 0 0.5em;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 900;
  font-size: clamp(2rem, 5.4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--lime);
  text-wrap: balance;
}

.lede {
  position: relative;
  margin: 0 auto 1.5em;
  max-width: 34ch;
  color: var(--paper);
  opacity: 0.88;
}

.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 1.6rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  letter-spacing: 0.1em;
  transition: transform 0.2s ease, background 0.2s ease;
}

.cta:hover {
  transform: translateY(-2px) rotate(-1.4deg);
  background: var(--lime);
}

.hero-fig {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 5;
  border-radius: var(--r);
  overflow: hidden;
  transform: rotate(-1.6deg);
  clip-path: polygon(0 5%, 93% 0, 100% 90%, 8% 100%);
  background:
    repeating-linear-gradient(45deg, rgba(135, 255, 113, 0.22) 0 8px, transparent 8px 18px),
    var(--ink-2);
  outline: 1px dashed var(--line);
  outline-offset: -10px;
}

.hero-fig::after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: -22px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--gold);
  mix-blend-mode: hard-light;
  opacity: 0.85;
  pointer-events: none;
}

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

/* ---------- content sections ---------- */
main > div:not(.lead) {
  position: relative;
  margin: clamp(26px, 4vw, 44px) 0;
  padding: clamp(20px, 3.6vw, 40px) clamp(18px, 3.6vw, 40px) clamp(20px, 3.6vw, 40px) clamp(24px, 4vw, 48px);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: linear-gradient(150deg, var(--glass), var(--glass-2));
  backdrop-filter: blur(6px);
  scroll-margin-top: 118px;
}

main > div:not(.lead)::before {
  content: "";
  position: absolute;
  left: clamp(8px, 1.4vw, 16px);
  top: clamp(20px, 3.4vw, 38px);
  bottom: clamp(20px, 3.4vw, 38px);
  width: 6px;
  border-radius: 999px;
  background: repeating-linear-gradient(to bottom, var(--gold) 0 10px, transparent 10px 18px);
}

main > div:not(.lead)::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 14px;
  width: 26px;
  height: 26px;
  background: var(--lime);
  opacity: 0.4;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

main > div:not(.lead) h2 {
  margin: 0.05em 0 0.7em;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 900;
  font-size: clamp(1.55rem, 3.4vw, 2.4rem);
  line-height: 1.16;
  letter-spacing: -0.01em;
  color: var(--lime);
}

main > div:not(.lead) h3 {
  margin: 1.4em 0 0.5em;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: 1.28rem;
  color: var(--gold);
}

main > div:not(.lead) p { margin: 0.85em 0; }

main > div:not(.lead) ul,
main > div:not(.lead) ol {
  margin: 0.9em 0;
  padding-left: 1.35em;
}

main > div:not(.lead) li { margin: 0.35em 0; }

main > div:not(.lead) li::marker { color: var(--gold); }

main > div:not(.lead) a {
  display: inline-block;
  padding: 0.25em 0;
  border-bottom: 1px dotted var(--gold);
  color: var(--gold);
}

main > div:not(.lead) a:hover { color: var(--lime); border-color: var(--lime); }

main > div:not(.lead) blockquote {
  margin: 1.2em 0;
  padding: 0.4em 0 0.4em 1.1em;
  border-left: 4px solid var(--gold);
  font-style: italic;
  opacity: 0.92;
}

main > div:not(.lead) figure {
  margin: 1.2em 0;
  border-radius: 20px;
  overflow: hidden;
  transform: rotate(0.6deg);
}

main > div:not(.lead) figcaption {
  padding: 0.5rem 0.2rem 0;
  font-size: 1rem;
  opacity: 0.72;
}

main > div:not(.lead) code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.95em;
  background: rgba(135, 255, 113, 0.14);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

main > div:not(.lead) table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.1em 0;
  font-size: 1rem;
}

main > div:not(.lead) th,
main > div:not(.lead) td {
  padding: 0.55em 0.6em;
  border-bottom: 1px dotted var(--line-soft);
  text-align: left;
  vertical-align: top;
}

main > div:not(.lead) th { color: var(--gold); font-weight: 600; }

/* ---------- footer ---------- */
.foot {
  margin-top: clamp(30px, 5vw, 56px);
  padding: clamp(22px, 3.4vw, 34px) 0 8px;
  border-top: 2px dashed var(--line);
}

.fnav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 34px);
}

.fnav dl { margin: 0; }

.fnav dt {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  letter-spacing: 0.24em;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.fnav dd { margin: 0; }

.fnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.15rem 0;
  font-size: 1rem;
  color: var(--paper);
  border-bottom: 1px dotted transparent;
}

.fnav a:hover { color: var(--lime); border-color: var(--lime); }

.copy {
  margin: clamp(18px, 3vw, 26px) 0 0;
  padding-top: 12px;
  border-top: 1px dotted var(--line-soft);
  text-align: center;
  font-size: 1rem;
  letter-spacing: 0.06em;
  opacity: 0.72;
}

/* ---------- reveal + top button ---------- */
.rv {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.rv.in {
  opacity: 1;
  transform: none;
}

.totop {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 40;
  display: none;
  align-items: center;
  min-height: 44px;
  padding: 0 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(25, 38, 23, 0.92);
  backdrop-filter: blur(8px);
  color: var(--lime);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  cursor: pointer;
}

.totop.on { display: inline-flex; }

.totop:hover { background: var(--lime); color: var(--ink); }

/* ---------- breakpoints ---------- */
@media (max-width: 980px) {
  .lead {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 22px;
  }

  .hero { order: 1; }

  .hero-fig {
    order: 2;
    aspect-ratio: 16 / 11;
    transform: rotate(-1deg);
  }

  .side {
    order: 3;
    margin-top: 0;
    align-self: stretch;
  }

  .toc ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
  }
}

@media (max-width: 780px) {
  body { font-size: 16px; }

  .bar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand call"
      "navl navl"
      "navr navr";
    row-gap: 8px;
    padding: 8px 0 10px;
  }

  .brand {
    grid-area: brand;
    justify-self: start;
  }

  .rail-l {
    grid-area: navl;
  }

  .rail-r {
    grid-area: navr;
    justify-self: stretch;
    justify-content: space-between;
  }

  .hero { text-align: left; }

  .lede { margin-left: 0; }

  .ghost { opacity: 0.9; }

  main > div:not(.lead) {
    padding: 20px 16px 22px 24px;
    scroll-margin-top: 150px;
  }

  .fnav { grid-template-columns: minmax(0, 1fr); gap: 6px; }

  .fnav dt { margin-bottom: 0.1rem; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .rv {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .pill:hover,
  .cta:hover,
  .ring:hover { transform: none; }
}

button[aria-expanded]{min-width:44px;min-height:44px}
