/* Home page dial (desktop only). Page names sit round a knob. The marker on the
   knob turns to one of them, and the logo in the center opens that page.
   Phones, tablets and small windows get the plain logo and links instead. */

.splash-plain {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.dial {
  display: none;
}

/* The dial shows in a wide window that either has a mouse or is tall enough.
   A phone turned sideways is wide but short and has no mouse, so it stays plain. */
@media (min-width: 680px) and (any-pointer: fine), (min-width: 680px) and (min-height: 480px) {
  .splash-plain {
    display: none;
  }

  .splash-dial {
    gap: 0.75rem;
    padding: 1rem;
  }

  .dial {
    display: block;
  }

  /* The whole dial: knob, ring of segments and page names. */
  .dial-face {
    --step: calc(360deg / var(--n));
    --turn: 0deg;
    --gap: 1.2deg;
    --chosen: 0;
    --segment-a: #dbe3ec;
    --segment-b: #c3d0de;
    --segment-c: #abbdd0;
    --segment-on: #182c40;
    position: relative;
    width: 640px;
    height: 460px;
    -webkit-user-select: none;
    user-select: none;
  }

  /* The ring of segments round the knob, one per page name, with a gap between
     neighbours. Three shades repeat, so no two neighbours match. */
  .dial-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 336px;
    height: 336px;
    margin: -168px 0 0 -168px;
    border-radius: 50%;
    background: repeating-conic-gradient(
      from calc(var(--step) / -2 + var(--gap) / 2),
      var(--segment-a) 0deg calc(var(--step) - var(--gap)),
      transparent 0deg var(--step),
      var(--segment-b) 0deg calc(var(--step) * 2 - var(--gap)),
      transparent 0deg calc(var(--step) * 2),
      var(--segment-c) 0deg calc(var(--step) * 3 - var(--gap)),
      transparent 0deg calc(var(--step) * 3));
    -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 22px), #000 calc(100% - 21px));
    mask: radial-gradient(closest-side, transparent calc(100% - 22px), #000 calc(100% - 21px));
    cursor: pointer;
    touch-action: none;
  }

  /* The lit segment: the one the marker points to. */
  .dial-ring-on {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
      from calc(var(--step) * var(--chosen) - var(--step) / 2 + var(--gap) / 2),
      var(--segment-on) 0deg calc(var(--step) - var(--gap)),
      transparent 0deg);
    pointer-events: none;
  }

  /* The knob. White in both light and dark mode, because the logo needs a white plate. */
  .dial-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 280px;
    height: 280px;
    margin: -140px 0 0 -140px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(24, 44, 64, 0.16);
    cursor: grab;
    touch-action: none;
  }

  /* The marker: a notch on the knob's edge that turns with the knob. */
  .dial-marker {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transform: rotate(var(--turn));
    transition: transform 0.25s ease-out;
    pointer-events: none;
  }

  .dial-marker::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 6px;
    width: 4px;
    height: 16px;
    margin-left: -2px;
    border-radius: 2px;
    background: #182c40;
  }

  /* The center: the logo, which is the link to the chosen page. */
  .dial-go {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 224px;
    height: 224px;
    margin: -112px 0 0 -112px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  .dial-go:focus-visible {
    outline: 2px solid #144470;
    outline-offset: 2px;
  }

  .dial .dial-go .logo {
    width: 208px;
    padding: 0;
    background: none;
    border-radius: 0;
  }

  .is-dragging .dial-ring,
  .is-dragging .dial-knob,
  .is-dragging .dial-go {
    cursor: grabbing;
  }

  .is-dragging .dial-marker {
    transition: none;
  }

  /* Page names. Each one is placed round the circle by its number, and lines up
     on the side nearest the knob. */
  .dial-labels {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .dial-labels li {
    --a: calc(var(--step) * var(--i));
    position: absolute;
    left: calc(50% + 186px * sin(var(--a)));
    top: calc(50% - 186px * cos(var(--a)));
    transform: translate(calc(-50% + 50% * sin(var(--a))), calc(-50% - 50% * cos(var(--a))));
    white-space: nowrap;
    line-height: 1.2;
  }

  .dial-labels a {
    display: block;
    padding: 0.3rem 0.6rem;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
  }

  .dial-labels .is-selected a,
  .dial-labels a:hover,
  .dial-labels a:focus-visible {
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.3em;
  }
}

/* Segment shades for dark mode. */
@media (prefers-color-scheme: dark) {
  .dial-face {
    --segment-a: #2c445c;
    --segment-b: #3a556f;
    --segment-c: #486683;
    --segment-on: #edf2f7;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dial-marker {
    transition: none;
  }
}
