/* ═══════════════════════════════════════════════════════════════
   R14 — REFINEMENT PASS
   Additive layer over styles.css. Same soul: tactical orange,
   1px borders, cut corners, Space Mono data. No new palette.
   1 · motion + easing consistency
   2 · typography correction (design.md bans Inter)
   3 · ARCHIVE / WORK gallery
   4 · lightbox
   ═══════════════════════════════════════════════════════════════ */

/* ── HIVE_OS HUD: ability row ──
   styles.css positions .panel-settings with margin-left:470px inside the
   shrink-to-fit #hive-panel-wrapper. That was sized for three buttons; R13
   injects EMP and JAVELIN too, so the row overshot the 900px panel and
   flex-shrank every label into `overflow:hidden`. Right-align it against the
   panel and let it wrap instead of shrinking. */
.panel-settings {
  margin-left: 0 !important;
  align-self: flex-end;
  max-width: 900px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.setting-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ── 0 · Scroll container ──
   Every scroll-driven behaviour in main.js / ai-chat.js reads window.scrollY
   and treats <html> as the scroller (nav active link, progress rail, grid
   parallax, FAB drift). Some hosts hand <body> a viewport-height box with
   overflow-y:auto, which parks window.scrollY at 0 and freezes all of it.
   Clip X on <html> and give <body> its natural height back so the document
   scrolls on the documentElement, exactly as the standalone page does.
   (overflow-x:hidden on <body> would force overflow-y to auto — hence the
   x-clip lives on <html>.) */
html {
  overflow-x: hidden;
}
body {
  height: auto !important;
  min-height: 100vh;
  overflow: visible !important;
}

:root {
  /* One easing family instead of the six that had accumulated. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);  --ease-snap: cubic-bezier(0.16, 0.84, 0.44, 1);
  --t-fast: 0.18s;
  --t-base: 0.32s;
  --t-slow: 0.6s;

  /* design.md §3: "Banned: Inter, Roboto, and generic system sans-serifs."
     The stylesheet was still shipping Inter as --font-body. Space Grotesk
     was already loaded and is the family the headings use. */
  --font-body: 'Space Grotesk', sans-serif;
}

/* ── 1 · Easing consistency on every interactive surface ── */
.nav-link,
.lang-toggle,
.btn-primary,
.btn-secondary,
.connect-btn,
.connect-email,
.connect-phone,
.exp-card,
.exp-card::before,
.edu-item::after,
.edu-item::before,
.setting-btn,
.upgrade-btn,
.mode-icon,
.nav-mobile-toggle,
.work-plate,
.work-filter,
.plate-expand {
  transition-timing-function: var(--ease-out);
}

/* Reveals share one duration + curve so sections feel like one machine. */
.scroll-reveal,
.edu-item,
.exp-card,
.work-plate {
  transition-duration: var(--t-slow), var(--t-slow);
  transition-timing-function: var(--ease-out);
}
.exp-card.visible:hover {
  transition-duration: var(--t-base);
}

/* Space Grotesk sits a touch tighter than Inter at the same size. */
.hero-desc,
.bio-text,
.connect-text {
  letter-spacing: 0.004em;
}
.exp-card .exp-desc {
  letter-spacing: 0.006em;
}

/* ── 2 · Hazard seam + top hairline for the new section ── */
#work {
  border-top: 1px solid var(--border);
}
#work::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: repeating-linear-gradient(-45deg, var(--orange-dim) 0 10px, transparent 10px 22px);
  opacity: 0.55;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, black 30%, transparent 72%);
  mask-image: linear-gradient(to right, black 30%, transparent 72%);
}

/* ═══════════ 3 · ARCHIVE / WORK ═══════════ */

.work-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.work-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.work-filter {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  padding: 8px 14px;
  cursor: pointer;
  position: relative;
  transition-property: color, border-color, background-color;
  transition-duration: var(--t-fast);
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}
.work-filter:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.03);
}
.work-filter.active {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--orange-dim);
}
.work-filter.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--orange);
}

.work-readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}
.work-readout-value {
  color: var(--orange);
  font-weight: 700;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(var(--work-cols, 4), 1fr);
  gap: 20px;
}

