html, body, h1, h2, h3, h4, h5, h6, input, button, div, span, p, a, label {
  font-family: 'Roboto', 'Poppins', Arial, sans-serif !important;
  font-weight: 300 !important;
}
/* Color dot for main color display */
/* Color dot for main color display */
.color-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin: 0.5rem auto 0.2rem auto;
  background: #eee;
}

/* Reset and base styling */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Roboto', 'Poppins', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* Theme variables */
:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #e0e0e0;
}

body.dark-theme {
  --bg: #0f1115;
  --card: #16181c;
  --text: #eee;
  --muted: #bbb;
  --border: #222428;
  background-color: var(--bg);
  color: var(--text);
}

/* Header */
header {
  text-align: center;
  padding: 1.5rem 1rem;
}

/* Banner image used as page title */
#header-banner { max-width: 100%; width: 420px; height: auto; display: block; margin: 0 auto; }

/* Accessible visually-hidden text for screen readers */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }


header h1 {
  font-size: 1.8rem;
  color: var(--text);
  text-shadow: none;
}

/* Gallery Grid */
.gallery {
  display: grid;
  /* Desktop: 4 columns (narrower cards) */
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 2rem;
  padding: 1.8rem;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  transition: transform 0.28s, box-shadow 0.28s;
  cursor: pointer;
  text-align: center;
  padding: 0.8rem;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  object-fit: contain; /* full image visible */
  background-color: #f0f0f0;
}

/* image wrapper so we can position overlays (color dot) */
.img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* let the image determine height so full images show without horizontal gaps */
}

.img-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

/* position color dot inside bottom-right of image */
/* legacy inline image-dot positioning removed; use .swatch-dot beside the title */

.card h2 {
  margin-top: 0.6rem;
  font-size: 1.1rem; /* ~10% larger */
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* Card meta: title + inline swatches */
.card-meta { display:flex; align-items:center; justify-content:flex-start; gap:1rem; margin-top:0.2rem; padding: 1rem 0 0.5rem 0; }
/* ensure the title inside the meta row has no top margin and is vertically centered */
.card-meta h2 { margin: 0; line-height: 1.2; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* push swatches to the right of the meta row and nudge the group 20px to the right */
.swatch-inline { position:relative; width:48px; height:18px; display:inline-block; margin-left: auto; transform: translateX(20px); }
.swatch-inline .swatch-dot { position:absolute; top:0; width:18px; height:18px; border-radius:50%; display:inline-block; box-shadow: 0 1px 4px rgba(0,0,0,0.12); border:1px solid rgba(0,0,0,0.06); transition: transform 0.12s ease; }
.swatch-inline .swatch-dot:nth-child(1) { /* base - front, left */ left: 0; z-index: 2; }
.swatch-inline .swatch-dot:nth-child(2) { /* logo - behind, right (overlap) */ left: 8px; z-index: 1; transform: scale(0.96); }
.swatch-inline:hover .swatch-dot:nth-child(1) { transform: translateX(0) scale(1.02); }
.swatch-dot[title] { cursor: default; }

/* Popup Lightbox */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 30, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  text-align: center;
}

.popup { overflow: visible; }

.popup.hidden {
  display: none;
}

/* Structured popup card */
.popup-card {
  display: flex;
  gap: 2rem;
  align-items: stretch;
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  max-width: 880px;
  width: 96vw;
}

.popup-left { flex: 0 0 auto; display:flex; align-items:center; justify-content:center; }
.popup-main-img { max-width: 320px; width: auto; height: auto; border-radius: 10px; display: block; }

/* Ensure the main popup image is vertically centered with equal top/bottom spacing inside the popup card */
.popup-card .popup-left .popup-main-img {
  margin: 0; /* remove extra bottom margin coming from .popup img */
  align-self: center;
}

/* Popup image larger and zoom behavior */
.popup-main-img.zoomable { cursor: zoom-in; transition: transform 0.25s ease; max-width: 560px; transform-origin: center center; }
.popup-main-img.zoomable.zoomed { transform: scale(2.2); cursor: zoom-out; z-index: 200; }

.popup-right { flex: 1 1 0; display:flex; flex-direction:column; padding: 0.25rem 0; }

/* Large title in popup */
.popup-title-large { font-family: 'Roboto', Arial, sans-serif !important; font-size: 2.1rem; letter-spacing: 2.6px; line-height: 1.05; font-weight: 700 !important; color: var(--text); margin-bottom: 0.8rem; padding: 0.8rem 0; transition: text-shadow 200ms ease; }

/* Color table styling: columns for base, logo, global */
.color-table { width: 100%; border-collapse: collapse; text-align: center; margin-top: 0.6rem; }
.color-table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid rgba(0,0,0,0.06); color: var(--text); }
.color-table .color-name-cell { color: var(--muted); font-weight: 400; }
.color-table .color-hex-cell { font-family: monospace; font-weight: 600; }
.color-table .color-rgb-cell { font-family: monospace; color: var(--muted); }


