/* ═══════════════════════════════════════════════════════════
   RETRO.CSS — shared design system
   Retrofuturistic Y2K desktop: window chrome over a dithered
   ocean. One stylesheet for every page.
═══════════════════════════════════════════════════════════ */

/* ── TOKENS ────────────────────────────────────────────── */
:root {
  --blue-900: #2E1B54;   /* headings, strongest ink */
  --blue-800: #38236A;
  --blue-700: #4C3A86;   /* body ink — AA on white (6.7:1) */
  --blue-600: #7C5FC4;   /* title bars */
  --blue-500: #9B7FD9;   /* accent */
  --blue-400: #B7A2E6;
  --blue-300: #D0C2F0;   /* hairlines */
  --blue-200: #E1D7F7;
  --blue-100: #F2ECFC;   /* inset fills */

  --paper:    #FFFFFF;
  --ink:      var(--blue-700);
  --ink-dim:  #8B79B8;
  --line:     #C3B2E8;
  --win-body: rgba(255, 255, 255, 0.86);
  --win-soft: rgba(255, 255, 255, 0.62);

  --amber:    #C08A3E;   /* rare accent — "failed project", warnings */
  --ok:       #2E8B57;

  --font-mono:    'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-display: 'Space Grotesk', system-ui, sans-serif;

  --tile:     32px;      /* background grid pitch — matches bg.js TILE */
  --max-w:    1120px;
  --taskbar-h: 34px;
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  /* Fallback beneath the WebGL canvas — also the no-WebGL background */
  background: linear-gradient(160deg, #C9B8ED 0%, #DED2F5 45%, #EDE5FB 100%);
  scroll-behavior: smooth;
  font-size: 112.5%;   /* 18px root — scales every rem across the site up for legibility */
}

body {
  background: transparent;          /* let the canvas at z-index:-2 show */
  font-family: var(--font-mono);
  font-size: 1rem;                  /* inherits the enlarged root */
  line-height: 1.68;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

/* No grid overlay — the halftone dots in bg.js carry the texture. */

/* No WebGL: add a static dither so the gradient doesn't read as flat */
.no-webgl body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,0.55) 1px, transparent 1px);
  background-size: 6px 6px;
}

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
ul { list-style: none; }

::selection { background: var(--blue-200); color: var(--blue-900); }

:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}

/* ═══ BOOT SCREEN ════════════════════════════════════════
   Timing:  0ms  white screen, loading bar starts
         1300ms  bar full
         1400ms  screen fades out → background revealed
         1520ms  windows begin entering, staggered
   All CSS-driven so it self-clears even without JavaScript.
═══════════════════════════════════════════════════════════ */
.boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #fff;
  animation: boot-out 380ms ease 1400ms both;
}
@keyframes boot-out {
  to { opacity: 0; visibility: hidden; }
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(340px, 78vw);
  text-align: center;
}
.boot-logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--blue-600);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1px var(--blue-200);
}
.boot-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--blue-900);
}
.boot-bar {
  width: 100%;
  height: 16px;
  padding: 2px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.12);
}
.boot-fill {
  height: 100%;
  width: 0;
  /* chunky segmented blocks, like a real 16-bit progress bar */
  background-image: repeating-linear-gradient(
    90deg, var(--blue-600) 0 9px, transparent 9px 12px
  );
  animation: boot-load 1300ms steps(18, end) both;
}
@keyframes boot-load {
  from { width: 0; }
  to   { width: 100%; }
}
.boot-msg {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  min-height: 1em;
}

/* Content waits for the boot screen, then eases in on a stagger */
.boot-in {
  animation: boot-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(1520ms + var(--d, 0ms));
}
@keyframes boot-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ── TYPE ──────────────────────────────────────────────── */
.mono-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.92;
  color: var(--blue-900);
}

.h-section {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--blue-900);
  margin-bottom: 14px;
}

.prose p { margin-bottom: 14px; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--blue-900); font-weight: 600; }

/* ═══ WINDOW CHROME ═══════════════════════════════════════ */

.win {
  display: flex;
  flex-direction: column;
  background: var(--win-body);
  border: 1px solid var(--line);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.9),
    0 18px 44px rgba(46, 27, 84, 0.18);
  backdrop-filter: blur(3px) saturate(1.05);
  -webkit-backdrop-filter: blur(3px) saturate(1.05);
}

