/* ================================================================
   TRAIL.CSS — styles for individual trail pages only
   /explore/css/trail.css
   ================================================================ */

/* ================================================================
   TRAIL HERO
   ================================================================ */
.trail-hero {
  position: relative;
  height: clamp(288px, 36vh, 432px);
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  width: 100vw; margin-left: calc(-50vw + 50%);
}
.trail-hero-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
.trail-hero-overlay {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to bottom,
    rgba(0,20,30,0.15) 0%, rgba(0,20,30,0.1) 35%,
    rgba(0,20,30,0.75) 70%, rgba(0,20,30,0.95) 100%);
}
.trail-hero-content {
  position: relative; z-index: 2;
  max-width: 1320px; margin: 0 auto; width: 100%;
  padding: 0 2.5rem 2.5rem;
}
.trail-region-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--f-label); font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: #fff; padding: 0.3rem 0.85rem; border-radius: 3px; margin-bottom: 1rem;
  opacity: 0; animation: fadeUp 0.5s 0.1s ease forwards;
}
.trail-region-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.6); }
.trail-hero-h1 {
  font-family: var(--f-head);
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  font-weight: 700; line-height: 1.05; color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.6); max-width: 720px;
  opacity: 0; animation: fadeUp 0.6s 0.25s ease forwards;
}
.trail-hero-sub {
  font-family: var(--f-head);
  font-size: 1.2rem; font-weight: 400; font-style: italic;
  color: rgba(255,255,255,0.8); margin-top: 0.75rem; max-width: 580px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
  opacity: 0; animation: fadeUp 0.6s 0.4s ease forwards;
}

/* ================================================================
   STATS BAR
   ================================================================ */
