/* Geology Explorer — globe view styles (ported from geo-explorer, re-tinted to
 * the amber "rock strata" theme). Reuses the existing .floating-panel /
 * .panel-header / .action-btn / topbar styles from style.css. */

#scene-canvas { cursor: grab; }
#scene-canvas:active { cursor: grabbing; }

/* The base loading overlay fades out once the earth texture is ready. */
.loading { transition: opacity .45s ease; }
.loading.texture-loaded { opacity: 0; pointer-events: none; }

/* ===== Hover tip (globe pointer pick) ===== */
.hover-tip {
  position: absolute;
  background: rgba(20, 16, 10, 0.94);
  border: 1px solid rgba(217, 164, 65, 0.4);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  pointer-events: none;
  z-index: 7;
  transform: translate(-50%, calc(-100% - 12px));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.hover-tip[hidden] { display: none; }
.tip-name { font-weight: 600; color: var(--ink); }
.tip-sub { font-size: 10.5px; color: var(--ink-dim); margin-top: 2px; }

/* ===== Town / city labels (GeoNames overlay) ===== */
.city-labels {
  position: absolute; inset: 0; overflow: hidden;
  pointer-events: none; z-index: 6;
}
.city-labels[hidden] { display: none; }
.city-label {
  position: absolute; top: 0; left: 0; will-change: transform;
  white-space: nowrap; pointer-events: none;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #eaf4ff; letter-spacing: .2px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 3px rgba(0,0,0,0.8);
}
.city-label.is-capital { color: #ffe39a; font-weight: 700; font-size: 12px; }

/* ===== Overlay checkboxes ===== */
.ov-check {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 2px; cursor: pointer; font-size: 12.5px; color: var(--ink);
}
.ov-check:hover { color: #fff; }
.ov-check input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--accent); border-radius: 3px;
  background: rgba(0, 0, 0, 0.3); cursor: pointer;
  position: relative; flex-shrink: 0;
}
.ov-check input[type=checkbox]:checked { background: var(--accent); }
.ov-check input[type=checkbox]:checked::after {
  content: ''; position: absolute; left: 3px; top: 0;
  width: 4px; height: 8px;
  border: solid var(--accent-ink); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.ov-check em { font-style: normal; color: var(--ink-dim); font-size: 11px; }

/* ===== Live attribution footer (active overlay licences) ===== */
.overlay-attrib { margin: 6px 10px 10px; }
.overlay-attrib:empty { display: none; }
.attrib-line { font-size: 10px; line-height: 1.4; color: var(--ink-dim); }

/* ===== Fact / info card (clicked globe point) ===== */
.info-empty { padding: 12px; font-size: 12.5px; color: var(--ink-dim); text-align: center; font-style: italic; }
.fc-head {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--panel-border);
}
.fc-thumb {
  width: 96px; height: 96px; object-fit: cover; background: #fff;
  border-radius: 6px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.fc-thumb.no-img {
  display: flex; align-items: center; justify-content: center; font-size: 42px;
  background: rgba(0, 0, 0, 0.25); border: 1px dashed var(--panel-border);
}
.fc-thumb-btn {
  position: relative; padding: 0; border: none; background: none; cursor: zoom-in;
  border-radius: 6px; flex-shrink: 0; line-height: 0;
}
.fc-thumb-btn .fc-thumb { display: block; }
.fc-thumb-btn:hover .fc-thumb { box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,.4); }
.fc-thumb-zoom {
  position: absolute; right: 4px; bottom: 4px; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  color: #fff; background: rgba(0,0,0,.6); border-radius: 5px; pointer-events: none;
}

/* ===== Image lightbox (js/lightbox.js) ===== */
.lightbox-backdrop {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center;
  justify-content: center; padding: 4vh 4vw; background: rgba(2, 3, 12, 0.88);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.lightbox-backdrop[hidden] { display: none; }
.lightbox-frame {
  position: relative; display: flex; flex-direction: column; max-width: 100%;
  max-height: 100%; gap: 10px;
}
.lightbox-img {
  max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 8px;
  background: #111; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
}
.lightbox-caption {
  display: flex; flex-direction: column; gap: 3px; max-width: 92vw;
  color: var(--ink); font-size: 13px; line-height: 1.5;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 9px 12px;
}
.lightbox-caption .lb-title { font-weight: 700; font-size: 14px; }
.lightbox-caption .lb-desc { color: var(--ink); }
.lightbox-caption .lb-attrib { color: var(--ink-dim); font-size: 11.5px; }
.lightbox-caption a { color: var(--accent); text-decoration: none; }
.lightbox-caption a:hover { text-decoration: underline; }
.lightbox-close {
  position: absolute; top: -6px; right: -6px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 22px; line-height: 1; color: #fff; background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--panel-border); border-radius: 50%; z-index: 1;
}
.lightbox-close:hover { background: var(--accent); color: var(--accent-ink); }
.fc-head-text { flex: 1; min-width: 0; }
.fc-name { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.fc-sub { font-size: 11.5px; color: var(--ink-dim); }
.fc-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--ink-dim); margin: 12px 0 6px;
}
.fc-summary { font-size: 12.5px; line-height: 1.55; color: var(--ink); }
.fc-facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px;
  font-size: 12px; margin-top: 4px;
}
.fc-facts dt { color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.5px; font-size: 10.5px; padding-top: 1px; }
.fc-facts dd { color: var(--ink); margin: 0; overflow-wrap: anywhere; }
.fc-links { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.fc-link {
  background: transparent; border: 1px solid rgba(217, 164, 65, 0.45);
  color: var(--accent); border-radius: 5px; padding: 3px 9px; font-size: 11px; text-decoration: none;
}
.fc-link:hover { background: var(--row-hover); border-color: var(--accent); }
.fc-locate-btn {
  background: var(--row); border: 1px solid var(--accent); color: var(--accent);
  border-radius: 5px; padding: 4px 10px; font-size: 11px; cursor: pointer; margin-top: 4px;
}
.fc-locate-btn:hover { background: var(--row-hover); }
.fc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.fc-chip {
  background: var(--row); border: 1px solid rgba(217, 164, 65, 0.45);
  color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 11px;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.fc-chip:hover { background: var(--row-hover); border-color: var(--accent); }

/* ===== Custom tooltips (replaces native title tooltips) ===== */
.ui-tip {
  position: fixed; z-index: 2147483600; pointer-events: none;
  max-width: 240px; white-space: normal; overflow-wrap: break-word; word-break: break-word;
  background: rgba(20, 16, 10, 0.97); color: var(--ink);
  border: 1px solid var(--panel-border); border-radius: 7px; padding: 6px 10px;
  font: 500 11.5px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: .1px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.ui-tip[hidden] { display: none; }

/* ===== Geology overlay: Macrostrat CC-BY attribution ===== */
.attrib-line a { color: var(--ink-dim); text-decoration: none; }
.attrib-line a:hover { color: var(--accent); text-decoration: underline; }

/* ===== Independent panel: legend ===== */
/* The legend docks at the TOP-LEFT by default. It is deliberately excluded from
   the right-edge horizontal auto-layout in js/panes.js (H_PANE_IDS), so this
   anchor is authoritative — overlays/info/minerals pack along the right while the
   legend sits on its own at the left. */
.legend-panel {
  top: 14px; left: 14px; right: auto;
  width: auto; max-width: calc(100vw - 28px);
}
/* Tile the legend's sections into horizontal columns: the body is a height-
   bounded flex column that wraps, so sections stack vertically until they hit
   the height cap and then start a new column. Opening bedrock age + mines +
   critmin together fans them out side by side instead of one very tall list;
   the panel width auto-grows to fit the columns. */
.legend-panel #legend-body {
  display: flex; flex-flow: column wrap; align-content: flex-start;
  max-height: calc(100vh - 96px);
  gap: 0 16px; overflow-x: auto; overflow-y: hidden;
}
.legend-panel .lg-section { width: 196px; box-sizing: border-box; }
/* Single info pane (globe-click facts + mineral details share it). Docked in
   the top-right column directly below the overlays panel; GeoOverlays measures
   that panel at runtime and drives --info-top so the two never overlap as the
   overlays panel grows/shrinks. The value here is the first-paint fallback used
   before the ResizeObserver fires. Width inherits the .floating-panel default
   so it matches the overlays panel. */
.info-panel {
  top: var(--info-top, 275px); right: 14px; left: auto; bottom: auto;
  max-height: calc(100% - var(--info-top, 275px) - 14px);
}
@media (max-width: 760px) {
  .legend-panel { left: 14px; right: 14px; width: auto; }
  .info-panel { left: 14px; right: 14px; }
}

/* ===== Map legend (#legend-body) ===== */
.lg-section { margin-bottom: 10px; }
.lg-section:last-child { margin-bottom: 0; }
.lg-sec-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--ink-dim); margin-bottom: 6px;
}
.lg-row { display: flex; align-items: center; gap: 9px; padding: 2px 0; font-size: 12.5px; color: var(--ink); }
.lg-swatch { flex: 0 0 auto; }
.lg-swatch-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
.lg-swatch-box { width: 14px; height: 11px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3); }
.lg-swatch-line { width: 16px; height: 3px; border-radius: 2px; }
.lg-swatch-tri { width: 0; height: 0; background: none !important; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 11px solid #888; filter: drop-shadow(0 0 0.5px rgba(0,0,0,0.5)); }
.lg-swatch-diamond { width: 10px; height: 10px; transform: rotate(45deg); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3); }
.lg-label { min-width: 0; flex: 1 1 auto; }
.lg-cap { text-transform: capitalize; }
.lg-ma { flex: 0 0 auto; font-size: 11px; opacity: 0.6; font-variant-numeric: tabular-nums; }
/* Clickable age rows drive the shared deep-time selection (markers + geology). */
.lg-row-btn { width: 100%; text-align: left; background: none; border: 0; cursor: pointer; border-radius: 4px; font: inherit; }
.lg-row-btn:hover { background: rgba(255,255,255,0.06); }
.lg-row-btn.sel { background: rgba(120,170,255,0.18); box-shadow: inset 0 0 0 1px rgba(120,170,255,0.5); }
/* Bedrock unit colour chip in the info card head. */
.fc-geo-swatch { display: inline-block; width: 22px; height: 22px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35); }
.fc-geo-comments { opacity: 0.75; font-size: 12px; }
.fc-geo-ref { margin-top: 8px; font-size: 11px; opacity: 0.6; }
.lg-note { margin-top: 6px; font-size: 11px; line-height: 1.35; opacity: 0.6; }
/* "Show all" reset button atop a filterable legend section. */
.lg-showall {
  display: block; width: 100%; margin-bottom: 6px; padding: 4px 8px;
  font: inherit; font-size: 11.5px; text-align: center; cursor: pointer;
  color: var(--ink); background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 5px;
}
.lg-showall:hover { background: rgba(255,255,255,0.1); }

