/* 全站共用頁尾：首頁與所有內頁皆會載入。 */

/* 頁尾版型與連結 */
.site-footer {
  --footer-gutter: var(--page-gutter, var(--home-gutter, 1.125rem));
  --footer-content: var(--content, 73.75rem);
  position: relative;
  z-index: 6;
  margin-top: clamp(2.5rem, 5vw, 5rem);
  padding-block: clamp(1.35rem, 2.5vw, 2rem);
  color: #f7f2df;
  background: var(--mountain-dark, #2f6e60);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: none;
}

.site-footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(8rem, 0.42fr) minmax(
      8rem,
      0.42fr
    );
  gap: clamp(1.25rem, 2.25vw, 2.25rem);
  width: min(
    calc(100% - var(--footer-gutter) - var(--footer-gutter)),
    var(--footer-content)
  );
  margin-inline: auto;
}

.footer-group:nth-child(2),
.footer-group:last-of-type {
  justify-self: start;
}

.footer-group h2 {
  margin: 0 0 0.55rem;
  color: #f4e7b2;
  font-size: 0.9375rem;
  letter-spacing: 0.14em;
}

.footer-group ul {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-group:first-child ul {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(1rem, 2.5vw, 2.5rem);
}

.footer-group li {
  color: #f7f2df;
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1.6;
}

.footer-group a {
  color: inherit;
  text-decoration: none;
  transition: color 0.18s ease;
}

.footer-group a:hover,
.footer-group a:focus-visible {
  color: var(--artist-pin, #ec652d);
}

.footer-copyright {
  grid-column: 1 / -1;
  margin: 0.4rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(247, 242, 223, 0.78);
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-align: right;
}

/* 響應式：平板與手機頁尾 */
@media (max-width: 760px) {
  .site-footer {
    --footer-gutter: var(--page-gutter, 18px);
    margin-top: 2.5rem;
    padding-block: 1.35rem 1.5rem;
  }

  .site-footer-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(1.25rem, 7vw, 2rem);
    row-gap: 1.35rem;
    align-items: start;
  }

  .footer-group {
    min-width: 0;
    justify-self: stretch;
    text-align: left;
  }

  .footer-group:first-child {
    grid-column: 1 / -1;
  }

  .footer-group:nth-child(2),
  .footer-group:last-of-type {
    justify-self: stretch;
    margin-right: 0;
  }

  .footer-group:first-child ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.2rem clamp(0.75rem, 4vw, 1.25rem);
  }

  .footer-group h2 {
    margin-bottom: 0.4rem;
  }

  .footer-group li {
    font-size: 0.9375rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  .footer-group a {
    display: inline-flex;
    align-items: center;
    min-height: 3rem;
  }

  .footer-copyright {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0;
    text-align: left;
  }
}

/* 響應式：小型手機頁尾 gutter */
@media (max-width: 520px) {
  .site-footer {
    --footer-gutter: var(--page-gutter, 16px);
  }
}

/* 全站共用回到頂端按鈕 */
.back-to-top {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  width: 3rem;
  height: 3rem;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(47, 110, 96, 0.58);
  border-radius: 50%;
  color: #37250f;
  background: rgba(244, 231, 178, 0.94);
  box-shadow: 0 0.65rem 1.6rem rgba(47, 110, 96, 0.24);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(0.75rem);
  transition:
    opacity 0.24s ease,
    transform 0.24s ease,
    visibility 0.24s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
  cursor: pointer;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.back-to-top svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  color: #ec652d;
  border-color: #ec652d;
  background: #f4e7b2;
  box-shadow: 0 0.8rem 1.8rem rgba(47, 110, 96, 0.3);
  transform: translateY(-0.15rem);
}

.back-to-top:focus-visible {
  outline: 3px solid rgba(236, 101, 45, 0.28);
  outline-offset: 3px;
}

/* 響應式：手機按鈕尺寸與安全區域 */
@media (max-width: 640px) {
  .back-to-top {
    right: max(0.875rem, env(safe-area-inset-right));
    bottom: max(0.875rem, env(safe-area-inset-bottom));
    width: 2.875rem;
    height: 2.875rem;
  }
}

/* 無障礙：停用按鈕動畫 */
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: none;
  }
}
