/* richardkalis.com
   Fraunces headings, Hanken Grotesk text. Dark by default, stone light page on request. No accent colour.
   Layout: a sticky index on the left, one reading column on the right.
   Every list uses the same row: date on the left, content on the right. */

:root {
  /* dark is the default */
  --paper: #191816;
  --paper-2: #221f1c;
  --ink: #ece7dd;
  --ink-2: #bdb6aa;
  --muted: #857e73;
  --line: #35312c;
  --serif: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;  /* body text */
  --head: "Fraunces", Georgia, serif;                               /* headings */
  --head-weight: 400;
  --head-track: -.02em;
  color-scheme: dark;
}
/* light page (stone), chosen with the switch */
:root[data-theme="light"] {
  --paper: #ebeae6; --paper-2: #e1dfda; --ink: #171614; --ink-2: #4a4640; --muted: #8b8479; --line: #d0cdc6;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.65 var(--serif); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; transition: background .3s, color .3s;
}
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }

/* links: an underline that grows on hover */
a { color: inherit; text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .3s ease; }
a:hover { background-size: 100% 1px; }
.welcome a, .row .in a, .row .note a { background-size: 100% 1px; background-image: linear-gradient(var(--line), var(--line)); }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: .4rem .7rem; z-index: 20; }

.sc { font-variant-caps: all-small-caps; letter-spacing: .06em; }

/* ---------- layout ---------- */
.layout {
  max-width: 72rem; margin: 0 auto; padding: 0 40px;
  display: grid; grid-template-columns: 11rem minmax(0, 46rem); column-gap: clamp(3rem, 7vw, 7rem);
}

/* ---------- sticky index ---------- */
.index {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; padding: 4.5rem 0 2.5rem;
}
.index-name { font-family: var(--head); font-size: .95rem; font-weight: 500; font-variant-caps: all-small-caps; letter-spacing: .08em;
  opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s; }
.index.named .index-name { opacity: 1; transform: none; }
.index ol { list-style: none; margin: 2.25rem 0 0; padding: 0; counter-reset: i; }
.index li { counter-increment: i; }
.index ol a {
  display: flex; align-items: baseline; gap: .8rem; padding: .35rem 0; color: var(--muted);
  background: none; transition: color .2s;
}
.index ol a::before { content: counter(i); font-size: .78rem; font-variant-numeric: oldstyle-nums; width: .8rem; }
.index ol a::after { content: ""; height: 1px; width: 0; background: currentColor; align-self: center; transition: width .35s ease; }
.index ol a:hover { color: var(--ink); }
.index ol a.on { color: var(--ink); }
.index ol a.on::after { width: 1.5rem; }
.index-cv { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .95rem; align-self: flex-start; }
.theme-btn { all: unset; cursor: pointer; margin-top: auto; font: italic 400 .85rem var(--serif); color: var(--muted); }
.theme-btn:hover { color: var(--ink); }
.theme-btn:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }

/* ---------- top: photo + who ---------- */
main { padding: 4.5rem 0 0; min-width: 0; }
.top { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.photo { margin: 0; aspect-ratio: 4 / 5; background: var(--paper-2); display: grid; place-items: center; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .8s ease; }
.photo:hover img { transform: scale(1.03); }
.photo span { font: 300 2.6rem var(--serif); color: var(--muted); letter-spacing: .04em; }
.who h1 { font: var(--head-weight) clamp(2.4rem, 5vw, 3.6rem)/1.02 var(--head); letter-spacing: var(--head-track);
  margin: -.166em 0 0; }   /* top of the capitals level with the top of the photo */
.who .pos { margin: .7rem 0 0; font-style: italic; font-size: 1.15rem; }
.who .aff { margin: .25rem 0 0; color: var(--ink-2); font-size: .98rem; line-height: 1.5; }
.contact { list-style: none; padding: 1rem 0 0; margin: 1.25rem 0 0; border-top: 1px solid var(--line); font-size: .95rem; color: var(--ink-2); }
.contact li { padding: .1rem 0; }

.welcome { margin: 3.5rem 0 0; font-size: 1.22rem; line-height: 1.6; font-weight: 300; }

/* ---------- sections ---------- */
.sec { padding-top: 6rem; scroll-margin-top: 1rem; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1.5rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--ink); padding-bottom: .9rem; margin-bottom: 2rem; }
.sec-head h2 { font: var(--head-weight) 2.3rem/1.1 var(--head); letter-spacing: var(--head-track); margin: 0; }
.sec-head p { margin: 0; font-style: italic; color: var(--muted); font-size: .95rem; }

