/* ============================================================
   Wire desk — hanshanley.com
   Light "paper" is the default; dark is opt-in via the toggle.
   ============================================================ */

:root {
  color-scheme: light;

  --paper:      #fdfcf9;
  --paper-2:    #f6f3ec;
  --ink:        #1a1917;
  --ink-2:      #4c4840;
  --ink-3:      #837c6e;
  --rule:       #1a1917;
  --hair:       #ded8ca;
  --hair-soft:  #ebe6da;
  --red:        #8b0000;

  --serif: "Iowan Old Style", Charter, "Bitstream Charter", "Palatino Linotype", Palatino, "Hoefler Text", Georgia, serif;
  --mono:  ui-monospace, "SF Mono", SFMono-Regular, "IBM Plex Mono", Menlo, Consolas, monospace;

  --measure: 64ch;
  --measure-wide: 82ch;
  --rail: 11rem;
  --gutter: clamp(1.5rem, 1rem + 2.4vw, 3rem);
  --shell: 62rem;

  --step-0: clamp(1.0625rem, 1.0rem + 0.28vw, 1.1563rem);
  --step-1: clamp(1.15rem, 1.08rem + 0.36vw, 1.3rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.7rem);
  --step-3: clamp(2rem, 1.35rem + 3vw, 3.6rem);
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper:      #14130f;
  --paper-2:    #1c1b16;
  --ink:        #ece7db;
  --ink-2:      #b8b1a0;
  --ink-3:      #857e6d;
  --rule:       #ece7db;
  --hair:       #35322a;
  --hair-soft:  #282620;
  --red:        #e39184;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.65;
  font-kerning: normal;
  font-variant-numeric: oldstyle-num;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--red); color: var(--paper); }

.wrap { max-width: var(--shell); margin: 0 auto; padding: 0 var(--gutter) 6rem; }

/* ================= masthead ================= */

.masthead__name {
  font-size: var(--step-3);
  line-height: 0.98;
  letter-spacing: -0.028em;
  margin: clamp(2.5rem, 5vw, 4.5rem) 0 0.9rem;
  font-weight: 600;
  font-variant-numeric: lining-nums;
  text-wrap: balance;
}
.masthead__name a { color: inherit; text-decoration: none; display: inline-block; }
.masthead__name a:hover { color: var(--red); }

.masthead__cn {
  font-family: "PingFang SC", "Hiragino Sans GB", "Songti SC", "Noto Serif CJK SC",
               "Source Han Serif SC", "Microsoft YaHei", var(--serif);
  font-size: 0.3em;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  vertical-align: 0.62em;
  margin-left: 1.5em;
  white-space: nowrap;
}
@media (max-width: 34rem) {
  .masthead__cn { display: block; margin: 0.5rem 0 0; vertical-align: baseline; font-size: 0.34em; }
}

.dateline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.35rem;
  font-family: var(--mono);
  font-size: 0.6563rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 1.15rem;
  padding: 0.7rem 0 0.75rem;
  border-top: 1px solid var(--hair);
}
.dateline > span { position: relative; }
.dateline > span + span:not(.spacer)::before {
  content: "·";
  position: absolute;
  left: -0.78rem;
  color: var(--hair);
}
.dateline .spacer { flex: 1 1 auto; }

.theme-toggle {
  font-family: var(--mono);
  font-size: 0.6563rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: none;
  border: 1px solid var(--hair);
  padding: 0.22rem 0.6rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--red); border-color: var(--red); }

/* ================= navigation ================= */

nav.site {
  border-top: 2.5px solid var(--rule);
  border-bottom: 1px solid var(--hair);
  margin-bottom: clamp(2.25rem, 4.5vw, 3.5rem);
}
nav.site ul {
  list-style: none; margin: 0; padding: 0.85rem 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.7rem;
  font-family: var(--mono);
  font-size: 0.7188rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
nav.site a {
  color: var(--ink-2); text-decoration: none;
  padding-bottom: 3px; border-bottom: 1.5px solid transparent;
  transition: color .15s, border-color .15s;
}
nav.site a:hover { color: var(--ink); border-bottom-color: var(--hair); }
nav.site a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); }
.nav__toggle { margin-left: auto; }
nav.site .ext::after {
  content: "↗"; font-size: 0.8em; margin-left: 0.28em;
  color: var(--ink-3); vertical-align: 0.15em;
}

