/* ==========================================================================
   arpaci.me — a personal website set like a vintage newspaper

   Palette: exactly three colours, and nothing else.
     --paper  slightly yellow newsprint
     --ink    black
     --red    matte red (secondary)
   No greys, no tints, no opacity mixing. Emphasis comes from weight, size,
   rules and letter-spacing, the way one-ink printing did it.
   ========================================================================== */

:root {
  --paper: #f3e9cc;
  --ink:   #111111;
  --red:   #a63a2e;

  --font-masthead: "UnifrakturCook", "Old English Text MT", serif;
  --font-display:  "Playfair Display", "Times New Roman", Times, serif;
  --font-body:     "Libre Caslon Text", Georgia, "Times New Roman", serif;

  --measure: 1120px;
  --gutter: 2rem;

  /* Grain: pitch of the dot grid and how strongly it prints. */
  --grain-pitch: 8px;
  --grain-opacity: .4;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}

/* Dot-grid grain. Black dots in a staggered, brick-like grid, printed into
   the paper: it sits above the paper colour but *below* the text and rules,
   so letterforms stay crisp. The tile is one pitch wide and two tall and
   holds two dots, the second offset by half a pitch, which gives the
   brick stagger. --grain-opacity sets how hard the dots print;
   --grain-pitch and the circle radius set the density. */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='16'%3E%3Ccircle cx='2' cy='4' r='.5' fill='%23111111'/%3E%3Ccircle cx='6' cy='12' r='.5' fill='%23111111'/%3E%3C/svg%3E");
  background-size: var(--grain-pitch) calc(var(--grain-pitch) * 2);
  opacity: var(--grain-opacity);
}

::selection { background: var(--red); color: var(--paper); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
a:hover { color: var(--red); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
p { margin: 0 0 1em; text-wrap: pretty; }
em, i { font-style: italic; }
abbr[title] { text-decoration: none; border-bottom: 1px dotted var(--ink); cursor: help; }
svg { color: var(--ink); }

.wrap { width: min(var(--measure), 100% - 2.5rem); margin-inline: auto; }
.nowrap { white-space: nowrap; }
.fine { font-size: .85rem; font-style: italic; }

/* Rules ------------------------------------------------------------------ */

.rule { border: 0; border-top: 1px solid var(--ink); margin: 0; }
.rule--oxford { border-top: 3px solid var(--ink); border-bottom: 1px solid var(--ink); height: 6px; }
.rule--double { border-top: 3px double var(--ink); }

.ornament { text-align: center; margin: 2rem 0; font-size: 1.4rem; line-height: 1; }
.ornament::before { content: "\2042"; }

/* Small-caps style labels (uppercase display face, tracked out) --------- */

.label,
.topstrip, .folio, .motto, .sections a, .kicker, .byline span, .box-title,
.entry dt, .spec dt, .contact span, .ear strong, .ledger th, .tags a, .btn,
.paper .authors, .dateline-inline {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */

.masthead { padding-top: .6rem; }

.topstrip {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin-top: .75rem;
  padding: .45rem 0 .4rem;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: .7rem;
}

.nameplate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 0 1.1rem;
}

.ear {
  max-width: 11.5rem;
  padding: .55rem .75rem;
  border: 1px solid var(--ink);
  font-size: .76rem;
  line-height: 1.35;
}
.ear strong { display: block; font-size: .62rem; margin-bottom: .3em; }
.ear:first-child { justify-self: start; }
.ear:last-child  { justify-self: end; text-align: right; }

.nameplate {
  font-family: var(--font-masthead);
  font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
}
.nameplate:hover { color: var(--ink); }

.motto {
  margin: 0;
  padding: .5rem 0;
  border-top: 1px solid var(--ink);
  text-align: center;
  font-size: .74rem;
  letter-spacing: .3em;
}

.sections {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
}
.sections a {
  display: block;
  padding: .65rem 1.6rem;
  font-size: .78rem;
  letter-spacing: .2em;
  text-decoration: none;
}
.sections a + a { border-left: 1px solid var(--ink); }
.sections a:hover,
.sections a[aria-current="page"] { color: var(--red); }

/* Inner pages carry a smaller nameplate and no ears. */
.masthead--compact .nameplate-row { grid-template-columns: minmax(0, 1fr); padding: 1rem 0 .7rem; }
.masthead--compact .ear,
.masthead--compact .motto { display: none; }
.masthead--compact .nameplate { font-size: clamp(1.9rem, 4.6vw, 3.2rem); }

.folio {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .4rem 0 .35rem;
  border-bottom: 1px solid var(--ink);
  font-size: .68rem;
}

/* --------------------------------------------------------------------------
   Page grid
   -------------------------------------------------------------------------- */

.page { padding: 1.75rem 0 3rem; }
.page--grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 0 var(--gutter);
  align-items: start;
}
.span-all { grid-column: 1 / -1; }
.sidebar { border-left: 1px solid var(--ink); padding-left: var(--gutter); }

.page-head {
  text-align: center;
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--ink);
}
.page-head .headline { font-size: clamp(2rem, 4.2vw, 3.1rem); }
.page-head .byline { margin-bottom: 0; }
.page--grid > .folio { margin-bottom: 1.5rem; }

