/*
 * hyd-lakes.css - the Lakes window (#hyd-lakes).
 *
 * A standalone dialog built by hyd-lakes.js, using the same compact Finder frame as Places: title bar, toolbar
 * (lake picker and shuffle), a Leaflet map and a grid of memory cards. The --lake-* custom properties on the
 * dialog map the themed --paper-* and --desktop-* tokens (with fallbacks) so every rule reads one set of names.
 *
 * Phone widths (620 px and under) turn the dialog into the shared bottom sheet sized by --phone-sheet-*
 * (defined in hyd-world.css).
 */

/* Lakes uses the same compact Finder frame, type and themed surfaces as Places. */
#hyd-lakes {
  --lake-ink: var(--paper-text,#f5f3f6);
  --lake-muted: var(--paper-muted,#c8c4cd);
  --lake-edge: var(--desktop-rim,#77717b);
  --lake-surface: var(--paper-surface,#28262c);
  --lake-panel: var(--paper-panel,#353239);
  --lake-inset: var(--paper-inset,#1c1a20);
  width: min(1360px, calc(100vw - 40px));
  max-width: none;
  height: calc(100dvh - 68px);
  max-height: 960px;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--lake-edge);
  border-radius: 4px;
  background: var(--lake-surface);
  color: var(--lake-ink);
  box-shadow:
    2px 3px #0007,
    0 12px 38px #0005;
  font: 13px/1.4 var(--desktop-font,"Lucida Grande","Lucida Sans Unicode",Tahoma,Arial,sans-serif);
  color-scheme: dark;
}
#hyd-lakes::backdrop {
  background: #100d1645;
}
#hyd-lakes[open] {
  display: flex;
  flex-direction: column;
}
#hyd-lakes :is(button, select) {
  font: inherit;
  letter-spacing: 0;
  touch-action: manipulation;
}
#hyd-lakes button {
  cursor: pointer;
}
#hyd-lakes button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* !important so hidden parts stay hidden: display rules in this sheet would otherwise override the
   hidden attribute. */
#hyd-lakes [hidden] {
  display: none !important;
}
#hyd-lakes :is(button, select):focus-visible {
  outline: 2px solid var(--paper-accent,#b8c9e6);
  outline-offset: 3px;
}

/* Title bar: a metal strip with the lake icon and title, a small red close disc and an equal spacer
   that keeps the title centred. */
#hyd-lakes .lakes-titlebar {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 36px;
  padding: 2px 9px;
  border-bottom: 1px solid #888;
  background:
    repeating-linear-gradient(0deg, #ffffff0a 0 1px, #00000004 1px 2px),
    linear-gradient(#dedede, #bdbdbd);
  color: #222;
  box-shadow: inset 0 1px #fff8;
}
#hyd-lakes .lakes-titlebar h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  font: 700 13px/1.2 var(--desktop-font,Tahoma,sans-serif);
  letter-spacing: 0;
  color: inherit;
  background: none;
  text-shadow: 0 1px #fff7;
}
#hyd-lakes .lakes-titlebar h2 img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
#hyd-lakes .lakes-close {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at 40% 15%, #fff0e9, #de9a91 55%, #be706e);
  border: 1px solid #98635f;
  border-radius: 50%;
  box-shadow:
    inset 0 1px #fff8,
    0 1px #fff7;
  color: #5b3031;
  font:
    700 14px/1 Arial,
    sans-serif;
}
#hyd-lakes .lakes-title-spacer {
  width: 32px;
}

