/* ── Custom properties ──────────────────────────────────────────── */
:root {
  --color-bg: #f7f4ef;
  --color-card: #fff;
  --color-border: #e8e3da;
  --color-text-primary: #2d2d2d;
  --color-text-secondary: #999;
  --color-accent-green: #4a7c59;
  --color-accent-brown: #8b5e3c;
  --color-accent-teal: #2e7d8a;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.07);
  --radius-card: 12px;
  --feed-max-width: 600px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1917;
    --color-card: #252320;
    --color-border: #3a3631;
    --color-text-primary: #f0ece4;
    --color-text-secondary: #7a7470;
    --color-accent-green: #5a9c6e;
    --color-accent-brown: #b07848;
    --color-accent-teal: #3aaabb;
    --shadow-card: 0 1px 6px rgba(0, 0, 0, 0.4);
  }

  .caption {
    color: #a09890;
  }
  .pill-green {
    background: #1e3528;
  }
  .pill-brown {
    background: #2e1e10;
  }
  .pill-teal {
    background: #0e2428;
  }
  .pill-gray {
    background: #2a2826;
    color: #8a8480;
  }
}

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

body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  min-height: 100vh;
}

/* ── Nav ────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 1001; /* above leaflet */
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--color-text-primary);
  text-decoration: none;
}

.nav-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--color-accent-green);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.nav-avatar {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--color-accent-green),
    var(--color-accent-brown)
  );
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Feed ───────────────────────────────────────────────────────── */
.feed {
  max-width: var(--feed-max-width);
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

activity-feed {
  display: block;
}

activity-feed.hidden {
  display: none;
}

/* ── Trails container ───────────────────────────────────────────── */
.trails-container {
  max-width: var(--feed-max-width);
  margin: 0 auto;
  padding: 24px 16px;
}

.trails-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs-container {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 56px;
  z-index: 1001; /* above leaflet */
}

.tabs {
  max-width: var(--feed-max-width);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
  border-radius: 6px 6px 0 0;
  letter-spacing: -0.3px;
}

.tab:hover {
  color: var(--color-text-primary);
  background: rgba(45, 45, 45, 0.04);
}

.tab[aria-selected="true"],
.tab.active {
  color: var(--color-text-primary);
  font-weight: 600;
}

.tab[aria-selected="true"]::after,
.tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-accent-green);
  border-radius: 2px 2px 0 0;
}

@media (prefers-color-scheme: dark) {
  .tab:hover {
    background: rgba(240, 236, 228, 0.06);
  }
}

/* ── Filter row ─────────────────────────────────────────────────── */
.filter-row {
  max-width: var(--feed-max-width);
  margin: 0 auto;
  padding: 12px 16px 4px;
}

