/* Book-like look: cream paper, ET Book serif, small monospace details, one red dot. */
@font-face {
  font-family: "et-book";
  src: url("fonts/et-book-roman-line-figures.woff") format("woff");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "et-book";
  src: url("fonts/et-book-display-italic-old-style-figures.woff") format("woff");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "et-book";
  src: url("fonts/et-book-bold-line-figures.woff") format("woff");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --paper: #fffff8;
  --ink: #111111;
  --soft: #555550;
  --line: #d8d6cc;
  --red: #c8331f;
  --serif: "et-book", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
p { margin: 0 0 1em; }

/* Outlined rounded boxes, used for nav "About", pills and buttons */
.boxed, .pills summary, button {
  display: inline-block;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 3px 10px;
  text-decoration: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.boxed:hover, .pills summary:hover, button:hover { background: var(--ink); color: var(--paper); }

/* Header: big title left, nav right */
.top {
  max-width: 1300px;
  margin: 0 auto;
  padding: 64px 56px 0 140px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}
h1 {
  font-weight: 400;
  font-size: 56px;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 a { text-decoration: none; }
.byline { font-size: 21px; margin: 0; max-width: 34em; }

nav {
  display: flex;
  align-items: center;
  gap: 40px;
  font-size: 19px;
  padding-top: 18px;
  white-space: nowrap;
}
nav a { text-decoration: none; }
nav a:not(.boxed):hover { text-decoration: underline; }

/* Two columns: reading column + sticky side panel */
.layout {
  max-width: 1300px;
  margin: 0 auto;
  padding: 64px 56px 0 140px;
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(0, 420px);
  justify-content: space-between;
  gap: 64px;
}

main { min-width: 0; }

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 1.4em 0 2.6em;
}
.pills details { display: contents; }
.pills summary { list-style: none; }
.pills summary::-webkit-details-marker { display: none; }
.pills details[open] summary { background: var(--ink); color: var(--paper); }
.pills details p {
  order: 99;
  flex-basis: 100%;
  margin: 10px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--ink);
}

h2 {
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 22px;
}

.meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--soft);
  margin: 0 0 6px;
}

section { margin-top: 3.2em; }

/* Letter form */
.letter {
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 26px 28px 24px;
}
.salutation { margin-bottom: 0.5em; }
.letter textarea {
  display: block;
  width: 100%;
  min-height: 200px;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0 0 22px;
  color: var(--ink);
  font: inherit;
  resize: vertical;
  outline: none;
  caret-color: var(--red);
}
.letter textarea::placeholder { color: var(--soft); font-style: italic; opacity: 1; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
}
.fields .wide { grid-column: 1 / -1; }
.fields label {
  display: flex;
  flex-direction: column;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--soft);
}
.fields em { font-style: normal; }
.fields input {
  margin-top: 4px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  padding: 2px 0 3px;
  outline: none;
  caret-color: var(--red);
}

