/* ==========================================================================
   Kardashev Systems — Nord design system
   Palette: https://www.nordtheme.com
   ========================================================================== */

/* ------------------------------ Fonts ------------------------------------ */

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("../fonts/space-grotesk-300.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/space-grotesk-400.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/space-grotesk-500.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/space-grotesk-700.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/inter-600.woff2") format("woff2");
}

/* ------------------------------ Tokens ------------------------------------ */

:root {
  /* Nord — Polar Night */
  --nord0: #2e3440;
  --nord1: #3b4252;
  --nord2: #434c5e;
  --nord3: #4c566a;
  /* Nord — Snow Storm */
  --nord4: #d8dee9;
  --nord5: #e5e9f0;
  --nord6: #eceff4;
  /* Nord — Frost */
  --nord7: #8fbcbb;
  --nord8: #88c0d0;
  --nord9: #81a1c1;
  --nord10: #5e81ac;
  /* Nord — Aurora */
  --nord11: #bf616a;
  --nord14: #a3be8c;

  --font-display: "Space Grotesk", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --font-body: "Inter", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;

  --container: 1160px;
  --header-h: 72px;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--nord0);
  --bg-alt: #2a303c;
  --surface: var(--nord1);
  --surface-hover: var(--nord2);
  --text: var(--nord6);
  --text-soft: var(--nord4);
  --text-muted: #9aa5b8;
  --accent: var(--nord8);
  --accent-strong: var(--nord7);
  --line: rgba(216, 222, 233, 0.12);
  --line-strong: rgba(216, 222, 233, 0.22);
  --header-bg: rgba(46, 52, 64, 0.72);
  --btn-primary-fg: var(--nord0);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.5);
  --kscale-track: var(--nord2);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: var(--nord6);
  --bg-alt: var(--nord5);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-hover: #ffffff;
  --text: var(--nord0);
  --text-soft: var(--nord2);
  --text-muted: var(--nord3);
  --accent: var(--nord10);
  --accent-strong: var(--nord9);
  --line: rgba(46, 52, 64, 0.12);
  --line-strong: rgba(46, 52, 64, 0.24);
  --header-bg: rgba(236, 239, 244, 0.78);
  --btn-primary-fg: var(--nord6);
  --shadow: 0 24px 60px -30px rgba(46, 52, 64, 0.28);
  --kscale-track: var(--nord4);
}

/* ------------------------------ Base -------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

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

::selection {
  background: var(--accent);
  color: var(--btn-primary-fg);
}

.container {
  width: min(100% - 3rem, var(--container));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  transition: top 0.2s ease;
}
.skip-link:focus-visible {
  top: 1rem;
}

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

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 0.35s ease, border-color 0.35s ease,
    backdrop-filter 0.35s ease;
}

.site-header.scrolled {
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom-color: var(--line);
}

.header-inner {
  width: min(100% - 3rem, var(--container));
  margin-inline: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

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

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex: none;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.24em;
}

.site-nav {
  display: flex;
  gap: 2rem;
}

.site-nav a {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: color 0.25s ease;
  position: relative;
  padding: 0.35rem 0;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
}

.site-nav a:hover::after,
.site-nav a.active::after {
  transform: scaleX(1);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--text-soft);
  transition: border-color 0.25s ease, color 0.25s ease,
    background-color 0.25s ease;
}

.control-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface);
}

.lang-btn {
  width: auto;
  padding-inline: 0.8rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.theme-btn svg {
  width: 19px;
  height: 19px;
  position: absolute;
  transition: transform 0.45s var(--ease), opacity 0.3s ease;
}

.theme-btn {
  position: relative;
}

html[data-theme="dark"] .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
html[data-theme="dark"] .icon-moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
html[data-theme="light"] .icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}
html[data-theme="light"] .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Mobile menu button */
.menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
}

.menu-line {
  display: block;
  width: 17px;
  height: 1.8px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.3s var(--ease);
}