.work-plate {
  position: relative;
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  margin: 0;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(24px);
  transition-property: opacity, transform, border-color, box-shadow;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
}
.work-plate.visible {
  opacity: 1;
  transform: translateY(0);
}
.work-plate.visible:hover {
  border-color: var(--orange);
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--orange-dim);
  transition-duration: var(--t-base);
}
.work-plate.feature {
  grid-column: span 2;
  grid-row: span 2;
}
.work-plate.wide {
  grid-column: span 2;
}
.work-plate.hidden {
  display: none;
}

.plate-media {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg-floor);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.work-plate:not(.feature):not(.wide) .plate-media {
  aspect-ratio: 3 / 2;
}
.plate-media image-slot {
  display: block;
  width: 100%;
  height: 100%;
}

.plate-idx {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px 9px;
}
.plate-tag {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--orange);
  background: rgba(19, 19, 19, 0.82);
  border-left: 1px solid var(--orange-dim);
  border-bottom: 1px solid var(--orange-dim);
  padding: 4px 9px;
}
[data-theme="light"] .plate-tag {
  background: rgba(213, 208, 203, 0.86);
}

/* Hover: one bright line sweeps the plate, then stops. */
.plate-scan {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background-image: linear-gradient(
    to bottom,
    transparent 0%,
    var(--orange-dim) 44%,
    var(--orange) 50%,
    var(--orange-dim) 56%,
    transparent 100%
  );
  background-size: 100% 44%;
  background-repeat: no-repeat;
  transition: opacity var(--t-fast) linear;
}
/* Hover used to sweep a bright orange line across the plate. The runic lens
   is the hover response now, and two answers to one gesture read as a fault —
   the line flashed on every pass. The element stays for markup stability. */
.work-plate:hover .plate-scan {
  opacity: 0;
  animation: none;
}
@keyframes plate-scan-sweep {
  from { background-position: 0 -46%; }
  to   { background-position: 0 146%; }
}

/* Registration brackets on the media well — bottom corners, so the
   index chip and the category tag keep the top edge to themselves. */
.plate-corner {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  width: 13px;
  height: 13px;
  border: 1px solid var(--orange);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease-out),
              width var(--t-base) var(--ease-out),
              height var(--t-base) var(--ease-out);
}
.plate-corner.bl { bottom: 8px; left: 8px; border-top: none; border-right: none; }
.plate-corner.br { bottom: 8px; right: 8px; border-top: none; border-left: none; }
.work-plate:hover .plate-corner {
  opacity: 0.8;
  width: 20px;
  height: 20px;
}

.plate-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px 15px;
}
.plate-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.plate-title {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cream);
  line-height: 1.2;
  text-wrap: pretty;
}
.work-plate.feature .plate-title {
  font-size: 1.05rem;
}
.plate-meta {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.11em;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Narrow plates stack the caption instead of squeezing the title into
   three lines beside the EXPAND control. */
@container (max-width: 270px) {
  .plate-caption {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .plate-expand {
    align-self: flex-start;
  }
  .plate-title {
    font-size: 0.78rem;
  }
}

.plate-expand {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  padding: 8px 11px;
  cursor: pointer;
  transition-property: color, border-color, background-color;
  transition-duration: var(--t-fast);
  clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}
.plate-expand:hover {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--orange-dim);
}

/* ═══════════ 4 · LIGHTBOX ═══════════ */

.work-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9995;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
}
.work-lightbox.open {
  display: flex;
}
.lb-scrim {
  position: absolute;
  inset: 0;
  background: rgba(6, 6, 8, 0.9);
  backdrop-filter: blur(6px);
  animation: lb-scrim-in var(--t-fast) linear;
}
[data-theme="light"] .lb-scrim {
  background: rgba(35, 30, 26, 0.86);
}
@keyframes lb-scrim-in { from { opacity: 0; } }

.lb-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  max-height: 92vh;
  background: var(--bg-panel);
  border: 1px solid var(--orange-dim);
  animation: lb-frame-in 0.24s var(--ease-snap) both;
}
@keyframes lb-frame-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
}