.checks { margin: 20px 0 22px; display: grid; gap: 4px; }
.check { font-size: 17px; display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.check input { accent-color: var(--ink); }

button { display: inline-flex; align-items: center; gap: 10px; padding: 5px 18px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.note { font-family: var(--mono); font-size: 12px; color: var(--soft); margin: 12px 0 0; }

/* Letters */
#letters article { margin-bottom: 2.6em; }
/* Collapsed letters show the first paragraph, fading into the second */
#letters article.collapsed p:nth-of-type(n+5) { display: none; }
#letters article.collapsed p:nth-of-type(4) {
  max-height: 3em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
}
/* Read more: a plain text link, not a box */
button.more {
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 18px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.more:hover { background: transparent; color: var(--soft); }

/* Side panel */
aside { min-width: 0; }
.panel {
  position: sticky;
  top: 32px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  border-left: 1px solid var(--line);
  padding: 4px 0 4px 28px;
}
.chip {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  padding: 2px 8px;
  font-weight: 500;
  margin-bottom: 20px;
}
.stats {
  display: flex;
  gap: 28px;
  margin-bottom: 26px;
}
.stats div { display: flex; flex-direction: column; }
.label { color: var(--soft); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 8px; }
.value { font-size: 22px; font-weight: 500; }
.squares {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 3px;
  max-width: 300px;
}
.squares span { aspect-ratio: 1; background: var(--ink); border-radius: 2px; }
.squares span.new { background: var(--red); }
.small { color: var(--soft); margin: 8px 0 26px; }
.places { list-style: none; margin: 0; padding: 0; line-height: 1.9; }
.places li::before { content: "■ "; }
.follow-label { margin-top: 26px; }
.latest { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.latest .snip { font-family: var(--serif); font-size: 16px; line-height: 1.35; margin: 0 0 3px; }
.latest .who { color: var(--soft); font-size: 11px; }
.latest .more-link { display: block; margin-top: 3px; font-family: var(--serif); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.latest .more-link:hover { color: var(--soft); }
#write .meta { margin: -12px 0 14px; }
.live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-right: 7px; vertical-align: 1px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.follow { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.follow a {
  display: inline-block;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 3px 9px;
  text-decoration: none;
  font-size: 12px;
}
.follow a:hover { background: var(--ink); color: var(--paper); }

/* Footer */
footer {
  max-width: 1300px;
  margin: 80px auto 0;
  padding: 24px 56px 48px 140px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--soft);
}
footer p { margin: 0 0 6px; }
footer a { text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* Narrower screens: side panel moves below the header, then one column */
@media (max-width: 1100px) {
  .top, .layout, footer { padding-left: 48px; padding-right: 48px; }
  .layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; }
}

@media (max-width: 800px) {
  body { font-size: 18px; }
  .top, .layout, footer { padding-left: 18px; padding-right: 18px; }
  .top { flex-direction: column-reverse; padding-top: 16px; gap: 24px; }
  nav { gap: 24px; font-size: 17px; padding-top: 0; align-self: flex-end; }
  h1 { font-size: 40px; }
  .byline { font-size: 18px; }
  .layout { display: flex; flex-direction: column; gap: 32px; padding-top: 18px; }
  .panel { position: static; border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
  h2 { font-size: 28px; }
  .letter { padding: 18px 16px; }
  .letter textarea { min-height: 160px; }
  .fields { grid-template-columns: 1fr; }
  .fields input { font-size: 18px; }
  .check { font-size: 15px; }
}

/* ---------- Archive and single letter pages ---------- */
.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 64px 56px 0 140px;
}
.page main { max-width: 680px; }
.page h2 { margin-bottom: 8px; }
.page > main > .meta:first-of-type { margin-bottom: 28px; }
.archive { margin-top: 28px; }
.archive-item { margin-bottom: 2.4em; }
.archive-item p:not(.meta) { margin-bottom: 0.4em; }
.more-link { text-decoration: underline; text-underline-offset: 3px; }
.more-link:hover { color: var(--soft); }
.letter-full { margin-top: 28px; }
.letter-full .signature { font-style: italic; margin-top: 1.6em; }
.letter-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 3em; flex-wrap: wrap; }

/* Thank-you screen after sending */
.thanks { padding: 6px 0; }
.thanks h3 { font-weight: 400; font-size: 26px; margin: 0 0 14px; }
.form-error { color: var(--red); font-family: var(--mono); font-size: 12px; margin: 12px 0 0; }

@media (max-width: 1100px) {
  .page { padding-left: 48px; padding-right: 48px; }
}
@media (max-width: 800px) {
  .page { padding: 32px 18px 0; }
}

/* Legal pages */
.legal { margin-top: 28px; }
.legal h3 { font-weight: 400; font-size: 24px; margin: 1.6em 0 0.4em; }
.legal p { margin-bottom: 0.8em; }
.contact { margin-top: 2.4em; }

/* ---------- Admin ---------- */
body.admin .page { padding-top: 32px; }
body.admin .page main { max-width: 760px; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 18px 0 32px; font-size: 17px; }
.admin-item { border: 1.5px solid var(--ink); border-radius: 6px; padding: 18px 20px; margin-bottom: 22px; }
.admin-item.flagged { border-color: var(--red); }
.admin-item .check { font-family: var(--mono); font-size: 12px; margin: 0 0 12px; }
.admin-item.flagged .check { color: var(--red); }
.admin-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.admin-item input, .admin-item textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px;
}
.admin-item textarea { resize: vertical; line-height: 1.45; }
.admin-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.admin-buttons button { font-size: 16px; padding: 3px 14px; }
.admin-buttons button.quiet { border-color: var(--line); color: var(--soft); margin-left: auto; }
.admin-buttons button.danger { border-color: var(--red); color: var(--red); }
@media (max-width: 800px) { .admin-fields { grid-template-columns: 1fr; } }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
