@use "settings";

// Footer and theme picker
body > footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
  margin-top: 1.4rem;
  padding-top: 1.25rem;
  border-top: var(--rule-width) solid var(--border);
  border-image: var(--starlight-rule);
  color: var(--text-muted);
  font-size: 0.875rem;

  @include settings.mobile {
    grid-template-columns: 1fr;
  }

  > address {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-top: var(--space-3);
    border-top: var(--rule-width) solid var(--border);
    border-image: var(--starlight-rule);
    font-style: normal;
  }

  > nav {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    text-align: right;
  }

  > .copyleft {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }

  > address,
  > nav,
  > .copyleft {
    @include settings.mobile {
      grid-column: 1;
      grid-row: auto;
      justify-self: start;
      text-align: left;
    }
  }

  > address {
    @include settings.mobile {
      padding-top: 0;
      border-top: 0;
    }
  }

  > .theme-constellation {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0.4rem;

    @include settings.mobile {
      grid-row: auto;
    }
    padding-top: var(--space-4);
    border-top: var(--rule-width) solid var(--border);
    border-image: var(--starlight-rule);

    &[hidden] {
      display: none;
    }

    > p {
      margin: -0.35rem 0 0;
      text-align: center;
    }

    .stars {
      position: relative;
      width: 100%;
      height: clamp(10rem, 22vw, 13rem);

      svg {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        overflow: visible;

        path {
          fill: none;
          stroke: var(--border);
          stroke-width: 0.45;
          vector-effect: non-scaling-stroke;
        }
      }

      .placeholder-star {
        position: absolute;
        top: var(--y);
        left: var(--x);
        color: var(--text-muted);
        font-size: 0.75rem;
        line-height: 1;
        opacity: 0.6;
        text-shadow: 0 0 0.5rem color-mix(in srgb, var(--text-muted) 35%, transparent);
        translate: -50% -50%;

        &::before {
          content: "✦";
        }
      }

      button {
        --star-color: var(--star-dark);
        position: absolute;
        top: var(--y);

        @media (prefers-color-scheme: light) {
          --star-color: var(--star-light);
        }
        left: var(--x);
        width: 3rem;
        height: 3rem;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: transparent;
        touch-action: manipulation;
        translate: -50% -50%;

        &::before {
          position: absolute;
          bottom: calc(100% - 0.15rem);
          left: 50%;
          z-index: 1;
          padding: 0.15rem 0.35rem;
          border: var(--rule-width) solid var(--border);
          color: var(--text-main);
          background: var(--surface-container-high);
          content: attr(data-label);
          opacity: 0;
          pointer-events: none;
          transform: translate(-50%, 0.2rem);
          transition: opacity var(--duration-normal) var(--ease-linear), transform var(--duration-normal) var(--ease-out);
          white-space: nowrap;
        }

        &:hover::before,
        &:focus-visible::before {
          opacity: 1;
          transform: translate(-50%, 0);
        }

        &:focus-visible,
        &[aria-pressed="true"] {
          outline: 0;
          box-shadow: inset 0 0 0 var(--rule-width) color-mix(in srgb, var(--star-color) 85%, transparent), 0 0 0.45rem color-mix(in srgb, var(--star-color) 25%, transparent);
        }

        span {
          position: absolute;
          top: 50%;
          left: 50%;
          color: var(--star-color);
          font-size: 1.05rem;
          line-height: 1;
          text-shadow: 0 0 var(--space-3) color-mix(in srgb, var(--star-color) 45%, transparent);
          transform: translate(-50%, -50%);
          transition: text-shadow var(--duration-normal) var(--ease-linear), transform var(--duration-normal) var(--ease-out);

          &::before {
            content: "✦";
          }
        }

        &:hover span,
        &:focus-visible span {
          text-shadow: 0 0 1rem var(--star-color);
          transform: translate(-50%, -50%) scale(1.2);
        }

        &:active span {
          transform: translate(-50%, -50%) scale(0.9);
        }

        &:disabled {
          cursor: not-allowed;
          opacity: 0.5;
        }

        &[aria-pressed="true"] span {
          text-shadow: 0 0 0.2rem var(--background-body), 0 0 0.45rem var(--star-color), 0 0 1rem var(--star-color);
          animation: star-glint 360ms var(--ease-out);
        }
      }
    }
  }

  > .print-site-link {
    display: none;
  }
}
