/* ============================================================
   jarrenchang.com — all styling for the whole site.

   If you want to change how anything LOOKS, it's in this file.
   The colours are all at the top, in the two blocks below.
   ============================================================ */

/* ---------- light mode (the default) ---------- */
/* Colours are the official University of Washington palette.
   Husky Purple #32006E · Spirit Purple #4B2E83 · Spirit Gold #FFC700
   Heritage Gold #85754D · White #FFFFFF                                */
:root {
  --paper:        #FFFFFF;
  --card:         #FAF8FD;
  --ink:          #1C1626;
  --ink-soft:     #57506B;
  --accent:       #32006E;  /* Husky Purple — passes contrast as text */
  --accent-fill:  #4B2E83;  /* Spirit Purple — for blocks with white text on top */
  --highlight:    #FFC700;  /* Spirit Gold — FILL ONLY, never small text */
  --on-highlight: #1C1626;
  --gold-text:    #85754D;  /* Heritage Gold — the gold that is readable as text */
  --rule:         #E5E0EE;
  --code-bg:      #F4F1F9;
  --grain:        .18;
  --wash-a:       rgba(255, 199, 0, .16);
  --wash-b:       rgba(75, 46, 131, .08);
  --card-shadow:  0 1px 2px rgba(28,22,38,.04), 0 12px 28px -14px rgba(28,22,38,.20);

  --display: "Outfit", -apple-system, BlinkMacSystemFont, sans-serif;
  --body:    "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #16101F;
    --card:         #201933;
    --ink:          #F3F0F8;
    --ink-soft:     #A9A0BC;
    --accent:       #C2A6F0;  /* purple lightened — #32006E is unreadable on dark */
    --accent-fill:  #4B2E83;
    --highlight:    #FFC700;
    --on-highlight: #16101F;
    --gold-text:    #E3C572;
    --rule:         #342B47;
    --code-bg:      #241C38;
    --grain:        .14;
    --wash-a:       rgba(255, 199, 0, .08);
    --wash-b:       rgba(147, 112, 219, .10);
    --card-shadow:  0 1px 2px rgba(0,0,0,.3), 0 14px 34px -16px rgba(0,0,0,.6);
  }
}

/* The toggle button has to beat the system setting in BOTH directions,
   so the dark values are repeated here for when it's switched on manually. */
:root[data-theme="dark"] {
  --paper:        #16101F;
  --card:         #201933;
  --ink:          #F3F0F8;
  --ink-soft:     #A9A0BC;
  --accent:       #C2A6F0;
  --accent-fill:  #4B2E83;
  --highlight:    #FFC700;
  --on-highlight: #16101F;
  --gold-text:    #E3C572;
  --rule:         #342B47;
  --code-bg:      #241C38;
  --grain:        .14;
  --wash-a:       rgba(255, 199, 0, .08);
  --wash-b:       rgba(147, 112, 219, .10);
  --card-shadow:  0 1px 2px rgba(0,0,0,.3), 0 14px 34px -16px rgba(0,0,0,.6);
}

/* ---------- basics ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .35s ease, color .35s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(70ch 60ch at 8% -10%, var(--wash-a), transparent 70%),
    radial-gradient(60ch 50ch at 105% 8%, var(--wash-b), transparent 65%);
}

.wrap {
  max-width: 74ch;
  margin: 0 auto;
  padding-inline: clamp(1.5rem, 6vw, 4rem);
}

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

a { color: var(--accent); }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--card);
  color: var(--ink);
  padding: .75rem 1.15rem;
  border: 1px solid var(--rule);
  z-index: 50;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- theme toggle ---------- */

.toggle {
  position: fixed;
  top: clamp(1rem, 3vw, 1.75rem);
  right: clamp(1rem, 3vw, 1.75rem);
  z-index: 10;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: var(--card-shadow);
  transition: color .2s ease, transform .2s ease;
}
.toggle:hover { color: var(--accent); transform: rotate(-12deg) scale(1.06); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.toggle .moon { display: none; }
:root[data-theme="dark"] .toggle .sun  { display: none; }
:root[data-theme="dark"] .toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toggle .sun  { display: none; }
  :root:not([data-theme="light"]) .toggle .moon { display: block; }
}

/* ============================================================
   FRONT PAGE
   ============================================================ */

.home main { padding-top: clamp(3.5rem, 11vh, 8rem); }

.eyebrow {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.4rem;
}

h1 {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 800;
  font-size: clamp(3.6rem, 15vw, 9.5rem);
  line-height: .84;
  letter-spacing: -.035em;
  margin: 0 0 0 -.055em;
}

h1 .surname {
  display: block;
  color: var(--accent);
  font-weight: 400;   /* light against the heavy given name, instead of italic —
                         Outfit has no true italic and a faux slant looks cheap */
}

.lede {
  font-family: var(--display);
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.7rem);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 36ch;
  margin: 2.4rem 0 0;
}