/* ================= links ================= */

a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--red) 42%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.17em;
  transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--red); text-decoration-color: var(--red); text-decoration-thickness: 1.5px; }
a:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; text-decoration: none; }

/* ================= intro (portrait + lede) ================= */

.intro { margin-bottom: 1.75rem; }
.intro .lede { max-width: var(--measure-wide); }

/* Inline portrait is a fallback: above 82rem the dock carries the photo instead. */
.portrait {
  margin: 0 0 1.25rem 1.75rem;
  float: right;
  max-width: 10rem;
}
@media (min-width: 82rem) { .portrait { display: none; } } /* dock carries the photo */
@media (max-width: 34rem) { .portrait { float: none; margin: 0 0 1.5rem; max-width: 9rem; } }
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--hair);
  padding: 5px;
  background: var(--paper-2);
  filter: saturate(0.92);
}
.portrait figcaption {
  font-family: var(--mono);
  font-size: 0.5938rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 0.55rem;
  line-height: 1.5;
}

/* ================= section headers ================= */

.section {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-caps: small-caps;
  letter-spacing: 0.045em;
  text-transform: none;
  color: var(--ink);
  border-top: 2.5px solid var(--rule);
  padding-top: 0.55rem;
  margin: clamp(2.75rem, 5.5vw, 4rem) 0 1.6rem;
}
.section a {
  color: var(--ink-3);
  text-decoration: none;
  font-size: 0.88rem;
  font-variant-caps: normal;
  letter-spacing: 0.01em;
  font-weight: 400;
}
.section a:hover { color: var(--red); }

/* ================= prose ================= */

.prose { max-width: var(--measure); }
.lede { max-width: var(--measure-wide); }
.lede p, .prose p { margin: 0 0 1.25rem; }
.lede > p:first-child { font-size: var(--step-1); line-height: 1.5; }

.prose h2 {
  font-size: var(--step-2); line-height: 1.18; letter-spacing: -0.014em;
  font-weight: 600; margin: 2.75rem 0 0.85rem; text-wrap: balance;
}
.prose h3 { font-size: 1.08rem; margin: 2rem 0 0.5rem; font-weight: 600; }
.prose ul { padding-left: 1.15rem; margin: 0 0 1.25rem; }
.prose li { margin-bottom: 0.55rem; }
.prose li::marker { color: var(--ink-3); }
.prose code, code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--paper-2); padding: 0.1em 0.35em;
  border: 1px solid var(--hair-soft);
}

/* ================= record index ================= */

.index { border-top: 1px solid var(--hair); }

.record {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  gap: 0 var(--gutter);
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--hair-soft);
  transition: background .15s;
}
.record:hover { background: color-mix(in srgb, var(--paper-2) 55%, transparent); }

.record__rail {
  font-family: var(--mono);
  font-size: 0.6563rem;
  line-height: 1.6;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding-top: 0.45rem;
  padding-right: var(--gutter);
  border-right: 1px solid var(--hair-soft);
}
.record__year {
  display: block; color: var(--ink); font-size: 0.875rem;
  letter-spacing: 0.04em; font-variant-numeric: lining-nums;
}
.record__venue {
  display: block; margin-top: 0.35rem; text-transform: none;
  letter-spacing: 0.025em; line-height: 1.45;
}
.record__flag {
  display: inline-block; margin-top: 0.6rem; color: var(--red);
  border: 1px solid currentColor; padding: 0.14rem 0.38rem;
  font-size: 0.5625rem; letter-spacing: 0.14em; line-height: 1;
}

.record__title {
  font-size: var(--step-1); line-height: 1.3; margin: 0 0 0.4rem;
  font-weight: 600; letter-spacing: -0.011em; text-wrap: balance;
}
.record__title a { color: var(--ink); text-decoration-color: transparent; }
.record__title a:hover { color: var(--red); text-decoration-color: var(--red); }

