﻿/* Modernized Battlemap Gallery Styles */

:root {
  /* Refined, higher-contrast light palette */
  --background: #f8fafc; /* slate-50 */
  --text: #111827;       /* slate-900 */
  --card-bg: #ffffff;
  --border: #d1d5db;     /* slate-300 for clearer separation */
  --accent: #14b8a6;     /* teal-500 */
  --accent-hover: #0d9488; /* teal-600 */
  /* Make filter chips and sort neutral slate with better contrast */
  --tag-bg: #e2e8f0;     /* slate-200 */
  --tag-hover: #cbd5e1;  /* slate-300 */
  --shadow: rgba(0, 0, 0, 0.06);
  /* Patreon: tone down to subtle neutral */
  --patreon-bg: #ffffff;
  --patreon-hover: #f1f5f9;
  --patreon-border: #e5e7eb;
}

/* Typography + Layout */
body {
  font-family: 'Inter', sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  margin: 0 auto;
  padding: 2rem 1rem;
  max-width: 1200px;
  overflow-x: hidden;
}


h1 {
  font-size: 2.5rem;
  margin-bottom: 0.2rem;
  font-weight: 600;
  text-align: center;
  color: #111;
  line-height: 1.15; /* tighter for multi-line headings */
  text-wrap: balance; /* improve mobile line breaks in modern browsers */
}

.subtitle {
  font-size: 1.1rem;
  color: #475569; /* slate-600 for cleaner tone */
  text-align: center;
  margin-bottom: 1rem;
  margin-top: 0.1rem;
  line-height: 1.45; /* more comfortable on small screens */
  text-wrap: pretty; /* avoid awkward widows/orphans where supported */
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

/* Top-right help link in header */
header { position: relative; }
.help-link {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.help-link svg { width: 16px; height: 16px; display: block; }

.help-link:hover {
  background: var(--tag-hover);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.help-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .help-link { width: 26px; height: 26px; top: 0.2rem; right: 0.2rem; }
}

/* License/Usage page layout */
.page-card {
  max-width: 820px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 6px var(--shadow);
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  transition: transform 0.18s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.10);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Active filter chips */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.active-filters .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  color: #334155;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.active-filters .chip button {
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
}

.active-filters .clear-all {
  background: none;
  border: none;
  color: #0f766e;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: underline;
}

/* Search + Tag Filter */
#search {
  padding: 0.8rem 1.2rem;
  font-size: 1.1rem;
  width: 100%;
  max-width: 480px;
  margin: 1.25rem auto 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px var(--shadow);
  display: block;
  box-sizing: border-box; /* prevent overflow from padding on mobile */
}

#tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.5rem auto 0.5rem;
  max-width: 700px;
}

#tags button {
  background: var(--tag-bg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
  color: #334155; /* slate-700 for readability */
  font-weight: 500;
}

#tags button:hover {
  background: var(--tag-hover);
}

#tags button.active {
  background: var(--accent);
  color: white;
}

/* (clear filters icon removed) */

/* (removed nav buttons) */

/* Patreon Button */
.patreon {
  background: var(--patreon-bg);
  border: 1px solid var(--patreon-border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: #444;
  text-decoration: none;
  display: inline-block;
  margin-top: 0; /* align with #sortOrder in .header-actions */
  opacity: 1;
  transition: opacity 0.6s ease-in-out;
  vertical-align: middle;
}

.patreon:hover {
  background-color: var(--patreon-hover);
  color: #222;
  border-color: var(--patreon-border);
}

.patreon,
#sortOrder {
  height: 42px;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit; /* ensure same font */
}

/* Dedicated select styling */
#sortOrder {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--card-bg);
  color: var(--text);
  height: 42px;
  cursor: pointer;
  vertical-align: middle;

  /* Dropdown arrow styling */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg fill='gray' viewBox='0 0 24 24' width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2rem;
  transition: background-color 0.2s, border-color 0.2s;
}

#sortOrder:hover {
  background-color: var(--tag-hover);
  color: var(--text);
  border-color: var(--border);
}




/* Gallery Grid */
#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding-bottom: 3rem;
}

/* Map Cards */
.map {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 6px var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform, box-shadow, border-color;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.map:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 10px 24px var(--shadow);
  border-color: var(--accent);
}

/* Shimmer highlight */
.map::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(120deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.22) 22%,
    rgba(255,255,255,0) 45%);
  transform: translateX(-60%) rotate(20deg);
  opacity: 0;
  pointer-events: none;
  transition: transform .6s ease, opacity .3s ease;
}

.map:hover::before {
  transform: translateX(60%) rotate(20deg);
  opacity: 1;
}

.map img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #eef2f7; /* subtle skeleton bg */
  will-change: transform, filter;
  transition: transform .35s ease, filter .35s ease;
}

.map:hover img {
  transform: scale(1.045);
  filter: saturate(1.05);
}

/* Subtle fade-in on cards */
.map.fade-in { opacity: 0; transform: translateY(6px); transition: opacity .35s ease, transform .35s ease; }
.map.fade-in.visible { opacity: 1; transform: translateY(0); }


.map a {
  padding: 0.4rem 0.9rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 6px;
  transition: background 0.2s ease;
}

.map a:hover {
  background: var(--accent-hover);
}

/* Improve card affordance and focus */
.map {
  cursor: pointer;
}

