/* ========================================
   BASE TYPOGRAPHY - Inter Font
   ======================================== */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 700;
  line-height: 1.3;
}

/* Tabular numbers for data display */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.red-text {
  color: red;
}

.responsive-iframe-container {
  position: relative;
  width: 100%;
  padding-bottom: 62.5%;
  height: 0;
  overflow: hidden;
  margin-bottom: 1rem;
}

.ghcnm-embed {
  padding-bottom: 78.125% !important;
  /* 62.5% * 1.25 */
}

.responsive-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.responsive-iframe-container.iframe-tall {
  padding-bottom: 90%;
  min-height: 720px;
}

.responsive-iframe-container.iframe-vertical {
  padding-bottom: 88%;
  min-height: 672px;
}

.iframe-fullscreen-toggle {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  box-sizing: border-box;
  line-height: 0;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #555;
  cursor: pointer;
}

.iframe-fullscreen-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.iframe-fullscreen-toggle .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
}

.iframe-fullscreen-toggle .icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.iframe-fullscreen-toggle .icon-exit {
  display: none;
}

.responsive-iframe-container.is-fullscreen-active .iframe-fullscreen-toggle {
  color: #555;
}

.responsive-iframe-container.is-fullscreen-active .iframe-fullscreen-toggle .icon-enter {
  display: none;
}

.responsive-iframe-container.is-fullscreen-active .iframe-fullscreen-toggle .icon-exit {
  display: inline-flex;
}

/* Native fullscreen mode styles */
.responsive-iframe-container:fullscreen,
.responsive-iframe-container:-webkit-full-screen {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  background: #000;
}

.responsive-iframe-container:fullscreen .responsive-iframe,
.responsive-iframe-container:-webkit-full-screen .responsive-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.responsive-iframe-container:fullscreen .iframe-fullscreen-toggle,
.responsive-iframe-container:-webkit-full-screen .iframe-fullscreen-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
}

.iframe-fallback {
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .responsive-iframe-container {
    padding-bottom: 110%;
  }

  .responsive-iframe-container.iframe-tall {
    padding-bottom: 130%;
    min-height: 0;
  }

  .responsive-iframe-container.iframe-vertical {
    padding-bottom: 116%;
    min-height: 0;
  }
}

@media (max-width: 480px) {
  .responsive-iframe-container {
    padding-bottom: 140%;
  }

  .responsive-iframe-container.iframe-tall {
    padding-bottom: 160%;
  }

  .responsive-iframe-container.iframe-vertical {
    padding-bottom: 140%;
  }
}

/* ========================================
   FOOTER LAYOUT
   ======================================== */

.nav-footer-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  width: 100%;
}

/* Unwrap the P tag so children become flex items */
.nav-footer-center p {
  display: contents;
}

/* Force copyright to take full width */
.footer-copyright {
  width: 100%;
  text-align: center;
  margin-bottom: 0.5rem;
}

/* Links group sits next to cookie preference */
.footer-links-inline {
  display: inline-flex;
  align-items: center;
}

/* Style all footer links (custom + cookie) to be consistent */
.footer-links-inline a,
#open_preferences_center {
  font-size: 0.75rem;
  /* Approx 12px, matches typical cookie consent size */
  text-decoration: underline;
  color: inherit;
  /* Inherit gray from footer */
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.footer-links-inline a:hover,
#open_preferences_center:hover {
  color: #000;
  /* Darker on hover */
}

/* Separator between links in the inline group */
.footer-links-inline a:not(:first-child)::before {
  content: "|";
  margin: 0 0.5rem;
  color: inherit;
  opacity: 0.6;
  text-decoration: none;
  font-size: 0.75rem;
  display: inline-block;
  /* Ensure it renders properly */
}

/* Cookie preferences link wrapper */
.nav-footer-center .cookie-consent-footer {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

/* Separator between the specific links group and the cookie link */
#open_preferences_center::before {
  content: "|";
  margin: 0 0.5rem;
  color: inherit;
  opacity: 0.6;
  text-decoration: none;
  font-size: 0.75rem;
}

/* ========================================
   DATASET CARDS - Homepage
   ======================================== */

/* Card Grid Layout */
.dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
  min-height: 500px;
  /* Reserve space to prevent collapse before content loads */
  content-visibility: auto;
  /* Improve rendering performance */
}