.group { margin-top: 3rem; }
.group:first-child, .filter + .group { margin-top: 0; }
.group[hidden] { display: none; }
.label { font: 500 .9rem var(--serif); font-variant-caps: all-small-caps; letter-spacing: .1em; color: var(--muted); margin: 0 0 .25rem; }

/* ---------- the row ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); column-gap: 1.75rem;
  padding: 1.6rem 1rem; margin: 0 -1rem; border-bottom: 1px solid var(--line);
  transition: background .25s; scroll-margin-top: 2rem;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--paper-2); }
.row[hidden] { display: none; }
.row .when { font-size: .92rem; color: var(--muted); font-variant-numeric: oldstyle-nums; padding-top: .12rem; }
.row h3 { font: 500 1.15rem/1.4 var(--serif); margin: 0; letter-spacing: -.005em; }
.row .by { margin: .35rem 0 0; color: var(--ink-2); font-size: 1rem; }
.row .in { margin: .1rem 0 0; color: var(--ink-2); font-size: 1rem; }
.row .note { margin: .6rem 0 0; color: var(--ink-2); font-size: 1rem; max-width: 38rem; }
.row .tools { margin: .7rem 0 0; display: flex; gap: 1.4rem; align-items: baseline; }
.row .tools button {
  all: unset; cursor: pointer; font-size: .92rem; font-variant-caps: all-small-caps; letter-spacing: .08em; color: var(--ink-2);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .3s, color .2s;
}
.row .tools button:hover, .row .tools button[aria-expanded="true"] { color: var(--ink); background-size: 100% 1px; }
.row .tools button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }
.row .tools .ok { font-style: italic; font-size: .88rem; color: var(--muted); }
.row .more { display: none; margin: 1rem 0 .25rem; padding-left: 1.1rem; border-left: 1px solid var(--ink); color: var(--ink-2); font-size: .98rem; max-width: 38rem; }
.row.show .more { display: block; animation: fade .4s ease; }
.row.flash { animation: flashbg 1.6s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes flashbg { from { background: var(--line); } to { background: transparent; } }

.syll { padding-left: 1.4rem; columns: 2; column-gap: 2.25rem; }
.syll li { break-inside: avoid; padding: .1rem 0; }
.syll li::marker { color: var(--muted); font-variant-numeric: oldstyle-nums; }

/* ---------- area filter ---------- */
.filter { margin: 0 0 3rem; }
.filter-lead { margin: 0 0 .6rem; font-size: .9rem; font-variant-caps: all-small-caps; letter-spacing: .1em; color: var(--muted); }
.areas { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.6rem; }
.area {
  all: unset; cursor: pointer; font-size: 1.08rem; color: var(--ink);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .3s, color .25s;
}
.area span { font-size: .72em; vertical-align: super; margin-left: .2rem; color: var(--muted); font-variant-numeric: oldstyle-nums; }
.area:hover { background-size: 100% 1px; }
.area:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }
.areas.active .area { color: var(--muted); }
.areas.active .area[aria-pressed="true"] { color: var(--ink); background-size: 100% 1.5px; }
.filter-state { margin: .9rem 0 0; min-height: 1.5em; font-style: italic; color: var(--muted); font-size: .95rem; }
.filter-state button { all: unset; cursor: pointer; font-style: normal; color: var(--ink); margin-left: .6rem;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat; }

/* ---------- footer ---------- */
.foot { margin-top: 7rem; padding: 1.5rem 0 3.5rem; border-top: 1px solid var(--ink); display: flex; justify-content: space-between;
  align-items: baseline; gap: 1.5rem; flex-wrap: wrap; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; font-size: .95rem; }
.foot p { margin: 0; font-size: .88rem; font-style: italic; color: var(--muted); }

