/* ============================================================
   FRAGMENTS · projector
   Dark, mono-only, keyboard-driven single-piece viewer.
   Deliberately opposite to website/ (light editorial catalogue).
   ============================================================ */

:root {
  --bg:        #0A0908;          /* near-black, faint warm tint */
  --bg-frame:  #14110F;
  --ink:       #E8E2D4;          /* warm off-white */
  --ink-soft:  #9C958A;
  --ink-mute:  #5A544B;
  --rule:      #2A2620;
  --accent:    #C45D32;          /* deeper orange than site 1 */

  --mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;

  --t-fade:    700ms;            /* piece → piece crossfade */
  --t-fast:    220ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 0.02em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle film-grain noise overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.97  0 0 0 0 0.88  0 0 0 0.16 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.35;
  mix-blend-mode: overlay;
  z-index: 9999;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  background: transparent;
  border: 1px solid var(--ink-mute);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0;
  line-height: 1.2;
  vertical-align: middle;
}

/* ============================================================
   Stage — the single-piece view
   ============================================================ */

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 8vh 4vw 8vh;
  gap: 4vh;
}

.coord {
  font-family: var(--mono);
  font-weight: 400;
  font-size: clamp(18px, 2.4vw, 30px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: center;
  user-select: text;
}

.frame {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: min(1200px, 76vw);
  max-height: 66vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Two stacked image layers — we alternate which is opaque on navigate
   to crossfade between pieces. */
.layer {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity var(--t-fade) ease;
}
.layer.is-active { opacity: 1; }

.meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}

/* ============================================================
   HUDs (corners)
   ============================================================ */

.hud {
  position: fixed;
  z-index: 50;
  font-family: var(--mono);
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  transition: opacity .5s ease;
}

/* Brand — top-left, persistent */
.hud--brand {
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1;
}
.brand__name {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.32em;
  color: var(--ink);
}
.brand__sub {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.brand__link {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s ease, border-color .2s ease;
}
.brand__link:hover { color: var(--ink); border-bottom-color: var(--ink-mute); }

/* Mode — top-right */
.hud--mode {
  top: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  text-transform: uppercase;
}
.mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* Hints — bottom-left, fade on inactivity */
.hud--hints {
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 200px;
  font-size: 10px;
  text-transform: uppercase;
}
.hud--hints span { display: flex; align-items: center; gap: 8px; }
.hud--hints.is-faded { opacity: 0.18; }

/* Minimap — bottom-right, prominent (was 140 → now 240) */
.hud--map {
  bottom: 24px;
  right: 24px;
  width: 240px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.hud-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  align-self: flex-end;
}
#minimap {
  width: 240px;
  height: 240px;
  background: rgba(20, 17, 15, 0.6);
  border: 1px solid var(--rule);
  cursor: crosshair;
}
/* Every piece on the map — quietly luminous */
#minimap .dot {
  fill: var(--ink-soft);
  opacity: 0.45;
}
/* Current piece — white highlight + halo */
#minimap .dot--curr {
  fill: var(--ink);
  filter: drop-shadow(0 0 6px rgba(232, 226, 212, 0.75));
}
#minimap .ring--curr {
  fill: none;
  stroke: var(--ink);
  stroke-width: 0.6;
  opacity: 0.55;
}

/* ============================================================
   Contact-sheet overlay
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 9, 8, 0.97);
  display: flex;
  flex-direction: column;
  animation: fade-in var(--t-fast) ease;
}
.overlay[hidden] { display: none !important; }

.overlay__head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.overlay__head .dim { color: var(--ink-mute); }

.grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px;
}
.cell {
  background: var(--bg-frame);
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color .15s ease, transform .15s ease;
  position: relative;
}
.cell img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  opacity: 0.78;
  transition: opacity .15s ease;
}
.cell:hover { border-color: var(--accent); }
.cell:hover img { opacity: 1; }
.cell.is-current {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   About overlay (toggled with A)
   ============================================================ */

.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10, 9, 8, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6vw;
  animation: fade-in var(--t-fast) ease;
  cursor: pointer;
}
.about-overlay[hidden] { display: none !important; }

.about-overlay__panel {
  max-width: 540px;
  background: var(--bg-frame);
  border: 1px solid var(--rule);
  padding: 36px 40px;
  cursor: default;
}
.about-overlay__panel h2 {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  margin: 0 0 24px;
  color: var(--ink);
}
.about-overlay__panel p {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 300;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.about-overlay__meta {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  font-size: 12px !important;
}
.about-overlay__meta a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink-mute);
}
.about-overlay__meta a:hover { border-bottom-color: var(--ink); }
.about-overlay__close {
  font-size: 10px !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 24px !important;
  margin-bottom: 0 !important;
}

/* ============================================================
   Boot splash — fades on first frame
   ============================================================ */

.boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 800ms ease;
}
.boot.is-gone { opacity: 0; pointer-events: none; }

.boot__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
}
.boot__title {
  font-size: clamp(28px, 5vw, 56px);
  font-weight: 400;
  letter-spacing: 0.32em;
  color: var(--ink);
}
.boot__sub {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.boot__hint {
  margin-top: 24px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  opacity: 0;
  animation: hint-blink 2.4s ease-in 0.6s infinite;
}
@keyframes hint-blink {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

/* ============================================================
   Mobile / narrow viewport
   ============================================================ */

@media (max-width: 760px) {
  .stage { padding: 12vh 16px 22vh; gap: 2vh; }
  .coord { font-size: 16px; letter-spacing: 0.1em; }
  .hud--hints { display: none; }
  .hud--brand { top: 16px; left: 16px; }
  .hud--mode  { top: 16px; right: 16px; }
  .hud--map   { bottom: 16px; right: 16px; width: 140px; }
  #minimap    { width: 140px; height: 140px; }
}
