/*
 * Footer (SPEC §2.29, design v2). Values from tokens.css only.
 *
 * HTML contract (one per page, last child of <body>)
 *   <footer class="footer">  (+ footer--ball-clearance on TOP, see below)
 *     <nav class="footer__nav" aria-label="フッター">
 *       <ul class="footer__list">
 *         <li class="footer__item"><a class="footer__link" href="#team">契約ゴルファー</a></li>
 *         <li class="footer__item"><a class="footer__link" href="#youtube">YouTube</a></li>
 *         <li class="footer__item"><a class="footer__link" href="mailto:…">お問い合わせ</a></li>
 *         <li class="footer__item">
 *           <a class="footer__link footer__link--social" href="https://www.instagram.com/…">
 *             <svg class="footer__icon" viewBox="0 0 34.272 34.285"
 *                  aria-hidden="true" focusable="false">
 *               <use href="../../assets/icons/instagram.svg#instagram"></use></svg>
 *             Instagram</a></li>
 *       </ul>
 *     </nav>
 *     <p class="footer__copyright">Copyright © サンミュージック ゴルフ
 *       エージェンシー <span class="footer__phrase">All Rights Reserved.</span></p>
 *     <a class="back-to-top" href="#top" …></a>              (§2.16, fixed)
 *   </footer>
 *   - <footer> as a child of <body> is the contentinfo landmark. The link
 *     list is a <nav> because it repeats site navigation; one list in DOM
 *     order, laid out as a row (PC) or as a 2×2 grid (SP).
 *   - v2: Instagram is the last list item (v1 had it on its own row above
 *     the list). The glyph is decorative; the label is the link name.
 *   - .footer__phrase keeps "All Rights Reserved." on one line, so the SP
 *     copyright breaks where XD breaks it.
 *   - Current page: aria-current="page" (underlined, like hover).
 *
 * Layout (SPEC §4.1 #16, §4.2): below 768 left-aligned in the page gutter:
 * links in 2 equal columns (契約ゴルファー, YouTube | お問い合わせ,
 * Instagram), copyright 12/20. From 768 everything is centred: one row of
 * links with 1px white rules, copyright fluid → 14/21. The band is full
 * bleed at every width.
 *
 * States are ASSUMPTION (Q4, SPEC §2.29): hover = underline (2px, 4 below);
 * active = underline + 70% opacity; focus = white ring (dark band).
 */

.footer {
  --focus-ring-color: var(--focus-ring-color-on-dark);
  --footer-art: var(--color-surface); /* glyph and rules: #FFF in XD */

  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-block: var(--footer-padding-block-start)
    var(--footer-padding-block-end);
  padding-inline: var(--gutter);
  color: var(--color-on-dark);
  background-color: var(--color-ink-900);
}

/* ---- Links ---- */

/* inline-block: the box is the label's line box (as measured in XD). */
.footer__link {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  text-decoration-thickness: var(--underline-thickness);
  text-underline-offset: var(--underline-offset);
  transition: opacity var(--duration-hover);
}

/* Instagram: glyph + label */
.footer__link--social {
  display: inline-flex;
  gap: var(--footer-icon-gap);
  align-items: center;
}

.footer__link[aria-current="page"] {
  text-decoration-line: underline;
}

@media (hover: hover) {
  .footer__link:hover {
    text-decoration-line: underline;
  }
}

.footer__link:active {
  text-decoration-line: underline;
  opacity: var(--opacity-pressed);
}

.footer__icon {
  flex: none;
  inline-size: var(--footer-icon-size);
  block-size: var(--footer-icon-size);
  color: var(--footer-art);
}

/* ---- Link list: 2×2 (SP) ----
   Equal columns (179 at 390, as drawn) that never get narrower than their
   longest label. Filled column by column, so DOM order reads down. */

.footer__nav {
  align-self: stretch;
}

.footer__list {
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-template-columns: repeat(2, minmax(max-content, 1fr));
  grid-auto-flow: column;
  row-gap: var(--footer-link-gap);
}

/* ---- Copyright ---- */

.footer__copyright {
  margin-block-start: var(--footer-gap-copyright);
  font-size: var(--text-copyright-size);
  line-height: var(--text-copyright-lh);
}

.footer__phrase {
  white-space: nowrap;
}

/* ---- Clearance for the floating YouTube ball (TOP) ----
   Below 1024 the ball is fixed at the bottom centre, right over the links
   and the copyright once the page is scrolled to the end. The modifier
   leaves a band of page colour (body background) under the ink band where
   the ball (and back-to-top) rest. SP: half the ball + inset, so the
   ball's upper half overlaps the copyright (as in the reference), never
   the links. 768–1023: the PC footer is shorter under its link row, so
   the band clears the whole ball. From 1024 the ball moves to the
   bottom-right corner, clear of the centred content: no band. */

.footer--ball-clearance {
  margin-block-end: var(--footer-ball-clearance);
}

@media (width >= 768px) {
  .footer--ball-clearance {
    margin-block-end: var(--footer-ball-clearance-full);
  }
}

@media (width >= 1024px) {
  .footer--ball-clearance {
    margin-block-end: 0;
  }
}

/* ---- Centred row (from 768) ---- */

@media (width >= 768px) {
  .footer {
    align-items: center;
    padding-block: var(--footer-padding-block-start-pc)
      var(--footer-padding-block-end-pc);
    text-align: center;
  }

  .footer__nav {
    align-self: auto;
  }

  .footer__list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .footer__item {
    display: flex;
    align-items: center;
  }

  /* Rule between links: decorative, so a pseudo-element. */
  .footer__item + .footer__item::before {
    inline-size: var(--border-thin);
    block-size: var(--footer-separator-height);
    margin-inline: var(--footer-separator-gap);
    content: "";
    background-color: var(--footer-art);
  }

  .footer__copyright {
    margin-block-start: var(--footer-gap-copyright-pc);
  }
}

/* Backgrounds are dropped in print: dark text on white instead. */
@media print {
  .footer {
    --footer-art: currentcolor;

    color: var(--color-ink-900);
    background-color: transparent;
  }
}
