/* Homepage cosmos: one source of truth for desktop and mobile. */

body[data-page="home"] {
  --cosmos-bg: #0b1015;
  --cosmos-glow: rgba(255, 190, 55, 0.38);
  --cosmos-glow-strong: rgba(255, 224, 145, 0.76);
  --cosmos-line: rgba(255, 223, 157, 0.16);
  --cosmos-line-strong: rgba(255, 229, 174, 0.34);
  --cosmos-star: #ffe3a3;
  --cosmos-dot: #f0bd52;
  --wind-line: rgba(255, 226, 171, 0.12);
  --cosmos-label-bg: rgba(11, 16, 21, 0.74);
  --nebula-cool-a: rgba(74, 110, 150, 0.075);
  --nebula-cool-b: rgba(45, 76, 108, 0.052);
  --nebula-warm: rgba(205, 154, 67, 0.022);
  --cosmos-grain-opacity: 0.014;
  --cosmos-grain-blend: soft-light;
  --stage-height: min(82svh, 860px);
  --orbit-width: clamp(660px, 76vw, 900px);
  --orbit-height: clamp(380px, 44vw, 520px);
  --orbit-inner-width: clamp(440px, 56vw, 660px);
  --orbit-inner-height: clamp(250px, 31vw, 365px);
  --orbit-radius-x: clamp(330px, 38vw, 450px);
  --orbit-radius-y: clamp(190px, 22vw, 260px);
  --orbit-icon-size: clamp(68px, 7vw, 84px);
  background:
    radial-gradient(circle at 50% 42%, rgba(63, 93, 126, 0.12), transparent 30%),
    radial-gradient(circle at 18% 12%, rgba(73, 92, 112, 0.1), transparent 26%),
    var(--cosmos-bg);
}

html[data-theme="light"] body[data-page="home"] {
  --cosmos-bg: #eef2f5;
  --cosmos-glow: rgba(172, 108, 8, 0.26);
  --cosmos-glow-strong: rgba(145, 89, 4, 0.48);
  --cosmos-line: rgba(139, 96, 23, 0.12);
  --cosmos-line-strong: rgba(139, 96, 23, 0.26);
  --cosmos-star: #9a6815;
  --cosmos-dot: #b87917;
  --wind-line: rgba(139, 96, 23, 0.1);
  --cosmos-label-bg: rgba(255, 255, 255, 0.92);
  --nebula-cool-a: rgba(118, 149, 181, 0.045);
  --nebula-cool-b: rgba(156, 176, 195, 0.034);
  --nebula-warm: rgba(187, 145, 77, 0.012);
  --cosmos-grain-opacity: 0.007;
  --cosmos-grain-blend: multiply;
  background:
    radial-gradient(circle at 50% 42%, rgba(144, 169, 196, 0.12), transparent 30%),
    radial-gradient(circle at 18% 12%, rgba(170, 185, 199, 0.14), transparent 26%),
    var(--cosmos-bg);
}

body[data-page="home"] .cosmos-hero {
  position: relative;
  width: 100%;
  min-height: calc(100svh - 66px);
  padding: 0 0 48px;
  overflow: hidden;
  isolation: isolate;
}

body[data-page="home"] .cosmos-hero::before,
body[data-page="home"] .cosmos-hero::after {
  position: absolute;
  content: "";
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body[data-page="home"] .cosmos-hero::before {
  inset: -10%;
  background:
    radial-gradient(ellipse 68% 58% at 12% 26%, var(--nebula-cool-a), transparent 76%),
    radial-gradient(ellipse 64% 56% at 90% 72%, var(--nebula-cool-b), transparent 78%),
    radial-gradient(ellipse 42% 34% at 68% 10%, var(--nebula-warm), transparent 80%);
  opacity: 0.62;
  transform: translate3d(-0.7%, -0.45%, 0) scale(1.008);
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  animation: cosmos-atmosphere-drift 84s ease-in-out infinite alternate;
}

body[data-page="home"] .cosmos-hero::after {
  opacity: var(--cosmos-grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  background-size: 176px 176px;
  background-repeat: repeat;
  mix-blend-mode: var(--cosmos-grain-blend);
}

.cosmos-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 48px), 1180px);
  margin: 0 auto;
}

.cosmos-field {
  position: relative;
  width: 100%;
  height: var(--stage-height);
  min-height: 680px;
  margin: 0;
  overflow: visible;
  isolation: isolate;
}

.decorative-stars,
.note-stars,
.star-threads,
.project-orbit,
.wind-streams,
.cosmos-center,
.orbit-project,
.all-writing-link {
  position: absolute;
}