/* Individual Card */
.dataset-card {
  position: relative;
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 2px 4px -2px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dataset-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-accent, linear-gradient(90deg, #3b82f6, #1d4ed8));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.dataset-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.08);
}

.dataset-card:hover::before {
  opacity: 1;
}

/* Card Header with Icon */
.dataset-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dataset-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  font-size: 1.5rem;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.dataset-card:hover .dataset-icon {
  transform: scale(1.05);
}

/* Icon Color Variants */
.dataset-icon.ghcnh {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1d4ed8;
}

.dataset-icon.dwd {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #b45309;
}

.dataset-icon.jma {
  background: linear-gradient(135deg, #fee2e2 0%, #ffc1c1 100%);
  color: #dc2626;
}

.dataset-icon.meteofrance {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  color: #6d28d9;
}

.dataset-icon.ghcnm {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #047857;
}

.dataset-icon.eurometeo {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0369a1;
}

.dataset-icon.imgw {
  background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 100%);
  color: #0f766e;
}



/* Card accent colors */
.dataset-card.ghcnh {
  --card-accent: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.dataset-card.dwd {
  --card-accent: linear-gradient(90deg, #f59e0b, #b45309);
}

.dataset-card.jma {
  --card-accent: linear-gradient(90deg, #ef4444, #b91c1c);
}

.dataset-card.meteofrance {
  --card-accent: linear-gradient(90deg, #8b5cf6, #6d28d9);
}

.dataset-card.ghcnm {
  --card-accent: linear-gradient(90deg, #10b981, #047857);
}

.dataset-card.eurometeo {
  --card-accent: linear-gradient(90deg, #0ea5e9, #0369a1);
}

.dataset-card.imgw {
  --card-accent: linear-gradient(90deg, #14b8a6, #0f766e);
}



/* Card Title */
.dataset-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 0.25rem 0;
  line-height: 1.3;
}

.dataset-card-subtitle {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0;
  font-weight: 500;
}

/* Card Description */
.dataset-card-description {
  color: #475569;
  font-size: 0.9375rem;
  line-height: 1.65;
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

/* Card Tags */
.dataset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.dataset-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

.dataset-tag svg {
  width: 12px;
  height: 12px;
}

/* Card CTA Button */
.dataset-card-cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: #1e293b;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.dataset-card-cta:hover {
  background: #334155;
  color: #ffffff;
  text-decoration: none;
  transform: translateX(2px);
}

.dataset-card-cta svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.dataset-card-cta:hover svg {
  transform: translateX(3px);
}

/* Homepage Hero Section */
.homepage-hero {
  text-align: center;
  padding: 2rem 0 3rem;
  margin-bottom: 1rem;
}

.homepage-hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.homepage-hero .lead {
  font-size: 1.125rem;
  color: #475569;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.7;
}

/* Section Titles */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin: 2.5rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, #e2e8f0, transparent);
  margin-left: 1rem;
}

/* What You Can Do Section */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0 2rem;
}

.feature-item {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 10px;
  color: #2563eb;
  flex-shrink: 0;
}

.feature-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.375rem 0;
}

.feature-content p {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .dataset-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .dataset-card {
    padding: 1.25rem;
  }

  .dataset-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  .homepage-hero h1 {
    font-size: 1.75rem;
  }

  .homepage-hero .lead {
    font-size: 1rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .dataset-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

/* ========================================
   LAYOUT ADJUSTMENTS
   ======================================== */

/* Reduce excessive spacing above footer */
main.content {
  margin-bottom: 0 !important;
  padding-bottom: 0.5rem !important;
}

div.page-columns {
  gap: 0;
}

footer.footer {
  margin-top: 0 !important;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  /* Optional: add subtle separator */
}

/* ========================================
   MOBILE FULL WIDTH ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
  :root {
    --bs-gutter-x: 0;
  }

  /* THE REAL FIX: Override Quarto's CSS Grid placement.
     #quarto-content uses display:grid with columns:
     [screen-start] 25.5px [page-start] auto [page-end] 25.5px [screen-end]
     #quarto-document-content is placed at page-start/page-end, creating 25.5px gutters.
     Override to span full screen width on mobile. */
  #quarto-document-content {
    grid-column: screen-start / screen-end !important;
  }

  /* Force containers to be full-width */
  body,
  .quarto-container,
  .page-columns,
  #quarto-content,
  #quarto-document-content,
  main.content {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden;
  }

  /* Small breathing room for text content on mobile */
  #quarto-document-content section,
  #quarto-document-content div,
  #quarto-document-content .level2,
  #quarto-document-content .level3 {
    padding-left: 0.2rem !important;
    padding-right: 0.2rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  /* The iframe container itself - full-bleed, no margins */
  #quarto-document-content .responsive-iframe-container {
    padding: 0 !important;
    margin-left: -0.2rem !important;
    margin-right: -0.2rem !important;
    width: calc(100% + 0.4rem) !important;
    max-width: none !important;
    height: 85vh !important;
    border-radius: 0 !important;
  }
}

/* ========================================
   SOCIAL SHARE BAR
   ======================================== */

.share-bar {
  position: fixed;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

/* Hide the toggle on desktop — icons always visible */
.share-bar-toggle {
  display: none;
}

/* Text labels always hidden (kept for accessibility) */
.share-label {
  display: none;
}

/* Icons always visible on desktop */
.share-bar-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.share-btn svg {
  width: 18px;
  height: 18px;
}

.share-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  text-decoration: none;
}

/* Brand colors */
.share-fb {
  background: #1877F2;
  color: #fff;
}

.share-fb:hover {
  background: #0d6eeb;
  color: #fff;
}

.share-x {
  background: #000;
  color: #fff;
}

.share-x:hover {
  background: #333;
  color: #fff;
}

.share-li {
  background: #0A66C2;
  color: #fff;
}

.share-li:hover {
  background: #085da6;
  color: #fff;
}

.share-wa {
  background: #25D366;
  color: #fff;
}

.share-wa:hover {
  background: #1fb855;
  color: #fff;
}

/* Mobile + Tablet: restore toggle + collapse behaviour */
@media (max-width: 1024px) {
  .share-bar {
    left: 0.5rem;
    top: auto;
    bottom: 1rem;
    transform: none;
    flex-direction: column-reverse;
    gap: 0;
  }

  .share-bar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .share-bar-toggle:hover {
    background: rgba(30, 41, 59, 1);
    transform: scale(1.1);
  }

  .share-bar-toggle svg {
    width: 16px;
    height: 16px;
  }

  .share-bar-icons {
    flex-direction: column-reverse;
    order: -1;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.25s ease,
      margin-bottom 0.35s ease;
    margin-bottom: 0;
  }

  .share-bar-open .share-bar-icons {
    max-height: 250px;
    opacity: 1;
    margin-bottom: 0.4rem;
  }

  .share-btn {
    width: 32px;
    height: 32px;
  }

  .share-btn svg {
    width: 16px;
    height: 16px;
  }
}