.stats-bar { background: var(--water-1); border-bottom: 3px solid var(--earth-2); position: relative; z-index: 10; }
.stats-bar-inner { max-width: 1320px; margin: 0 auto; display: grid; grid-template-columns: repeat(4,1fr); }
.stat-item { display: flex; align-items: center; gap: 1rem; padding: 1.25rem 2rem; border-right: 1px solid rgba(255,255,255,0.1); }
.stat-item:last-child { border-right: none; }
.stat-icon { font-size: 1.5rem; flex-shrink: 0; opacity: 0.8; }
.stat-label { font-family: var(--f-body); font-size: 0.65rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255,255,255,0.45); margin-bottom: 0.15rem; }
.stat-value { font-family: var(--f-body); font-size: 1.4rem; font-weight: 600; color: #fff; line-height: 1.1; }
.stat-value em { font-family: var(--f-body); font-size: 0.78rem; font-weight: 400; font-style: normal; color: rgba(255,255,255,0.55); margin-left: 0.2rem; }
.diff-easy     { color: #7fc97f; }
.diff-moderate { color: var(--water-3); }
.diff-hard     { color: var(--earth-3); }

/* ================================================================
   TRAIL BODY — two column layout
   ================================================================ */
.trail-body {
  max-width: 1320px; margin: 0 auto;
  padding: 2.5rem 2.5rem 3.5rem;
  display: grid; grid-template-columns: 1fr 340px;
  gap: 4rem; align-items: start;
}
.trail-intro {
  font-size: 1.12rem; line-height: 1.85; color: var(--ink);
  margin-bottom: 2.5rem; font-weight: 300;
  border-left: 3px solid var(--water-3); padding-left: 1.5rem;
}
.trail-section { margin-bottom: 2.75rem; }
.trail-section h2 {
  font-family: var(--f-head); font-size: 1.75rem;
  font-weight: 600; color: var(--water-1); margin-bottom: 1rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.trail-section p { font-size: 0.97rem; line-height: 1.8; color: #2a3a3f; margin-bottom: 1rem; }
.trail-section p:last-child { margin-bottom: 0; }

/* Lists */
.trail-list { list-style: none; margin: 0.75rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.trail-list li { display: flex; align-items: flex-start; gap: 0.65rem; font-size: 0.95rem; line-height: 1.6; color: #2a3a3f; }
.trail-list li::before { content: '›'; color: var(--water-2); font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }

/* Highlight & warning boxes */
.trail-highlight {
  background: var(--water-pale); border: 1px solid #b8d8e8;
  border-left: 4px solid var(--water-2); border-radius: 6px;
  padding: 1.25rem 1.5rem; margin: 1.75rem 0;
  font-size: 0.95rem; line-height: 1.7; color: var(--water-1);
}
.trail-highlight strong { display: block; margin-bottom: 0.35rem; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--f-label); }
.trail-warning {
  background: #fdf3f2; border: 1px solid #e8c4bf;
  border-left: 4px solid var(--earth-2); border-radius: 6px;
  padding: 1.25rem 1.5rem; margin: 1.75rem 0;
  font-size: 0.95rem; line-height: 1.7; color: var(--earth-1);
}
.trail-warning strong { display: block; margin-bottom: 0.35rem; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--f-label); }

/* Launch sites table */
.launch-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.launch-table th { font-family: var(--f-label); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.8); background: var(--water-1); padding: 0.6rem 0.85rem; text-align: left; }
.launch-table td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border); color: #2a3a3f; line-height: 1.5; vertical-align: top; }
.launch-table tr:last-child td { border-bottom: none; }
.launch-table tr:nth-child(even) td { background: var(--paper); }
.launch-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-family: var(--f-label); font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; background: var(--water-pale); color: var(--water-2); padding: 0.15rem 0.5rem; border-radius: 3px; }

/* Points of interest */
.poi-list { list-style: none; padding: 0; margin: 0.75rem 0; display: flex; flex-direction: column; }
.poi-item { display: flex; gap: 0.85rem; padding: 0.85rem 0; border-bottom: 1px solid var(--border); font-size: 0.93rem; line-height: 1.6; color: #2a3a3f; }
.poi-item:last-child { border-bottom: none; }
.poi-num { font-family: var(--f-label); font-size: 0.72rem; font-weight: 700; background: var(--water-2); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 0.1rem; }
.poi-item a { color: var(--water-2); text-decoration: none; }
.poi-item a:hover { color: var(--water-1); text-decoration: underline; }

/* Leaflet map */
#trail-map { height: 380px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); margin-top: 1rem; }
.leaflet-popup-content-wrapper { font-family: var(--f-body); border-radius: 6px; }
.leaflet-popup-content { font-size: 0.85rem; line-height: 1.5; }
.leaflet-popup-content strong { font-family: var(--f-label); font-size: 0.9rem; letter-spacing: 0.04em; color: var(--water-1); }

/* ================================================================
   SIDEBAR
   ================================================================ */
.trail-sidebar {}
.sidebar-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 1.5rem; box-shadow: 0 2px 12px rgba(0,62,81,0.06); }
.sidebar-card-head { background: var(--water-1); padding: 0.85rem 1.25rem; font-family: var(--f-label); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255,255,255,0.8); }
.sidebar-card-body { padding: 0 1.25rem; }
.qf-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.qf-row:first-child { padding-top: 1.1rem; }
.qf-row:last-child { border-bottom: none; padding-bottom: 1.1rem; }
.qf-label { color: var(--muted); font-weight: 400; }
.qf-value { font-weight: 600; color: var(--ink); text-align: right; }
.sidebar-cta { padding: 0 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.65rem; }
.facility-list { display: flex; flex-direction: column; }
.facility-item { display: flex; align-items: center; gap: 0.75rem; font-size: 0.88rem; color: var(--ink); padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.facility-item:first-child { padding-top: 1.1rem; }
.facility-item:last-child { border-bottom: none; padding-bottom: 1.1rem; }
.facility-icon { font-size: 1rem; flex-shrink: 0; width: 22px; text-align: center; color: var(--water-2); }
.facility-item.not-available { color: var(--muted); }
.facility-item.not-available .facility-icon { opacity: 0.4; }
.facility-item.not-available .facility-label { text-decoration: line-through; }

/* ================================================================
   GALLERY & LIGHTBOX
   ================================================================ */
.gallery-section { padding: 3rem 0 4rem; border-top: 1px solid var(--border); }
.gallery-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.75rem; padding: 0 2.5rem; max-width: 1320px; margin-left: auto; margin-right: auto; }
.gallery-section-head h2 { font-family: var(--f-head); font-size: 2rem; font-weight: 600; color: var(--water-1); }
.gallery-section-head h2 span { color: var(--water-2); font-style: italic; }
.gallery-count { font-family: var(--f-label); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.gallery-masonry { padding: 0 2.5rem; max-width: 1320px; margin: 0 auto; columns: 4; column-gap: 0.85rem; }
.gallery-item { break-inside: avoid; margin-bottom: 0.85rem; cursor: pointer; position: relative; overflow: hidden; border-radius: 6px; display: block; background: var(--water-pale); }
.gallery-item img { display: block; width: 100%; height: auto; transition: transform 0.4s cubic-bezier(0.4,0,0.2,1); border-radius: 6px; }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item-caption { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(0,20,30,0.85) 0%, transparent 100%); padding: 1.25rem 0.85rem 0.65rem; font-family: var(--f-body); font-size: 0.78rem; color: rgba(255,255,255,0.9); line-height: 1.4; opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; border-radius: 0 0 6px 6px; }
.gallery-item:hover .gallery-item-caption { opacity: 1; transform: translateY(0); }
.gallery-skeleton { background: var(--paper); border-radius: 6px; animation: galSkel 1.4s ease-in-out infinite; }
@keyframes galSkel { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.gallery-empty { padding: 0 2.5rem; max-width: 1320px; margin: 0 auto; font-family: var(--f-body); font-size: 0.9rem; color: var(--muted); font-style: italic; }

/* Lightbox */
.lb-backdrop { position: fixed; inset: 0; background: rgba(0,10,18,0.94); z-index: 900; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity 0.22s; }
.lb-backdrop.open { opacity: 1; pointer-events: all; }
.lb-inner { position: relative; display: flex; flex-direction: column; align-items: center; max-width: min(90vw,1100px); max-height: 92vh; width: 100%; }
.lb-img-wrap { position: relative; display: flex; align-items: center; justify-content: center; flex: 1; min-height: 0; width: 100%; }
.lb-img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 4px; display: block; opacity: 0; transform: scale(0.97); transition: opacity 0.2s, transform 0.2s; }
.lb-img.loaded { opacity: 1; transform: scale(1); }
.lb-spinner { position: absolute; width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.15); border-top-color: rgba(255,255,255,0.6); border-radius: 50%; animation: lbSpin 0.7s linear infinite; }
@keyframes lbSpin { to { transform: rotate(360deg); } }
.lb-spinner.hide { display: none; }
.lb-bar { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0.85rem 0.5rem 0; gap: 1rem; }
.lb-caption { font-family: var(--f-body); font-size: 0.85rem; color: rgba(255,255,255,0.7); line-height: 1.4; flex: 1; min-width: 0; font-style: italic; }
.lb-counter { font-family: var(--f-label); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; color: rgba(255,255,255,0.35); white-space: nowrap; flex-shrink: 0; }
.lb-btn { position: fixed; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); color: rgba(255,255,255,0.75); font-size: 1.4rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s, color 0.15s; user-select: none; z-index: 901; line-height: 1; }
.lb-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.lb-btn-prev { left: clamp(8px,2.5vw,32px); }
.lb-btn-next { right: clamp(8px,2.5vw,32px); }
.lb-close { position: fixed; top: 20px; right: 20px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); color: rgba(255,255,255,0.6); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.15s; z-index: 902; }
.lb-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.lb-thumbs { display: flex; gap: 6px; padding: 0.65rem 0.5rem 0; overflow-x: auto; width: 100%; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; }
.lb-thumbs::-webkit-scrollbar { height: 4px; }
.lb-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.lb-thumb { width: 52px; height: 36px; object-fit: cover; border-radius: 3px; cursor: pointer; opacity: 0.45; flex-shrink: 0; transition: opacity 0.15s; border: 2px solid transparent; }
.lb-thumb:hover { opacity: 0.75; }
.lb-thumb.active { opacity: 1; border-color: rgba(255,255,255,0.6); }

