/* =====================================================================
   OASIS_OS — 3D blueprint viewer (blueprint.html). Loads after site.css.
   The scene keeps its blueprint blue; the chrome uses the site system.
   js/blueprint-engine.js owns the element ids used here.
   ===================================================================== */

.page-blueprint {
  --bp: #0a1628;
  --bp-line: #1e3352;
  --bp-ink: #cfe6ff;
  --bp-accent: #5cb2ff;
  --bp-panel: rgba(8, 14, 26, 0.78);
  background: var(--bp);
}
.page-blueprint .topbar { position: fixed; left: 0; right: 0; background: rgba(8, 9, 13, 0.82); }
.page-blueprint main { padding-top: var(--topbar-h); }

/* Before the engine picks a mode, and in gallery mode, the viewer chrome is hidden. */
.page-blueprint:not(.is-viewer) .hud,
.page-blueprint:not(.is-viewer) #dims,
.page-blueprint:not(.is-viewer) #legend,
.page-blueprint:not(.is-viewer) .hud__dock,
.page-blueprint:not(.is-viewer) .state-note { display: none; }
.page-blueprint:not(.is-gallery) #gallery,
.page-blueprint:not(.is-gallery) .footer { display: none; }
.page-blueprint .footer { background: var(--bg); }
.page-blueprint.is-viewer { overflow: hidden; }

.page-blueprint canvas {
  position: fixed; inset: 0; z-index: 0; display: block;
  touch-action: none; outline: none;
}
.page-blueprint canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--bp-accent); }

#loading.is-error {
  flex-direction: column; gap: 1.25rem; padding: 2rem; text-align: center;
  letter-spacing: 0.04em; text-transform: none; line-height: 1.6;
}
#loading.is-error img {
  width: min(720px, 100%); border-radius: var(--radius); border: 1px solid var(--bp-line);
}
#loading {
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: var(--bp); color: var(--bp-accent);
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.2em; text-transform: uppercase;
}

/* ---------- HUD ---------- */
.hud__panel {
  background: var(--bp-panel); border: 1px solid var(--bp-line); border-radius: 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--bp-ink); font-family: var(--mono);
}
.hud {
  position: fixed; z-index: 10; left: 0; right: 0; top: calc(var(--topbar-h) + 16px);
  padding: 0 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud__panel--title { padding: 14px 16px 16px; max-width: min(560px, 100%); }
.hud__crumbs { display: flex; flex-wrap: wrap; gap: 0.15rem 0.5rem; font-size: 0.72rem; color: rgba(207, 230, 255, 0.6); }
.hud__crumbs a { color: var(--bp-accent); }
#back-link:not(:empty)::before { content: "/"; margin-right: 0.5rem; color: rgba(207, 230, 255, 0.4); }
#title {
  margin-top: 0.4rem; font-family: var(--sans); font-size: 1.2rem; font-weight: 700;
  letter-spacing: -0.01em; color: #fff;
}
#subtitle { margin-top: 0.25rem; font-size: 0.72rem; line-height: 1.6; color: rgba(207, 230, 255, 0.7); }

#tabs { margin-top: 0.85rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
#tabs:empty { display: none; }
#tabs button {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; cursor: pointer;
  padding: 0.4rem 0.75rem; border-radius: var(--radius-pill);
  background: transparent; color: rgba(207, 230, 255, 0.75);
  border: 1px solid rgba(92, 178, 255, 0.3);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
#tabs button:hover { color: #fff; border-color: var(--bp-accent); }
#tabs button.active { background: var(--bp-accent); color: #04101f; border-color: var(--bp-accent); font-weight: 700; }

#controls { padding: 12px 14px; font-size: 0.7rem; line-height: 1.9; color: rgba(207, 230, 255, 0.7); text-align: right; }
#controls kbd {
  font-family: var(--mono); font-size: 0.66rem; padding: 0.05rem 0.35rem; border-radius: 4px;
  border: 1px solid rgba(92, 178, 255, 0.35); color: var(--bp-ink); background: rgba(92, 178, 255, 0.08);
}

#dims {
  position: fixed; z-index: 10; right: 20px; top: calc(var(--topbar-h) + 132px);
  padding: 10px 14px; font-size: 0.68rem; line-height: 1.9; text-align: right;
  color: rgba(207, 230, 255, 0.7); pointer-events: none;
}
#dims:empty, #legend:empty { display: none; }

#legend {
  position: fixed; z-index: 10; left: 20px; bottom: 20px;
  padding: 10px 14px; font-size: 0.7rem; line-height: 2; pointer-events: none;
}
#legend .row { display: flex; align-items: center; gap: 10px; }
#legend .swatch { width: 22px; height: 3px; border-radius: 2px; display: inline-block; }

