/* ==========================================================================
   Notes — Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens
   -------------------------------------------------------------------------- */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #121212;
  --text-light: #5a5a5a;
  --text-faint: #999999;
  --accent: #326891;
  --accent-light: #e8f0f8;
  --border: #dfdfdf;
  --border-light: #ebebeb;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --orange: #e65100;
  --orange-light: #fff3e0;
  --red: #c62828;
  --red-light: #ffebee;

  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", Menlo, Consolas, monospace;

  --measure: 72rem;
  --gutter: 1.5rem;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.masthead,
.main,
.footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */

.masthead {
  text-align: center;
  padding-top: 2.5rem;
  padding-bottom: 1rem;
}

.masthead-title {
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 1rem 0 0.25rem;
}

.masthead-subtitle {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.rule {
  border: none;
  border-top: 2px solid var(--text);
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  gap: 0;
}

.nav-link {
  display: inline-block;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition:
    color 0.2s,
    border-color 0.2s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

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

.section {
  margin-bottom: 3.5rem;
}

.section-header {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  padding-top: 1rem;
}

.section-deck {
  font-size: 1.05rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   Subsections
   -------------------------------------------------------------------------- */

.subsection {
  margin-bottom: 2rem;
}

.subsection-title {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Stat Cards
   -------------------------------------------------------------------------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1rem;
  text-align: center;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--text-light);
}

.card-body {
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.card-expandable {
  cursor: pointer;
}

.card-detail {
  display: none;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.card-expandable.open .card-detail {
  display: block;
}

.card-toggle {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.5rem;
}

.card-toggle::before {
  content: "\25B8  ";
}

.card-expandable.open .card-toggle::before {
  content: "\25BE  ";
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Net Worth
   -------------------------------------------------------------------------- */

.net-worth {
  text-align: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.net-worth-value {
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 700;
}

.net-worth-value.positive {
  color: var(--green);
}
.net-worth-value.negative {
  color: var(--red);
}

.net-worth-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Bar Charts
   -------------------------------------------------------------------------- */

.bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 0.75rem;
}

.bar-label {
  flex: 0 0 120px;
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.6s ease;
}

.bar-fill.high {
  background: var(--orange);
}
.bar-fill.full {
  background: var(--red);
}

.bar-amount {
  flex: 0 0 100px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Filters & Search
   -------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-pill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.search-input {
  width: 100%;
  max-width: 360px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 1rem;
}

.search-input:focus {
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Tags
   -------------------------------------------------------------------------- */

.tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 3px;
  background: var(--accent-light);
  color: var(--accent);
  vertical-align: middle;
}

.tag-green {
  background: var(--green-light);
  color: var(--green);
}

.tag-orange {
  background: var(--orange-light);
  color: var(--orange);
}

.cluster-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  border-radius: 100px;
  background: #f0e6f6;
  color: #6a1b9a;
  margin: 0.15rem 0.15rem;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.data-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--text);
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.data-table tr:hover td {
  background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   Item Lists
   -------------------------------------------------------------------------- */

.item-list {
  list-style: none;
}

.item-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.95rem;
}

.item-list li:last-child {
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Todos
   -------------------------------------------------------------------------- */

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 3px;
}

.todo-item.completed .todo-check {
  background: var(--green);
  border-color: var(--green);
}

.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Meal Plan
   -------------------------------------------------------------------------- */

.meal-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meal-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
}

.meal-day-name {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-light);
}

.meal-day .item-list li {
  font-size: 0.9rem;
  padding: 0.2rem 0;
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Recipes
   -------------------------------------------------------------------------- */

.recipe-ingredients {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.recipe-ingredients li {
  padding: 0.15rem 0;
}

.recipe-steps {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.recipe-steps li {
  padding: 0.25rem 0;
}

/* --------------------------------------------------------------------------
   Ask Box
   -------------------------------------------------------------------------- */

.ask-box {
  margin-bottom: 2rem;
  padding-top: 1rem;
}

.ask-row {
  display: flex;
  gap: 0.5rem;
}

.ask-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

.ask-input:focus {
  border-color: var(--accent);
}

.ask-button {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--sans);
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.ask-button:hover {
  opacity: 0.85;
}

.ask-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.ask-output {
  display: none;
}

.ask-output.has-response,
.ask-output.has-error {
  display: block;
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
}

.ask-output.has-error {
  color: var(--red);
  background: var(--red-light);
  border-color: var(--red);
}

/* --------------------------------------------------------------------------
   Loading & Error
   -------------------------------------------------------------------------- */

.loading {
  text-align: center;
  padding: 4rem 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-light);
  font-size: 1.1rem;
}

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

.footer {
  padding-top: 2rem;
  padding-bottom: 3rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.footer p {
  margin-top: 1rem;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .masthead-title {
    font-size: 2.25rem;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .bar-label {
    flex: 0 0 80px;
    font-size: 0.75rem;
  }

  .bar-amount {
    flex: 0 0 70px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