.lb-head,
.lb-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-card);
  flex: 0 0 auto;
}
.lb-head { border-bottom: 1px solid var(--border); }
.lb-foot { border-top: 1px solid var(--border); justify-content: space-between; }

.lb-idx {
  color: var(--orange);
  font-weight: 700;
}
.lb-title {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.lb-close:hover { color: var(--orange); border-color: var(--orange); }

.lb-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 42vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--bg-floor);
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
}
.lb-img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: none;
}
.lb-img.shown { display: block; }
.lb-empty {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  line-height: 2;
}
.lb-empty.hidden { display: none; }

.lb-nav {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  padding: 9px 14px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out),
              background-color var(--t-fast) var(--ease-out);
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}
.lb-nav:hover {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--orange-dim);
}
.lb-meta {
  flex: 1 1 auto;
  text-align: center;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Corner brackets on the lightbox frame */
.lb-bracket {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid var(--orange);
  opacity: 0.5;
  pointer-events: none;
}
.lb-bracket.tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.lb-bracket.tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.lb-bracket.bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.lb-bracket.br { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* ═══════════ RESPONSIVE ═══════════ */

@media (max-width: 1400px) {
  .work-grid { gap: 16px; }
}

/* Four columns need room; below that the plates get too narrow to read. */
@media (max-width: 1240px) {
  .work-grid { grid-template-columns: repeat(min(var(--work-cols, 4), 3), 1fr); }
}

/* The hero CTAs are flex children — long labels were breaking mid-phrase. */
.btn-primary .btn-text,
.btn-secondary .btn-text {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .work-grid { grid-template-columns: repeat(2, 1fr); }
  .work-plate.feature { grid-row: span 1; }
  .work-toolbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .plate-title { font-size: 0.8rem; }
  .work-plate.feature .plate-title { font-size: 0.92rem; }
}

@media (max-width: 600px) {
  .work-grid { grid-template-columns: 1fr; gap: 14px; }
  .work-plate.feature,
  .work-plate.wide { grid-column: span 1; }
  .work-plate .plate-media,
  .work-plate.feature .plate-media,
  .work-plate.wide .plate-media { aspect-ratio: 3 / 2; }
  .work-filter { font-size: 0.55rem; padding: 7px 10px; }
  .plate-caption { padding: 11px 12px 13px; }
  .lb-frame { max-height: 88vh; }
  .lb-img { max-height: 60vh; }
  .work-lightbox { padding: 12px; }
}

/* Filtered view drops the editorial spans so the grid stays even. */
.work-grid.is-filtered .work-plate.feature,
.work-grid.is-filtered .work-plate.wide {
  grid-column: span 1;
  grid-row: span 1;
}
.work-grid.is-filtered .work-plate .plate-media { aspect-ratio: 3 / 2; }
.work-grid.is-filtered .work-plate.feature .plate-title { font-size: 0.85rem; }

@media (hover: none) and (pointer: coarse) {
  .work-filter { min-height: 44px; }
  .plate-expand { min-height: 44px; }
  .lb-nav, .lb-close { min-height: 44px; }
  .work-plate:hover .plate-scan { animation: none; opacity: 0; }
}

/* ── Section titles take a registration lock once, then leave a faint
   bracket behind. Same target-lock language as the active nav link. ── */
.section-header .section-title {
  position: relative;
}
.section-header.visible .section-title::after {
  content: '';
  position: absolute;
  inset: -11px -15px;
  pointer-events: none;
  background:
    linear-gradient(var(--orange), var(--orange)) left 0 top 0 / 12px 1.5px,
    linear-gradient(var(--orange), var(--orange)) left 0 top 0 / 1.5px 12px,
    linear-gradient(var(--orange), var(--orange)) right 0 top 0 / 12px 1.5px,
    linear-gradient(var(--orange), var(--orange)) right 0 top 0 / 1.5px 12px,
    linear-gradient(var(--orange), var(--orange)) left 0 bottom 0 / 12px 1.5px,
    linear-gradient(var(--orange), var(--orange)) left 0 bottom 0 / 1.5px 12px,
    linear-gradient(var(--orange), var(--orange)) right 0 bottom 0 / 12px 1.5px,
    linear-gradient(var(--orange), var(--orange)) right 0 bottom 0 / 1.5px 12px;
  background-repeat: no-repeat;
  animation: title-lock 1s var(--ease-snap) 0.12s both;
}
@keyframes title-lock {
  0%   { opacity: 0; transform: scale(1.16); }
  38%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0.3; transform: scale(1); }
}
@media (max-width: 600px) {
  .section-header.visible .section-title::after { inset: -8px -10px; }
}
html.hive-motion-off .section-header.visible .section-title::after { animation: none; opacity: 0.3; }

/* ═══════════ MOTION GUARDS ═══════════ */

html.hive-motion-off .work-plate:hover .plate-scan,
html.hive-motion-off .lb-frame,
html.hive-motion-off .lb-scrim {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .section-header.visible .section-title::after {
    animation: none !important;
    opacity: 0.3;
  }
  html:not(.force-motion) .work-plate:hover .plate-scan,  html:not(.force-motion) .lb-frame,
  html:not(.force-motion) .lb-scrim {
    animation: none !important;
  }
  html:not(.force-motion) .work-plate {
    opacity: 1;
    transform: none;
  }
}


/* ═══════════════════════════════════════════════════════════════
   R15 — MOTION PASS
   The site had accumulated eight durations and six curves. This
   normalises every transition onto the three-step scale declared at
   the top (--t-fast / --t-base / --t-slow) and the two curves, then
   adds four restrained mechanical beats. Nothing new is invented:
   same orange, same 1px strokes, same cut corners.
   ═══════════════════════════════════════════════════════════════ */

/* ── 1 · Small chrome: one fast step ── */
.nav-link,
.lang-toggle,
.setting-btn,
.upgrade-btn,
.work-filter,
.plate-expand,
.lb-close,
.lb-nav,
.nav-mobile-toggle,
.hamburger-line,
.chat-close-btn {
  transition-duration: var(--t-fast);
  transition-timing-function: var(--ease-out);
}

/* ── 2 · Buttons, cards, links: one base step ── */
.btn-primary,
.btn-secondary,
.connect-btn,
.connect-email,
.connect-phone,
.mode-icon,
.plate-idx,
.edu-item::before,
.edu-item::after,
.exp-card::before {
  transition-duration: var(--t-base);
  transition-timing-function: var(--ease-out);
}

/* ── 3 · One reveal choreography for every section ──
   Was: 30px/0.7s fades, 20px/0.6s X-slides and 20px/0.6s Y-slides on
   three different curves. Now one distance, one duration, one curve. */
.scroll-reveal {
  transform: translateY(18px);
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-slow) var(--ease-out);
}
.edu-item {
  transform: translateX(-18px);
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-slow) var(--ease-out);
}
.exp-card {
  transform: translateY(18px);
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-base) var(--ease-out),
              background-image var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out);
}
.scroll-reveal.re-enter { transform: translateY(18px); }
.edu-item.re-enter { transform: translateX(-18px); }
.exp-card.re-enter { transform: translateY(18px); }