/* ---------- motion ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .8s ease, transform .8s ease; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}

/* ---------- narrower screens: index becomes a top bar ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 24px; }
  .index {
    position: sticky; top: 0; z-index: 10; height: auto; padding: .8rem 24px; margin: 0 -24px;
    flex-direction: row; align-items: center; gap: 1.25rem; background: var(--paper); border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
  }
  .index::-webkit-scrollbar { display: none; }
  .index-name { display: none; }
  .index ol { display: flex; gap: 1.25rem; margin: 0; }
  .index ol a { padding: 0; white-space: nowrap; }
  .index ol a::before, .index ol a::after { display: none; }
  .index ol a.on { box-shadow: 0 1px 0 currentColor; }
  .index-cv { margin: 0; padding: 0; border: 0; white-space: nowrap; }
  .theme-btn { margin: 0 0 0 auto; white-space: nowrap; }
  main { padding-top: 2.5rem; }
}
@media (max-width: 600px) {
  body { font-size: 1rem; }
  .layout { padding: 0 16px; }
  .index { padding: .75rem 16px; margin: 0 -16px; gap: .8rem; font-size: .86rem; }
  .index ol { gap: .8rem; }
  .index-cv span { display: none; }
  .theme-btn .sun { font-size: 0; }
  .theme-btn .sun::before { content: "◐"; font-size: 1rem; font-style: normal; }
  .top { grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0 1.25rem; grid-template-rows: auto auto 1fr; align-items: start; }
  .who .aff { font-size: .9rem; }
  .contact { grid-column: 1 / -1; }
  .welcome { font-size: 1.1rem; margin-top: 2.25rem; }
  .sec { padding-top: 4rem; }
  .sec-head h2 { font-size: 1.75rem; }
  .row { grid-template-columns: minmax(0, 1fr); padding: 1.25rem .5rem; margin: 0 -.5rem; }
  .row .when { padding: 0 0 .2rem; }
  .syll { columns: 1; }
}
/* on phones the contact list moves under photo + name */
@media (max-width: 600px) {
  .who { display: contents; }
  .who h1, .who .pos, .who .aff { grid-column: 2; }
  .photo { grid-row: 1 / span 3; }
  .contact { grid-column: 1 / -1; }
}

/* ---------- recent: a small window that scrolls on its own, then hands over to the page ---------- */
.recent { margin-top: 3.25rem; }
.recent .label { padding-bottom: .7rem; margin: 0; border-bottom: 1px solid var(--line); }
.feed { max-height: 15.5rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; padding-right: 1rem; }
.feed.more { -webkit-mask-image: linear-gradient(#000 calc(100% - 3.5rem), transparent); mask-image: linear-gradient(#000 calc(100% - 3.5rem), transparent); }
.feed ul { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 5.5rem 4.5rem minmax(0, 1fr); column-gap: 1rem; align-items: baseline;
  padding: .62rem 0; border-bottom: 1px solid var(--line); font-size: .98rem; line-height: 1.45; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: .9rem; }
.feed .kind { color: var(--muted); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; }
.feed .what { color: var(--ink-2); }
.feed .up { color: var(--ink); }
@media (max-width: 600px) {
  .feed li { grid-template-columns: auto minmax(0, 1fr); column-gap: .8rem; }
  .feed .what { grid-column: 1 / -1; }
  .feed { max-height: 19rem; }
}

@media print {
  .index, .tools, .filter, .theme-btn { display: none !important; }
  .layout { display: block; }
  .js .reveal { opacity: 1; transform: none; }
  .row .more { display: block; }
}


/* labels and small buttons: spaced capitals */
.label, .filter-lead { font-variant-caps: normal; text-transform: uppercase; font-size: .7rem; letter-spacing: .12em; font-weight: 500; }
.row .tools button { font-variant-caps: normal; text-transform: uppercase; font-size: .72rem; letter-spacing: .1em; }
.welcome { font-weight: 300; font-size: 1.2rem; }
.index-name { font-variant-caps: normal; font-size: 1.05rem; letter-spacing: -.01em; }

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

/* ---------- BibTeX, copy email ---------- */
.label .bib { float: right; font-size: .85rem; letter-spacing: .04em; color: var(--ink-2); }
.copy { all: unset; cursor: pointer; margin-left: .5rem; font-size: .78rem; font-style: italic; color: var(--muted); }
.copy:hover { color: var(--ink); }
.copy:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }

/* ---------- reading progress + back to top ---------- */
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 100%; background: var(--ink); transform-origin: 0 50%;
  transform: scaleX(var(--p, 0)); z-index: 30; pointer-events: none; }
.to-top { position: fixed; right: 1.5rem; bottom: 1.5rem; width: 2.6rem; height: 2.6rem; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink); font-size: 1rem;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .3s, transform .3s, border-color .2s; z-index: 15; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--ink); background-size: 0; }

@media print { .progress, .to-top, .copy, .bib { display: none !important; } }

@media print { :root, :root[data-theme] { --paper: #fff; --paper-2: #fff; --ink: #000; --ink-2: #222; --muted: #555; --line: #bbb; color-scheme: light; } }
@media print { .feed { max-height: none; overflow: visible; -webkit-mask: none; mask: none; } }