/* Toolbar: the lake picker and the shuffle button. */
#hyd-lakes .lakes-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: none;
  padding: 10px 12px;
  background: var(--lake-surface);
  border-bottom: 1px solid var(--lake-edge);
  color: var(--lake-ink);
}
#hyd-lakes .lakes-location {
  display: flex;
  align-items: center;
  flex: 1 1 250px;
  gap: 9px;
  min-width: 0;
  font-size: 12px;
  color: var(--lake-ink);
}
#hyd-lakes .lakes-location select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 4px 27px 4px 9px;
  border: 1px solid var(--lake-edge);
  border-radius: 3px;
  background: var(--lake-inset);
  color: var(--lake-ink);
  font-size: 12px;
  box-shadow: inset 1px 1px #0005;
}
#hyd-lakes .lakes-toolbar > button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid var(--lake-edge);
  border-radius: 3px;
  background: var(--lake-panel);
  color: var(--lake-ink);
  box-shadow: inset 0 1px #ffffff20;
  font-size: 12px;
  white-space: nowrap;
}
#hyd-lakes .lakes-toolbar > button:not(:disabled):hover {
  background: var(--lake-inset);
  border-color: var(--paper-accent,#b8c9e6);
}
#hyd-lakes .lakes-shuffle svg {
  display: block;
  flex: none;
  width: 22px;
  height: 22px;
}

/* Body: one scrolling column, map first and memory cards below. */
#hyd-lakes .lakes-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--lake-edge) var(--lake-inset);
}
#hyd-lakes .lakes-map-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-bottom: 1px solid var(--lake-edge);
}
#hyd-lakes .lakes-map-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  min-height: 29px;
  padding: 5px 12px;
  background: var(--lake-panel);
  border-bottom: 1px solid var(--lake-edge);
  color: var(--lake-muted);
  font-size: 11px;
}

/* The map height follows the viewport: 53 percent of the dynamic viewport height, clamped to 320-530 px. */
#hyd-lakes .lakes-map {
  width: 100%;
  height: clamp(320px, 53dvh, 530px);
  flex: none;
  background: #bbc4c3;
  color: #28313b;
  font-family: var(--desktop-font,Tahoma,sans-serif);
  isolation: isolate;
}
#hyd-lakes .lakes-map .leaflet-control-zoom a {
  background: var(--lake-panel);
  color: var(--lake-ink);
  border-color: var(--lake-edge);
}
#hyd-lakes .lakes-map-unavailable {
  display: grid;
  place-content: center;
  padding: 30px;
  text-align: center;
  background: var(--lake-inset);
  color: var(--lake-muted);
}

/* Memory cards: an auto-filling grid of photo thumbnails, each with name, caption and date. */
#hyd-lakes .lakes-memories {
  padding: 18px 18px 22px;
  background: var(--lake-surface);
}
#hyd-lakes .lakes-shelf-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
#hyd-lakes .lakes-shelf-heading h3 {
  margin: 0;
  color: var(--lake-ink);
  font: 700 14px/1.3 var(--desktop-font,Tahoma,sans-serif);
  letter-spacing: 0;
}
#hyd-lakes .lakes-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  align-content: start;
  gap: 22px 16px;
}
#hyd-lakes .lakes-card {
  min-width: 0;
  text-align: left;
}

/* Card thumbnail: a framed 4:3 photo with a small action badge in the corner. */
#hyd-lakes .lakes-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  min-height: 0;
  overflow: hidden;
  margin: 0 0 8px;
  padding: 4px;
  border: 1px solid var(--lake-edge);
  border-radius: 2px;
  background: var(--lake-inset);
  box-shadow: 1px 2px #0005;
  color: var(--lake-ink);
}
#hyd-lakes .lakes-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#hyd-lakes .lakes-card-action {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid #ffffff80;
  border-radius: 3px;
  background: #1c1a20d9;
  font:
    14px/1 Arial,
    sans-serif;
  color: #fff;
}
#hyd-lakes .lakes-thumb:hover {
  border-color: var(--paper-accent,#b8c9e6);
}