/* ── 4 · One hover lift for everything that lifts ──
   Buttons used -3px, experience cards -4px, plates -4px. */
.exp-card.visible:hover,
.work-plate.visible:hover {
  transform: translateY(-3px);
}
/* Reveal is slow, hover feedback is quick — same split as the exp cards. */
.work-plate {
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out);
}

/* ── 5 · Ghost section numerals drift in with their header ──
   They were painted at full strength before the header arrived. */
section > .section-header::before {
  opacity: 0;
  transform: translateY(-54%) translateX(16px);
  transition: opacity var(--t-slow) var(--ease-out) 0.1s,
              transform var(--t-slow) var(--ease-out) 0.1s;
}
section > .section-header.visible::before {
  opacity: 0.45;
  transform: translateY(-54%) translateX(0);
}

/* ── 6 · Scroll rail: smooth the per-event height jump ── */
#scroll-rail-fill {
  transition: height 0.12s linear;
}

/* ── 7 · Archive plate: the serial chip inverts on hover ── */
.work-plate:hover .plate-idx {
  background: var(--orange);
  border-color: var(--orange);
  color: #0b0b0d;
}
[data-theme="light"] .work-plate:hover .plate-idx { color: #f0ece6; }

/* ── 8 · Lightbox image arrives under a top-down wipe ── */
.lb-img.shown {
  animation: lb-img-wipe 0.34s var(--ease-snap) both;
}
@keyframes lb-img-wipe {
  from { clip-path: inset(0 0 100% 0); filter: brightness(1.7); }
  to   { clip-path: inset(0 0 0 0); filter: brightness(1); }
}

/* ── 9 · Filter change flashes the archive counter ── */
.work-readout-value.flash {
  animation: readout-flash 0.4s linear;
}
@keyframes readout-flash {
  from { color: #ffd9ad; text-shadow: 0 0 10px var(--orange-glow); }
  to   { color: var(--orange); text-shadow: none; }
}

/* ── Motion guards for the additions ── */
html.hive-motion-off .lb-img.shown,
html.hive-motion-off .work-readout-value.flash,
html.hive-motion-off #scroll-rail-fill {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .lb-img.shown,
  html:not(.force-motion) .work-readout-value.flash,
  html:not(.force-motion) #scroll-rail-fill {
    animation: none !important;
    transition: none !important;
  }
  html:not(.force-motion) section > .section-header::before {
    opacity: 0.45;
    transform: translateY(-54%);
  }
}


