.logo-motion {
  position: relative;
  display: block;
  width: var(--logo-size, clamp(60px, 6vw, 78px));
  max-width: 100%;
  aspect-ratio: 1;
}

.logo-motion img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-motion .logo-ring {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  @supports (clip-path: polygon(0 0, 100% 0, 100% 100%)) and (mask-image: url("logo-arc-1.webp")) {
    .logo-motion {
      /* The path runs through the transparent space around the three emblems. */
      --logo-centre: 21.67% 39.72%, 25% 34.44%, 45.56% 30.56%, 52.78% 30.56%,
        61.94% 34.17%, 72.78% 35%, 76.94% 41.11%, 76.11% 46.39%, 76.11% 48.06%,
        75.56% 50%, 74.44% 51.94%, 72.78% 54.17%, 69.72% 56.94%, 69.72% 67.22%,
        30.28% 67.22%, 26.67% 60%, 22.78% 57.50%, 21.67% 53.06%, 21.67% 39.72%;
    }

    .logo-motion .logo-core {
      clip-path: polygon(var(--logo-centre));
    }

    .logo-motion .logo-ring {
      position: absolute;
      inset: 0;
      display: block;
      transform-origin: 48.89% 49.72%;
      animation: logo-rotation 32s linear infinite;
    }

    .logo-rest:not([open]) :is(.logo-ring, .logo-arc) {
      animation-play-state: paused;
    }
  }
}

@keyframes logo-rotation {
  from { transform: rotate(0turn) scale(1.075); }
  to { transform: rotate(1turn) scale(1.075); }
}

@property --logo-fill {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@property --logo-wash {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

.logo-arc {
  position: absolute;
  inset: 0;
  --logo-dark: #102d4d;
  --logo-color: color-mix(in srgb, var(--arc-color) var(--logo-wash), var(--logo-dark));
  --logo-light: color-mix(in srgb, var(--arc-light) var(--logo-wash), var(--logo-dark));
  mask: var(--arc-mask) center / contain no-repeat;
  background: var(--logo-dark);
  background: conic-gradient(from var(--arc-tip) at 48.89% 49.72%,
    var(--logo-color) 0deg,
    var(--logo-color) max(0deg, calc(var(--logo-fill) - 28deg)),
    var(--logo-light) var(--logo-fill),
    var(--logo-dark) calc(var(--logo-fill) + 14deg));
  animation: logo-arc-fill var(--arc-time) linear var(--arc-delay) infinite;
}

.logo-arc:nth-child(1) {
  --arc-mask: url("logo-arc-1.webp");
  --arc-tip: 324deg;
  --arc-color: #008c82;
  --arc-light: #5bd4c0;
  --arc-time: 10s;
  --arc-delay: -2s;
}

.logo-arc:nth-child(2) {
  --arc-mask: url("logo-arc-2.webp");
  --arc-tip: 205deg;
  --arc-color: #285fc6;
  --arc-light: #79baff;
  --arc-time: 13s;
  --arc-delay: -5s;
}

.logo-arc:nth-child(3) {
  --arc-mask: url("logo-arc-3.webp");
  --arc-tip: 82deg;
  --arc-color: #8054b8;
  --arc-light: #c890dc;
  --arc-time: 16s;
  --arc-delay: -.8s;
}

@keyframes logo-arc-fill {
  0% { --logo-fill: 0deg; --logo-wash: 0%; }
  10% { --logo-fill: 26deg; --logo-wash: 100%; }
  76%, 85% { --logo-fill: 255deg; --logo-wash: 100%; }
  100% { --logo-fill: 255deg; --logo-wash: 0%; }
}

.brand-rest-trigger {
  display: none;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.has-logo-rest .brand-rest-trigger { display: block !important; }
.has-logo-rest .brand-static { display: none; }

.logo-rest {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  color: #102a21;
  background: radial-gradient(ellipse at 50% 42%, #f8faf0 12%, #e4efe3 68%, #cfdfd8);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overscroll-behavior: contain;
  overflow-x: hidden;
}

.logo-rest[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: 12px;
}

body:has(.logo-rest[open]) { overflow: hidden; }

.logo-rest-head {
  display: flex;
  width: min(100%, 70rem);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo-rest-head h2 {
  margin: 0;
  font-size: clamp(1rem, 2.4vmin, 1.45rem);
  font-weight: 650;
}

.logo-rest .logo-motion {
  --logo-size: min(78vw, 56vh, 29rem);
  --logo-size: min(78vw, 56dvh, 29rem);
}

.logo-rest-button {
  appearance: none;
  min-height: 44px;
  padding: .55rem 1rem;
  border: 1px solid #526f64;
  border-radius: 999px;
  background: #f8faf5;
  color: #16352b;
  font: 650 .9rem/1.2 var(--font-sans, system-ui, sans-serif);
  cursor: pointer;
}

.logo-rest-button:hover { background: #e3eee0; }
.logo-rest-button:focus-visible { outline-color: #42725d; }

.logo-rest-controls {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.logo-rest-music {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.logo-rest-controls select {
  height: 44px;
  padding-inline-end: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, #365449 50%),
    linear-gradient(135deg, #365449 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.logo-rest-transport {
  display: flex;
  gap: 8px;
}

.logo-rest-transport :is([data-music-prev], [data-music-next]) {
  min-width: 44px;
  padding-inline: .65rem;
  font-size: 1.05rem;
}

.logo-rest-track {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  font-size: .9rem;
}

.logo-rest-track select {
  min-width: 0;
  max-width: min(235px, 58vw);
}

@media (max-height: 500px) and (orientation: landscape) {
  .logo-rest .logo-motion {
    --logo-size: min(64vw, 40dvh, 29rem);
  }
}

.logo-rest-credits {
  font-size: .8rem;
  color: #365449;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.logo-rest-status {
  min-height: 1.3em;
  margin: 0;
  color: #365449;
  font-size: .85rem;
}


.has-logo-rest [data-logo-rest],
.has-logo-rest .trainer-navigation.noprint ~ .wrap :is(.hero, .start) > img.logo {
  display: none;
}

.topbar .brand-rest-trigger { --logo-size: 68px; }

.topbar .brand-rest-trigger .logo-core {
  width: 100%;
  height: 100%;
}

.hero > .brand-rest-trigger {
  --logo-size: 104px;
  margin: 0 auto 6px;
}

.trainer-navigation > .brand-rest-trigger { --logo-size: 52px; }

@media (max-width: 640px) {
  .topbar .brand-rest-trigger { --logo-size: 54px; }
  .trainer-navigation > .brand-rest-trigger { --logo-size: 44px; }
}

@media print {
  .logo-rest, .brand-rest-trigger { display: none !important; }
}