.filter-row select {
  appearance: none;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 30px 6px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.filter-row select:focus {
  outline: none;
  border-color: var(--color-accent-green);
  color: var(--color-text-primary);
}

/* ── About view ─────────────────────────────────────────────────── */
.about-container {
  max-width: var(--feed-max-width);
  margin: 0 auto;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-hero {
  background: linear-gradient(135deg, var(--color-accent-green), var(--color-accent-teal));
  border-radius: var(--radius-card);
  padding: 24px 20px;
  color: #fff;
}

.about-hero-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.75;
  margin-bottom: 6px;
}

.about-hero-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.about-hero-tagline {
  font-size: 13px;
  opacity: 0.85;
  line-height: 1.5;
}

.about-ctas {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.about-cta-primary {
  background: var(--color-accent-green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.about-cta-secondary {
  background: var(--color-bg);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.about-cta-primary:hover {
  opacity: 0.9;
}

.about-cta-secondary:hover {
  background: var(--color-card);
}

/* ── Card shell ─────────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ── Card header (activity posts) ───────────────────────────────── */
.card-header {
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-primary);
}

.user-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.distance {
  margin-left: auto;
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.distance span {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* ── Activity type pills ────────────────────────────────────────── */
.pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-green {
  background: #eef5f0;
  color: var(--color-accent-green);
}
.pill-brown {
  background: #faf3ec;
  color: var(--color-accent-brown);
}
.pill-teal {
  background: #ecf5f7;
  color: var(--color-accent-teal);
}
.pill-gray {
  background: #f0f0f0;
  color: #666;
}

/* ── Activity map ───────────────────────────────────────────────── */
.activity-map {
  height: 140px;
  width: 100%;
}

/* ── Trail map ──────────────────────────────────────────────────── */
.trail-map {
  height: 200px;
  width: 100%;
}

/* ── Trail title ────────────────────────────────────────────────── */
.trail-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.trail-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* ── Trail info ────────────────────────────────────────────────── */
.trail-info {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.trail-info span {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* ── Activity title ─────────────────────────────────────────────── */
.activity-title {
  padding: 0 16px 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.3;
}

/* ── Card body ──────────────────────────────────────────────────── */
.card-body {
  padding: 12px 16px 14px;
}

.caption {
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.stats span {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ── Travel card cover ──────────────────────────────────────────── */
.travel-cover {
  height: 160px;
  display: flex;
  align-items: flex-end;
  padding: 14px 16px;
}

.travel-cover-location {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  margin-bottom: 2px;
}

.travel-cover-title {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

/* ── Travel card author row ─────────────────────────────────────── */
.travel-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.travel-author .avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.travel-author-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-primary);
}

.travel-author-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .feed {
    padding: 16px 12px;
  }
  .nav {
    padding: 0 16px;
  }
}

/* ── Login / Auth ───────────────────────────────────────────────── */

/* Host element positioning */
atproto-login {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* trails-list custom element styling */
trails-list {
  display: block;
}

activity-feed.hidden {
  display: none;
}

/* "Sign in" button (logged-out state) */
.login-btn {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
}

.login-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-border);
}

/* Handle display (logged-in state) */
.login-handle {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
}

.login-handle:hover {
  color: var(--color-text-primary);
  text-decoration: underline;
}

/* Modal dialog */
.login-dialog {
  border: none;
  border-radius: var(--radius-card);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  padding: 24px;
  width: min(320px, 90vw);
  background: var(--color-card);
  color: var(--color-text-primary);
  font-family: inherit;
}

.login-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.login-dialog form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-dialog h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.login-dialog input {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: inherit;
}

.login-dialog input:focus {
  outline: 2px solid var(--color-accent-green);
  outline-offset: -1px;
  border-color: transparent;
}

.login-dialog-submit {
  padding: 9px 16px;
  background: var(--color-accent-green);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.login-dialog-submit:hover:not(:disabled) {
  filter: brightness(1.08);
}

.login-dialog-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  font-size: 12px;
  color: #c0392b;
  display: none;
}

/* Logout dialog content */
.login-logout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-logout-handle {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.login-logout-btn {
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.login-logout-btn:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
}

/* ── Detail pages ─────────────────────────────────────────────── */
.detail-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

.back-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0;
}

.back-btn:hover {
  color: var(--color-text-primary, #222);
}

.not-found {
  color: var(--color-text-secondary, #666);
  text-align: center;
  margin-top: 2rem;
}

.detail-section-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-secondary, #666);
  margin: 1.5rem 0 0.75rem;
  padding: 0;
}

/* ── Card view links ──────────────────────────────────────────── */
.view-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary, #666);
  text-decoration: none;
}

.view-link:hover {
  text-decoration: underline;
}

/* ── Skeleton loading ────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(90deg, #ece8e2 25%, #f5f2ee 50%, #ece8e2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #ece8e2 25%, #f5f2ee 50%, #ece8e2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-line.w80 { width: 80%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w40 { width: 40%; }

.skeleton-map {
  height: 140px;
  background: linear-gradient(90deg, #ece8e2 25%, #f5f2ee 50%, #ece8e2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
