/* ============================================================================
   Own Protocol — "How It Works"  ·  Theme: FINANCIAL ALMANAC
   Warm ivory paper + deep ink + a single burnt-amber accent.
   Display: Fraunces · Body: Newsreader · Mono/diagrams: IBM Plex Mono.
   ASCII diagrams are treated as dark "terminal" cards — a feature, not raw code.
   Overrides the honkit theme-default. (Color themes toggle on .book.color-theme-*)
   ============================================================================ */

/* Fonts synced with own-finance-v2: Lora (headings), DM Sans (body), JetBrains Mono */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400;1,9..40,500&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ----------------------------------------------------------------- palette */
.book {
  /* === synced with own-finance-v2: dark, neutral, own-orange accent === */
  --paper:        oklch(0.145 0 0);    /* app --background (near-black)      */
  --paper-raised: oklch(0.205 0 0);    /* app --card / sidebar               */
  --paper-deep:   oklch(0.185 0 0);    /* subtle panels                      */
  --ink:          oklch(0.985 0 0);    /* app --foreground (near-white)      */
  --ink-soft:     oklch(0.708 0 0);    /* app --muted-foreground             */
  --ink-faint:    oklch(0.556 0 0);
  --rule:         oklch(1 0 0 / 0.10); /* app --border (white/10%)           */
  --rule-strong:  oklch(1 0 0 / 0.20);
  --accent:       #FE581C;             /* app --own-orange (brand)           */
  --accent-deep:  #ff6f37;             /* brighter for hover on dark         */
  --accent-soft:  #ff8a57;
  --accent-tint:  rgba(254, 88, 28, 0.15);
  --accent-tint2: rgba(254, 88, 28, 0.07);
  --gold:         #F79E0E;             /* app --own-amber (secondary)        */

  /* ASCII-diagram "terminal" card — dark in every mode */
  --term-bg:      oklch(0.12 0 0);
  --term-bg2:     oklch(0.10 0 0);
  --term-fg:      oklch(0.93 0 0);
  --term-accent:  #FE581C;
  --term-rule:    oklch(1 0 0 / 0.10);

  --shadow:       0 1px 2px rgba(0,0,0,.45), 0 18px 44px -20px rgba(0,0,0,.75);
  --shadow-soft:  0 1px 2px rgba(0,0,0,.35), 0 8px 22px -14px rgba(0,0,0,.6);

  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body:    'DM Sans', system-ui, -apple-system, 'Segoe UI', Helvetica, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  background: var(--paper);
  font-family: var(--font-body);
}

/* deep "ink" dark mode (honkit "Night") --------------------------------- */
.book.color-theme-2 {
  --paper:        oklch(0.145 0 0);
  --paper-raised: oklch(0.205 0 0);
  --paper-deep:   oklch(0.185 0 0);
  --ink:          oklch(0.985 0 0);
  --ink-soft:     oklch(0.708 0 0);
  --ink-faint:    oklch(0.556 0 0);
  --rule:         oklch(1 0 0 / 0.10);
  --rule-strong:  oklch(1 0 0 / 0.20);
  --accent:       #FE581C;
  --accent-deep:  #ff6f37;
  --accent-soft:  #ff8a57;
  --accent-tint:  rgba(254, 88, 28, 0.15);
  --accent-tint2: rgba(254, 88, 28, 0.07);
  --term-bg:      oklch(0.10 0 0);
  --term-bg2:     oklch(0.08 0 0);
  --term-fg:      oklch(0.93 0 0);
  --term-rule:    oklch(1 0 0 / 0.10);
}

/* light reading mode (the Aa "Sepia" slot) — clean neutral + orange ----- */
.book.color-theme-1 {
  --paper:        oklch(1 0 0);
  --paper-raised: oklch(0.985 0 0);
  --paper-deep:   oklch(0.965 0 0);
  --ink:          oklch(0.205 0 0);
  --ink-soft:     oklch(0.45 0 0);
  --ink-faint:    oklch(0.6 0 0);
  --rule:         oklch(0.922 0 0);
  --rule-strong:  oklch(0.86 0 0);
  --accent:       #E2480F;
  --accent-deep:  #c23c0a;
  --accent-soft:  #FE581C;
  --accent-tint:  rgba(254, 88, 28, 0.10);
  --accent-tint2: rgba(254, 88, 28, 0.05);
}