.popup-right { flex: 1 1 0; display:flex; flex-direction:column; padding: 0.25rem 0; }

/* annotation rows: label and value */
.annotation-row { display:flex; align-items:center; gap:0.6rem; padding: 0.35rem 0; }
.annotation-label { color:var(--muted); font-weight:300; min-width: 110px; }
.annotation-value { color:var(--text); font-weight:500; }
.annotation-color-swatch { width:28px; height:28px; border-radius:50%; display:inline-block; }

/* Collaboration row special styling: centered and stacked */
.annotation-row.collab { display:flex; flex-direction:row; align-items:center; justify-content:center; gap:0.6rem; padding: 0.4rem 0; margin-bottom: 1.6rem; }
.annotation-row.collab .annotation-label { min-width: auto; color: var(--muted); font-weight: 300; font-size: 0.95rem; }
.annotation-row.collab .annotation-value { font-size: 1.12rem; font-weight: 800; text-align:left; }
.annotation-row.collab { background: transparent; }

.popup-flex-spacer { flex:1 1 auto; }

/* sample canvas displayed at a reasonable size but keep native resolution to preserve quality */
.sample-canvas { display:inline-block; width:64px; height:auto; border-radius:6px; }

.specs-row { margin-top:0.5rem; color:var(--muted); }

/* Popup image styling */
.popup img {
  max-width: 320px;
  width: 100%;
  max-height: 45vh;
  border-radius: 10px;
  margin-bottom: 1.2rem;
  background: var(--card);
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Remove bottom margin specifically for large images inside the structured popup card */
.popup-card .popup img { margin-bottom: 0; }

/* Popup title styling */
.popup h2 {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
}

.close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 2rem;
  color: #888;
  cursor: pointer;
  transition: color 0.3s;
}

.close:hover {
  color: #222;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  opacity: 0.6;
}

/* Mobile responsiveness */
/* Responsive breakpoints */
@media (max-width: 1100px) {
  .gallery { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
}
@media (max-width: 800px) {
  .gallery { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 480px) {
  header h1 { font-size: 1.4rem; color: var(--text); }
  .gallery { grid-template-columns: 1fr; gap: 0.9rem; padding: 1rem; }
  .card h2 { font-size: 1.05rem; }
}

/* Samples area in popup */
.samples-title {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 300;
}

.popup-sample-bottom {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding-top: 0.6rem;
  flex-wrap: wrap;
}

.sample-canvas {
  width: 64px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.06);
}
.sample-canvas:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.18); }

@media (max-width: 480px) {
  .popup-main-img { max-width: 220px; }
  .sample-canvas { width: 52px; }
}

/* Controls container near the top (search, sort, theme) */
.controls {
  width:100%;
  max-width:720px;
  margin: 0 auto 1rem auto;
  display:flex;
  gap:1rem;
  align-items:center;
}

/* Theme toggle button tweaks - small square */
#theme-toggle {
  width:44px; height:40px; display:inline-flex; align-items:center; justify-content:center; font-size:1.05rem;
  background: var(--card); color: var(--text); border:1px solid var(--border); cursor:pointer; border-radius:8px;
}
body.dark-theme #theme-toggle { background: var(--card); color: var(--text); border-color: var(--border); }

/* Search bar and sort select use theme variables */
#search-bar {
  flex: 1 1 auto;
  height: 40px;
  padding: 0 1rem; /* horizontal padding, height controls vertical */
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-sizing: border-box;
  background: var(--card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
}
#search-bar::placeholder { color: var(--muted); }

#sort-select {
  min-width: 220px;
  height: 40px;
  padding: 0 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
}

#per-row-select {
  min-width: 120px;
  height: 40px;
  padding: 0 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
}

/* Empty / error message styling for gallery */
.empty-message {
  padding: 2rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1/-1;
  min-height: 40vh;
}