/* ═══════════════════════════════════════════════════════════════
   R16 — HIVE_OS HUD FINE-TUNE
   Grounded fixes to the game menu only. No new palette: the panel
   keeps tactical orange, the zinc surface and the cut corners.
   ═══════════════════════════════════════════════════════════════ */

/* ── 1 · Telemetry reads as a monitor again ──
   design.md §3: "Numbers/Metadata: Space Mono — essential for the system
   monitor feel." styles.css was rendering the values in the display face. */
.telemetry-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.telemetry-value.resources {
  font-size: 1.02rem;
  letter-spacing: 0.04em;
}
.telemetry-label {
  letter-spacing: 0.07em;
}

/* ── 2 · Upgrade labels return to the panel's own accent ──
   #5BB0EA was the only blue in an orange HUD. Warm high-contrast cream
   holds the same readability on the zinc surface. */
.btn-label {
  color: #F2E4D6;
}
.upgrade-btn:hover .btn-label {
  color: #FFD2A8;
}

/* ── 3 · Unaffordable upgrades stay legible ──
   opacity:0.3 + grayscale(1) hid the very label you are saving toward, and
   killed the progress bar that says how close you are. Dim the cost, mark
   the frame as pending, keep label and progress readable. */
.upgrade-btn.disabled {
  opacity: 1;
  filter: none;
  border-style: dashed;
  border-color: rgba(113, 113, 122, 0.55);
  background: rgba(24, 24, 30, 0.62);
}
.upgrade-btn.disabled .btn-label {
  color: rgba(242, 228, 214, 0.62);
}
.upgrade-btn.disabled .btn-cost {
  color: rgba(255, 255, 255, 0.45);
}
.upgrade-btn.disabled .btn-progress-fill {
  background: var(--orange);
  opacity: 0.85;
}

/* ── 4 · Two control families read differently ──
   Abilities are momentary with a cooldown; AUTO_MODE / SOUND are state.
   Toggles already carry a 2px left bar (.setting-btn.active), so a ready
   ability takes a 2px top bar instead, and a charging one goes dashed. */
.ability-btn {
  position: relative;
}
.ability-btn.ability-ready::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.75;
}
.ability-btn:not(.ability-ready) {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-dim);
}

/* ── 5 · Threat assessment only alarms when there is a threat ──
   styles.css pulsed .threat-status red on an infinite loop and framed the
   box in red even while the readout said STABLE. main.js now bands the
   level; the frame and the label follow it. */
