/* ======================================
   Denning-Kemp Reunion 2027 — Design System
   ====================================== */

:root {
  /* NZ Earthy palette */
  --teal: #1A5C5E;
  --teal-light: #2A8A8C;
  --teal-dark: #0F3D3E;
  --amber: #D4943A;
  --amber-light: #F0C078;
  --forest: #2E5E3F;
  --cream: #FAF7F2;
  --cream-dark: #EDE8E0;
  --charcoal: #2C2C2C;
  --gray-600: #555;
  --gray-400: #999;
  --gray-200: #E0DCD6;
  --white: #FFFFFF;
  --red: #C0392B;
  --green: #27AE60;

  /* Branch colors */
  --mckenzie: #1565C0;
  --browning: #2E7D32;
  --strahorn: #E65100;
  --dk: #7B1FA2;

  /* Layout */
  --max-width: 1200px;
  --nav-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--charcoal);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Navigation ---- */
#main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  z-index: 1000;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--teal);
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
}

.nav-year {
  font-weight: 400;
  opacity: 0.5;
  font-size: 0.85rem;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover { background: var(--cream); color: var(--teal); }
.nav-link.active { background: var(--teal); color: white; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--charcoal);
  border-radius: 2px;
  transition: 0.3s;
}

/* Identity */
.nav-identity { position: relative; margin-left: 8px; }

.identity-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--charcoal);
  transition: 0.2s;
}

.identity-btn:hover { border-color: var(--teal); }

.identity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.identity-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  min-width: 200px;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: 0.2s;
}

.identity-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.identity-current { font-size: 0.95rem; margin-bottom: 12px; }
.identity-current small { color: var(--gray-400); }

.identity-switch {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--cream);
  cursor: pointer;
  font-size: 0.85rem;
  transition: 0.2s;
}

.identity-switch:hover { border-color: var(--teal); background: white; }

/* Mobile nav */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
  }
  #main-nav.open .nav-links { display: flex; }
  .nav-link { padding: 12px 16px; }
}

/* ---- Identity Picker Modal ---- */
.identity-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s;
}

.identity-overlay.visible { opacity: 1; }

.identity-modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.identity-modal h2 {
  font-size: 1.5rem;
  color: var(--teal);
  margin-bottom: 4px;
}

.identity-subtitle {
  color: var(--gray-400);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.identity-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.identity-branch h3 {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.branch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.identity-members {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.identity-member {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  transition: 0.2s;
  font-size: 0.9rem;
}

.identity-member:hover {
  border-color: var(--teal);
  background: var(--cream);
}

.member-gen { font-size: 0.75rem; color: var(--gray-400); }

.identity-close {
  display: block;
  margin: 20px auto 0;
  padding: 10px 24px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
}

/* ---- Page Layout ---- */
.page-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--nav-height) + 24px) 20px 60px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 2rem;
  color: var(--teal-dark);
  font-weight: 700;
}

.page-header p {
  color: var(--gray-600);
  font-size: 1.05rem;
  margin-top: 4px;
}

/* ---- Hero Section (Landing) ---- */
.hero {
  position: relative;
  height: 85vh;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  margin-top: var(--nav-height);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.55);
}

.hero-content {
  position: relative;
  z-index: 1;
  color: white;
  padding: 20px;
  max-width: 700px;
}

.hero-title {
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  opacity: 0.9;
  margin-bottom: 32px;
  font-weight: 300;
}

.hero-date {
  font-size: 1.1rem;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  display: inline-block;
  padding: 8px 24px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.25);
  margin-bottom: 32px;
}

/* Countdown */
.countdown {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 32px;
}

.countdown-item {
  text-align: center;
}

.countdown-num {
  display: block;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1;
}

.countdown-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 24px 20px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--teal);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* CTA Button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 28px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--amber);
  color: white;
}

