/* ── Font ──────────────────────────────────────────────── */
@font-face {
  font-family: 'DestroyFont';
  src: url('fonts/destroy-font.woff2') format('woff2'),
       url('fonts/destroy-font.woff') format('woff'),
       url('fonts/destroy-font.otf') format('opentype');
  font-display: swap;
  font-style: normal;
  font-weight: 800;
  font-stretch: normal;
}

/* ── Reset & base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #e5e5e5;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --border: #111111;
  --text: #111111;
  --text-dim: #666666;
  --accent: #111111;
  --accent-dim: #444444;
  --radius: 0;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --fs: 15px;
}

html { background: transparent; color: var(--text); font-family: var(--font); font-size: var(--fs); }
body { min-height: 100vh; position: relative; }

/* ── Header ────────────────────────────────────────────── */
header {
  padding: 16px 24px;
  border-bottom: none;
  position: relative;
  z-index: 10;
}

.header-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

h1 {
  font-size: 16px;
  font-weight: 400;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.h1-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.h1-link:hover {
  text-decoration: underline;
}

.fire-icon {
  flex-shrink: 0;
  vertical-align: -1px;
}

h1 .eth {
  font-weight: 400;
}

/* ── Center cluster: stats + live ────────────────────── */
.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.header-stats {
  color: var(--text);
}

/* ── Spawn counter (flip-clock digits) ────────────────── */
.spawn-counter {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.spawn-counter .sc-label {
  margin-left: 4px;
  font-size: var(--fs);
}
.spawn-counter .sc-digit {
  display: inline-block;
  position: relative;
  width: 0.62em;
  height: 1.2em;
  overflow: hidden;
  text-align: center;
  line-height: 1.2em;
}
.spawn-counter .sc-slash {
  display: inline-block;
  width: 0.5em;
  text-align: center;
}
.spawn-counter .sc-inner {
  display: block;
  position: absolute;
  left: 0;
  width: 100%;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.spawn-counter .sc-inner span {
  display: block;
  height: 1.2em;
  line-height: 1.2em;
}

.header-sep {
  color: var(--text);
  font-size: 15px;
  line-height: 1;
}

/* ── Right cluster: nav + gear ────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  padding: 4px 10px;
  font-size: var(--fs);
  font-family: var(--font);
  line-height: 1.2;
  transition: background 0.15s, color 0.15s;
}
.header-nav-btn:hover, .header-nav-btn.is-active {
  background: var(--text);
  color: var(--bg);
}

.header-link {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: var(--fs);
  line-height: 1.2;
  transition: background 0.15s, color 0.15s;
}
.header-link:hover {
  background: var(--text);
  color: var(--bg);
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.live-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text);
  animation: pulse-dot 2s ease-in-out infinite;
}

.live-circle {
  display: block;
  color: var(--text);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Gear button ───────────────────────────────────────── */
.settings-btn {
  background: none;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 4px 5px 2px;
  line-height: 1;
  display: flex;
  align-items: center;
}
.settings-btn:hover, .settings-btn.is-open { background: var(--text); color: var(--bg); }

/* ── Settings pane (right slide panel) ─────────────────── */
.settings-pane {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--text);
  z-index: 50;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  transition: right 0.2s ease;
}
.settings-pane.open {
  right: 0;
}

.settings-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--text);
}

.settings-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 26px;
  height: 26px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.settings-close:hover {
  background: var(--text);
  color: var(--bg);
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.settings-section:last-of-type {
  border-bottom: none;
}

.settings-section-title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text);
  margin-bottom: 12px;
}

.settings-group {
  margin-bottom: 10px;
}

.settings-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.settings-slider {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-slider span {
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-dim);
}

.settings-pane select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs);
  cursor: pointer;
  outline: none;
}
.settings-pane select:focus { border-color: var(--text); }

.settings-pane input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 2px;
  background: var(--text);
  outline: none;
}
.settings-pane input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text);
  border-radius: 50%;
  cursor: pointer;
}
.settings-pane input[type=range]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--text);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.settings-save-btn {
  width: 100%;
  padding: 8px 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs);
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: auto;
}
.settings-save-btn:hover {
  background: var(--text);
  color: var(--bg);
}