/* Bottom-right dock: reset camera + explode slider. */
.hud__dock {
  position: fixed; z-index: 10; right: 20px; bottom: 20px;
  display: flex; align-items: stretch; gap: 8px;
}
#explode-slider {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 0.7rem;
}
#explode-slider input { width: 140px; accent-color: var(--bp-accent); }
.hud__reset {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0 14px; cursor: pointer;
  font-size: 0.7rem; color: var(--bp-ink);
  transition: border-color var(--dur-1), color var(--dur-1);
}
.hud__reset:hover { border-color: var(--bp-accent); color: #fff; }
.hud__reset:focus-visible { outline-color: var(--bp-accent); }
.hud__legend-btn {
  display: none; padding: 0 12px; cursor: pointer; font-size: 0.7rem; color: var(--bp-ink);
}
.hud__legend-btn[aria-expanded="true"] { border-color: var(--bp-accent); color: #fff; }

.state-note {
  position: fixed; z-index: 10; right: 20px; bottom: 76px; max-width: 220px;
  font-family: var(--mono); font-size: 0.68rem; line-height: 1.7; text-align: right;
  color: rgba(207, 230, 255, 0.8); pointer-events: none;
  text-shadow: 0 0 6px var(--bp), 0 0 12px var(--bp);
}

#tooltip {
  position: fixed; z-index: 20; display: none; max-width: 320px; pointer-events: none;
  padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(92, 178, 255, 0.45);
  background: rgba(8, 14, 26, 0.94); color: var(--bp-ink);
  font-family: var(--mono); font-size: 0.74rem; line-height: 1.55;
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.9);
}
#tooltip .label { color: var(--bp-accent); font-weight: 700; margin-bottom: 2px; }
#tooltip .dim { color: rgba(207, 230, 255, 0.6); font-size: 0.7rem; }

@media (max-width: 760px) {
  .hud { padding: 0 12px; top: calc(var(--topbar-h) + 10px); }
  #controls, #dims { display: none; }
  .hud__panel--title { padding: 12px 14px; }
  #subtitle { display: none; }
  #legend {
    left: 12px; right: 12px; bottom: 70px; padding: 8px 12px;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px;
    font-size: 0.62rem; line-height: 1.75;
  }
  #legend .row { min-width: 0; }
  /* folded behind the dock's Legend button (js/blueprint-page.js) */
  .page-blueprint:not(.legend-open) #legend { display: none; }
  .hud__legend-btn:not([hidden]) { display: inline-flex; align-items: center; }
  .hud__crumbs { flex-wrap: nowrap; min-width: 0; }
  #back-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud__dock { left: 12px; right: 12px; bottom: 12px; }
  .hud__reset span { display: none; }
  .hud__reset { padding: 0 12px; }
  .hud__dock > button { flex: none; }
  #explode-slider { flex: 1; min-width: 0; justify-content: center; padding-inline: 12px; }
  #explode-slider input { flex: 1; min-width: 0; width: auto; }
  #explode-slider > span { display: none; }
  .state-note { display: none; }
}

/* ---------- Gallery (no ?diagram=) ---------- */
#gallery {
  min-height: calc(100vh - var(--topbar-h));
  padding-block: clamp(3rem, 8vw, 5.5rem);
  background:
    linear-gradient(rgba(92, 178, 255, 0.05) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(92, 178, 255, 0.05) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--bp);
}
#gallery .kicker { color: var(--bp-accent); }
#gallery h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.05; letter-spacing: -0.03em; font-weight: 750;
}
.gallery__lede { margin-top: 1rem; max-width: 40rem; color: rgba(207, 230, 255, 0.72); font-size: 1.05rem; }
.gallery__lede a { color: var(--bp-accent); }
#gallery .cards {
  margin-top: clamp(2rem, 5vw, 3rem); display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
#gallery .card {
  display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--bp-line); background: #0c1a30; color: var(--bp-ink);
  transition: border-color 0.2s, transform 0.25s var(--ease);
}
#gallery .card:hover { text-decoration: none; border-color: var(--bp-accent); transform: translateY(-3px); }
#gallery .card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; opacity: 0.9; transition: opacity 0.2s; }
#gallery .card:hover img { opacity: 1; }
.card-body { display: grid; gap: 0.35rem; padding: 1.1rem 1.25rem 1.3rem; }
.card-kicker { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bp-accent); }
.card-title { font-size: 1.15rem; font-weight: 650; color: #fff; letter-spacing: -0.01em; }
.card-desc { font-size: 0.92rem; color: rgba(207, 230, 255, 0.72); }
.card-cta {
  margin-top: 0.5rem; font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.04em;
  color: var(--bp-accent);
}
#gallery .card:hover .card-cta { color: #fff; }
.gallery__hints {
  margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem;
  font-family: var(--mono); font-size: 0.74rem; color: rgba(207, 230, 255, 0.66);
}
.gallery__hints kbd {
  font-size: 0.7rem; border-color: rgba(92, 178, 255, 0.35); background: rgba(92, 178, 255, 0.08);
  color: var(--bp-ink);
}
