/* =============================================
   MESSIER.CSS - Lista Messiera
   ============================================= */

/* =============================================
   MESSIER 3D - Celestial sphere flagship
   ============================================= */
.messier-3d-section {
  position: relative;
  width: 100%;
  padding: 0 0 2rem;
}
.m3d-canvas-wrap {
  position: relative;
  width: 100%;
  height: min(72vh, 720px);
  overflow: hidden;
  background: radial-gradient(ellipse at center, #070a18 0%, #03040a 75%);
  border-top: 1px solid var(--clr-border);
  border-bottom: 1px solid var(--clr-border);
}
#messier-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}
.m3d-hud {
  position: absolute;
  top: 1.2rem; left: 1.2rem; right: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  pointer-events: none;
  z-index: 2;
}
.m3d-hud-left { display: flex; flex-direction: column; gap: 0.25rem; }
.m3d-title {
  font-family: var(--font-heading, 'Georgia', serif);
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  color: rgba(232, 234, 246, 0.95);
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}
.m3d-hint {
  font-size: 0.78rem;
  color: rgba(150, 170, 210, 0.75);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.m3d-badge {
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  color: rgba(180, 255, 220, 0.95);
  background: rgba(55, 200, 150, 0.12);
  border: 1px solid rgba(90, 240, 180, 0.28);
  border-radius: 999px;
  letter-spacing: 0.03em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}
.m3d-legend {
  position: absolute;
  bottom: 1.2rem; left: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.75rem;
  color: rgba(200, 215, 240, 0.85);
  background: rgba(8, 10, 22, 0.55);
  border: 1px solid var(--clr-border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2;
  max-width: calc(100% - 2.4rem);
}
.m3d-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.02em;
}
.m3d-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.m3d-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 0.45rem 0.7rem;
  background: rgba(12, 16, 30, 0.88);
  border: 1px solid rgba(124, 92, 252, 0.35);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #e8eaf6;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 3;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.m3d-tt-sub {
  color: rgba(160, 175, 210, 0.75);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* Flash highlight karty po kliknięciu w 3D */
.m-card.m3d-flash {
  animation: m3dFlash 1.2s ease-out;
}
@keyframes m3dFlash {
  0%   { box-shadow: 0 0 0 0 rgba(124, 92, 252, 0.0); }
  20%  { box-shadow: 0 0 0 6px rgba(124, 92, 252, 0.45),
                     0 0 40px 8px rgba(0, 212, 255, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(124, 92, 252, 0.0); }
}

@media (max-width: 680px) {
  .m3d-canvas-wrap { height: 62vh; }
  .m3d-title { font-size: 1rem; }
  .m3d-hint { display: none; }
  .m3d-legend { font-size: 0.68rem; gap: 0.4rem 0.8rem; padding: 0.45rem 0.65rem; }
}

.messier-section {
  padding: 3rem 0 6rem;
}

/* =============================================
   PROGRESS CARD
   ============================================= */
.messier-progress-card {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
}

.mp-stats {
  display: flex;
  gap: 2rem;
  flex-shrink: 0;
}

.mp-stat {
  text-align: center;
}

.mp-val {
  display: block;
  font-size: 2rem;
  font-weight: 900;
  color: var(--clr-gold);
  font-variant-numeric: tabular-nums;
}

.mp-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clr-muted);
}

.mp-bar-wrap {
  flex: 1;
  min-width: 160px;
}

.mp-bar {
  height: 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 50px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.mp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-accent), var(--clr-accent-2));
  border-radius: 50px;
  width: 0%;
  transition: width 0.6s var(--ease-out-expo);
}

.mp-bar-label {
  font-size: 0.75rem;
  color: var(--clr-muted);
}

.btn-reset-messier {
  background: none;
  border: 1px solid rgba(255,71,87,0.3);
  color: rgba(255,71,87,0.7);
  padding: 0.5em 1.1em;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-reset-messier:hover {
  border-color: #ff4757;
  color: #ff4757;
  background: rgba(255,71,87,0.06);
}

/* =============================================
   FILTERS
   ============================================= */
.messier-filters {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 1.5rem;
}

.mf-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mf-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clr-muted);
  white-space: nowrap;
  min-width: 90px;
}

