.page--home {
  --scene-rgb: 113, 91, 255;
  --scene-secondary-rgb: 60, 200, 255;
  --scene-glow-rgb: 184, 166, 255;
  background:
    linear-gradient(118deg, rgba(var(--scene-glow-rgb), 0.24) 0%, rgba(255, 255, 255, 0.42) 35%, rgba(var(--scene-secondary-rgb), 0.17) 70%, rgba(var(--scene-rgb), 0.2) 100%),
    linear-gradient(155deg, #f7fbff 0%, #edf8fc 48%, #eff8fb 100%);
  transition: background-color 560ms ease;
}

.page--home::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(ellipse 78% 72% at 4% 8%, rgba(255, 255, 255, 0.42), transparent 78%),
    radial-gradient(ellipse 92% 82% at 98% 94%, rgba(var(--scene-secondary-rgb), 0.09), transparent 78%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.16), transparent 46%, rgba(var(--scene-rgb), 0.045));
  pointer-events: none;
}

.atmosphere {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.atmosphere__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(52px);
}

.atmosphere__orb--one {
  top: -24vw;
  left: -12vw;
  width: 54vw;
  height: 54vw;
  background: radial-gradient(circle, rgba(var(--scene-glow-rgb), 0.12), transparent 70%);
  animation: atmosphereBreathe 10s ease-in-out infinite alternate;
}

.atmosphere__orb--two {
  right: -17vw;
  bottom: -32vw;
  width: 65vw;
  height: 65vw;
  background: radial-gradient(circle, rgba(var(--scene-secondary-rgb), 0.1), transparent 70%);
  animation: atmosphereBreathe 13s ease-in-out -5s infinite alternate-reverse;
}

.atmosphere__spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.95);
  animation: atmosphereDrift 8s ease-in-out infinite alternate;
}

.atmosphere__spark--one { top: 25%; left: 14%; }
.atmosphere__spark--two { top: 68%; left: 8%; animation-delay: -3s; }
.atmosphere__spark--three { top: 21%; right: 13%; animation-delay: -6s; }