.decorative-stars,
.note-stars,
.star-threads,
.project-orbit,
.wind-streams {
  inset: 0;
}

.decorative-stars,
.star-threads,
.project-orbit {
  z-index: 1;
  pointer-events: none;
}

.decorative-star {
  position: absolute;
  width: calc(var(--star-size, 5px) * 0.62);
  height: calc(var(--star-size, 5px) * 0.62);
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 249, 224, 0.96) 0 16%, var(--cosmos-dot) 34%, color-mix(in srgb, var(--cosmos-dot) 42%, transparent) 62%, transparent 100%);
  box-shadow: 0 0 2px color-mix(in srgb, var(--cosmos-dot) 46%, transparent), 0 0 5px color-mix(in srgb, var(--cosmos-dot) 18%, transparent);
  filter: blur(0.18px);
  scale: 0.72;
  animation: ambient-twinkle var(--twinkle-duration, 4s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
}

html[data-theme="light"] .decorative-star {
  background: radial-gradient(circle, rgba(255, 246, 214, 0.94) 0 14%, var(--cosmos-dot) 34%, color-mix(in srgb, var(--cosmos-dot) 36%, transparent) 60%, transparent 100%);
  box-shadow: 0 0 1.5px color-mix(in srgb, var(--cosmos-dot) 40%, transparent), 0 0 4px color-mix(in srgb, var(--cosmos-dot) 14%, transparent);
}

.star-threads {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.star-thread {
  stroke: var(--cosmos-line);
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
  transition: stroke 220ms ease, opacity 220ms ease;
}

.star-thread.is-active { stroke: var(--cosmos-line-strong); }

.note-stars {
  z-index: 4;
  pointer-events: none;
}

.note-star {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 44px;
  height: 44px;
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  touch-action: manipulation;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.note-star-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--note-star-size, 12px);
  height: var(--note-star-size, 12px);
  background: var(--cosmos-star);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 71%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  opacity: 1;
  scale: 1;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 2.4px var(--cosmos-glow-strong)) drop-shadow(0 0 7px var(--cosmos-glow)) drop-shadow(0 0 12px color-mix(in srgb, var(--cosmos-glow) 88%, transparent));
  animation: note-star-twinkle var(--twinkle-duration, 3.8s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
}

.note-star-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  display: grid;
  gap: 3px;
  min-width: 164px;
  max-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--cosmos-line);
  border-radius: 16px;
  background: var(--cosmos-label-bg);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(12px);
}

.note-star-label time {
  color: var(--quiet);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.note-star-label > span { font-size: 0.82rem; }

.note-star:hover .note-star-label,
.note-star:focus-visible .note-star-label,
.note-star.is-touch-active .note-star-label {
  opacity: 1;
  transform: translate(-50%, 0);
}

.note-star:hover .note-star-core,
.note-star:focus-visible .note-star-core,
.note-star.is-touch-active .note-star-core {
  scale: 1.18;
  filter: drop-shadow(0 0 3.4px var(--cosmos-glow-strong)) drop-shadow(0 0 9px var(--cosmos-glow)) drop-shadow(0 0 15px color-mix(in srgb, var(--cosmos-glow) 94%, transparent));
}

.note-star.is-touch-active { z-index: 8; }
.note-star.is-touch-active .note-star-label { pointer-events: auto; }

body[data-page="home"].windy .note-star-core {
  filter: drop-shadow(0 0 3.1px var(--cosmos-glow-strong)) drop-shadow(0 0 8.5px var(--cosmos-glow)) drop-shadow(0 0 14px color-mix(in srgb, var(--cosmos-glow) 92%, transparent));
}

.wind-streams {
  z-index: 2;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.wind-stream {
  position: absolute;
  left: -42%;
  width: clamp(240px, 38vw, 500px);
  height: clamp(34px, 5vw, 66px);
  border-top: 1px solid var(--wind-line);
  border-radius: 50%;
  opacity: 0;
  filter: blur(0.15px);
}

.wind-stream:nth-child(1) { top: 24%; }
.wind-stream:nth-child(2) { top: 43%; width: clamp(190px, 31vw, 410px); animation-delay: 90ms !important; }
.wind-stream:nth-child(3) { top: 62%; width: clamp(280px, 44vw, 560px); animation-delay: 180ms !important; }
.cosmos-field[data-wind-direction] .wind-streams { opacity: 1; }
.cosmos-field[data-wind-direction="right"] .wind-stream { animation: wind-flow-right var(--wind-duration, 2.2s) cubic-bezier(.2, .7, .25, 1) both; }
.cosmos-field[data-wind-direction="left"] .wind-stream { right: -42%; left: auto; animation: wind-flow-left var(--wind-duration, 2.2s) cubic-bezier(.2, .7, .25, 1) both; }

.project-orbit-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--orbit-width);
  height: var(--orbit-height);
  border: 1.25px solid rgba(255, 223, 157, 0.21);
  border-radius: 50%;
  opacity: 0.96;
  transform: translate(-50%, -50%);
}

