/* The window follows libhm's SwiftUI layout (dark appearance): app/Sources/PhotoAtlas/ContentView.swift. */
:root {
  --fg: #f5f5f7;
  --muted: #98989d;
  --text-muted: #8c8c8c;
  --border: rgb(255 255 255 / 10%);
  --primary: #e5e5e5;
  --accent: #0a84ff;
  --glass: rgb(36 36 38 / 62%);
  --glass-edge: rgb(255 255 255 / 12%);
  --hover: rgb(255 255 255 / 8%);
  --sep: rgb(255 255 255 / 12%);
  --field: rgb(255 255 255 / 7%);
  --font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui,
    sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: #0e0e0f;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--fg);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: #5a5a5a;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
}

.icon {
  flex: none;
  width: 52px;
  height: 52px;
  margin: -4px;
}

.req {
  color: var(--text-muted);
  font-size: 12.5px;
  white-space: nowrap;
}

/* Stage */

.stage {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

.window {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #232325;
  box-shadow: 0 24px 60px rgb(0 0 0 / 45%);
  font-size: 13px;
  line-height: 1.3;
  user-select: none;
  -webkit-user-select: none;
}

.map,
.heat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map {
  z-index: 0;
  background: #232325;
}

.map .maplibregl-canvas {
  outline: none;
}

.heat {
  z-index: 1;
  pointer-events: none;
}

.lights {
  position: absolute;
  top: 17px;
  left: 20px;
  z-index: 20;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.lights i {
  width: 12px;
  height: 12px;
  border: 0.5px solid rgb(0 0 0 / 20%);
  border-radius: 50%;
  background: #ec6765;
}

.lights i:nth-child(2) {
  background: #ebc33f;
}

.lights i:nth-child(3) {
  background: #65c466;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
  box-shadow:
    0 8px 28px rgb(0 0 0 / 35%),
    inset 0 0 0 0.5px var(--glass-edge),
    inset 0 1px 0 rgb(255 255 255 / 6%);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  color: var(--fg);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn.secondary {
  color: var(--muted);
}

.icon-btn.small {
  width: 28px;
  height: 28px;
}

.icon-btn.small svg {
  width: 16px;
  height: 16px;
}

/* Floating panel */

.panel {
  position: absolute;
  top: 44px;
  bottom: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  width: 340px;
  flex-direction: column;
  border-radius: 24px;
}

.panel.collapsed {
  bottom: auto;
}

.panel.collapsed .brand,
.panel.collapsed .gallery-head,
.panel.collapsed .gallery {
  display: none;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.baseline {
  align-items: baseline;
}

.spacer {
  flex: 1;
}

.brand {
  gap: 0;
}

.brand img {
  display: block;
  width: 58px;
  height: 25px;
}

.search {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--field);
  color: var(--muted);
}

.search svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.search input {
  all: unset;
  flex: 1;
  min-width: 0;
  color: var(--fg);
  font-size: 13px;
}

.search input::placeholder {
  color: var(--muted);
}

.search:focus-within {
  box-shadow: 0 0 0 3px rgb(10 132 255 / 45%);
}

.results {
  position: absolute;
  top: 42px;
  right: 0;
  left: 0;
  z-index: 5;
  padding: 5px;
  border-radius: 12px;
  background: rgb(40 40 42 / 94%);
}

.results button {
  display: block;
  width: 100%;
  padding: 6px 9px;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
}

.results button span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.results button:hover,
.results button[aria-selected="true"] {
  background: var(--accent);
}

.results button:hover span,
.results button[aria-selected="true"] span {
  color: rgb(255 255 255 / 75%);
}

.results .none {
  padding: 8px 9px;
  color: var(--muted);
}

#toggle-gallery {
  width: 24px;
  height: 28px;
  cursor: pointer;
}

#toggle-gallery svg {
  width: 19px;
  height: 19px;
}

.gallery-head {
  padding: 3px 16px 8px;
}

.gallery-head h2 {
  flex: 1;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.link {
  margin-top: 6px;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.link:hover,
.link.pressed {
  text-decoration: underline;
}

.gallery {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 14px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(
    transparent,
    #000 24px,
    #000 calc(100% - 24px),
    transparent
  );
  mask-image: linear-gradient(
    transparent,
    #000 24px,
    #000 calc(100% - 24px),
    transparent
  );
}

.gallery::-webkit-scrollbar {
  display: none;
}

.day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 2px;
}

.day b {
  font-size: 12px;
  font-weight: 600;
}

.day span {
  color: var(--muted);
  font-size: 11px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px 0 10px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background: rgb(255 255 255 / 6%);
  cursor: pointer;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  pointer-events: none;
}

.tile.selected::after {
  box-shadow: inset 0 0 0 2.5px var(--accent);
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tile.fresh {
  animation: appear 0.3s ease-out;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

.empty {
  padding: 40px 12px;
  color: var(--muted);
  text-align: center;
}

.empty b {
  display: block;
  margin-bottom: 4px;
  color: var(--fg);
  font-size: 15px;
}

/* Map controls */

.controls {
  position: absolute;
  top: 44px;
  right: 16px;
  z-index: 3;
  display: flex;
  width: 42px;
  flex-direction: column;
  gap: 10px;
}

.group {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 19px;
}

.group hr {
  margin: 0 9px;
  border: 0;
  border-top: 0.5px solid var(--sep);
}

.ctl {
  width: 42px;
  height: 40px;
  cursor: pointer;
}

.ctl:hover,
.ctl.pressed {
  background: var(--hover);
}

.ctl:focus-visible,
.vb:focus-visible,
.link:focus-visible,
#toggle-gallery:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 10px;
}

.menu {
  position: absolute;
  top: 44px;
  right: 68px;
  z-index: 6;
  width: 140px;
  padding: 5px;
  border-radius: 12px;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 24px;
  padding: 0 8px 0 4px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.menu button svg {
  width: 15px;
  height: 15px;
  visibility: hidden;
}

.menu button[aria-checked="true"] svg {
  visibility: visible;
}

.menu button:hover,
.menu button:focus-visible {
  outline: none;
  background: var(--accent);
}

.legend {
  position: absolute;
  right: 16px;
  bottom: 22px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 20px;
  font-size: 10px;
}

.legend[hidden] {
  display: none;
}

.legend i {
  width: 66px;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    rgb(156 82 227),
    cyan,
    rgb(255 230 122),
    rgb(250 138 194)
  );
}

/* Viewer (PhotoViewer.swift) */

.viewer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  animation: viewer-in 0.2s ease;
}

.viewer[hidden] {
  display: none;
}

@keyframes viewer-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
}

.viewer-bar {
  display: flex;
  height: 52px;
  margin-top: 36px;
  padding: 0 12px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.viewer-bar .group {
  flex: none;
  flex-direction: row;
  align-items: center;
  overflow: visible;
  padding: 0 5px;
  border-radius: 18px;
}

.vb {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
}

.vb:hover,
.vb.pressed {
  background: var(--hover);
}

.vb.fav {
  width: 30px;
  cursor: default;
}

.vb.fav:hover {
  background: none;
}

.zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  color: var(--muted);
}

.zoom svg {
  width: 15px;
  height: 15px;
}

.zoom input {
  width: 82px;
  accent-color: var(--accent);
}

.title-block {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
}

.title-block strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-block span {
  color: var(--muted);
  font-size: 11px;
}

.viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: zoom-in;
}

