/* =====================================================================
   GDOH Provincial Referral Pathways Toolkit
   styles/organogram-ecc.css

   Extends styles/organogram.css with two additions:
     1. An immersive fleet.jpg background + premium glass / 3D cards for the
        district picker.  Everything here is scoped under `.og-overlay.has-fleet`,
        so when that class is absent the original picker styling is unchanged.
     2. A pan-and-zoom image viewer (`.ogi-*`) used for image-based organograms
        such as the Emergency Communication Centre (ECC).

   Loads AFTER organogram.css, so the design tokens declared there
   (--og-navy, --og-blue, --og-gold, --og-teal, --og-ease, --og-dur …)
   are available to this file.
   ===================================================================== */

:root {
  --ogi-ease: cubic-bezier(.22, .61, .36, 1);
  --ogi-dur:  380ms;
  --ogi-glass:       rgba(255, 255, 255, .10);
  --ogi-glass-line:  rgba(255, 255, 255, .28);
}

/* =====================================================================
   1 · IMMERSIVE FLEET BACKGROUND  (district picker)
   ===================================================================== */

/* Full-bleed fleet photograph behind the picker, held in place while the
   panel scrolls, with a dark gradient so all text stays legible. CSS-only. */
.og-overlay.has-fleet {
  background: transparent;                 /* the ::before layer replaces it */
}
.og-overlay.has-fleet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(4, 12, 26, .66), rgba(6, 16, 32, .74)),
    url("/assets/fleet.jpg") center / cover no-repeat fixed;
}

/* On coarse-pointer / small screens `background-attachment:fixed` is janky,
   so pin it normally there. */
@media (max-width: 720px), (hover: none) {
  .og-overlay.has-fleet::before {
    background-attachment: scroll, scroll;
  }
}

/* ---- Picker panel becomes a dark glass sheet over the photograph ---- */
.og-overlay.has-fleet .og-panel {
  background: linear-gradient(165deg, rgba(11, 30, 56, .72) 0%, rgba(6, 18, 38, .78) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .14),
    0 40px 100px rgba(2, 8, 20, .60),
    0 0 0 1px rgba(255, 255, 255, .10);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}
