/* Shared ride photo strip (hub & live) + responsive 3:4 diary grid + dark stage modal */

.ride-photo-gallery {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  margin-inline: -8px;
  padding: 10px 8px;
  scroll-padding-inline: 8px;
  max-width: calc(100% + 16px);
  scrollbar-width: thin;
  scrollbar-color: rgba(243, 238, 224, 0.28) transparent;
}
.panel .ride-photo-gallery {
  margin-inline: 0;
  padding: 10px 0;
  max-width: 100%;
}

.ride-photo-thumb {
  flex: 0 0 160px;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0;
  color: inherit;
  background: rgba(16, 37, 31, 0.52);
  border: 1px solid rgba(243, 238, 224, 0.2);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.panel .ride-photo-thumb {
  background: rgba(24, 49, 45, 0.05);
  border-color: var(--line, #d9cfb7);
}
.ride-photo-thumb:hover {
  border-color: rgba(239, 185, 79, 0.6);
}
@media (prefers-reduced-motion: no-preference) {
  .ride-photo-thumb:hover {
    transform: translateY(-2px);
  }
}

.ride-photo-thumb img {
  display: block;
  width: 160px;
  height: 120px;
  object-fit: cover;
  background: #0f241f;
}
.ride-photo-thumb span {
  display: block;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted, #aab8b2);
}

/* Dedicated diary page: 3:4 portrait editorial grid without horizontal scrollbars */
.diary-page .ride-photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 14px;
  overflow: visible;
  margin-inline: 0;
  padding: 6px 0 8px;
  max-width: 100%;
}
.diary-page .ride-photo-gallery:has(> .ride-photo-thumb:only-child) {
  grid-template-columns: minmax(0, 320px);
}
.diary-page .ride-photo-gallery[aria-busy="true"]:empty {
  min-height: 248px;
  border-radius: 14px;
  background: rgba(16, 37, 31, 0.42);
}
.diary-page .ride-photo-thumb {
  flex: initial;
  width: 100%;
  border-radius: 14px;
  background: #10251f;
  border-color: var(--line, rgba(243, 238, 224, 0.16));
}
.diary-page .ride-photo-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
}
.diary-page .ride-photo-thumb span {
  padding: 10px 12px;
  font-size: 0.82rem;
}

@media (max-width: 520px) {
  .diary-page .ride-photo-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}
@media (max-width: 340px) {
  .diary-page .ride-photo-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ride-photo-empty {
  grid-column: 1 / -1;
  margin: 4px 0;
  color: var(--muted, #aab8b2);
  font-size: 0.95rem;
}
.ride-photo-error {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(239, 185, 79, 0.3);
  background: rgba(16, 37, 31, 0.55);
}
.ride-photo-error p {
  margin: 0;
  color: var(--muted, #aab8b2);
}
.ride-photo-retry {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(239, 185, 79, 0.55);
  background: transparent;
  color: #efb94f;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 750;
  cursor: pointer;
}
.ride-photo-retry:hover {
  background: rgba(239, 185, 79, 0.12);
}

.ride-photo-day { grid-column: 1 / -1; min-width: 0; width: 100%; }
.ride-photo-day summary { cursor: pointer; font-size: 13px; }
[data-recent-ride-photos] { min-width: 0; }
[data-recent-ride-photos][hidden] { display: none; }

/* Dark full-stage lightbox (<dialog>) with self-contained Sääksi tokens */
.ride-photo-dialog {
  --lb-bg: rgba(11, 26, 22, 0.96);
  --lb-ink: #f3eee0;
  --lb-muted: #b7c5bf;
  --lb-line: rgba(243, 238, 224, 0.2);
  --lb-pill: rgba(243, 238, 224, 0.08);
  --lb-pill-hover: rgba(243, 238, 224, 0.16);
  --lb-sun: #efb94f;
  --lb-deep: #0b1a16;
  color-scheme: dark;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--lb-ink);
}
.ride-photo-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(880px, 95vw);
  height: min(94dvh, 920px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: clamp(12px, 2vw, 20px);
  border-radius: 16px;
  background: var(--lb-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.62);
}
.ride-photo-dialog [hidden] {
  display: none;
}
.ride-photo-dialog:modal {
  overscroll-behavior: contain;
}
.ride-photo-dialog::backdrop {
  background: rgba(6, 15, 13, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.ride-photo-dialog :where(button, a):focus-visible {
  outline: 3px solid var(--lb-sun);
  outline-offset: 3px;
}

.ride-photo-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ride-photo-dialog-close,
.ride-photo-dialog-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--lb-line);
  background: var(--lb-pill);
  color: var(--lb-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.ride-photo-dialog-arrow {
  padding: 0;
}
.ride-photo-dialog-close:hover,
.ride-photo-dialog-arrow:hover {
  background: var(--lb-pill-hover);
  border-color: rgba(243, 238, 224, 0.36);
}
.ride-photo-dialog-close:disabled,
.ride-photo-dialog-arrow:disabled {
  opacity: 0.45;
  cursor: default;
}

.ride-photo-dialog-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ride-photo-dialog-count {
  font-size: 0.88rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--lb-muted);
  min-width: 5ch;
  text-align: center;
}

.ride-photo-dialog-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.ride-photo-dialog-stage :is(img, video):not([hidden]) {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  border-radius: 10px;
  transition: opacity 0.16s ease;
}
.ride-photo-dialog-stage img.is-loading {
  opacity: 0.42;
}
.ride-photo-dialog-error:not([hidden]) {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--lb-muted);
}
.ride-photo-dialog-error p {
  margin: 0;
}

.ride-photo-dialog-foot {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(243, 238, 224, 0.12);
}
.ride-photo-dialog-meta-wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.ride-photo-dialog-caption {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.4;
  color: var(--lb-ink);
}
.ride-photo-dialog-meta {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--lb-muted);
}

.ride-photo-dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.ride-media-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 0;
  background: var(--lb-sun, #efb94f);
  color: var(--lb-deep, #0b1a16);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.ride-media-share:hover {
  filter: brightness(1.06);
}
.ride-photo-dialog-status {
  font-size: 0.84rem;
  color: var(--lb-muted);
}
.ride-photo-report {
  margin-inline-start: auto;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--lb-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.ride-photo-report:hover {
  color: var(--lb-ink);
  border-color: var(--lb-line);
}
.ride-photo-report[data-armed="true"] {
  color: #ffd7b3;
  border-color: rgba(242, 145, 61, 0.72);
  background: rgba(242, 145, 61, 0.16);
  font-weight: 750;
}
.ride-photo-report:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 520px) {
  .ride-photo-dialog[open] {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }
}