.record__authors { color: var(--ink-2); font-size: 0.9375rem; margin: 0 0 0.45rem; line-height: 1.5; }
.record__authors b { color: var(--ink); font-weight: 600; }
.record__abstract {
  color: var(--ink-2); font-size: 0.9375rem; line-height: 1.55;
  margin: 0 0 0.85rem; max-width: 56ch;
}

.affordances {
  display: flex; flex-wrap: wrap; gap: 0.45rem 1.1rem;
  font-family: var(--mono); font-size: 0.6563rem;
  letter-spacing: 0.12em; text-transform: uppercase; align-items: center;
}
.affordances a, .affordances button {
  color: var(--ink-2); background: none; border: 0; text-decoration: none;
  border-bottom: 1px solid var(--hair); padding: 0 0 3px;
  font: inherit; cursor: pointer; transition: color .15s, border-color .15s;
}
.affordances a:hover, .affordances button:hover { color: var(--red); border-bottom-color: var(--red); }
.affordances .is-primary { color: var(--red); border-bottom-color: var(--red); }

/* ================= log ================= */

.log { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hair); }
.log li {
  display: grid; grid-template-columns: var(--rail) 1fr; gap: 0 var(--gutter);
  padding: 1.05rem 0; border-bottom: 1px solid var(--hair-soft); align-items: stretch;
}
.log time {
  font-family: var(--mono); font-size: 0.6563rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3);
  border-right: 1px solid var(--hair-soft); padding-right: var(--gutter);
  display: block;
}
.log p { margin: 0; font-size: 0.9688rem; line-height: 1.55; }
.log .kind {
  font-family: var(--mono); font-size: 0.5625rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--red); display: block; margin-top: 0.35rem;
}

/* ================= profiles ================= */

.profiles {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  font-family: var(--mono); font-size: 0.7188rem; letter-spacing: 0.045em;
  border-top: 1px solid var(--hair-soft);
}
.profiles li { padding: 0.6rem 1.5rem 0.6rem 0; border-bottom: 1px solid var(--hair-soft); }
.profiles .label {
  color: var(--ink-3); display: inline-block; min-width: 6.5rem;
  text-transform: uppercase; font-size: 0.6563rem; letter-spacing: 0.13em;
}
.profiles a { text-decoration-color: transparent; }
.profiles a:hover { text-decoration-color: var(--red); }

/* ================= sticky side widget ================= */

