/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #c05621;
  --primary-dark: #7b341e;
  --text: #3d2c1e;
  --text-muted: #8b7355;
  --bg: #fffaf0;
  --bg-alt: #fef3e2;
  --border: #e8d5c0;
  --highlight: #feebc8;
  --max-width: 1100px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  background: var(--primary-dark);
  border-bottom: none;
  padding: 1rem 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.0rem;
  font-weight: 700;
  color: #fff;
}
.logo:hover { text-decoration: none; }

.main-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: nowrap;
  align-items: center;
}

.main-nav a {
  color: rgba(255,255,255,0.8);
  font-weight: 500;
  font-size: 1.0rem;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.main-nav a:hover {
  color: #fff;
  text-decoration: none;
}

/* ── Page Layout (sidebar + main) ────────────────────────── */
.page-layout {
  display: flex;
  gap: 2rem;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.info-sidebar {
  width: 260px;
  flex-shrink: 0;
}

.sidebar-section {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.sidebar-section h4 {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
}

.sidebar-section ul {
  list-style: none;
  padding: 0;
}

.sidebar-section li {
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.sidebar-section li:last-child {
  border-bottom: none;
}

.sidebar-section li strong {
  color: var(--text);
}

.main-area {
  flex: 1;
  min-width: 0;
}

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  padding: 4rem 0;
  text-align: center;
}

.hero h1 {
  font-size: 1.5rem;
  font-weight: 800;
}

/* ── Posts grid ──────────────────────────────────────────── */
.posts-section {
  padding: 2rem 0 4rem;
}

.posts-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.post-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.post-card:hover {
  box-shadow: 0 4px 12px rgba(123,52,30,0.1);
}

.post-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.post-card-body {
  padding: 1.25rem;
}

.post-card-body h3 { margin-bottom: 0.25rem; }
.post-card-body h3 a { color: var(--text); }

.post-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

/* ── Page / Post content ────────────────────────────────── */
.page-content,
.post-content {
  padding: 3rem 0;
  max-width: 750px;
}

.post-header { margin-bottom: 1.5rem; }
.post-header h1 { font-size: 2rem; margin-bottom: 0.5rem; }

.post-hero-image {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.content h2 { margin-top: 2rem; margin-bottom: 0.75rem; }
.content h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.content p { margin-bottom: 1rem; }
.content ul, .content ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
}
.content img { border-radius: 8px; margin: 1rem 0; }

/* ── Contact Form ───────────────────────────────────────── */
.contact-page {
  padding: 3rem 0;
  max-width: 600px;
}

.contact-page h1 { margin-bottom: 0.5rem; }
.contact-page > p { color: var(--text-muted); margin-bottom: 2rem; }

.contact-form { display: flex; flex-direction: column; gap: 1rem; }

.form-field label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-field textarea { resize: vertical; }

.submit-btn {
  padding: 0.65rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-start;
}

.submit-btn:hover { background: var(--primary-dark); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form-status {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.form-status.success { background: #dcfce7; color: #166534; }
.form-status.error { background: #fee2e2; color: #991b1b; }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  background: var(--primary-dark);
  border-top: none;
  padding: 2rem 0;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
}

/* ── Household Form ─────────────────────────────────────── */
.household-page {
  padding: 2rem 0;
  max-width: 700px;
}

.household-page h1 { margin-bottom: 0.5rem; }
.household-page > p { color: var(--text-muted); margin-bottom: 2rem; }

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-field {
  flex: 1;
}

.member-entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: var(--bg-alt);
}

.member-entry h4 {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--primary);
}

.checkbox-field {
  margin: 0.75rem 0;
}

.checkbox-field label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
}

.checkbox-field input[type="checkbox"] {
  margin: 0;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.adult-fields {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

#members-container h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* ── Finances Page ──────────────────────────────────────── */
.finances-page {
  padding: 2rem 0;
}

.finances-page h1 { margin-bottom: 0.5rem; }
.finances-page > p { color: var(--text-muted); margin-bottom: 1.5rem; }

.finance-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.finance-stat {
  flex: 1;
  min-width: 150px;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.finance-stat.income { background: #dcfce7; }
.finance-stat.expense { background: #fee2e2; }
.finance-stat.balance { background: #dbeafe; }

.finance-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.finance-stat.income .finance-label { color: #166534; }
.finance-stat.expense .finance-label { color: #991b1b; }
.finance-stat.balance .finance-label { color: #1e40af; }

.finance-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.finance-stat.income .finance-value { color: #166534; }
.finance-stat.expense .finance-value { color: #991b1b; }
.finance-stat.balance .finance-value { color: #1e40af; }

.badge-income {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #dcfce7;
  color: #166534;
}

.badge-expense {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #fee2e2;
  color: #991b1b;
}

/* ── Residents Table ────────────────────────────────────── */
.residents-page {
  padding: 2rem 0;
}

.residents-page h1 { margin-bottom: 0.5rem; }
.residents-page > p { color: var(--text-muted); margin-bottom: 2rem; }

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.residents-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.residents-table th,
.residents-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.residents-table th {
  background: var(--bg-alt);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.residents-table tr:hover {
  background: var(--bg-alt);
}

.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.member-list li {
  padding: 0.15rem 0;
  font-size: 0.9rem;
}

.no-data {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
  background: var(--bg-alt);
  border-radius: 8px;
}

/* ── Mobile nav toggle ──────────────────────────────────── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Responsive — Tablet ───────────────────────────────── */
@media (max-width: 1024px) {
  .info-sidebar {
    width: 220px;
  }

  .page-layout {
    gap: 1.5rem;
  }

  .hero h1 { font-size: 2rem; }
}

/* ── Responsive — Mobile ───────────────────────────────── */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .site-header .container {
    flex-wrap: wrap;
  }

  .main-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 1rem;
  }

  .hero {
    padding: 2.5rem 0;
  }

  .hero h1 { font-size: 1.75rem; }

  .page-layout {
    flex-direction: column;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .info-sidebar {
    width: 100%;
    order: 2;
  }

  .main-area {
    order: 1;
  }

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

  .post-card-body {
    padding: 1rem;
  }

  .page-content,
  .post-content {
    padding: 1.5rem 0;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }

  .contact-page {
    padding: 1.5rem 0;
  }

  .submit-btn {
    width: 100%;
    text-align: center;
    align-self: stretch;
    padding: 0.8rem;
  }

  .form-field input,
  .form-field textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .household-page {
    padding: 1.5rem 0;
  }

  .member-entry {
    padding: 1rem;
  }

  .residents-table {
    min-width: 500px;
  }

  .site-footer {
    padding: 1.5rem 0;
  }
}

/* ── Responsive — Small phones ─────────────────────────── */
@media (max-width: 400px) {
  .container {
    padding: 0 1rem;
  }

  .hero h1 {
    font-size: 1.4rem;
  }

  .sidebar-section {
    padding: 0.75rem 1rem;
  }

  .sidebar-section h4 {
    font-size: 0.85rem;
  }

  .sidebar-section li {
    font-size: 0.8rem;
  }
}
