/* ============================================================
   MIDGAR AFTER DARK — Jason Crabtree about page
   World: industrial retrofuturist city terminal — steel plate,
   mako reactor, terminal windows.
   Palette: oxidized steel ground, paper-white ink, mako green
   primary accent, amber/rust warnings.
   ============================================================ */

@font-face {
  font-family: "Dela Gothic One";
  src: url("../fonts/DelaGothicOne-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DotGothic16";
  src: url("../fonts/DotGothic16-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("../fonts/ZenKakuGothicNew-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("../fonts/ZenKakuGothicNew-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #0c1114;
  --ground-deep: #080c0e;
  --panel: #131a1e;
  --panel-edge: #28343b;
  --paper: #ece7db;
  --ink: #10150f;
  --muted: #a4b4ad;
  --mako: #4fe3a1;
  --mako-dim: #1f6b4c;
  --mako-deep: #143527;
  --amber: #e2a63d;
  --amber-deep: #8a6420;
  --rust: #94451f;
  --measure: 68ch;
  --rail: 3px;
  --font-display: "Dela Gothic One", "Zen Kaku Gothic New", sans-serif;
  --font-body: "Zen Kaku Gothic New", system-ui, sans-serif;
  --font-pixel: "DotGothic16", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--mako); color: var(--ink); }

/* Browser surfaces, themed from the palette */
:focus-visible {
  outline: 2px solid var(--mako);
  outline-offset: 3px;
}
html { scrollbar-color: var(--panel-edge) var(--ground-deep); }

.jp { font-family: var(--font-pixel); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 1.2rem;
  background: var(--mako-deep);
  color: var(--paper);
  font-family: var(--font-pixel);
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ============ GRID STATUS HEADER ============ */

.grid-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--panel-edge);
  background: var(--ground-deep);
  font-family: var(--font-pixel);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.grid-status p { margin: 0; }
.grid-status .separator { color: var(--mako); }
.grid-status .en { color: var(--muted); }
.clock time { color: var(--mako); font-variant-numeric: tabular-nums; }
.clock { white-space: nowrap; }
.clock .en:last-child { margin-left: 0.35em; }

/* ============ CITY SYSTEMS NAV ============ */

.city-systems {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--ground);
  border-bottom: 1px solid var(--panel-edge);
}
.sectors {
  display: flex;
  margin: 0 auto;
  padding: 0 clamp(0.5rem, 3vw, 2rem);
  max-width: 78rem;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.sectors::-webkit-scrollbar { display: none; }
.sectors li { flex: 1 0 auto; min-width: 7.5rem; }
.sectors a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.85rem 0.5rem 0.75rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border-bottom: var(--rail) solid transparent;
  transition: color 160ms ease-out, border-color 160ms ease-out;
}
.sectors a::before {
  content: "";
  position: absolute;
  top: calc(0.85rem + 0.42rem);
  left: 0; right: 0;
  height: 2px;
  background: var(--panel-edge);
  z-index: -1;
}
.junction {
  width: 0.85rem;
  height: 0.85rem;
  background: var(--ground);
  border: 3px solid var(--mako-dim);
  transform: rotate(45deg);
  margin-bottom: 0.35rem;
  transition: border-color 160ms ease-out, background 160ms ease-out;
}
.sector-jp {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: var(--paper);
}
.sector-en { font-family: var(--font-pixel); }
.sectors a:hover,
.sectors a:focus-visible {
  color: var(--mako);
  border-bottom-color: var(--mako);
}
.sectors a:hover .junction,
.sectors a:focus-visible .junction {
  border-color: var(--mako);
  background: var(--mako);
}

/* ============ HERO ============ */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 0%, #101a17 0%, var(--ground) 62%);
}

