/* ===========================================================
   FinanceWithoutFluff — design tokens
   Concept: a bank ledger / register receipt. Warm paper, ink,
   a single rubber-stamp red for emphasis, typewriter display
   type, tabular mono for every number that matters.
   =========================================================== */

/* Fonts are loaded via <link rel="stylesheet"> in each page's <head>
   (with preconnect) rather than a render-blocking @import here. */

:root {
  --ink:        #211E1A;   /* near-black warm ink, body text */
  --ink-soft:   #4A453B;   /* muted ink for secondary text — meets WCAG AA on paper */
  --paper:      #F1EEE3;   /* warm paper background */
  --paper-alt:  #E8E3D3;   /* slightly deeper paper, panels */
  --rule:       #B9B29C;   /* dotted rule / hairline color */
  --stamp:      #A8342A;   /* rubber-stamp red, the one accent */
  --stamp-dim:  #A8342A22; /* translucent stamp for washes */
  --ledger:     #2F5233;   /* deep ledger green, positive figures */
  --paper-shadow: 0 1px 0 rgba(33,30,26,0.06);

  --font-display: 'Special Elite', 'Courier New', monospace;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --radius: 2px;
  --max-width: 720px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background-image:
    linear-gradient(var(--paper) 0%, var(--paper) 100%);
}

/* subtle paper fiber texture without external images */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image:
    repeating-linear-gradient(0deg, #000 0px, transparent 1px, transparent 3px);
  z-index: 0;
}

a { color: var(--stamp); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

img { max-width: 100%; display: block; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ---------------- Masthead (styled like a receipt header) ---------------- */

.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 28px 0 18px;
}

.masthead-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--stamp); }

.masthead-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

nav.tape {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

nav.tape a {
  color: var(--ink);
  text-decoration: none;
  padding: 4px 14px;
  border-right: 1px dotted var(--rule);
}
nav.tape a:last-child { border-right: none; }
nav.tape a:hover { color: var(--stamp); }
nav.tape a.current { color: var(--stamp); font-weight: 600; }

.nav-toggle {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  background: none;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 14px 20px 0;
  cursor: pointer;
  color: var(--ink);
}
.nav-toggle:hover { color: var(--stamp); border-color: var(--stamp); }
.nav-toggle[aria-expanded="true"] { color: var(--stamp); border-color: var(--stamp); }

@media (max-width: 680px) {
  .nav-toggle { display: inline-block; }
  nav.tape {
    display: none;
    flex-direction: column;
    gap: 0;
    margin-top: 10px;
    border-top: 1px dashed var(--rule);
  }
  nav.tape.is-open { display: flex; }
  nav.tape a {
    padding: 12px 4px;
    border-right: none;
    border-bottom: 1px dotted var(--rule);
  }
}

/* ---------------- Hero ---------------- */

.hero {
  padding: 56px 0 40px;
  border-bottom: 1px dashed var(--rule);
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stamp);
  margin: 0 0 12px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.15;
  margin: 0 0 18px;
  max-width: 14ch;
}

.hero p.lede {
  font-size: 1.08rem;
  max-width: 52ch;
  color: var(--ink);
  opacity: 0.85;
}

.receipt-stub {
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink);
  opacity: 0.55;
  border-top: 1px dotted var(--rule);
  padding-top: 10px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

/* ---------------- Sections ---------------- */

section { padding: 44px 0; border-bottom: 1px dashed var(--rule); }
section:last-of-type { border-bottom: none; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
}

.section-head .see-all {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ---------------- Cards / line items ---------------- */

.line-items { border-top: 1px solid var(--ink); }

.line-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px dotted var(--rule);
  text-decoration: none;
  color: var(--ink);
}

.line-item:hover .line-item-title { color: var(--stamp); }

.line-item-title {
  font-weight: 600;
  font-size: 1.02rem;
}

.line-item-desc {
  grid-column: 1 / -1;
  font-size: 0.92rem;
  color: var(--ink-soft);
  max-width: 56ch;
}

.line-item-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  align-self: center;
}

/* ---------------- Calculator card ---------------- */

