/* Local fonts (Baskerville BQ, private license, repo must be Private) */
@font-face {
  font-family: 'Baskerville';
  src: url('../fonts/BaskervilleNewBQ-Roman.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Baskerville';
  src: url('../fonts/BaskervilleNewBQ-Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: optional;
}
@font-face {
  font-family: 'Baskerville';
  src: url('../fonts/BaskervilleNewBQ-SemiBold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Baskerville';
  src: url('../fonts/BaskervilleNewBQ-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Alibaba PuHuiTi 2.0 */
@font-face {
  font-family: 'Alibaba PuHuiTi';
  src: url('../fonts/AlibabaPuHuiTi-2-55-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Alibaba PuHuiTi';
  src: url('../fonts/AlibabaPuHuiTi-2-85-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
/* 800/900 weights rarely used, font-display: optional to avoid blocking */
@font-face {
  font-family: 'Alibaba PuHuiTi';
  src: url('../fonts/AlibabaPuHuiTi-2-95-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
  font-display: optional;
}
@font-face {
  font-family: 'Alibaba PuHuiTi';
  src: url('../fonts/AlibabaPuHuiTi-2-105-Heavy.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: optional;
}
/* Baskerville Italic used in one place, optional to avoid blocking */

/* Tokens */
:root {
  --bg: #131313;
  --bg-2: #181818;
  --panel: rgba(20, 20, 20, 0.65);
  --panel-solid: #141414;
  --accent: #e63946;
  --accent-soft: rgba(230, 57, 70, 0.18);
  --accent-line: rgba(230, 57, 70, 0.45);
  --text: #f3f3f3;
  --text-dim: #9a9a9a;
  --text-faint: #5a5a5a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);

  --font-serif: 'Baskerville', 'Alibaba PuHuiTi', -apple-system, 'PingFang SC', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
  --font-sans: 'Inter', 'Alibaba PuHuiTi', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;

  /* Type scale */
  --fs-mono-xs: 10px;
  --fs-mono-sm: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fs-2xl: 40px;
  --fs-3xl: 64px;

  --rail-w: 44px;
  --hud-pad: 28px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; }
img, video { display: block; max-width: 100%; }
::selection { background: var(--accent); color: #fff; }

/* Background grain + scanline */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 2px,
      rgba(255,255,255,0.012) 2px,
      rgba(255,255,255,0.012) 3px
    );
  mix-blend-mode: overlay;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 998;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,0.28) 100%);
}

/* Left rail */
.rail {
  position: fixed;
  left: 0; top: 0;
  width: var(--rail-w);
  height: 100vh;
  z-index: 50;
  background: transparent;
  border-right: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  pointer-events: none;
}
/* re-enable pointer-events on inner links */
.rail__logo,
.rail__logo a,
.rail__honors {
  pointer-events: auto;
}
.rail__nav-block {
  position: absolute;
  left: 0;
  top: 20px;
  transform: none;
  width: calc(var(--rail-w) + 8px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2;
}
.rail__logo {
  display: flex;
  align-items: center; justify-content: center;
  width: 100%;
  padding: 18px 0 14px;
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: transparent;
  border: none;
}
.rail__logo a { display: block; line-height: 1; }
.rail__honors {
  display: flex;
  align-items: center; justify-content: center;
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: #fff;
  background: transparent;
  padding: 22px 0 24px;
  border: none;
  cursor: pointer;
  transition: color .3s;
  text-transform: uppercase;
}
.rail__honors:hover { color: var(--accent); }

.rail__nav { display: none; }

/* Project nav buttons, fixed at screen edges */
.page-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  cursor: pointer;
  z-index: 65;
  transition: background .25s, color .25s, transform .25s, padding .25s;
  padding: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}
.page-nav-btn--prev { left: 0; }
.page-nav-btn--next { right: 0; }
.page-nav-btn:hover:not([disabled]) {
  background: var(--accent);
  color: #fff;
}
.page-nav-btn--prev:hover:not([disabled]) { transform: translate(-4px, -50%); }
.page-nav-btn--next:hover:not([disabled]) { transform: translate(4px, -50%); }
.page-nav-btn[disabled] { opacity: 0.25; cursor: not-allowed; }

/* HUD (top corners) */
.hud {
  position: fixed;
  top: var(--hud-pad);
  z-index: 60;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  pointer-events: none;
}
.hud--tl { left: calc(var(--rail-w) + 24px); color: var(--text-dim); }
.hud--tl .signal { color: var(--accent); margin-top: 2px; display: block; }
.hud--tr { right: var(--hud-pad); text-align: right; color: var(--text-dim); }
.hud--tr .ts { font-size: 11px; letter-spacing: 0.1em; }
.hud--tr .iso { color: var(--text-faint); }

.lang-toggle {
  position: fixed;
  right: var(--hud-pad);
  top: 70px;
  display: flex; gap: 6px;
  z-index: 60;
  font-family: var(--font-mono);
  font-size: 11px;
}
.lang-toggle button {
  width: 30px; height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  letter-spacing: 0.1em;
  transition: all .25s;
  background: rgba(0, 0, 0, 0.55);
}
.lang-toggle button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.lang-toggle button.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* Live feed (bottom-left) */
.live-feed {
  position: fixed;
  left: calc(var(--rail-w) + 18px);
  bottom: 22px;
  z-index: 60;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
.live-feed .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blink 1.6s infinite;
}
@keyframes blink {
  0%, 70% { opacity: 1; }
  85% { opacity: 0.2; }
  100% { opacity: 1; }
}

/* Status (bottom-right) */
.sys-status {
  position: fixed;
  right: var(--hud-pad);
  bottom: 22px;
  z-index: 60;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  text-align: right;
}
.sys-status .stable { color: var(--accent); }

/* Tag / chip */
.tag {
  display: inline-flex; align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.tag--ghost { border-color: var(--border-strong); color: var(--text-dim); }
.tag--solid { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Decorative box */
.deco-box {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
  background: rgba(0,0,0,0.4);
  pointer-events: none;
}

/* Crosshair corners */
.crosshair {
  position: relative;
}
.crosshair::before, .crosshair::after,
.crosshair > .ch-tl, .crosshair > .ch-tr,
.crosshair > .ch-bl, .crosshair > .ch-br {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border: 1px solid var(--accent);
  pointer-events: none;
}
.crosshair > .ch-tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.crosshair > .ch-tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.crosshair > .ch-bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.crosshair > .ch-br { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* Buttons */
.btn-decrypt {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--text);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 4px;
  transition: color .25s, border-color .25s;
  cursor: pointer;
}
.btn-decrypt:hover { color: var(--accent); }

/* Page heading (oversized serif) */
.page-heading {
  font-family: var(--font-serif);
  font-size: clamp(40px, 5.5vw, 80px);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 0.95;
  position: relative;
}
.page-heading .slash {
  display: inline-block;
  width: 2px; height: 0.85em;
  background: var(--accent);
  margin: 0 0.5em -0.05em 0.5em;
  transform: rotate(20deg);
  vertical-align: middle;
}

/* Utility */
.label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-dim); }
.label-accent { color: var(--accent); }
.divider { height: 1px; background: var(--border); width: 100%; }
.divider-accent { height: 1px; background: linear-gradient(to right, transparent, var(--accent), transparent); }

/* Page wrapper */
.page {
  min-height: 100vh;
  position: relative;
}

@media (max-width: 720px) {
  :root { --rail-w: 36px; --hud-pad: 14px; }
  .rail__nav-block {
    top: 14px;
    left: 14px;
    transform: none;
    flex-direction: row;
    align-items: center;
    width: auto;
    padding: 0;
    gap: 0;
  }
  .rail__logo {
    padding: 6px 10px;
    font-size: 20px;
    border-right: 1px solid rgba(255,255,255,0.18);
  }
  .rail__honors {
    writing-mode: horizontal-tb;
    padding: 7px 12px;
    font-size: 11px;
    letter-spacing: 0.22em;
  }
  .page-nav-btn { width: 44px; height: 44px; font-size: 22px; }
  body[data-page="project-intro"] .hud--tl,
  body[data-page="project-detail"] .hud--tl { display: none; }
  .hud--tl { left: calc(var(--rail-w) + 10px); font-size: 9px; letter-spacing: 0.15em; }
  .hud--tr { font-size: 9px; letter-spacing: 0.14em; }
  .hud--tr .ts { font-size: 10px; }
  .lang-toggle { top: 52px; }
  .lang-toggle button { width: 26px; height: 22px; font-size: 10px; }
  .live-feed {
    left: calc(var(--rail-w) + 10px);
    bottom: 14px;
    font-size: 9px;
    letter-spacing: 0.14em;
  }
  .sys-status { display: none; }
  .rail { padding: 12px 0; }
  .rail__logo { font-size: 16px; }
  .rail__honors {
    margin-top: 18px;
    font-size: 9px;
    letter-spacing: 0.22em;
    padding: 10px 6px;
  }
  /* dim vignette + scanlines on mobile for readability */
  body::after { background: radial-gradient(ellipse at 50% 50%, transparent 65%, rgba(0,0,0,0.18) 100%); }
  body::before { opacity: 0.5; }
  .page-heading { font-size: clamp(36px, 8.5vw, 56px); }
}
@media (max-width: 420px) {
  :root { --rail-w: 32px; --hud-pad: 12px; }
  .hud--tl { font-size: 8.5px; letter-spacing: 0.1em; }
  .live-feed { display: none; }
  .rail__honors { writing-mode: vertical-rl; padding: 8px 4px; font-size: 8.5px; letter-spacing: 0.18em; }
}
