/* =========================================================
   Table Unlock — Full CSS (theme-aware, clean, no repeats)
   Works with your current HTML structure:
   body[data-theme], .bg-glow, main.page, header, aside.panel,
   section.results, .cards, .card, modal, pagination, top button
   ========================================================= */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  line-height: 1.35;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

/* ---------- Theme Tokens ---------- */
body[data-theme="dark"] {
  --bg: #020617;
  --surface: rgba(15, 23, 42, 0.60);
  --surface-2: rgba(2, 6, 23, 0.55);
  --surface-3: rgba(2, 6, 23, 0.35);

  --border: rgba(148, 163, 184, 0.24);
  --border-strong: rgba(148, 163, 184, 0.34);

  --text: #e5e7eb;
  --text-2: rgba(229, 231, 235, 0.82);
  --text-3: rgba(229, 231, 235, 0.62);

  --primary: rgba(45, 212, 191, 0.92);   /* aqua */
  --primary-soft: rgba(45, 212, 191, 0.16);
  --primary-border: rgba(45, 212, 191, 0.55);

  --shadow: rgba(15, 23, 42, 0.85);
  --danger: rgba(248, 113, 113, 0.90);
  --success: rgba(34, 197, 94, 0.92);
}

body[data-theme="light"] {
  --bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-2: rgba(255, 255, 255, 0.92);
  --surface-3: rgba(17, 24, 39, 0.04);

  --border: rgba(17, 24, 39, 0.12);
  --border-strong: rgba(17, 24, 39, 0.18);

  --text: #111827;
  --text-2: rgba(17, 24, 39, 0.76);
  --text-3: rgba(17, 24, 39, 0.58);

  --primary: rgba(249, 115, 22, 0.96);   /* fiery orange */
  --primary-soft: rgba(249, 115, 22, 0.14);
  --primary-border: rgba(249, 115, 22, 0.45);

  --shadow: rgba(148, 163, 184, 0.55);
  --danger: rgba(239, 68, 68, 0.92);
  --success: rgba(22, 163, 74, 0.92);
}

/* ---------- Background Glow (no repeat, no cutoff) ---------- */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;

  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: 120% 120%;
}

