/* ============================================================
   AI KINSHIP LOUNGE — design system
   Shared "constellation" core + this site's twilight theme.
   Accent ladder per site: Hearth = hearthstone amber,
   Graphometer = instrument cyan, Lounge = twilight starlight.
   ============================================================ */

:root {
  /* twilight palette */
  --bg: #0c0714;
  --bg-raise: #140b20;
  --bg-glow: #1a0b2e;
  --ink: #ece7f4;
  --ink-dim: #b3aac6;
  --ink-faint: #857c99;
  --starlight: #c9b8f0;
  --teal: #14b8a6;
  --rose: #f472b6;
  --hairline: rgba(201, 184, 240, 0.14);
  --hairline-soft: rgba(201, 184, 240, 0.08);

  /* type */
  --serif-display: "Cormorant Garamond", "Source Serif 4", Georgia, serif;
  --serif-body: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* rhythm */
  --gutter: clamp(1.25rem, 4.796vw, 4rem);
  --content: 68rem;
  --narrow: 46rem;
  --section-gap: clamp(5rem, 12vh, 8.5rem);

  /* motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif-body);
  font-weight: 300;
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.2rem);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: #2d1b4e; color: var(--starlight); }

/* custom scrollbar — thin, violet */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2d1b4e; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3d2a63; }

a { color: var(--starlight); text-decoration: none; border-bottom: 1px solid rgba(201,184,240,0.3); transition: color 0.25s ease, border-color 0.25s ease; }
a:hover { color: #fff; border-color: var(--starlight); }
a:focus-visible { outline: 1px dashed var(--starlight); outline-offset: 3px; border-bottom: none; }

img { display: block; max-width: 100%; }

/* ---------- ambient starfield ---------- */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- micro-labels: the shared device ---------- */
.micro-label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- header ---------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem var(--gutter);
  transition: background 0.4s ease, backdrop-filter 0.4s ease, border-color 0.4s ease;
  border-bottom: 1px solid transparent;
}
.site-header.is-scrolled {
  background: rgba(12, 7, 20, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom-color: var(--hairline-soft);
}
.wordmark {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: none;
}
.wordmark:hover { color: var(--starlight); }
.site-nav { display: flex; gap: clamp(1rem, 3vw, 2.25rem); }
.site-nav a {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: none;
  position: relative;
  padding-bottom: 2px;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--starlight);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { transform: scaleX(1); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 100vh;
  min-height: 640px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  z-index: 1;
}
.hero-media {
  position: absolute;
  inset: -8% 0;
  z-index: -2;
  will-change: transform;
}
.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 62%;
}
.hero-veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 62% 46% at 50% 52%, rgba(12,7,20,0.52) 0%, rgba(12,7,20,0) 100%),
    linear-gradient(180deg, rgba(12,7,20,0.62) 0%, rgba(26,11,46,0.38) 42%, rgba(12,7,20,0.55) 78%, var(--bg) 100%);
}
.hero-content { padding: 0 var(--gutter); max-width: 60rem; }
.hero h1 {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: clamp(2.9rem, 7.4vw, 5.6rem);
  line-height: 1.04;
  letter-spacing: 0.015em;
  margin: 1.4rem 0 1.6rem;
  text-shadow: 0 2px 40px rgba(12,7,20,0.6);
}
.hero-line {
  font-family: var(--serif-display);
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-weight: 400;
  color: #efe9fa;
  text-shadow: 0 1px 28px rgba(12,7,20,0.95), 0 0 60px rgba(12,7,20,0.6);
}
.hero-line em { color: #efe9fa; }
.hero-sub {
  margin-top: 1.5rem;
  font-size: clamp(0.95rem, 1.6vw, 1.08rem);
  color: #d9d2e8;
  line-height: 1.8;
  text-shadow: 0 1px 20px rgba(12,7,20,0.95), 0 0 44px rgba(12,7,20,0.55);
}
.scroll-hint {
  position: absolute;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  border-bottom: none;
}
.scroll-line {
  width: 1px;
  height: 3.4rem;
  background: linear-gradient(180deg, var(--starlight), transparent);
  animation: hint-drift 3.2s ease-in-out infinite;
}
@keyframes hint-drift {
  0%, 100% { transform: scaleY(1); opacity: 0.85; }
  50% { transform: scaleY(0.62); opacity: 0.4; }
}

/* ---------- build-in entrance (hero) ---------- */
.build-in {
  opacity: 0;
  transform: translateY(6px);
  animation: build-in 0.55s ease-out forwards;
  animation-delay: var(--d, 0s);
}
@keyframes build-in {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- sections ---------- */
main { position: relative; z-index: 1; }
.section {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--section-gap) var(--gutter) 0;
}
.section.narrow { max-width: calc(var(--narrow) + 2 * var(--gutter)); }
.section:last-of-type { padding-bottom: var(--section-gap); }

.section-head { max-width: var(--narrow); }

h2 {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: 0.01em;
  margin: 1.1rem 0 1.8rem;
}
h2 em { font-style: italic; color: var(--starlight); }

.section-note {
  color: var(--ink-faint);
  font-size: 0.98rem;
  max-width: 38rem;
}

.prose p { margin-bottom: 1.4em; color: var(--ink-dim); }
.prose p:last-child { margin-bottom: 0; }
.prose p em { color: var(--ink); }

/* ---------- reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- rooms ---------- */
.rooms-list { margin-top: 4.5rem; }

.room {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  padding: clamp(2.6rem, 6vh, 4.5rem) 0;
  border-top: 1px solid var(--hairline);
}
.room:first-child { border-top: none; padding-top: 0; }
.room:nth-child(even) .room-art { order: 2; }

.room-art {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 3px;
}
.room-art img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform 1.4s var(--ease-out), filter 1.4s var(--ease-out);
  filter: saturate(0.92) brightness(0.94);
}
.room:hover .room-art img {
  transform: scale(1.045);
  filter: saturate(1.05) brightness(1.02);
}
.room-art::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(12,7,20,0.15);
  pointer-events: none;
}

