/* jrheaton.com
 *
 * Hand-written, no framework. A site whose whole job is setting prose well is a bad place to
 * be composing type out of utility classes.
 *
 * The one rule that matters: .prose is shared verbatim between the published page and the
 * editing surface. Jake writes in the typography he publishes in. Anything that styles prose
 * goes under .prose and nowhere else.
 */

/* ------------------------------------------------------------------- fonts */

@font-face {
  font-family: 'EB Garamond';
  src: url('/static/fonts/ebgaramond-latin-normal.woff2') format('woff2');
  font-weight: 400 800; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('/static/fonts/ebgaramond-latin-ext-normal.woff2') format('woff2');
  font-weight: 400 800; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
                 U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('/static/fonts/ebgaramond-latin-italic.woff2') format('woff2');
  font-weight: 400 800; font-style: italic; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('/static/fonts/ebgaramond-latin-ext-italic.woff2') format('woff2');
  font-weight: 400 800; font-style: italic; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
                 U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ tokens */

:root {
  --paper:     #faf6ef;
  --paper-2:   #f3ece0;   /* a shade down, for wells and inputs */
  --ink:       #2b2622;
  --ink-soft:  #6b6259;
  --ink-faint: #a99e91;
  --rust:      #9c4a2f;
  --rule:      #e2d8c8;

  --serif: 'EB Garamond', Iowan Old Style, Palatino, 'Palatino Linotype', Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --measure: 34rem;      /* ~66 characters at the prose size */
  --prose-size: 1.1875rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #17140f;
    --paper-2:   #221d17;
    --ink:       #ece2d2;
    --ink-soft:  #a1968a;
    --ink-faint: #6d6459;
    --rust:      #d9865f;
    --rule:      #332c24;
  }
}

/* -------------------------------------------------------------------- base */

*, *::before, *::after { 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: var(--prose-size);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: oldstyle-num;
}
a { color: inherit; text-decoration-color: var(--ink-faint); text-underline-offset: 0.14em; }
a:hover { text-decoration-color: var(--rust); }
::selection { background: rgba(156, 74, 47, 0.16); }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.5rem; }
.wide { max-width: 52rem; }

