/* ============================================================
   COMPEO — boot loader ("Contact Sheet")
   Full-screen boot overlay for index.html only. A photographer's
   proof sheet reviews the listing set, then the sheet snaps away
   and the Compeo lockup resolves like a camera iris opening.
   Vanilla port of compeo-loaders-lab/src/loaders/21-contact-sheet.
   ============================================================ */

:root { --ink: #17140f; --char-2: #26221c; }

/* lock the page while the overlay is up */
html.boot-active,
html.boot-active body { overflow: hidden; }

#boot-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--ink);
  color: var(--cream);
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.55s var(--ease);
}
#boot-loader.boot--lift { opacity: 0; pointer-events: none; }
#boot-loader.boot--gone { display: none; }

/* session-skip: repeat load this session — no sheet, no readout, quick fade */
#boot-loader.boot--skip { transition: opacity 0.3s var(--ease); }
#boot-loader.boot--skip .cs-stage,
#boot-loader.boot--skip .boot-progress { display: none; }

/* soft workbench vignette */
#boot-loader .boot__vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 20%, rgba(50,44,36,0.55), rgba(23,20,15,1) 70%);
}

/* film-grain overlay helper (from lab index.css) */
.boot-grain::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- THE SHEET ---------------- */
#boot-loader .cs-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; }

@media (min-width: 640px) { #boot-loader .cs-stage { padding: 2rem; } }

#boot-loader .cs-sheet {
  position: relative;
  width: 100%;
  max-width: 860px;
  border-radius: 8px;
  background: rgba(30,27,23,0.92);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.5);
  transition: transform 0.8s var(--ease), opacity 0.8s var(--ease), filter 0.8s var(--ease);
  transform-origin: center;
}
#boot-loader.is-revealed .cs-sheet {
  transform: scale(0.9);
  opacity: 0.24;
  filter: blur(3px);
}

/* sheet header + footer meta */
#boot-loader .cs-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem 0.25rem;
  font-family: var(--sans);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.25em;
  color: rgba(247,242,234,0.4);
}
#boot-loader .cs-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.25rem 1rem 0.75rem;
}
#boot-loader .cs-foot__label {
  font-family: var(--sans); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.28em;
  color: rgba(247,242,234,0.45);
}
#boot-loader .cs-foot__count {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--amber-hi);
}

/* sprocket strips */
#boot-loader .cs-sprockets {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0.5rem;
}
#boot-loader .cs-sprockets span {
  height: 7px; width: 9px; flex: 0 0 auto; border-radius: 2px;
  background: rgba(23,20,15,0.7);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5);
}
#boot-loader .cs-sprockets--top { padding-top: 0.25rem; }
#boot-loader .cs-sprockets--bot { padding-bottom: 0.5rem; }

/* frame grid */
#boot-loader .cs-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 8px;
  padding: 0.75rem 0.75rem;
}
@media (min-width: 640px) { #boot-loader .cs-grid { grid-template-columns: repeat(4, 1fr); gap: 22px 12px; } }
@media (min-width: 820px) { #boot-loader .cs-grid { grid-template-columns: repeat(5, 1fr); } }

#boot-loader .cs-cell { position: relative; }
#boot-loader .cs-frame {
  position: relative; overflow: hidden; border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
  aspect-ratio: 4 / 3;
}
#boot-loader .cs-frame img {
  height: 100%; width: 100%; object-fit: cover; display: block;
  user-select: none; -webkit-user-drag: none;
  opacity: 0.82;
  filter: none;
  transition: filter 0.5s ease, opacity 0.5s ease;
}
#boot-loader .cs-cell.is-reviewed .cs-frame img { opacity: 1; }
#boot-loader .cs-cell.is-reviewed.is-reject .cs-frame img { opacity: 0.55; filter: grayscale(0.8) brightness(0.5); }

/* dim un-reviewed / warm the active frame */
#boot-loader .cs-frame__tint {
  position: absolute; inset: 0; pointer-events: none;
  background: rgba(15,12,9,0.35);
  transition: background 0.5s ease;
}
#boot-loader .cs-cell.is-reviewed .cs-frame__tint { background: transparent; }
#boot-loader .cs-cell.is-active .cs-frame__tint {
  background: radial-gradient(120% 120% at 50% 40%, rgba(200,116,60,0.12), transparent 70%);
}

