/* ═══════════════════════════════════════════════════════════════════════════
   ALMA FRAGMENTS v2 — Design System & Styles
   Pure CSS · No frameworks · No external dependencies
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:            #060a12;
  --bg2:           #0b1424;
  --border:        rgba(255,255,255,0.07);
  --text:          #dde4f0;
  --muted:         #5a6a7e;
  --font-h:        'Syne', sans-serif;
  --font-b:        'Plus Jakarta Sans', sans-serif;
  /* Stage accent colors */
  --c-cyan:        #00e5ff;
  --c-gold:        #ffb300;
  --c-coral:       #ff5722;
  --c-emerald:     #00e676;
  /* Fragment type colors */
  --c-pdf:         #e53935;
  --c-xls:         #43a047;
  --c-doc:         #1e88e5;
  --c-dwg:         #f57c00;
  --c-jpg:         #8e24aa;
  --c-cxc:         #00acc1;
  --c-client:      #3d5afe;
  --c-payment:     #00e676;
  --c-contract:    #90a4ae;
  --c-quote:       #7986cb;
  --c-number:      #00bfa5;
  --c-data:        #546e7a;
  --c-order:       #5c6bc0;
  --c-inventory:   #ff8f00;
  --c-project:     #ef6c00;
  --c-report:      #78909c;
  --c-evolution:   #aa00ff;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ── 3. Scroll Architecture ─────────────────────────────────────────────── */
.scroll-wrapper {
  height: 700vh;
  position: relative;
}

.sticky-scene {
  position: sticky;
  top: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ── 4. Background ──────────────────────────────────────────────────────── */
.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* Edge vignette */
.sticky-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 35%, rgba(6,10,18,0.75) 100%);
  pointer-events: none;
  z-index: 1;
}

/* ── 5. Overlay Layers ──────────────────────────────────────────────────── */
#svg-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

#frag-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

#module-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

#panel-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

/* ── 6. Fragment base ───────────────────────────────────────────────────── */
.frag {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: center center;
  will-change: transform, opacity;
  pointer-events: none;
  user-select: none;
}

/* ── 7. File Card fragments (PDF, XLS, DOC, DWG, JPG, RPT) ─────────────── */
.frag-card {
  width: 64px;
  height: 78px;
  border-radius: 5px;
  background: var(--bg2);
  border: 1.5px solid var(--c, #546e7a);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5), inset 0 0 0 0.5px rgba(255,255,255,0.03);
}

/* Dog-ear corner fold */
.frag-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 12px; height: 12px;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.06) 50%);
  border-bottom-left-radius: 2px;
}

.frag-card .fc-tag {
  font-family: monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--bg);
  background: var(--c, #546e7a);
  padding: 3px 6px 2px;
  text-align: center;
  flex-shrink: 0;
}

