/* === RaceCapture Core Styles (v3.0 — True Masonry) === */

.rcx {
  --rc-red: #e21b2f;
  --rc-ink: #050608;
  --rc-soft: #c7cbd6;
  --rc-white: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--rc-white);
  background: radial-gradient(circle at top, #1a1013 0, #050608 45%, #020203 100%);
  padding: 24px;
  border-radius: 18px;
  max-width: 1800px;
  margin: 0 auto;
}

/* Header / container */
.rcx-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 12px;
}

/* === CART BAR === */
.rcx-cartbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: rgba(10, 11, 16, 0.96);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.55);
  border: 1px solid rgba(226,27,47,0.2);
}

/* Buttons */
.rcx-btn {
  background: var(--rc-red);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.03em;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.rcx-btn:hover:not([disabled]) {
  background: #ff4053;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(226,27,47,0.6);
}
.rcx-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}
.rcx-btn.rcx-clear {
  background: #363945;
}
.rcx-btn.rcx-clear:hover {
  background: #474a58;
}

/* Status & Price */
.rcx-cart-status {
  font-weight: 600;
  color: #c7cbd6;
  white-space: nowrap;
}
.rcx-cart-total {
  font-weight: 600;
  opacity: 0.95;
  white-space: nowrap;
}

/* Action buttons grouped on the right */
.rcx-cart-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* === GALLERY GRID — CSS Columns Masonry (matches organizer page) === */
#rcx-grid,
.rcx-grid {
  column-count: 4;
  column-gap: 14px;
  margin-top: 16px;
}

@media (max-width: 1200px) {
  #rcx-grid,
  .rcx-grid { column-count: 3; }
}

@media (max-width: 768px) {
  #rcx-grid,
  .rcx-grid { column-count: 2; column-gap: 10px; }
}

@media (max-width: 480px) {
  #rcx-grid,
  .rcx-grid { column-count: 2; column-gap: 8px; }
}

/* === TILE STYLES === */
.rcx-tile {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #15161c;
  border: 1px solid #242736;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  margin-bottom: 14px;
  break-inside: avoid;
}

@media (max-width: 768px) {
  .rcx-tile {
    margin-bottom: 10px;
  }
}

/* Images — natural aspect ratio */
.rcx-tile img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Hover feedback (desktop only) */
@media (hover: hover) and (pointer: fine) {
  .rcx-tile:hover img {
    transform: scale(1.03);
    opacity: 0.95;
  }
}

/* === WATERMARK OVERLAY === */
:root {
  --rc-wm-url: url("https://racecapture.ca/wp-content/uploads/2025/10/Racecapture-Logos-transparent1-scaled.png");
  --rc-wm-size: 70%;
  --rc-wm-opacity: 0.55;
}

.rcx-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--rc-wm-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: var(--rc-wm-size);
  opacity: var(--rc-wm-opacity);
  pointer-events: none;
  z-index: 3;
}

/* Tap shield stays above image but under UI badges */
.rcx-tap-shield {
  position: absolute;
  inset: 0;
  z-index: 4;
}

/* Never watermark fullscreen viewer */
.pswp *,
.pswp *::after,
.pswp *::before,
.rc-viewer * {
  background-image: none !important;
}

/* === SELECTED STATE === */
.rcx-tile.rc-selected,
.rcx-tile.rcx-tile-selected {
  outline: 2px solid #ff355a;
  box-shadow: 0 0 0 1px #ff355a, 0 14px 36px rgba(0, 0, 0, 0.75);
}

/* Badge for selected tiles */
.rcx-tile .rc-badge-selected {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 53, 90, 0.95);
  color: #fff;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  z-index: 5;
}

/* Select mode badge (checkbox style) */
.rcx-select-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: transparent;
  transition: all .2s;
  opacity: 0;
  z-index: 5;
}
.rcx-select-mode .rcx-select-badge { opacity: 1; }
.rcx-tile-selected .rcx-select-badge { background: #ff6b6b; border-color: #ff6b6b; color: #fff; }

/* Four corner watermark stamps (deters cropping out the center mark).
   Sits above the photo but below the center stamp (z-index 2 vs 3).
   Center stamp stays primary (70%/.55 on ::after) — corners are smaller
   and more transparent, just enough to deter "crop-out-the-watermark"
   editing without competing with the center mark. */
.rcx-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    var(--rc-wm-url),
    var(--rc-wm-url),
    var(--rc-wm-url),
    var(--rc-wm-url);
  background-repeat: no-repeat;
  background-size: 22%, 22%, 22%, 22%;
  background-position:
    10px 10px,                        /* top-left */
    right 10px top 10px,              /* top-right */
    10px bottom 10px,                 /* bottom-left */
    right 10px bottom 10px;           /* bottom-right */
  opacity: 0.30;
  pointer-events: none;
  z-index: 2;
}
/* Hover: corners stay constant (no animation — keeps protection visible). */
@media (hover:hover) {
  .rcx-tile:hover::before { opacity: 0.32; }
}

/* Broken-image fallback */
.rcx-tile img.is-broken {
  display: none;
}

