@font-face {
  font-family: Cinzel;
  src: url("/assets/cinzel-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

.atlas-hero {
  margin-bottom: clamp(28px, 5vw, 60px);
}

@media (min-width: 980px) {
  .atlas-hero {
    display: grid;
    grid-template-columns: minmax(275px, .42fr) minmax(0, 1fr);
    gap: clamp(20px, 2.75vw, 38px);
    align-items: center;
    padding-top: 36px;
  }

  .atlas-hero .intro { padding-block: 0 2rem; }
  .atlas-hero .intro-grid { grid-template-columns: 1fr; gap: 22px; }
  .atlas-hero h1 { font-size: clamp(39px, 3.85vw, 53px); letter-spacing: -.045em; }
  .atlas-hero .intro-copy { justify-self: start; }
}

.atlas-plate {
  --atlas-x: 50%;
  --atlas-y: 48.5%;
  --atlas-radius-x: 37.3%;
  --atlas-radius-y: 29%;
  --atlas-turn: 240s;
  --atlas-disc-turn: 180s;
  --atlas-sign-font: Cinzel, "Palatino Linotype", Georgia, serif;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 3 / 2;
}

.atlas-scenery {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  mask-image:
    linear-gradient(to right, transparent, #000 5%, #000 95%, transparent),
    linear-gradient(to bottom, transparent, #000 6%, #000 94%, transparent);
  mask-composite: intersect;
}

.atlas-picture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* The mask leaves the central shadow and the outer field in the still image. */
.atlas-accretion {
  display: none;
  position: absolute;
  inset: 0;
  transform: rotate(-10deg);
  transform-origin: var(--atlas-x) var(--atlas-y);
  mask-image: radial-gradient(ellipse 26.8% 19.3% at var(--atlas-x) var(--atlas-y),
    transparent 34%, #000 42% 77%, transparent 100%);
  pointer-events: none;
}

@supports (mask-image: radial-gradient(black, transparent)) {
  .atlas-accretion { display: block; }
}

.atlas-accretion::before {
  position: absolute;
  inset: 0;
  content: "";
  background: url("/assets/piano-orbitale-notte.jpg") center / 100% 100% no-repeat;
  transform-origin: var(--atlas-x) var(--atlas-y);
  animation: atlas-disc-revolution var(--atlas-disc-turn) linear infinite;
}

/* Undo the projection for the rotation, then restore the inclined plane. */
@keyframes atlas-disc-revolution {
  from { transform: scaleY(.48) rotate(0turn) scaleY(2.083333) rotate(10deg); }
  to { transform: scaleY(.48) rotate(1turn) scaleY(2.083333) rotate(10deg); }
}

.atlas-caption {
  -webkit-text-stroke: .072em #261910;
  paint-order: stroke fill;
  text-shadow: 0 1px 2px #261910, 0 0 4px #261910, 0 0 7px #26191080;
}

.atlas-comets {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.atlas-comet {
  position: absolute;
  width: var(--size);
  height: auto;
  opacity: .94;
  filter: drop-shadow(0 0 1px #b9d7e599);
  transform: rotate(var(--angle));
  animation: drifta-cometa var(--duration) ease-in-out infinite alternate;
}

.atlas-comet-first {
  --size: 11.8%;
  --angle: 8deg;
  --duration: 19s;
  --drift-x: 26%;
  --drift-y: -17%;
  top: 7%;
  left: 42%;
}

.atlas-comet-second {
  --size: 9.6%;
  --angle: 174deg;
  --duration: 23s;
  --drift-x: -25%;
  --drift-y: 15%;
  top: 78%;
  left: 45%;
  animation-delay: -8s;
}

@keyframes drifta-cometa {
  to { transform: translate(var(--drift-x), var(--drift-y)) rotate(var(--angle)); }
}

.atlas-worlds {
  position: absolute;
  inset: 0;
}

.atlas-world {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--orbit-width, 21%);
  aspect-ratio: 1.65;
  transform: translate(-50%, -50%);
}

.world-ikuccioli { --x: 25%; --y: 24%; --course: 62.5%; --glow: #a55034; --sign: #ffda95; --period: 31s; --phase: -2s; }
.world-store { --x: 75%; --y: 24%; --course: 87.5%; --glow: #655377; --sign: #f2dfff; --period: 37s; --phase: -11s; }
.world-etetron { --x: 25%; --y: 73%; --course: 37.5%; --glow: #566436; --sign: #ecffa5; --period: 40s; --phase: -14s; }
.world-betaglobe { --x: 75%; --y: 73%; --course: 12.5%; --glow: #415b7a; --sign: #bdeaff; --period: 35s; --phase: -9s; --orbit-width: 24%; }

.atlas-worlds::before {
  content: "";
  position: absolute;
  left: var(--atlas-x);
  top: var(--atlas-y);
  width: calc(var(--atlas-radius-x) * 2);
  height: calc(var(--atlas-radius-y) * 2);
  transform: translate(-50%, -50%);
  border: 1px solid #ddb572a6;
  border-radius: 50%;
  pointer-events: none;
}

.atlas-sun {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--sun-width, 70%);
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.atlas-binary {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 82%;
  aspect-ratio: 320 / 187;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.atlas-binary-star {
  position: absolute;
  top: 50%;
  left: var(--binary-x);
  width: 53.75%;
  height: 100%;
  transform: translate(-50%, -50%);
  background: url("/assets/soli-betaglobe.png") var(--sprite-side) center / 186.0465% 100% no-repeat;
  mask-image: radial-gradient(ellipse closest-side, #000 70%, transparent 100%);
}

.atlas-binary-amber {
  --binary-x: 27%;
  --binary-start: 50%;
  --sprite-side: left;
}

.atlas-binary-blue {
  --binary-x: 73%;
  --binary-start: 0%;
  --sprite-side: right;
}

@supports (offset-path: ellipse(23% 28% at 50% 50%)) {
  .atlas-binary-star {
    left: 0;
    top: 0;
    transform: none;
    offset-path: ellipse(23% 28% at 50% 50%) border-box;
    offset-anchor: center;
    offset-rotate: 0deg;
    offset-distance: var(--binary-start);
    animation: atlas-binary-revolution 72s linear infinite;
  }
}

@keyframes atlas-binary-revolution {
  from { offset-distance: var(--binary-start); }
  to { offset-distance: calc(var(--binary-start) + 100%); }
}

@supports (offset-path: ellipse(50% 50% at 50% 50%)) {
  .atlas-world {
    left: 0;
    top: 0;
    transform: none;
    offset-path: ellipse(var(--atlas-radius-x) var(--atlas-radius-y) at var(--atlas-x) var(--atlas-y)) border-box;
    offset-anchor: center;
    offset-rotate: 0deg;
    offset-distance: var(--course);
    animation: atlas-world-revolution var(--atlas-turn) linear infinite;
  }
}

@keyframes atlas-world-revolution {
  from { offset-distance: var(--course); }
  to { offset-distance: calc(var(--course) + 100%); }
}

.atlas:has(.atlas-destination:is(:hover, :focus-visible)) :is(.atlas-world, .atlas-binary-star) {
  animation-play-state: paused;
}

.atlas-world:focus-within {
  z-index: 2;
}

.atlas-orbit {
  position: absolute;
  inset: 0;
  border: 1px solid color-mix(in srgb, var(--sign), transparent 56%);
  border-radius: 50%;
  pointer-events: none;
}

.atlas-object {
  position: absolute;
  top: 0;
  left: 0;
  width: 25%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  offset-path: ellipse(50% 50% at 50% 50%) border-box;
  offset-rotate: 0deg;
  offset-distance: 8%;
  filter: drop-shadow(0 2px 2px #30261445);
  animation: atlas-revolution var(--period) linear infinite var(--phase);
}

.atlas-object-second {
  --start: 58%;
  offset-distance: 58%;
}

.world-betaglobe .atlas-object { width: 20%; }
.world-betaglobe .atlas-object-second { --start: 33%; offset-distance: 33%; }
.atlas-object-third { --start: 58%; offset-distance: 58%; }
.atlas-object-fourth { --start: 83%; offset-distance: 83%; }

@keyframes atlas-revolution {
  from { offset-distance: var(--start, 8%); }
  to { offset-distance: calc(var(--start, 8%) + 100%); }
}

@supports not (offset-path: ellipse(50% 50% at 50% 50%)) {
  .atlas-object { inset: auto -10% 5% auto; }
  .atlas-object-second { inset: 4% auto auto -10%; }
  .atlas-object-third { inset: -10% auto auto 38%; }
  .atlas-object-fourth { inset: auto auto -10% 38%; }
}

.atlas-destination {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.atlas-hit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(66%, 44px);
  height: max(84%, 44px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.world-betaglobe .atlas-hit {
  width: max(82%, 44px);
  height: max(100%, 44px);
}

.atlas-caption {
  position: absolute;
  left: 50%;
  top: calc(100% + .45rem);
  transform: translateX(-50%);
  padding: .34em .6em;
  border-radius: 3px;
  color: var(--sign);
  font: 600 clamp(.65rem, 1.24vw, 1.05rem)/1.16 var(--atlas-sign-font);
  letter-spacing: .018em;
  text-align: center;
  white-space: nowrap;
  pointer-events: auto;
}

.atlas-caption span {
  font: 700 .62em/1 Arial, sans-serif;
  margin-left: .22em;
  vertical-align: .19em;
}

.atlas-destination:hover .atlas-caption,
.atlas-destination:focus-visible .atlas-caption {
  color: #fff8e7;
}

.atlas-destination:focus-visible .atlas-caption {
  outline: 2px solid var(--sign);
  outline-offset: 3px;
}

.atlas-destination:hover .atlas-hit {
  box-shadow: 0 0 0 1px #fff9 inset, 0 0 28px #fff4;
}

.atlas-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: .7rem;
}

.atlas-motion-label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 30px;
  padding: .3rem .55rem;
  border: 1px solid #c6bfae;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: 400 .75rem Arial, sans-serif;
  cursor: pointer;
}

.atlas-motion-label:hover {
  background: #eae5d8;
}

.atlas-motion-label:focus-within {
  outline: 2px solid #72502b;
  outline-offset: 3px;
}

.atlas-motion {
  margin: 0;
  accent-color: #51664b;
}

.atlas:has(.atlas-motion:checked) :is(.atlas-world, .atlas-binary-star, .atlas-object, .atlas-comet),
.atlas:has(.atlas-motion:checked) .atlas-accretion::before {
  animation-play-state: paused;
}

@media (max-width: 640px) {
  .atlas-plate { margin-inline: -10px; --atlas-radius-x: 32%; --atlas-radius-y: 27%; }
  .atlas-object { width: max(23%, 17px); }
  .atlas-caption { top: calc(100% + .16rem); padding: .27em .33em; }
  .atlas-caption span { display: none; }
  .atlas-motion-label { min-height: 36px; }
}

@media (max-width: 420px) {
  .atlas-caption { font-size: .64rem; letter-spacing: 0; }
  .intro h1 { font-size: clamp(42px, 12vw, 50px); }
  .header nav { gap: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .atlas-world, .atlas-binary-star, .atlas-object, .atlas-comet { animation: none; }
  .atlas-accretion, .atlas-motion-label { display: none; }
}
