/* ---------- fonts ---------- */
@font-face {
  font-family: 'iA Writer Quattro';
  src: url('/fonts/iAWriterQuattroV.ttf') format('truetype-variations');
  font-weight: 400 700;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: 'iA Writer Quattro';
  src: url('/fonts/iAWriterQuattroV-Italic.ttf') format('truetype-variations');
  font-weight: 400 700;
  font-style: italic;
  font-display: block;
}

/* ---------- design tokens ---------- */
:root {
  --font-size: 20px;          /* whole px only; A−/A+ adjusts this */
  --line-height: 1.6;
  --measure: 65ch;
  --focus-line: 45vh;         /* keep in sync with FOCUS_LINE in editor.js */
  --bg: #faf9f7;              /* paper white, never #fff */
  --fg: #1a1a18;              /* soft black, never #000 */
  --fg-dim: #8f8d88;
  --accent: #c96342;
  --sidebar-bg: #f1efeb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;            /* near-black, warm */
    --fg: #e8e6e1;            /* warm off-white */
    --fg-dim: #706e69;
    --sidebar-bg: #232220;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; }
html, body { background: var(--bg); color: var(--fg); }
body {
  font-family: 'iA Writer Quattro', system-ui, sans-serif;
  font-kerning: normal;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ---------- editor column ---------- */
main { display: flex; justify-content: center; }
#editor {
  width: min(var(--measure), 100% - 3rem);
  min-height: 100vh;
  padding-top: var(--focus-line);
  padding-bottom: 55vh;                /* room so the last line can sit on the focus line */
  font-size: var(--font-size);
  line-height: var(--line-height);
  hyphens: auto;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  text-wrap: pretty;                   /* engine-level line-break optimization */
  hanging-punctuation: first last;     /* Safari/iPad: optically straight edges */
  font-variant-numeric: oldstyle-nums;
  outline: none;
  caret-color: var(--accent);
}
#editor:empty::before {
  content: attr(data-placeholder);
  color: var(--fg-dim);
}
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- status corner ---------- */
#status {
  position: fixed;
  right: 1.25rem;
  bottom: 1rem;
  font-size: 13px;
  color: var(--fg-dim);
  user-select: none;
}

/* ---------- sidebar ---------- */
#btn-menu {
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 30;
  font: inherit; font-size: 20px; line-height: 1;
  color: var(--fg-dim);
  background: none; border: none; cursor: pointer;
  padding: 0.5rem 0.65rem; border-radius: 6px;
}
#btn-menu:hover { color: var(--fg); }
body.sidebar-open #btn-menu { color: var(--fg); }
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20;
  background: var(--sidebar-bg);
  transform: translateX(-100%);
  transition: transform 160ms ease-out;
  display: flex; flex-direction: column;
  padding: 3.75rem 1rem 1.25rem;   /* top clears the fixed ☰ toggle */
  font-size: 14px;
}
body.sidebar-open #sidebar { transform: translateX(0); }

#sidebar button {
  font: inherit; color: inherit;
  background: none; border: 1px solid var(--fg-dim);
  border-radius: 6px; padding: 0.5rem 0.75rem; cursor: pointer;
}
#sidebar button:hover { border-color: var(--fg); }
#btn-publish { border-color: var(--accent); color: var(--accent); width: 100%; }

#drafts-list { flex: 1; overflow-y: auto; margin-top: 1rem; }
#drafts-list .draft {
  display: block; width: 100%; text-align: left;
  border: none; padding: 0.6rem 0.5rem; border-radius: 6px;
}
#drafts-list .draft:hover { background: color-mix(in srgb, var(--fg) 7%, transparent); }
#drafts-list .draft.current { background: color-mix(in srgb, var(--fg) 12%, transparent); }
#drafts-list .draft .date { color: var(--fg-dim); font-size: 12px; display: block; }
#drafts-list .draft .excerpt {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}

.sidebar-footer { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.font-buttons { display: flex; gap: 0.5rem; }
.font-buttons button { flex: 1; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 3rem; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  padding: 0.6rem 1rem; border-radius: 8px; font-size: 14px;
  max-width: min(90vw, 40rem);
}
#toast a { color: inherit; }
