/* ============================================================
   360-panos theme — main.css
   ============================================================ */

/* --- Variables -------------------------------------------- */
:root {
  --sidebar-w: 220px;
  --sidebar-bg: #151520;
  --sidebar-text: #b0b0c8;
  --sidebar-title-color: #ffffff;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-active-color: #ffffff;
  --content-bg: #ffffff;
  --content-text: #1a1a1a;
  --content-muted: #888;
  --link-color: #0055cc;
  --tag-bg: #f0f0f0;
  --tag-text: #555;
  --tag-hover-bg: #e0e0e0;
  --border: #e8e8e8;
  --map-height: 420px;
  --modal-bg: #ffffff;
  --radius: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --content-bg: #0f0f14;
    --content-text: #d8d8e8;
    --content-muted: #777;
    --link-color: #6699ff;
    --tag-bg: #222230;
    --tag-text: #999;
    --tag-hover-bg: #2e2e40;
    --border: #252535;
    --modal-bg: #1a1a26;
  }
}

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

/* --- Layout shell ----------------------------------------- */
body {
  font-family: var(--font-sans);
  background: var(--content-bg);
  color: var(--content-text);
}

/* Sidebar — fixed left column */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 28px 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-brand a {
  color: var(--sidebar-title-color);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.2;
}

.sidebar-brand .tagline {
  color: var(--sidebar-text);
  font-size: 0.7rem;
  margin-top: 4px;
  opacity: 0.65;
  letter-spacing: 0.03em;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.nav-links li a {
  display: block;
  padding: 11px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}

.nav-links li a:hover,
.nav-links li.active a {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-active-color);
}

/* Main scrollable content area */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* --- Masonry homepage ------------------------------------- */
.home-header {
  padding: 40px 32px 24px;
  border-bottom: 1px solid var(--border);
}

.home-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.home-header p {
  color: var(--content-muted);
  margin-top: 6px;
  font-size: 0.9rem;
}

/* CSS columns masonry — no JS required */
.masonry {
  columns: 3 260px;
  column-gap: 0;
  padding: 0;
}

.masonry-item {
  display: block;
  break-inside: avoid;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
  border-radius: 0;
  background: #111;
  text-decoration: none;
}

.masonry-item img {
  width: 100%;
  height: auto;   /* preserve native aspect ratio — never stretch */
  display: block;
  transition: transform 0.35s ease;
}

.masonry-item:hover img {
  transform: scale(1.04);
}

.masonry-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
}

.masonry-item:hover .masonry-overlay {
  opacity: 1;
}

