/* ============================================================
   APAMU — a page about my universe
   ============================================================ */

:root {
  --bg:        #04050a;
  --fg:        #ece7dc;
  --fg-faint:  #3a362f;
  --accent:    #d8c39a;

  --ease-soft: cubic-bezier(.22,.61,.36,1);
  --ease-out:  cubic-bezier(.19,1,.22,1);

  --serif:     'Fraunces', ui-serif, Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body {
  background:
    /* brighter nebulae */
    radial-gradient(ellipse 55% 45% at 18% 22%, rgba(120, 80, 180, .22), transparent 60%),
    radial-gradient(ellipse 50% 42% at 82% 78%, rgba(60, 110, 180, .20), transparent 62%),
    radial-gradient(ellipse 40% 30% at 65% 25%, rgba(200, 120, 80, .08), transparent 65%),
    /* deep space base */
    radial-gradient(ellipse 120% 90% at 50% 50%, #0d1020 0%, #050612 70%, #02030a 100%);
  min-height: 100vh;
  min-height: 100svh;
}

::selection { background: rgba(216, 195, 154, .28); color: var(--fg); }

/* ------------------------------------------------------------
   Sky
   ------------------------------------------------------------ */

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 130% 85% at 50% 50%, transparent 58%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply;
}

/* ------------------------------------------------------------
   Hero
   ------------------------------------------------------------ */

.hero {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
  text-align: center;
}

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.5rem, 4vh, 2.25rem);
}

/* --- Title -------------------------------------------------- */

.title {
  --size: clamp(4.6rem, 17vw, 11rem);
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "wght" 260, "SOFT" 30;
  font-weight: 300;
  font-size: var(--size);
  line-height: .95;
  letter-spacing: .18em;
  padding-left: .18em;
  color: var(--fg);
  display: inline-block;
  will-change: transform;
  user-select: none;
  position: relative;
  transform-style: preserve-3d;
}

.title::before,
.title::after {
  content: '';
  position: absolute;
  top: 50%;
  width: clamp(28px, 6vw, 56px);
  height: 1px;
  background: linear-gradient(to right, transparent, var(--fg-faint), transparent);
  opacity: 0;
  animation: fade-in 2s var(--ease-out) 1.6s forwards;
}
.title::before { right: calc(100% + clamp(.6rem, 2vw, 1.25rem)); }
.title::after  { left:  calc(100% + clamp(.6rem, 2vw, 1.25rem));
                 background: linear-gradient(to left, transparent, var(--fg-faint), transparent); }

/* --- Constellation letters --------------------------------- */

.letter {
  display: inline-block;
  height: 1em;
  width: auto;
  vertical-align: baseline;
  overflow: visible;
  opacity: 0;
  transform: translateY(14px);
  animation-name: letter-enter, letter-float;
  animation-duration: 1.4s, calc(11s + var(--i) * .9s);
  animation-timing-function: var(--ease-out), ease-in-out;
  animation-delay: calc(.25s + var(--i) * .18s), calc(4s + var(--i) * .7s);
  animation-iteration-count: 1, infinite;
  animation-fill-mode: forwards, none;
}

@keyframes letter-enter {
  to { opacity: 1; transform: translateY(0); }
}

/* barely-there vertical drift — gives the constellation a subtle life  */
@keyframes letter-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2.5px); }
}

.letter-lines {
  filter:
    drop-shadow(0 0 1.5px rgba(255, 232, 188, .35))
    drop-shadow(0 0 5px   rgba(255, 210, 150, .12));
}

.letter-lines line {
  stroke: rgba(240, 232, 210, .78);
  stroke-width: 2.1;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  animation: draw-line 1.8s var(--ease-out) forwards;
  animation-delay: calc(.9s + var(--i) * .18s + var(--k) * .09s);
}

@keyframes draw-line {
  0%   { stroke-dashoffset: 1; opacity: 0; }
  15%  { opacity: .78; }
  100% { stroke-dashoffset: 0; opacity: .78; }
}

