
/* ─── TOKENS ─────────────────────────────────────── */
:root {
  /* A very dark warm paper, not pure black */
  --bg:          #111009;
  --bg-modal:    #16140e;

  /* Text — aged paper tones */
  --ink-1:       #e8e0cc;   /* primary — warm off-white */
  --ink-2:       #b0a690;   /* secondary — faded */
  --ink-3:       #6b6050;   /* tertiary — ghost */

  /* Accents */
  --red:         #9e3a2a;   /* faded red stamp */
  --underline:   #6b6050;   /* hover underline */
  --rule:        #2e2a20;   /* horizontal rules */

  /* Type — everything is typewriter */
  --type:   'Courier Prime', 'Special Elite', 'Courier New', monospace;
  --display:'Special Elite', 'Courier Prime', monospace;

  /* Space */
  --s1: .5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2.5rem;
  --s5: 4rem;

  --max-w: 780px;
  --t: 180ms ease;
}

/* ─── RESET ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--type);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Subtle paper texture via CSS noise */
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(60,50,30,.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(40,35,20,.12) 0%, transparent 50%);
}

button { font-family: var(--type); cursor: pointer; }
svg { display: block; }

/* ─── PAGE WRAPPER ───────────────────────────────── */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s4) var(--s3);
}

/* ─── MASTHEAD ───────────────────────────────────── */
.masthead {
  margin-bottom: var(--s4);
}

.masthead-line {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 0;
}

.top-rule  { margin-bottom: var(--s3); }
.bottom-rule { margin-top: var(--s3); }

.masthead-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s3);
}

.masthead-left {
  flex: 1;
}

.issue-label {
  font-size: .7rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: .4rem;
}

.site-title {
  font-family: var(--display);
  font-size: clamp(3rem, 8vw, 5.5rem);
  line-height: 1;
  color: var(--ink-1);
  letter-spacing: -.02em;
  /* Slight intentional misalignment — typewriter feel */
  transform: skewX(-.4deg);
  display: inline-block;
}

.site-byline {
  font-size: .78rem;
  color: var(--ink-3);
  letter-spacing: .1em;
  margin-top: .5rem;
  text-transform: uppercase;
}

.masthead-right {
  text-align: right;
  flex-shrink: 0;
  padding-bottom: .3rem;
}

.masthead-statement {
  font-size: .88rem;
  line-height: 1.8;
  color: var(--ink-3);
  font-style: normal;
}

.masthead-statement em {
  color: var(--ink-2);
  font-style: italic;
}

/* ─── ABOUT ──────────────────────────────────────── */
.about {
  margin-bottom: var(--s4);
  /* Asymmetric indent — manuscript margin note feel */
  padding-left: 4ch;
  border-left: 1px solid var(--rule);
  position: relative;
}

.about::before {
  content: '//';
  position: absolute;
  left: -3.5ch;
  top: 0;
  font-size: .7rem;
  color: var(--ink-3);
  letter-spacing: .05em;
}

.about-text {
  font-size: .9rem;
  line-height: 1.9;
  color: var(--ink-2);
  max-width: 58ch;
}

/* ─── CONTROLS ───────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--rule);
}

/* Search — typewriter command-line feel */
.search-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
  min-width: 160px;
}

.search-prefix {
  color: var(--ink-3);
  font-size: 1rem;
  line-height: 1;
  animation: blink 1.2s step-end infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-1);
  font-family: var(--type);
  font-size: .88rem;
  padding: .25rem 0;
  outline: none;
  letter-spacing: .03em;
  transition: border-color var(--t);
}

.search-input::placeholder { color: var(--ink-3); }
.search-input:focus { border-bottom-color: var(--ink-2); }
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: .75rem;
  transition: color var(--t);
  padding: 0;
  flex-shrink: 0;
}
.search-clear:hover { color: var(--ink-1); }
.search-clear[hidden] { display: none; }

/* Filter tabs — bracketed typewriter style */
.filter-tabs {
  display: flex;
  gap: .15rem;
  flex-shrink: 0;
}

.ftab {
  background: none;
  border: none;
  color: var(--ink-3);
  font-family: var(--type);
  font-size: .8rem;
  padding: .2rem .4rem;
  letter-spacing: .04em;
  transition: color var(--t);
}

.ftab:hover { color: var(--ink-2); }
.ftab.active { color: var(--ink-1); }

.count-label {
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .06em;
  margin-left: auto;
  white-space: nowrap;
}

/* ─── ARCHIVE LIST ───────────────────────────────── */
.archive-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  /* No uniform gap — rows breathe differently */
}

/* ─── SKELETON ROWS ──────────────────────────────── */
.skel-row {
  height: 1.4rem;
  background: var(--rule);
  margin-bottom: 2rem;
  opacity: .5;
  animation: pulse 2s ease infinite;
}

.skel-row:nth-child(2) { width: 70%; animation-delay: .15s; }
.skel-row:nth-child(3) { width: 85%; animation-delay: .3s;  }
.skel-row:nth-child(4) { width: 60%; animation-delay: .45s; }
.skel-row:nth-child(5) { width: 75%; animation-delay: .6s;  }

@keyframes pulse {
  0%, 100% { opacity: .25; }
  50%       { opacity: .45; }
}

/* ─── ENTRY ROW ──────────────────────────────────── */
.entry-row {
  display: grid;
  /* date | title | type mark */
  grid-template-columns: 9ch 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 2ch;
  align-items: baseline;

  padding: .9rem 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  position: relative;
  transition: background var(--t);

  /* Prose and poem rows indent differently — set via JS inline style */
  padding-left: var(--row-indent, 0);
}