.frag-card .fc-body {
  flex: 1;
  padding: 7px 7px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.frag-card .fc-line {
  height: 2px;
  border-radius: 1px;
  background: var(--c, #546e7a);
  opacity: 0.22;
}
.frag-card .fc-line:nth-child(2) { width: 75%; opacity: 0.15; }
.frag-card .fc-line:nth-child(3) { width: 88%; opacity: 0.12; }
.frag-card .fc-line:nth-child(4) { width: 60%; opacity: 0.10; }
.frag-card .fc-line:nth-child(5) { width: 80%; opacity: 0.08; }

.frag-card .fc-sub {
  font-family: monospace;
  font-size: 6px;
  color: var(--c, #546e7a);
  opacity: 0.55;
  padding: 0 6px 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* PDF */
.frag.type-pdf { --c: var(--c-pdf); }

/* XLS — mini grid body */
.frag.type-xls { --c: var(--c-xls); }
.frag.type-xls .fc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}
.frag.type-xls .fc-line {
  height: auto;
  min-height: 8px;
  width: 100%;
}

/* DOC */
.frag.type-doc { --c: var(--c-doc); }

/* DWG — blueprint style */
.frag.type-dwg { --c: var(--c-dwg); }
.frag.type-dwg .frag-card { background: #061624; }
.frag.type-dwg .fc-body { position: relative; padding: 4px; }
.frag.type-dwg .bp-border {
  position: absolute;
  inset: 3px;
  border: 0.5px solid rgba(245,124,0,0.25);
}
.frag.type-dwg .bp-line {
  position: absolute;
  background: rgba(245,124,0,0.2);
}
.frag.type-dwg .bp-h { height: 0.5px; width: 70%; top: 38%; left: 10%; }
.frag.type-dwg .bp-h2 { height: 0.5px; width: 50%; top: 62%; left: 10%; }
.frag.type-dwg .bp-v { width: 0.5px; height: 45%; top: 25%; left: 35%; }

/* JPG — image placeholder */
.frag.type-jpg { --c: var(--c-jpg); }
.frag.type-jpg .frag-card { background: #100818; }
.frag.type-jpg .fc-body {
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 0;
}
.frag.type-jpg .img-placeholder {
  width: 40px; height: 32px;
  border: 1px solid rgba(142,36,170,0.25);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.frag.type-jpg .img-placeholder::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(rgba(142,36,170,0.1), rgba(142,36,170,0.2));
}

/* Report */
.frag.type-report { --c: var(--c-report); }

/* ── 8. Pill / Badge fragments ──────────────────────────────────────────── */
.frag-pill {
  padding: 5px 11px 4px;
  border-radius: 20px;
  border: 1px solid var(--c, #546e7a);
  background: rgba(0,0,0,0.45);
  font-family: monospace;
  font-size: 9.5px;
  letter-spacing: 0.8px;
  color: var(--c, #546e7a);
  white-space: nowrap;
  line-height: 1.4;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 0 0 0.5px rgba(255,255,255,0.04);
}

.frag-pill .pill-sub {
  display: block;
  font-size: 7px;
  opacity: 0.5;
  margin-top: 1px;
}

.frag.type-cxc      { --c: var(--c-cxc); }
.frag.type-quote    { --c: var(--c-quote); }
.frag.type-payment  { --c: var(--c-payment); }
.frag.type-data     { --c: var(--c-data); }
.frag.type-project  { --c: var(--c-project); }
.frag.type-inventory{ --c: var(--c-inventory); }
.frag.type-order    { --c: var(--c-order); }
.frag.type-evolution{ --c: var(--c-evolution); }

/* ── 9. Special fragment types ──────────────────────────────────────────── */

/* Client card */
.frag.type-client { --c: var(--c-client); }
.frag-client-card {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  background: rgba(61,90,254,0.07);
  border: 1px solid rgba(61,90,254,0.3);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  min-width: 88px;
}
.cc-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(61,90,254,0.2);
  border: 1px solid rgba(61,90,254,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: rgba(100,130,255,0.8);
  flex-shrink: 0;
}
.cc-info { display: flex; flex-direction: column; gap: 2px; }
.cc-name { font-size: 8px; font-weight: 600; color: rgba(180,195,255,0.9); letter-spacing: 0.3px; }
.cc-sub  { font-size: 6.5px; color: rgba(100,130,200,0.55); font-family: monospace; }

/* Contract card */
.frag.type-contract { --c: var(--c-contract); }
.frag-contract-card {
  width: 64px; height: 78px;
  border-radius: 5px;
  background: rgba(25,35,48,0.9);
  border: 1px solid rgba(144,164,174,0.25);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.ct-seal {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(144,164,174,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: rgba(144,164,174,0.45);
}
.ct-label { font-family: monospace; font-size: 7px; color: rgba(144,164,174,0.55); letter-spacing: 1px; }
.ct-id    { font-family: monospace; font-size: 5.5px; color: rgba(144,164,174,0.35); }

/* Number block */
.frag.type-number { --c: var(--c-number); }
.frag-number-block {
  font-family: var(--font-h);
  font-size: 19px;
  font-weight: 800;
  color: var(--c-number);
  text-shadow: 0 0 20px rgba(0,191,165,0.35);
  white-space: nowrap;
  line-height: 1;
}
.frag-number-block small {
  display: block;
  font-family: var(--font-b);
  font-weight: 400;
  font-size: 7px;
  letter-spacing: 1.5px;
  color: rgba(0,191,165,0.45);
  text-shadow: none;
  margin-top: 3px;
}

/* Order card */
.frag.type-order { --c: var(--c-order); }
.frag-order-card {
  background: rgba(92,107,192,0.08);
  border: 1px solid rgba(92,107,192,0.28);
  border-radius: 6px;
  padding: 6px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.ord-label { font-family: monospace; font-size: 6.5px; color: rgba(92,107,192,0.55); letter-spacing: 1px; margin-bottom: 1px; }
.ord-id    { font-family: var(--font-h); font-size: 14px; font-weight: 700; color: rgba(151,163,240,0.85); letter-spacing: 0.5px; }

/* ── 10. Module boxes ───────────────────────────────────────────────────── */
.mod {
  position: absolute;
  background: rgba(8, 14, 26, 0.88);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: scale(0.90) translateY(10px);
  transition: opacity 0.7s cubic-bezier(0.16,1,0.3,1),
              transform 0.7s cubic-bezier(0.16,1,0.3,1),
              border-color 0.5s ease;
  overflow: hidden;
}

.mod.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.mod-hd {
  padding: 8px 12px;
  font-family: var(--font-h);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2.5px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.015);
}

.mod-bd {
  padding: 9px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-content: flex-start;
  min-height: 52px;
}

/* Mini chips inside module bodies */
.mod-chip {
  font-family: monospace;
  font-size: 8px;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid;
  opacity: 0;
  transform: scale(0.65) translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.mod-chip.shown {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* ── 11. ALMA Core ──────────────────────────────────────────────────────── */
.alma-core {
  position: absolute;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.alma-core.visible { opacity: 1; }

.ac-rings {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
}

.ac-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(0,229,255,0.18);
}
.r1 { width:56px;  height:56px;  animation: ring-s 7s linear infinite; }
.r2 { width:82px;  height:82px;  border-style: dashed; border-color: rgba(0,229,255,0.10); animation: ring-s 13s linear infinite reverse; }
.r3 { width:108px; height:108px; border-color: rgba(0,229,255,0.06); animation: ring-s 22s linear infinite; }

@keyframes ring-s {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ac-wordmark {
  position: relative;
  z-index: 1;
  font-family: var(--font-h);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--c-cyan);
  text-shadow: 0 0 18px rgba(0,229,255,0.45);
}

/* ── 12. Stage text panels ──────────────────────────────────────────────── */
.stg-panel {
  position: absolute;
  left: 5.5%;
  top: 50%;
  max-width: 360px;
  opacity: 0;
  transform: translate(0, calc(-50% + 22px));
  transition: opacity 0.55s cubic-bezier(0.16,1,0.3,1),
              transform 0.55s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.stg-panel.active {
  opacity: 1;
  transform: translate(0, -50%);
}

.stg-tag {
  font-family: monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.stg-letter {
  font-family: var(--font-h);
  font-size: 60px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 0 40px currentColor;
  opacity: 0.85;
}

.stg-h1, .stg-h2 {
  font-family: var(--font-h);
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #fff 15%, rgba(190,205,225,0.65));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stg-p {
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--muted);
  margin-bottom: 18px;
  max-width: 310px;
}

.stg-code {
  font-family: monospace;
  font-size: 0.675rem;
  color: var(--c-cyan);
  letter-spacing: 1.5px;
  opacity: 0.65;
  display: block;
  border-top: 1px solid rgba(0,229,255,0.12);
  padding-top: 10px;
}

/* Panel glass backdrop (shows on smaller viewports) */
@media (max-width: 1024px) {
  .stg-panel {
    left: 4%;
    right: 4%;
    max-width: none;
    top: auto;
    bottom: 9vh;
    transform: translateY(20px);
    background: rgba(6,10,18,0.8);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
    backdrop-filter: blur(14px);
  }
  .stg-panel.active { transform: translateY(0); }
  .stg-h1, .stg-h2 { font-size: 1.35rem; }
  .stg-letter { font-size: 44px; }
}

@media (max-width: 600px) {
  .stg-panel { bottom: 4vh; padding: 16px 18px; }
  .stg-h1, .stg-h2 { font-size: 1.15rem; }
}

/* ── 13. HUD bar ────────────────────────────────────────────────────────── */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 28px;
  font-family: monospace;
  font-size: 0.68rem;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  background: rgba(6,10,18,0.72);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.hud-brand {
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 5px;
  color: var(--c-cyan);
}
.hud-sep  { color: rgba(255,255,255,0.13); margin: 0 8px; }
.hud-tag, .hud-key { color: var(--muted); }
.hud-val  { color: var(--c-cyan); font-weight: 700; }
.hud-right { display: flex; align-items: center; gap: 2px; }
.mono { font-family: monospace; }

.blink { animation: blink-a 2.2s ease-in-out infinite; }
@keyframes blink-a {
  0%,100% { opacity: 0.65; }
  50% { opacity: 1; text-shadow: 0 0 10px var(--c-cyan); }
}

@media (max-width: 600px) {
  .hud { flex-direction: column; gap: 5px; padding: 9px 14px; font-size: 0.6rem; }
  .hud-right { flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
}

/* ── 14. Side navigation ────────────────────────────────────────────────── */
.sidenav {
  position: fixed;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidenav-step {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: flex-end;
  opacity: 0.28;
  transition: opacity 0.3s ease;
  padding: 0;
}
.sidenav-step:hover { opacity: 0.75; }
.sidenav-step.active { opacity: 1; }

.sn-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text);
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.sidenav-step.active .sn-dot {
  background: var(--c-cyan);
  box-shadow: 0 0 8px var(--c-cyan);
  transform: scale(1.8);
}

.sn-lbl {
  font-family: monospace;
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  color: var(--text);
  opacity: 0;
  transform: translateX(5px);
  transition: all 0.28s ease;
  white-space: nowrap;
}
.sidenav-step:hover .sn-lbl,
.sidenav-step.active .sn-lbl {
  opacity: 1;
  transform: translateX(0);
  color: var(--c-cyan);
}

@media (max-width: 900px) { .sidenav { display: none; } }

/* ── 15. Scroll cue ─────────────────────────────────────────────────────── */
.scroll-cue {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  opacity: 0.55;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.scroll-cue.hidden { opacity: 0; }

.sc-mouse {
  width: 21px; height: 34px;
  border: 1.5px solid var(--muted);
  border-radius: 11px;
  display: flex; justify-content: center;
  padding-top: 5px;
}
.sc-wheel {
  width: 3px; height: 6px;
  background: var(--c-cyan);
  border-radius: 2px;
  animation: scw 1.7s ease-out infinite;
}
@keyframes scw {
  0%   { transform: translateY(0); opacity: 1; }
  80%  { transform: translateY(13px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}
.sc-text {
  font-family: monospace;
  font-size: 0.58rem;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}