/* grease-pencil mark svg */
#boot-loader .cs-mark { position: absolute; inset: 0; height: 100%; width: 100%; overflow: visible; pointer-events: none; }
#boot-loader .cs-mark path { transition: stroke-dashoffset 0.5s var(--ease), opacity 0.3s ease; }
/* keeper ellipse + check */
#boot-loader .cs-ellipse {
  fill: none; stroke: var(--amber-hi); stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0;
  filter: drop-shadow(0 0 3px rgba(224,138,74,0.45));
}
#boot-loader .cs-check {
  fill: none; stroke: var(--amber-hi); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40; opacity: 0;
  transition: stroke-dashoffset 0.35s var(--ease) 0.28s, opacity 0.2s ease 0.28s;
}
#boot-loader .cs-x {
  fill: none; stroke: rgba(236,227,214,0.7); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 30; stroke-dashoffset: 30; opacity: 0;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
  transition: stroke-dashoffset 0.4s var(--ease), opacity 0.25s ease;
}
#boot-loader .cs-cell.is-reviewed .cs-ellipse { stroke-dashoffset: 0; opacity: 0.95; }
#boot-loader .cs-cell.is-reviewed .cs-check { stroke-dashoffset: 0; opacity: 1; }
#boot-loader .cs-cell.is-reviewed .cs-x { stroke-dashoffset: 0; opacity: 0.85; }

/* frame number, grease-pencil style */
#boot-loader .cs-no {
  position: absolute; bottom: -14px; left: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  color: rgba(236,227,214,0.35); transition: color 0.4s ease;
}
#boot-loader .cs-cell.is-reviewed .cs-no { color: var(--amber-hi); }

/* ---------------- LOUPE ---------------- */
#boot-loader .cs-loupe {
  position: absolute; z-index: 20; pointer-events: none;
  display: grid; place-items: center;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1),
              width 0.3s cubic-bezier(0.22,1,0.36,1),
              height 0.3s cubic-bezier(0.22,1,0.36,1),
              opacity 0.25s ease;
}
#boot-loader.is-loupe-on .cs-loupe { opacity: 1; }
#boot-loader.is-revealed .cs-loupe { opacity: 0; }
#boot-loader .cs-loupe__ring {
  position: relative; width: 72%; aspect-ratio: 1 / 1;
  animation: cs-loupe-pulse 1.6s ease-in-out infinite;
}
@keyframes cs-loupe-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
#boot-loader .cs-loupe__disc {
  position: absolute; inset: 0; border-radius: 999px;
  border: 2px solid rgba(224,138,74,0.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 0 14px rgba(224,138,74,0.35), inset 0 0 18px rgba(224,138,74,0.12);
  background: radial-gradient(circle at 38% 34%, rgba(247,242,234,0.10), transparent 55%);
}
#boot-loader .cs-loupe__h,
#boot-loader .cs-loupe__v {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(224,138,74,0.7);
}
#boot-loader .cs-loupe__h { height: 1px; width: 12px; }
#boot-loader .cs-loupe__v { height: 12px; width: 1px; }
#boot-loader .cs-loupe__handle {
  position: absolute; right: -16px; bottom: 6px;
  height: 3px; width: 24px; border-radius: 999px;
  background: rgba(224,138,74,0.9);
  transform: rotate(38deg); transform-origin: left center;
}

/* ---------------- weighted-preloader readout ---------------- */
#boot-loader .boot-progress {
  position: absolute; left: 50%; bottom: clamp(1.6rem, 6vh, 3.2rem);
  transform: translateX(-50%);
  z-index: 30; pointer-events: none;
  display: flex; align-items: baseline; gap: 0.7em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.3em; text-transform: uppercase;
  color: rgba(247, 242, 234, 0.42);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.4s var(--ease);
}
#boot-loader .boot-progress__pct {
  min-width: 3.4ch; letter-spacing: 0.1em;
  color: var(--amber-hi);
}
#boot-loader .boot-progress.is-ready .boot-progress__label { color: var(--amber-hi); }
#boot-loader.boot--lift .boot-progress { opacity: 0; }

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  #boot-loader .cs-stage { display: none; }
  #boot-loader .cs-loupe__ring { animation: none; }
  #boot-loader { transition: opacity 0.35s ease; }
  /* the sheet is hidden — center the % readout as the sole boot signal */
  #boot-loader .boot-progress { bottom: auto; top: 50%; transform: translate(-50%, -50%); }
}
