/* AboutMe — screen styles.
   A private notebook: warm paper, fountain-pen blue, and answers written on
   ruled lines rather than typed into boxes. Sized for a reader in their
   seventies or eighties, so the base is 18px and contrast stays high. */

:root {
  --paper: #fbfbfa;
  --paper-raised: #ffffff;
  --ink: #16161a;
  --ink-2: #55555c;
  --ink-faint: #8a8a92;
  --rule: #dcdcd8;
  --rule-soft: #ebebe7;
  --accent: #1f3a5f;
  --accent-2: #2f5b8f;
  --accent-wash: #e7ebf1;
  --danger: #8f2f24;

  --display: "Bodoni Moda", "Didot", "Playfair Display", Georgia, serif;
  --sans: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --book-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  --line-height: 34px;   /* must match the ruled-paper gradient period */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131316;
    --paper-raised: #1a1a1e;
    --ink: #e8e8ea;
    --ink-2: #a8a8b0;
    --ink-faint: #75757d;
    --rule: #2c2c32;
    --rule-soft: #232328;
    --accent: #8fb6e0;
    --accent-2: #a9c8ea;
    --accent-wash: #1c242f;
    --danger: #e08a7c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--paper-raised); padding: .7rem 1.1rem; z-index: 30; }
.skip-link:focus { left: .5rem; top: .5rem; }

/* --- chrome ------------------------------------------------------------ */

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.topbar {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .9rem 1.5rem;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--display); font-weight: 500; font-size: 1.4rem; letter-spacing: .01em; }
.brand-text small { color: var(--ink-faint); font-size: .8rem; }

.topbar-actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }

.save-status { font-size: .85rem; color: var(--ink-faint); min-height: 1.2em; }
.save-status.is-error, .save-status.is-unavailable { color: var(--danger); max-width: 24rem; }

.btn {
  font: inherit;
  font-size: .95rem;
  font-weight: 500;
  padding: .55rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .35; cursor: default; }
.btn-primary,
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); }
.btn-danger { border-color: var(--danger); color: var(--danger); }

.progress-strip { max-width: 1140px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem .8rem; }
.progress-track { flex: 1; height: 2px; background: var(--rule-soft); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.progress-label { font-size: .82rem; color: var(--ink-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- layout ------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 3.5rem;
  max-width: 1140px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6rem;
  align-items: start;
}

.sidebar { position: sticky; top: 7rem; min-width: 0; }
.sidebar-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--ink-faint);
  font-weight: 600;
  margin: 0 0 .9rem;
}
.chapter-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.chapter-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .6rem;
  width: 100%;
  font: inherit;
  font-size: .97rem;
  text-align: left;
  padding: .4rem 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}
.chapter-link:hover { color: var(--accent); }
.chapter-link.is-current { color: var(--ink); font-weight: 600; }
.chapter-link-count { font-size: .8rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.chapter-link.is-complete .chapter-link-count { color: var(--accent); }
.sidebar-note { margin: 1.5rem 0 0; font-size: .84rem; line-height: 1.55; color: var(--ink-faint); }

.main { min-width: 0; max-width: 42rem; }

/* --- marks -------------------------------------------------------------- */

/* The book's chapter marks ship in two inks and CSS shows one. The book page
   stays paper-coloured in both themes, so it always wants the dark variant —
   which is also what print needs. */
img.is-dark { display: none; }

/* --- chapter ------------------------------------------------------------ */

.chapter-header { margin-bottom: 3rem; }
.chapter-eyebrow {
  margin: 0;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 600;
  color: var(--ink-faint);
}
.chapter-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -.015em;
  margin: .5rem 0 .6rem;
  text-wrap: balance;
}
.chapter-blurb { margin: 0; color: var(--ink-2); font-size: 1.1rem; max-width: 46ch; }

/* --- questions ---------------------------------------------------------- */

.question { padding: 2.25rem 0 2.75rem; border-bottom: 1px solid var(--rule-soft); }
.question:first-of-type { border-top: 1px solid var(--rule-soft); }

.question-prompt {
  display: block;
  font-size: 1.28rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  text-wrap: pretty;
}
.question-hint { margin: .45rem 0 0; font-size: .98rem; color: var(--ink-faint); max-width: 54ch; }

.question-input {
  display: block;
  width: 100%;
  margin-top: 1.1rem;
  font-family: inherit;
  font-size: 1.15rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  resize: none;
  overflow: hidden;
}
.question-input::placeholder { color: var(--ink-faint); }

/* A one-line answer rests on a single rule. */
input.question-input {
  line-height: var(--line-height);
  height: var(--line-height);
  padding: 0;
  border-bottom: 1px solid var(--rule);
}
input.question-input:focus { border-bottom-color: var(--accent); outline: none; }

