/* ============================================================
   KAIYUN — /assets/site.css
   Shared shell: night ops console + printed archive
   ============================================================ */

/* ---------- 1. Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body,
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }

ul, ol { padding: 0; list-style: none; }

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

img, svg, video { max-width: 100%; height: auto; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

button { background: none; border: 0; padding: 0; }

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

/* ---------- 2. Tokens ---------- */
:root {
  --ink-900: #061426;
  --ink-800: #0A1D36;
  --ink-700: #123052;
  --cyan: #3DE7FF;
  --mist: #9FEAF5;
  --amber: #FF8B3D;
  --paper: #F0E5D0;
  --paper-line: #CDBFA6;
  --slate: #8EA6C4;
  --signal: #5BE3B6;
  --text: #E8F0FA;
  --ink-text: #0A1D36;

  --line: rgba(159, 234, 245, 0.16);
  --line-strong: rgba(159, 234, 245, 0.34);
  --line-soft: rgba(159, 234, 245, 0.09);

  --rail-w: 244px;
  --header-h: 64px;
  --shell-max: 1180px;
  --pad: clamp(18px, 4vw, 44px);

  --font-sans: "Noto Sans SC", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", Consolas, "Courier New", monospace;

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 20px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ---------- 3. Base ---------- */
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 620px at 80% -12%, rgba(61, 231, 255, 0.07), transparent 62%),
    radial-gradient(720px 520px at 4% 112%, rgba(255, 139, 61, 0.06), transparent 60%),
    var(--ink-900);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1 {
  font-size: clamp(34px, 5.4vw, 62px);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(23px, 3.2vw, 34px);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: -0.015em;
}

h3 {
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.005em;
}

p { max-width: 68ch; }

@media (min-width: 1024px) {
  body { padding-left: var(--rail-w); }
}

/* ---------- 4. Utilities ---------- */
.container {
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.section { padding-block: clamp(38px, 5vw, 78px); }

.label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--mist);
  line-height: 1.6;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.link-underline {
  position: relative;
  color: var(--mist);
  transition: color 0.18s var(--ease);
}

.link-underline::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.22s var(--ease);
}

.link-underline:hover { color: var(--cyan); }
.link-underline:hover::after { transform: scaleX(1); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: center;
  cursor: pointer;
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #16202e;
}

.btn-primary:hover { background: #ffa463; border-color: #ffa463; }

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--mist);
}

.btn-ghost:hover {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(255, 139, 61, 0.08);
}

.btn-quiet {
  background: rgba(61, 231, 255, 0.08);
  border-color: rgba(61, 231, 255, 0.35);
  color: var(--cyan);
}

.btn-quiet:hover { background: rgba(61, 231, 255, 0.16); }

.btn-block { width: 100%; }

.panel {
  position: relative;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: clamp(16px, 2.2vw, 26px);
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.panel:hover { border-color: rgba(255, 139, 61, 0.55); }

.panel--raised { background: var(--ink-700); }

.panel--paper {
  background: var(--paper);
  border-color: var(--paper-line);
  color: var(--ink-text);
}

.panel--paper:hover { border-color: var(--amber); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--slate);
}

.breadcrumb li { display: inline-flex; align-items: center; gap: 8px; }

.breadcrumb li + li::before {
  content: "/";
  color: rgba(142, 166, 196, 0.45);
}

.breadcrumb a { color: var(--slate); transition: color 0.18s var(--ease); }
.breadcrumb a:hover { color: var(--cyan); }
.breadcrumb [aria-current="page"] { color: var(--mist); }

.grid { display: grid; gap: clamp(14px, 2vw, 22px); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }

/* ---------- 5. Skip link ---------- */
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 300;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--cyan);
  color: #04121f;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transform: translateY(-160%);
  transition: transform 0.18s var(--ease);
}

.skip-link:focus,
.skip-link:focus-visible { transform: translateY(0); }