.skyline {
  position: absolute;
  inset: auto 0 0 0;
  height: min(36vh, 280px);
  pointer-events: none;
}
.skyline svg { width: 100%; height: 100%; display: block; }
.skyline .plate rect,
.skyline .plate polygon { fill: #0a0f11; }
.skyline .reactor > polygon,
.skyline .reactor > rect { fill: #131b1f; }
.skyline .reactor .core,
.skyline .reactor .core circle { fill: var(--mako); }
.skyline .pipes rect { fill: #0f1619; }
.skyline .block.far rect { fill: #10171b; }
.skyline .block.near rect { fill: #0a0f11; }
.skyline .vents rect { fill: var(--mako-dim); }
.skyline .vents rect:nth-child(3n) { fill: var(--mako); }
.skyline .warn rect { fill: var(--amber); }
.skyline .ground rect { fill: var(--ground-deep); }

.hero-inner {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(15rem, 22rem);
  align-items: end;
  gap: clamp(1.5rem, 4vw, 4rem);
  width: 100%;
  max-width: 78rem;
  margin: 0 auto;
  padding: clamp(4rem, 10vh, 7rem) clamp(1rem, 4vw, 2.5rem) clamp(3rem, 8vh, 5rem);
}

.nameplate-kanji {
  margin: 0 0 0.75rem;
  color: var(--mako);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  letter-spacing: 0.3em;
}
.nameplate-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  /* Size to the nameplate grid track, not the viewport: below ~1280px the
     first track narrows faster than the viewport (fixed card column + vw
     padding/gap), and a viewport-scaled size let "CRABTREE" overflow its
     track and slide under the PC-98 card. Track width ≈ 1.2×viewport − 851px
     in that band; glyph width ≈ 7.11em, so cap at (16.9vw − 122px). */
  font-size: clamp(3rem, calc(16.9vw - 122px), 6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--paper);
  text-wrap: balance;
}
.nameplate-sub {
  max-width: 46ch;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.15rem);
}
.nameplate-hint { margin: 1.5rem 0 0; }
.nameplate-hint a {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  background: var(--mako-deep);
  border: 1px solid var(--mako-dim);
  color: var(--paper);
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: background 160ms ease-out, border-color 160ms ease-out;
}
.nameplate-hint a:hover { background: var(--mako-dim); border-color: var(--mako); }

/* PC-98 character window */
.pc98-window {
  margin: 0;
  justify-self: end;
  width: min(100%, 21rem);
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(8, 12, 14, 0.55);
}
.pc98-titlebar {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  background: var(--mako-deep);
  color: var(--paper);
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}
.pc98-body { padding: 1rem 1rem 1.1rem; text-align: center; }
.pc98-body img {
  display: block;
  width: 62%;
  max-width: 12rem;
  height: auto;
  margin: 0 auto;
  border: 2px solid var(--ink);
  image-rendering: pixelated;
  background: #77828f;
}
.pc98-name {
  margin: 0.85rem 0 0.15rem;
  font-family: var(--font-pixel);
  font-size: 1.3rem;
  letter-spacing: 0.25em;
}
.pc98-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
}
.pc98-page {
  margin: 0.8rem 0 0;
  font-family: var(--font-pixel);
  color: var(--rust);
  text-align: right;
}

/* ============ SECTIONS ============ */

main > section {
  max-width: 78rem;
  margin: 0 auto;
  padding: clamp(3.5rem, 9vh, 6rem) clamp(1rem, 4vw, 2.5rem);
}

.section-head { margin-bottom: clamp(2rem, 5vh, 3rem); }
.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.file-code {
  display: inline-block;
  margin-right: 0.9rem;
  padding: 0.15rem 0.55rem;
  border: 2px solid var(--mako);
  color: var(--mako);
  font-family: var(--font-pixel);
  font-size: 0.55em;
  letter-spacing: 0.12em;
  vertical-align: middle;
  transform: translateY(-0.2em);
}
.section-head .jp { color: var(--amber); margin-left: 0.6rem; font-size: 0.72em; }
.section-sub {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ============ ABOUT ============ */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(14rem, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.about-bio p {
  margin: 0 0 1.2rem;
  max-width: var(--measure);
}
.about-bio p:last-child { margin-bottom: 0; }

.about-inventory {
  border: 2px solid var(--panel-edge);
  background: var(--panel);
  padding: 0 0 0.5rem;
}
.inventory-title {
  margin: 0;
  padding: 0.5rem 1rem;
  background: var(--mako-dim);
  color: var(--paper);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
}
.inventory-title .en { font-family: var(--font-pixel); margin-left: 0.5em; }
.inventory-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-pixel);
}
.inventory-list li {
  padding: 0.45rem 1rem;
  color: var(--paper);
}
.inventory-list li::before { content: "▸ "; color: var(--amber); }
.inventory-list li:hover { background: var(--mako-deep); }
.inventory-list li:hover::before { color: var(--paper); }

/* ============ PROJECTS: SYSTEMS REGISTRY ============ */

.board {
  border: 2px solid var(--panel-edge);
  background: var(--ground-deep);
  font-size: 0.95rem;
}
.board-head,
.board-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) auto 10.5rem;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
}
.board-head {
  background: var(--panel);
  border-bottom: 2px solid var(--panel-edge);
  font-family: var(--font-pixel);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--mako);
}
.board-row { border-bottom: 1px solid var(--panel-edge); }
.board-row:last-child { border-bottom: 0; }