/* ── Universal tooltip (utt) ───────────────────────────── */
.utt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  display: none;
}
.utt.active { display: block; }

.utt-target {
  position: absolute;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 300;
  line-height: 1;
  color: var(--text);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.35s ease-in;
}
.utt.closing .utt-target {
  opacity: 0;
}

.utt-tether {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.utt-tether line {
  stroke: var(--text);
  stroke-width: 2;
  opacity: 0.35;
  transition: opacity 0.35s ease-in;
}
.utt.closing .utt-tether line {
  opacity: 0;
}

.utt-window {
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--text);
  border-radius: 0;
  overflow: hidden;
  max-width: 220px;
  min-width: 100px;
  opacity: 1;
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.3s ease-out;
}
.utt:not(.active) .utt-window { opacity: 0; }
.utt.closing .utt-window {
  clip-path: inset(50% 50% 50% 50%);
  transition: clip-path 0.35s ease-in;
}

.utt-img {
  display: none;
}
.utt-img.has-img {
  display: block;
}
.utt-img img {
  width: 100%;
  height: auto;
  display: block;
}

.utt-body {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.utt-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.utt-collection {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.utt-sender {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.utt-text {
  color: var(--text);
  font-size: 12px;
}

/* ── Physics controls (inside settings pane) ──────────── */
.phys-ctrls { display: none; }
.physics-active .phys-ctrls { display: block; }
.phys-ctrls button {
  background: none;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 2px 6px;
  font-size: var(--fs);
  line-height: 1;
}
.phys-ctrls button:hover { background: var(--text); color: var(--bg); }

/* ── Layout toggle button ──────────────────────────────── */
.layout-btn, .view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
}
.layout-btn:hover, .view-btn:hover { background: var(--text); color: var(--bg); }
.layout-btn .layout-icon--v { display: block; }
.layout-btn .layout-icon--h { display: none; }
.layout-btn.is-horizontal .layout-icon--v { display: none; }
.layout-btn.is-horizontal .layout-icon--h { display: block; }

/* ── Grid (masonry) ────────────────────────────────────── */
.grid {
  margin: 0 auto;
  padding: 16px 24px 48px;
  columns: 6 140px;
  column-gap: 14px;
  position: relative;
  z-index: 2;
}

/* Horizontal masonry (row-first flow) */
.grid.grid--horizontal {
  columns: unset;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.grid.grid--horizontal .card {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 400px;
  margin-bottom: 0;
  break-inside: unset;
}

.grid.grid--horizontal .card .card-img-wrap img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.grid.grid--horizontal .skeleton-card {
  flex: 0 0 auto;
  width: 180px;
  margin-bottom: 0;
  break-inside: unset;
}

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  break-inside: avoid;
  margin-bottom: 16px;
}

.card:hover {
  border-color: var(--text);
}

.card-img-wrap {
  width: 100%;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-dim);
  background: #f0f0f0;
}

.card-body {
  padding: 8px 10px;
}

.card-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-collection {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.card-sender {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* ── Detail overlay ────────────────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.detail-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: row;
  transform: scale(0.97);
  opacity: 0;
  transition: transform 0.25s ease-out, opacity 0.2s ease-out;
}

.detail-overlay.open .detail-panel {
  transform: scale(1);
  opacity: 1;
}

.detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 1;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.detail-close:hover {
  background: var(--text);
  color: var(--bg);
}

.detail-image {
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.detail-image img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.detail-info {
  padding: 16px 20px 20px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  min-width: 200px;
  max-width: 280px;
}

.detail-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.detail-collection {
  color: var(--text-dim);
  margin-bottom: 10px;
}

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
}

.detail-meta dt {
  color: var(--text-dim);
  font-weight: 500;
}

.detail-meta dd {
  color: var(--text);
  font-family: var(--font-mono);
  word-break: break-all;
}

.detail-meta a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-dim);
  transition: border-color 0.15s;
}

.detail-meta a:hover {
  border-color: var(--text);
}

.detail-description {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-dim);
  line-height: 1.5;
  font-size: 0.92em;
  max-height: 120px;
  overflow-y: auto;
}