/* ----------------------------------------------------------- page surface */
.book,
.book.color-theme-1,
.book.color-theme-2 { background: var(--paper); color: var(--ink); }

.book-body,
.book .book-body { background: transparent; color: var(--ink); }

/* faint paper grain over the reading column for depth */
.book-body .body-inner { background: transparent; }
.book .page-wrapper .page-inner {
  position: relative;
  max-width: 62rem;
  padding: 44px 48px 80px;
}
.book .page-wrapper .page-inner::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------- typography */
.markdown-section {
  font-family: var(--font-body);
  font-size: 1.26rem;
  line-height: 1.66;
  color: var(--ink);
  font-weight: 400;
  position: relative; z-index: 1;
  animation: almanac-rise .55s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes almanac-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.markdown-section p { margin: 0 0 1.15em; }
.markdown-section a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-tint); transition: border-color .15s, color .15s; }
.markdown-section a:hover { color: var(--accent-deep); border-bottom-color: var(--accent); }

/* headings — Fraunces, editorial */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.12;
  border: 0;
}
.markdown-section h1 {
  font-size: 3rem;
  font-weight: 700;
  margin: .1em 0 .7em;
  letter-spacing: -0.02em;
  padding-bottom: .4em;
  position: relative;
}
.markdown-section h1::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 3.2rem; height: 3px; border-radius: 2px;
  background: var(--accent);
}
.markdown-section h2 {
  font-size: 1.82rem;
  margin: 2.1em 0 .7em;
  padding-top: .2em;
}
.markdown-section h3 { font-size: 1.38rem; font-weight: 600; margin: 1.7em 0 .5em; color: var(--ink); }
.markdown-section h4 { font-size: 1.12rem; font-weight: 600; color: var(--ink-soft); text-transform: none; }

/* strong / em */
.markdown-section strong { font-weight: 600; color: var(--ink); }
.markdown-section em { font-style: italic; }

/* drop-cap: the opening paragraph of every chapter */
.markdown-section > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.5em;
  line-height: .82;
  float: left;
  margin: .04em .10em -.02em 0;
  color: var(--accent);
}

/* lists */
.markdown-section ul, .markdown-section ol { margin: 0 0 1.2em; padding-left: 1.3em; }
.markdown-section li { margin: .3em 0; padding-left: .2em; }
.markdown-section ul > li::marker { color: var(--accent); }

/* rules — small centred ornament */
.markdown-section hr {
  border: 0 !important; height: auto !important; background: none !important;
  margin: 2.4em 0 1.6em;
}
.markdown-section hr::before {
  content: "✦"; display: block; text-align: center;
  color: var(--accent-soft); font-size: 14px;
}

/* blockquote (generic) */
.markdown-section blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-tint2);
  color: var(--ink-soft);
  margin: 1.4em 0; padding: .6em 1.1em;
  border-radius: 0 6px 6px 0; font-style: italic;
}

/* ------------------------------------------------- tables (financial report) */
.markdown-section table {
  display: table; width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0; font-size: 1.04rem;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-soft);
  border-radius: 8px; overflow: hidden;
}
.markdown-section table th,
.markdown-section table td {
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: .62em .9em; text-align: left;
}
.markdown-section table thead th {
  background: var(--paper-deep);
  color: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: .76rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--accent);
}
.markdown-section table tbody tr { background: var(--paper-raised); }
.markdown-section table tbody tr:nth-child(even) { background: var(--paper-deep); }
.markdown-section table tbody tr:hover { background: var(--accent-tint); }
.markdown-section table tbody td:first-child { font-weight: 500; color: var(--ink); }

/* --------------------------------------- code + ASCII diagrams (terminal) */
.markdown-section code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--accent-tint);
  color: var(--accent-deep);
  padding: .12em .4em; border-radius: 4px;
}
.book.color-theme-2 .markdown-section code { color: var(--accent-soft); }