/* ---------- 6. Header / frame navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(10, 29, 54, 0.97);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.24s var(--ease);
}

.site-header[data-scrolled] { box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.header-brand { display: flex; align-items: center; min-width: 0; }

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(61, 231, 255, 0.45);
  background: radial-gradient(120% 120% at 28% 8%, rgba(61, 231, 255, 0.22), rgba(10, 29, 54, 0.25) 72%);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.brand-link:hover .brand-mark {
  border-color: var(--amber);
  color: var(--amber);
}

.brand-text { display: grid; gap: 1px; min-width: 0; }

.brand-name {
  display: block;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1.2;
  color: var(--text);
}

.brand-descriptor {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  line-height: 1.3;
  color: var(--slate);
  white-space: nowrap;
}

@media (max-width: 399px) {
  .brand-descriptor { display: none; }
}

.header-status {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mist);
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal);
  animation: pulse-dot 2.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91, 227, 182, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(91, 227, 182, 0); }
}

@media (min-width: 560px) {
  .header-status { display: inline-flex; }
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.nav-toggle:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255, 139, 61, 0.08);
}

.nav-toggle-bars { display: inline-grid; gap: 4px; }

.nav-toggle-bars span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.18s var(--ease);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:first-child {
  transform: translateY(3px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bars span:last-child {
  transform: translateY(-3px) rotate(-45deg);
}

.site-nav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  z-index: 95;
  display: none;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  padding: 14px var(--pad) 28px;
  background: var(--ink-800);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.58);
}

.site-nav[data-open] { display: flex; }

.nav-list { display: flex; flex-direction: column; gap: 2px; }

.nav-item { display: block; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px 11px 16px;
  border-radius: var(--radius-s);
  color: var(--slate);
  font-size: 15px;
  line-height: 1.4;
  transition: color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 2px;
  background: var(--cyan);
  transform: translateY(-50%);
  transition: height 0.2s var(--ease), background-color 0.2s var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: rgba(61, 231, 255, 0.06);
}

.nav-link:hover::before { height: 14px; }

.nav-link[aria-current="page"] {
  color: var(--cyan);
  background: linear-gradient(90deg, rgba(61, 231, 255, 0.16), rgba(61, 231, 255, 0));
}

.nav-link[aria-current="page"]::before { height: 20px; }

.nav-index {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(142, 166, 196, 0.68);
  transition: color 0.18s var(--ease);
}

.nav-link[aria-current="page"] .nav-index { color: var(--cyan); }

.nav-label { font-weight: 500; }

.nav-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
}

.nav-foot {
  margin: 10px 0 0;
  max-width: none;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(142, 166, 196, 0.62);
}

.scroll-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  pointer-events: none;
}

.scroll-meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
  transition: transform 0.12s linear;
}

@media (min-width: 1024px) {
  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    width: var(--rail-w);
    display: flex;
    background: var(--ink-800);
    border-bottom: 0;
    border-right: 1px solid var(--line);
    box-shadow: none;
  }

  .site-header::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    background: linear-gradient(180deg, var(--cyan), rgba(61, 231, 255, 0) 46%, var(--amber));
    opacity: 0.85;
    pointer-events: none;
  }

  .site-header[data-scrolled] { box-shadow: none; }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 24px 18px 18px;
    gap: 14px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .header-brand {
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--line-strong);
  }

  .header-status { align-self: flex-start; margin-top: 2px; }

  .nav-toggle { display: none; }

  .site-nav {
    position: static;
    display: flex;
    flex: 1 1 auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    gap: 0;
  }

  .nav-list { gap: 1px; }

  .nav-link { padding: 10px 12px 10px 15px; font-size: 14.5px; }

  .nav-actions { margin-top: auto; }

  .scroll-meter {
    inset: 0 -1px 0 auto;
    width: 2px;
    height: auto;
  }

  .scroll-meter-fill {
    background: linear-gradient(180deg, var(--cyan), var(--amber));
    transform: scaleY(var(--progress, 0));
    transform-origin: center top;
  }
}

/* ---------- 7. Footer ---------- */
.site-footer {
  background: var(--ink-900);
  border-top: 1px solid var(--line);
  color: var(--slate);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(26px, 4vw, 44px);
  max-width: var(--shell-max);
  margin-inline: auto;
  padding: clamp(36px, 5vw, 68px) var(--pad) 0;
}

@media (min-width: 640px) {
  .footer-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1080px) {
  .footer-inner { grid-template-columns: 1.4fr 0.7fr 0.7fr 1fr; }
}

.footer-brand {
  font-family: var(--font-mono);
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1.2;
  color: var(--text);
}

.footer-statement {
  margin-top: 12px;
  max-width: 36ch;
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--slate);
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.footer-col { min-width: 0; }

.footer-col-title {
  margin-bottom: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mist);
}

.footer-list { display: grid; gap: 2px; }

.footer-link {
  position: relative;
  display: inline-block;
  padding: 4px 0;
  font-size: 14px;
  color: var(--slate);
  transition: color 0.18s var(--ease);
}

.footer-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 1px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.22s var(--ease);
}

.footer-link:hover { color: var(--cyan); }
.footer-link:hover::after { transform: scaleX(1); }

.footer-contact { display: block; }

.contact-list { display: grid; gap: 10px; }

.contact-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.contact-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(142, 166, 196, 0.7);
}

.contact-value {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  overflow-wrap: anywhere;
}

.footer-note {
  margin-top: 14px;
  max-width: 30ch;
  font-size: 12px;
  line-height: 1.7;
  color: rgba(142, 166, 196, 0.75);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
  max-width: var(--shell-max);
  margin: clamp(28px, 4vw, 44px) auto 0;
  padding: 18px var(--pad) 28px;
  border-top: 1px solid var(--line);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  max-width: none;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(142, 166, 196, 0.82);
}

.to-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.to-top:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255, 139, 61, 0.08);
}

@media (max-width: 559px) {
  .footer-meta { margin-left: 0; }
  .to-top { width: 100%; justify-content: center; }
}

/* ---------- 8. Reusable media containers ---------- */
.media-frame {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--ink-700);
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line-soft);
}

.media-frame > img,
.media-frame > svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-frame--wide { aspect-ratio: 21 / 9; }
.media-frame--square { aspect-ratio: 1 / 1; }
.media-frame--tall { aspect-ratio: 4 / 5; }

.media-placeholder {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 100% at 14% 0%, rgba(61, 231, 255, 0.18), transparent 56%),
    radial-gradient(90% 90% at 100% 100%, rgba(255, 139, 61, 0.16), transparent 62%),
    var(--ink-800);
}

.media-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(159, 234, 245, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(159, 234, 245, 0.1) 1px, transparent 1px);
  background-size: 32px 32px;
}

.media-placeholder::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(6, 20, 38, 0.78));
}

/* ---------- 9. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .status-dot { animation: none; box-shadow: 0 0 0 3px rgba(91, 227, 182, 0.22); }
  .scroll-meter-fill { transition: none; }
}