.menu-btn[aria-expanded="true"] .menu-line:first-child {
  transform: translateY(3.4px) rotate(45deg);
}
.menu-btn[aria-expanded="true"] .menu-line:last-child {
  transform: translateY(-3.4px) rotate(-45deg);
}

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

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

.hero-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-inner {
  position: relative;
  z-index: 1;
  padding-block: calc(var(--header-h) + 3rem) 6rem;
  max-width: 720px;
  margin-left: max(calc((100vw - var(--container)) / 2), 1.5rem);
  margin-right: 1.5rem;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.75rem;
}

.hero-title {
  font-size: clamp(2.6rem, 6.5vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 1.75rem;
}

.hero-lede {
  font-size: clamp(1rem, 1.4vw, 1.16rem);
  line-height: 1.85;
  color: var(--text-muted);
  max-width: 34em;
  margin-bottom: 2.75rem;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.9rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: transform 0.3s var(--ease), background-color 0.25s ease,
    border-color 0.25s ease, color 0.25s ease, box-shadow 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent);
  color: var(--btn-primary-fg);
}

.btn-primary:hover {
  box-shadow: 0 12px 30px -12px var(--accent);
}

.btn-ghost {
  border: 1px solid var(--line-strong);
  color: var(--text-soft);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}

.hero-scroll {
  position: absolute;
  bottom: 2.2rem;
  left: max(calc((100vw - var(--container)) / 2), 1.5rem);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hero-scroll-line {
  display: block;
  width: 56px;
  height: 1px;
  background: var(--line-strong);
  position: relative;
  overflow: hidden;
}

.hero-scroll-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  animation: scroll-sweep 2.4s var(--ease) infinite;
}

@keyframes scroll-sweep {
  0% {
    transform: translateX(-100%);
  }
  55%,
  100% {
    transform: translateX(100%);
  }
}

/* ---------------------------- Stat strip ----------------------------------- */

.stat-strip {
  border-block: 1px solid var(--line);
  background: var(--bg-alt);
  transition: background-color 0.4s ease;
}

.stat-strip-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  padding-block: 2.2rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.stat-label {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ------------------------------ Sections ----------------------------------- */

.section {
  padding-block: clamp(5.5rem, 11vw, 9rem);
}

.section-alt {
  background: var(--bg-alt);
  border-block: 1px solid var(--line);
  transition: background-color 0.4s ease;
}

.section-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 3rem 5rem;
  align-items: start;
}

.section-head {
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.section-index {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  color: var(--accent);
}

.section-title {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  letter-spacing: -0.02em;
}

.section-body {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.section-lede {
  max-width: 46em;
  margin-top: 1.4rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.85;
}

.prose-lg {
  font-size: clamp(1.15rem, 1.8vw, 1.45rem);
  line-height: 1.7;
  letter-spacing: -0.005em;
  font-weight: 400;
  color: var(--text);
}

.prose {
  color: var(--text-muted);
  line-height: 1.9;
  max-width: 42em;
}

/* Standalone section head (not in grid) */
#systems .section-head,
#scale .section-head {
  position: static;
  flex-direction: row;
  align-items: baseline;
  gap: 1.4rem;
}

/* ------------------------------ Mission ------------------------------------ */

.mission-block {
  max-width: 880px;
}

.mission-statement {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 3rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-block: 1.6rem 2rem;
}

.mission-detail {
  max-width: 40em;
}

/* ------------------------------- Cards ------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.2rem;
  margin-top: 3.2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.9rem 1.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: transform 0.35s var(--ease), border-color 0.3s ease,
    background-color 0.3s ease, box-shadow 0.35s ease;
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  background: var(--surface-hover);
  box-shadow: var(--shadow);
}

.card-icon {
  width: 30px;
  height: 30px;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.card h3 {
  font-size: 1.06rem;
  font-weight: 500;
}

.card p {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-muted);
}

/* ---------------------------- Kardashev scale ------------------------------- */

.kscale {
  margin-block: 4.2rem 3.4rem;
}

.kscale-track {
  position: relative;
  height: 3px;
  border-radius: 3px;
  background: var(--kscale-track);
}

.kscale-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 24.3%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--nord10), var(--nord8));
}