.threat-status {
  animation: none;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.threat-assessment {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(113, 113, 122, 0.32);
  transition: border-color var(--t-base) var(--ease-out),
              background-color var(--t-base) var(--ease-out);
}
.threat-status.threat-calm { color: #00FFCC; }
.threat-assessment.threat-calm { border-color: rgba(0, 255, 204, 0.22); }

.threat-status.threat-warn { color: #d99a52; }
.threat-assessment.threat-warn {
  background: rgba(217, 154, 82, 0.05);
  border-color: rgba(217, 154, 82, 0.32);
}

.threat-status.threat-alarm {
  color: #FF3333;
  animation: alert-pulse 2s infinite;
}
.threat-assessment.threat-alarm {
  background: rgba(255, 51, 51, 0.06);
  border-color: rgba(255, 51, 51, 0.34);
}

/* ── 6 · Threat bar ramps instead of being uniformly red ── */
.threat-segment {
  background: rgba(255, 255, 255, 0.08);
  transition: background-color var(--t-fast) linear;
}
.threat-segment.active { background: #00FFCC; }
.threat-segment:nth-child(3).active,
.threat-segment:nth-child(4).active { background: #d99a52; }
.threat-segment:nth-child(5).active,
.threat-segment:nth-child(6).active,
.threat-segment:nth-child(7).active,
.threat-segment:nth-child(8).active { background: #FF3333; }

/* ── 7 · Tutorial line: readable over both themes ── */
.hive-panel-tutorial {
  letter-spacing: 0.08em;
  opacity: 0.72;
}

/* ── 8 · Plate trace ──
   next-prompt.md asked for a MORE defined tactical-orange drop-shadow
   tracing the clip-path silhouette. The crisp 1px trace and the deep
   black lift stay; the orange mid-layer goes to the specified 0.35. */
#hive-os-panel {
  filter: drop-shadow(0 0 1px rgba(232, 118, 43, 0.6))
          drop-shadow(0 2px 10px rgba(232, 118, 43, 0.35))
          drop-shadow(0 10px 34px rgba(0, 0, 0, 0.78));
}
[data-theme="light"] #hive-os-panel {
  filter: drop-shadow(0 0 1px rgba(7, 110, 174, 0.55))
          drop-shadow(0 2px 10px rgba(7, 110, 174, 0.3))
          drop-shadow(0 10px 34px rgba(0, 0, 0, 0.34));
}
.panel-edge-glow {
  will-change: opacity, filter;
}
html.hive-motion-off .panel-edge-glow,
html.hive-motion-off .threat-status.threat-alarm {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .threat-status.threat-alarm { animation: none !important; }
}


/* ═══════════════════════════════════════════════════════════════
   R17 — HIVE_OS HUD VISUAL PASS
   Instrument detailing for the game menu. Every motif already exists
   somewhere on the page: serial indices (EXP_001 / ARC_001), the
   white-hot LED cap from the skill bars, registration brackets,
   datasheet leader rules.
   ═══════════════════════════════════════════════════════════════ */

/* ── 1 · Cost reads as a price tag, label as the product ── */
.btn-cost {
  align-self: flex-start;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(232, 118, 43, 0.28);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
.btn-label {
  letter-spacing: 0.015em;
}

/* ── 2 · Progress bar gets the page's LED cap + a real track ── */
.btn-progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-top: 1px solid rgba(232, 118, 43, 0.14);
  position: relative;
  overflow: hidden;
}
.btn-progress-fill {
  position: relative;
}
.btn-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2px;
  background: #ffd9ad;
  box-shadow: 0 0 5px var(--orange-glow);
}

/* ── 4 · Panel sections read as instrument modules ──
   design.md §4: "Control Panels — border-top highlights." */
#hive-os-panel .panel-section .section-header {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(232, 118, 43, 0.22);
  align-items: baseline;
}
#hive-os-panel .panel-section .section-header span:first-child {
  position: relative;
  padding-left: 11px;
}
#hive-os-panel .panel-section .section-header span:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.32em;
  width: 5px;
  height: 5px;
  background: var(--orange);
}