/* Title bar */
.win-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px 7px 11px;
  background: linear-gradient(180deg, #9179D0 0%, var(--blue-600) 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  user-select: none;
  flex: none;
}
.win-title-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.win-controls { display: flex; gap: 3px; flex: none; }
.win-btn {
  width: 19px;
  height: 16px;
  display: grid;
  place-items: center;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  color: var(--blue-900);
  background: var(--blue-200);
  border: 1px solid #fff;
  border-right-color: var(--blue-800);
  border-bottom-color: var(--blue-800);
}
.win-btn:hover { background: #fff; }
.win-btn:active {
  border-color: var(--blue-800);
  border-right-color: #fff;
  border-bottom-color: #fff;
}

/* Menu bar */
.win-menu {
  display: flex;
  gap: 18px;
  padding: 5px 12px;
  background: var(--win-soft);
  border-bottom: 1px solid var(--blue-200);
  font-size: 0.72rem;
  color: var(--ink);
  flex: none;
}
.win-menu span { cursor: default; }
.win-menu span:first-letter { text-decoration: underline; }

/* Body */
.win-body { padding: 22px 24px; }
.win-body > * + * { margin-top: 14px; }

/* Inset panel — plain soft fill (hatch lines removed for readability) */
.win-inset {
  border: 1px solid var(--blue-300);
  background: rgba(247, 244, 252, 0.72);
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.10);
  padding: 16px;
}
.win-inset.flush { padding: 0; overflow: hidden; }
.win-inset-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  padding: 26px 16px;
  text-align: center;
  font-size: clamp(0.9rem, 1.9vw, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue-600);
}

/* Status bar */
.win-status {
  display: flex;
  gap: 5px;
  padding: 5px 6px;
  border-top: 1px solid var(--blue-200);
  background: var(--win-soft);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  color: var(--blue-600);
  flex: none;
}
.win-status > * {
  padding: 2px 9px;
  border: 1px solid var(--blue-200);
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.07);
  white-space: nowrap;
}
.win-status > :first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* ── FIELDS / LISTS ────────────────────────────────────── */
.field {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.82rem;
}
.field-key { color: var(--ink); }
.field-val { color: var(--blue-900); font-weight: 600; letter-spacing: 0.04em; }

.note-list li {
  position: relative;
  padding-left: 18px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.note-list li::before {
  content: '▪';
  position: absolute;
  left: 2px;
  color: var(--blue-500);
}

/* Tag chips */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-700);
  background: var(--blue-100);
  border: 1px solid var(--blue-200);
  padding: 3px 8px;
}

