/* Binder — phone and desktop.
 *
 * Palette and type follow the documents Dan already had: navy headings, gold
 * accents, cream callouts, Georgia body against Arial headings. The point is
 * that the site reads like the PDFs he was printing, not like a wiki.
 */

:root {
  --ground:      #f4f5f7;
  --surface:     #ffffff;
  --ink:         #1a1a1a;
  --muted:       #5f6875;
  --hairline:    #d7dce2;

  --navy:        #0f2540;   /* headings, table header bar */
  --navy-soft:   #f2f4f7;   /* zebra rows, quiet panels */
  --gold:        #b8860b;   /* rules, accents */
  --gold-deep:   #7a5c00;   /* text on cream */
  --cream:       #fdf8ec;   /* callouts */
  --cream-edge:  #e0cd9a;

  --danger:      #8a1c1c;
  --danger-bg:   #fbeee9;
  --code-bg:     #eef0f3;
  --table-border:#9aa3ad;

  --sans:  Arial, Helvetica, system-ui, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono:  ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:      #12161c;
    --surface:     #191f27;
    --ink:         #e6e9ee;
    --muted:       #99a3b0;
    --hairline:    #2a323c;

    --navy:        #a8c4e6;   /* navy inverts to a light blue; the role survives */
    --navy-soft:   #1d2530;
    --gold:        #d9a94a;
    --gold-deep:   #e8c579;
    --cream:       #241f13;
    --cream-edge:  #4a3d1c;

    --danger:      #e8845e;
    --danger-bg:   #2c1811;
    --code-bg:     #1e242d;
    --table-border:#39424e;
  }
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 11px max(16px, env(safe-area-inset-left)) 11px max(16px, env(safe-area-inset-right));
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 10;
}
@media (prefers-color-scheme: dark) {
  .topbar { background: #101822; }
}
.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: #fff;
  font-size: 17px;
}
@media (prefers-color-scheme: dark) { .brand { color: var(--navy); } }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a {
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  padding: 3px 0;
  border-bottom: 2px solid transparent;
  font-size: 15px;
}
.topbar nav a.on { color: #fff; border-bottom-color: var(--gold); }
.topbar nav a:hover { color: #fff; }
.signout { margin: 0; }
.signout button {
  background: none; border: 0; color: rgba(255,255,255,0.66);
  font: inherit; font-size: 14px; cursor: pointer; padding: 4px;
}
.signout button:hover { color: #fff; filter: none; }

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

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 30px max(16px, env(safe-area-inset-left)) 90px max(16px, env(safe-area-inset-right));
}
.wrap.narrow { max-width: 380px; padding-top: 12vh; }

.page-title {
  font-family: var(--sans);
  font-size: 27px;
  color: var(--navy);
  letter-spacing: -0.01em;
  margin: 0 0 5px;
  text-wrap: balance;
}
.count { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.empty { color: var(--muted); max-width: 52ch; }
.backlink { margin-top: 44px; }

a { color: var(--gold-deep); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { a { color: var(--gold); } }

.flash { padding: 10px 14px; border-radius: 5px; font-size: 15px; margin: 0 0 16px; }
.flash.error { background: var(--danger-bg); color: var(--danger); border-left: 4px solid var(--danger); }

button, .button {
  font: inherit;
  font-weight: 700;
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 11px 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
@media (prefers-color-scheme: dark) { button, .button { background: #24405f; color: #eaf1fa; } }
button:hover, .button:hover { filter: brightness(1.15); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- capture */

.capture { display: flex; flex-direction: column; gap: 10px; margin-bottom: 34px; }
.capture textarea {
  width: 100%;
  font-family: var(--serif);
  font-size: 17px;           /* >=16px stops iOS zooming on focus */
  line-height: 1.5;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--navy);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
.capture button { align-self: flex-start; padding-inline: 30px; }

.thoughts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.thoughts li {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--gold);
  border-radius: 3px;
  padding: 14px 16px;
}
.thought-body { font-family: var(--serif); font-size: 16.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.thought-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 10px; color: var(--muted); font-size: 13px;
}
.thought-meta form { margin: 0; }
button.link {
  background: none; color: var(--muted); padding: 2px 5px;
  font-size: 13px; font-weight: 400; border-radius: 3px;
}
button.link:hover { color: var(--gold-deep); filter: none; }

/* ------------------------------------------------------------------ signin */

.signin { display: flex; flex-direction: column; gap: 6px; }
.signin label {
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-top: 12px; font-weight: 700;
}
.signin input {
  font: inherit; font-size: 17px; padding: 11px 13px;
  border: 1px solid var(--hairline); border-radius: 4px;
  background: var(--surface); color: var(--ink);
}
.signin .hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.signin button { margin-top: 24px; }

/* -------------------------------------------------------------- doc lists */

.doc-section { margin-bottom: 32px; }
.doc-section h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--gold-deep); margin: 0 0 8px; padding-bottom: 6px;
  border-bottom: 2px solid var(--navy); font-weight: 700;
}
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { padding: 9px 0; border-bottom: 1px solid var(--hairline); }
.doc-list li:last-child { border-bottom: 0; }
.doc-link { font-weight: 700; text-decoration: none; display: block; color: var(--navy); font-size: 16px; }
.doc-link:hover { color: var(--gold-deep); }
@media (prefers-color-scheme: dark) { .doc-link:hover { color: var(--gold); } }
.doc-path { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }

.doc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
  border-bottom: 3px solid var(--navy); padding-bottom: 14px; margin-bottom: 8px;
}

/* ------------------------------------------------------------- doc content */

.doc-body {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  margin-top: 28px;
}
.doc-body > *:first-child { margin-top: 0; }

.doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4, .doc-body h5, .doc-body h6 {
  font-family: var(--sans);
  color: var(--navy);
  line-height: 1.28;
  text-wrap: balance;
}
.doc-body h1 {
  font-size: 25px; margin: 1.9em 0 0.5em;
  border-bottom: 3px solid var(--navy); padding-bottom: 7px;
}
.doc-body h2 {
  font-size: 20px; margin: 1.7em 0 0.45em;
  border-bottom: 1px solid var(--hairline); padding-bottom: 4px;
}
.doc-body h3 { font-size: 17px; margin: 1.5em 0 0.35em; }
.doc-body h4 { font-size: 15px; margin: 1.3em 0 0.3em; color: var(--gold-deep); }

.doc-body p { margin: 0.85em 0; overflow-wrap: break-word; }
.doc-body ul, .doc-body ol { padding-left: 24px; margin: 0.85em 0; }
.doc-body li { margin-bottom: 6px; overflow-wrap: break-word; }
.doc-body strong { color: var(--navy); }
@media (prefers-color-scheme: dark) { .doc-body strong { color: #cfe0f5; } }

/* Blockquotes read as the callouts these documents already use. */
.doc-body blockquote {
  margin: 1.3em 0;
  padding: 12px 18px;
  background: var(--cream);
  border-left: 4px solid var(--gold);
  border-radius: 0 3px 3px 0;
  color: var(--ink);
}
.doc-body blockquote > *:first-child { margin-top: 0; }
.doc-body blockquote > *:last-child { margin-bottom: 0; }
.doc-body blockquote strong { color: var(--gold-deep); }

.doc-body code {
  font-family: var(--mono); font-size: 0.83em;
  background: var(--code-bg); padding: 1px 5px; border-radius: 2px;
  overflow-wrap: anywhere;
}
.doc-body pre {
  background: var(--code-bg);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--navy);
  padding: 13px 16px; border-radius: 3px;
  overflow-x: auto; font-size: 13.5px; line-height: 1.55;
}
.doc-body pre code { background: none; padding: 0; font-size: inherit; }

/* Tables carry a lot of these documents, so they get the full treatment:
   navy header bar, zebra rows, real borders. Scrolling happens on the wrapper
   so the table itself stays a table. */
.table-wrap { overflow-x: auto; margin: 1.2em 0; }
.doc-body table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.45;
}
.doc-body th, .doc-body td {
  border: 1px solid var(--table-border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.doc-body th {
  background: var(--navy);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
@media (prefers-color-scheme: dark) {
  .doc-body th { background: #1c2b3f; color: #dce7f4; }
}
.doc-body tbody tr:nth-child(even) td { background: var(--navy-soft); }

.doc-body img { max-width: 100%; height: auto; }
.doc-body hr { border: 0; border-top: 2px solid var(--hairline); margin: 2.2em 0; }

/* Deep-linking to a paragraph marks it. */
.doc-body :target {
  background: var(--cream);
  box-shadow: -6px 0 0 var(--gold);
  border-radius: 2px;
  scroll-margin-top: 78px;
}

@media (max-width: 540px) {
  .topbar { gap: 13px; }
  .doc-body { font-size: 17px; }
  .doc-body table { font-size: 13.5px; }
  .doc-body th, .doc-body td { padding: 6px 8px; }
  .page-title { font-size: 23px; }
  .wrap { padding-top: 22px; }
}

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