.btn-primary:hover { background: var(--amber-light); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-secondary {
  background: white;
  color: var(--teal);
  border: 2px solid var(--teal);
}

.btn-secondary:hover { background: var(--teal); color: white; }

.btn-sm { padding: 6px 16px; font-size: 0.85rem; border-radius: 20px; }
.btn-ghost { background: transparent; border: 1px solid var(--gray-200); color: var(--gray-600); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }

/* ---- Cards ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

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

.card-body { padding: 20px; }

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--gray-600);
  margin-bottom: 12px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
}

/* Category tags */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-adventure { background: #FFEBEE; color: #C62828; }
.tag-cultural { background: #E8EAF6; color: #283593; }
.tag-food { background: #FFF8E1; color: #F57F17; }
.tag-relaxation { background: #E0F2F1; color: #00695C; }

/* Upvote button */
.upvote-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-600);
  transition: 0.2s;
}

.upvote-btn:hover { border-color: var(--amber); color: var(--amber); }
.upvote-btn.voted { background: var(--amber); color: white; border-color: var(--amber); }

/* ---- Branch Badge ---- */
.branch-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ---- RSVP Status ---- */
.rsvp-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.rsvp-pending { background: #FFF3E0; color: #E65100; }
.rsvp-confirmed { background: #E8F5E9; color: #2E7D32; }
.rsvp-declined { background: #FFEBEE; color: #C62828; }

/* ---- Accommodation ---- */
.building-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.building-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-200);
}

.building-header h3 {
  font-size: 1.2rem;
  color: var(--teal-dark);
}

.building-photos {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--gray-200);
}

.building-photo {
  position: relative;
  flex-shrink: 0;
  width: 160px;
  height: 110px;
}

.building-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.building-photo-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 12px 8px 4px;
}

/* ---- Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
  cursor: pointer;
}

.lightbox-overlay.visible { opacity: 1; }

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.lightbox-caption {
  color: white;
  font-size: 0.95rem;
  margin-top: 12px;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: 0.2s;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  backdrop-filter: blur(4px);
}

.lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.lightbox-prev { left: -60px; }
.lightbox-next { right: -60px; }

@media (max-width: 768px) {
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

.building-capacity {
  font-size: 0.85rem;
  color: var(--gray-400);
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--gray-200);
}

.room-cell {
  padding: 16px 20px;
  background: white;
}

.room-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.bed-info {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.bed-occupants {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.occupant-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.building-backup {
  opacity: 0.5;
  border: 2px dashed var(--gray-200);
  box-shadow: none;
}

/* ---- Updates Board ---- */
.update-item {
  background: white;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}

.update-item.pinned {
  border-left-color: var(--amber);
  background: #FFFCF5;
}

.update-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.update-author {
  font-weight: 600;
  font-size: 0.9rem;
}

.update-time {
  font-size: 0.8rem;
  color: var(--gray-400);
}

.update-content {
  font-size: 0.95rem;
  line-height: 1.6;
}

.update-pin-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Post form */
.post-form {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.post-form textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font);
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 12px;
}

.post-form textarea:focus { outline: none; border-color: var(--teal); }

.post-form-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---- Family Tree ---- */
.tree-container {
  width: 100%;
  padding: 20px 0;
}

.tree-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tree-zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.tree-zoom-btn:hover { border-color: var(--teal); }

.tree-node {
  cursor: pointer;
  transition: 0.2s;
}

.tree-node:hover rect { filter: brightness(0.92); }

/* ---- Admin Page ---- */
.admin-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
  padding: 20px;
}

.admin-gate-box {
  background: white;
  border-radius: var(--radius);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.admin-gate-box h2 { color: var(--teal); margin-bottom: 8px; }
.admin-gate-box p { color: var(--gray-400); margin-bottom: 24px; font-size: 0.9rem; }

.admin-gate-box input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  text-align: center;
  margin-bottom: 16px;
  font-family: var(--font);
}

.admin-gate-box input:focus { outline: none; border-color: var(--teal); }

.admin-error { color: var(--red); font-size: 0.85rem; margin-bottom: 12px; display: none; }

/* Admin tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
  overflow-x: auto;
}

.admin-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: 0.2s;
}

.admin-tab:hover { color: var(--teal); }
.admin-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.admin-panel { display: none; }
.admin-panel.active { display: block; }

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--cream);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

.admin-table tr:hover td { background: var(--cream); }

.admin-table select {
  padding: 4px 8px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--font);
}

/* ---- Section Headers ---- */
.section {
  padding: 48px 20px;
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 36px;
}

.section-header h2 {
  font-size: 1.8rem;
  color: var(--teal-dark);
  margin-bottom: 8px;
}

.section-header p {
  color: var(--gray-600);
  font-size: 1rem;
}

/* ---- Filter Tabs ---- */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.2s;
  font-family: var(--font);
}

.filter-tab:hover { border-color: var(--teal); color: var(--teal); }
.filter-tab.active { background: var(--teal); color: white; border-color: var(--teal); }

/* ---- Misc ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--gray-600); }

.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
}

.capacity-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.capacity-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .countdown { gap: 10px; }
  .stats-bar { gap: 16px; }
  .hero { height: 75vh; min-height: 420px; }
  .page-header h1 { font-size: 1.5rem; }
  .building-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .room-grid { grid-template-columns: 1fr; }
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
}