.markdown-section pre {
  font-family: var(--font-mono);
  background: var(--term-bg);
  background-image: linear-gradient(180deg, var(--term-bg) 0%, var(--term-bg2) 100%);
  color: var(--term-fg);
  border: 1px solid var(--term-rule);
  border-radius: 10px;
  padding: 2.1em 1.4em 1.4em;
  margin: 1.8em 0;
  overflow-x: auto;
  position: relative;
  box-shadow: var(--shadow);
  line-height: 1.5;
}
/* faux "window" dots + label so diagrams read as intentional schematics */
.markdown-section pre::before {
  content: "";
  position: absolute; top: 13px; left: 16px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #d2543f;
  box-shadow: 16px 0 0 #e0a45a, 32px 0 0 #6fae5f;
}
.markdown-section pre::after {
  content: "SCHEMATIC";
  position: absolute; top: 11px; right: 16px;
  font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .22em; color: var(--ink-faint);
  opacity: .75;
}
.markdown-section pre code {
  background: transparent; color: inherit;
  padding: 0; font-size: .9rem; border-radius: 0;
  white-space: pre;
}

/* =================================================================== */
/*  CALLOUTS                                                            */
/*  Recap  =  h2#what-just-happened  +  the <ul> right after it         */
/*  Go deeper = the <p> right after that recap list                     */
/* =================================================================== */

/* "What just happened" — recap card header */
.markdown-section h2#what-just-happened {
  font-family: var(--font-mono);
  font-size: .88rem !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent-deep);
  background: var(--accent-tint);
  margin: 2.6em 0 0 !important;
  padding: .85em 1.2em .8em 2.7em;
  border: 1px solid var(--rule-strong);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  position: relative;
}
.book.color-theme-2 .markdown-section h2#what-just-happened { color: var(--accent-soft); }
.markdown-section h2#what-just-happened::before {
  content: "❦";
  position: absolute; left: 1.05em; top: 50%; transform: translateY(-50%);
  font-size: 1.15rem; color: var(--accent);
}
.markdown-section h2#what-just-happened::after { display: none; }

/* recap body — the bullet list immediately after */
.markdown-section h2#what-just-happened + ul {
  margin: 0 0 1.4em !important;
  padding: 1.05em 1.4em 1.05em 2.7em;
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-soft);
  font-size: 1.12rem;
  color: var(--ink-soft);
}
.markdown-section h2#what-just-happened + ul > li { margin: .42em 0; }
.markdown-section h2#what-just-happened + ul > li::marker { color: var(--accent); }

/* "Go deeper" — the paragraph right after the recap list */
/* (Go-deeper callouts removed: the book no longer references the technical docs.) */

/* the closing disclaimer (em block after the final hr) */
.markdown-section hr + p { font-size: 14px; line-height: 1.55; color: var(--ink-faint); margin-top: 1.4em; }
.markdown-section hr + p em { color: var(--ink-faint); font-style: italic; }

/* ====================================================== SIDEBAR / SUMMARY */
.book-summary {
  background: var(--paper-raised);
  border-right: 1px solid var(--rule);
  font-family: var(--font-body);
  color: var(--ink-soft);
}
.book-summary ul.summary { padding: 8px 0 40px; }
.book-summary ul.summary li a {
  color: var(--ink-soft);
  font-size: .94rem;
  padding: 7px 16px 7px 22px;
  font-weight: 400;
  transition: color .14s, background .14s;
}
.book-summary ul.summary li a:hover { color: var(--accent-deep); background: var(--accent-tint2); }
.book-summary ul.summary li.active > a {
  color: var(--accent-deep);
  font-weight: 600;
  background: var(--accent-tint);
  border-right: 2px solid var(--accent);
}
.book.color-theme-2 .book-summary ul.summary li.active > a { color: var(--accent-soft); }

/* part headers ("## Part 1 — …") */
.book-summary ul.summary li.header {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .66rem;
  font-weight: 600;
  color: var(--accent);
  padding: 22px 16px 8px 22px;
  margin-top: 6px;
  border-top: 1px solid var(--rule);
}
.book-summary ul.summary li.header:first-child { border-top: 0; }

/* the "Introduction"/divider tweaks */
.book-summary ul.summary li.divider { background: var(--rule); }

/* search box */
#book-search-input {
  background: var(--paper-raised) !important;
  border-bottom: 1px solid var(--rule);
  padding: 12px 14px;
}
.book-summary .search-input,
#book-search-input input,
.book-summary input {
  background: var(--paper-deep) !important;
  border: 1px solid var(--rule-strong) !important;
  color: var(--ink) !important;
  border-radius: 8px;
  font-family: var(--font-body);
  box-shadow: none !important;
}
#book-search-input input::placeholder { color: var(--ink-faint); }
.book-search-results .search-results .has-results .search-results-item { border-bottom: 1px solid var(--rule); }