/* A long answer is written across ruled paper — the gradient period and the
   line-height have to stay identical or the text drifts off the lines. */
textarea.question-input {
  line-height: var(--line-height);
  padding: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(var(--line-height) - 1px),
    var(--rule-soft) calc(var(--line-height) - 1px),
    var(--rule-soft) var(--line-height)
  );
  background-attachment: local;
}
textarea.question-input:focus { outline: none; }

/* Answered state is carried by the rule under the answer — one signal, not two. */
.question.is-answered textarea.question-input:focus,
.question.is-answered input.question-input { border-bottom-color: var(--accent); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
}
.pager-label { font-family: var(--display); color: var(--ink-faint); font-size: 1.05rem; }

/* --- dialog ------------------------------------------------------------- */

.dialog {
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0;
  width: min(32rem, calc(100vw - 2rem));
}
.dialog::backdrop { background: rgba(15, 14, 12, .5); }
.dialog-form { padding: 2rem; }
.dialog-form h2 { font-family: var(--display); font-weight: 500; margin: 0 0 .3rem; font-size: 1.9rem; }
.dialog-blurb { margin: 0 0 1.75rem; color: var(--ink-faint); font-size: .92rem; }

.field { display: block; margin-bottom: 1.5rem; }
.field-label { display: block; font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .45rem; }
.field-label small { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-faint); }
.field input, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: .4rem 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-bottom-color: var(--accent); outline: none; }

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-soft);
}
.danger-zone strong { font-size: .92rem; }
.danger-zone p { margin: .25rem 0 0; font-size: .84rem; color: var(--ink-faint); max-width: 28ch; }
.dialog-actions { display: flex; justify-content: flex-end; }

/* --- the book ----------------------------------------------------------- */

body.is-previewing .sticky-head,
body.is-previewing .layout { display: none; }

.book-view { max-width: 54rem; margin: 0 auto; padding: 1.5rem 1.5rem 6rem; }
.book-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .9rem 0;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.toggle { display: flex; align-items: center; gap: .45rem; font-size: .92rem; color: var(--ink-2); }
.book-hint { margin: 1.25rem 0 1.75rem; font-size: .88rem; line-height: 1.6; color: var(--ink-faint); }

/* The page keeps its paper colouring in both themes — it is a print preview. */
.book {
  background: #fdfcf8;
  color: #1c1a16;
  border: 1px solid var(--rule);
  padding: 4rem clamp(1.5rem, 7vw, 5rem);
  font-family: var(--book-serif);
  font-size: 1.1rem;
  line-height: 1.7;
}
.book-empty { color: #6b6157; font-style: italic; text-align: center; margin: 2rem 0; }

.book-titlepage { text-align: center; padding: 3rem 0 4rem; }
.book-title { font-family: var(--display); font-weight: 500; font-size: 3rem; line-height: 1.1; margin: 0 0 1rem; }
.book-byline { margin: 0; font-size: 1.15rem; font-style: italic; color: #4a423a; }
.book-dedication { margin: 3rem auto 0; max-width: 26rem; font-style: italic; color: #4a423a; }
.book-dedication p { margin: .3rem 0; }
.book-stamp { margin: 3rem 0 0; font-family: var(--sans); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: #8b7f74; }

.book-contents { padding: 2.5rem 0; border-top: 1px solid #e0d8cb; border-bottom: 1px solid #e0d8cb; }
.book-contents h2 { font-family: var(--sans); font-size: .78rem; letter-spacing: .18em; text-transform: uppercase; font-weight: 600; margin: 0 0 1.25rem; }
.book-contents ol { margin: 0; padding-left: 1.5rem; }
.book-contents li { margin-bottom: .4rem; }

.book-chapter { padding: 3.5rem 0 1rem; }
.book-mark { display: block; width: 44px; height: 44px; margin-bottom: 1rem; }
.book-chapter-number { font-family: var(--sans); margin: 0; font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; color: #8b7f74; }
.book-chapter-title { font-family: var(--display); font-weight: 500; font-size: 2.1rem; margin: .35rem 0 2rem; }

.book-entry { margin-bottom: 2rem; }
.book-entry-prompt { margin: 0 0 .6rem; font-family: var(--sans); font-size: .92rem; color: #6b6157; }
.book.hide-prompts .book-entry-prompt { display: none; }
.book-entry-text { margin: 0 0 .8rem; }

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .sidebar { position: static; }
  .chapter-nav { flex-direction: row; overflow-x: auto; overscroll-behavior-x: contain; gap: 1.25rem; }
  .chapter-link { width: auto; white-space: nowrap; border-bottom: 2px solid transparent; }
  .chapter-link.is-current { border-bottom-color: var(--accent); }
  .sidebar-note { display: none; }
  .book { padding: 2rem 1.25rem; }
  .book-title { font-size: 2.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
