/* The connection lens: luminous teal glass and progressively disclosed controls. */

/* Unfold left from the fixed pause emblem as the sketch opens right. */
.app-shell .topbar .header-help {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(12px) scaleX(.35);
  transform-origin: right center;
  transition: opacity .28s ease, transform .65s cubic-bezier(.22,1,.36,1), visibility 0s .65s;
}
.app-shell.is-brand-expanded .topbar .header-help {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity .38s .09s ease, transform .65s cubic-bezier(.22,1,.36,1), visibility 0s;
}

/* Connection paths belong beneath the title diffusion and navigation. */
.app-shell[data-mode="coincidence"] :is(.map,.leaflet-container) {
  background:
    radial-gradient(ellipse at 38% 12%,rgba(142,239,207,.13),transparent 52%),
    radial-gradient(ellipse at 78% 62%,rgba(106,225,190,.1),transparent 48%),
    linear-gradient(155deg,#258c76,#197c64 48%,#12644f);
}
.app-shell[data-mode="coincidence"] .map::after {
  inset: 0; opacity: .6;
  background: radial-gradient(ellipse at 44% 70%,rgba(167,255,222,.08),transparent 40%),radial-gradient(ellipse at 24% 25%,rgba(135,241,203,.1),transparent 45%);
}
.app-shell[data-mode="coincidence"] :is(.leaflet-tile-pane,.mapboxgl-canvas) { opacity: .12; }
.app-shell[data-mode="coincidence"][data-view="world"] .leaflet-tile-pane { opacity: 0; visibility: hidden; }
.app-shell[data-mode="coincidence"] .coincidence-country-outline {
  fill: #075e4e !important; fill-opacity: .82 !important;
  stroke: rgba(173,238,213,.28) !important; stroke-width: .35px !important; filter: none;
}
.app-shell .coincidence-outline-pane > svg { overflow: visible; }
.app-shell .coincidence-links { z-index: 60; }
.app-shell[data-mode="coincidence"] .map-grid { opacity: .22; }
.app-shell[data-mode="coincidence"] .coincidence-links line { stroke: rgba(199,229,208,.46); stroke-width: .75; }
.app-shell[data-mode="coincidence"] .coincidence-links circle { fill: #c2dfcc; filter: none; }
.app-shell[data-mode="coincidence"] .coincidence-pixel { box-shadow: 0 0 12px #b3ffe23d, 0 2px 7px #003c302e, inset 0 1px 0 #effff4b3; }
.app-shell[data-mode="coincidence"] .coincidence-pixel:is(:hover,.is-selected) { box-shadow: 0 0 0 2px #c5e6d075, 0 4px 18px #001b1140; }

/* Keep invisible aggregate blocks in flow, so the title never drops on entry. */
.app-shell:has(:is(#coincidence-controls,#coincidence-unlock,#coincidence-card):not([hidden])) #overall-pixel > :is(.overall-pixel-core,.overall-pixel-copy,.network-goal) {
  display: block; visibility: hidden; pointer-events: none;
}
.app-shell[data-mode="coincidence"] #overall-pixel .map-title-line { color: #f4fff8; text-shadow: 0 0 14px #d4ffea40, 0 1px 2px #07433366; }
.app-shell[data-mode="coincidence"] #overall-pixel .map-title #map-subtitle { color: #c8dbcf; }
.app-shell[data-mode="coincidence"] #title-atmosphere { display: none; }
.app-shell.is-reveal-title:has(#coincidence-unlock:not([hidden])) #title-atmosphere { visibility: visible; }

/* A single pale glass material for the introduction, filters and reading card. */
.app-shell :is(#coincidence-controls,#coincidence-unlock) {
  top: var(--coincidence-top,104px); right: var(--coincidence-right,82px); bottom: auto; left: auto;
  width: min(416px,calc(100vw - 100px)); max-height: var(--coincidence-limit,calc(100dvh - 320px));
  padding: 18px; border: 1px solid rgba(232,248,237,.8); border-radius: 26px;
  color: #1e5042; background: linear-gradient(145deg,rgba(225,250,237,.94),rgba(165,221,199,.91));
  -webkit-backdrop-filter: blur(26px) saturate(1.08); backdrop-filter: blur(26px) saturate(1.08);
  box-shadow: inset 0 1px 0 #f4fff6, 0 0 24px #b3ffe215, 0 12px 32px #00463120;
  overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #9ab5a3 transparent;
}
.app-shell #coincidence-controls {
  transform: translateX(10px) scale(.982); transform-origin: 100% 50%;
  transition: opacity .5s ease, transform .8s cubic-bezier(.2,.7,.2,1);
}
.app-shell #coincidence-controls.is-visible { transform: none; }
.app-shell #coincidence-controls .coincidence-compact-bar { display: none; }
.app-shell #coincidence-controls .coincidence-panel-body {
  display: grid; grid-template-rows: 1fr; opacity: 1;
  transition: grid-template-rows .42s cubic-bezier(.2,.7,.2,1), opacity .3s ease, margin .42s ease;
}
.app-shell #coincidence-controls .coincidence-panel-content { min-height: 0; overflow: hidden; }
.app-shell:has(#coincidence-card:not([hidden])) #coincidence-controls { opacity: 0; visibility: hidden; pointer-events: none; }
.app-shell #coincidence-controls .coincidence-controls-head { gap: 14px; align-items: center; }
.app-shell #coincidence-controls .coincidence-controls-head span { margin-bottom: 6px; font: 500 10px/1.4 var(--sans); letter-spacing: .1em; color: #617c69; }
.app-shell #coincidence-controls .coincidence-controls-head strong { color: #2c4835; font: 550 21px/1.2 var(--sans); letter-spacing: -.025em; }
.app-shell #coincidence-controls .coincidence-controls-head button {
  min-height: 40px; max-width: none; flex: none; padding: 8px 11px; border-radius: 20px;
  font: 500 13px/1.35 var(--sans); color: #3e624a; background: #ffffff70;
}
.app-shell #coincidence-controls .coincidence-filter-description {
  min-height: 42px; margin: 14px 0 0; color: #566e5f; font: 400 14px/1.45 var(--sans);
}
.app-shell #coincidence-controls .coincidence-filters {
  grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: repeat(2,minmax(94px,auto)); gap: 10px; margin: 14px 0;
}
.app-shell #coincidence-controls .coincidence-filters button:not([data-coincidence-filter="ALL"]) {
  --lens-color: #63a5be;
  min-width: 0; min-height: 94px; padding: 12px 13px;
  grid-template-columns: 1fr auto; align-content: center; gap: 6px;
  border: 1px solid color-mix(in srgb,var(--lens-color) 32%,#dce7df);
  border-radius: 17px; background: linear-gradient(145deg,#f2fff4a8,color-mix(in srgb,var(--lens-color) 12%,#d7f0e3));
  box-shadow: inset 0 1px 0 #fff; color: #35553f;
  transition: background .4s ease, border-color .4s ease, box-shadow .4s ease;
}
.app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="SY"] { --lens-color: #81b4a8; }
.app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="PR"] { --lens-color: #a6bd85; }
.app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="SE"] { --lens-color: #668272; }
.app-shell #coincidence-controls .coincidence-filters button:not([data-coincidence-filter="ALL"]):is(:hover,:focus-visible,.is-active) {
  border-color: var(--lens-color); background: color-mix(in srgb,var(--lens-color) 14%,#f7faf7);
  box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--lens-color) 20%,transparent), 0 3px 12px #24493209;
}
.app-shell #coincidence-controls .coincidence-filters button :is(b,span) { color: #34523e; font: 500 12px/1.2 var(--sans); }
.app-shell #coincidence-controls .coincidence-filters button > span { color: #718879; }
.app-shell #coincidence-controls .coincidence-filters button small {
  grid-column: 1 / -1; overflow: visible; white-space: normal; overflow-wrap: anywhere;
  font: 500 14px/1.3 var(--sans); color: #34523e; letter-spacing: -.015em;
}
.app-shell #coincidence-controls .coincidence-filters button i {
  grid-row: 3; height: 2px; margin-top: 2px; opacity: .6;
  background: linear-gradient(90deg,var(--lens-color) var(--meter,0%),#cbd9ce var(--meter,0%));
}
.app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="ALL"] {
  display: grid; place-content: center; width: 52px; min-width: 52px; max-width: 52px; height: 52px; min-height: 52px;
  padding: 7px; gap: 2px; grid-template-columns: 1fr; border-radius: 50%;
  background: #d4f1df; border: 1px solid #7cb79b; box-shadow: 0 0 0 5px #bfe5d2, inset 0 1px 0 #f7fff9;
}
.app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="ALL"].is-active { background: #b3e4c7; border-color: #5e9d7c; }
.app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="ALL"] i { display: none; }
.app-shell #coincidence-controls .coincidence-controls-foot { gap: 10px; align-items: center; }
.app-shell #coincidence-controls .coincidence-controls-foot > span { font: 400 13px/1.4 var(--sans); color: #607867; }
.app-shell #coincidence-controls .coincidence-controls-foot button { padding: 10px 13px; min-height: 42px; font: 500 13px/1.3 var(--sans); color: #3d6649; }
.app-shell #coincidence-unlock h2 { margin-bottom: 8px; color: #2d4836; font: 550 26px/1.2 var(--sans); letter-spacing: -.025em; }
.app-shell #coincidence-unlock :is(p,li) { color: #4c6856; font-size: 15px; line-height: 1.5; }
.app-shell #coincidence-unlock .coincidence-eyebrow { font-size: 10px; letter-spacing: .09em; }
.app-shell #coincidence-unlock .coincidence-credit { font-size: 13px; }
.app-shell #coincidence-unlock > small { color: #6b8172; font: 400 12px/1.45 var(--sans); }