.viewer-stage.zoomed {
  cursor: grab;
}

.photo {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  max-width: none;
  border-radius: 2px;
  transition:
    transform 0.2s ease,
    opacity 0.15s;
  will-change: transform;
}

.photo.instant {
  transition: opacity 0.15s;
}

.photo.loading {
  opacity: 0;
}

.info {
  position: absolute;
  top: 94px;
  right: 14px;
  z-index: 2;
  display: grid;
  width: 270px;
  margin: 0;
  padding: 14px 16px;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
}

.info[hidden] {
  display: none;
}

.info dt {
  color: var(--muted);
  text-align: right;
}

.info dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Demo cursor */

.cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 60%));
}

.cursor::after {
  content: "";
  position: absolute;
  top: -10px;
  left: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgb(255 255 255 / 40%);
  opacity: 0;
}

.cursor.click::after {
  animation: ripple 0.4s ease-out;
}

@keyframes ripple {
  from {
    opacity: 1;
    transform: scale(0.4);
  }
  to {
    opacity: 0;
    transform: scale(1.5);
  }
}

/* Phones: the same window, narrower panel. */
@media (max-width: 720px) {
  .icon {
    width: 44px;
    height: 44px;
  }

  .window {
    border-radius: 18px;
  }

  .lights {
    top: 14px;
    left: 16px;
  }

  /* The floating panel becomes a bottom sheet so the map stays visible. */
  .panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: 48%;
    border-radius: 18px;
  }

  .panel-head {
    padding: 10px 10px 8px;
  }

  .brand,
  #toggle-gallery {
    display: none;
  }

  .gallery-head {
    padding: 0 12px 4px;
  }

  .gallery-head .link {
    margin-top: 2px;
  }

  .gallery {
    padding: 0 8px 10px;
  }

  .tiles {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
  }

  .controls,
  .menu {
    top: 38px;
    right: 8px;
  }

  .menu {
    right: 58px;
  }

  .legend {
    top: 40px;
    right: auto;
    bottom: auto;
    left: 10px;
  }

  .legend span {
    display: none;
  }

  .viewer-bar {
    margin-top: 30px;
    padding: 0 8px;
  }

  .zoom {
    display: none;
  }

  .info {
    right: 8px;
    left: 8px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewer,
  .tile.fresh {
    animation: none;
  }

  .photo {
    transition: none;
  }
}

@media (max-width: 820px) {
  .stage {
    height: 600px;
  }
}