/* ================================================================
   NEARBY TRAILS SECTION
   ================================================================ */
.nearby-section { background: var(--paper); border-top: 1px solid var(--border); padding: 4rem 2.5rem; }
.nearby-inner { max-width: 1320px; margin: 0 auto; }
.nearby-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2rem; }
.nearby-header h2 { font-family: var(--f-head); font-size: 2rem; font-weight: 600; color: var(--water-1); }
.nearby-header h2 span { color: var(--water-2); font-style: italic; }
.view-all { font-family: var(--f-label); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--water-2); text-decoration: none; }
.view-all:hover { color: var(--water-1); }
.trail-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 1.5rem; }

/* Map layer switcher buttons */
.map-controls { display: flex; gap: 0.5rem; padding: 0.75rem 0; border-top: 1px solid var(--border); margin-top: 0; }
.map-btn { font-family: var(--f-label); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.35rem 0.75rem; border-radius: 4px; border: 1px solid var(--border); background: #fff; color: var(--muted); cursor: pointer; transition: all 0.15s; }
.map-btn:hover { border-color: var(--region-colour); color: var(--region-colour); }
.map-btn.active { background: var(--region-colour); border-color: var(--region-colour); color: #fff; }

/* ================================================================
   RESPONSIVE — trail page specific
   ================================================================ */

/* ── 1024px: tablet landscape ── */
@media (max-width: 1024px) {
  /* Drop two-column layout; sidebar becomes a 2-col card grid */
  .trail-body {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .trail-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    /* All cards visible at this breakpoint */
  }
  /* Emergency card (always last) spans full width */
  .trail-sidebar .sidebar-card:last-child {
    grid-column: 1 / -1;
  }
  .gallery-masonry { columns: 3; }
}

/* ── 768px: tablet portrait / large phone ── */
@media (max-width: 768px) {
  /* Hero */
  .trail-hero-content { padding: 0 1.25rem 1.75rem; }
  .trail-hero-h1     { font-size: 2rem; }
  .trail-hero-sub    { font-size: 1rem; }

  /* Stats bar: 2×2 grid */
  .stats-bar-inner {
    grid-template-columns: 1fr 1fr;
  }
  .stat-item {
    padding: 1rem 1.25rem;
    border-right: 1px solid rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .stat-item:nth-child(2n)   { border-right: none; }
  .stat-item:nth-child(3),
  .stat-item:nth-child(4)    { border-bottom: none; }

  /* Trail body */
  .trail-body { padding: 1.5rem 1.25rem 2rem; }

  /* Sidebar: full-width block above main content */
  .trail-sidebar {
    order: -1;
    display: block;       /* single-column stack on mobile */
    width: 100%;
  }
  .trail-sidebar .sidebar-card {
    margin-bottom: 1rem;
  }
  /* Emergency card always visible — guarantee with specificity */
  .trail-sidebar .sidebar-card:last-child {
    display: block !important;
  }

  /* Map */
  #trail-map { height: 260px; }

  /* Launch table: allow horizontal scroll rather than overflow */
  .launch-table        { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Nearby section */
  .nearby-section { padding: 2.5rem 1.25rem; }

  /* Gallery */
  .gallery-section-head { padding: 0 1.25rem; }
  .gallery-masonry      { columns: 2; padding: 0 1.25rem; }
  .gallery-empty        { padding: 0 1.25rem; }

  /* Lightbox */
  .lb-btn    { width: 40px; height: 40px; font-size: 1.1rem; }
  .lb-thumbs { display: none; }

  /* Map controls */
  .map-controls { flex-wrap: wrap; gap: 6px; }
  .map-btn      { font-size: 0.72rem; padding: 0.4rem 0.7rem; }

  /* Breadcrumb */
  .breadcrumb-inner { flex-wrap: wrap; font-size: 0.75rem; }
}

/* ── 480px: small phones ── */
@media (max-width: 480px) {
  /* Hero */
  .trail-hero-h1  { font-size: 1.7rem; }
  .trail-hero-sub { font-size: 0.92rem; }

  /* Stats bar: keep 2-col but tighten padding */
  .stat-item     { padding: 0.85rem 0.75rem; }
  .stat-value    { font-size: 1.15rem; }

  /* Trail body */
  .trail-body    { padding: 1.25rem 1rem 1.75rem; }
  .trail-intro   { font-size: 1rem; padding-left: 1rem; }
  .trail-section h2 { font-size: 1.45rem; }

  /* Gallery: single column */
  .gallery-masonry { columns: 1; }

  /* POI list tighten */
  .poi-item      { font-size: 0.88rem; }

  /* Hide nav page title pill — not enough room */
  .nav-page-title { display: none; }
}