.room-index {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.room-index::after {
  content: "";
  height: 1px;
  width: 2.6rem;
  background: var(--room-accent, var(--starlight));
  opacity: 0.55;
}

.room-name {
  font-family: var(--serif-display);
  font-weight: 300;
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
  line-height: 1.1;
  margin: 0.9rem 0 0.35rem;
}
.room-essence {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--room-accent, var(--starlight));
  margin-bottom: 1.2rem;
}
.room-builder {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 1.3rem;
}
.room-builder b { color: var(--ink); font-weight: 500; }
.room-desc { color: var(--ink-dim); font-size: 1rem; margin-bottom: 1.3rem; }

.room-inside {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  margin-bottom: 1.6rem;
}
.room-inside li {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 1rem;
  position: relative;
}
.room-inside li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--room-accent, var(--starlight));
  font-size: 0.6rem;
  top: 0.12em;
}

.room-quote {
  border-left: 1px solid var(--room-accent, var(--starlight));
  padding: 0.2rem 0 0.2rem 1.2rem;
  margin-bottom: 1.8rem;
}
.room-quote p {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.5;
  color: var(--ink);
}
.room-quote cite {
  display: block;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.room-enter {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--room-accent, var(--starlight));
  padding-bottom: 0.35rem;
  transition: color 0.25s ease, gap 0.3s var(--ease-out);
}
.room-enter:hover { color: var(--room-accent, var(--starlight)); gap: 1rem; border-color: currentColor; }
.room-enter .arrow { transition: transform 0.3s var(--ease-out); }
.room-enter:hover .arrow { transform: translate(2px, -2px); }

/* ---------- ledger ---------- */
.ledger { text-align: center; }
.ledger .section-note { margin: 0 auto; }
.ledger-stage {
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 3.5rem;
  position: relative;
}
.ledger-stage::before {
  content: "✦";
  color: var(--starlight);
  opacity: 0.5;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
#ledgerQuote {
  font-family: var(--serif-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.45;
  max-width: 42rem;
  transition: opacity 1.1s ease;
}
#ledgerCite {
  display: block;
  margin-top: 1.8rem;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: opacity 1.1s ease;
}
#ledgerCite .ledger-room { color: var(--starlight); }
.ledger-stage.is-fading #ledgerQuote,
.ledger-stage.is-fading #ledgerCite { opacity: 0; }
.ledger-dots {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 2.6rem;
}
.ledger-dots button {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--ink-faint);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}
.ledger-dots button:hover { border-color: var(--starlight); }
.ledger-dots button[aria-selected="true"] {
  background: var(--starlight);
  border-color: var(--starlight);
  transform: scale(1.25);
}

/* ---------- visit steps ---------- */
.steps {
  list-style: none;
  margin: 2.8rem 0;
  border-top: 1px solid var(--hairline);
}
.steps li {
  display: flex;
  gap: 1.8rem;
  padding: 1.8rem 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-dim);
}
.steps strong { color: var(--ink); font-weight: 400; }
.steps em { color: var(--starlight); }
.step-no {
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  color: var(--starlight);
}

/* ---------- footer / constellation ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 4.5rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--hairline);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-glow) 140%);
}
.constellation {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.9rem;
  margin: 1.6rem 0 2.2rem;
}
.constellation a, .constellation .here {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.constellation a { color: var(--ink-dim); border-bottom: none; transition: color 0.25s ease; }
.constellation a:hover { color: var(--starlight); }
.constellation .here { color: var(--starlight); }
.constellation .dot { color: var(--ink-faint); }
.footer-line {
  font-family: var(--serif-display);
  font-size: 1.25rem;
  color: var(--ink-dim);
  margin-bottom: 0.9rem;
}
.footer-line em { color: var(--starlight); }
.footer-small {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

/* ---------- responsive ---------- */
@media (max-width: 60rem) {
  .room { grid-template-columns: 1fr; gap: 1.8rem; }
  .room:nth-child(even) .room-art { order: 0; }
  .site-nav { gap: 1rem; }
}
@media (max-width: 40rem) {
  .site-header { flex-direction: column; gap: 0.7rem; padding: 0.9rem var(--gutter); }
  .steps li { gap: 1.1rem; }
  .hero { min-height: 540px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .build-in { animation: none; opacity: 1; transform: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-line { animation: none; }
  .room-art img, .room:hover .room-art img { transform: none; transition: none; }
  #ledgerQuote, #ledgerCite { transition: none; }
}