/* Card text: name, caption and date. */
#hyd-lakes .lakes-card-name {
  display: block;
  color: var(--lake-ink);
  font: 700 12px/1.4 var(--desktop-font,Tahoma,sans-serif);
  overflow-wrap: anywhere;
}
#hyd-lakes .lakes-card-caption {
  margin: 4px 0;
  color: var(--lake-muted);
  font: 12px/1.45 var(--desktop-font,Tahoma,sans-serif);
}
#hyd-lakes .lakes-card-date {
  display: block;
  min-height: 15px;
  color: var(--lake-muted);
  font: 11px/1.4 var(--desktop-font,Tahoma,sans-serif);
}
#hyd-lakes .lakes-empty {
  grid-column: 1/-1;
  padding: 25px 7px;
  color: var(--lake-muted);
  text-align: center;
  font-size: 12px;
}

/* Footer: the status line. */
#hyd-lakes .lakes-footer {
  display: flex;
  align-items: center;
  flex: none;
  gap: 12px;
  min-height: 28px;
  padding: 5px 12px;
  border-top: 1px solid var(--lake-edge);
  background: var(--lake-panel);
}
#hyd-lakes .lakes-status {
  min-width: 0;
  color: var(--lake-muted);
  font-size: 11px;
}

/* Map pins: a small photo print with a pointer triangle (::after) and a corner badge. */
#hyd-lakes .lakes-pin {
  background: none;
  border: 0;
}
#hyd-lakes .lakes-pin-art {
  position: relative;
  display: block;
  width: 58px;
  height: 48px;
  padding: 3px;
  border: 1px solid #68747e;
  border-radius: 3px;
  background: #e4e5e8;
  box-shadow: 0 2px 3px #0007;
}
#hyd-lakes .lakes-pin-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#hyd-lakes .lakes-pin-art i {
  position: absolute;
  right: 2px;
  bottom: 2px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: #24202cde;
  color: white;
  font:
    11px/1 Arial,
    sans-serif;
}
#hyd-lakes .lakes-pin-art::after {
  content: '';
  position: absolute;
  left: 23px;
  bottom: -7px;
  border: 4px solid transparent;
  border-top-color: #68747e;
  border-bottom: 0;
}

/* Phone: the dialog becomes a bottom sheet with a compact layout. */
@media (max-width: 620px) {
  /* Phone sheet (--phone-sheet-* in hyd-world.css); beats the short-screen height rule below. */
  html[data-theme] #hyd-lakes {
    position: fixed;
    inset: auto 8px var(--phone-sheet-bottom) 8px;
    margin: 0;
    width: auto;
    height: var(--phone-sheet-height);
    max-height: none;
  }
  #hyd-lakes .lakes-titlebar {
    min-height: 40px;
    padding-inline: 8px;
  }
  #hyd-lakes .lakes-titlebar h2 {
    font-size: 12px;
  }
  #hyd-lakes .lakes-close {
    width: 25px;
    height: 25px;
  }
  #hyd-lakes .lakes-toolbar {
    gap: 8px;
    padding: 9px;
  }
  #hyd-lakes .lakes-location {
    flex-basis: 100%;
  }
  #hyd-lakes .lakes-location select {
    height: 36px;
  }
  #hyd-lakes .lakes-toolbar > button {
    flex: 1;
    min-height: 35px;
  }
  /* Inside the phone sheet a shorter map, so the memory cards show on open (also beats the short-screen rule below). */
  html[data-theme] #hyd-lakes .lakes-map {
    height: clamp(120px, 22svh, 260px);
    min-height: 0;
  }
  #hyd-lakes .lakes-memories {
    padding: 14px 12px 18px;
  }
  #hyd-lakes .lakes-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 12px;
  }
}

/* Short screens (520 px tall and under): a near full-height dialog with a fixed 260 px map. */
@media (max-height: 520px) {
  #hyd-lakes {
    height: calc(100dvh - 16px);
  }
  #hyd-lakes .lakes-map {
    height: 260px;
    min-height: 0;
  }
}

/* Touch: a 44px press area around the close disc, kept inside the window's clipped edge. */
@media (pointer: coarse) {
  #hyd-lakes .lakes-close {
    position: relative;
  }
  #hyd-lakes .lakes-close::after {
    content: '';
    position: absolute;
    inset: -7px -12px -16px;
  }
}
