/* ==========================================================================
   LAYER 100: Page Content
   ========================================================================== */

.page {
  position: relative;
  z-index: 100;
  flex: 1 0 auto;
  opacity: 1;
  transition: opacity 0.52s ease;
}

.page[data-page-type="home"] {
  display: flex;
  flex-direction: column;
}

.page.is-leaving {
  opacity: 0;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
}

.page.htmx-settling {
  opacity: 0;
  transition: none;
}

.page.is-entering {
  transition: none;
  animation: pageEnter 0.52s ease both;
}

/* Between content pages, keep the page veil fully present and transition only
   the readable content. This prevents the background from flashing away. */
body.content-page-swap .page,
body.content-page-swap .page.is-leaving,
body.content-page-swap .page.htmx-settling {
  opacity: 1;
  transition: none;
  animation: none;
}

body.content-page-swap .page.is-leaving .content-surface {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

body.content-page-swap .page.htmx-settling .content-surface {
  opacity: 0;
  transition: none;
}

.page.is-content-entering .content-surface {
  animation: contentPageEnter 0.3s ease both;
}

@keyframes pageEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes contentPageEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Full document pages. The fixed veil belongs to the page rather than a
   floating card, so content uses the browser's normal scroll flow. */
.content-page {
  --page-veil-r: 250;
  --page-veil-g: 249;
  --page-veil-b: 246;
  --page-veil: var(--page-veil-r), var(--page-veil-g), var(--page-veil-b);
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  padding: var(--frame-content-top) var(--frame-inline) var(--frame-content-bottom);
  color: var(--color-text-day);
  text-shadow: none;
}

.content-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 72% 115% at 50% 48%,
    rgba(var(--page-veil), 0.985) 0%,
    rgba(var(--page-veil), 0.985) 45%,
    rgba(var(--page-veil), 0.96) 54%,
    rgba(var(--page-veil), 0.68) 67%,
    rgba(var(--page-veil), 0.28) 80%,
    rgba(var(--page-veil), 0) 96%
  );
}

.theme-night .content-page {
  --page-veil-r: 46;
  --page-veil-g: 45;
  --page-veil-b: 43;
  color: #fff;
}

/* Theme changes use the same 900ms smoothstep as the WebGL background. The
   registered RGB channels let the radial veil interpolate without changing
   its opacity or shape midway through the transition. */
body.theme-transition-ready .content-page {
  transition:
    color var(--theme-transition-duration) var(--theme-transition-easing),
    --page-veil-r var(--theme-transition-duration) var(--theme-transition-easing),
    --page-veil-g var(--theme-transition-duration) var(--theme-transition-easing),
    --page-veil-b var(--theme-transition-duration) var(--theme-transition-easing);
}

.content-surface {
  width: min(100%, 760px);
  margin: 0 auto;
  font-family: var(--mono-font);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

.page--prose .content-surface {
  width: min(100%, 760px);
}

.page--post-detail .content-surface {
  width: min(100%, 760px);
}

.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;
}

@media (prefers-reduced-motion: reduce) {
  .page,
  .page.is-leaving,
  body.content-page-swap .page.is-leaving .content-surface,
  body.theme-transition-ready .content-page {
    transition-duration: 0.01ms;
  }

  .page.is-entering,
  .page.is-content-entering .content-surface {
    animation-duration: 0.01ms;
  }
}

body:has(.content-page) .center-logo {
  z-index: 200;
}

body:not(.theme-night):has(.content-page) :is(.nav-link, .menu-label, #site-footer, #theme-toggle, #lang-toggle) {
  color: var(--color-text-day);
  text-shadow: none;
}

body.theme-night:has(.content-page) :is(.nav-link, .menu-label, #site-footer, #theme-toggle, #lang-toggle) {
  color: #fff;
  text-shadow: none;
}

html :is(.nav-link, .menu-label, #site-footer, #theme-toggle, #lang-toggle) {
  transition-duration: 0.52s;
  transition-timing-function: ease;
}

body:not(.theme-night):has(.content-page) {
  cursor: var(--cursor-dark), auto;
}

