/* ============================================================
   Footer — CSS Grid layout with named areas
   ============================================================
   Grid areas (all optional, collapsed when empty):
      language    — language dropdown
      sections    — explore / site-section navigation
      resources   — related resources
      logo        — brand logo
      social      — social-icon links
      copyright   — copyright notice
      links       — regular text links
   ============================================================ */

.footer-container {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
  border-top: 1px solid var(--border-soft);

  @media print {
    display: none;
  }

  .footer {
    position: relative;
    padding: 2rem;
    width: 100%;

    @media (max-width: 1000px) {
      padding: 1rem;
    }

    p {
      margin: 0;
    }

    .footer-lang-select {
      min-width: 160px;
      max-width: 280px;
    }
  }
}

/* ── Grid layout ───────────────────────────────────────────── */

.footer-grid {
  display: grid;
  color: var(--footer-color, var(--pico-color, #3c3c3c));
  grid-template-areas:
    "logo      .          .           language "
    "sections  sections   resources   resources"
    "social    links      copyright   copyright";
  grid-template-columns: auto 1fr auto auto;
  column-gap: 1rem;
  row-gap: 0;
  margin-bottom: -1rem;
  align-items: start;

  @media (max-width: 640px) {
    grid-template-areas:
      "logo"
      "sections"
      "resources"
      "social"
      "language"
      "links"
      "copyright";
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

.footer-grid>* {
  margin-bottom: 1rem;
}

/* ── Area assignments ──────────────────────────────────────── */

.footer-area-language {
  grid-area: language;
}

.footer-area-sections {
  grid-area: sections;
}

.footer-area-resources {
  grid-area: resources;
}

.footer-area-logo {
  grid-area: logo;
  align-self: start;
  justify-self: baseline;
}

.footer-area-social {
  grid-area: social;
}

.footer-area-copyright {
  grid-area: copyright;
}

.footer-area-links {
  grid-area: links;
}

/* ── Logo ──────────────────────────────────────────────────── */

.footer-logo {
  height: 5rem;
  width: auto;

  @media (max-width: 768px) {
    height: 3.5rem;
  }
}

.footer-logo-default,
[data-theme=light] .footer-logo-default {
    display: block;
}

.footer-logo-dark-theme,
[data-theme=light] .footer-logo-dark-theme {
    display: none;
}

@media (prefers-color-scheme: dark) {
    .footer-logo-default {
        display: none;
    }

    .footer-logo-dark-theme {
        display: block;
    }
}

[data-theme=dark] .footer-logo-default {
    display: none;
}

[data-theme=dark] .footer-logo-dark-theme {
    display: block;
}

/* ── Social icons ──────────────────────────────────────────── */

.footer-area-social {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: flex-start;
  align-items: center;

  @media (max-width: 640px) {
    justify-content: center;
  }
}

/* ── Text links ────────────────────────────────────────────── */

.footer-area-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  align-items: center;

  @media (max-width: 640px) {
    justify-content: center;
  }
}

.footer-link-item {
  text-decoration: none;
  white-space: nowrap;
  text-align: center;
  color: inherit;
}

.footer-link-item:hover {
  opacity: 0.7;
}

/* ── Copyright ─────────────────────────────────────────────── */

.footer-area-copyright {
  font-size: 13px;
  text-align: right;

  @media (max-width: 640px) {
    text-align: center;
  }
}

/* ── Sections ──────────────────────────────────────────────── */

.footer-section-header {
  margin-bottom: 0.75rem;
}

.footer-section-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-section-link {
  text-decoration: none;
}

/* ── Related resources ─────────────────────────────────────── */

.footer-resources-header {
  margin-bottom: 0.75rem;
}

.footer-resources-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-resource-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-resource-desc {
  font-size: 0.875rem;
  opacity: 0.7;
}

/* ============================================================
   Social link icons — inline SVG
   ============================================================
   Usage: add a socialLinks entry with "icon": "x" (or facebook,
   etc.) in portal config. The SVGs are rendered inline from the
   social-icons.peb fragment.
   ============================================================ */

.footer-social-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.footer-social-icon svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.footer-social-icon:hover {
  opacity: 0.7;
}

.footer-social-text {
  font-size: 14px;
}

/* ── Scroll to top ─────────────────────────────────────────── */

button#scroll-to-top {
  width: 4rem;
  height: 4rem;
  position: absolute;
  top: -2rem;
  right: 2rem;
  background: var(--elements-background);
  border-radius: 50px;
  display: flex;
  justify-content: center;
  align-items: center;

  &:focus {
    --pico-box-shadow: none;
  }
}