/* ─── Global hidden override ──────────────────────────────────────────── */
[hidden] { display: none !important; }


/* ─── Design tokens ───────────────────────────────────────────────────── */
:root {
  --bg:           #0b0e13;
  --surface:     #131820;
  --surface-2:   #1a2029;
  --surface-3:   #232b36;
  --border:      #2a3340;
  --border-hot:  #3a4555;

  --text:        #e3e7ee;
  --text-dim:    #8a93a3;
  --text-faint:  #5a6373;

  --accent:      #ff6b35;
  --accent-hot:  #ff8554;
  --accent-dim:  #7a3d20;

  --font-display: 'Rajdhani', 'IBM Plex Sans', sans-serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  --sidebar-w:    280px;
  --topbar-h:     56px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255,255,255,0.012) 0,
    rgba(255,255,255,0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 9999;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent); text-decoration: none; }

::selection { background: var(--accent); color: #000; }


/* ─── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.brand-mark      { color: var(--accent); font-size: 14px; transform: translateY(-1px); }
.brand-name      { font-size: 18px; letter-spacing: 0.18em; }
.brand-section   {
  font-size: 11px;
  color: var(--text-dim);
  border-left: 1px solid var(--border);
  padding-left: 10px;
  letter-spacing: 0.22em;
}

.topbar-search {
  position: relative;
  max-width: 480px;
  width: 100%;
  justify-self: center;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 38px 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: border-color 120ms, background 120ms;
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}
.topbar-search input::placeholder { color: var(--text-faint); }
.search-hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.topbar-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}


/* ─── Layout ──────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

/* ─── Filter sidebar ──────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  /* Important: overflow visible so absolute-positioned dropdown panels
     can extend past the sidebar edge if needed. We pair that with an
     internal y-overflow on each panel. */
  overflow-y: auto;
  overflow-x: visible;
  max-height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.filters-header h2 {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--text);
  font-weight: 600;
}
.ghost {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 4px 8px;
  border: 1px solid transparent;
  transition: color 120ms, border-color 120ms;
}
.ghost:hover { color: var(--accent); border-color: var(--border-hot); }

.filter-group { margin-bottom: 18px; }
.filter-group label {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.filter-help {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: -2px;
  margin-bottom: 6px;
  font-style: italic;
}

.filter-group input[type="date"] {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  transition: border-color 120ms;
}
.filter-group input[type="date"]:hover { border-color: var(--border-hot); }
.filter-group input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.date-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}
.date-sep { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }


/* ─── Dropdown multi-select ───────────────────────────────────────────── */
.dropdown { position: relative; }

.dropdown-trigger {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: border-color 120ms, background 120ms;
}
.dropdown-trigger:hover  { border-color: var(--border-hot); }
.dropdown.open .dropdown-trigger {
  border-color: var(--accent);
  background: var(--surface-2);
}

.dropdown-summary {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
/* Greyed when nothing selected ("Any") so it reads as a placeholder. */
.dropdown-summary.is-empty { color: var(--text-faint); }
/* When selections active, accent colour to draw the eye. */
.dropdown-summary.is-set { color: var(--accent); }

.dropdown-chev {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 120ms;
  flex: 0 0 auto;
}
.dropdown.open .dropdown-chev { transform: rotate(180deg); color: var(--accent); }

/* Panel: absolutely positioned so it overlays content below instead of
   pushing things around. */
.dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--border-hot);
  max-height: 280px;
  overflow-y: auto;
  /* Subtle shadow to lift it above neighbouring filters */
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.6);
}

.dropdown-search {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  z-index: 1;
}
.dropdown-search input {
  width: 100%;
  height: 26px;
  padding: 0 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
}
.dropdown-search input:focus { outline: none; border-color: var(--accent); }

.dropdown-options { display: grid; }
.dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background 80ms, color 80ms;
}
.dropdown-option:hover { background: var(--surface-3); }
.dropdown-option.active { color: var(--accent); }
.dropdown-option input { accent-color: var(--accent); cursor: pointer; }
.dropdown-option span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-empty {
  padding: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}


/* ─── Results grid ────────────────────────────────────────────────────── */
.results {
  padding: 24px 28px 48px;
  min-width: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms;
  position: relative;
}
.card:hover { border-color: var(--accent); }
.card:hover .card-thumb { filter: brightness(1.05); }

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: filter 120ms;
}

.card-body {
  padding: 12px 14px;
  display: grid;
  gap: 6px;
}

.card-team {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.card-line .mono { color: var(--text-faint); font-size: 11px; }

.card-map  { color: var(--text); font-weight: 500; }
.card-site { color: var(--text-dim); font-size: 11px; }

.card-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.card-op {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* Loading + empty + load more */
.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 60px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}
.scanner {
  width: 80px;
  height: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.scanner::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: var(--accent);
  animation: scan 1.2s linear infinite;
}
@keyframes scan { to { left: 100%; } }

.empty-state { padding: 80px 0; text-align: center; }
.empty-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-sub { font-size: 12px; color: var(--text-dim); }

.load-more {
  display: block;
  margin: 32px auto 0;
  padding: 12px 32px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.2em;
  font-weight: 600;
  transition: all 120ms;
}
.load-more:hover {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.06);
  color: var(--accent);
}


/* ─── Modal viewer ────────────────────────────────────────────────────── */
.viewer {
  width: 95vw;
  max-width: 1400px;
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border-hot);
  color: var(--text);
  padding: 0;
  margin: auto;
  overflow: hidden;
}
.viewer::backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(2px);
}

.viewer-inner {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: 100%;
  max-height: 92vh;
}

.viewer-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  font-size: 24px;
  line-height: 1;
  color: var(--text-dim);
  z-index: 2;
  transition: color 120ms;
}
.viewer-close:hover { color: var(--accent); }

.viewer-image {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.viewer-image img {
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
}

.viewer-meta {
  padding: 28px 24px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.meta-row { display: grid; gap: 2px; }
.meta-row-primary { margin-bottom: 6px; }
.meta-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--text-faint);
  font-weight: 600;
}
.meta-team {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  line-height: 1.1;
}

.meta-divider { height: 1px; background: var(--border); margin: 8px 0; }

.meta-ops { display: grid; gap: 8px; }
.op-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.op-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  background: rgba(255, 107, 53, 0.08);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
}

.mono { font-family: var(--font-mono); }

.download-btn {
  margin-top: auto;
  padding: 14px 18px;
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: background 120ms;
}
.download-btn:hover { background: var(--accent-hot); }
.download-icon { font-size: 22px; font-weight: 700; line-height: 1; }
.download-label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
}


/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .filters {
    position: relative;
    top: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .viewer-inner { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .viewer-meta  { border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 600px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    height: auto;
    padding: 12px;
  }
  .topbar-status { display: none; }
  .results { padding: 16px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-body { padding: 10px; }
}