.kscale-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.kscale-marker-dot {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
  animation: marker-pulse 3s ease-in-out infinite;
}

@keyframes marker-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
  }
  50% {
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 10%, transparent);
  }
}

.kscale-marker-label {
  position: absolute;
  bottom: calc(100% + 0.8rem);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.kscale-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.type-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.9rem 1.7rem;
  background: var(--surface);
  transition: transform 0.35s var(--ease), border-color 0.3s ease,
    box-shadow 0.35s ease;
}

.type-card:hover {
  transform: translateY(-5px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.type-num {
  display: block;
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.type-card h3 {
  font-size: 1.02rem;
  margin-bottom: 0.7rem;
}

.type-card p {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text-muted);
}

/* ----------------------------- Principles ----------------------------------- */

.principle-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: principle;
  display: flex;
  flex-direction: column;
}

.principle-list li {
  counter-increment: principle;
  display: flex;
  align-items: baseline;
  gap: 1.6rem;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: color 0.25s ease;
}

.principle-list li:first-child {
  border-top: 1px solid var(--line);
}

.principle-list li::before {
  content: "0" counter(principle);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--accent);
  flex: none;
}

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

.contact-section {
  padding-block: clamp(7rem, 14vw, 11rem);
}

.contact-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.contact-lede {
  max-width: 36em;
  margin-block: 1.6rem 2.8rem;
  color: var(--text-muted);
  line-height: 1.9;
}

.contact-mail {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4.5vw, 3.2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  position: relative;
  transition: color 0.3s ease;
}

.contact-mail svg {
  width: 0.62em;
  height: 0.62em;
  transition: transform 0.35s var(--ease);
}

.contact-mail::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.12em;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
}

.contact-mail:hover {
  color: var(--accent);
}

.contact-mail:hover::after {
  transform: scaleX(1);
}

.contact-mail:hover svg {
  transform: translate(0.12em, -0.12em);
}

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

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2.4rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.footer-brand .brand-mark {
  width: 20px;
  height: 20px;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-meta a {
  color: var(--text-soft);
  transition: color 0.25s ease;
}

.footer-meta a:hover {
  color: var(--accent);
}

.footer-sep {
  opacity: 0.5;
}

/* ------------------------------ Reveal -------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.reveal[data-reveal-delay="1"] {
  transition-delay: 0.1s;
}
.reveal[data-reveal-delay="2"] {
  transition-delay: 0.2s;
}
.reveal[data-reveal-delay="3"] {
  transition-delay: 0.3s;
}

.reveal.in {
  opacity: 1;
  transform: none;
}

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

@media (max-width: 860px) {
  .site-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 99;
    flex-direction: column;
    gap: 0;
    padding: 0.6rem 1.5rem 1.4rem;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--line);
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s var(--ease), opacity 0.3s ease,
      visibility 0.3s;
  }

  .site-nav.open {
    transform: none;
    opacity: 1;
    visibility: visible;
  }

  .site-nav a {
    padding: 0.85rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--line);
  }

  .site-nav a::after {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .section-grid {
    grid-template-columns: 1fr;
    gap: 2.2rem;
  }

  .section-head {
    position: static;
  }

  #systems .section-head,
  #scale .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
  }

  .stat-strip-inner {
    grid-template-columns: 1fr;
    gap: 1.4rem;
    padding-block: 1.8rem;
  }

  .stat {
    flex-direction: row;
    align-items: baseline;
    gap: 1rem;
  }

  .hero-inner {
    padding-block: calc(var(--header-h) + 4.5rem) 7rem;
  }

  /* keep the headline readable over the particle field on small screens */
  .hero-scene canvas {
    opacity: 0.55;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 2.15rem;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero-scroll-line::after,
  .kscale-marker-dot {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
