/* ===== Design tokens ===== */
:root {
  --space-deep: #050810;        /* page background — near-black blue */
  --space-mid: #0b1124;         /* raised surfaces */
  --hamal: #ffb45e;             /* the star — K-type orange giant */
  --hamal-bright: #ffd9a0;      /* hot inner glow */
  --hamal-deep: #e08a3c;        /* ember edge */
  --starlight: #eef2ff;         /* primary text — faint blue-white */
  --starlight-dim: #9aa3c0;     /* muted text */
  --accent: var(--hamal);
  --card: rgba(15, 22, 46, 0.55);
  --card-edge: rgba(154, 163, 192, 0.16);

  --radius: 16px;
  --maxw: 1080px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --glow: 0 0 24px rgba(255, 180, 94, 0.35);
  --font: "Inter", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--starlight);
  background: var(--space-deep);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* main fills the space between the nav and footer */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

::selection { background: rgba(255, 180, 94, 0.35); }

/* Lock scroll while the intro is playing */
body.intro-active { overflow: hidden; }

/* ===== Starfield & nebula backdrop ===== */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;   /* the bitmap is W×dpr — without this, a retina canvas */
  height: 100%;  /* displays at its intrinsic 2× size and draws off-target */
  z-index: 0;
  display: block;
  pointer-events: none;
}

.nebula {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 72% 22%, rgba(255, 150, 70, 0.10), transparent 70%),
    radial-gradient(45% 40% at 18% 68%, rgba(96, 78, 190, 0.13), transparent 70%),
    radial-gradient(30% 30% at 55% 85%, rgba(40, 110, 160, 0.10), transparent 70%);
  filter: blur(10px);
  animation: nebula-drift 60s ease-in-out infinite alternate;
}

@keyframes nebula-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 1.5%, 0) scale(1.06); }
}

/* Everything readable sits above the sky */
.nav, main, .footer { position: relative; z-index: 1; }

/* ===== Arrival choreography =====
   The flight happens on the #starfield canvas (script.js). When the
   canvas star settles into the title's seat, the real star element
   fades in over it first — one continuous star. Only once it holds
   its place does the name surface beside it, then the rest follows. */
body.intro-active main { opacity: 0; pointer-events: none; }

body.intro-active .hero > * { opacity: 0; }
body.entered .hero > * { animation: rise-in 0.9s ease both; }
body.entered .hero-title { animation: none; } /* its children stage their own entrance */
body.entered .hero-star  { animation: fade-in 0.55s ease both; }
body.entered .hero-word  { animation: word-in 1.1s ease 0.7s both; }
body.entered .hero-eyebrow { animation-delay: 1.45s; }
body.entered .hero-tagline { animation-delay: 1.65s; }
body.entered .hero .btn    { animation-delay: 1.8s; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* the name emerges from the star's side, its glow blooming with it */
@keyframes word-in {
  from {
    opacity: 0;
    filter: blur(0.08em) drop-shadow(0 0 28px rgba(255, 180, 94, 0));
  }
  to {
    opacity: 1;
    filter: blur(0) drop-shadow(0 0 28px rgba(255, 180, 94, 0.35));
  }
}

/* When motion is reduced, the flight is skipped (script) and fades are brief */
@media (prefers-reduced-motion: reduce) {
  .nebula { animation: none; }
  .hero-star svg, .hero-star .spike-d { animation: none; }
  .nav, .footer { transition-duration: 0.2s; transition-delay: 0s; }
  body.entered .hero > *,
  body.entered .hero-word,
  body.entered .hero-star { animation-duration: 0.01s; animation-delay: 0s; }
}

/* ===== Navigation ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 5vw, 40px);
  background: rgba(5, 8, 16, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-edge);
  opacity: 0;
  transition: opacity 0.9s ease 1.5s;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--starlight);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* the mark: an eight-pointed star sparkle */
.brand-mark {
  width: 24px;
  height: 24px;
  flex: none;
  filter: drop-shadow(0 0 7px rgba(255, 180, 94, 0.7));
}
.brand-mark svg { display: block; width: 100%; height: 100%; }

.nav-links { display: flex; gap: clamp(8px, 3vw, 24px); }

.nav-link {
  position: relative;
  text-decoration: none;
  color: var(--starlight-dim);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 6px 2px;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}
.nav-link:hover { color: var(--starlight); }
.nav-link.active {
  color: var(--hamal);
  text-shadow: 0 0 14px rgba(255, 180, 94, 0.55);
}
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--hamal);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--hamal);
}

/* ===== Views ===== */
.view { display: none; }
.view.active { display: block; animation: view-in 0.45s ease both; }

/* Landing page fills the viewport exactly (nav + hero + footer = one screen) */
#home.view.active { display: flex; flex: 1; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(40px, 7vw, 88px) clamp(16px, 5vw, 40px);
}

.view-head { margin-bottom: 36px; }
.view-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}
.view-head p { margin: 0; color: var(--starlight-dim); font-size: 1.1rem; }

/* ===== Hero (Home) ===== */
.hero {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  padding: clamp(24px, 6vw, 64px);
  gap: 18px;
}
.hero-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hamal);
  text-shadow: 0 0 16px rgba(255, 180, 94, 0.5);
}
.hero-eyebrow .greek { text-transform: none; }
.hero-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.14em;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.2rem, 11vw, 7.5rem);
  line-height: 0.98;
  letter-spacing: 0.02em;
}