/* ── 5 · RESOURCES is the primary readout, not row one of a list ── */
.telemetry-row:first-child {
  background: rgba(232, 118, 43, 0.07);
  border: 1px solid rgba(232, 118, 43, 0.22);
  border-bottom-width: 1px;
  padding: 5px 8px 6px;
  margin-bottom: 4px;
}
.telemetry-row:first-child .telemetry-label {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  opacity: 0.7;
}
.telemetry-row:first-child .telemetry-value.resources {
  font-size: 1.18rem;
  color: #ffd9ad;
  text-shadow: 0 0 10px var(--orange-glow);
}

/* ── 6 · Datasheet leader rules between label and value ── */
.telemetry-row {
  border-bottom-color: rgba(232, 118, 43, 0.16);
  padding-bottom: 0.22rem;
  gap: 8px;
}
.telemetry-row:not(:first-child) .telemetry-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.telemetry-row:not(:first-child) .telemetry-label::after {
  content: '';
  flex: 1 1 auto;
  min-width: 12px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.22);
  transform: translateY(-0.22em);
}

/* ── 7 · Threat bar framed as a gauge ── */
.threat-bar {
  padding: 1px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  height: 8px;
  box-sizing: content-box;
}
.threat-header {
  letter-spacing: 0.1em;
  padding-bottom: 2px;
}

/* ── 8 · Registration brackets on the panel body ──
   The hero, the lightbox and the theme overlay all carry them; the HUD
   was the only framed region without. */
.panel-sections-row::before,
.panel-sections-row::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(232, 118, 43, 0.5);
  pointer-events: none;
}
.panel-sections-row::before {
  top: -8px;
  left: -10px;
  border-right: none;
  border-bottom: none;
}
.panel-sections-row::after {
  top: -8px;
  right: -12px;
  border-left: none;
  border-bottom: none;
}

/* ── 9 · Ability row sits on a hairline plinth ── */
.panel-settings {
  border-color: rgba(232, 118, 43, 0.28);
  background: rgba(8, 8, 10, 0.55);
}
[data-theme="light"] .panel-settings {
  background: rgba(28, 26, 24, 0.42);
}


/* ── Archive source line ─────────────────────────────────────────
   The readout says how many pieces; this says where they come from.
   Goes live (accent dot) when the ArtStation feed answers. */
.work-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.work-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.work-source:hover {
  color: var(--orange);
  border-bottom-color: var(--orange);
}
.work-source-dot {
  width: 5px;
  height: 5px;
  background: var(--text-dim);
  transition: background-color var(--t-fast) var(--ease-out);
}
.work-source.is-live .work-source-dot {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange-glow);
}
.work-source-path { color: var(--text-secondary); }
.work-source:hover .work-source-path { color: var(--orange); }

/* ── Viewer spec strip ───────────────────────────────────────────
   Tag · software · year on the left, the project link on the right.
   Fields that do not exist are not rendered — no empty labels. */