/* === NOTES / ERRORS === */
.rcx-note {
  padding: 8px 10px;
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: 8px;
  color: #333;
}
.rcx-error {
  padding: 12px;
  background: #fff1f0;
  border: 1px solid #ffa39e;
  border-radius: 10px;
  color: #cf1322;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 600px) {
  .rcx-cartbar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .rcx-cart-actions {
    margin-left: 0;
    justify-content: center;
  }
  .rcx-cart-status,
  .rcx-cart-total {
    text-align: center;
    width: 100%;
  }
}

/* --- Anti-save deterrents for gallery images --- */
.rcx-grid img {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.rcx-tap-shield {
  position: absolute;
  inset: 0;
  display: block;
  background: transparent;
  cursor: default;
}

.rcx-load-more {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* === Manual Selection Mode === */
.rcx-tile-selectable {
  cursor: pointer;
}

.rcx-tile-selectable:hover {
  box-shadow: 0 0 0 3px rgba(255,107,107,0.4);
}

.rcx-tile-selected {
  box-shadow: 0 0 0 3px #ff6b6b !important;
}

.rcx-tile-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,107,107,0.15);
  pointer-events: none;
  z-index: 2;
}

.rcx-select-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.15s;
}

.rcx-tile-selected .rcx-select-indicator {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

@media (max-width: 768px) {
  .rcx-select-indicator {
    width: 24px;
    height: 24px;
    font-size: 14px;
    top: 6px;
    right: 6px;
  }
}

/* === Event Header above gallery === */
.rcx-event-header {
  margin: 10px 4px 4px;
  padding: 4px 2px 0;
  color: #ffffff;
}

.rcx-event-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
}

.rcx-event-meta {
  margin: 4px 0 0;
  font-size: 14px;
  color: #c7cbd6;
}

.rcx-event-team {
  margin: 2px 0 0;
  font-size: 13px;
  color: #a5a7b0;
  opacity: 0.9;
}

/* === Scroll Position Indicator === */
#rcx-scroll-indicator {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  color: #b9c2d6;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#rcx-scroll-indicator .current {
  color: #fff;
  font-weight: 700;
}

#rcx-scroll-indicator .bar {
  width: 60px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

#rcx-scroll-indicator .bar-fill {
  height: 100%;
  background: #ff6b6b;
  border-radius: 2px;
  transition: width 0.15s;
}

/* === Redemption Modal === */
.rcx-promo-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rcxFadeIn 0.2s ease;
}

@keyframes rcxFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.rcx-promo-modal-inner {
  background: #1a1c22;
  border: 1px solid #2a2e39;
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: rcxSlideUp 0.3s ease;
}

@keyframes rcxSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.rcx-promo-title {
  font-family: 'League Gothic', Impact, sans-serif;
  font-size: 28px;
  color: #fff;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.rcx-promo-desc {
  color: #a0a8b8;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.rcx-promo-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: monospace;
  letter-spacing: 1px;
  background: #121318;
  border: 1px solid #3a3f4a;
  border-radius: 10px;
  color: #fff;
  margin-bottom: 16px;
  box-sizing: border-box;
  text-align: center;
  text-transform: uppercase;
}

.rcx-promo-input:focus {
  outline: none;
  border-color: #ff6b6b;
}

.rcx-promo-input::placeholder {
  color: #555;
  text-transform: none;
}

.rcx-promo-buttons {
  display: flex;
  gap: 12px;
}

.rcx-promo-btn {
  flex: 1;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.rcx-promo-btn.secondary {
  background: transparent;
  border: 1px solid #3a3f4a;
  color: #a0a8b8;
}

.rcx-promo-btn.secondary:hover {
  background: rgba(255,255,255,0.05);
  border-color: #555;
}

.rcx-promo-btn.primary {
  background: linear-gradient(135deg, #ff4053, #ff6b6b);
  border: none;
  color: #fff;
  font-weight: 700;
}

.rcx-promo-btn.primary:hover {
  box-shadow: 0 6px 20px rgba(255,64,83,0.4);
}

.rcx-promo-status {
  font-size: 13px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 8px;
  display: none;
}

.rcx-promo-status.error {
  display: block;
  background: rgba(255,59,59,0.15);
  color: #ff6b6b;
}

.rcx-promo-status.success {
  display: block;
  background: rgba(0,163,42,0.15);
  color: #00a32a;
}

/* === TOOLBAR / CONTROLS ROW === */
.rc-toolbar,
.rc-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: #14151b;
  border-radius: 12px;
  border: 1px solid #242736;
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  .rc-toolbar,
  .rc-controls-row {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* === RC BUTTON VARIANTS === */
.rc-btn,
.rc-button,
button.rc-btn,
button.rc-button {
  border-radius: 999px;
  padding: 9px 18px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.rc-btn-primary,
.rc-button-primary {
  background: #ff355a;
  color: #fff;
  box-shadow: 0 8px 20px rgba(255, 53, 90, 0.5);
}

.rc-btn-primary:hover,
.rc-button-primary:hover {
  background: #ff4e6f;
  transform: translateY(-1px);
}

.rc-btn-ghost,
.rc-button-ghost {
  background: #232530;
  color: #f4f4f8;
}

.rc-btn-ghost:hover,
.rc-button-ghost:hover {
  background: #2d3040;
}