/* Wide viewport: image left, info right (default row layout) */
/* Tall/narrow viewport: stack vertically */
@media (max-aspect-ratio: 1/1) {
  .detail-panel {
    flex-direction: column;
    max-width: 520px;
  }

  .detail-image img {
    max-height: 50vh;
  }

  .detail-info {
    border-left: none;
    border-top: 1px solid var(--border);
    max-width: none;
    min-width: 0;
    overflow-y: auto;
    max-height: 35vh;
  }
}

/* ── Loading state ─────────────────────────────────────── */
.loading-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  break-inside: avoid;
  margin-bottom: 16px;
}

.skeleton-img {
  width: 100%;
  padding-top: 100%;
  background: linear-gradient(110deg, #f0f0f0 30%, #e0e0e0 50%, #f0f0f0 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-text {
  height: 10px;
  margin: 8px 10px;
  border-radius: 0;
  background: linear-gradient(110deg, #f0f0f0 30%, #e0e0e0 50%, #f0f0f0 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-text.short { width: 60%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty / error state ───────────────────────────────── */
.empty-state {
  column-span: all;
  text-align: center;
  padding: 80px 24px;
}

.empty-state h2 {
  color: var(--text-dim);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-dim);
}

/* ── Background images ─────────────────────────────────── */
#physics-bg {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#physics-bg .bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.35s ease;
}

body.physics-active #physics-bg {
  display: block;
}

#physics-canvas {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}

#physics-canvas:active {
  cursor: grabbing;
}

body.physics-active {
  overflow: hidden;
}

body.physics-active #grid {
  display: none;
}

body.physics-active #physics-canvas {
  display: block;
}

body.physics-active header {
  position: relative;
  z-index: 2;
}

body.physics-active .header-stats,
body.physics-active .live-status,
body.physics-active .settings-btn {
  color: var(--text);
}

/* ── Card wipe-in animation ────────────────────────────── */
@keyframes card-wipe {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}
.card {
  animation: card-wipe 0.5s ease-out both;
}

/* ── List view ─────────────────────────────────────────── */
#list-view {
  display: none;
  padding: 24px;
  min-height: calc(100vh - 60px);
  position: relative;
  z-index: 2;
}
#list-view.active {
  display: flex;
  gap: 48px;
}

.list-hero {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 0;
}

.list-hero-count {
  font-size: clamp(48px, 10vw, 120px);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.03em;
}

.list-hero-label {
  font-size: clamp(28px, 6vw, 72px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.list-table-wrap {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 100px);
  border: 1px solid var(--border);
  background: var(--bg);
}

.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.list-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text);
}

.list-table td {
  padding: 4px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.list-table tr {
  cursor: pointer;
}
.list-table tr:hover td {
  background: rgba(0,0,0,0.04);
}

.list-table .list-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  vertical-align: middle;
}

.list-table .mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

@media (max-width: 900px) {
  #list-view.active {
    flex-direction: column;
    gap: 24px;
  }
  .list-hero {
    text-align: center;
  }
}

/* ── HUH? overlay ──────────────────────────────────────── */
#huh-overlay {
  position: fixed;
  inset: 0;
  background: none;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
  cursor: pointer;
  pointer-events: none;
}
#huh-overlay.active {
  display: flex;
  pointer-events: auto;
}
#huh-text {
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  max-width: 100%;
  color: #ffffff;
}

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
  position: fixed;
  bottom: 12px;
  right: 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #ffffff;
  background: #000000;
  padding: 4px 8px;
  z-index: 5;
  pointer-events: none;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  .grid {
    columns: 3 100px;
    column-gap: 8px;
    padding: 12px 12px 48px;
  }

  .grid.grid--horizontal .card .card-img-wrap img {
    height: 150px;
  }

  header {
    padding: 12px;
  }

  .header-top {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .header-center {
    justify-content: flex-start;
  }

  .detail-overlay {
    padding: 8px;
  }

  .detail-panel {
    max-width: 100%;
    flex-direction: column;
  }

  .detail-info {
    border-left: none;
    border-top: 1px solid var(--border);
    max-width: none;
    min-width: 0;
  }
}