.project-orbit-line-inner {
  width: var(--orbit-inner-width);
  height: var(--orbit-inner-height);
  border-color: rgba(255, 255, 255, 0.085);
  opacity: 0.82;
}

html[data-theme="light"] .project-orbit-line { border-color: rgba(139, 96, 23, 0.2); }
html[data-theme="light"] .project-orbit-line-inner { border-color: rgba(139, 96, 23, 0.075); }

.cosmos-center {
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  justify-items: center;
  transform: translate(-50%, -50%);
}

.cosmos-center img {
  width: clamp(78px, 10vw, 104px);
  height: clamp(78px, 10vw, 104px);
  border-radius: 26%;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 42px rgba(0, 0, 0, 0.14);
}

.cosmos-center h1 {
  margin: 22px 0 0;
  font-size: clamp(2.8rem, 6vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: -0.08em;
}

.cosmos-center time {
  margin-top: 12px;
  color: var(--quiet);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}

.cosmos-center img,
.orbit-icon-shell img {
  display: block;
  image-rendering: auto;
  transform: none;
}

.orbit-project {
  --orbit-duration: 56s;
  left: 0;
  top: 0;
  width: var(--orbit-icon-size);
  height: var(--orbit-icon-size);
  offset-path: ellipse(var(--orbit-radius-x) var(--orbit-radius-y) at 50% 50%);
  offset-distance: 0%;
  offset-rotate: 0deg;
  transform-origin: center;
  will-change: offset-distance, opacity;
  animation: project-orbit var(--orbit-duration) linear infinite, project-orbit-depth var(--orbit-duration) linear infinite;
}

.orbit-icon-shell {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  border-radius: 26%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.13), 0 0 0 1px rgba(255, 255, 255, 0.22);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

html[data-theme="light"] .orbit-icon-shell {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(61, 72, 84, 0.1), 0 0 0 1px rgba(50, 60, 70, 0.09);
}

.orbit-icon-shell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.orbit-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  padding: 6px 10px;
  border: 1px solid var(--cosmos-line);
  border-radius: 999px;
  background: var(--cosmos-label-bg);
  font-size: 0.72rem;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.orbit-project:hover,
.orbit-project:focus-visible { outline: none; animation-play-state: paused; }
.orbit-project:hover .orbit-icon-shell,
.orbit-project:focus-visible .orbit-icon-shell { transform: scale(1.04); }
.orbit-project:hover .orbit-tooltip,
.orbit-project:focus-visible .orbit-tooltip { opacity: 1; }

.all-writing-link {
  right: 14px;
  bottom: 18px;
  z-index: 6;
  color: var(--quiet);
  font-size: 0.84rem;
}

.footer-links { display: flex; gap: 20px; }

body.is-page-hidden .cosmos-hero::before,
body.is-page-hidden .orbit-project,
body.is-page-hidden .decorative-star,
body.is-page-hidden .note-star-core,
body.is-page-hidden .wind-stream { animation-play-state: paused !important; }

@keyframes cosmos-atmosphere-drift {
  0% { opacity: 0.56; transform: translate3d(-0.7%, -0.45%, 0) scale(1.008) rotate(-0.05deg); }
  34% { opacity: 0.66; transform: translate3d(0.65%, -0.18%, 0) scale(1.016) rotate(0.03deg); }
  68% { opacity: 0.6; transform: translate3d(0.35%, 0.7%, 0) scale(1.012) rotate(0.05deg); }
  100% { opacity: 0.64; transform: translate3d(-0.35%, 0.28%, 0) scale(1.014) rotate(-0.03deg); }
}

@keyframes ambient-twinkle {
  0%, 64%, 100% { opacity: 0; scale: 0.58; }
  70% { opacity: calc(var(--star-opacity, 0.72) * 0.14); scale: 0.72; }
  76% { opacity: var(--star-opacity, 0.72); scale: 1; }
  82% { opacity: calc(var(--star-opacity, 0.72) * 0.22); scale: 0.78; }
  88% { opacity: 0; scale: 0.62; }
}

@keyframes note-star-twinkle {
  0%, 100% { opacity: 1; scale: 0.995; filter: drop-shadow(0 0 2.4px var(--cosmos-glow-strong)) drop-shadow(0 0 7px var(--cosmos-glow)) drop-shadow(0 0 12px color-mix(in srgb, var(--cosmos-glow) 88%, transparent)); }
  50% { opacity: 1; scale: 1.11; filter: drop-shadow(0 0 3.8px var(--cosmos-glow-strong)) drop-shadow(0 0 11px var(--cosmos-glow)) drop-shadow(0 0 18px color-mix(in srgb, var(--cosmos-glow) 100%, transparent)); }
}

@keyframes wind-flow-right {
  0% { opacity: 0; transform: translateX(0) scaleX(0.72); }
  24% { opacity: 0.5; }
  100% { opacity: 0; transform: translateX(185vw) scaleX(1.08); }
}

@keyframes wind-flow-left {
  0% { opacity: 0; transform: translateX(0) scaleX(0.72); }
  24% { opacity: 0.5; }
  100% { opacity: 0; transform: translateX(-185vw) scaleX(1.08); }
}

@keyframes project-orbit { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@keyframes project-orbit-depth {
  0%, 100% { z-index: 2; opacity: 0.86; }
  22% { z-index: 3; opacity: 0.94; }
  46%, 54% { z-index: 5; opacity: 1; }
  78% { z-index: 3; opacity: 0.94; }
}

@media (hover: none), (pointer: coarse) {
  .note-star-label { min-width: min(168px, calc(100vw - 36px)); max-width: min(210px, calc(100vw - 36px)); padding: 9px 11px; }
  .note-star:focus-visible .note-star-label { opacity: 0; transform: translate(-50%, 6px); }
  .note-star.is-touch-active:focus-visible .note-star-label { opacity: 1; transform: translate(-50%, 0); }
  .orbit-project:hover { animation-play-state: running; }
  .orbit-project:hover .orbit-icon-shell,
  .orbit-project:focus-visible .orbit-icon-shell { transform: none; }
}

@media (max-width: 780px) {
  body[data-page="home"] {
    --stage-height: 720px;
    --orbit-width: min(620px, calc(100vw - 56px));
    --orbit-height: min(360px, 46vw);
    --orbit-inner-width: min(440px, calc(100vw - 150px));
    --orbit-inner-height: min(255px, 33vw);
    --orbit-radius-x: min(310px, 46vw);
    --orbit-radius-y: min(180px, 23vw);
  }
  .cosmos-shell { width: min(calc(100% - 28px), 700px); }
  .cosmos-field { min-height: 0; }
}

@media (max-width: 560px) {
  body[data-page="home"] {
    --stage-height: clamp(620px, calc(100svh - 62px), 720px);
    --orbit-width: min(380px, calc(100vw - 36px));
    --orbit-height: clamp(190px, 52vw, 220px);
    --orbit-inner-width: min(270px, calc(100vw - 108px));
    --orbit-inner-height: clamp(142px, 38vw, 156px);
    --orbit-radius-x: min(190px, 45vw);
    --orbit-radius-y: clamp(95px, 26vw, 110px);
    --orbit-icon-size: 64px;
  }
  body[data-page="home"] .cosmos-hero { min-height: auto; padding-bottom: 28px; }
  body[data-page="home"] .cosmos-hero::before { inset: -16%; animation-duration: 90s; }
  body[data-page="home"] .cosmos-hero::after { background-size: 148px 148px; }
  .cosmos-shell { width: 100%; }
  .cosmos-center { top: 51%; }
  .cosmos-center img { width: 82px; height: 82px; }
  .cosmos-center h1 { margin-top: 18px; font-size: clamp(3.1rem, 14vw, 3.65rem); }
  .cosmos-center time { margin-top: 10px; }
  .orbit-icon-shell { border-radius: 24%; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.24); }
  .note-star-label { min-width: 140px; max-width: 170px; backdrop-filter: blur(8px); }
  .all-writing-link { right: 18px; bottom: 14px; }
}

@media (max-width: 380px) {
  body[data-page="home"] { --stage-height: 640px; --orbit-icon-size: 60px; }
  .cosmos-center img { width: 76px; height: 76px; }
  .cosmos-center h1 { font-size: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="home"] .cosmos-hero::before { opacity: 0.58; transform: none; animation: none; }
  .decorative-star { opacity: calc(var(--star-opacity, 0.72) * 0.46); scale: 0.78; animation: none; }
  .note-star-core { opacity: 1; animation: none; }
  .orbit-project { z-index: 5; offset-distance: 18%; opacity: 1; animation: none; }
  .wind-streams { display: none; }
}
