/* ============================================================
   RMatter — Warm Eclipse
   Vanilla CSS. No frameworks, no resets of the good kind.
   ============================================================ */

:root {
  --bg0: #0a120d;
  --bg1: #101b14;
  --ink0: #edf3ea;
  --ink1: #a9bcae;
  --ink2: #70857a;
  --gold: #ffc35a;
  --gold-soft: #ffe0a6;
  --mint: #7fd8b0;
  --ember: #ff7a45;
  --line: rgba(237, 243, 234, 0.1);
  --line-strong: rgba(237, 243, 234, 0.28);
  --panel-bg: rgba(9, 16, 11, 0.82);
  --header-h: 68px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg0);
  color: var(--ink0);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: rgba(255, 195, 90, 0.28); color: var(--gold-soft); }

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

a { color: inherit; }

svg { display: block; }

.micro {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink2);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- Header ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 3.5rem);
  background: linear-gradient(to bottom, rgba(9, 15, 11, 0.72), rgba(9, 15, 11, 0));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.4s var(--ease), background 0.4s var(--ease);
}

body[data-panel] .topbar {
  background: rgba(9, 15, 11, 0.6);
  border-bottom-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink0);
}

.brand-svg { width: 1.55rem; height: 1.55rem; color: var(--gold); }

