:root {
  --primary: #2c6e49;
  --accent: #f4a261;
  --bg: #faf9f6;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  line-height: 1.6;
  /* ── Background collage image ── */
  /* To change: replace images/background.jpg with your own file — no code changes needed */
  background-color: #2a1f10;
  background-image: url('../images/background.jpg');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
  min-height: 100vh;
}

/* Frosted-glass card effect so content stays readable over the photo */
main, #login-screen, #admin-panel {
  background: rgba(250, 249, 246, 0.92);
  border-radius: 12px;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Header ── */
header {
  background: rgba(44, 110, 73, 0.97);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
}

header h1 { font-size: 1.6rem; font-weight: 700; }
header p.tagline { font-size: 0.9rem; opacity: 0.85; }

nav a {
  color: white;
  text-decoration: none;
  margin-left: 1.5rem;
  font-weight: 500;
  opacity: 0.9;
  transition: opacity 0.2s;
}
nav a:hover { opacity: 1; text-decoration: underline; }
nav a.active { border-bottom: 2px solid var(--accent); opacity: 1; }

/* ── Layout ── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}

/* ── Map ── */
#map-section { margin-bottom: 2rem; }
#map-section h2 { margin-bottom: 0.75rem; color: var(--primary); }

#map {
  height: 440px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.map-status {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Section headings ── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h2 { color: var(--primary); }
.section-header a {
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.section-header a:hover { text-decoration: underline; }

/* ── Posts container bottom padding ── */
#posts-container { padding-bottom: 1.25rem; overflow: hidden; }

/* ── Post cards ── */
.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.post-card:last-child { margin-bottom: 0; }

.post-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.post-meta .location-tag {
  background: var(--primary);
  color: white;
  border-radius: 20px;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
}

.post-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.post-card .post-body {
  font-size: 0.95rem;
  color: #333;
}
.post-card .post-body ul,
.post-card .post-body ol {
  padding-left: 1.4rem;
  margin: 0.25rem 0;
}
.post-card .post-body a {
  color: var(--primary);
  text-decoration: underline;
}

/* ── Media grid ── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.media-grid img,
.media-grid video {
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  max-height: 180px;
  cursor: pointer;
  transition: transform 0.15s;
}

.media-grid img:hover,
.media-grid video:hover { transform: scale(1.02); }

/* ── Lightbox ── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#lightbox.open { display: flex; }
#lightbox img, #lightbox video {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
}
#lightbox-close {
  position: absolute;
  top: 1rem; right: 1.25rem;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* ── About page ── */
.about-page { max-width: 720px; margin: 0 auto; }
.about-photo { margin-bottom: 1.5rem; border-radius: 12px; overflow: hidden; }
.about-photo img { width: 100%; max-height: 340px; object-fit: cover; display: block; }
.about-title { color: var(--primary); font-size: 1.8rem; margin-bottom: 1.25rem; }
.about-body p { margin-bottom: 1rem; font-size: 1rem; line-height: 1.75; color: #333; }
.about-body p:last-child { margin-bottom: 0; }

/* ── Blog page ── */
.blog-page-title {
  color: var(--primary);
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}

/* ── Admin ── */
#login-screen {
  max-width: 380px;
  margin: 6rem auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

#login-screen h2 { margin-bottom: 1.25rem; color: var(--primary); }

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--muted);
}

.form-group input,
.form-group textarea,
.form-group select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea { min-height: 120px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-accent { background: var(--accent); color: white; }
.btn-danger { background: #d9534f; color: white; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.82rem; }

#admin-panel { padding: 1.5rem; max-width: 800px; margin: 0 auto; }
#admin-panel h2 { color: var(--primary); margin-bottom: 1.5rem; }

.admin-form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.admin-form h3 { margin-bottom: 1rem; color: var(--primary); }

.admin-post-list { display: flex; flex-direction: column; gap: 0.75rem; }

.admin-post-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.admin-post-item .post-summary { flex: 1; }
.admin-post-item .post-summary strong { font-size: 1rem; }
.admin-post-item .post-summary small { color: var(--muted); font-size: 0.8rem; }

.admin-post-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ── Map position form ── */
.map-form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.map-form h3 { margin-bottom: 1rem; color: var(--primary); }
.inline-form { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form .form-group { margin-bottom: 0; }

.pos-coords-row { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.pos-coords-row .form-group { flex: 1; margin-bottom: 0; }
.pos-coords-row input { width: 100%; }
.pos-btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ── Rich text editor ── */
.editor-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.editor-toolbar button {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.editor-toolbar button:hover { background: var(--border); }

.editor-body {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  min-height: 120px;
  background: white;
  outline: none;
  line-height: 1.6;
}
.editor-body:focus { border-color: var(--primary); }
.editor-body:empty:before {
  content: attr(placeholder);
  color: #aaa;
  pointer-events: none;
}
.editor-body ul { padding-left: 1.4rem; margin-left: 0; }

/* ── Image previews in admin ── */
.img-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.img-preview-row .preview-thumb {
  position: relative;
  width: 80px;
  height: 80px;
}
.img-preview-row .preview-thumb img,
.img-preview-row .preview-thumb video {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.img-preview-row .preview-thumb .remove-media {
  position: absolute;
  top: -6px; right: -6px;
  background: #d9534f;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Spinner ── */
.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 28px; height: 28px;
  animation: spin 0.7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 10000;
}
#toast.show { transform: translateY(0); opacity: 1; }

/* ══════════════════════════════════════
   RESPONSIVE / MOBILE
   ══════════════════════════════════════ */

/* ── Hamburger button (hidden on desktop) ── */
#nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: white;
  flex-direction: column;
  gap: 5px;
  align-self: center;
}
#nav-toggle span {
  display: block;
  width: 26px;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
/* Animate to X when open */
#nav-toggle.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
#nav-toggle.open span:nth-child(2) { opacity: 0; }
#nav-toggle.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ── Tablet (≤ 768px) ── */
@media (max-width: 768px) {
  header {
    padding: 0.9rem 1rem;
    position: relative;
  }

  header h1 { font-size: 1.25rem; }
  header p.tagline { font-size: 0.82rem; }

  #nav-toggle { display: flex; }

  /* Nav slides down from header on mobile */
  nav {
    display: none;
    flex-direction: column;
    width: 100%;
    background: var(--primary);
    padding: 0.5rem 0 1rem;
    gap: 0;
    order: 3; /* pushes below the header row */
  }
  nav.open { display: flex; }

  nav a {
    margin-left: 0;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    font-size: 1rem;
  }
  nav a:last-child { border-bottom: none; }

  main {
    margin: 1.25rem auto;
    padding: 0 0.75rem;
  }

  #map { height: 300px; }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  .media-grid img,
  .media-grid video { max-height: 130px; }

  .post-card { padding: 1rem; }

  .admin-post-item {
    flex-direction: column;
    gap: 0.6rem;
  }
  .admin-post-actions { justify-content: flex-end; }

  .inline-form { flex-direction: column; }
  .inline-form input { width: 100% !important; }

  #admin-panel { padding: 0.75rem; }

  .blog-page-title { font-size: 1.4rem; }
}

/* ── Small phones (≤ 420px) ── */
@media (max-width: 420px) {
  header h1 { font-size: 1.05rem; }

  #map { height: 240px; border-radius: 8px; }

  .media-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .media-grid img,
  .media-grid video { max-height: 110px; }

  .btn { padding: 0.55rem 1rem; font-size: 0.88rem; }

  /* Stack form buttons vertically */
  .admin-form > div[style*="display:flex"] {
    flex-direction: column;
  }

  #login-screen {
    margin: 2rem auto;
    padding: 1.25rem;
  }

  /* Toast full-width on small screens */
  #toast {
    left: 0.75rem;
    right: 0.75rem;
    text-align: center;
  }
}