.entry-row:first-child { border-top: 1px solid var(--rule); }

.entry-row::before {
  /* Typewriter ribbon artifact — subtle left gutter mark */
  content: '';
  position: absolute;
  left: calc(var(--row-indent, 0) - 1.5ch);
  top: 50%;
  transform: translateY(-50%);
  width: 1ch;
  height: 1px;
  background: var(--ink-3);
  opacity: 0;
  transition: opacity var(--t);
}

.entry-row:hover::before { opacity: 1; }

/* Date */
.entry-date {
  grid-column: 1;
  grid-row: 1;
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .04em;
  white-space: nowrap;
  align-self: center;
}

/* Title — the main event */
.entry-title {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--display);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 400;
  color: var(--ink-2);
  line-height: 1.25;
  letter-spacing: .01em;
  transition: color var(--t);
  /* Simulate uneven typewriter key pressure */
  word-spacing: .05em;
}

.entry-row:hover .entry-title { color: var(--ink-1); }

/* Poem titles — italic */
.entry-row[data-type="poem"] .entry-title { font-style: italic; }

/* Type mark */
.entry-type {
  grid-column: 3;
  grid-row: 1;
  font-size: .65rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  align-self: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t);
}

.entry-row:hover .entry-type { opacity: 1; }

/* Peek excerpt — hidden row that reveals on hover */
.entry-peek {
  grid-column: 2 / 4;
  grid-row: 2;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--ink-3);
  max-height: 0;
  overflow: hidden;
  transition: max-height 240ms ease, padding-top 240ms ease, color 240ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-row:hover .entry-peek {
  max-height: 3rem;
  padding-top: .4rem;
  color: var(--ink-2);
}

/* Pinned / unsent markers */
.entry-row.is-pinned .entry-title::before {
  content: '* ';
  color: var(--ink-3);
}

.entry-row.is-unsent .entry-date {
  color: var(--red);
}

/* ─── EMPTY ───────────────────────────────────────── */
.empty-state {
  padding: var(--s5) 0;
  color: var(--ink-3);
  font-size: .9rem;
  font-style: italic;
  letter-spacing: .04em;
}

/* ─── MODAL ──────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8,7,4,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: var(--bg-modal);
  border: 1px solid var(--rule);
  /* Intentionally off-center — like paper not quite aligned */
  margin-left: 3%;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  position: relative;
  transform: translateY(14px) rotate(.15deg);
  transition: transform 200ms ease;
  overflow: hidden;
}

.modal-backdrop.is-open .modal-sheet {
  transform: translateY(0) rotate(.15deg);
}

.modal-close {
  position: absolute;
  top: var(--s2);
  right: var(--s2);
  z-index: 10;
  background: none;
  border: none;
  color: var(--ink-3);
  font-family: var(--type);
  font-size: .78rem;
  letter-spacing: .05em;
  transition: color var(--t);
  padding: .2rem .4rem;
}
.modal-close:hover { color: var(--ink-1); }

.modal-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}

.modal-body {
  padding: var(--s4) var(--s4) var(--s5);
}

/* Modal content styles */
.m-type {
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s2);
  display: block;
}

.m-title {
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 400;
  color: var(--ink-1);
  line-height: 1.15;
  letter-spacing: -.01em;
  margin-bottom: var(--s3);
}

.m-title.is-poem { font-style: italic; }

.m-meta {
  display: flex;
  gap: 2ch;
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .05em;
  margin-bottom: var(--s4);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.m-unsent { color: var(--red); }

.m-content {
  font-size: .98rem;
  line-height: 2;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.m-content.is-poem {
  font-style: italic;
  line-height: 2.2;
  color: var(--ink-1);
  padding-left: 4ch;
  border-left: 1px solid var(--rule);
}

.m-tags {
  margin-top: var(--s4);
  padding-top: var(--s2);
  border-top: 1px solid var(--rule);
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .06em;
}

.m-tags-inner { margin-top: .4rem; }
.m-tag { display: inline; }
.m-tag::after { content: ', '; }
.m-tag:last-child::after { content: ''; }

/* ─── FOOTER ─────────────────────────────────────── */
.site-footer {
  margin-top: var(--s4);
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .06em;
  display: flex;
  gap: var(--s2);
  align-items: center;
}

.footer-rule {
  letter-spacing: .1em;
  opacity: .4;
}

/* ─── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 560px) {
  .page { padding: var(--s3) var(--s2); }

  .masthead-body { flex-direction: column; align-items: flex-start; }
  .masthead-right { text-align: left; }

  .site-title { font-size: clamp(2.4rem, 12vw, 3.5rem); }

  .controls { flex-direction: column; align-items: flex-start; }
  .count-label { margin-left: 0; }

  .entry-row {
    grid-template-columns: 7ch 1fr;
    grid-template-rows: auto auto auto;
  }

  .entry-type {
    grid-column: 2;
    grid-row: 3;
    opacity: 1;
    padding-top: .2rem;
  }

  .entry-peek { grid-column: 1 / 3; white-space: normal; }

  .modal-sheet { margin-left: 0; transform: none; }
  .modal-backdrop.is-open .modal-sheet { transform: none; }
  .modal-body { padding: var(--s3) var(--s2) var(--s5); }
}

/* ─── REDUCED MOTION ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .search-prefix { animation: none; opacity: 1; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}