.og-overlay.has-fleet .og-panel h2      { color: #f4f8ff; }
.og-overlay.has-fleet .og-panel__sub    { color: #b9c8dc; }
.og-overlay.has-fleet .og-note {
  background: rgba(255, 255, 255, .07);
  color: #c4d2e4;
}
.og-overlay.has-fleet .og-x {
  color: #dbe6f4;
  background: rgba(255, 255, 255, .08);
}
.og-overlay.has-fleet .og-x:hover { background: rgba(255, 255, 255, .18); }

/* ---- Premium glass cards with a pointer-tracked 3D tilt ----
   The tilt angles (--tx / --ty) are set from JavaScript on pointer move and
   default to 0, so the cards are perfectly flat until hovered. */
.og-overlay.has-fleet .og-card {
  --tx: 0deg; --ty: 0deg;
  background: linear-gradient(160deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .06) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .30),
    inset 0 0 0 1px rgba(255, 255, 255, .16),
    0 10px 30px rgba(2, 8, 20, .40);
  backdrop-filter: blur(9px) saturate(1.1);
  -webkit-backdrop-filter: blur(9px) saturate(1.1);
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(var(--tx)) rotateY(var(--ty));
  transition:
    transform 120ms var(--ogi-ease),
    box-shadow var(--og-dur) var(--ogi-ease);
}
.og-overlay.has-fleet .og-card__name { color: #f4f8ff; }
.og-overlay.has-fleet .og-card__meta { color: #aebfd4; }
.og-overlay.has-fleet .og-card__go   { color: #7db4ff; }

.og-overlay.has-fleet .og-card:hover,
.og-overlay.has-fleet .og-card:focus-visible {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .40),
    inset 0 0 0 1px rgba(255, 255, 255, .30),
    0 22px 48px rgba(2, 8, 20, .55),
    0 0 30px rgba(70, 140, 240, .28);
}
/* the icon floats slightly forward for depth */
.og-overlay.has-fleet .og-card__icon { transform: translateZ(26px); }

/* ---- ECC card accent (teal → gold), distinct from the blue district cards - */
.og-overlay.has-fleet .og-card--ecc .og-card__icon {
  background: linear-gradient(160deg, var(--og-teal, #12a3a3), #0b7f8f);
  box-shadow: 0 6px 16px rgba(6, 90, 100, .40);
}
.og-overlay.has-fleet .og-card--ecc { grid-column: 1 / -1; }   /* full-width, sits below the districts */
.og-overlay.has-fleet .og-card--ecc:hover,
.og-overlay.has-fleet .og-card--ecc:focus-visible {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .40),
    inset 0 0 0 1px rgba(255, 255, 255, .30),
    0 22px 48px rgba(2, 8, 20, .55),
    0 0 30px rgba(20, 163, 163, .34);
}
.og-overlay.has-fleet .og-card--ecc .og-card__go { color: #4fd6d6; }

/* A slim "Provincial" tag on the ECC card */
.og-card__tag {
  align-self: flex-start;
  margin-top: 2px;
  padding: 3px 9px;
  border-radius: 999px;
  font: 700 10px/1 'Segoe UI', system-ui, sans-serif;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: #05202a;
  background: linear-gradient(160deg, var(--og-gold, #f2a900), #d99400);
}

@media (prefers-reduced-motion: reduce) {
  .og-overlay.has-fleet .og-card { transform: none !important; transition: box-shadow var(--og-dur) var(--ogi-ease); }
}

/* =====================================================================
   2 · IMAGE ORGANOGRAM VIEWER  (.ogi-*)
   A focused, dependency-free pan / zoom viewer for prepared PNG charts.
   ===================================================================== */
.ogi-viewer {
  position: fixed;
  inset: 0;
  z-index: 9350;                 /* above the tree viewer (9300) */
  display: flex;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(120% 120% at 50% 0%, rgba(6, 18, 38, .82) 0%, rgba(2, 8, 20, .94) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity var(--ogi-dur) var(--ogi-ease), visibility 0s linear var(--ogi-dur);
}
.ogi-viewer.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--ogi-dur) var(--ogi-ease), visibility 0s;
}

.ogi-shell {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transform: scale(.985);
  transition: transform var(--ogi-dur) var(--ogi-ease);
}
.ogi-viewer.is-open .ogi-shell { transform: scale(1); }
.ogi-shell:fullscreen { background: #0a1526; }

/* ---- Top bar (reuses .og-btn from organogram.css) ---- */
.ogi-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(9, 24, 46, .96), rgba(9, 24, 46, .80));
  border-bottom: 1px solid rgba(255, 255, 255, .10);
  flex-wrap: wrap;
}
.ogi-title { flex: 1; min-width: 120px; line-height: 1.25; }
.ogi-title b     { display: block; color: #f4f8ff; font: 700 15px/1.3 'Segoe UI', system-ui, sans-serif; }
.ogi-title span  { display: block; color: #9db0c8; font: 400 12px/1.3 'Segoe UI', system-ui, sans-serif; }
.ogi-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---- Stage: scroll container that the scaled image lives inside ---- */
.ogi-stage {
  position: relative;
  flex: 1;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: grab;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ogi-stage.is-panning { cursor: grabbing; }
.ogi-stage:focus-visible { outline: 2px solid var(--og-blue, #0b4da2); outline-offset: -2px; }

.ogi-img {
  transform-origin: 0 0;
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  background: #fff;
  opacity: 0;
  transition: opacity 420ms var(--ogi-ease);
}
.ogi-img.is-ready { opacity: 1; }

/* ---- Skeleton + spinner shown while the PNG streams in ---- */
.ogi-skel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  background: linear-gradient(90deg, rgba(255,255,255,.04) 0%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.04) 100%);
  background-size: 220% 100%;
  animation: ogi-shimmer 1.4s var(--ogi-ease) infinite;
}
.ogi-skel[hidden] { display: none; }
@keyframes ogi-shimmer { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }

.ogi-spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: #7db4ff;
  animation: ogi-spin .8s linear infinite;
}
@keyframes ogi-spin { to { transform: rotate(360deg); } }
.ogi-skel__label { color: #9db0c8; font: 500 12.5px/1 'Segoe UI', system-ui, sans-serif; }

.ogi-zoomlabel {
  position: absolute;
  right: 16px; bottom: 14px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(9, 24, 46, .85);
  color: #cfe0f4;
  font: 600 12px/1 'Segoe UI', system-ui, sans-serif;
  pointer-events: none;
}

/* ---- Error state ---- */
.ogi-error {
  position: absolute; inset: 0;
  display: grid; place-content: center; place-items: center; gap: 8px;
  text-align: center; padding: 24px;
  color: #dbe6f4;
}
.ogi-error b { font: 700 15px/1.3 'Segoe UI', system-ui, sans-serif; }
.ogi-error p { margin: 0; max-width: 340px; color: #9db0c8; font: 400 13px/1.5 'Segoe UI', system-ui, sans-serif; }

@media (max-width: 560px) {
  .ogi-tools .og-btn__label { display: none; }   /* icon-only toolbar on phones */
  .ogi-bar { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .ogi-viewer, .ogi-shell, .ogi-img { transition: none; }
  .ogi-skel, .ogi-spinner { animation: none; }
}
