/* ============================================================================
   PAGE STYLES - Homepage, Explorer, and Client Map page layouts
   ============================================================================
   Consolidates:
   - Homepage hero, sections, and grid layouts
   - Explorer map page viewport and filter layout
   - Client map popup and sidebar positioning
   - Responsive breakpoints for all pages
*/

/* ──────────────────────────────────────────────────────
   HOMEPAGE - Hero Section & Layout
   ────────────────────────────────────────────────────– */

.hero-container {
  position: relative;
  height: 50vh;
  min-height: 300px;
  overflow: hidden;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url(https://caboz.ch/media/pages/hero/1230733497-1717883727/p1050185-3000x.jpg);
  background-size: cover;
  background-position: 75% center;
  z-index: 0;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.6));
  z-index: 1;
}

.hero-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: flex;
  align-items: center;
}

/* Hero text - responsive sizing */
.hero-title {
  font-weight: 900;
  color: white;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 3.5rem);
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.hero-subtitle {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  margin: 0.3rem 0 0 0;
  font-size: clamp(0.9rem, 2.5vw, 1.4rem);
}

/* Mobile hero adjustments */
@media (max-width: 767px) {
  .hero-title {
    font-size: clamp(1.2rem, 4vw, 2rem);
  }

  .hero-subtitle {
    font-size: clamp(0.75rem, 2vw, 1rem);
  }
}

/* Tablet/Desktop */
@media (min-width: 768px) and (max-width: 991px) {
  .hero-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
  }
}

@media (min-width: 1200px) {
  .hero-title {
    font-size: 3.5rem;
  }
}

/* ──────────────────────────────────────────────────────
   HOMEPAGE - Section Styling
   ────────────────────────────────────────────────────– */

.impact-section,
.biodiversity-section {
  background-color: #fcfcfc;
}

.impact-image,
.biodiversity-image {
  height: 400px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background-size: cover;
  background-position: center;
}

/* ──────────────────────────────────────────────────────
   HOMEPAGE - Page Preview Cards
   ────────────────────────────────────────────────────– */

.page-preview-card {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  min-height: 100px !important;
  min-width: 90px !important;
  padding: 1rem !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  text-decoration: none !important;
  color: white !important;
  border: none !important;
  border-radius: var(--radius-md) !important;
  background-color: transparent !important;
  background: transparent !important;
}

.page-preview-card:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-radius: var(--radius-lg) !important;
  transform: translateY(-4px) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
}

/* Icon styling */
.page-preview-icon {
  color: white !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.page-preview-icon svg {
  fill: white !important;
  color: white !important;
}

.page-preview-card .mantine-Stack-root {
  color: white !important;
  background-color: transparent !important;
}

.page-preview-card .mantine-Text-root {
  color: white !important;
}

/* ──────────────────────────────────────────────────────
   HOMEPAGE - Main Grid & Layout
   ────────────────────────────────────────────────────– */

#home-page-container {
  width: 100%;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  /* Grid response on mobile */
  .mantine-Grid-col {
    padding: 0.5rem !important;
  }

  .mantine-GridCol-root[style*="base: 12"] {
    width: 100% !important;
  }

  /* Reduce text sizes */
  .mantine-Text-root[size="sm"] {
    font-size: calc(0.75rem - 0.1rem) !important;
  }

  .mantine-Text-root[size="xs"] {
    font-size: calc(0.65rem - 0.05rem) !important;
  }

  /* Icon sizing */
  [style*="width: 36px"] {
    width: 32px !important;
    height: 32px !important;
  }

  /* Tight stacking */
  .mantine-Stack-root {
    gap: 0.25rem !important;
  }

  .mantine-Container-root {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .mantine-Group-root {
    gap: 0.25rem !important;
  }
}

/* Small mobile phones */
@media (max-width: 479px) {
  #home-page-container {
    padding: 0 !important;
  }

  .mantine-GridCol-root {
    width: 100% !important;
    padding: 0.25rem !important;
  }

  .mantine-Paper-root {
    padding: 0.5rem !important;
  }

  .mantine-Text-root {
    word-break: break-word !important;
  }

  .mantine-Group-root {
    gap: 0.15rem !important;
    row-gap: 0.25rem !important;
  }

  img[style*="height: 20px"] {
    height: 16px !important;
  }
}