/* Dark: dark grey + aqua */
body[data-theme="dark"] .bg-glow {
  background-image:
    radial-gradient(900px 520px at 18% -12%, rgba(45, 212, 191, 0.18), transparent 60%),
    radial-gradient(780px 470px at 82% -8%, rgba(56, 189, 248, 0.12), transparent 64%),
    linear-gradient(to bottom, #020617 0%, #020617 100%);
}

/* Light: white + fiery orange */
body[data-theme="light"] .bg-glow {
  background-image:
    radial-gradient(960px 560px at 18% -12%, rgba(249, 115, 22, 0.20), transparent 62%),
    radial-gradient(780px 470px at 82% -8%, rgba(251, 146, 60, 0.16), transparent 64%),
    linear-gradient(to bottom, #ffffff 0%, #ffffff 100%);
}

/* ---------- Layout ---------- */
.page {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 22px 16px 28px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  min-height: 100vh; /* keeps layout tall when few cards */
  /* IMPORTANT: keep the grid packed at the top */
  align-content: start;

  /* prevent items from stretching weirdly */
  align-items: start;

  /* explicitly define rows: header + content row */
  grid-template-rows: auto 1fr;
}

@media (max-width: 980px) {
  .page {
    grid-template-columns: 1fr;
  }
}

/* ---------- Header ---------- */
header {
  grid-column: 1 / -1;
  padding: 18px 18px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 18px 45px var(--shadow);
  backdrop-filter: blur(10px);
  align-self: start;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--text-2);
  font-size: 0.96rem;
  max-width: 70ch;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pill {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.86rem;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.theme-toggle:hover {
  border-color: var(--border-strong);
}
.theme-toggle-icon {
  font-size: 1rem;
}
.theme-toggle-label {
  font-size: 0.9rem;
  color: var(--text-2);
}

/* ---------- Left Panel (Filters) ---------- */
.panel {
  padding: 14px 14px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 18px 45px var(--shadow);
  backdrop-filter: blur(10px);
  height: fit-content;
  position: sticky;
  top: 14px;
}

@media (max-width: 980px) {
  .panel {
    position: static;
  }
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-count {
  color: var(--text-3);
  font-size: 0.86rem;
}

.field-group {
  margin-top: 12px;
}

.field-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--text-2);
}

.field-group select,
.field-group input[type="search"],
.field-group input[type="text"] {
  width: 100%;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.field-group select:focus,
.field-group input[type="search"]:focus,
.field-group input[type="text"]:focus {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.field-group input::placeholder {
  color: var(--text-3);
}

.small-note {
  margin-top: 7px;
  font-size: 0.82rem;
  color: var(--text-3);
}

.legend {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.legend ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.legend li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text-3);
  font-size: 0.86rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  margin-top: 4px;
}

/* ---------- Results Column ---------- */
.results {
  padding: 14px 14px 92px; /* bottom room for pager + top button */
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 18px 45px var(--shadow);
  backdrop-filter: blur(10px);
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.results-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.results-meta {
  color: var(--text-3);
  font-size: 0.86rem;
}

/* ---------- Cards Grid ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  min-height: 140px;
  flex: 1 1 auto;
}

@media (max-width: 980px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

/* ---------- Card ---------- */
.card {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  padding: 12px 12px 12px;
  display: grid;
  gap: 10px;

  opacity: 0;
  transform: translateY(10px);
  transition: opacity 420ms ease, transform 420ms ease;
}

.card.in-view {
  opacity: 1;
  transform: translateY(0);
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title > div:first-child {
  font-size: 1.02rem;
  font-weight: 780;
  letter-spacing: -0.01em;
}

.card-location {
  margin-top: 4px;
  font-size: 0.86rem;
  color: var(--text-2);
}

.card-tagline {
  margin-top: 6px;
  font-size: 0.84rem;
  color: var(--text-3);
}

/* Pills (top-right per card) */
.pill-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---------- Card body meta ---------- */
.card-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 4px;
}

.meta-label {
  font-size: 0.78rem;
  color: var(--text-3);
}

.meta-value {
  margin-top: 4px;
  font-size: 0.98rem;
  font-weight: 750;
  color: var(--text);
}

.meta-subtle {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-3);
}

@media (max-width: 560px) {
  .card-body {
    grid-template-columns: 1fr;
  }
}

/* ---------- Buttons row ---------- */
.buttons-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

@media (max-width: 560px) {
  .buttons-row {
    grid-template-columns: 1fr;
  }
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  font-weight: 650;
}

.btn-link:hover {
  border-color: var(--border-strong);
  filter: brightness(1.03);
}

.btn-link.primary {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.btn-link:disabled {
  opacity: 0.55;
  cursor: default;
}

.icon {
  font-size: 0.98rem;
}

/* ---------- Empty state ---------- */
.empty-state {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-3);
  color: var(--text-2);
}

/* ---------- Pagination (top + bottom) ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 18px 0 38px;
  font-size: 0.84rem;
}

#pagination-top {
  margin-top: 10px;
  margin-bottom: 14px;
}

.page-btn {
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-btn.active {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

/* ---------- Report Issue Modal ---------- */
.report-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.62);
}

body[data-theme="light"] .report-backdrop {
  background: rgba(17, 24, 39, 0.34);
}

.report-backdrop.hidden {
  display: none;
}

.report-modal {
  width: min(560px, 100%);
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 18px 55px var(--shadow);
  padding: 14px 14px 12px;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.report-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.report-subtitle {
  margin: 6px 0 0;
  color: var(--text-3);
  font-size: 0.86rem;
}

.report-close {
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

.report-label {
  display: block;
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 0.84rem;
  color: var(--text-2);
}

.report-select-input,
.report-textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 10px;
  outline: none;
}

.report-textarea {
  min-height: 92px;
  resize: vertical;
}

.report-select-input:focus,
.report-textarea:focus {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.report-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.report-message {
  margin: 10px 0 0;
  font-size: 0.86rem;
  color: var(--text-2);
}

/* ---------- Scroll-to-top button ---------- */
.scroll-top-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;

  border-radius: 999px;
  border: 1px solid var(--border-strong);
  padding: 10px 12px;

  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 16px 42px var(--shadow);

  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;

  transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top-btn:hover {
  border-color: var(--primary-border);
  box-shadow: 0 18px 52px var(--shadow);
}

/* ---------- Helpers ---------- */
a {
  color: inherit;
}

button {
  font: inherit;
}

::selection {
  background: var(--primary-soft);
}

/* If you ever add "Sponsored" ad cards, keep them aligned */
.card[data-ad-index] .card-tagline {
  color: var(--text-3);
}

/* --- Ads: keep them from stretching cards/layout --- */

/* the <ins class="adsbygoogle"> inside the sponsored card */
.card ins.adsbygoogle {
  max-height: 220px;      /* adjust: 180–260 usually works well */
  overflow: hidden;
  border-radius: 14px;
}

/* wrapper div in createAdCard() */
.card [data-ad-slot-wrap],
.card .ad-slot-wrap {
  max-height: 220px;      /* must match the ins max-height */
  overflow: hidden;
  border-radius: 14px;
}

/* ensure the card layout doesn't blow out due to the ad */
.card[data-ad-index] .card-body {
  grid-template-columns: minmax(0, 1fr);
}

/* ===========================
   HARD CLAMP ADS CARD HEIGHT
   =========================== */

/* Clamp the entire sponsored card */
.card[data-ad-index]{
  max-height: 320px;           /* adjust as needed */
  overflow: auto;
}

/* Make sure the ad area itself can't force growth */
.card[data-ad-index] .buttons-row{
  margin-top: 10px;
  max-height: 240px;           /* ad area clamp */
  overflow: hidden;
}

/* Clamp common AdSense structures (ins + iframe) */
.card[data-ad-index] ins.adsbygoogle{
  display: block !important;
  max-height: 240px;
  overflow: hidden;
}

.card[data-ad-index] iframe{
  max-height: 240px !important;
}

/* ---------- Results header: allow sort button + meta to coexist ---------- */
.results-header {
  align-items: center;      /* instead of baseline */
  flex-wrap: wrap;          /* allow wrapping on small widths */
}

.results-header h2 {
  flex: 0 0 auto;
}

.sort-toggle {
  flex: 0 0 auto;
  border-radius: 999px;
  margin-left: 10px;        /* pushes meta to the right when space allows */
  font-size: 1.05rem;
  font-weight: 800;
  width: 38px;
  height: 38px;
  padding: 0;
  line-height: 1;
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.sort-toggle:hover {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.results-meta {
  flex: 0 0 auto;
  margin-left: auto;
}

.cards::after {
  content: "";
  display: block;
  min-height: 80px;
}

/* ---------- Site logo ---------- */
.site-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 0;
  flex: 0 0 auto;
}

.site-logo img {
  display: block;
  height: 100px !important;
  max-height: 100px;
  width: auto;
}

/* Subtle hover affordance */
.site-logo:hover {
  opacity: 0.92;
}

/* Header alignment safeguard */
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Header layout ---------- */
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* Right side: logo + theme toggle */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;

  /* THIS forces it to hug top-right */
  margin-left: auto;
}

/* Theme toggle hugging corner */
.theme-toggle {
  margin-top: -2px; /* subtle optical alignment */
}

/* Optional: tighter on mobile */
@media (max-width: 560px) {
  .theme-toggle-label {
    display: none;
  }
}

.site-footer {
  position: fixed;
  bottom: 16px;
  left: 16px;
  font-size: 0.85rem;
  opacity: 0.75;
  z-index: 40; /* below scroll-top, above content */
}

.site-footer a {
  text-decoration: none;
  color: inherit;
}

.site-footer a:hover {
  opacity: 1;
}

.privacy-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.privacy-backdrop.hidden { display: none; }

.privacy-modal {
  position: relative; /* REQUIRED */
  background: #0f172a;
  color: #e5e7eb;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 24px 24px 20px; /* top padding leaves room for button */
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}


.privacy-header,
.privacy-actions {
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.privacy-body {
  padding: 14px;
  overflow-y: auto;
  font-size: .95rem;
}

.privacy-header button {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.privacy-modal h1,
.privacy-modal h2,
.privacy-modal h3,
.privacy-modal p,
.privacy-modal li,
.privacy-modal strong,
.privacy-modal span {
  color: #e5e7eb;
}

.privacy-modal h1,
.privacy-modal h2 {
  margin-top: 0;
}

.privacy-modal a {
  color: #7dd3fc;
  text-decoration: underline;
}

.privacy-modal a:hover {
  color: #bae6fd;
}

/* Close button pinned to top-right */
.privacy-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #e5e7eb;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.privacy-close:hover {
  opacity: 0.75;
}

/* --- Tighten spacing below bottom pagination --- */

.pagination {
  margin-bottom: 8px; /* was too large */
}

.results {
  padding-bottom: 16px; /* reduce excessive bottom padding */
}

.cards {
  margin-bottom: 0;
}

/* If empty-state is shown, don’t add extra space */
.empty-state {
  margin-bottom: 8px;
}

/* --- Cookie consent banner --- */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 960px;
  margin: 0 auto;
  z-index: 200;

  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;

  padding: 14px 16px;
  border-radius: 14px;

  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;

  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 20px 40px rgba(0,0,0,.45);
}

[data-theme="light"] .cookie-banner {
  background: rgba(255, 255, 255, 0.97);
  color: #111827;
  border-color: rgba(0,0,0,.12);
}

.cookie-banner.hidden {
  display: none;
}

.cookie-text {
  font-size: 0.85rem;
  line-height: 1.4;
}

.cookie-text p {
  margin: 4px 0 0;
  opacity: 0.85;
}

.cookie-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .cookie-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .cookie-actions {
    width: 100%;
    justify-content: flex-end;
  }
}