/* =========================================================
   IMPOSSIBLE TOWER LIST — style.css
   Dark theme, smooth animations, EToH difficulty icons.
   ========================================================= */

:root {
  --bg-0:        #070709;
  --bg-1:        #0d0d10;
  --bg-2:        #131318;
  --bg-3:        #1a1a20;
  --bg-hover:    #1e1e26;
  --border:      #272730;
  --border-hover:#353540;

  --text:        #e8e6f0;
  --text-dim:    #8a8699;
  --text-muted:  #5c5866;

  --accent:      #ff6b4a;
  --accent-2:    #ff9e5e;
  --accent-gold: #f0c040;

  --tier-verified:   #4ade80;
  --tier-unverified: #f87171;

  /* EToH Difficulty Colors */
  --diff-horrific:    #b388ff;
  --diff-unreal:      #7c3aed;
  --diff-nil:         #888888;
  --diff-error:       #cc2222;
  --diff-high-peak:   #c084fc;

  --font-body:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'IBM Plex Mono', monospace;

  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ---------------- Header ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7,7,9,0.82);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.header-brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.header-meta {
  display: flex;
  gap: 14px;
  align-items: center;
}

.roblox-play-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 100px;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
  letter-spacing: 0.01em;
}

.roblox-play-btn:hover {
  background: var(--bg-3);
  border-color: var(--border-hover);
  transform: scale(1.03);
}

.roblox-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.meta-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 12px;
}

.meta-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
}

.meta-label {
  color: var(--text-muted);
  font-weight: 500;
}

.meta-date {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-weight: 500;
}

/* ---------------- Controls bar ---------------- */

.controls-bar {
  position: sticky;
  top: 72px;
  z-index: 90;
  background: rgba(7,7,9,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.controls-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  max-width: 340px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px 11px 40px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 200ms, box-shadow 200ms;
}

#searchInput::placeholder { color: var(--text-muted); }

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,107,74,0.12);
}

.tier-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tier-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 180ms ease;
  letter-spacing: 0.01em;
}

.tier-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--bg-3);
}

.tier-btn.active {
  color: var(--bg-0);
  background: var(--text);
  border-color: var(--text);
}

/* ---------------- List section ---------------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

.list-section { padding-top: 8px; }

.list-head {
  display: grid;
  grid-template-columns: 64px 1fr 180px 180px 40px;
  align-items: center;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.level-list {
  list-style: none;
  border-top: none;
}

/* ---------------- Level row ---------------- */

.level-row {
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(12px);
  animation: rowIn 400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes rowIn {
  to { opacity: 1; transform: translateY(0); }
}

.row-main {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr 180px 180px 40px;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 180ms ease;
  border-radius: 0;
  position: relative;
}

.row-main::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 200ms ease;
}

.row-main:hover {
  background: var(--bg-hover);
}

.row-main:hover::before {
  background: var(--accent);
}

/* Verified / Unverified colored left borders */
.level-row[data-tier="verified"] .row-main::before   { background: var(--tier-verified); }
.level-row[data-tier="unverified"] .row-main::before { background: var(--tier-unverified); }

/* Difficulty colored left borders (override tier colors when difficulty is present) */
.level-row[data-diff="horrific"] .row-main::before  { background: var(--diff-horrific); }
.level-row[data-diff="unreal"] .row-main::before    { background: var(--diff-unreal); }
.level-row[data-diff="nil"] .row-main::before       { background: var(--diff-nil); }
.level-row[data-diff="error"] .row-main::before     { background: var(--diff-error); }
.level-row[data-diff="high-peak"] .row-main::before { background: var(--diff-high-peak); }

.row-rank {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  padding-left: 12px;
}

.level-row[data-diff="horrific"] .row-rank  { color: var(--diff-horrific); }
.level-row[data-diff="unreal"] .row-rank    { color: var(--diff-unreal); }
.level-row[data-diff="nil"] .row-rank       { color: var(--diff-nil); }
.level-row[data-diff="error"] .row-rank     { color: var(--diff-error); }
.level-row[data-diff="high-peak"] .row-rank { color: var(--diff-high-peak); }

.row-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Difficulty badge with icon */
.row-difficulty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 12px 5px 9px;
  border-radius: 100px;
  border: 1px solid transparent;
  text-transform: uppercase;
  transition: transform 150ms ease, box-shadow 200ms ease;
}

.diff-badge:hover {
  transform: scale(1.04);
}

/* SVG Icons */
.diff-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Horrific — 4-pointed X star, light purple */
.diff-horrific {
  color: var(--diff-horrific);
  border-color: rgba(179,136,255,0.35);
  background: rgba(179,136,255,0.08);
}
.diff-horrific .diff-icon {
  filter: drop-shadow(0 0 4px rgba(179,136,255,0.5));
}

/* Unreal — 8-pointed star, deep purple */
.diff-unreal {
  color: var(--diff-unreal);
  border-color: rgba(124,58,237,0.35);
  background: rgba(124,58,237,0.08);
}
.diff-unreal .diff-icon {
  filter: drop-shadow(0 0 4px rgba(124,58,237,0.5));
}

/* Nil — two overlapping gray stars */
.diff-nil {
  color: var(--diff-nil);
  border-color: rgba(136,136,136,0.30);
  background: rgba(136,136,136,0.08);
}
.diff-nil .diff-icon {
  filter: drop-shadow(0 0 3px rgba(136,136,136,0.4));
}