/* Prevent horizontal scrolling */
@media (max-width: 768px) {
  body,
  html {
    overflow-x: hidden !important;
    width: 100% !important;
  }

  #page-content {
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .mantine-Container-root {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* Large screens */
@media (min-width: 900px) {
  .mantine-Container-root {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }

  .mantine-Grid-col {
    padding: 1rem !important;
  }
}

/* Responsive 2-col grid */
@media (max-width: 640px) {
  [style*="cols="] .mantine-Grid-col {
    max-width: 50% !important;
    padding: 0.35rem !important;
  }
}

/* Dual background images - responsive */
.hero-bg-left {
  width: 50% !important;
  left: 0 !important;
}

.hero-bg-right {
  width: 50% !important;
  right: 0 !important;
}

@media (max-width: 767px) {
  .hero-bg-left {
    width: 100% !important;
  }

  .hero-bg-right {
    display: none !important;
  }
}

/* Project cards - flex distribution */
.mantine-SimpleGrid-root .mantine-Paper-root {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
}

.mantine-Paper-root .mantine-Title-root {
  word-break: break-word !important;
  white-space: normal !important;
  min-width: 0 !important;
}

/* Mobile - larger project cards */
@media (max-width: 768px) {
  .mantine-Paper-root .mantine-Group-root {
    gap: 1.25rem !important;
    row-gap: 1.25rem !important;
  }

  .page-preview-card {
    min-height: 110px !important;
    min-width: 100px !important;
    padding: 1rem !important;
  }

  .mantine-SimpleGrid-root .mantine-Paper-root {
    min-height: 340px !important;
    padding: 2rem !important;
  }

  .mantine-Paper-root .mantine-Title-root {
    font-size: 1.3rem !important;
    margin-bottom: 1.5rem !important;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .mantine-SimpleGrid-root .mantine-Paper-root {
    min-height: 360px !important;
    padding: 1.75rem !important;
  }

  .mantine-Paper-root .mantine-Title-root {
    font-size: 1.2rem !important;
    margin-bottom: 1.25rem !important;
  }

  .page-preview-card {
    min-height: 105px !important;
    min-width: 95px !important;
    padding: 0.75rem !important;
  }

  .mantine-Paper-root .mantine-Group-root {
    gap: 1rem !important;
    row-gap: 1rem !important;
  }
}

/* ──────────────────────────────────────────────────────
   EXPLORER PAGE - Map & Viewport Layout
   ────────────────────────────────────────────────────– */

/* Map info card styling */
.map-info-card {
  padding: 10px 12px;
  font-family: var(--font-family);
  background: var(--map-info-bg);
  box-shadow: var(--map-info-shadow);
  border-radius: var(--radius-lg);
  border: var(--map-info-border);
  pointer-events: none;
  z-index: 60 !important;
}

.map-info-card h4 {
  margin: 0 0 6px 0;
  color: #214097;
  font-size: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
}

.map-info-card .info-row {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.4;
}

.map-info-card .info-label {
  font-weight: 600;
  color: #666;
  margin-right: 4px;
}

.map-info-card .info-value {
  color: #333;
}

/* Explorer viewport layout */
.explorer-page {
  --explorer-chrome: 250px;
  --explorer-panel-h: calc(100vh - var(--explorer-chrome));
  max-width: 90% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden;
}

/* Title row - truncate long names */
.explorer-title-row {
  min-width: 0;
}

.explorer-title-row h5 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Responsive badge and reset button */
@media screen and (max-width: 768px) {
  .explorer-title-row .mantine-Badge-root {
    font-size: 10px;
    height: 20px;
    padding: 0 6px;
  }

  .explorer-title-row .mantine-Button-root {
    font-size: 11px;
    padding: 2px 6px;
  }
}

/* ──────────────────────────────────────────────────────
   EXPLORER PAGE - Filter Layout
   ────────────────────────────────────────────────────– */

/* Desktop: 4-column centered grid */
@media screen and (min-width: 769px) {
  .explorer-filter-row {
    display: grid;
    grid-template-columns: repeat(4, var(--explorer-filter-width));
    justify-content: center;
    gap: var(--explorer-filter-gap);
    width: 1040px;
    margin: 0 auto;
    padding: 4px 0;
  }

  .explorer-filter-btn-slot {
    width: var(--explorer-filter-width);
    min-width: var(--explorer-filter-width);
    max-width: var(--explorer-filter-width);
  }
}

/* Mobile: horizontal scroll strip */
@media screen and (max-width: 768px) {
  .explorer-filter-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    max-width: 100%;
    margin: 0;
    gap: var(--explorer-filter-gap);
    padding: 2px 4px;
  }

  .explorer-filter-row::-webkit-scrollbar {
    display: none;
  }

  .explorer-filter-btn-slot {
    flex-shrink: 0;
    width: var(--explorer-filter-width);
    min-width: var(--explorer-filter-width);
  }
}

/* ──────────────────────────────────────────────────────
   CLIENT MAP PAGE - Popup & Layout
   ────────────────────────────────────────────────────– */

.client-map-popup-fixed {
  position: fixed !important;
  top: 80px !important;
  left: calc(var(--sidebar-width-collapsed, 42px) + 20px) !important;
  bottom: 20px !important;
  right: auto !important;
  transform: none !important;
  margin: 0 !important;
  width: 400px !important;
  max-width: 400px !important;
  z-index: 1000 !important;
  display: flex;
  flex-direction: column;
}

/* Sidebar visible on expanding: adjust popup position */
@media (min-width: 991px) {
  .client-map-popup-fixed {
    left: calc(var(--sidebar-width-collapsed, 42px) + 20px) !important;
  }
  
  .sidebar-container:hover ~ [class*="client-map"], 
  .sidebar-container.search-pinned ~ [class*="client-map"] {
    /* When sidebar expands, only reposition if needed */
  }
}

.client-map-popup-fixed .leaflet-popup-content-wrapper {
  height: 100%;
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  background: white;
  padding: 0;
}

.client-map-popup-fixed .leaflet-popup-content {
  margin: 0 !important;
  height: 100%;
  overflow-y: auto;
  width: 100% !important;
}

.client-map-popup-fixed .leaflet-popup-tip-container {
  display: none !important;
}

.client-map-popup-fixed a.leaflet-popup-close-button {
  font-size: 24px !important;
  padding: 8px !important;
  color: #333 !important;
  z-index: 1001;
}

/* ──────────────────────────────────────────────────────
   RESPONSIVE ADJUSTMENTS - All Pages
   ────────────────────────────────────────────────────– */

@media (max-width: 768px) {
  /* Reduce grid column padding on mobile */
  .mantine-Grid-col {
    padding: 0.5rem !important;
  }

  /* Compact paper padding */
  .mantine-Paper-root {
    padding: 0.75rem !important;
  }

  /* Smaller section gaps */
  .mantine-Stack-root {
    gap: 0.5rem !important;
  }
}

/* ──────────────────────────────────────────────────────
   GLOBAL DEFAULT STYLES - Fallback for all elements
   ────────────────────────────────────────────────────– */

/* Ensure containers have proper background colors */
.mantine-Container-root {
  background-color: transparent;
}

/* Default Paper styling if not overridden */
.mantine-Paper-root:not(.page-preview-card) {
  background-color: var(--bg-paper);
  border: 1px solid var(--color-gray-3);
  border-radius: var(--radius-md);
}

/* Ensure Stack has proper spacing */
.mantine-Stack-root {
  gap: inherit;
}

/* Responsive for very large screens */
@media (min-width: 1400px) {
  /* Add extra padding on ultra-wide screens */
  .mantine-Container-root {
    max-width: 1400px !important;
  }
}