.app-shell #coincidence-card {
  max-height: var(--coincidence-card-limit,calc(100dvh - 320px));
  border: 1px solid #f4fff7c9; border-radius: 24px;
  color: #254c3c; background: linear-gradient(145deg,#e8faefed,#bee3ceeb);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  box-shadow: inset 0 1px 0 #fff, 0 16px 44px #00170b24;
  scrollbar-width: thin; scrollbar-color: #9ab5a3 transparent;
}
.app-shell #coincidence-card h2 { color: #2d4536; font: 550 24px/1.2 var(--sans); }
.app-shell #coincidence-card :is(.coincidence-meaning,.coincidence-story,.coincidence-match) { color: #425e4b; border-color: #aac1b34d; background: #ffffff42; }
.app-shell #coincidence-card :is(.coincidence-story p,.coincidence-match p) { font: 400 15px/1.5 var(--sans); }
.app-shell #coincidence-card .card-close { color: #466c52; }
.app-shell .zoom-controls #coincidence-mode-toggle {
  visibility: inherit;
  transition: background .45s ease, border-color .45s ease, box-shadow .45s ease;
}
.app-shell[data-mode="coincidence"] .zoom-controls #coincidence-mode-toggle { opacity: 1; visibility: visible; pointer-events: auto; border-color: #a8d9b6; background: #b6d9c0; }
.app-shell[data-mode="coincidence"] .zoom-controls {
  z-index: 960; background: #a2dfc872; border-color: #ddffedb3;
  box-shadow: inset 0 1px 0 #effff3, 0 0 18px #b9ffe21a, 0 5px 16px #064b3530;
}
.app-shell[data-mode="coincidence"] .zoom-controls #zoom-in { background: linear-gradient(145deg,#dcf9f2,#bee9e0); border-color: #a8d8c9; color: #276859; }
.app-shell[data-mode="coincidence"] .zoom-controls #zoom-out { background: linear-gradient(145deg,#eaf4df,#d2e8ce); border-color: #bed6b8; color: #617958; }
.app-shell[data-mode="coincidence"] .zoom-controls #coincidence-mode-toggle { background: #9ed8b9; border-color: #d6ffe6; }
.app-shell .zoom-controls #coincidence-mode-toggle[aria-expanded="true"] > span { opacity: 0; visibility: hidden; }
.app-shell.is-mode-transitioning[data-mode="coincidence"] .coincidence-sweep { animation: connectionLensSweep 1s cubic-bezier(.2,.7,.2,1) both; }
@keyframes connectionLensSweep {
  0% { opacity: 0; clip-path: circle(0 at var(--sweep-x,90%) var(--sweep-y,50%)); }
  25% { opacity: .48; }
  100% { opacity: 0; clip-path: circle(150vmax at var(--sweep-x,90%) var(--sweep-y,50%)); }
}
@media (max-width: 640px) {
  .app-shell :is(#coincidence-controls,#coincidence-unlock) {
    position: fixed; top: var(--coincidence-top,76px); right: auto; left: 12px; bottom: auto;
    width: min(280px,calc(100vw - 88px)); padding: 8px;
    max-height: var(--coincidence-limit,calc(100dvh - 320px)); border-radius: 23px;
  }
  .app-shell #coincidence-controls { transform: translateY(-8px) scale(.987); transform-origin: 50% 0; }
  .app-shell #coincidence-controls.is-visible { transform: none; }
  .app-shell #coincidence-controls .coincidence-controls-head strong { font-size: 20px; }
  .app-shell #coincidence-controls .coincidence-filters { margin-block: 12px; }
  .app-shell #coincidence-controls .coincidence-filter-description { margin-top: 10px; }
  .app-shell #coincidence-card { position: fixed; top: var(--coincidence-card-top,76px); left: 12px; right: 76px; bottom: auto; width: auto; }
  .app-shell #coincidence-controls .coincidence-compact-bar {
    position: sticky; top: -8px; z-index: 4; display: flex; align-items: center; gap: 4px;
    min-height: 44px; border-radius: 17px; background: #c4e8d7e6;
  }
  .app-shell #coincidence-panel-toggle {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px;
    padding: 5px 7px; border: 0; border-radius: 17px; background: transparent; color: #255744;
    text-align: left; cursor: pointer;
  }
  .app-shell #coincidence-controls .coincidence-compact-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
  .app-shell #coincidence-controls .coincidence-compact-copy b { font: 550 14px/1.2 var(--sans); letter-spacing: -.01em; }
  .app-shell #coincidence-controls .coincidence-compact-copy small { font: 450 11px/1.3 var(--sans); color: #4e7a65; }
  .app-shell #coincidence-panel-toggle > svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.2; transform: rotate(180deg); transition: transform .35s ease; }
  .app-shell #coincidence-controls[data-collapsed="true"] #coincidence-panel-toggle > svg { transform: none; }
  .app-shell #coincidence-controls .coincidence-mini-pixel { display: grid; grid-template-columns: repeat(2,7px); grid-template-rows: repeat(2,7px); gap: 2px; flex: none; }
  .app-shell #coincidence-controls .coincidence-mini-pixel i { border: 1px solid #497d60; border-radius: 1px; background: #f4fff3; }
  .app-shell #coincidence-controls .coincidence-mini-pixel i:nth-child(2),.app-shell #coincidence-controls .coincidence-mini-pixel i:nth-child(3) { background: #28523f; }
  .app-shell #coincidence-compact-exit { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; min-height: 40px; padding: 10px; border: 1px solid #a2ceb5; border-radius: 50%; background: #dcf6e680; color: #34644e; cursor: pointer; }
  .app-shell #coincidence-compact-exit svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.2; }
  .app-shell #coincidence-controls .coincidence-panel-body { margin-top: 8px; }
  .app-shell #coincidence-controls[data-collapsed="true"] .coincidence-panel-body { grid-template-rows: 0fr; opacity: 0; margin-top: 0; pointer-events: none; }
  .app-shell #coincidence-controls .coincidence-controls-head { display: none; }
  .app-shell #coincidence-controls .coincidence-panel-content { padding: 0 3px 3px; }
  .app-shell #coincidence-controls .coincidence-filter-description { min-height: 36px; margin: 2px 0 0; font-size: 13px; }
  .app-shell #coincidence-controls .coincidence-filters { grid-template-rows: minmax(76px,auto) minmax(84px,auto); gap: 8px; margin-block: 10px; }
  .app-shell #coincidence-controls .coincidence-filters button:not([data-coincidence-filter="ALL"]) { min-height: 76px; padding: 8px; }
  .app-shell #coincidence-controls .coincidence-filters button:is([data-coincidence-filter="PR"],[data-coincidence-filter="SE"]) { min-height: 84px; padding-top: 16px; padding-bottom: 6px; align-content: end; }
  .app-shell #coincidence-controls .coincidence-filters button[data-coincidence-filter="ALL"] { width: 44px; height: 44px; min-width: 44px; max-width: 44px; min-height: 44px; box-shadow: 0 0 0 4px #bfe5d2, inset 0 1px 0 #f7fff9; }
  .app-shell #coincidence-controls .coincidence-controls-foot { gap: 6px; }
  .app-shell #coincidence-controls .coincidence-controls-foot > span { font-size: 11px; }
  .app-shell #coincidence-controls .coincidence-controls-foot button { padding-inline: 8px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .app-shell.is-mode-transitioning .coincidence-sweep { animation: none; }
  .app-shell #coincidence-controls, .app-shell #coincidence-unlock { animation: none; transition: none; }
  .app-shell #coincidence-controls .coincidence-filters button, .app-shell .topbar .header-help, .app-shell .topbar #open-concept,
  .app-shell #coincidence-controls .coincidence-panel-body,.app-shell #coincidence-panel-toggle > svg { transition: none; }
}
/* Keep the complete filter/action panel visible on short phones. */
@media (max-width: 640px) and (max-height: 740px) {
  .app-shell #coincidence-unlock { padding: 15px; }
}