/* ── BUTTONS ───────────────────────────────────────────── */
.btn-retro {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 17px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--blue-900);
  background: linear-gradient(180deg, #fff 0%, var(--blue-100) 100%);
  border: 1px solid var(--line);
  border-top-color: #fff;
  border-left-color: #fff;
  box-shadow: 1px 1px 0 rgba(46,27,84,0.18);
  transition: background 0.15s;
}
.btn-retro:hover { background: linear-gradient(180deg, #fff 0%, var(--blue-200) 100%); }
.btn-retro:active {
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.22);
  transform: translate(1px, 1px);
}
.btn-retro.primary {
  color: #fff;
  background: linear-gradient(180deg, #9179D0 0%, var(--blue-600) 100%);
  border-color: var(--blue-800);
  border-top-color: var(--blue-400);
  border-left-color: var(--blue-400);
}
.btn-retro.primary:hover { background: linear-gradient(180deg, #9F87DC 0%, #6B4FB0 100%); }
/* Prominent CTAs — larger tap target and label */
.btn-retro.big {
  padding: 15px 30px;
  font-size: 0.95rem;
  gap: 10px;
  letter-spacing: 0.08em;
}

/* Inline text link */
.link {
  color: var(--blue-600);
  border-bottom: 1px dotted var(--blue-400);
  font-weight: 600;
}
.link:hover { color: var(--blue-900); border-bottom-style: solid; }

/* ── LAYOUT ────────────────────────────────────────────── */
.shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}
.stack-lg > * + * { margin-top: 26px; }

/* ── TOP MENU BAR (site nav) ───────────────────────────── */
.menubar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 30px;
  padding: 0 10px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
}
.menubar-left, .menubar-right { display: flex; align-items: center; gap: 4px; }
.menubar-logo {
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue-900);
  padding: 0 8px;
}
.menubar a.menu-item, .menubar span.menu-item {
  padding: 4px 9px;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.menubar a.menu-item:hover { background: var(--blue-600); color: #fff; }
.menubar a.menu-item.active { color: var(--blue-900); font-weight: 600; }
.menubar-clock { padding: 0 8px; color: var(--ink-dim); font-size: 0.68rem; }

/* ── DESKTOP (portfolio page) ──────────────────────────── */
.desktop {
  position: relative;
  min-height: 100vh;
  padding-bottom: var(--taskbar-h);
}

.icon-field {
  position: absolute;
  top: 20px;
  right: 20px;         /* right-hand column, clear of the opening windows */
  z-index: 1;
  display: grid;
  grid-template-columns: 124px;
  gap: 6px;
  width: fit-content;
  align-content: start;
}
.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 124px;
  padding: 10px 4px;
  text-align: center;
  color: var(--blue-900);
}
.desktop-icon:hover .desktop-icon-label,
.desktop-icon:focus-visible .desktop-icon-label {
  background: var(--blue-600);
  color: #fff;
}
.desktop-icon-glyph {
  width: 52px;
  height: 46px;
  display: grid;
  place-items: center;
  image-rendering: pixelated;
}
.desktop-icon-label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.35;
  padding: 3px 7px;
  color: var(--blue-900);
  /* readable chip so labels stand off the busy halftone */
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(195, 178, 232, 0.6);
}

/* Floating windows */
.win.floating {
  position: absolute;
  z-index: 10;
  width: min(560px, calc(100vw - 36px));
  max-height: calc(100vh - var(--taskbar-h) - 60px);
}
.win.floating .win-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;   /* flex children won't shrink below content without this */
}
.win.floating.dragging { user-select: none; }
.win.floating .win-title { cursor: grab; }
.win.floating.dragging .win-title { cursor: grabbing; }
.win.floating[hidden] { display: none; }
.win.floating.inactive .win-title {
  background: linear-gradient(180deg, #CFC3E8 0%, #B9A9DC 100%);
}

/* ── TASKBAR ───────────────────────────────────────────── */
.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 5px;
  height: var(--taskbar-h);
  padding: 0 5px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.start-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue-900);
  background: linear-gradient(180deg, #fff 0%, var(--blue-100) 100%);
  border: 1px solid var(--line);
  border-top-color: #fff;
  border-left-color: #fff;
  flex: none;
}
.start-btn[aria-expanded="true"] {
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.22);
  background: var(--blue-200);
}
.task-list {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}
.task-btn {
  max-width: 190px;
  padding: 4px 11px;
  font-size: 0.68rem;
  color: var(--ink);
  background: linear-gradient(180deg, #fff 0%, var(--blue-100) 100%);
  border: 1px solid var(--line);
  border-top-color: #fff;
  border-left-color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-btn.active {
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.2);
  background: var(--blue-200);
  font-weight: 600;
}
.tray {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 11px;
  font-size: 0.68rem;
  color: var(--ink);
  border: 1px solid var(--blue-200);
  box-shadow: inset 1px 1px 0 rgba(46,27,84,0.07);
  flex: none;
}

/* Start menu */
.start-menu {
  position: fixed;
  left: 5px;
  bottom: calc(var(--taskbar-h) + 4px);
  z-index: 85;
  width: 232px;
  padding: 5px;
  background: var(--win-body);
  border: 1px solid var(--line);
  box-shadow: 0 14px 36px rgba(46,27,84,0.24);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.start-menu[hidden] { display: none; }
.start-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 11px;
  font-size: 0.76rem;
  text-align: left;
  color: var(--blue-900);
}
.start-menu-item:hover { background: var(--blue-600); color: #fff; }
.start-menu-sep { height: 1px; background: var(--blue-200); margin: 5px 0; }

/* ── FILE LIST (inside folder windows) ─────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 4px;
}
.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 15px 7px;
  text-align: center;
  color: var(--blue-900);
  border: 1px solid transparent;
}
.file-item:hover, .file-item:focus-visible {
  background: var(--blue-100);
  border-color: var(--blue-300);
}
.file-name {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.35;
  color: var(--blue-900);   /* deep plum ink — distinct from the coloured icons */
}

/* ── REVEAL ────────────────────────────────────────────── */
.fade-up {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-up.visible { opacity: 1; transform: none; }

/* ── MOTION / A11Y ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fade-up { opacity: 1; transform: none; transition: none; }
  /* Skip the boot sequence entirely. The global rule below zeroes
     durations but NOT delays, so without this the page would sit
     blank for 1.5s waiting on animation-delay. */
  .boot { display: none; }
  .boot-in { animation: none !important; opacity: 1; transform: none; }
  /* iteration-count matters: without it, an *infinite* animation would
     just loop every 0.001s and spin frantically instead of stopping. */
  * {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 860px) {
  .win-body { padding: 18px; }
  .shell { padding: 0 16px; }
}

/* Below this the desktop metaphor degrades into a readable stack */
@media (max-width: 760px) {
  .icon-field {
    position: static;            /* flow above the stacked windows */
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    width: auto;                 /* override the desktop column */
    padding: 16px 12px 0;
  }
  .desktop-icon { width: auto; }
  .win.floating {
    position: static !important;
    width: 100% !important;
    max-height: none;
    margin-bottom: 14px;
    transform: none !important;
  }
  .win.floating .win-title { cursor: default; }
  .win.floating .win-scroll { overflow: visible; }
  .desktop { padding-bottom: calc(var(--taskbar-h) + 12px); }
  .task-list { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   PAGE: HOME
═══════════════════════════════════════════════════════════ */

.section { padding: 46px 24px; }
.section:last-of-type { padding-bottom: 80px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.section-head.flush { margin-bottom: 26px; }
.section-head .h-section { margin-bottom: 0; }

/* ── Hero ──────────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding: 76px 0 46px;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  gap: 22px;
  align-items: start;
  width: 100%;
}
.hero-body { padding: 30px 32px 34px; }
.hero-name {
  font-size: clamp(3.2rem, 9vw, 6.4rem);
  margin: 6px 0 18px;
}
.hero-tagline {
  font-size: clamp(0.92rem, 1.3vw, 1.06rem);
  color: var(--ink);
  max-width: 34ch;
  margin-bottom: 26px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-right { display: flex; flex-direction: column; gap: 22px; }
.hero-side .win-body > * + * { margin-top: 10px; }
.hero-side .win-inset { margin-top: 16px; }

/* ── Koi pond ──────────────────────────────────────────── */
.koi-pond {
  position: relative;
  height: 142px;
  overflow: hidden;
  /* same hatched treatment as .win-inset, edge to edge */
  background:
    repeating-linear-gradient(45deg, rgba(155,127,217,0.12) 0 2px, transparent 2px 7px),
    rgba(255,255,255,0.5);
  box-shadow: inset 0 1px 0 rgba(46,27,84,0.10);
}

/* Each orbit spins the whole layer; the fish inside is offset from
   centre, so it rides the circle. */
.koi-orbit {
  position: absolute;
  inset: 0;
  animation: koi-swim 17s linear infinite;
}
.koi-orbit.reverse {
  animation-duration: 24s;
  animation-direction: reverse;
}
@keyframes koi-swim { to { transform: rotate(360deg); } }

.koi {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  /* translateX = orbit radius (shrinks as the fish grows, so a huge koi
     centres instead of clipping off one edge); rotate(90deg) faces it
     along its direction of travel; scale is driven by feeding */
  transform:
    translate(-50%, -50%)
    translateX(calc(46px * var(--koi-r, 1)))
    rotate(90deg)
    scale(var(--koi-scale, 1));
  transition: transform 0.5s cubic-bezier(0.34, 1.35, 0.64, 1);
}

/* ── Koi varieties ─────────────────────────────────────────
   Real-world patterns. Each sets body/fin/patch colours; a
   transparent patch changes the pattern, not just the palette. */
.koi-body   { fill: var(--k-body); stroke: var(--k-line); stroke-width: 1; }
.koi-fin    { fill: var(--k-fin);  stroke: var(--k-line); stroke-width: 1; stroke-linejoin: round; }
.koi-dorsal { fill: none; stroke: var(--k-line); stroke-width: 1; stroke-linecap: round; }
.koi-p1     { fill: var(--k-p1); }
.koi-p2     { fill: var(--k-p2); }
.koi-p3     { fill: var(--k-p3); }
.koi-eye    { fill: #2E1B54; }

/* Kohaku — white body, crimson patches */
.koi-v-kohaku { --k-body:#FFF9F4; --k-fin:#F6EFE8; --k-line:#B4541A;
                --k-p1:#E4572E; --k-p2:#E4572E; --k-p3:transparent; }
/* Ogon — solid metallic gold, no markings */
.koi-v-ogon   { --k-body:#F3B63C; --k-fin:#E8A62C; --k-line:#A8761A;
                --k-p1:transparent; --k-p2:transparent; --k-p3:transparent; }
/* Sanke — white with red patches and black flecks */
.koi-v-sanke  { --k-body:#FFF9F4; --k-fin:#F0E8E0; --k-line:#8A6A50;
                --k-p1:#E4572E; --k-p2:#E4572E; --k-p3:#2E2E33; }
/* Showa — black body broken by red and white */
.koi-v-showa  { --k-body:#33333A; --k-fin:#3E3E46; --k-line:#1A1A1F;
                --k-p1:#E4572E; --k-p2:#F5F0E8; --k-p3:#F5F0E8; }
/* Asagi — blue net back, orange flanks */
.koi-v-asagi  { --k-body:#8FC0E6; --k-fin:#E88A4A; --k-line:#2B6CB0;
                --k-p1:#E88A4A; --k-p2:#FFF7F0; --k-p3:transparent; }
/* Bekko — amber body with black tortoiseshell spots */
.koi-v-bekko  { --k-body:#F5C542; --k-fin:#E8B62E; --k-line:#A8761A;
                --k-p1:#2E2E33; --k-p2:#2E2E33; --k-p3:#2E2E33; }

/* ── Feeding ───────────────────────────────────────────── */
.koi-status { align-items: stretch; }
.koi-btn {
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue-900);
  background: linear-gradient(180deg, #fff 0%, var(--blue-100) 100%);
  border: 1px solid var(--line) !important;
  border-top-color: #fff !important;
  border-left-color: #fff !important;
  box-shadow: none !important;
  cursor: pointer;
}
.koi-btn:hover { background: linear-gradient(180deg, #fff 0%, var(--blue-200) 100%); }
.koi-btn:active { box-shadow: inset 1px 1px 0 rgba(46,27,84,0.22) !important; }
.koi-btn:disabled { opacity: 0.45; cursor: default; }

/* "Do not feed the fish" sign — which is, of course, right next to
   a button labelled FEED. */
.koi-sign {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.koi-sign:hover { opacity: 1; }
.koi-sign svg { width: 100%; height: 100%; display: block; }

/* Overflow error panel */
.koi-error {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px;
  text-align: center;
  background: rgba(255, 245, 238, 0.94);
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--blue-700);
}
.koi-error[hidden] { display: none; }
.koi-error-title {
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #B4541A;
}
.koi-error-dim { color: var(--ink-dim); }

/* Screen wipe on reset */
.koi-wipe {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(90deg, rgba(43,108,176,0) 0%, var(--blue-600) 18%, var(--blue-600) 82%, rgba(43,108,176,0) 100%);
  transform: translateX(-105%);
  pointer-events: none;
}
.koi-wipe.run { animation: koi-wipe 900ms ease-in-out 1; }
@keyframes koi-wipe {
  0%   { transform: translateX(-105%); }
  100% { transform: translateX(105%); }
}

.koi-tail {
  transform-origin: 88% 50%;
  animation: koi-wag 1.5s ease-in-out infinite alternate;
}
@keyframes koi-wag {
  from { transform: rotate(-10deg); }
  to   { transform: rotate(10deg); }
}

@media (prefers-reduced-motion: reduce) {
  .koi-orbit, .koi-tail { animation: none !important; }
}

/* ── About ─────────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr);
  gap: 28px;
  align-items: start;
}
.about-grid .prose > * + * { margin-top: 14px; }
.about-side { display: flex; flex-direction: column; gap: 12px; }
.about-side img { width: 100%; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  text-align: center;
  align-items: center;
}
.stat-val {
  font-family: var(--font-display);
  font-size: 1.24rem;
  font-weight: 700;
  color: var(--blue-900);
  letter-spacing: -0.01em;
}

/* ── Work ──────────────────────────────────────────────── */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.work-head { margin-bottom: 18px; }
.work-head .win-body { padding: 18px 24px; }
.work-head .section-head { margin-bottom: 0; }

.proj.featured { grid-column: span 2; }
.proj-media { border-left: 0; border-right: 0; border-top: 0; }
.proj-media .cover-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
/* Featured demo plays uncropped — it's a UI recording, so cropping loses content */
.proj-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--blue-900);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.proj .win-body > * + * { margin-top: 11px; }
.proj-links { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* ── Resume ────────────────────────────────────────────── */
.resume-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px;
  align-items: start;
}
.res-head {
  padding-bottom: 6px;
  margin-top: 28px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--blue-200);
}
.res-head:first-child { margin-top: 0; }
.timeline { margin-bottom: 30px; }
.tl-item {
  position: relative;
  padding-left: 20px;
  padding-bottom: 18px;
  border-left: 1px solid var(--blue-200);
}
.tl-item:last-child { border-left-color: transparent; padding-bottom: 4px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 6px;
  width: 7px;
  height: 7px;
  background: var(--blue-500);
  border: 1px solid var(--paper);
}
.tl-item:first-child::before { background: var(--blue-800); }
.tl-role {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--blue-900);
  margin-top: 3px;
}
.tl-org {
  font-size: 0.78rem;
  color: var(--blue-600);
  font-weight: 500;
  margin-bottom: 6px;
}
.tl-item p:last-child { font-size: 0.84rem; }

/* ── Photo carousel (resume window) ────────────────────── */
.carousel-win { margin-top: 30px; }
.carousel-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--blue-100);
  border-bottom: 1px solid var(--blue-200);
}
.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.carousel-slide {
  flex: 0 0 100%;
  height: 100%;
  margin: 0;
}
.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* placeholder frame until real photos are dropped in */
.carousel-ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  background:
    repeating-linear-gradient(45deg, rgba(155,127,217,0.10) 0 2px, transparent 2px 8px),
    var(--blue-100);
}
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--blue-900);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: 1px 1px 0 rgba(46,27,84,0.18);
  transition: background 0.15s;
}
.carousel-nav:hover { background: #fff; }
.carousel-nav:active { transform: translateY(-50%) translate(1px, 1px); }
.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }
.carousel-caption {
  padding: 11px 14px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--blue-900);
  min-height: 2.6em;
  background: var(--win-soft);
  border-bottom: 1px solid var(--blue-200);
}
.carousel-status { justify-content: space-between; }
.carousel-dots {
  display: inline-flex;
  gap: 6px;
  border: none !important;
  box-shadow: none !important;
  background: none;
  padding: 2px 4px !important;
}
.carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 1px solid var(--blue-500);
  background: transparent;
}
.carousel-dot.active { background: var(--blue-600); border-color: var(--blue-600); }

@media (prefers-reduced-motion: reduce) {
  .carousel-track { transition: none; }
}

/* ── Contact ───────────────────────────────────────────── */
.contact-body { padding: 34px 32px 38px; }
.contact-email {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.4vw, 2.1rem);
  font-weight: 700;
  color: var(--blue-900);
  letter-spacing: -0.02em;
  border-bottom: 2px solid var(--blue-300);
}
.contact-email:hover { border-bottom-color: var(--blue-700); }

/* ── Home responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .proj-grid { grid-template-columns: 1fr; }
  .proj.featured { grid-column: span 1; }
  .resume-grid { grid-template-columns: 1fr; gap: 4px; }
  .hero { min-height: auto; padding-top: 66px; }
}
@media (max-width: 560px) {
  .section { padding: 30px 16px; }
  .hero-body { padding: 24px 20px 28px; }
  .contact-body { padding: 24px 20px 28px; }
  .stat-row { grid-template-columns: 1fr; }
}

/* Keep the menu bar from overflowing on phones */
@media (max-width: 520px) {
  .menubar { font-size: 0.66rem; padding: 0 4px; }
  .menubar a.menu-item { padding: 4px 6px; }
  .menubar-logo { padding: 0 5px; }
  .menubar-clock { display: none; }
}