.dock {
  position: fixed;
  /* Sits below the masthead and nav rather than centred on the viewport, so it
     never crowds the name at the top of the page. */
  top: 12.75rem;
  right: max(0.9rem, calc((100vw - var(--shell)) / 2 - 11rem));
  /* The column is sized to fit its content at ordinary window heights, so no
     inner scrollbar appears. `auto` is only a safety net for very short windows. */
  max-height: calc(100vh - 14.5rem);
  overflow-y: auto;
  width: 10.5rem;
  z-index: 20;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  border-left: 2px solid var(--red);
  /* Right padding gives the 2px hover nudge somewhere to go. Without it the
     shifted link overflows the padding box and Chrome shows a scrollbar
     (setting overflow-y also forces overflow-x to `auto`). */
  padding: 0.15rem 0.45rem 0.15rem 0.7rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
}
.dock__head {
  display: block; color: var(--ink-3); font-size: 0.5625rem;
  letter-spacing: 0.16em; margin-bottom: 0.4rem;
}
.dock__standfirst {
  margin: 0 0 0.7rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--hair);
  /* Sentence-case serif: uppercase mono is unreadable at this column width. */
  font-family: var(--serif);
  font-size: 0.8125rem;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
}
.dock__standfirst span { display: block; }
.dock__standfirst span + span { margin-top: 0.2rem; }
.dock__standfirst span:first-child { color: var(--ink); font-weight: 600; }
.dock ul { list-style: none; margin: 0; padding: 0; }
.dock li { margin: 0 0 0.24rem; }
.dock a {
  color: var(--ink-2); text-decoration: none; display: flex; align-items: baseline;
  gap: 0.4rem; line-height: 1.3;
  transition: color .15s, transform .15s;
}
.dock a:hover { color: var(--red); transform: translateX(2px); }
.dock__ico {
  font-size: 0.72rem;
  line-height: 1;
  width: 1em;
  flex: 0 0 auto;
  filter: saturate(0.75);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.dock .dock__cv { color: var(--red); }
.dock__thumb {
  display: block; width: 100%; max-width: 7.4rem; height: auto; margin: 0 0 0.55rem;
  border: 1px solid var(--hair); padding: 4px; background: var(--paper-2);
  filter: saturate(0.9);
}
/* Below the sidebar breakpoint the dock becomes an inline block at the end of
   the page, so the portrait and links stay available on narrow screens. */
@media (max-width: 82rem) {
  /* Below the sidebar breakpoint the dock becomes an inline block at the foot
     of the page. Typography is deliberately identical to the fixed version. */
  .dock {
    position: static;
    top: auto;
    transform: none;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    background: none;
    border-left: 0;
    border-top: 2.5px solid var(--rule);
    padding: 1.1rem 0 0;
    margin-top: clamp(2.5rem, 5vw, 4rem);
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0 2rem;
    align-items: start;
  }
  .dock__thumb { margin: 0; }
  .dock__body { min-width: 0; }
  .dock__standfirst {
    border-bottom: 0;
    padding-bottom: 0;
    margin: 0 0 1rem;
  }
  .dock__standfirst span { display: inline; }
  .dock__standfirst span + span::before {
    content: " · ";
    color: var(--hair);
    margin: 0 0.15rem;
  }
  .dock__standfirst span + span { margin-top: 0; }
  .dock ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.42rem 1.5rem;
    align-content: start;
  }
  .dock li { margin: 0; }
  .dock a { white-space: nowrap; }
}
@media (max-width: 30rem) {
  .dock { grid-template-columns: 1fr; }
  .dock__thumb { max-width: 8rem; margin-bottom: 0.9rem; }
  .dock ul { columns: 1; }
}

/* ================= compact CV / résumé layout ================= */

/* PDF downloads at the head of the CV. Set as running text, not boxes:
   the weight comes from the serif size and the rule colour, not from borders. */
.downloads {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 2.15rem;
  margin: 0 0 2.4rem;
}
.download {
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 0.6rem;
}
.download__label {
  font-family: var(--serif);
  font-size: 1.16rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--red);
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.download:hover .download__label { border-bottom-color: var(--red); }
.download__label::after {
  content: " ↓";
  font-size: 0.8em;
  color: var(--ink-3);
}
.download:hover .download__label::after { color: var(--red); }
.download__meta {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
@media (max-width: 30rem) {
  .downloads { flex-direction: column; gap: 0.75rem; }
}

/* Section jump list, sitting directly above the first section heading. */
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.35rem;
  font-family: var(--mono);
  font-size: 0.6563rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0 0 0.55rem;
  margin: 0;
}
.jump a { color: var(--ink-3); text-decoration: none; }
.jump a:hover { color: var(--red); }
/* Pull the first section heading up tight under the jump list. */
.jump + .section { margin-top: 0; }

.cv .record { padding: 0.85rem 0; }
.cv .record__rail { padding-top: 0.22rem; }
.cv .record__title { font-size: 1.02rem; margin-bottom: 0.18rem; letter-spacing: -0.006em; }
.cv .record__abstract {
  max-width: none;
  margin-bottom: 0;
  font-size: 0.9063rem;
  line-height: 1.5;
}
.cv .record__authors { margin-bottom: 0.2rem; font-size: 0.9063rem; }

.cv .log li { padding: 0.6rem 0; }
.cv .log p { font-size: 0.9063rem; }