body:not(.theme-night):has(.content-page) :is(a, button, summary) {
  cursor: var(--cursor-dark), pointer;
}

body.theme-night:has(.content-page) {
  cursor: var(--cursor-light), auto;
}

body.theme-night:has(.content-page) :is(a, button, summary) {
  cursor: var(--cursor-light), pointer;
}

.main-logo {
  transition: filter var(--theme-transition-duration) var(--theme-transition-easing);
}

body:not(.theme-night) .main-logo {
  filter: brightness(0.2);
}

.theme-night .main-logo {
  filter: brightness(1);
}

body:not(.theme-night) :is(.nav-link, .menu-label, #site-footer, #theme-toggle, #lang-toggle) {
  color: var(--color-text-day);
  text-shadow: none;
}

body:not(.theme-night) .menu-trigger-toggle,
body:not(.theme-night) :is(.nav-link, .menu-trigger-toggle, #theme-toggle, #lang-toggle):hover {
  color: var(--color-text-day);
}

body:not(.theme-night):has(.content-page) .top-nav.has-overlap-backdrop .nav-link {
  color: var(--color-text-day);
  text-shadow: none;
}

.home-hero {
  position: relative;
  flex: 1 0 auto;
  box-sizing: border-box;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
}

.home-hero-text {
  position: absolute;
  inset-inline: var(--frame-inline);
  /* Anchor the text's lower edge above the WebGL horizon. As translations or
     type sizes change, the text grows upward without changing this distance. */
  bottom: calc(var(--scene-horizon-from-bottom) + var(--hero-horizon-gap));
  margin: 0;
  font-family: var(--serif-font);
  font-size: var(--text-hero);
  line-height: var(--leading-tight);
  font-style: italic;
  font-weight: 400;
  text-wrap: balance;
}

.home-hero-open-clause {
  white-space: nowrap;
}

.home-hero-tail-clause {
  display: inline-block;
  max-width: 100%;
  vertical-align: baseline;
}

.home-hero-link,
.home-hero-open {
  position: relative;
  display: inline-block;
  --hero-star-size: 15px;
  --hero-star-gap: 3px;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 0.03em;
  text-underline-offset: 0.08em;
}

.home-hero-link,
.home-hero-open {
  color: inherit;
  text-shadow: none;
  cursor: var(--cursor-light), pointer;
}

.home-hero-link:hover,
.home-hero-open:hover {
  color: inherit;
  text-decoration: none;
  text-shadow: none;
  cursor: var(--cursor-dark), pointer;
}

body:not(.theme-night) .home-hero {
  color: var(--color-text-day);
  text-shadow: none;
}

.theme-night .home-hero-link,
.theme-night .home-hero-open {
  cursor: var(--cursor-dark), pointer;
}

.theme-night .home-hero-link:hover,
.theme-night .home-hero-open:hover {
  cursor: var(--cursor-light), pointer;
}

.home-hero-link::before,
.home-hero-open::after {
  content: "";
  position: absolute;
  left: 50%;
  width: var(--hero-star-size);
  height: var(--hero-star-size);
  transform: translateX(-50%);
  transform-origin: center;
  background: url('../cursor-light.svg') center/contain no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

body:not(.theme-night) .home-hero-link::before,
body:not(.theme-night) .home-hero-open::after {
  background-image: url('../cursor-dark.svg');
}

.home-hero-link::before {
  top: calc(-1 * (var(--hero-star-size) + var(--hero-star-gap)));
}

.home-hero-open::after {
  bottom: calc(-1 * (var(--hero-star-size) + var(--hero-star-gap)) + 4px);
}

.home-hero-link:hover::before,
.home-hero-open:hover::after {
  opacity: 1;
  animation: heroWordStarSpin 0.85s linear infinite;
}

@keyframes heroWordStarSpin {
  from {
    transform: translateX(-50%) rotate(0deg);
  }
  to {
    transform: translateX(-50%) rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-hero-link:hover::before,
  .home-hero-open:hover::after {
    animation: none;
  }
}