.mf-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mf-chip {
  padding: 0.3em 0.9em;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: var(--clr-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.mf-chip:hover {
  border-color: rgba(124,92,252,0.4);
  color: var(--clr-text);
}

.mf-chip.active {
  border-color: var(--clr-accent);
  background: rgba(124,92,252,0.12);
  color: var(--clr-text);
}

/* =============================================
   OBJECTS GRID
   ============================================= */
.messier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* ---- Object card ---- */
.m-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.2s var(--ease-spring), box-shadow 0.25s;
}

.m-card:hover {
  border-color: rgba(124,92,252,0.35);
  background: rgba(124,92,252,0.04);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.m-card.observed {
  border-color: rgba(0,230,118,0.35);
}

.m-card.observed:hover {
  border-color: rgba(0,230,118,0.6);
}

/* Zdjecie (przycisk podgladu) */
.m-photo {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  padding: 0;
  border: 0;
  background: #05070f;
  overflow: hidden;
  cursor: zoom-in;
}

.m-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease-out-expo);
}

.m-card:hover .m-photo img {
  transform: scale(1.04);
}

.m-photo:focus-visible {
  outline: 2px solid var(--clr-accent-2);
  outline-offset: -2px;
}

.m-photo-none {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--clr-muted);
  font-size: 1.4rem;
  font-weight: 900;
}

.m-card.observed .m-photo::after {
  content: '\2713  Zaobserwowany';
  position: absolute;
  left: 0.6rem;
  top: 0.6rem;
  padding: 0.2em 0.65em;
  border-radius: 50px;
  background: rgba(0,0,0,0.7);
  color: #00e676;
  font-size: 0.68rem;
  font-weight: 700;
}

/* Card body */
.m-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.9rem 1.1rem 0.85rem;
}

.m-header {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--clr-text);
}