/* ============================================================= TOP HEADER */
.book-header {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  border-bottom: 1px solid transparent;
}
.book-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .02em;
  opacity: 0;          /* honkit shows page title on scroll; keep it quiet  */
}
.book-header .btn { color: var(--ink-faint); }
.book-header .btn:hover { color: var(--accent); }
.book.color-theme-2 .book-header .btn:hover { color: var(--accent-soft); }

/* page navigation arrows (prev/next) */
.book .navigation { color: var(--accent); }
.book .navigation:hover { color: var(--accent-deep); }
.book.color-theme-2 .book .navigation:hover { color: var(--accent-soft); }

/* ============================================================ MISC POLISH */
::selection { background: var(--accent); color: var(--paper); }

/* scrollbar */
.book-summary::-webkit-scrollbar, .book-body .body-inner::-webkit-scrollbar { width: 10px; height: 10px; }
.book ::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 6px; border: 2px solid var(--paper); }
.book ::-webkit-scrollbar-thumb:hover { background: var(--accent-soft); }
.book ::-webkit-scrollbar-track { background: transparent; }

/* honkit font-settings button list — keep it on-palette */
.dropdown-menu { background: var(--paper-raised); border: 1px solid var(--rule-strong); box-shadow: var(--shadow); }
.dropdown-menu .buttons .button { color: var(--ink-soft); }
.dropdown-menu .buttons .button:hover { color: var(--accent); }

/* tighten the default theme's heavy link/heading borders we don't want */
.markdown-section h1, .markdown-section h2 { border-bottom: 0 !important; }

/* responsive: relax the drop-cap and padding on small screens */
@media (max-width: 600px) {
  .markdown-section { font-size: 1.14rem; }
  .markdown-section h1 { font-size: 2.3rem; }
  .book .page-wrapper .page-inner { padding: 28px 18px 48px; }
}

/* =================================================================== */
/*  THEME OVERRIDES — honkit's theme-default ships high-specificity     */
/*  `.book.color-theme-N X` rules for Sepia(1)/Night(2). Re-assert our   */
/*  palette at matching specificity so the almanac wins in every mode.   */
/* =================================================================== */
.book.color-theme-1, .book.color-theme-2 { background: var(--paper); color: var(--ink); }
.book.color-theme-1 .book-body, .book.color-theme-2 .book-body { background: var(--paper); color: var(--ink); }
.book.color-theme-1 .book-body .page, .book.color-theme-2 .book-body .page,
.book.color-theme-1 .book-body .body-inner, .book.color-theme-2 .book-body .body-inner { background: transparent; }

.book.color-theme-1 .markdown-section, .book.color-theme-2 .markdown-section { color: var(--ink); }
.book.color-theme-1 .markdown-section p, .book.color-theme-2 .markdown-section p,
.book.color-theme-1 .markdown-section li, .book.color-theme-2 .markdown-section li { color: var(--ink); }
.book.color-theme-1 .markdown-section a, .book.color-theme-2 .markdown-section a { color: var(--accent); }
.book.color-theme-1 .markdown-section a:hover, .book.color-theme-2 .markdown-section a:hover { color: var(--accent-soft); }
.book.color-theme-1 .markdown-section h1, .book.color-theme-2 .markdown-section h1,
.book.color-theme-1 .markdown-section h2, .book.color-theme-2 .markdown-section h2,
.book.color-theme-1 .markdown-section h3, .book.color-theme-2 .markdown-section h3,
.book.color-theme-1 .markdown-section h4, .book.color-theme-2 .markdown-section h4 { color: var(--ink); }
.book.color-theme-1 .markdown-section strong, .book.color-theme-2 .markdown-section strong { color: var(--ink); }

/* keep the ASCII "schematic" cards dark in every theme */
.book.color-theme-1 .markdown-section pre, .book.color-theme-2 .markdown-section pre {
  background: var(--term-bg); color: var(--term-fg); border-color: var(--term-rule);
}
.book.color-theme-1 .markdown-section pre code, .book.color-theme-2 .markdown-section pre code { color: var(--term-fg); background: transparent; }
.book.color-theme-1 .markdown-section code, .book.color-theme-2 .markdown-section code { background: var(--accent-tint); color: var(--accent-soft); }