/* two-column lists for skills / service — kills the dead right-hand space */
.cols {
  columns: 2;
  column-gap: var(--gutter);
  max-width: none;
  margin: 0 0 0.5rem;
  padding-left: 1.1rem;
}
.cols li { break-inside: avoid; margin-bottom: 0.4rem; }
.cols li::marker { color: var(--ink-3); }
@media (max-width: 46rem) { .cols { columns: 1; } }

.section-anchor { scroll-margin-top: 1.5rem; }

.aside-note {
  border-left: 2px solid var(--red);
  padding: 0.35rem 0 0.35rem 1.25rem;
  margin: clamp(2.25rem, 4.5vw, 3.25rem) 0 0;
  max-width: var(--measure);
  color: var(--ink-2); font-size: 0.9688rem; line-height: 1.6;
}

/* ================= machine blocks ================= */

.machine {
  font-family: var(--mono); font-size: 0.7813rem; line-height: 1.7;
  background: var(--paper-2); border: 1px solid var(--hair);
  border-left: 2px solid var(--ink-3);
  padding: 1.15rem 1.35rem; overflow-x: auto; white-space: pre;
  margin: 0 0 1.5rem; color: var(--ink-2);
}

.kv { border-collapse: collapse; width: 100%; max-width: var(--measure); margin-bottom: 1.75rem; font-size: 0.9375rem; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 0.5rem 1rem 0.5rem 0; border-bottom: 1px solid var(--hair-soft); }
.kv th {
  font-family: var(--mono); font-size: 0.6563rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 400; width: 10.5rem;
}

/* ================= filters ================= */

.filters {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem;
  font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.13em;
  text-transform: uppercase; margin-bottom: 1.75rem;
}
.filters button {
  background: none; border: 0; border-bottom: 1.5px solid transparent;
  color: var(--ink-3); font: inherit; padding: 0 0 3px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.filters button:hover { color: var(--ink); }
.filters button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--red); }
.record[hidden] { display: none; }

/* ================= dialog ================= */

dialog {
  max-width: 46rem; width: calc(100% - 2rem);
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink-3); padding: 1.4rem;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .machine { margin: 0; }

/* ================= footer ================= */

footer.site {
  border-top: 2.5px solid var(--rule);
  margin-top: clamp(3rem, 6vw, 5rem);
  padding-top: 1.1rem;
  font-family: var(--mono); font-size: 0.6563rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.6rem 1.5rem;
}
footer.site a { color: var(--ink-2); text-decoration: none; }
footer.site a:hover { color: var(--red); }

/* ================= responsive ================= */

@media (max-width: 46rem) {
  :root { --rail: auto; }
  .intro { grid-template-columns: 1fr; }
  .portrait { max-width: 9rem; order: -1; }
  .record, .log li { grid-template-columns: 1fr; gap: 0.55rem; }
  .record__rail, .log time { border-right: 0; padding-right: 0; padding-top: 0; }
  .record__rail > * { display: inline; }
  .record__venue { margin-top: 0; }
  .record__venue::before { content: " · "; color: var(--hair); }
  .record__flag { display: inline-block; margin: 0 0 0 .5rem; }
  .profiles { grid-template-columns: 1fr; }
  .dateline { font-size: 0.6rem; letter-spacing: 0.12em; }
  nav.site ul { gap: 0.5rem 1.15rem; font-size: 0.6875rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= print ================= */

@media print {
  :root {
    --paper: #fff; --paper-2: #fff; --ink: #000; --ink-2: #222;
    --ink-3: #555; --hair: #bbb; --hair-soft: #ddd; --rule: #000;
  }
  nav.site, .filters, .theme-toggle, .dock, .affordances button, dialog { display: none !important; }
  body { font-size: 10.5pt; line-height: 1.45; }
  .wrap { max-width: none; padding: 0; }
  a { text-decoration: none; color: #000; }
  .record, .log li { break-inside: avoid; }
  .section { break-after: avoid; }
}

/* talk body: links carried in the markdown body of each talk */
.record__body p { margin: 0 0 0.5rem; }
.record__body p:last-child { margin-bottom: 0; }
.record__body a { font-size: 0.95em; }
