@font-face {
  font-family: Geologica;
  src: url('./assets/geologica.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  font-family: Geologica, system-ui, sans-serif;
  color: #f6f1e8;
  background: #192d29;
  color-scheme: dark;
  --shell: #192d29;
  --paper: #f5f1e9;
  --ink: #203730;
  --edge: #d7dace;
  --accent: #2d5046;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
button, summary { font: inherit; cursor: pointer; }
button:focus-visible, summary:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid #cb9e48; outline-offset: 3px; }

.masthead {
  display: flex;
  flex: none;
  align-items: center;
  gap: 22px;
  min-height: 70px;
  padding: max(10px, env(safe-area-inset-top)) max(23px, env(safe-area-inset-right)) 10px max(23px, env(safe-area-inset-left));
  position: relative;
  z-index: 2;
}
.wordmark { width: 154px; height: auto; flex: none; }
h1 { margin: 0; padding-left: 22px; border-left: 1px solid #73877b; color: #e5e9df; font-size: 14px; font-weight: 430; white-space: nowrap; }
.help { margin-left: auto; position: relative; }
.help summary { display: flex; align-items: center; gap: 8px; color: #e5e9df; list-style: none; border-radius: 10px; padding: 8px 9px; font-size: 12px; }
.help summary::-webkit-details-marker { display: none; }
.help summary:hover, .help[open] summary { background: #30473e; }
.help summary span:first-child { border: 1px solid #a9b6aa; display: grid; place-items: center; border-radius: 50%; width: 19px; height: 19px; }
.help-panel {
  width: min(330px, calc(100vw - 30px));
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  border-radius: 11px;
  padding: 10px 17px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 8px 30px #10211b35;
  font-size: 12px;
  line-height: 1.6;
}
.help-panel p { margin: 7px 0; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 0 max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  gap: 8px;
}
.viewport { min-height: 0; position: relative; overflow: hidden; border-radius: 12px; background: #b2c5bd; }
#canvas-host, .loading, .fallback { position: absolute; inset: 0; }
#canvas-host canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#canvas-host canvas:active { cursor: grabbing; }
#canvas-host canvas:focus-visible { outline-offset: -4px; }
.imagery-credit { position: absolute; right: 6px; bottom: 6px; max-width: calc(100% - 12px); padding: 4px 7px; color: #fffdf7; background: #192d29d9; font-size: 9px; border-radius: 4px; }

.cover { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 54% 56%; }
.loading { background: #73968a; }
.loading::after { position: absolute; inset: 0; content: ''; background: linear-gradient(0deg, #12241eaa, transparent 48%); pointer-events: none; }
.loading-status {
  position: absolute;
  inset: auto auto clamp(13px, 4vw, 44px) clamp(13px, 4vw, 44px);
  display: flex;
  gap: 13px;
  align-items: center;
  max-width: calc(100% - 26px);
  padding: 15px 19px;
  background: #192d29f2;
  border: 1px solid #ffffff3d;
  border-radius: 12px;
  z-index: 1;
}
.loading-status strong { display: block; font-weight: 520; font-size: 15px; }
#progress-label { display: block; margin: 4px 0 7px; color: #d3e1d6; font-size: 11px; }
progress { display: block; width: min(180px, 46vw); height: 4px; border: none; accent-color: #e0c386; }
.loading-wheel { flex: none; width: 23px; height: 23px; border: 2px solid #7e9286; border-top-color: #e0c386; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-dock { display: flex; align-items: center; gap: 13px; padding: 8px 10px; background: var(--paper); color: var(--ink); border-radius: 11px; }
.views { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.view-dock button { min-height: 44px; padding: 7px 12px; display: flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--edge); border-radius: 7px; background: transparent; color: var(--ink); font-size: 12px; font-weight: 490; line-height: 1.2; }
.view-dock button svg { flex: none; }
.view-dock button:hover { background: #e2e8dc; }
.view-dock button[aria-pressed='true'] { color: #fffdf7; border-color: var(--accent); background: var(--accent); }
.view-dock .reset { margin-left: auto; border-color: transparent; white-space: nowrap; }

.fallback { display: flex; flex-direction: column; padding: 10px; background: var(--paper); color: var(--ink); }
.fallback-content { display: grid; place-items: center; flex: 1; min-height: 0; background: #dae2d5; overflow: hidden; border-radius: 7px; }
.fallback-content img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.fallback p { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px 16px; margin: 0; padding: 13px 4px 3px; font-size: 12px; }
.fallback a { color: #254d40; margin-left: auto; }

@media (max-width: 790px) {
  .masthead { min-height: 55px; padding-inline: 12px; gap: 12px; }
  .wordmark { width: 126px; }
  h1 { font-size: 12px; padding-left: 12px; }
  .help-label { display: none; }
  .help summary { padding: 9px; min-height: 44px; }
  .layout { padding-inline: max(7px, env(safe-area-inset-left)) max(7px, env(safe-area-inset-right)); padding-bottom: max(7px, env(safe-area-inset-bottom)); }
  .viewport { border-radius: 9px; }
  .view-dock { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; padding: 6px; }
  .views { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-dock button { font-size: 11.5px; justify-content: flex-start; padding-inline: 8px; gap: 6px; }
  .view-dock .reset { justify-self: center; margin: 0; }
  .fallback a { margin-left: 0; }
}

@media (max-width: 790px) and (min-aspect-ratio: 5/4) {
  .views { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .view-dock { grid-template-columns: minmax(0, 1fr) auto; }
  .view-dock button { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-wheel { animation: none; }
}