/* ===== Measuring tool ===== */
.measure-panel {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: rgba(15, 18, 30, 0.94); border: 1px solid rgba(53,224,255,0.4);
  border-radius: 10px; padding: 10px 12px; z-index: 9;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); max-width: 92vw;
}
.measure-panel[hidden] { display: none; }
.measure-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.measure-seg { display: inline-flex; border: 1px solid #2c3550; border-radius: 7px; overflow: hidden; }
.measure-seg button {
  background: #161c2c; color: #9fb3d0; border: none; padding: 6px 12px;
  font: 600 12px/1 inherit; cursor: pointer;
}
.measure-seg button + button { border-left: 1px solid #2c3550; }
.measure-seg button:hover { background: #1d2740; color: #cfe0f5; }
.measure-seg button.on { background: #0e3a4a; color: #6fe9ff; }
.measure-units button { padding: 6px 14px; }
.measure-clear {
  background: #2a1622; color: #ff9bbd; border: 1px solid #5a2740; border-radius: 7px;
  padding: 6px 12px; font: 600 12px/1 inherit; cursor: pointer; margin-left: auto;
}
.measure-clear:hover { background: #3a1d2e; color: #ffc0d6; }
.measure-readout { margin-top: 8px; font-size: 12px; color: #bcd0ea; text-align: center; min-height: 14px; }

.measure-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 8; }
.measure-labels[hidden] { display: none; }
.measure-label {
  position: absolute; top: 0; left: 0; will-change: transform; white-space: nowrap; pointer-events: none;
  padding: 3px 8px; border-radius: 999px; background: rgba(8,16,26,0.9);
  border: 1px solid rgba(53,224,255,0.55); color: #d8f4ff;
  font: 700 12px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8); box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.measure-hover { border-color: rgba(255,210,77,0.7); color: #ffe7ad; }
.measure-close { margin-left: 6px; align-self: center; font-size: 18px; color: #9fb0c8; }
.measure-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