/* the name carries its own gradient so it can enter after the star */
.hero-word {
  background: linear-gradient(180deg, #fff 10%, var(--hamal-bright) 55%, var(--hamal) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(255, 180, 94, 0.35));
}

/* the wordmark's star — a real element, so it can never drift or vanish.
   Baseline-aligned with cap height so it centers on the capitals optically.
   The canvas flight lands on this exact spot, then hands off to it. */
.hero-star {
  position: relative;
  width: 0.6em;
  height: 0.66em;
  flex: none;
}
.hero-star svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 0.12em rgba(255, 180, 94, 0.8));
  animation: star-breathe 3.8s ease-in-out infinite;
}

/* the twinkle: a slow breath of glow, with the diagonal rays
   shimmering on their own beat so it never feels mechanical */
.hero-star .spike-d { animation: spike-shimmer 2.6s ease-in-out infinite; }

@keyframes star-breathe {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 0.1em rgba(255, 180, 94, 0.7)); }
  50%      { transform: scale(1.07); filter: drop-shadow(0 0 0.22em rgba(255, 217, 160, 0.95)); }
}

@keyframes spike-shimmer {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.85; }
}
.hero-tagline {
  margin: 0 auto;
  max-width: 42ch;
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  color: var(--starlight-dim);
}

.btn {
  justify-self: center;
  margin-top: 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--space-deep);
  background: linear-gradient(180deg, var(--hamal-bright), var(--hamal));
  border: 1px solid rgba(255, 217, 160, 0.6);
  padding: 14px 30px;
  border-radius: 999px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 0 28px rgba(255, 180, 94, 0.35), 0 10px 24px rgba(0, 0, 0, 0.4);
}
.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 0 40px rgba(255, 180, 94, 0.55), 0 14px 28px rgba(0, 0, 0, 0.4);
}
.btn:active { transform: translateY(0); }

/* ===== Observations: the project constellation =====
   Each star on the chart is a project; templates hold seats for the
   next ones. Hover or focus a star and the chart entry reads below. */
.constellation-wrap {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: clamp(14px, 3.5vw, 34px);
}

.constellation { display: block; width: 100%; height: auto; }

/* the figure draws itself in when the chart opens */
.const-lines line {
  stroke: rgba(154, 163, 192, 0.3);
  stroke-width: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.view.active .const-lines line { animation: const-draw 1s ease forwards; }
.view.active .const-lines line:nth-child(1) { animation-delay: 0.15s; }
.view.active .const-lines line:nth-child(2) { animation-delay: 0.35s; }
.view.active .const-lines line:nth-child(3) { animation-delay: 0.55s; }
.view.active .const-lines line:nth-child(4) { animation-delay: 0.75s; }
.view.active .const-lines line:nth-child(5) { animation-delay: 0.95s; }

@keyframes const-draw { to { stroke-dashoffset: 0; } }

.const-star { cursor: pointer; outline: none; }
.const-star.is-template { cursor: default; }
.const-star .halo {
  fill: rgba(255, 180, 94, 0.14);
  transition: fill 0.25s ease;
}
.const-star .core {
  fill: var(--hamal-bright);
  animation: const-twinkle 3.2s ease-in-out infinite;
}
.const-star.is-template .halo { fill: rgba(154, 163, 192, 0.08); }
.const-star.is-template .core { fill: #b9c4e6; }

/* in progress: lit, but still condensing — the halo slowly swells */
.const-star.is-progress { cursor: default; }
.const-star.is-progress .core { fill: var(--hamal); }
.const-star.is-progress .halo {
  fill: rgba(255, 180, 94, 0.12);
  animation: const-rising 2.8s ease-in-out infinite;
}

@keyframes const-rising {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

.const-star .bayer {
  fill: rgba(154, 163, 192, 0.55);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
}
.const-star .const-label {
  fill: var(--starlight-dim);
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 0.05em;
  text-anchor: middle;
  transition: fill 0.25s ease;
}
.const-star.is-template .const-label {
  font-style: italic;
  fill: rgba(154, 163, 192, 0.6);
}

.const-star:hover .halo,
.const-star:focus-visible .halo { fill: rgba(255, 180, 94, 0.3); }
.const-star.is-template:hover .halo,
.const-star.is-template:focus-visible .halo { fill: rgba(154, 163, 192, 0.18); }
.const-star:hover .const-label,
.const-star:focus-visible .const-label { fill: var(--starlight); }

@keyframes const-twinkle {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.const-detail {
  margin: 20px 6px 0;
  min-height: 1.7em;
  color: var(--starlight-dim);
  font-size: 1rem;
}
.const-detail strong { color: var(--hamal-bright); font-weight: 600; }

/* labels stay legible when the chart scales down */
@media (max-width: 560px) {
  .const-star .const-label { font-size: 24px; }
  .const-star .bayer { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .const-star .core { animation: none; }
  .const-star.is-progress .halo { animation: none; }
  .view.active .const-lines line { animation: none; }
  .const-lines line { stroke-dashoffset: 0; }
}

/* ===== About ===== */
.about-body { max-width: 60ch; }
.about-body p { font-size: 1.1rem; margin: 0 0 18px; color: var(--starlight); }

.values {
  list-style: none;
  margin: 44px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
}
.values li {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.values h3 { margin: 0 0 8px; color: var(--hamal); }
.values p { margin: 0; color: var(--starlight-dim); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 28px 16px;
  color: var(--starlight-dim);
  font-size: 0.9rem;
  border-top: 1px solid var(--card-edge);
  background: rgba(5, 8, 16, 0.5);
  opacity: 0;
  transition: opacity 0.9s ease 1.7s;
}
.footer p { margin: 0; }

/* Header and footer fade in once the intro reveals the site */
body.entered .nav,
body.entered .footer { opacity: 1; }

/* ===== Responsive nav ===== */
@media (max-width: 520px) {
  .brand-text { display: none; }
}