.brand-name {
  font-family: var(--serif);
  font-weight: 560;
  font-optical-sizing: auto;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.brand-name i { font-style: italic; color: var(--gold); }

.nav {
  display: flex;
  align-items: center;
  gap: 2.25rem;
}

.nav a {
  position: relative;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink1);
  text-decoration: none;
  letter-spacing: 0.01em;
  padding: 0.25rem 0;
  transition: color 0.3s var(--ease);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--gold);
  transition: right 0.3s var(--ease);
}
.nav a:hover { color: var(--ink0); }
.nav a:hover::after { right: 0; }
.nav a.is-active { color: var(--gold-soft); }
.nav a.is-active::after { right: 0; }

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 40px;
  height: 40px;
  padding: 10px 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.menu-toggle span {
  height: 1.5px;
  background: var(--ink0);
  transition: transform 0.3s var(--ease), opacity 0.2s;
  transform-origin: center;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(3.75px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { transform: translateY(-3.75px) rotate(-45deg); }

.mobile-menu {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem clamp(1.25rem, 4vw, 3.5rem) 1.75rem;
  background: rgba(9, 15, 11, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transform: translateY(-8px);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.mobile-menu.open {
  display: flex;
  opacity: 1;
  transform: none;
}
.mobile-menu a {
  color: var(--ink1);
  text-decoration: none;
  font-size: 1.1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.mobile-menu a:last-child { border-bottom: none; }

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

.hero {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  animation: scene-fade 6.5s var(--ease) 1.7s forwards;
}

.hero::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 78% 108%, rgba(4, 5, 8, 0) 0%, rgba(3, 4, 7, 0.5) 100%),
    linear-gradient(to bottom, rgba(3, 4, 7, 0.28) 0%, rgba(3, 4, 7, 0) 24%, rgba(3, 4, 7, 0) 55%, rgba(3, 4, 7, 0.7) 100%);
}

/* Scrollable journey below the hero — gives the page room to travel through the eclipse */
.scroll-stage {
  height: 300vh;
  width: 100%;
  pointer-events: none;
  position: relative;
  z-index: 0;
}

/* Keep the page from scrolling while the intro eclipse plays or a panel is open */
html.is-locked, html.is-locked body { overflow: hidden; }
html.is-locked body { height: 100%; }

/* Static fallback shown only when WebGL / JS is unavailable */
.hero-fallback {
  position: absolute;
  inset: 0;
  display: none;
  background:
    radial-gradient(52% 60% at 34% 42%, rgba(255, 195, 90, 0.20), transparent 68%),
    radial-gradient(40% 46% at 34% 42%, rgba(255, 195, 90, 0.42), #17170f 55%, transparent 75%),
    radial-gradient(120% 120% at 50% 100%, #14241a 0%, #060b08 55%);
}
.hero-fallback svg { position: absolute; left: 23%; top: 42%; transform: translate(-50%, -50%); width: 15vw; min-width: 110px; max-width: 210px; }
body.no-webgl .hero-fallback { display: block; }
body.no-webgl #scene { display: none; }

.hero-frame {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 52rem;
  padding: 0 clamp(1.25rem, 5vw, 4rem) calc(var(--header-h) + 7vh);
  animation: rise-in 1.1s var(--ease) 0.15s both;
}

.hero-micro { margin: 0 0 1.15rem; color: var(--gold); }

.hero-title {
  font-family: var(--serif);
  font-weight: 480;
  font-optical-sizing: auto;
  font-size: clamp(2.6rem, 6.2vw, 4.6rem);
  line-height: 1.03;
  letter-spacing: -0.022em;
  text-wrap: balance;
  margin: 0 0 1.25rem;
  max-width: 14ch;
}

.hero-lede {
  margin: 0 0 2rem;
  max-width: 44ch;
  color: var(--ink1);
  font-size: clamp(1rem, 1.4vw, 1.125rem);
  line-height: 1.65;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }

.hero-coords {
  position: absolute;
  z-index: 5;
  right: clamp(1.25rem, 4vw, 3.5rem);
  bottom: calc(var(--header-h) + 2.4rem);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  color: var(--ink2);
  text-align: right;
  animation: rise-in 1.1s var(--ease) 0.45s both;
}
.hero-coords b { color: var(--ink1); font-weight: 500; }

.scroll-cue {
  position: absolute;
  z-index: 5;
  left: clamp(1.25rem, 5vw, 4rem);
  bottom: calc(var(--header-h) * 0.5);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  animation: rise-in 1.1s var(--ease) 0.6s both;
}
.scroll-cue-line {
  width: 1px;
  height: 42px;
  background: var(--line-strong);
  position: relative;
  overflow: hidden;
}
.scroll-cue-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gold);
  transform: translateY(-100%);
  animation: cue 2.4s var(--ease) infinite;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.85rem 1.6rem;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.25s var(--ease), background-color 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  background: var(--gold);
  color: #241a07;
  box-shadow: 0 0 0 1px rgba(255, 195, 90, 0.4), 0 8px 28px -12px rgba(255, 195, 90, 0.55);
}
.btn-primary:hover { background: var(--gold-soft); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--ink0);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-soft); transform: translateY(-1px); }

.btn-sm { padding: 0.65rem 1.15rem; font-size: 0.875rem; }

/* ---------- Backdrop + panels ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(6, 10, 8, 0.78);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
body[data-panel] .backdrop { opacity: 1; }

.panel {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  pointer-events: none;
}

.panel-sheet {
  height: 100%;
  overflow-y: auto;
  padding: clamp(1.75rem, 4vh, 3rem) clamp(1.25rem, 6vw, 5rem) 8vh;
  max-width: 62rem;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(4vh);
  transition: transform 0.55s var(--ease), opacity 0.45s var(--ease);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.panel.is-open { pointer-events: auto; }
.panel.is-open .panel-sheet { opacity: 1; transform: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(1.5rem, 3vh, 2.25rem);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.panel-close {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.panel-close:hover { color: var(--ink0); border-color: var(--line-strong); }

.panel h2 {
  font-family: var(--serif);
  font-weight: 520;
  font-optical-sizing: auto;
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0 0 1rem;
}

.panel-lede {
  max-width: 48ch;
  color: var(--ink1);
  font-size: 1.0625rem;
  margin: 0 0 clamp(2rem, 4vh, 3rem);
}

/* ---------- Software cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.card {
  background: rgba(16, 27, 20, 0.92);
  padding: clamp(1.4rem, 2.5vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: background-color 0.35s var(--ease);
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--mint), transparent 80%);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}
.card:hover { background: rgba(21, 34, 26, 0.98); }
.card:hover::before { opacity: 1; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.card-index { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; color: var(--ink2); }
.card-icon { width: 2.2rem; height: 2.2rem; color: var(--mint); }

.card-micro { margin-bottom: 0.25rem; }
.card h3 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  margin: 0;
}
.card-body {
  color: var(--ink1);
  font-size: 0.9375rem;
  line-height: 1.62;
  margin: 0 0 1.1rem;
  flex: 1;
}

/* ---------- About ---------- */

.epigraph {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 420;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  line-height: 1.35;
  color: var(--gold-soft);
  border-left: 2px solid var(--gold);
  padding-left: 1.5rem;
  margin: 0 0 clamp(2rem, 4vh, 3rem);
  max-width: 30ch;
  text-wrap: balance;
}

.prose { max-width: 60ch; }
.prose p {
  color: var(--ink1);
  font-size: 1.05rem;
  line-height: 1.75;
  margin: 0 0 1.25rem;
}
.prose p:first-child::first-letter {
  font-family: var(--serif);
  font-weight: 560;
  float: left;
  font-size: 3.4rem;
  line-height: 0.82;
  padding: 0.15rem 0.5rem 0 0;
  color: var(--gold);
}

.about-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  margin-top: clamp(2rem, 4vh, 3rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.about-cta .micro { flex-basis: 100%; margin: 0; }

/* ---------- Contact ---------- */

.contact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.4rem;
}
.contact-note { margin: 0; }

/* ---------- Footer ---------- */

.footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1.25rem, 4vw, 3.5rem);
  border-top: 1px solid var(--line);
  color: var(--ink2);
  background: linear-gradient(to top, rgba(9, 15, 11, 0.85), rgba(9, 15, 11, 0.25));
}
.footer a { color: var(--ink2); text-decoration: none; transition: color 0.25s; }
.footer a:hover { color: var(--gold); }

.noscript-note {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 100;
  margin: 0;
  padding: 0.75rem 1rem;
  background: #241a07;
  color: var(--gold-soft);
  font-size: 0.8125rem;
}

/* ---------- Keyframes ---------- */

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

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

@keyframes cue {
  0% { transform: translateY(-100%); }
  60% { transform: translateY(100%); }
  100% { transform: translateY(100%); }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .nav { display: none; }
  .menu-toggle { display: flex; }
  .hero-coords { display: none; }
  .scroll-cue { display: none; }
  .hero-frame { max-width: 100%; }
  .footer { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
}

@media (max-width: 560px) {
  .hero-title { font-size: clamp(2.1rem, 10vw, 2.9rem); }
  .hero-frame { padding-bottom: calc(var(--header-h) + 5vh); }
  .panel-sheet { padding-bottom: 10vh; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .hero-frame, .hero-coords, .scroll-cue { animation: none; opacity: 1; transform: none; }
}