/* tables */
.book.color-theme-1 .markdown-section table th, .book.color-theme-2 .markdown-section table th,
.book.color-theme-1 .markdown-section table td, .book.color-theme-2 .markdown-section table td { border-bottom-color: var(--rule); }
.book.color-theme-1 .markdown-section table tbody tr, .book.color-theme-2 .markdown-section table tbody tr { background: var(--paper-raised); }
.book.color-theme-1 .markdown-section table tbody tr:nth-child(even), .book.color-theme-2 .markdown-section table tbody tr:nth-child(even) { background: var(--paper-deep); }
.book.color-theme-1 .markdown-section table thead th,
.book.color-theme-2 .markdown-section table thead th { background: var(--paper-deep); color: var(--accent-soft); border-bottom: 1px solid var(--accent); }

/* sidebar */
.book.color-theme-1 .book-summary, .book.color-theme-2 .book-summary { background: var(--paper-raised); color: var(--ink-soft); border-right-color: var(--rule); }
.book.color-theme-1 .book-summary ul.summary li a, .book.color-theme-2 .book-summary ul.summary li a { color: var(--ink-soft); }
.book.color-theme-1 .book-summary ul.summary li a:hover, .book.color-theme-2 .book-summary ul.summary li a:hover { color: var(--accent-soft); background: var(--accent-tint2); }
.book.color-theme-1 .book-summary ul.summary li.active > a, .book.color-theme-2 .book-summary ul.summary li.active > a { color: var(--accent-soft); background: var(--accent-tint); }
.book.color-theme-1 .book-summary ul.summary li.header, .book.color-theme-2 .book-summary ul.summary li.header { color: var(--accent); border-top-color: var(--rule); }
.book.color-theme-1 .book-summary ul.summary li.divider, .book.color-theme-2 .book-summary ul.summary li.divider { background: var(--rule); }

/* header */
.book.color-theme-1 .book-header, .book.color-theme-2 .book-header { background: transparent; color: var(--ink-soft); box-shadow: none; }

/* =================================================================== */
/*  SIZING LAYER — honkit's root font-size is 62.5% (1rem = 10px), and  */
/*  the fontsettings plugin sets body size via `.book.font-size-N`       */
/*  rules. Size the reading experience in px here so it isn't tiny and   */
/*  the column fills the page; this layer wins (loaded last, matched     */
/*  specificity) over both rem rounding and the plugin defaults.         */
/* =================================================================== */
.book .page-wrapper .page-inner { max-width: 1060px; padding: 48px 56px 88px; }

/* body — keep the Aa size toggle working, just larger at every step */
.book .book-body .page-inner section.markdown-section { font-size: 20px !important; }
.markdown-section { line-height: 1.62; }
.markdown-section p { margin-bottom: 1.05em; }

/* headings */
.markdown-section h1 { font-size: 44px; }
.markdown-section h2 { font-size: 29px; margin-top: 1.9em; }
.markdown-section h3 { font-size: 22px; }
.markdown-section h4 { font-size: 17px; }

/* tables, diagrams, inline code */
.markdown-section table { font-size: 17px; }
.markdown-section table thead th { font-size: 12.5px; }
.markdown-section table th, .markdown-section table td { padding: .7em 1em; }
.markdown-section pre { padding: 2.2em 1.6em 1.5em; }
.markdown-section pre code { font-size: 15px; line-height: 1.5; }

/* callouts */
.markdown-section h2#what-just-happened { font-size: 14px !important; padding: 1em 1.3em 1em 3em; }
.markdown-section h2#what-just-happened::before { font-size: 1.4rem; }
.markdown-section h2#what-just-happened + ul { font-size: 18px; padding: 1.2em 1.5em 1.2em 3em; }

/* sidebar — nudge up from the cramped default */
.book .book-summary ul.summary li a { font-size: 15.5px; padding-top: 8px; padding-bottom: 8px; }
.book .book-summary ul.summary li.header { font-size: 11px; }
#book-search-input input, .book-summary .search-input { font-size: 15px; }