.home-main {
  min-height: 0;
  padding-top: 10px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.subject-tabs {
  display: flex;
  width: min(1540px, calc(100% - 110px));
  height: 46px;
  margin: 0 auto 2px;
  padding: 0 4px;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.15vw, 22px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.subject-tabs::-webkit-scrollbar {
  display: none;
}

.subject-tab {
  position: relative;
  flex: 0 0 auto;
  height: 36px;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: rgba(53, 70, 112, 0.63);
  cursor: pointer;
  font-size: clamp(11px, 0.76vw, 14px);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 36px;
  white-space: nowrap;
  transition: color 180ms ease, transform 180ms ease;
}

.subject-tab::after {
  content: "";
  position: absolute;
  right: 18%;
  bottom: 1px;
  left: 18%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transform: scaleX(0.45);
  transition: opacity 180ms ease, transform 220ms ease;
}

.subject-tab:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.subject-tab.is-active {
  color: var(--ink);
  font-weight: 700;
}

.subject-tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.subject-carousel {
  position: relative;
  width: 100%;
  min-height: 0;
}

.carousel-viewport {
  position: relative;
  width: 100%;
  height: min(70vh, 760px);
  min-height: 500px;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  touch-action: pan-y;
}

.carousel-track {
  position: absolute;
  inset: 0;
}

.subject-slide {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(112%, 0, 0);
  transition:
    transform var(--carousel-step-ms, 920ms) cubic-bezier(0.18, 0.78, 0.18, 1),
    opacity var(--carousel-fade-ms, 560ms) ease;
  will-change: transform, opacity;
}

.subject-slide.is-active {
  z-index: 3;
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.subject-slide.is-prev {
  z-index: 2;
  opacity: 0.72;
  transform: translate3d(-36.5%, 0, 0);
}

.subject-slide.is-next {
  z-index: 2;
  opacity: 0.72;
  transform: translate3d(36.5%, 0, 0);
}

.subject-slide.is-far-prev {
  z-index: 1;
  visibility: visible;
  opacity: 0;
  transform: translate3d(-46%, 0, 0) scale(0.82);
}

.subject-slide.is-far-next {
  z-index: 1;
  visibility: visible;
  opacity: 0;
  transform: translate3d(46%, 0, 0) scale(0.82);
}

.subject-slide:is(.is-far-prev, .is-far-next) .subject-world__piece--main {
  --piece-scale: 0.2;
  opacity: 0;
}

.subject-slide:is(.is-prev, .is-next) .subject-world__piece--main {
  cursor: pointer;
  pointer-events: auto;
}

.subject-world {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-style: preserve-3d;
}

.subject-world::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 13%;
  left: 50%;
  width: min(68vw, 980px);
  height: 70%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(var(--slide-accent-rgb), 0.12), transparent 70%);
  filter: blur(44px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(0.78);
  transition:
    opacity var(--carousel-fade-ms, 580ms) ease,
    transform var(--carousel-step-ms, 880ms) cubic-bezier(0.2, 0.78, 0.2, 1);
}

.subject-slide.is-active .subject-world::before {
  opacity: 0.64;
  transform: translateX(-50%) scale(1);
}

.subject-world__piece {
  --piece-size: min(58vw, 68vh, 790px);
  --piece-left: 50%;
  --piece-top: 50%;
  --piece-scale: 1;
  --piece-rotate: 0deg;
  --wave-prev-y: 4vh;
  --wave-next-y: -4vh;
  position: absolute;
  z-index: 2;
  top: var(--piece-top);
  left: var(--piece-left);
  width: var(--piece-size);
  height: var(--piece-size);
  opacity: 1;
  transform:
    translate3d(-50%, -50%, 0)
    scale(var(--piece-scale))
    rotate(var(--piece-rotate));
  transform-origin: center;
  transition:
    transform var(--carousel-step-ms, 880ms) cubic-bezier(0.17, 0.8, 0.18, 1),
    opacity var(--carousel-fade-ms, 520ms) ease,
    visibility 0s linear;
  transition-delay: calc(var(--piece-index, 0) * 26ms);
  will-change: transform, opacity;
}

.subject-world__piece--main {
  --piece-size: min(55vw, 67vh, 760px);
  --piece-top: 50%;
  z-index: 7;
}

.subject-world__piece--secondary-1 {
  --piece-size: min(26vw, 36vh, 390px);
  --piece-left: 24%;
  --piece-top: 30%;
  --piece-scale: 0.84;
  --piece-rotate: -4deg;
  --wave-prev-y: -9vh;
  --wave-next-y: 7vh;
  z-index: 3;
}

.subject-world__piece--secondary-2 {
  --piece-size: min(23vw, 31vh, 340px);
  --piece-left: 76%;
  --piece-top: 28%;
  --piece-scale: 0.78;
  --piece-rotate: 4.5deg;
  --wave-prev-y: 8vh;
  --wave-next-y: -10vh;
  z-index: 4;
}

.subject-world__piece--secondary-3 {
  --piece-size: min(19vw, 26vh, 290px);
  --piece-left: 70%;
  --piece-top: 73%;
  --piece-scale: 0.72;
  --piece-rotate: -2.5deg;
  --wave-prev-y: -6vh;
  --wave-next-y: 9vh;
  z-index: 5;
}

.subject-world__piece--debris {
  --piece-size: clamp(34px, 3.7vw, 66px);
  z-index: 8;
}

.subject-world__piece--stone-1 {
  --piece-left: 35%;
  --piece-top: 66%;
  --piece-scale: 0.76;
  --wave-prev-y: 10vh;
  --wave-next-y: -8vh;
}

.subject-world__piece--stone-2 {
  --piece-left: 60%;
  --piece-top: 20%;
  --piece-scale: 0.58;
  --wave-prev-y: -12vh;
  --wave-next-y: 6vh;
}

.subject-world__piece--stone-3 {
  --piece-left: 81%;
  --piece-top: 58%;
  --piece-scale: 0.46;
  --wave-prev-y: 5vh;
  --wave-next-y: -11vh;
}

.subject-world__float,
.subject-world__orbit {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform-origin: center;
  will-change: transform;
}

.subject-world__float {
  animation: worldFloatA calc(var(--float-duration, 6.2s) + var(--piece-index, 0) * 0.43s) ease-in-out var(--piece-delay, 0s) infinite alternate;
}

.subject-world__piece--secondary-1 .subject-world__float {
  animation-name: worldFloatB;
}

.subject-world__piece--secondary-2 .subject-world__float {
  animation-name: worldFloatC;
}

.subject-world__piece--secondary-3 .subject-world__float {
  animation-name: worldFloatD;
}

.subject-world__orbit {
  animation: debrisOrbit calc(7.5s + var(--piece-index, 0) * 0.72s) linear var(--piece-delay, 0s) infinite;
}

.subject-world__island,
.subject-world__debris {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center;
  user-select: none;
}

.subject-world__island {
  filter: saturate(0.82) contrast(0.97) drop-shadow(0 16px 22px rgba(38, 71, 110, 0.16));
  transition: filter 520ms ease;
}

.subject-world__island[data-fallback="true"],
.subject-world__debris[data-fallback="true"] {
  transform:
    translateX(var(--island-shift-x, 0%))
    scaleX(var(--island-mirror, 1))
    scale(var(--island-normalize, 1));
}

.subject-world__debris {
  filter:
    saturate(0.9)
    contrast(0.98)
    drop-shadow(0 8px 8px rgba(35, 61, 95, 0.2));
}

.subject-slide.is-active .subject-world__island {
  filter:
    saturate(1.02)
    contrast(1.01)
    drop-shadow(0 24px 30px rgba(31, 65, 108, 0.2))
    drop-shadow(0 8px 18px rgba(var(--slide-accent-rgb), 0.14));
}

.subject-slide:is(.is-prev, .is-next) .subject-world__piece--main {
  --piece-scale: 0.43;
  --piece-top: 50%;
  opacity: 0.76;
}

.subject-slide.is-prev .subject-world__piece--main {
  --piece-rotate: -2.2deg;
  transform:
    translate3d(-50%, calc(-50% + 2.6vh), 0)
    scale(var(--piece-scale))
    rotate(var(--piece-rotate));
}

.subject-slide.is-next .subject-world__piece--main {
  --piece-rotate: 2.2deg;
  transform:
    translate3d(-50%, calc(-50% - 2.6vh), 0)
    scale(var(--piece-scale))
    rotate(var(--piece-rotate));
}

.subject-slide:not(.is-active) .subject-world__piece:not(.subject-world__piece--main) {
  opacity: 0;
}

.subject-slide.is-prev .subject-world__piece:not(.subject-world__piece--main) {
  transform:
    translate3d(calc(-50% - 30vw), calc(-50% + var(--wave-prev-y)), 0)
    scale(0.26)
    rotate(-12deg);
}

.subject-slide.is-next .subject-world__piece:not(.subject-world__piece--main) {
  transform:
    translate3d(calc(-50% + 30vw), calc(-50% + var(--wave-next-y)), 0)
    scale(0.26)
    rotate(12deg);
}

/*
 * Depth staging keeps the fourth island spatially understandable:
 * it grows out of the distance on entry and recedes before disappearing.
 */
.carousel-track .subject-slide:is(.is-entering-left, .is-exiting-left) {
  z-index: 1;
  opacity: 0;
  transform: translate3d(-46%, 0, 0) scale(0.82);
}

.carousel-track .subject-slide:is(.is-entering-right, .is-exiting-right) {
  z-index: 1;
  opacity: 0;
  transform: translate3d(46%, 0, 0) scale(0.82);
}

.carousel-track .subject-slide:is(.is-entering-left, .is-entering-right, .is-exiting-left, .is-exiting-right)
  .subject-world__piece--main {
  --piece-scale: 0.2;
  opacity: 0;
}

.carousel-track.is-staging-entry
  .subject-slide:is(.is-entering-left, .is-entering-right),
.carousel-track.is-staging-entry
  .subject-slide:is(.is-entering-left, .is-entering-right)
  .subject-world__piece--main,
.carousel-track.is-initializing .subject-slide,
.carousel-track.is-initializing .subject-world__piece {
  transition: none !important;
}

.carousel-track[data-direction="next"].is-transitioning .subject-slide.is-active .subject-world__piece {
  transition-timing-function: cubic-bezier(0.14, 0.78, 0.2, 1);
}

.carousel-track[data-direction="prev"].is-transitioning .subject-slide.is-active .subject-world__piece {
  transition-timing-function: cubic-bezier(0.2, 0.76, 0.14, 1);
}

.subject-slide:focus-visible {
  outline: 0;
}

.subject-slide:focus-visible .subject-world__piece--main::after {
  content: "";
  position: absolute;
  inset: 13%;
  border: 3px solid color-mix(in srgb, var(--accent) 65%, #fff 35%);
  border-radius: 50%;
  opacity: 0.72;
}

.carousel-arrow {
  position: absolute;
  z-index: 20;
  top: 50%;
  display: grid;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 16px;
  cursor: pointer;
  place-items: center;
  transform: translateY(-50%);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.carousel-arrow:hover {
  box-shadow: 0 16px 38px rgba(38, 73, 137, 0.22), inset 0 1px 0 #fff;
  transform: translateY(-50%) scale(1.05);
}

.carousel-arrow:active {
  transform: translateY(-50%) scale(0.98);
}

.carousel-arrow svg {
  width: 21px;
  height: 21px;
}

.carousel-arrow--prev { left: 2.1%; }
.carousel-arrow--next { right: 2.1%; }

.subject-entry {
  position: relative;
  z-index: 20;
  display: flex;
  width: max-content;
  min-width: 238px;
  height: 58px;
  margin: 9px auto 0;
  padding: 0 6px 0 25px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 42px rgba(var(--accent-rgb), 0.31), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: #fff;
  font-family: var(--font-head);
  font-size: clamp(17px, 1.15vw, 21px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.subject-entry[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.72;
}

.subject-entry:hover {
  box-shadow: 0 22px 50px rgba(var(--accent-rgb), 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.46);
  transform: translateY(-2px);
}

.subject-entry:active {
  transform: translateY(0) scale(0.99);
}

.subject-entry__arrow {
  display: grid;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  place-items: center;
}

.subject-entry__arrow svg {
  width: 20px;
  height: 20px;
}

@keyframes atmosphereBreathe {
  to { transform: translate3d(3vw, 2vw, 0) scale(1.08); }
}

@keyframes atmosphereDrift {
  to { opacity: 0.46; transform: translate3d(22px, -24px, 0) scale(1.22); }
}

@keyframes worldFloatA {
  from { transform: translate3d(0, 8px, 0) rotate(-0.24deg); }
  to { transform: translate3d(0, -13px, 0) rotate(0.24deg); }
}

@keyframes worldFloatB {
  from { transform: translate3d(-3px, -8px, 0) rotate(0.45deg); }
  to { transform: translate3d(4px, 10px, 0) rotate(-0.38deg); }
}

@keyframes worldFloatC {
  from { transform: translate3d(4px, 9px, 0) rotate(-0.42deg); }
  to { transform: translate3d(-3px, -11px, 0) rotate(0.34deg); }
}

@keyframes worldFloatD {
  from { transform: translate3d(-2px, 7px, 0) rotate(-0.3deg); }
  to { transform: translate3d(3px, -9px, 0) rotate(0.42deg); }
}

@keyframes debrisOrbit {
  0% { transform: rotate(0deg) translate3d(4px, 0, 0) rotate(0deg); }
  50% { transform: rotate(180deg) translate3d(9px, 3px, 0) rotate(-180deg); }
  100% { transform: rotate(360deg) translate3d(4px, 0, 0) rotate(-360deg); }
}

@media (max-width: 1180px) {
  .subject-tabs {
    width: calc(100% - 72px);
    justify-content: flex-start;
  }

  .subject-tab {
    font-size: 12px;
  }

  .carousel-viewport {
    height: min(68vh, 700px);
    min-height: 460px;
  }

  .subject-world__piece--main {
    --piece-size: min(61vw, 65vh, 700px);
  }

  .subject-slide.is-prev { transform: translate3d(-34%, 0, 0); }
  .subject-slide.is-next { transform: translate3d(34%, 0, 0); }

  .subject-world__piece--secondary-1 { --piece-left: 22%; }
  .subject-world__piece--secondary-2 { --piece-left: 78%; }
}

@media (max-width: 760px) {
  .page--home {
    --control-height: 44px;
    overflow-x: clip;
  }

  .page--home .app-shell--wide {
    width: calc(100% - 28px);
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .page--home .topbar {
    min-height: 44px;
  }

  .page--home .language-switch {
    width: 126px;
  }

  .page--home :is(.icon-button, .action-button, .language-switch) {
    min-height: 44px;
    touch-action: manipulation;
  }
}

@media (max-width: 700px) {
  .home-main {
    padding-top: 12px;
  }

  .subject-tabs {
    width: 100%;
    height: 42px;
    margin-bottom: 6px;
    gap: 16px;
  }

  .subject-tab {
    height: 34px;
    font-size: 12px;
    line-height: 34px;
  }

  .subject-carousel {
    min-height: calc(100vh - 130px);
  }

  .carousel-viewport {
    height: min(58vh, 430px);
    min-height: 350px;
  }

  .subject-world__piece--main {
    --piece-size: min(72vw, 46vh, 340px);
  }

  .subject-slide,
  .subject-world__piece {
    transition-duration: 620ms;
  }

  .subject-world__piece:not(.subject-world__piece--main) {
    display: none;
  }

  .subject-slide:is(.is-prev, .is-next) .subject-world__piece--main {
    --piece-scale: 0.34;
  }

  .subject-slide.is-prev { transform: translate3d(-34%, 0, 0); }
  .subject-slide.is-next { transform: translate3d(34%, 0, 0); }

  .carousel-arrow {
    top: 50%;
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .carousel-arrow--prev { left: 8px; }
  .carousel-arrow--next { right: 8px; }

  .subject-entry {
    min-width: 220px;
    height: 54px;
    margin-top: 10px;
    border-radius: 17px;
    font-size: 18px;
  }

  .subject-entry__arrow {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }
}

@media (max-width: 380px) {
  .page--home .topbar__left {
    gap: 8px;
  }

  .page--home .brand img {
    width: 94px;
  }

  .page--home .language-switch {
    width: 108px;
  }
}

@media (max-width: 350px) {
  .page--home .app-shell--wide {
    width: calc(100% - 24px);
  }

  .page--home .topbar {
    display: grid;
    min-height: 96px;
    align-items: center;
    grid-template-areas:
      "left instruction"
      "language language";
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-rows: 44px 44px;
    column-gap: 8px;
    row-gap: 8px;
  }

  .page--home .topbar__left {
    grid-area: left;
    gap: 7px;
  }

  .page--home .topbar__actions {
    display: contents;
  }

  .page--home .topbar [data-instruction] {
    grid-area: instruction;
  }

  .page--home .language-switch {
    width: 100%;
    grid-area: language;
  }

  .carousel-viewport {
    height: min(54vh, 360px);
    min-height: 300px;
  }

  .subject-world__piece--main {
    --piece-size: min(72vw, 43vh, 290px);
  }
}

@media (max-height: 760px) and (min-width: 701px) {
  .home-main { padding-top: 4px; }
  .subject-tabs { height: 40px; }
  .carousel-viewport {
    height: min(62vh, 620px);
    min-height: 390px;
  }
  .subject-world__piece--main { --piece-size: min(55vw, 59vh, 650px); }
  .carousel-arrow { top: 50%; }
  .subject-entry { height: 52px; margin-top: 5px; }
  .subject-entry__arrow { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .subject-slide,
  .subject-world__piece,
  .subject-world__float,
  .subject-world__orbit,
  .atmosphere__orb,
  .atmosphere__spark {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}
