/* Album tile grid for Lithuanian numismatic album */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 18px;
  justify-content: center;
  margin-bottom: 18px;
}
.coin-cell {
  width: var(--tile-w);
  height: var(--tile-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto;
  max-width: 100%;
  cursor: default;
}
.coin-meta {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  color: #374151;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.02em;
}
.coin-meta-item {
  position: absolute;
  max-width: calc(100% - 6mm);
  padding: 1.6mm 2.1mm;
  background: rgba(255, 255, 255, 0.92);
  color: #111827;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(3px);
  border-radius: 0;
}
.coin-meta-item.year {
  top: 0;
  right: 0;
  font-weight: 700;
  font-size: 13px;
}
.coin-meta-item.volume {
  right: 0;
  bottom: 0;
  font-weight: 700;
  font-size: 12px;
}
.coin-meta-item.name {
  left: 0;
  bottom: 0;
  width: 40%;
  max-width: 40%;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

.coin-meta-link {
  display: block;
  color: inherit;
  text-decoration: none;
  white-space: inherit;
  overflow: inherit;
  text-overflow: inherit;
}

.coin-cell:hover .coin-shop-links,
.coin-cell:focus-within .coin-shop-links {
  opacity: 1;
  pointer-events: auto;
}

.coin-meta-link:hover {
  text-decoration: underline;
}

.coin-shop-links {
  position: absolute;
  left: 0;
  top: 8mm;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.coin-shop-link {
  display: block;
  padding: 1.4mm 2.1mm;
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.16);
}

.coin-shop-link:hover {
  background: #f3f4f6;
}
.coin-slot {
  width: var(--slot-w);
  height: var(--slot-h);
  border-radius: 3mm;
  border: 1px solid #d8dee6;
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  margin: 0 auto;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6), 0 8px 18px rgba(15,23,42,0.08);
}
.coin-slot.collected {
  border: 2px solid #1f9d45;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55), 0 0 0 2px rgba(31,157,69,0.12);
}
.coin-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}
.coin-placeholder-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  color: #555;
  padding: 3px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
}

.coin-action-btn {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  padding: 1.6mm 2.2mm;
  border: none;
  background: rgba(17, 24, 39, 0.95);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.coin-cell:hover .coin-action-btn,
.coin-cell:focus-within .coin-action-btn {
  opacity: 1;
  pointer-events: auto;
}

.coin-action-btn:hover {
  background: #111827;
}

@media (hover: none) {
  .coin-action-btn {
    opacity: 1;
    pointer-events: auto;
  }
  .coin-shop-links {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 1200px) {
  .coin-meta {
    font-size: 10px;
  }
  .coin-meta-item.year,
  .coin-meta-item.volume {
    font-size: 10px;
  }
  .coin-meta-item.name {
    font-size: 9px;
    max-width: calc(100% - 22mm);
  }
}
/* Burger Menu / Controls (from 2eur_kolekcija) */
.menu-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1002;
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  padding: 0 10px;
  cursor: pointer;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}
body.menu-open .menu-toggle {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: #374151;
}
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.45);
}
.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(320px, 86vw);
  z-index: 1001;
  background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
  border-right: 1px solid #e5e7eb;
  box-shadow: 10px 0 30px rgba(0,0,0,0.35);
  padding: 12px 14px 14px;
  overflow-y: auto;
  transform: translateX(-103%);
  transition: transform 0.2s ease;
}
.side-menu.open {
  transform: translateX(0);
}
.menu-close {
  position: absolute;
  top: 6px;
  right: 10px;
  border: none;
  background: transparent;
  color: #374151;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}
.menu-controls {
  margin-bottom: 12px;
  padding-top: 26px;
}
.text-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.text-toggle {
  border: 1px solid #d1d5db;
  background: transparent;
  color: #4b5563;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: pointer;
}
.text-toggle.is-active {
  border-color: #1f2937;
  background: #1f2937;
  color: #fff;
}
.btn-print {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85rem;
  text-align: left;
}
.btn-print:hover { opacity: 0.85; }
.stats {
  margin-left: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
  line-height: 1.4;
}
:root {
  --tile-w: 106mm;
  --tile-h: 72mm;
  --slot-w: 93mm;
  --slot-h: 65mm;
  --gap: 5mm;
  --page-w: calc(var(--tile-w) * 2 + var(--gap) + 16mm);
  --page-h: calc(var(--tile-h) * 4 + var(--gap) * 3 + 24mm);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #ececec;
  color: #1f2937;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid #d1d5db;
  padding: 10px 14px;
}
.topbar h1 {
  margin: 0 0 6px;
  font-size: 18px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
#statsText {
  margin: 8px 0 0;
  color: #6b7280;
  font-size: 13px;
}

#albumContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 18px 84px 24px 18px;
}