/* Error — red square with dark border (icon has baked-in colors) */
.diff-error {
  color: #ff5555;
  border-color: rgba(204,34,34,0.40);
  background: rgba(204,34,34,0.10);
}
.diff-error .diff-icon {
  filter: drop-shadow(0 0 5px rgba(204,34,34,0.5));
}

/* High-Peak — bright vivid purple, uses Unreal star icon */
.diff-high-peak {
  color: var(--diff-high-peak);
  border-color: rgba(192,132,252,0.40);
  background: rgba(192,132,252,0.10);
}
.diff-high-peak .diff-icon {
  filter: drop-shadow(0 0 5px rgba(192,132,252,0.6));
}

.row-creator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  overflow: hidden;
}

.creator-first {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creator-more {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 100px;
}

.row-chevron {
  width: 18px;
  height: 18px;
  justify-self: end;
  color: var(--text-muted);
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1), color 200ms;
}

.level-row.expanded .row-chevron {
  transform: rotate(180deg);
  color: var(--text);
}

/* ---------------- Detail panel — FIXED ALIGNMENT ---------------- */

.row-detail {
  display: grid;
  grid-template-columns: minmax(0, 480px) 1fr;
  gap: 0;
  padding: 0 20px;
  background: transparent;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  /* Smooth transitions for all properties */
  transition: max-height 350ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 250ms ease 50ms,
              padding 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.level-row.expanded .row-detail {
  opacity: 1;
  padding: 4px 20px 28px 20px;
  /* max-height set inline by JS */
}

.detail-video {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-sizing: border-box;
}

.detail-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.video-fallback {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(204,34,34,0.9);
  color: #fff;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 100px;
  text-decoration: none;
  z-index: 10;
  transition: background 180ms ease;
}

.video-fallback:hover {
  background: rgba(204,34,34,1);
}

.detail-video-missing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-mono);
  text-align: center;
  padding: 16px;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-left: 8px; /* subtle offset for visual balance */
  box-sizing: border-box;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-content: start;
  width: 100%;
  box-sizing: border-box;
}

.place-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: var(--bg-0);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: var(--radius);
  transition: transform 180ms ease, background 180ms ease;
  width: fit-content;
  box-sizing: border-box;
}

.place-link:hover {
  background: var(--accent-2);
  transform: scale(1.02);
}

.place-link .place-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.place-link-missing {
  background: var(--bg-2);
  border: 1px dashed var(--border-hover);
  color: var(--text-muted);
  cursor: default;
}

.place-link-missing:hover {
  transform: none;
  background: var(--bg-2);
}

.meta-item {
  box-sizing: border-box;
}

.meta-item dt {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.meta-item dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* ---------------- Empty state / load more ---------------- */

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 70px 0;
  font-size: 15px;
}

.load-more {
  display: block;
  margin: 32px auto 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 12px 28px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 180ms ease;
}

.load-more:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-3);
}

/* ---------------- Footer ---------------- */

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 28px 60px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.site-footer p { margin: 4px 0; }

.footer-note code {
  font-family: var(--font-mono);
  background: var(--bg-2);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------------- Mobile ---------------- */

@media (max-width: 720px) {
  .header-inner { padding: 14px 18px; }
  .header-brand h1 { font-size: 18px; }
  .header-meta { gap: 8px; }
  .meta-pill { padding: 6px 10px; font-size: 11px; }
  .roblox-play-btn span { display: none; }
  .roblox-play-btn { padding: 8px 10px; }

  .controls-inner { padding: 0 18px; }
  .search-box { max-width: 100%; flex: 1 1 100%; }
  .tier-filters { width: 100%; }

  main { padding: 0 18px 60px; }

  .list-head { display: none; }
  .row-main { grid-template-columns: 52px 1fr 24px; padding: 14px 16px; }
  .row-difficulty { display: none; }
  .row-creator { display: none; }
  .row-rank { padding-left: 8px; font-size: 13px; }
  .row-name { font-size: 14px; }

  .row-detail { 
    grid-template-columns: 1fr; 
    padding: 0 16px; 
  }
  .level-row.expanded .row-detail { 
    padding: 4px 16px 24px 16px; 
  }
  .detail-meta { 
    grid-template-columns: 1fr 1fr; 
    gap: 14px 16px; 
  }
  .detail-side {
    padding-left: 0;
  }
}

/* Stagger animation delays */
.level-row:nth-child(1)  { animation-delay: 0ms; }
.level-row:nth-child(2)  { animation-delay: 30ms; }
.level-row:nth-child(3)  { animation-delay: 60ms; }
.level-row:nth-child(4)  { animation-delay: 90ms; }
.level-row:nth-child(5)  { animation-delay: 120ms; }
.level-row:nth-child(6)  { animation-delay: 150ms; }
.level-row:nth-child(7)  { animation-delay: 180ms; }
.level-row:nth-child(8)  { animation-delay: 210ms; }
.level-row:nth-child(9)  { animation-delay: 240ms; }
.level-row:nth-child(10) { animation-delay: 270ms; }
.level-row:nth-child(11) { animation-delay: 300ms; }
.level-row:nth-child(12) { animation-delay: 330ms; }
.level-row:nth-child(13) { animation-delay: 360ms; }
.level-row:nth-child(14) { animation-delay: 390ms; }
.level-row:nth-child(15) { animation-delay: 420ms; }
.level-row:nth-child(16) { animation-delay: 450ms; }
.level-row:nth-child(17) { animation-delay: 480ms; }
.level-row:nth-child(18) { animation-delay: 510ms; }
.level-row:nth-child(19) { animation-delay: 540ms; }
.level-row:nth-child(20) { animation-delay: 570ms; }