.masonry-title {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

/* --- Pano page ------------------------------------------- */

/* Hero image — top padding + rounded corners give it breathing room.
   Capped at 900px so the browser never upscales the resized asset. */
.post-hero {
  max-width: 900px;
  margin: 28px auto 0;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
}

.post-hero img {
  width: 100%;
  height: auto;
  display: block;
}

/* Body constrained to readable width */
.post-body {
  max-width: 740px;
  margin: 0 auto;
  padding: 36px 36px 80px;
}

.post-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.post-meta time {
  color: var(--content-muted);
  font-size: 0.82rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}

.tag:hover {
  background: var(--tag-hover-bg);
}

.post-content {
  line-height: 1.75;
  font-size: 1rem;
}

/* Authors put the title as the first H1 in markdown; the page header
   already shows it, so we suppress the duplicate. */
.post-content > h1:first-child {
  display: none;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 2em;
  margin-bottom: 0.5em;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.post-content h2 { font-size: 1.2rem; }
.post-content h3 { font-size: 1.05rem; }

.post-content p {
  margin-bottom: 1.2em;
}

.post-content a {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content img {
  max-width: 100%;
  border-radius: var(--radius);
}

/* --- Pano CTA button ------------------------------------- */
.pano-button-wrap {
  display: flex;
  justify-content: center;
  margin: 40px 0 12px;
}

.pano-button,
.post-content .pano-button {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 8px;
  padding: 13px 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--content-text);
  background: transparent;
  border: 2px solid currentColor;
  transition: gap 0.2s ease, letter-spacing 0.2s ease, opacity 0.15s;
  position: relative;
}

/* Radar pulse — box-shadow spread grows by a fixed pixel amount in all
   four directions equally (unlike scale, which is proportional to the
   element size and barely visible vertically on a wide/short button).
   ::before is used because ::after is already taken by the hover arrow. */
@keyframes button-pulse {
  0%   { box-shadow: 0 0 0 0px  currentColor; opacity: 0.5; filter: blur(0px);  }
  100% { box-shadow: 0 0 0 15px currentColor; opacity: 0;   filter: blur(4px);  }
}

.pano-button::before,
.post-content .pano-button::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  animation: button-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.pano-button svg {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}

/* Spin only the meridian/equator lines; the outer circle stays fixed.
   transform-box: fill-box centres the rotation on the path's own
   bounding box, which happens to coincide with the globe centre. */
@keyframes globe-spin {
  to { transform: rotate(360deg); }
}

.pano-button .globe-spin {
  animation: globe-spin 6s linear infinite;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

/* Arrow — hidden by default, slides in on hover */
.pano-button::after {
  content: '→';
  display: inline-block;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pano-button:hover,
.post-content .pano-button:hover {
  text-decoration: none;
  opacity: 0.85;
}

.pano-button:hover::after,
.post-content .pano-button:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.pano-button:hover svg,
.post-content .pano-button:hover svg {
  opacity: 1;
}

.pano-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--content-muted);
  margin-bottom: 20px;
  letter-spacing: 0.01em;
}

/* --- Location section (auto-rendered from frontmatter) ---- */
.post-location {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.post-location h2 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--content-muted);
  margin-bottom: 14px;
}

/* --- Map embed (shortcode + post auto-map) ---------------- */
.map-embed {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-canvas {
  height: var(--map-height);
  width: 100%;
}

/* shortcode uses CSS custom property for height override */
.map-canvas[style] {
  height: var(--map-height);
}

.map-popup-img {
  width: 100%;
  display: block;
  border-radius: var(--radius) var(--radius) 0 0;
  /* Leaflet popup pads the content; negative margin bleeds image to edges */
  margin: -13px -19px 0;
  width: calc(100% + 38px);
}

.map-popup-body {
  padding-top: 10px;
}

.map-popup-caption {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.map-popup-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.map-popup-links a {
  color: #0055cc;
  text-decoration: none;
  font-size: 0.8rem;
}

.map-embed-error {
  color: #c00;
  font-size: 0.85rem;
  padding: 8px 0;
}

/* --- List pages (posts section, tags) -------------------- */
.list-page {
  padding: 40px 32px 60px;
}

.list-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.list-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.list-header p {
  color: var(--content-muted);
  margin-top: 6px;
  font-size: 0.88rem;
}

/* 3 columns → 2 at ≤1200px → 1 on mobile. */
.post-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 1200px) {
  .post-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .post-list { grid-template-columns: 1fr; }
}

.post-card {
  text-decoration: none;
  color: var(--content-text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s;
  display: block;
}

.post-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.post-card img {
  width: 100%;
  height: auto;
  display: block;
}

.post-card-body {
  padding: 12px 14px;
}

.post-card-title {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.post-card-summary {
  font-size: 0.78rem;
  color: var(--content-muted);
  line-height: 1.4;
}

/* --- Pagination ------------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pagination-item {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--content-text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.pagination-item:hover {
  background: var(--tag-bg);
  border-color: var(--content-muted);
}

.pagination-item--disabled {
  color: var(--content-muted);
  cursor: default;
  pointer-events: none;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--content-muted);
  min-width: 60px;
  text-align: center;
}

/* --- Tags index page ------------------------------------- */

/* Two-column grid: letter label | tags. Each pair of children is one row. */
.tag-index {
  display: grid;
  grid-template-columns: 24px 1fr;
  column-gap: 20px;
  row-gap: 10px;
  align-items: first baseline;
}

.tag-group-letter {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--content-muted);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.tag-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--content-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}

.tag-link:hover {
  background: var(--tag-hover-bg);
}

.tag-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--content-muted);
  background: var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

/* --- Maps page ------------------------------------------- */
/* Full-screen map filling the main content area */
.layout-maps {
  overflow: hidden;
}

.layout-maps .main-content {
  position: fixed;
  left: var(--sidebar-w);
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  margin-left: 0;
}

/* Absolutely positioned to fill the fixed .main-content container reliably
   across browsers — height: 100% alone is inconsistent inside fixed parents. */
#world-map {
  position: absolute;
  inset: 0;
}

/* Map page modal */
.map-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.map-modal-backdrop[hidden] {
  display: none;
}

.map-modal-content {
  background: var(--modal-bg);
  border-radius: 14px;
  overflow: hidden;
  max-width: 360px;
  width: 90%;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
}

.map-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  border: none;
  cursor: pointer;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.map-modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.map-modal-link {
  display: block;
  text-decoration: none;
  color: var(--content-text);
}

.map-modal-img-wrap {
  width: 100%;
  aspect-ratio: 2/1;
  overflow: hidden;
  background: #111;
}

.map-modal-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.map-modal-link:hover .map-modal-img-wrap img {
  transform: scale(1.03);
}

.map-modal-body {
  padding: 16px 18px 18px;
}

.map-modal-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.map-modal-date {
  font-size: 0.75rem;
  color: var(--content-muted);
  margin-bottom: 14px;
}

.map-modal-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--link-color);
}

/* Subtle tile darkening in dark mode */
@media (prefers-color-scheme: dark) {
  .leaflet-tile {
    filter: brightness(0.82) contrast(1.05);
  }
}

/* --- Mobile ≤ 768px --------------------------------------- */
@media (max-width: 768px) {
  /* Sidebar becomes fixed top bar */
  .sidebar {
    width: 100%;
    height: 52px;
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
    bottom: auto;
    overflow: visible;
  }

  .sidebar-brand {
    padding: 0;
    border-bottom: none;
    flex: 1;
  }

  .sidebar-brand .tagline {
    display: none;
  }

  .nav-links {
    display: flex;
    flex-direction: row;
    padding: 0;
    gap: 2px;
  }

  .nav-links li a {
    padding: 8px 10px;
    font-size: 0.7rem;
  }

  .main-content {
    margin-left: 0;
    margin-top: 52px;
    min-height: calc(100vh - 52px);
  }

  /* Maps page on mobile */
  .layout-maps .main-content {
    left: 0;
    top: 52px;
  }

  .post-body {
    padding: 24px 18px 60px;
  }

  .home-header {
    padding: 24px 18px 18px;
  }

  .list-page {
    padding: 24px 18px 40px;
  }
}

@media (max-width: 520px) {
  .masonry {
    columns: 1;
  }
}