.map:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Show outlines only when keyboard-tabbing */
.map:focus:not(:focus-visible) { outline: none; }
.map:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Lightbox Styles */
#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 15, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow: hidden;
}

#lightbox.hidden {
  display: none;
}

.lightbox-content {
  position: relative;
  background: #fff;
  padding: 1rem;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
}

/* New wrapper so key hints sit over the image */
.lightbox-media {
  position: relative;
  display: inline-block;
}

/* Subtle keyboard hint overlay */
.lightbox-keyhints {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.35rem;
  pointer-events: auto;
  opacity: 0.9;
  z-index: 2;
  background: rgba(0,0,0,0.25);
  padding: 4px 8px;
  border-radius: 999px;
}

.lightbox-keyhints button {
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.95);
  color: #111;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 1px 2px var(--shadow) inset;
}

.lightbox-keyhints button:hover {
  transform: translateY(-1px) scale(1.06);
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.lightbox-keyhints button:active {
  transform: translateY(0) scale(0.98);
}

/* On touch devices, avoid sticky hover scaling on hint buttons */
@media (hover: none), (pointer: coarse) {
  .lightbox-keyhints button { transition: background 0.18s ease, box-shadow 0.18s ease; }
  .lightbox-keyhints button:hover { transform: none; }
  .lightbox-keyhints button:active { transform: none; }
}

.lightbox-content img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 6px;
  margin-bottom: 0;
}

/* Empty state styling */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: #666;
  padding: 2rem 1rem;
}

/* (pagination removed) */

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.lightbox-meta {
  margin-top: 12px;
}

.lightbox-meta h2 {
  margin: 0 0 4px;
}

.lightbox-meta p {
  margin: 0 0 8px;
}

#lightbox-title {
  font-size: 1.4rem;
  color: #222;
}

#lightbox-tags {
  color: #666;
  font-size: 0.9rem;
  margin: 0.5rem 0 1.2rem 0;
}


.lightbox-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.lightbox-buttons a {
  display: inline-block;
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.lightbox-buttons a:hover {
  background: var(--accent-hover);
}

.lightbox-buttons a.active {
  box-shadow: 0 0 0 2px var(--accent-hover) inset;
}

#lightbox-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  font-size: 2rem;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

#lightbox-close:focus:not(:focus-visible) { outline: none; }
#lightbox-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

#lightbox-close:hover {
  transform: scale(1.12);
  color: var(--accent);
}

#lightbox-close:active {
  transform: scale(0.96);
}

/* Shared metadata layout for gallery and lightbox */
.map-title {
  font-size: 1.4rem;
  color: #222;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.map-modal-date {
  font-size: 0.9rem;
  color: #aaa;
  margin: 0 0 8px 0;
}

.map-modal-tags {
  font-size: 0.9rem;
  color: #666;
  margin: 0.5rem 0 1.2rem 0;
}

.map-meta {
  margin-top: 0.5rem;
  text-align: center;
}

.map-meta h2.map-title {
  font-size: 1.4rem;
  color: #222;
  font-weight: 600;
  margin: 0 0 4px;
}

.map-meta .map-modal-date {
  font-size: 0.9rem;
  color: #aaa;
  margin: 0 0 8px;
}

.map-meta .map-modal-tags {
  font-size: 0.9rem;
  color: #666;
  margin: 0.5rem 0 .7rem 0;
}



.header-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.results-count {
  font-size: 0.95rem;
  color: #64748b; /* slate-500 */
}

/* (removed dark mode toggle button styles) */




/* ------------------------------------- */
/* âœ… Mobile Cleanup (Nothing redundant) */
/* ------------------------------------- */

@media (max-width: 600px) {
  h1 {
    font-size: clamp(1.8rem, 7vw, 2.2rem);
    margin-bottom: 0.35rem;
  }

  .subtitle {
    font-size: 1rem;
    max-width: 32ch; /* readable line length when wrapping */
    margin-left: auto;
    margin-right: auto;
  }

  #search {
    width: 100%;
  }

  .map {
    padding: 0.75rem;
  }

  .map a {
    font-size: 0.85rem;
  }

.map-title {
  font-size: 1.2rem;
}
.map-modal-date,
.map-modal-tags {
  font-size: 0.8rem;
}

  .header-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .header-actions .patreon,
  .header-actions #sortOrder {
    flex: 0 1 auto;
  }

  .results-count {
    width: 100%;
    text-align: center;
    order: 3;
    margin-top: 0.25rem;
  }

}
/* Lightbox keyboard tooltip */
.lightbox-keyhints:hover::after,
.lightbox-keyhints:focus-within::after {
  content: "Use your keyboard arrow keys";
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  pointer-events: none;
}

.lightbox-keyhints:hover::before,
.lightbox-keyhints:focus-within::before {
  content: "";
  position: absolute;
  bottom: 118%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0,0,0,0.85);
  pointer-events: none;
}

/* Improve focus visibility for keyboard users on hint buttons */
.lightbox-keyhints button:focus:not(:focus-visible) { outline: none; }
.lightbox-keyhints button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Disable tooltip on touch devices and small screens */
@media (hover: none), (pointer: coarse), (max-width: 700px) {
  .lightbox-keyhints:hover::after,
  .lightbox-keyhints:focus-within::after,
  .lightbox-keyhints:hover::before,
  .lightbox-keyhints:focus-within::before {
    content: none;
  }
}