.m-num {
  font-weight: 900;
  color: var(--clr-accent-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.m-name {
  color: var(--clr-text);
}

.m-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.m-type-badge {
  font-size: 0.65rem;
  padding: 0.15em 0.6em;
  border-radius: 50px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Type colors */
.mb-galaxy     { background: rgba(124,92,252,0.18); color: #a07cff; }
.mb-globular   { background: rgba(240,180,0,0.18); color: var(--clr-gold); }
.mb-open       { background: rgba(0,212,255,0.18); color: var(--clr-accent-2); }
.mb-nebula     { background: rgba(255,100,50,0.18); color: #ff8b60; }
.mb-planetary  { background: rgba(100,220,100,0.18); color: #64dc64; }
.mb-other      { background: rgba(136,146,176,0.15); color: var(--clr-muted); }

.m-constellation {
  font-size: 0.75rem;
  color: var(--clr-muted);
}

.m-details {
  display: flex;
  gap: 0.25rem 1rem;
  flex-wrap: wrap;
}

.m-detail {
  font-size: 0.75rem;
  color: var(--clr-muted);
}

.m-detail strong {
  color: var(--clr-text);
  font-weight: 600;
}

.m-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.m-credit {
  flex: 1;
  min-width: 0;
  font-size: 0.66rem;
  line-height: 1.35;
  color: var(--clr-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dziennik obserwatora: checkbox "Zaobserwowany" */
.m-seen {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  min-height: 36px;
  padding: 0.15rem 0.6rem 0.15rem 0.45rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  font-size: 0.74rem;
  color: var(--clr-muted);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.m-seen:hover {
  border-color: rgba(0,230,118,0.5);
  color: var(--clr-text);
}

.m-seen input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: #00c864;
  cursor: pointer;
}

.m-seen:has(input:checked) {
  border-color: rgba(0,230,118,0.5);
  background: rgba(0,230,118,0.08);
  color: #00e676;
}

.m-seen:has(input:focus-visible) {
  outline: 2px solid var(--clr-accent-2);
  outline-offset: 2px;
}

/* No results */
.messier-empty {
  grid-column: 1 / -1;
  margin: 0;
  text-align: center;
  padding: 3rem;
  color: var(--clr-muted);
  font-size: 1.05rem;
}

/* Zdanie o dzienniku w karcie postepu */
.mp-note {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--clr-muted);
}

/* Przypis o zrodlach zdjec */
.messier-credits {
  max-width: 72ch;
  margin: 2rem 0 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--clr-muted);
}

.messier-credits a {
  color: var(--clr-accent-2);
}

/* =============================================
   PODGLAD ZDJECIA (dialog)
   ============================================= */
html:has(.m-zoom[open]) {
  overflow: hidden;
}

.m-zoom {
  padding: 0;
  border: 1px solid #394665;
  border-radius: 12px;
  background: #070a18;
  color: var(--clr-text);
}

.m-zoom[open] {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(1240px, 96vw);
  height: 94dvh;
  max-width: none;
  max-height: none;
  overflow: hidden;
}

.m-zoom::backdrop {
  background: rgba(0,0,0,0.88);
}

.m-zoom-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.5rem 0.5rem 0.5rem 1.1rem;
  border-bottom: 1px solid #394665;
}

.m-zoom-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-zoom-pos {
  font-size: 0.78rem;
  color: var(--clr-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.m-zoom-tools {
  display: flex;
  gap: 0.25rem;
}

.m-zoom-tools button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: #c7bcff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.m-zoom-tools button:hover,
.m-zoom-tools button:focus-visible {
  border-color: #394665;
  background: rgba(124,92,252,0.12);
}

.m-zoom-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.m-zoom-view {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0.75rem;
  background: #03050c;
  touch-action: pan-y;
}

.m-zoom-view img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(94dvh - 5.5rem);
  transition: opacity 0.25s;
}

.m-zoom-view img.is-loading {
  opacity: 0.35;
}

.m-zoom-missing {
  color: var(--clr-muted);
}

.m-zoom-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
  min-height: 0;
  padding: 1.1rem 1.2rem;
  border-left: 1px solid #394665;
  overflow-y: auto;
}

.m-zoom-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.9rem;
  margin: 0;
  font-size: 0.85rem;
}

.m-zoom-facts dt {
  color: var(--clr-muted);
}

.m-zoom-facts dd {
  margin: 0;
  color: var(--clr-text);
  font-weight: 600;
}

.m-zoom-seen {
  min-height: 40px;
  font-size: 0.85rem;
}

.m-zoom-note {
  margin: -0.4rem 0 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--clr-muted);
}

.m-zoom-credit {
  margin: auto 0 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--clr-muted);
  overflow-wrap: anywhere;
}

.m-zoom-credit a {
  color: var(--clr-accent-2);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .messier-progress-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.25rem;
  }
  .messier-progress-card > * { max-width: 100%; }
  .mp-stats { flex-wrap: wrap; flex-shrink: 1; gap: 0.75rem 1.25rem; }
  .mp-bar-wrap { align-self: stretch; min-width: 0; }
  .mp-note { flex-basis: auto; }
  .mf-group { flex-direction: column; align-items: flex-start; }
  .mf-label { min-width: auto; }

  .m-zoom[open] {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .m-zoom-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    overflow-y: auto;
  }
  .m-zoom-view { padding: 0.5rem; }
  .m-zoom-view img { max-height: 62dvh; }
  .m-zoom-info {
    border-left: 0;
    border-top: 1px solid #394665;
    overflow: visible;
  }
  .m-zoom-credit { margin-top: 0; }
}

@media (max-width: 480px) {
  .mp-val { font-size: 1.5rem; }
  .messier-filters { padding: 1rem; }
  .m-zoom-pos { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .m-card,
  .m-photo img { transition: none; }
  .m-card:hover,
  .m-card:hover .m-photo img { transform: none; }
}