/* Highlighted words. The fill covers the FULL line height on purpose: an
   underline-style swipe (transparent 62% -> gold 94%) left the text sitting on
   the page background, and in dark mode --on-highlight is the same value as
   --paper, so the words vanished completely. A full fill means the dark text is
   always on gold — about 10:1 either way — instead of depending on the theme.
   box-decoration-break keeps the padding correct when a phrase wraps a line. */
.lede em {
  font-style: normal;
  color: var(--on-highlight);
  background: var(--highlight);
  padding: .08em .32em;
  border-radius: 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* the "read the manual" call-to-action */
.cta {
  display: inline-flex;
  align-items: baseline;
  gap: .55rem;
  margin-top: 2.2rem;
  padding: .8rem 1.35rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-weight: 600;
  font-size: .96rem;
  letter-spacing: .01em;
  border-radius: 2px;
  transition: transform .18s ease, background-color .18s ease;
}
.cta:hover { background: var(--accent); transform: translateY(-2px); }
.cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cta .arrow { transition: transform .18s ease; }
.cta:hover .arrow { transform: translateX(3px); }

/* ideas notecard */
.ideas {
  position: relative;
  margin: clamp(3.5rem, 9vh, 6rem) 0 0;
  padding: clamp(1.75rem, 4vw, 2.75rem) clamp(1.5rem, 4vw, 3rem) clamp(2rem, 4vw, 3rem);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  transform: rotate(-.7deg);
  box-shadow: var(--card-shadow);
}

.ideas::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .5;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(1.9em - 1px),
    var(--rule) calc(1.9em - 1px),
    var(--rule) 1.9em
  );
}

.ideas > * { position: relative; }

.ideas h2, .elsewhere h2 {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .35rem;
}

.ideas .sub {
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 0 0 1.75rem;
  line-height: 1.4;
}

.ideas ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .95rem; }

.ideas li {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  align-items: baseline;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.ideas li::before { content: "→"; color: var(--accent); font-weight: 600; opacity: .8; }
.ideas li b { font-weight: 700; color: var(--ink); }

.ideas .last {
  margin: 1.9rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--rule);
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--ink-soft);
}