.letter-dots {
  filter: drop-shadow(0 0 3px rgba(255, 228, 180, .75));
}

.letter-dots circle {
  fill: #fff3d4;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation:
    dot-pop 0.9s var(--ease-out) forwards,
    dot-twinkle calc(2.8s + var(--j) * .35s) ease-in-out infinite;
  animation-delay:
    calc(.55s + var(--i) * .18s + var(--j) * .08s),
    calc(2.8s + var(--j) * .4s + var(--i) * .15s);
}

@keyframes dot-pop {
  0%   { opacity: 0; transform: scale(.2); }
  60%  { opacity: 1; transform: scale(1.5); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes dot-twinkle {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

@keyframes fade-in { to { opacity: 1; transform: none; } }

/* --- Tagline ----------------------------------------------- */

.tagline {
  display: inline-flex;
  align-items: center;
  gap: clamp(.9rem, 2.5vw, 1.5rem);
  font-family: var(--serif);
  font-variation-settings: "opsz" 14, "wght" 300, "SOFT" 100;
  font-size: clamp(.82rem, 1.35vw, 1rem);
  font-weight: 300;
  letter-spacing: .32em;
  text-transform: lowercase;
  color: var(--fg);
  opacity: 0;
  animation: fade-in 2.4s var(--ease-out) 1.9s forwards;
}

.tagline-text {
  white-space: nowrap;
  color: rgba(236, 231, 220, .6);
}

.tagline-rule {
  display: inline-block;
  width: clamp(24px, 5vw, 48px);
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(216, 195, 154, .5), transparent);
}

/* ------------------------------------------------------------
   Modes  (hero  →  compose  →  black hole  →  hero)
   ------------------------------------------------------------ */

.hero {
  transition: opacity .8s var(--ease-out), transform 1s var(--ease-out), filter .8s var(--ease-out);
}
.hero-inner {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: transform .6s var(--ease-soft);
}
.hero-inner:hover    { transform: translateY(-2px); }
.hero-inner:focus-visible .tagline-text { color: rgba(236, 231, 220, .9); }

body.mode-compose .hero {
  opacity: 0;
  transform: scale(.96) translateY(-18px);
  filter: blur(6px);
  pointer-events: none;
}

/* Compose layer */
.compose {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vh, 4rem) clamp(1.25rem, 5vw, 2rem);
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
  transition:
    opacity .9s var(--ease-out) .15s,
    transform .9s var(--ease-out) .15s,
    filter .6s var(--ease-out);
}

body.mode-compose .compose {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.compose-inner {
  width: min(640px, 92vw);
  height: 78vh;
  height: 78svh;
  max-height: 36rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(1.5rem, 4vh, 2.5rem);
}

.compose-header {
  font-family: var(--serif);
  font-variation-settings: "opsz" 48, "wght" 320, "SOFT" 60;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  color: rgba(240, 232, 210, .85);
  text-align: center;
  letter-spacing: .015em;
  line-height: 1.35;
}

.compose-text {
  width: 100%;
  height: 100%;
  padding: 1.25rem .25rem;
  background: transparent;
  color: rgba(240, 232, 210, .95);
  font-family: var(--serif);
  font-variation-settings: "opsz" 14, "wght" 340, "SOFT" 100;
  font-size: clamp(.98rem, 2vw, 1.08rem);
  line-height: 1.85;
  letter-spacing: .005em;
  border: none;
  border-top:    1px solid rgba(240, 232, 210, .12);
  border-bottom: 1px solid rgba(240, 232, 210, .12);
  outline: none;
  resize: none;
  caret-color: var(--accent);
  transition: border-color .35s var(--ease-soft);
}
.compose-text::placeholder {
  color: rgba(240, 232, 210, .28);
  font-style: italic;
}
.compose-text:focus {
  border-top-color:    rgba(240, 232, 210, .32);
  border-bottom-color: rgba(240, 232, 210, .32);
}

/* Submit — looks asleep, but still clickable */
.compose-submit {
  justify-self: center;
  padding: .95rem 2.3rem;
  background: transparent;
  border: 1px solid rgba(240, 232, 210, .14);
  color: rgba(240, 232, 210, .32);
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 14, "wght" 340, "SOFT" 100;
  font-size: .95rem;
  letter-spacing: .04em;
  cursor: not-allowed;
  user-select: none;
  border-radius: 2px;
  position: relative;
  transform: translateZ(0);
  transition: color .45s var(--ease-soft), border-color .45s var(--ease-soft);
  -webkit-tap-highlight-color: transparent;
}
.compose-submit:hover {
  color: rgba(240, 232, 210, .42);
  border-color: rgba(240, 232, 210, .22);
}

/* three escalating shake intensities */
.compose-submit.shake-1 { animation: shake-1 .35s cubic-bezier(.36,.07,.19,.97); }
.compose-submit.shake-2 {
  animation: shake-2 .5s  cubic-bezier(.36,.07,.19,.97);
  color: rgba(240, 220, 190, .55);
}
.compose-submit.shake-3 {
  animation: shake-3 .7s  cubic-bezier(.36,.07,.19,.97);
  color: rgba(255, 190, 160, .75);
  border-color: rgba(255, 190, 160, .35);
}

@keyframes shake-1 {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}
@keyframes shake-2 {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(5px, -1px, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 1px, 0); }
  40%, 60% { transform: translate3d(6px, -1px, 0); }
}
@keyframes shake-3 {
  10%, 90% { transform: translate3d(-3px, 2px, 0) rotate(-.4deg); }
  20%, 80% { transform: translate3d(8px, -2px, 0) rotate(.5deg); }
  30%, 50%, 70% { transform: translate3d(-10px, 2px, 0) rotate(-.5deg); }
  40%, 60% { transform: translate3d(10px, -2px, 0) rotate(.5deg); }
}

/* Black hole: compose gets sucked in */
body.mode-blackhole .compose {
  animation: suck-in 1.8s cubic-bezier(.55, 0, .75, 0) forwards;
  pointer-events: none;
}

@keyframes suck-in {
  0%   { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); filter: blur(0); }
  60%  { opacity: .5; filter: blur(3px); }
  100% { opacity: 0; transform: translateY(10px) scale(.16) rotate(110deg); filter: blur(10px); }
}