.sys-id {
  font-family: var(--font-pixel);
  color: var(--amber);
  letter-spacing: 0.1em;
}
.sys-name strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.sys-desc {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 58ch;
}
.access { display: flex; gap: 0.5rem; }
.board-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--mako-dim);
  color: var(--mako);
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: background 140ms ease-out, color 140ms ease-out, border-color 140ms ease-out;
}
.board-link:hover,
.board-link:focus-visible {
  background: var(--mako);
  border-color: var(--mako);
  color: var(--ink);
}
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-pixel);
  font-size: 0.82rem;
  color: var(--paper);
  letter-spacing: 0.04em;
}
.status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  flex: none;
}
.status-online { background: var(--mako); }
.status-field { background: var(--amber); }

/* systems power-up — rows are visible by default;
   JS adds .flap once, animation plays from the powered-down pose */
@media (prefers-reduced-motion: no-preference) {
  .board-row.flap {
    animation: power-up 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .board-row.flap:nth-child(2) { animation-delay: 60ms; }
  .board-row.flap:nth-child(3) { animation-delay: 130ms; }
  .board-row.flap:nth-child(4) { animation-delay: 200ms; }
  .board-row.flap:nth-child(5) { animation-delay: 270ms; }
  .board-row.flap:nth-child(6) { animation-delay: 340ms; }
  .board-row.flap:nth-child(7) { animation-delay: 400ms; }
  .board-row.flap:nth-child(8) { animation-delay: 460ms; }
  .board-row.flap:nth-child(9) { animation-delay: 520ms; }
  .board-row.flap:nth-child(10) { animation-delay: 580ms; }
  .board-row.flap:nth-child(11) { animation-delay: 640ms; }

  /* Reactor core breathing — a slow mako pulse, bounded and ambient. */
  .skyline .core {
    animation: mako-pulse 6.4s ease-in-out infinite;
  }
}
@keyframes power-up {
  from { opacity: 0.2; transform: translateY(10px); }
  to   { opacity: 1;    transform: translateY(0); }
}
@keyframes mako-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* ============ ELSEWHERE: UPLINK CHANNELS ============ */

.channels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.channel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  height: 100%;
  padding: 1.4rem 1.1rem 1.1rem;
  border: 2px solid var(--panel-edge);
  background: var(--panel);
  color: var(--paper);
  text-decoration: none;
  transition: border-color 160ms ease-out, background 160ms ease-out;
}
.channel::after {
  content: "";
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 0.9rem;
  height: 2px;
  background: var(--mako);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease-out;
}
.channel:hover, .channel:focus-visible { border-color: var(--mako); }
.channel:hover::after, .channel:focus-visible::after { transform: scaleX(1); }
.channel-icon {
  width: 2rem;
  height: 2rem;
  fill: var(--mako);
  margin-bottom: 0.4rem;
}
.channel-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.channel-handle {
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}
.channel-tag {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--amber);
}
.channel { padding-bottom: 2rem; }

/* ============ COLOPHON ============ */

.colophon {
  border-top: 2px solid var(--mako);
  background: var(--ground-deep);
}
.colophon-inner {
  max-width: 78rem;
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 4vw, 2.5rem) 3rem;
}
.colophon p { margin: 0 0 0.9rem; max-width: var(--measure); }
.colophon p:last-child { margin-bottom: 0; }
.colophon-credit { font-family: var(--font-pixel); }
.colophon-credit a { color: var(--mako); }
.colophon-line { color: var(--muted); font-size: 0.92rem; }
.colophon-legal { color: var(--muted); font-size: 0.82rem; font-family: var(--font-pixel); }

/* ============ RESPONSIVE ============ */

@media (max-width: 60rem) {
  /* Anchor the hero content to the nav instead of centering it in the
     viewport — vertical centering left a dead gap between the city
     systems nav and the nameplate on phones. The generic `main > section`
     padding (9vh top) stacked on hero-inner's own padding to make it
     worse, so hero-inner owns all hero padding here. Skyline stays
     bottom-anchored. */
  .hero { justify-content: flex-start; padding: 0; }
  .hero-inner {
    grid-template-columns: 1fr;
    align-items: start;
    padding-top: clamp(2rem, 6vh, 3rem);
  }
  .pc98-window { justify-self: start; width: min(100%, 18rem); }
  .about-grid { grid-template-columns: 1fr; }
  .channels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-head { display: none; }
  .board-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 1.1rem 1rem;
  }
  .status { order: -1; }
}

@media (max-width: 26rem) {
  body { font-size: 1rem; }
  .grid-status { font-size: 0.72rem; }
  .pc98-body img { max-width: 9.5rem; }
  .channels { grid-template-columns: 1fr; }
  .nameplate-hint a { width: 100%; text-align: center; }
  /* 3rem floor would clip "CRABTREE" at 320px: the column is 256px wide
     and the word is ~7.11em, so scale it with the small viewport. */
  .nameplate-name { font-size: clamp(2rem, 10.5vw, 2.75rem); }
}

/* ============ REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