/* --------------------------------------------------------------------------
   Headlines, decks, bylines, kickers
   -------------------------------------------------------------------------- */

.kicker {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 .8rem;
  font-size: .7rem;
  letter-spacing: .24em;
  color: var(--red);
}
.kicker::before, .kicker::after { content: ""; flex: 1 1 auto; border-top: 1px solid var(--ink); }
.kicker--left { justify-content: flex-start; }
.kicker--left::before { display: none; }

.headline {
  margin: 0 0 .65rem;
  font-size: clamp(2rem, 4.8vw, 3.5rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -.012em;
  text-align: center;
}

.deck {
  max-width: 44rem;
  margin: 0 auto 1rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  line-height: 1.35;
  text-align: center;
}

.byline { text-align: center; margin: 0 0 1.4rem; }
.byline span {
  display: inline-block;
  padding: .4em 0 .35em;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: .68rem;
  letter-spacing: .18em;
}

.dateline-inline { font-size: .82em; letter-spacing: .08em; }

/* --------------------------------------------------------------------------
   Running text in newspaper columns
   -------------------------------------------------------------------------- */

.columns {
  column-gap: var(--gutter);
  column-rule: 1px solid var(--ink);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.columns--2 { column-count: 2; }
.columns--3 { column-count: 3; }
.columns p { margin: 0; text-indent: 1.5em; }
.columns p:first-child,
.columns p.dropcap { text-indent: 0; }

.dropcap::first-letter {
  float: left;
  padding: .12em .12em 0 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 3.7em;
  line-height: .72;
}

.continued {
  margin-top: .9rem;
  text-indent: 0 !important;
  text-align: right;
  font-style: italic;
  font-size: .85rem;
}
.continued a { text-decoration: none; }
.continued a::after { content: " \2192"; }

/* --------------------------------------------------------------------------
   Boxes, lists, sidebars
   -------------------------------------------------------------------------- */

.box {
  margin: 0 0 1.5rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 3px double var(--ink);
  font-size: .95rem;
}
.box-title {
  margin: -1rem -1.1rem 1rem;
  padding: .6rem .5rem .5rem;
  border-bottom: 1px solid var(--ink);
  text-align: center;
  font-size: .72rem;
  letter-spacing: .24em;
}
.box > :last-child { margin-bottom: 0; }

.index { list-style: none; margin: 0; padding: 0; }
.index li { display: flex; align-items: baseline; gap: .5rem; padding: .35rem 0; }
.index li + li { border-top: 1px dotted var(--ink); }
.index a { text-decoration: none; }
.index .leader { flex: 1; border-bottom: 1px dotted var(--ink); transform: translateY(-.3em); }
.index .pg { font-family: var(--font-display); font-weight: 700; }

.interests dt { font-weight: 700; margin-top: .7rem; }
.interests dt:first-child { margin-top: 0; }
.interests dd { margin: .1rem 0 0; font-size: .92rem; }

.contact { list-style: none; margin: 0; padding: 0; }
.contact li { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; }
.contact li + li { border-top: 1px dotted var(--ink); }
.contact span { flex: none; padding-top: .3em; font-size: .66rem; }
.contact a { text-align: right; }

.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: .35rem 0; }
.plain li + li { border-top: 1px dotted var(--ink); }

.spec { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .25rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
.spec dt { padding-top: .35em; font-size: .66rem; }
.spec dd { margin: 0; }
.spec--wide { font-size: 1rem; gap: .4rem 1.5rem; }
.spec--wide dt { font-size: .72rem; }

.cut { margin: 0 auto 1rem; text-align: center; }
.cut svg { display: block; width: 64px; height: 64px; margin: 0 auto; }

/* A newspaper photo ("cut"): full colour, hairline frame, italic cutline. */
.photo { margin: 0 0 1.1rem; break-inside: avoid; }
.photo-frame { border: 1px solid var(--ink); }
.photo-frame img { display: block; width: 100%; height: auto; }
.photo figcaption {
  margin-top: .5rem;
  font-size: .8rem;
  font-style: italic;
  line-height: 1.4;
  text-align: left;
  text-indent: 0;
}
.photo figcaption strong { font-style: normal; }

/* The home page sets the headshot twice (templates/headshot.html): once in
   the lead story's columns, once at the head of the sidebar. Wide presses
   show the sidebar copy; the narrow ones (below) keep it with the story. */
.lead-story .photo { display: none; }
.sidebar > .photo { margin-bottom: 1.5rem; }

.engraving { margin: 0 0 1.75rem; text-align: center; }
.engraving svg { display: block; width: min(100%, 230px); height: auto; margin: 0 auto .6rem; }
.engraving figcaption { font-size: .8rem; font-style: italic; }

.stamp-row { margin: .4rem 0 1.5rem; text-align: center; }
.stamp {
  display: inline-block;
  padding: .4em .9em .3em;
  border: 3px double var(--red);
  transform: rotate(-4deg);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .22em;
  color: var(--red);
}

/* --------------------------------------------------------------------------
   Front-page teasers
   -------------------------------------------------------------------------- */

.teasers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 var(--gutter);
  margin-top: 2.25rem;
  padding-top: 1.4rem;
  border-top: 3px double var(--ink);
}
.teaser + .teaser { border-left: 1px solid var(--ink); padding-left: var(--gutter); }
.teaser h3 { margin: 0 0 .6rem; font-size: 1.45rem; line-height: 1.12; }
.teaser h3 a { text-decoration: none; }
.teaser p { font-size: .95rem; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.teaser .continued { margin-top: .25rem; }

/* --------------------------------------------------------------------------
   Curriculum vitæ
   -------------------------------------------------------------------------- */

.section-head {
  margin: 2.25rem 0 .8rem;
  padding: .45rem 0 .35rem;
  border-top: 4px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.main-col > .section-head:first-child { margin-top: 0; }

.entries { margin: 0; }
.entry { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 0 1.25rem; padding: .75rem 0; }
.entry + .entry { border-top: 1px dotted var(--ink); }
.entry dt { margin: 0; padding-top: .3em; font-size: .7rem; letter-spacing: .1em; }
.entry dd { margin: 0; }
.entry .note { display: block; margin-top: .15rem; font-size: .92rem; font-style: italic; }

.pubs { margin: 0; padding-left: 1.5em; }
.pubs li { margin-bottom: .6em; padding-left: .2em; }
.pubs li::marker,
.recipe li::marker { font-family: var(--font-display); font-weight: 700; color: var(--red); }

.coupon {
  position: relative;
  margin: 0 0 1.75rem;
  padding: 1.1rem 1.1rem 1.2rem;
  border: 2px dashed var(--ink);
  text-align: center;
  font-size: .9rem;
}
.coupon::before {
  content: "\2702\FE0E";
  position: absolute;
  top: -.8rem;
  left: 1rem;
  padding: 0 .35rem;
  background: var(--paper);
  font-size: 1.15rem;
  line-height: 1;
}
.coupon p { margin-bottom: .75rem; }

.btn {
  display: inline-block;
  padding: .65em 1.2em .55em;
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: .72rem;
  letter-spacing: .2em;
  text-decoration: none;
}
.btn:hover { background: var(--red); border-color: var(--red); color: var(--paper); }

/* --------------------------------------------------------------------------
   Papers
   -------------------------------------------------------------------------- */

.paper {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  gap: 0 1rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--ink);
}
.paper:first-child { padding-top: .25rem; border-top: 0; }
.paper-no { font-family: var(--font-display); font-weight: 900; font-size: 2.5rem; line-height: .9; color: var(--red); }
.paper h3 { margin: 0 0 .5rem; font-size: 1.5rem; line-height: 1.15; }
.paper .authors { margin: 0 0 .3rem; font-size: .72rem; letter-spacing: .12em; }
.paper .authors .me { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: .22em; }
.paper .venue { margin: 0 0 .8rem; font-style: italic; font-size: .95rem; }
.paper .abstract { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }

/* Inline maths, typeset by KaTeX. Its own 1.21em sits too big next to Caslon,
   and its error red is not one of our three colours. */
.katex { font-size: 1.08em; }
.katex .mord { hyphens: none; -webkit-hyphens: none; }
.katex-error { color: var(--red); }

.tags { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: .9rem 0 0; padding: 0; }
.tags a { display: inline-block; padding: .35em .75em .3em; border: 1px solid var(--ink); font-size: .64rem; text-decoration: none; }
.tags a:hover { border-color: var(--red); color: var(--red); }

/* --------------------------------------------------------------------------
   Tables & recipes
   -------------------------------------------------------------------------- */

.ledger { width: 100%; margin: 0 0 1rem; border-collapse: collapse; font-size: .92rem; }
.ledger th { padding: .55rem .5rem .4rem; border-top: 3px solid var(--ink); border-bottom: 1px solid var(--ink); text-align: left; font-size: .66rem; }
.ledger td { padding: .55rem .5rem; border-bottom: 1px dotted var(--ink); vertical-align: top; }
.ledger td:first-child, .ledger th:first-child { padding-left: 0; }

.recipe ol { margin: 0 0 .75rem; padding-left: 1.4em; }
.recipe li { margin-bottom: .45em; padding-left: .2em; }

/* --------------------------------------------------------------------------
   Colophon
   -------------------------------------------------------------------------- */

.colophon { padding: 0 0 3rem; text-align: center; font-size: .85rem; }
.colophon .rule--oxford { margin-bottom: .5rem; }
.colophon .ornament { margin: 1rem 0; }
.colophon nav { margin-top: .5rem; }
.colophon nav a { margin: 0 .7rem; font-family: var(--font-display); font-weight: 700; font-size: .68rem; text-transform: uppercase; letter-spacing: .18em; text-decoration: none; }

/* --------------------------------------------------------------------------
   Gear log: one entry per item, photo beside the write-up. Used by the
   coffee gear page (one entry per machine) and the 3D prints page (one
   entry per design).
   -------------------------------------------------------------------------- */

.gear {
  padding: 1.75rem 0;
  border-top: 1px solid var(--ink);
  scroll-margin-top: 1rem;
}
.gear::after { content: ""; display: block; clear: both; }
.gear--first { padding-top: .25rem; border-top: 0; }
.gear .kicker { margin-bottom: .55rem; }
.gear h3 { margin: 0 0 .75rem; font-size: 1.6rem; line-height: 1.12; }
/* The cut sits under the headline, small, with the spec list and the
   first paragraphs running down its right-hand side. */
.gear .photo { float: left; width: 30%; margin: .2rem var(--gutter) .6rem 0; }
.gear .spec { margin-bottom: 1rem; }
.gear-body p { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.gear-body > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Narrower presses
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .page--grid { grid-template-columns: minmax(0, 1fr); }
  .sidebar { margin-top: 2.25rem; padding: 1.5rem 0 0; border-left: 0; border-top: 3px double var(--ink); }
  .teasers { grid-template-columns: minmax(0, 1fr); }
  .teaser + .teaser { margin-top: 1.25rem; padding: 1.25rem 0 0; border-left: 0; border-top: 1px solid var(--ink); }
  .columns--3 { column-count: 2; }
  .lead-story .photo { display: block; }
  .sidebar > .photo { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .ear { display: none; }
  .nameplate-row { grid-template-columns: minmax(0, 1fr); padding: 1.1rem 0 .8rem; }
  .nameplate { font-size: clamp(1.8rem, 9.5vw, 2.6rem); }
  .topstrip { justify-content: center; text-align: center; }
  .motto { letter-spacing: .18em; font-size: .66rem; }
  .sections a { flex: 1 1 0; padding: .6rem .5rem; font-size: .68rem; letter-spacing: .12em; text-align: center; }
  .columns--2, .columns--3 { column-count: 1; }
  .entry { grid-template-columns: minmax(0, 1fr); gap: .15rem 0; }
  .paper { grid-template-columns: minmax(0, 1fr); }
  .paper-no { margin-bottom: .3rem; font-size: 1.6rem; }
  .gear .photo { float: none; width: auto; max-width: 16rem; margin: 0 0 1rem; }
  .folio { font-size: .6rem; }
}

@media print {
  body::before, .sections, .ear, .coupon, .colophon nav, .stamp-row { display: none; }
  .page--grid { display: block; }
  .sidebar { border: 0; padding: 0; margin-top: 2rem; }
}