/* During blackhole the hero stays hidden (no snap-back flash) */
body.mode-blackhole .hero {
  opacity: 0;
  transform: scale(.96);
  filter: blur(6px);
  pointer-events: none;
}

/* Rebirth: when the black hole has completed, coast the hero back in */
body.mode-rebirth .hero {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
  transition: opacity 1s var(--ease-out) .15s, transform 1.2s var(--ease-out) .15s, filter 1s var(--ease-out) .15s;
}

/* ------------------------------------------------------------
   Mobile
   ------------------------------------------------------------ */

@media (max-width: 640px) {
  .title {
    letter-spacing: .12em;
    padding-left: .12em;
  }
  .title::before, .title::after { display: none; }

  .tagline {
    font-size: .72rem;
    letter-spacing: .24em;
    gap: .7rem;
  }
  .tagline-rule { width: 22px; }
}

@media (max-width: 380px) {
  .tagline-rule { display: none; }
}

@media (max-width: 640px) {
  .compose-header { font-size: 1.1rem; }
  .compose-inner  { gap: 1.25rem; height: 82svh; }
  .compose-submit { padding: .85rem 1.6rem; font-size: .85rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .letter { opacity: 1; transform: none; }
  .letter-lines line { stroke-dashoffset: 0; opacity: .78; }
  .letter-dots circle { opacity: 1; transform: scale(1); }
  .compose-submit.shake-1,
  .compose-submit.shake-2,
  .compose-submit.shake-3 { animation: none; }
}