.calc-card {
  background: var(--paper-alt);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--paper-shadow);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 18px;
}

.field-row label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-row .hint {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: normal;
}

.field-row input, .field-row select {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}

button.stamp-btn {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--stamp);
  color: var(--paper);
  border: none;
  border-radius: var(--radius);
  padding: 13px 22px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.08s ease, background 0.15s ease;
}
button.stamp-btn:hover { background: #8c2b23; }
button.stamp-btn:active { transform: scale(0.99); }

/* ---------------- Receipt output (the signature element) ---------------- */

.receipt {
  margin-top: 28px;
  background: #FAF8F0;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  position: relative;
  display: none;
}
.receipt.is-visible { display: block; animation: unfurl 0.35s ease; }

@keyframes unfurl {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.receipt-head {
  text-align: center;
  padding: 18px 20px 12px;
  border-bottom: 1px dashed var(--ink);
}
.receipt-head .stamp-mark {
  display: inline-block;
  border: 2px solid var(--stamp);
  color: var(--stamp);
  padding: 3px 10px;
  transform: rotate(-3deg);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  margin-bottom: 8px;
}

.receipt-body { padding: 14px 20px; }

.receipt-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
}
.receipt-line .val { text-align: right; }

.receipt-line.total {
  border-top: 1px dashed var(--ink);
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 600;
  font-size: 1.05rem;
}
.receipt-line.total .val { color: var(--stamp); }

.receipt-foot {
  text-align: center;
  padding: 12px 20px 20px;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

/* torn edge */
.receipt-tear {
  height: 10px;
  background:
    linear-gradient(135deg, var(--paper) 50%, transparent 50%) 0 0/10px 10px repeat-x,
    linear-gradient(-135deg, var(--paper) 50%, transparent 50%) 0 0/10px 10px repeat-x;
  background-color: #FAF8F0;
}

/* ---------------- Ad slot ---------------- */

.ad-slot {
  margin: 8px 0;
  padding: 10px;
  border: 1px dashed var(--rule);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------------- Footer ---------------- */

footer {
  padding: 30px 0 50px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
}
footer a { color: var(--ink); }

/* ---------------- Blog ---------------- */

.article-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.prose h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-top: 2em;
}
.prose p { margin: 1em 0; }
.prose ul { padding-left: 1.2em; }
.prose blockquote {
  border-left: 3px solid var(--stamp);
  margin: 1.5em 0;
  padding: 4px 0 4px 18px;
  opacity: 0.85;
  font-style: italic;
}

/* ---------------- Forms (feedback) ---------------- */

.form-note { font-size: 0.85rem; color: var(--ink-soft); margin-top: -8px; margin-bottom: 20px; }

textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  min-height: 120px;
  resize: vertical;
}

/* ---------------- Utility ---------------- */

.small { font-size: 0.85rem; color: var(--ink-soft); }
.center { text-align: center; }

/* ---------------- Data tables (amortization schedule, etc.) ---------------- */

.table-wrap { overflow-x: auto; margin-top: 20px; }

table.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
table.ledger-table th {
  text-align: right;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--ink);
  color: var(--ink-soft);
}
table.ledger-table th:first-child, table.ledger-table td:first-child { text-align: left; }
table.ledger-table td {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px dotted var(--rule);
}
table.ledger-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }

.toggle-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: none;
  border: 1px dashed var(--ink);
  border-radius: var(--radius);
  padding: 9px 16px;
  cursor: pointer;
  color: var(--ink);
  margin-top: 16px;
}
.toggle-link:hover { color: var(--stamp); border-color: var(--stamp); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* Skip-to-content link — visually hidden until focused (injected by nav.js). */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 10;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 8px; outline: 2px solid var(--stamp); outline-offset: 2px; }

/* Expense rows in the budget planner are <button>s (remove-on-click);
   strip native button chrome so they match the .line-item ledger rows. */
button.line-item {
  width: 100%;
  font: inherit;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px dotted var(--rule);
  cursor: pointer;
}
button.line-item:hover .line-item-title,
button.line-item:focus-visible .line-item-title { color: var(--stamp); }