/* the other Changs */
.elsewhere { margin: clamp(3rem, 8vh, 5rem) 0 0; }
.elsewhere h2 { margin-bottom: 1.25rem; }
.elsewhere ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: .85rem 2.75rem;
}
.elsewhere a { display: inline-flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.elsewhere .who {
  font-family: var(--display);
  font-size: 1.2rem; font-weight: 600; line-height: 1.25;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  transition: color .2s ease, text-decoration-color .2s ease;
}
.elsewhere .rel { font-size: .84rem; letter-spacing: .04em; color: var(--ink-soft); margin-top: .15rem; }
.elsewhere a:hover .who, .elsewhere a:focus-visible .who { color: var(--accent); text-decoration-color: var(--accent); }
.elsewhere a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* footer */
footer { position: relative; z-index: 1; margin-top: clamp(3.5rem, 9vh, 6rem); padding-bottom: 4rem; }
footer .inner { padding-top: 2rem; border-top: 2px solid var(--ink); }
footer p { margin: 0 0 .9rem; max-width: 48ch; color: var(--ink-soft); }

footer .ask {
  font-family: var(--display);
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 600; line-height: 1.35;
  color: var(--ink); margin-bottom: 1.1rem;
}
footer .ask b { color: var(--accent); font-weight: 800; white-space: nowrap; }

footer .handoff {
  margin-top: 1.6rem;
  padding: 1rem 0 1rem 1.35rem;
  border-left: 3px solid var(--accent);
  font-family: var(--display);
  font-size: clamp(1.05rem, .98rem + .35vw, 1.22rem);
  line-height: 1.5;
  color: var(--ink);
  max-width: 46ch;
}
footer .handoff b { font-weight: 700; }

footer small {
  display: block; margin-top: 1.8rem;
  font-size: .82rem; letter-spacing: .04em;
  color: var(--ink-soft); opacity: .7;
}

/* ---------- entrance animation ---------- */

.reveal { opacity: 0; transform: translateY(14px); animation: rise .85s cubic-bezier(.22,.68,.32,1) forwards; }
.d1 { animation-delay: .05s; }
.d2 { animation-delay: .18s; }
.d3 { animation-delay: .32s; }
.d4 { animation-delay: .48s; }
.d5 { animation-delay: .62s; }

@keyframes rise { to { opacity: 1; transform: translateY(0); } }

.ideas.reveal { animation-name: rise-tilt; }
@keyframes rise-tilt {
  from { opacity: 0; transform: translateY(20px) rotate(1.4deg); }
  to   { opacity: 1; transform: translateY(0)   rotate(-.7deg); }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  .ideas.reveal { transform: rotate(-.7deg); }
  body, .toggle, .cta { transition: none; }
}

@media (max-width: 34rem) {
  .ideas, .ideas.reveal { transform: none; }
  .ideas.reveal { animation-name: rise; }
  h1 { margin-left: -.03em; }
}

/* ============================================================
   THE MANUAL  (/howto)
   ============================================================ */

.manual main { padding-top: 2rem; padding-bottom: 5rem; }

.topbar {
  position: relative;
  z-index: 1;
  padding-top: clamp(1.5rem, 4vh, 2.5rem);
}

.topbar a.back {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .2s ease, gap .2s ease;
}
.topbar a.back:hover { color: var(--accent); gap: .75rem; }
.topbar a.back:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.manual-head { margin: clamp(2rem, 6vh, 3.5rem) 0 0; }

.manual-head .kicker {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}

.manual-head h1 {
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: .95;
  letter-spacing: -.03em;
  margin: 0;
}

.manual-head .standfirst {
  font-family: var(--display);
  font-size: clamp(1.15rem, 1rem + .8vw, 1.5rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 44ch;
  margin: 1.5rem 0 0;
}

/* table of contents */
.toc {
  margin: clamp(2.5rem, 7vh, 4rem) 0 0;
  padding: 1.75rem clamp(1.25rem, 3vw, 2rem);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.toc h2 {
  font-size: .78rem; font-weight: 700; letter-spacing: .17em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 1.1rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; counter-reset: none; }
.toc a {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  gap: .5rem;
  text-decoration: none;
  color: var(--ink);
  padding: .18rem 0;
  border-radius: 2px;
}
.toc a:hover .label { color: var(--accent); text-decoration: underline; text-underline-offset: .2em; }
.toc a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.toc .num { font-family: var(--mono); font-size: .82rem; color: var(--accent); font-weight: 600; }
.toc .label { font-size: .99rem; }

/* stations */
.station {
  margin: clamp(3rem, 8vh, 4.5rem) 0 0;
  scroll-margin-top: 1.5rem;
}

.station > h2 {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .9rem;
  align-items: baseline;
  font-family: var(--display);
  font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 1.1rem;
  padding-top: 1.4rem;
  border-top: 2px solid var(--ink);
}

.station > h2 .num {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--accent);
  padding-top: .55rem;
}

.station p { margin: 0 0 1.1rem; max-width: 62ch; }
.station p:last-child { margin-bottom: 0; }

.station ol, .station ul { max-width: 62ch; padding-left: 1.35rem; margin: 0 0 1.2rem; }
.station li { margin-bottom: .6rem; }
.station li::marker { color: var(--accent); font-weight: 600; }

.station h3 {
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 1.8rem 0 .7rem;
  color: var(--ink);
}

code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--code-bg);
  padding: .12em .38em;
  border-radius: 3px;
}

pre {
  font-family: var(--mono);
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1.15rem;
  margin: 0 0 1.2rem;
  overflow-x: auto;
  font-size: .86rem;
  line-height: 1.6;
}
pre code { background: none; padding: 0; font-size: inherit; }

/* callouts */
.note, .careful {
  margin: 1.4rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--card);
  border-radius: 0 2px 2px 0;
  max-width: 62ch;
}
.note { border-left-color: var(--ink-soft); }
.note p, .careful p { margin: 0; }
.note p + p, .careful p + p { margin-top: .7rem; }

.note strong, .careful strong {
  display: block;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: .45rem;
}
.careful strong { color: var(--accent); }
.note strong { color: var(--ink-soft); }

/* copyable prompt blocks */
.prompt {
  margin: 0 0 1rem;
  padding: 1.05rem 1.25rem;
  background: var(--card);
  border: 1px dashed var(--rule);
  border-radius: 3px;
  max-width: 62ch;
}
.prompt .tag {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}
.prompt p {
  margin: 0;
  font-family: var(--mono);
  font-size: .87rem;
  line-height: 1.6;
  color: var(--ink);
}

/* good vs bad comparison */
.compare {
  display: grid;
  gap: 1rem;
  margin: 1.3rem 0;
  max-width: 62ch;
}
@media (min-width: 46rem) { .compare { grid-template-columns: 1fr 1fr; } }
.compare > div {
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--card);
}
.compare .verdict {
  display: block;
  font-size: .74rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; margin-bottom: .5rem;
}
.compare .weak .verdict { color: var(--ink-soft); }
.compare .strong .verdict { color: var(--accent); }
.compare p { margin: 0; font-family: var(--mono); font-size: .84rem; line-height: 1.55; }

/* glossary */
.glossary dl { margin: 0; max-width: 62ch; }
.glossary dt {
  font-weight: 700;
  font-family: var(--mono);
  font-size: .92rem;
  color: var(--accent);
  margin-top: 1.15rem;
}
.glossary dd { margin: .3rem 0 0; color: var(--ink-soft); }

/* manual footer */
.manual footer .inner { border-top: 2px solid var(--ink); }
