/* ===== GeoSolvr Discoveries page =====
   Loaded after styles.css, which supplies the colours, fonts, header, burger menu and modal. */

/* styles.css locks the game page to the window; put this page back to normal browser scrolling.
   (Both must be 'visible' and overscroll-behavior reset, or the mouse wheel can get stuck on <body>.) */
html,
body.discoveries-page {
  height: auto;
  overflow: visible;
  overscroll-behavior: auto;
}

body.discoveries-page.modal-open {
  overflow: hidden;
}

.disc-page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 30px;
}

.disc-page header {
  margin-bottom: 24px;
  padding-bottom: 24px;
}

.disc-page .logo {
  display: block;
}

/* ---- Title, count and search ---- */
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.title {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.disc-count {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Search and sort sit side by side, wrapping on narrow screens */
.disc-controls {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 0 0 24px;
}

.disc-filter-search {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 4px 20px;
}

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

.disc-inputs .btn {
  padding: 8px 20px;
}

/* ===== Search box with clear (X) button ===== */
.disc-search-wrap {
  position: relative;
  max-width: 420px;
  width: 100%;
}

.disc-search {
  width: 100%;
  max-width: none;
  -webkit-appearance: none;
  appearance: none;
  min-width: 300px;
  margin: 0;
  padding: 8px 42px 8px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.disc-search:focus {
  outline: none;
  border-color: var(--accent);
}
 
/* Hide the browser's own clear button so there's only one */
.disc-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  display: none;
}
 
.disc-search-clear {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 6px;
  margin: auto 0; /* centred without transform, which the general button:active rule overrides */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
 
.disc-search-clear[hidden] {
  display: none;
}
 
.disc-search-clear:active {
  transform: none;
}


/* Filtering */
.disc-sort {
  display: flex;
  align-items: center;
  font-size: 14px;
}

.disc-sort-label {
  margin-right: 4px;
  color: var(--text-secondary);
}

/* Not buttons to look at: plain text, the selected one in the accent colour */
.disc-sort-btn {
  padding: 6px 8px;
  font: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.disc-sort-btn[aria-pressed="true"] {
  color: var(--accent);
}

@media (hover: hover) {
  .disc-sort-btn:hover {
    color: var(--text-primary);
  }
  .disc-sort-btn[aria-pressed="true"]:hover {
    color: var(--accent);
  }
}

/* ---- Grid: as many columns as fit ---- */
.disc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.disc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 8px 8px 12px;
  font: inherit;
  text-align: center;
  color: var(--text-primary);
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.disc-tile[hidden] {
  display: none;
}

.disc-img {
  width: 100%;
  aspect-ratio: 2 / 1;           /* same shape as the photos, so nothing is cropped */
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-3);
}

.disc-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Undiscovered: lighter box with the logo */
.disc-tile.locked .disc-img {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
}

.disc-tile.locked .disc-img img.disc-logo {
  width: 62%;
  height: auto;
  object-fit: contain;
  opacity: 0.45;
}

.disc-tile-name {
  max-width: 100%;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.disc-tile-country {
  max-width: 100%;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-secondary);
}

/* Not found yet: name and country dimmed back */
.disc-tile.locked .disc-tile-name,
.disc-tile.locked .disc-tile-country {
  color: var(--text-muted);
  opacity: 0.75;
}

.disc-empty {
  margin: 24px 0;
  color: var(--text-secondary);
}

/* ---- Place modal (builds on .win-modal / .win-end in styles.css) ---- */
.disc-modal {
  max-width: 720px;
  text-align: left;
}

.disc-modal .win-body {
  padding: 22px 28px 28px;
}

.disc-country {
  margin: 4px 0 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--neutral);
}

.disc-detail {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.disc-blurb {
  flex: 1;
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  text-wrap: pretty;
}

.disc-stats {
  flex: 0 0 170px;
  margin: 0;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.disc-stats div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
}

.disc-stats dt {
  font-size: 13px;
  color: var(--text-secondary);
}

.disc-stats dd {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

/* ---- Toast ---- */
.disc-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 200;
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--text-primary);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.disc-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Discoveries details: "Norway | Found 25 October 2026" */
.disc-country .separator {
  margin: 0 8px;
}

/* ---- Phones ---- */
@media (max-width: 900px) {
  .disc-page {
    padding: 15px 20px 30px;
  }

  .disc-page header {
    padding: 0 0 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
  }

  .disc-page .logo {
    width: 140px;
  }

  .disc-controls {
    flex-direction: column-reverse;
    align-items: flex-start;
  }

  .disc-filter-search {
    flex-direction: column;
    align-items: flex-start;
  }

  .disc-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .disc-modal .win-body {
    padding: 18px 20px 22px;
  }

  .disc-name {
    font-size: 24px;
  }

  /* Stats move under the description, in a row of three */
  .disc-detail {
    flex-direction: column;
    gap: 16px;
  }

  .disc-stats {
    flex: none;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 14px 0 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .disc-stats div {
    flex-direction: column-reverse;
    align-items: center;
    gap: 0;
    padding: 0;
    text-align: center;
  }

  .disc-stats dt {
    font-size: 12px;
  }
}

@media (hover: hover) {

  .disc-search-clear:hover {
    color: var(--text-primary);
    background: var(--surface-2);
  }

  .disc-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
  }

}

/* ===== Place details: arrows and "3 of 19" (js/discoveries.js) ===== */
.disc-photo-wrap {
  position: relative;
}

.disc-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin-top: -20px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.disc-nav-prev { left: 12px; }
.disc-nav-next { right: 12px; }

.disc-nav:active {
  transform: scale(0.94);
}

@media (hover: hover) {
  .disc-nav:hover {
    background: rgba(0, 0, 0, 0.65);
    opacity: 1;
  }
}

/* Only one place to show: no arrows */
.disc-single .disc-nav {
  display: none;
}

.disc-pos {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--neutral);
}

.disc-pos:empty {
  display: none;
}

/* Phones: smaller arrows (you can swipe as well) */
@media (max-width: 900px) {
  .disc-nav {
    width: 32px;
    height: 32px;
    margin-top: -17px;
  }

  .disc-nav-prev { left: 8px; }
  .disc-nav-next { right: 8px; }
}

/* Touch screens: no arrows on the photo (swipe instead) */
@media (hover: none) and (pointer: coarse) {
  .disc-nav {
    display: none;
  }
}