.lb-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-floor);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.lb-spec {
  min-width: 0;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-visit {
  flex: 0 0 auto;
  color: var(--orange);
  text-decoration: none;
  font-weight: 700;
  border: 1px solid var(--orange-dim);
  padding: 7px 12px;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}
.lb-visit:hover {
  background: var(--orange-dim);
  border-color: var(--orange);
}

@media (max-width: 640px) {
  .work-meta { align-items: flex-start; }
  .lb-info { flex-direction: column; align-items: stretch; gap: 10px; }
  .lb-spec { white-space: normal; line-height: 1.7; }
  .lb-visit { text-align: center; }
}


/* ── Plate media framing ────────────────────────────────────────── */
.plate-media { position: relative; }
.runic-canvas { display: none !important; }
/* Plate furniture stays on top of media. */
.plate-idx, .plate-tag, .plate-scan, .plate-corner { z-index: 2; }


/* ═══════════════════════════════════════════════════════════════
   R19 — LIGHT MODE
   The light theme had inverted its own elevation: the floor was the
   LIGHTEST surface (#D5D0CB) and cards sat two steps DARKER on top of
   it (#BDB8B2), which is the opposite of what the dark theme does and
   the reason everything read as one muddy grey. This restores the
   relationship — paper, then cards lifting off it — raises the whole
   ramp, and deepens the accent so it clears AA on warm paper.
   ═══════════════════════════════════════════════════════════════ */

[data-theme="light"] {
  --bg-floor: #E8E3DB;      /* paper */
  --bg-panel: #E1DBD2;      /* recessed band */
  --bg-card: #F3EFE8;       /* lifts off the paper, as in dark mode */
  --bg-elevated: #FBF8F2;   /* chips, the highest step */
  --border: #B5AEA3;
  --border-light: #8D8579;

  --orange: #0A5F97;        /* 5.2:1 on paper, 5.9:1 on card */
  --orange-dim: rgba(10, 95, 151, 0.13);
  --orange-glow: rgba(10, 95, 151, 0.28);

  --text-primary: #16151A;
  --text-secondary: #3B3936;
  --text-dim: #5C5852;
  --cream: #1D1A17;

  --section-bg: rgba(232, 227, 219, 0.86);
  --nav-bg: rgba(236, 232, 225, 0.94);
  --paper-tint: rgba(40, 32, 22, 0.025);
}

/* The accent is now dark enough to be read directly — the three hand-picked
   darker blues can go back to the token. */
[data-theme="light"] .edu-desc,
[data-theme="light"] .hero-subtitle,
[data-theme="light"] .lang-line { color: var(--orange); }

/* Surfaces that were pinned to the old floor colour. */
[data-theme="light"] .nav-links { background: rgba(236, 232, 225, 0.98); }
[data-theme="light"] .nav-mobile-overlay { background: rgba(232, 227, 219, 0.96); }
[data-theme="light"] #sim-standby,
[data-theme="light"] #audio-hint { background: rgba(240, 236, 229, 0.95); }
[data-theme="light"] .plate-tag { background: rgba(243, 239, 232, 0.9); }

/* Experience cards carry no border by design; on near-white paper they need
   one hairline or they float without an edge. */
[data-theme="light"] .exp-card {
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

/* Hover washes were built as white-on-dark and vanish on light paper. */
[data-theme="light"] .work-filter:hover { background: rgba(22, 21, 26, 0.05); }
[data-theme="light"] .work-plate.visible:hover {
  box-shadow: 0 12px 26px rgba(48, 40, 32, 0.16), 0 0 0 1px var(--orange-dim);
}

/* The HUD keeps its dark instrument surface in both themes; it was a step too
   light for the cream labels to hold contrast. */
[data-theme="light"] #hive-os-panel { background: rgba(70, 70, 76, 0.96); }
[data-theme="light"] #hive-os-panel::before { background: rgba(56, 56, 62, 0.98); }

/* The chat panel is a dark terminal in both themes — its frame was inheriting
   the light border token and disappearing into itself. */
[data-theme="light"] #chat-modal { border-color: rgba(245, 240, 232, 0.16); }
[data-theme="light"] #chat-modal .chat-input { border-color: rgba(245, 240, 232, 0.2); }

/* --- Cyber HUD Overlay for Plates --- */
.plate-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  background: 
    linear-gradient(180deg, rgba(19, 19, 19, 0) 0%, rgba(19, 19, 19, 0.5) 45%, rgba(19, 19, 19, 0.95) 100%),
    url("data:image/svg+xml,%3Csvg width='30' height='30' viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15 0L30 15L15 30L0 15Z' fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='1'/%3E%3Cpath d='M15 13L17 15L15 17L13 15Z' fill='rgba(255,255,255,0.04)'/%3E%3C/svg%3E");
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.work-plate:hover .plate-overlay {
  opacity: 1;
  transform: translateY(0);
}
.plate-hud-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plate-hud-title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.plate-hud-desc {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--cream);
  line-height: 1.4;
  margin-bottom: 4px;
}
.plate-hud-stack {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.plate-hud-action {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bg-card);
  background: var(--orange);
  padding: 4px 8px;
  display: inline-block;
  align-self: flex-start;
  margin-top: 6px;
}
.plate-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.6s ease;
}
.work-plate:hover .plate-img {
  transform: scale(1.05);
  filter: brightness(0.85);
}
/* Ensure the link covers the whole well and does not break flex */
a.plate-media {
  display: block;
  text-decoration: none;
  cursor: pointer;
}