/* Small type for anything that is not the writing: labels, buttons, the desk. */
.ui { font-family: var(--sans); font-size: 0.8125rem; letter-spacing: 0.01em; font-variant-numeric: normal; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

/* ===================================================================== PROSE
 *
 * Shared by views/piece.ejs and the editor. Do not fork these rules.
 */

.prose { font-size: var(--prose-size); line-height: 1.62; }
.prose > * + * { margin-top: 1.15em; }
.prose p { margin: 0; hyphens: auto; }

/* Paragraphs are spaced, not indented (they were indented until 2026-09-09). A blank
 * paragraph is how the editor asks for a wider gap, and it has to survive publishing: an
 * empty <p> has no line box, so without this it collapses to nothing on the reader's page
 * while the editor (which pads it with a <br>) shows the gap. One no-break space gives it
 * the same one-line height in both places. */
.prose p:empty::before { content: '\00a0'; }

.prose h2, .prose h3 {
  font-weight: 600;
  line-height: 1.25;
  margin-top: 2.2em;
  margin-bottom: 0.1em;
  letter-spacing: -0.005em;
}
.prose h2 { font-size: 1.42em; }
.prose h3 { font-size: 1.14em; font-style: italic; font-weight: 500; }
.prose h2 + p, .prose h3 + p { margin-top: 0.5em; }

.prose em { font-style: italic; }
.prose strong { font-weight: 650; }

.prose blockquote {
  margin: 1.7em 0;
  padding-left: 1.3em;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

.prose ul, .prose ol { margin: 1.15em 0; padding-left: 1.4em; }
.prose li { margin: 0.3em 0; }

/* The dinkus. An <hr> is stored, but a rule across the page is a document divider and this
 * is a breath between scenes, so it is drawn instead. */
.prose hr {
  border: 0;
  margin: 2.1em 0;
  text-align: center;
  overflow: visible;
  height: 0;
}
.prose hr::before {
  content: '❦';
  color: var(--ink-soft);
  font-size: 1.5em;
  line-height: 0;
  display: inline-block;
  transform: translateY(-0.1em);
}

.prose a { text-decoration: underline; text-decoration-thickness: 0.5px; }

/* ------------------------------------------------------------- reader pages */

.masthead { padding: 3.5rem 0 2.4rem; }
.masthead .mark { display: inline-block; text-decoration: none; line-height: 0; }

/* Height, never width, so any aspect ratio behaves. max-width keeps a very wide
 * wordmark-shaped logo inside the measure on a phone. */
.masthead .mark img {
  height: 3.2rem; width: auto; max-width: 100%;
  display: block; object-fit: contain;
}
.masthead .mark:hover img { opacity: 0.82; }

/* The fallback when no logo has been uploaded. Never let the site be headless. */
.masthead .wordmark {
  font-size: 1.9rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink); line-height: 1.1; display: inline-block;
}
.masthead .mark:hover .wordmark { color: var(--rust); }

/* The mark is the SAME size on every page (2026-09-09; a piece page used to shrink it to
 * 2.1rem). Only the space under it tightens on a piece, because the title follows. */
.piece-page .masthead { padding-bottom: 1.6rem; }
.piece-page .masthead .wordmark {
  font-size: 0.75rem; font-family: var(--sans); font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
}

@media (max-width: 40rem) {
  .masthead .mark img { height: 2.6rem; }
  .masthead .wordmark { font-size: 1.55rem; }
}

/* The uploaded logo, previewed on the settings page. */
.logo-preview {
  display: inline-block; padding: 0.7rem 0.9rem; border: 1px solid var(--rule);
  border-radius: 3px; background: var(--paper); margin-bottom: 0.7rem;
}
.logo-preview img { height: 3.2rem; width: auto; max-width: 100%; display: block; }
/* The dark variant needs the dark ground behind it to be judged at all. */
.logo-preview.dark { background: #17140f; border-color: #332c24; margin-left: 0.4rem; }
@media (prefers-color-scheme: dark) {
  .logo-preview { background: #17140f; }
  .logo-preview.dark { background: #faf6ef; border-color: #e2d8c8; }
  .logo-preview.dark img { content: none; }
}

.epigraph {
  margin: 0 0 3.4rem;
  font-style: italic; color: var(--ink-soft); line-height: 1.5;
  max-width: 26rem;
}

.index-group { margin: 0 0 2.9rem; }
.index-group > h2 {
  font-family: var(--sans); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 0.9rem;
}
.index-group > h2 a { text-decoration: none; }
.index-group .blurb { margin: -0.5rem 0 1.1rem; font-style: italic; color: var(--ink-soft); font-size: 0.95em; }

.contents { list-style: none; margin: 0; padding: 0; }
.contents li { margin: 0 0 0.85rem; }
.contents a { text-decoration: none; display: block; }
.contents a:hover .t { text-decoration: underline; text-decoration-color: var(--rust); }
.contents .t { font-size: 1.2rem; line-height: 1.3; }

article.piece { padding: 2.4rem 0 0; }
article.piece > header { margin-bottom: 2.6rem; }
article.piece h1 {
  font-size: clamp(2rem, 5.5vw, 2.7rem);
  font-weight: 600; line-height: 1.14; letter-spacing: -0.015em;
  margin: 0;
}
article.piece .in-collection {
  font-family: var(--sans); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 0.9rem; display: block; text-decoration: none;
}
article.piece .in-collection:hover { color: var(--rust); }

.draft-mark {
  display: inline-block; margin-bottom: 1.4rem;
  font-family: var(--sans); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rust); border: 1px solid currentColor; border-radius: 2px;
  padding: 0.2rem 0.5rem;
}

/* The printer's end mark. Deliberately NOT the dinkus used for a section break: one of them
 * means "pause" and the other means "that is all", and they should not look alike. */
.endmark { margin: 3.2rem 0 0; text-align: center; color: var(--ink-faint); line-height: 1; }
.endmark::before { content: '\25A0'; font-size: 0.5em; }

footer.site {
  margin: 5rem 0 3rem; padding-top: 1.6rem; border-top: 1px solid var(--rule);
  color: var(--ink-soft); font-style: italic; font-size: 0.95rem;
  display: flex; gap: 1rem; justify-content: space-between; align-items: baseline; flex-wrap: wrap;
}
footer.site a { font-family: var(--sans); font-style: normal; font-size: 0.72rem;
  letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none; color: var(--ink-faint); }
footer.site a:hover { color: var(--rust); }

/* ------------------------------------------------------------------ forms */

.field { display: block; margin: 0 0 1.1rem; }
.field > span {
  display: block; font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.32rem;
}
input[type=text], input[type=password], select, textarea {
  width: 100%; font-family: var(--sans); font-size: 1rem;   /* 16px: iOS zooms below this */
  color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: 3px;
  padding: 0.5rem 0.6rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rust); outline-offset: -1px; }

.btn {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.06em; cursor: pointer;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: 3px;
  padding: 0.45rem 0.9rem;
}
.btn:hover { background: var(--rust); border-color: var(--rust); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--rule); }
.btn.ghost:hover { color: var(--rust); border-color: var(--rust); background: transparent; }
.btn.danger:hover { background: #8c2f2f; border-color: #8c2f2f; }

.notice { padding: 0.6rem 0.8rem; border-radius: 3px; margin-bottom: 1.2rem;
  font-family: var(--sans); font-size: 0.84rem; }
.notice.bad  { background: rgba(156,74,47,0.1); color: var(--rust); }
.notice.good { background: rgba(60,120,70,0.12); color: #3c7846; }
@media (prefers-color-scheme: dark) { .notice.good { color: #86c294; } }

.centered { max-width: 22rem; margin: 5rem auto; }
.centered h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 0.4rem; }
.centered .lede { color: var(--ink-soft); font-style: italic; margin: 0 0 2rem; }

/* ======================================================================= DESK */

.desk-bar {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding: 1.6rem 0 1.8rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem;
}
.desk-bar h1 { font-size: 1.35rem; font-weight: 600; margin: 0; flex: 1; }
.desk-bar nav { display: flex; gap: 0.9rem; align-items: baseline; }

.desk-section { margin: 0 0 2.8rem; }
.desk-section > h2 {
  font-family: var(--sans); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 0.8rem;
}
.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: flex; align-items: baseline; gap: 0.8rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--rule);
}
.rows li .grip { cursor: grab; color: var(--ink-faint); font-family: var(--sans); user-select: none; }
/* min-width:0 because a flex item will not shrink below its content width by default, and a
 * long title beside several nowrap meta spans is exactly how a row overflows on a phone. */
.rows li .title { flex: 1; min-width: 0; overflow-wrap: anywhere; text-decoration: none; }
.rows li .title:hover { text-decoration: underline; text-decoration-color: var(--rust); }
.rows li .meta { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); white-space: nowrap; }
.rows li.dragging { opacity: 0.45; }
.rows li.drop-target { border-top: 2px solid var(--rust); }

.empty { color: var(--ink-soft); font-style: italic; }

/* The trash bin at the foot of the desk and the restore icon at the head of the trash page
 * are the same kind of thing: a drop target that is also a link. Dashed because it is a
 * place to put something, not a button to press. */
.trash-bin, .restore-target {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto;
  column-gap: 0.9rem; align-items: center;
  margin: 1rem 0 2.8rem; padding: 1rem 1.2rem;
  border: 1px dashed var(--ink-faint); border-radius: 6px;
  color: var(--ink-soft); text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.trash-bin .icon, .restore-target .icon {
  grid-column: 1; grid-row: 1 / span 2; width: 1.9rem; height: 1.9rem;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.trash-bin .label, .restore-target .label {
  grid-column: 2; grid-row: 1;
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.trash-bin .count {
  grid-column: 3; grid-row: 1 / span 2; font-family: var(--sans); font-size: 0.8rem; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.trash-bin .hint, .restore-target .hint { grid-column: 2; grid-row: 2; font-style: italic; font-size: 0.92rem; color: var(--ink-faint); }
.trash-bin:hover, .restore-target:hover { color: var(--ink); border-color: var(--ink-soft); }
.trash-bin.over { color: var(--rust); border-color: var(--rust); border-style: solid; background: rgba(156,74,47,0.08); }
.restore-target.over { color: #3c7846; border-color: #3c7846; border-style: solid; background: rgba(60,120,70,0.1); }
@media (prefers-color-scheme: dark) { .restore-target.over { color: #86c294; border-color: #86c294; } }
.restore-target { margin: 0 0 2.4rem; }

/* A form button dressed as one of the row's small links. */
.rows li .linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); white-space: nowrap;
}
.rows li .linkish:hover { color: var(--rust); text-decoration: underline; }
.rows li .linkish.danger:hover { color: #8c2f2f; }

.card { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px;
  padding: 1rem 1.1rem; margin: 0 0 1rem; }
.card h3 { font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-soft); margin: 0 0 0.7rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 10rem; margin: 0; }

/* ==================================================================== EDITOR */

.editor-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  padding: 0.7rem 1.5rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  transition: opacity 0.25s ease;
}
.editor-bar .spacer { flex: 1; }
body.typing .editor-bar { opacity: 0.18; }
body.typing .editor-bar:hover { opacity: 1; }

#save-status { font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.04em; color: var(--ink-faint); }
#save-status[data-tone="dirty"] { color: var(--ink-soft); }
#save-status[data-tone="saving"] { color: var(--ink-soft); }
#save-status[data-tone="saved"] { color: var(--ink-faint); }
#save-status[data-tone="error"] { color: var(--rust); font-weight: 600; }
#word-count { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); }

.desk-link { font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; text-decoration: none; color: var(--ink-soft); }
.desk-link:hover { color: var(--rust); }

.compose { padding: 2.6rem 0 6rem; }

/* The title is an input that looks exactly like the published heading, because on this
 * page it IS the published heading. */
#piece-title {
  display: block; width: 100%; border: 0; background: transparent; padding: 0;
  font-family: var(--serif); color: var(--ink); resize: none; overflow: hidden;
}
#piece-title {
  font-size: clamp(2rem, 5.5vw, 2.7rem); font-weight: 600; line-height: 1.14;
  letter-spacing: -0.015em;
}
#piece-title:focus { outline: none; }
#piece-title::placeholder { color: var(--ink-faint); }

#editor { margin-top: 2.6rem; }
#editor .tiptap { outline: none; min-height: 60vh; }
#editor .tiptap p.is-editor-empty:first-child::before {
  content: attr(data-placeholder); color: var(--ink-faint); float: left; height: 0; pointer-events: none;
}

/* Focus mode. The Focus extension marks the active node; this dims everything else. */
body.focus-mode #editor .tiptap > * { opacity: 0.32; transition: opacity 0.2s ease; }
body.focus-mode #editor .tiptap > .is-focused { opacity: 1; }

#bubble-menu {
  display: flex; gap: 0.1rem; padding: 0.2rem;
  background: var(--ink); border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
#bubble-menu button {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 600;
  background: transparent; border: 0; border-radius: 3px; cursor: pointer;
  color: color-mix(in srgb, var(--paper) 70%, transparent);
  padding: 0.3rem 0.55rem; line-height: 1;
}
#bubble-menu button:hover { color: var(--paper); background: rgba(255,255,255,0.12); }
#bubble-menu button.is-on { color: var(--paper); background: var(--rust); }
#bubble-menu button.i { font-style: italic; }
#bubble-menu button.b { font-weight: 800; }
#bubble-menu button.s { text-decoration: line-through; }

/* The side panel: everything that is about the piece rather than in it. */
.panel { border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1.6rem; }
.panel-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.share-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem;
  word-break: break-all; color: var(--ink-soft); background: var(--paper); padding: 0.4rem 0.5rem;
  border: 1px solid var(--rule); border-radius: 3px; display: block; margin-bottom: 0.5rem; }
.rev-list { list-style: none; margin: 0; padding: 0; max-height: 12rem; overflow-y: auto; }
.rev-list li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.3rem 0;
  font-family: var(--sans); font-size: 0.74rem; border-bottom: 1px solid var(--rule); }
.rev-list li span { flex: 1; color: var(--ink-soft); }
.rev-list button { background: none; border: 0; color: var(--rust); cursor: pointer;
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600; padding: 0; }

@media (max-width: 40rem) {
  :root { --prose-size: 1.125rem; }
  .masthead { padding-top: 2.2rem; }
  .editor-bar { padding: 0.6rem 1rem; gap: 0.6rem; }
  .editor-bar .btn, .editor-bar .desk-link { font-size: 0.72rem; }
  .compose { padding-top: 1.6rem; }
  .rows li { flex-wrap: wrap; row-gap: 0.2rem; }
  .rows li .title { flex-basis: 100%; }
  .panel-grid { grid-template-columns: 1fr; }
  .inline-form .field { min-width: 100%; }
  footer.site { flex-direction: column; gap: 0.5rem; }
}
