/* ────────────────────────────────────────────
   Tokens
   ──────────────────────────────────────────── */
:root {
  --fire: #e5391f;
  --ember: #f79a3e;
  --water: #1596d1;
  --earth: #2f9e57;
  --air: #e08a12;
  --ink: #22130a;
  --paper: #fff8ea;

  --brush: "Knewave", "Figtree", system-ui, sans-serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --glyph: "Ma Shan Zheng", "Kaiti SC", "KaiTi", serif;

  --gutter: clamp(1.25rem, 4.5vw, 4rem);
  --measure: 66rem;
}

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

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

body {
  margin: 0;
  background: #7a120b;
  color: #fff;
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 4px;
  border-radius: 6px;
}

.defs { position: absolute; }

.skip {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ────────────────────────────────────────────
   Backdrop: five painted skies + the canvas
   ──────────────────────────────────────────── */
.sky,
.sky__layer,
.sky__grain,
#bend {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.sky { z-index: 0; }

.sky__layer {
  opacity: 0;
  transition: opacity 0.9s ease;
}

.sky__layer--balance {
  background:
    radial-gradient(46rem 26rem at 54% 4%, rgba(255, 238, 176, 0.9), transparent 70%),
    linear-gradient(104deg, #a8130c 0%, #d92c15 24%, #f0621d 39%, #f8ab55 47%, #fce9bd 52%, #8fdde2 57%, #2aa9d6 68%, #1380c6 82%, #0b4e93 100%);
}
.sky__layer--water {
  background:
    radial-gradient(50rem 30rem at 85% 0%, rgba(120, 232, 240, 0.35), transparent 70%),
    linear-gradient(165deg, #05203f 0%, #0a4f86 52%, #148fb4 100%);
}
.sky__layer--earth {
  background:
    radial-gradient(50rem 30rem at 85% 0%, rgba(214, 196, 110, 0.28), transparent 70%),
    linear-gradient(165deg, #142313 0%, #26502b 52%, #6f6a2c 100%);
}
.sky__layer--fire {
  background:
    radial-gradient(50rem 30rem at 85% 100%, rgba(255, 196, 92, 0.4), transparent 70%),
    linear-gradient(165deg, #2f0504 0%, #8f150b 50%, #d94716 100%);
}
.sky__layer--air {
  background:
    radial-gradient(50rem 30rem at 85% 0%, rgba(255, 255, 255, 0.55), transparent 70%),
    linear-gradient(165deg, #ef9f2a 0%, #f6c25c 52%, #f9dfa0 100%);
}

body[data-show="balance"] .sky__layer--balance,
body[data-show="water"] .sky__layer--water,
body[data-show="earth"] .sky__layer--earth,
body[data-show="fire"] .sky__layer--fire,
body[data-show="air"] .sky__layer--air { opacity: 1; }

.sky__grain {
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#bend {
  z-index: 1;
  width: 100%;
  height: 100%;
  transition: opacity 0.9s ease;
}
/* Behind reading text the particles step back. */
body:not([data-show="balance"]) #bend { opacity: 0.6; }
body[data-show="water"] #bend { opacity: 0.5; }

main {
  position: relative;
  z-index: 2;
}

/* ────────────────────────────────────────────
   Section dots (fixed, right edge)
   ──────────────────────────────────────────── */
.dots {
  position: fixed;
  right: clamp(0.9rem, 2vw, 1.75rem);
  top: 50%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1.1rem;
  transform: translateY(-50%);
  color: #fff;
  transition: color 0.6s ease;
}
body[data-active="air"] .dots { color: var(--ink); }

.dots a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}
.dots span {
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  transition: box-shadow 0.25s ease, background-color 0.25s ease, transform 0.25s ease;
}
.dots a:hover span,
.dots a:focus-visible span,
.dots a[aria-current="true"] span {
  opacity: 1;
  transform: none;
}
.dots a[aria-current="true"] i {
  background: transparent;
  box-shadow: 0 0 0 3px currentColor;
  transform: scale(1.15);
}

/* ────────────────────────────────────────────
   Hero
   ──────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: 1.5rem var(--gutter) 2rem;
}

.hero__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.mark {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.mark b { font-weight: 400; opacity: 0.85; }

.emblem {
  display: block;
  width: clamp(3.75rem, 5.6vw, 4.75rem);
  height: auto;
  aspect-ratio: 1;
  /* hangs a little outside the bar so it does not push the hero down */
  margin: -0.85rem clamp(0rem, 3vw, 2.5rem) -0.85rem 0;
  border-radius: 50%;
  object-fit: cover;
  /* the artwork has dark corners; the circle crop hides them */
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 8px 22px rgba(4, 38, 79, 0.4);
}

.hero__body {
  align-self: center;
  max-width: 46rem;
  padding-block: clamp(1.25rem, 4vh, 2.5rem);
}

.hero__role {
  margin-bottom: 0.9rem;
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  font-weight: 600;
}

.name {
  font: 400 clamp(3.4rem, min(9.4vw, 20vh), 9.25rem) / 0.86 var(--brush);
  letter-spacing: 0.005em;
  text-transform: uppercase;
  filter: url(#rough) drop-shadow(0 0.045em 0 rgba(92, 8, 2, 0.28));
}
.name__line {
  display: block;
  width: fit-content;
  padding: 0.06em 0.08em 0.1em 0;
}

.name__stroke {
  display: block;
  width: min(34rem, 82%);
  height: 1.9rem;
  margin: 0.35rem 0 1.5rem;
  overflow: visible;
}
.name__stroke path {
  fill: none;
  stroke: #fff;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 540;
  stroke-dashoffset: 0;
  vector-effect: non-scaling-stroke;
}

.hero__lede {
  max-width: 34rem;
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  font-weight: 500;
  line-height: 1.5;
  text-shadow: 0 1px 10px rgba(110, 12, 4, 0.35);
}

/* Element chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chip {
  --c: var(--water);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 8.6rem;
  padding: 0.55rem 0.95rem 0.55rem 0.6rem;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-size: 0.8125rem;
  line-height: 1.25;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(60, 6, 0, 0.26);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chip--earth { --c: var(--earth); }
.chip--fire { --c: var(--fire); }
.chip--air { --c: var(--air); }

.chip svg {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 14%, #fff);
  fill: none;
  stroke: var(--c);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: background-color 0.2s ease, stroke 0.2s ease;
}
.chip b {
  display: block;
  color: var(--c);
  font-size: 1rem;
  font-weight: 800;
}
.chip:hover,
.chip:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(60, 6, 0, 0.34);
}
.chip:hover svg,
.chip:focus-visible svg {
  background: var(--c);
  stroke: #fff;
}
.chip:focus-visible { outline-color: #fff; }

/* One load sequence: the name is painted in, then everything else settles. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  .name__line {
    clip-path: inset(-10% 100% -10% 0);
    animation: paint 0.75s cubic-bezier(0.7, 0, 0.2, 1) 0.25s forwards;
  }
  .name__line + .name__line { animation-delay: 0.5s; }

  .name__stroke path {
    stroke-dashoffset: 540;
    animation: draw 0.8s cubic-bezier(0.6, 0, 0.2, 1) 1.05s forwards;
  }

  .hero__role,
  .hero__lede,
  .chips {
    opacity: 0;
    animation: settle 0.7s ease 1.35s forwards;
  }
  .hero__role { animation-delay: 0.1s; }
  .chips { animation-delay: 1.6s; }
}

@keyframes paint { to { clip-path: inset(-10% -5% -10% 0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes settle {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ────────────────────────────────────────────
   Chapters (one per element)
   ──────────────────────────────────────────── */
.chapter {
  --fg: #fff;
  --soft: rgba(255, 255, 255, 0.78);
  --line: rgba(255, 255, 255, 0.3);
  --tint: rgba(255, 255, 255, 0.1);

  position: relative;
  min-height: 100vh;
  padding: clamp(5rem, 14vh, 9rem) var(--gutter);
  color: var(--fg);
  overflow: clip;
}
.chapter--air {
  --fg: var(--ink);
  --soft: rgba(34, 19, 10, 0.8);
  --line: rgba(34, 19, 10, 0.3);
  --tint: rgba(255, 255, 255, 0.4);
}

.chapter__inner {
  position: relative;
  max-width: var(--measure);
  margin-inline: auto;
  padding-right: clamp(0rem, 5vw, 4rem);
}

.chapter__glyph {
  position: absolute;
  top: clamp(1rem, 6vh, 4rem);
  right: clamp(1rem, 7vw, 7rem);
  font: 400 clamp(11rem, 30vw, 26rem) / 1 var(--glyph);
  opacity: 0.13;
  user-select: none;
}

.chapter__title,
.reach__title {
  font: 400 clamp(3rem, 8vw, 6.5rem) / 0.95 var(--brush);
  text-transform: uppercase;
  filter: url(#rough);
}

.chapter__lede {
  max-width: 36rem;
  margin-top: 1rem;
  color: var(--soft);
  font-size: clamp(1.125rem, 1.7vw, 1.375rem);
  font-weight: 500;
  line-height: 1.45;
}

/* Timeline entries (experience, education) */
.trail { margin-top: clamp(2.5rem, 6vh, 4.5rem); }

.entry {
  display: grid;
  grid-template-columns: minmax(12rem, 17rem) 1fr;
  gap: 1.25rem clamp(1.5rem, 5vw, 4rem);
  padding-block: 2.25rem;
  border-top: 2px solid var(--line);
}

.entry__dates {
  font-size: 1.0625rem;
  font-weight: 800;
}
.entry__org {
  margin-top: 0.5rem;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.25;
}
.entry__place { color: var(--soft); }

.entry__what h3 {
  font-size: clamp(1.5rem, 2.6vw, 2.125rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.entry__what > p {
  margin-top: 0.6rem;
  color: var(--soft);
}
.entry__what ul,
.project ul {
  display: grid;
  gap: 0.55rem;
  max-width: 44rem;
  margin-top: 1.1rem;
}
.entry__what li,
.project li {
  position: relative;
  padding-left: 1.5rem;
}
.entry__what li::before,
.project li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.62em;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50% 0 50% 50%;
  background: currentColor;
  opacity: 0.75;
  transform: rotate(-45deg);
}

/* Projects */
.forge { margin-top: clamp(2.5rem, 6vh, 4.5rem); }

.project { border-top: 2px solid var(--line); }
.project:last-child { border-bottom: 2px solid var(--line); }

.project summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem 1.5rem;
  padding: 1.4rem 0.25rem;
  cursor: pointer;
  list-style: none;
}
.project summary::-webkit-details-marker { display: none; }

.project summary::after {
  content: "";
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background:
    linear-gradient(currentColor, currentColor) center / 1rem 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2px 1rem no-repeat,
    var(--tint);
  transition: transform 0.3s ease, background-color 0.3s ease;
}
.project[open] summary::after {
  background:
    linear-gradient(currentColor, currentColor) center / 1rem 2px no-repeat,
    var(--tint);
  transform: rotate(180deg);
}

.project h3 {
  grid-column: 1;
  font-size: clamp(1.375rem, 2.8vw, 2.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.015em;
  transition: transform 0.25s ease;
}
.project summary:hover h3 { transform: translateX(6px); }

.project__stack {
  grid-column: 1;
  color: #ffd08a;
  font-size: 1rem;
  font-weight: 600;
}

.project ul {
  margin: 0;
  padding: 0 0.25rem 1.9rem;
}
@media (prefers-reduced-motion: no-preference) {
  .project[open] ul { animation: settle 0.35s ease; }
}

/* Skills */
.kit { margin-top: clamp(2.5rem, 6vh, 4.5rem); }

.kit__row {
  display: grid;
  grid-template-columns: minmax(12rem, 17rem) 1fr;
  gap: 0.9rem clamp(1.5rem, 5vw, 4rem);
  padding-block: 1.6rem;
  border-top: 2px solid var(--line);
}
.kit dt {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
}
.kit ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.kit li {
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  background: var(--tint);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-weight: 600;
}

/* Contact */
.reach {
  margin-top: clamp(5rem, 14vh, 9rem);
  padding-bottom: 2rem;
}
.reach__mail {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: clamp(1.375rem, 4.4vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.16em;
}
.reach__mail:hover { text-decoration-thickness: 0.12em; }

.reach__more {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2.25rem;
  margin-top: 1.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}
.reach__more a { text-underline-offset: 0.2em; }

/* ────────────────────────────────────────────
   Small screens
   ──────────────────────────────────────────── */
@media (max-width: 760px) {
  .dots { display: none; }

  /* Narrow screens: water above, fire below, so the text always sits on red. */
  .sky__layer--balance {
    background:
      radial-gradient(22rem 12rem at 50% 27%, rgba(255, 238, 176, 0.85), transparent 70%),
      linear-gradient(172deg, #0b4e93 0%, #1380c6 10%, #2aa9d6 18%, #8fdde2 24%, #fce9bd 28%, #f8ab55 32%, #f0621d 39%, #d92c15 58%, #a8130c 100%);
  }

  .hero { padding-bottom: 1.5rem; }
  .hero__body {
    align-self: end;
    padding-block: 2rem 2.25rem;
  }
  .emblem { margin: -0.5rem 0; }
  .name { font-size: clamp(2.9rem, 14.6vw, 5.5rem); }

  .chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .chip { min-width: 0; }

  .chapter__inner { padding-right: 0; }

  .entry,
  .kit__row { grid-template-columns: 1fr; }

  .project summary::after {
    width: 2.25rem;
    height: 2.25rem;
  }
}
