/* NanoPix – minimal, dark-friendly, responsive */

:root {
  --bg: #0d0d0f;
  --surface: #16161a;
  --border: #2a2a2e;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --danger: #ef4444;
  --radius: 8px;
  --space: 1rem;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* Header */
.header {
  padding: var(--space) 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space);
}

.site-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.site-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space);
  flex-wrap: wrap;
}

.price-ticker {
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.ticker-label { color: var(--text-muted); }
.ticker-usd::before { content: " $"; }
.ticker-eur::before { content: " / €"; }
.ticker-stale {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.btn-wallet {
  background: var(--accent);
  color: #fff;
}

.btn-wallet:hover {
  background: var(--accent-hover);
}

.btn-wallet.connected {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.wallet-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-balance {
  font-size: 0.8rem;
  color: var(--accent);
}

.wallet-network {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.wallet-network.wrong-network {
  color: #f59e0b;
}

/* Main / Gallery */
.main {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: var(--text-muted);
}

.card-image-wrap {
  position: relative;
  display: block;
}

.card-image {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--bg);
}

.btn-share-card {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-share-card:hover {
  background: rgba(0, 0, 0, 0.85);
}

.btn-share-card svg {
  flex-shrink: 0;
}

.card-body {
  padding: var(--space);
}

.card-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.card-price {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.card-actions .btn {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.card-actions .btn:hover {
  background: var(--border);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
}

.modal-close:hover {
  color: var(--text);
  background: var(--border);
}

.modal-content {
  padding: 1.5rem;
}

.modal-preview-wrap {
  position: relative;
  margin-bottom: 1rem;
  display: block;
}

.modal-preview {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: contain;
  background: var(--bg);
  border-radius: var(--radius);
}

.btn-share-overlay {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  transition: background 0.15s;
}

.btn-share-overlay:hover {
  background: rgba(0, 0, 0, 0.9);
}

.btn-share-overlay svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: block;
}

.btn-share-overlay-label {
  white-space: nowrap;
}

.modal-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

.modal-description {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.modal-price {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--accent);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.modal-actions .btn-buy {
  background: var(--accent);
  color: #fff;
}

.modal-actions .btn-buy:hover:not(:disabled) {
  background: var(--accent-hover);
}

.modal-actions .btn-buy:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-actions .btn-download {
  background: var(--accent);
  color: #fff;
}

.modal-actions .btn-download:hover {
  background: var(--accent-hover);
}

.payment-status {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

.payment-status.pending { color: #f59e0b; }
.payment-status.success { color: var(--accent); }
.payment-status.error { color: var(--danger); word-break: break-all; }

.tx-link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.tx-link:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    margin-left: 0;
    width: 100%;
  }
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}