.album-page {
  width: var(--page-w);
  min-height: var(--page-h);
  background: #fff;
  border: 1px solid #d1d5db;
  box-shadow: 0 8px 26px rgba(0,0,0,0.16);
  padding: 8mm;
  position: relative;
}
.page-label {
  text-align: center;
  color: #6b7280;
  font-size: 11px;
  margin-bottom: 5mm;
  font-style: italic;
}

.grid {
  display: grid;
  grid-template-columns: var(--tile-w) var(--tile-w);
  grid-auto-rows: var(--tile-h);
  column-gap: var(--gap);
  row-gap: var(--gap);
  justify-content: center;
}

.album-page.is-partial {
  min-height: auto;
}

.tile {
  border: 1px dashed #cfd5dd;
  padding: 3mm;
  background: #fff;
  position: relative;
  cursor: pointer;
}
.tile.selected {
  border: 2px solid #16a34a;
  background: #f0fdf4;
}
.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 1.5mm;
  font-size: 10px;
  color: #4b5563;
}
.tile-year {
  font-weight: 700;
}
.tile-mintage {
  color: #6b7280;
}
.tile-name {
  font-size: 10px;
  line-height: 1.2;
  min-height: 7mm;
  margin-bottom: 1.5mm;
}

.pack-slot {
  width: var(--slot-w);
  height: var(--slot-h);
  margin: 0 auto;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pack-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.pack-fallback {
  font-size: 10px;
  color: #6b7280;
  text-align: center;
  padding: 4mm;
}

.tile-footer {
  margin-top: 1.5mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 9px;
}
.tile-link {
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-id {
  color: #6b7280;
}

.year-shortcuts {
  position: fixed;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 6px 4px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1003;
}
.year-shortcuts:empty { display: none; }
.year-btn {
  width: 34px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #cfd5dd;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.year-bookmark {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #cfd5dd;
  background: radial-gradient(circle at 30% 30%, #fff8d8 0%, #f6dc8a 45%, #d7af4b 100%);
  color: #5b4308;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 1px 3px rgba(0, 0, 0, 0.2);
}

.year-bookmark:hover {
  filter: brightness(0.98);
}

@media (max-width: 1200px) {
  :root {
    --tile-w: auto;
    --tile-h: auto;
    --slot-w: auto;
    --slot-h: auto;
    --page-w: 100%;
    --page-h: auto;
  }
  #albumContainer {
    padding: 12px 56px 16px 12px;
  }
  .album-page {
    width: 100%;
    min-height: auto;
    padding: 8px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
    column-gap: 8px;
    row-gap: 8px;
  }
  .coin-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 106 / 72;
  }
  .coin-slot {
    width: calc(100% - 6px);
    height: auto;
    aspect-ratio: 93 / 65;
  }
  .year-shortcuts {
    right: 2px;
    padding: 4px 3px;
    max-height: 72vh;
  }
  .year-btn {
    min-width: 30px;
    height: 22px;
    font-size: 10px;
  }
}

@media (max-width: 720px) {
  #albumContainer {
    padding: 10px 46px 14px 10px;
  }
  .grid {
    column-gap: 6px;
    row-gap: 6px;
  }
  .coin-meta {
    font-size: 10px;
  }
  .coin-meta-item.year,
  .coin-meta-item.volume {
    font-size: 10px;
  }
  .coin-meta-item.name {
    font-size: 9px;
    width: 40%;
    max-width: 40%;
  }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff; }
  .no-print { display: none !important; }
  #albumContainer {
    gap: 0;
    padding: 0;
  }
  .album-page {
    box-shadow: none;
    border: none;
    width: var(--page-w);
    min-height: var(--page-h);
    page-break-after: always;
    break-after: page;
  }
}
