:root {
  --page-max: 1100px;
  --gap: 18px;
  --radius: 14px;
  --border: #e5e7eb;
  --ink: #111827;
  --ink-2: #4b5563;
  --bg: #ffffff;
  --muted: #f8fafc;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
body.no-scroll { overflow: hidden; }

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.header .header-wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--gap);
  align-items: center;
}

.brand a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 22px;
}

/* Mobile menu button (hidden on desktop) */
.menu-toggle {
  display: none;                 /* shown at <=900px */
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.menu-toggle:focus { outline: 2px solid #c7d2fe; outline-offset: 2px; }
.menu-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  margin: 4px 0;
}
.menu-toggle-label {
  font-size: 14px;
  color: var(--ink-2);
}

/* Navigation (desktop baseline) */
.nav {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  position: relative; /* for dropdown panel positioning */
}

/* Hide the mobile list on desktop */
.nav-links { display: none; }

/* Search */
.search {
  display: flex;
  gap: 8px;
}
.search input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
}
.search button {
  padding: 8px 12px;
  border: 1px solid var(--ink);
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
}

/* Main */
.main .wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px 16px;
}

/* Hero */
.hero {
  border: 1px solid var(--border);
  background: var(--muted);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
}
.hero h1 {
  margin: 0 0 8px 0;
  font-size: 28px;
}
.hero p { margin: 0; color: var(--ink-2); }

/* Sections */
.section-title {
  font-size: 20px;
  margin: 22px 0 12px;
}

/* Grid/cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gap);
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Image containment (prevents overflow on wide banners) ---------- */
.card .imgbox {
  position: relative;            /* for rank-badge */
  width: 100%;
  height: 170px;                 /* desktop default */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  overflow: hidden;              /* key: no spill outside the card */
  padding: 8px;                  /* breathing room */
  border-radius: 10px;
}
.card .imgbox img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;           /* keep aspect ratio, fit inside box */
}

/* Title / text */
.card .title { font-weight: 600; }
.card .blurb {
  color: var(--ink-2);
  font-size: 14px;
}
.card a.btn {
  align-self: start;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
}

/* Subcategory pills */
.subcat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 18px;
}
.subcat-pills a {
  text-decoration: none;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
}
.subcat-pills a:hover { background: #eef2f7; }

/* Rank + rating on subcategory pages (circular medals) */
.rank-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #1d4ed8;           /* default blue */
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  line-height: 42px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  pointer-events: none;
}
.rank-1 { background: #facc15; color:#111; }  /* gold */
.rank-2 { background: #d1d5db; color:#111; }  /* silver */
.rank-3 { background: #d97706; color:#fff; }  /* bronze */

.rating-line {
  font-size: 14px;
  color: var(--ink-2);
}

/* Helper link from category cards to subcategory */
.subcat-link {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 6px;
}
.subcat-link a { color: var(--ink-2); text-decoration: none; border-bottom: 1px dotted var(--ink-2); }
.subcat-link a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  margin-top: 30px;
  background: var(--bg);
}
.footer .wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 20px 16px;
  color: var(--ink-2);
  font-size: 14px;
  text-align: center;   /* centre everything */
}

/* Affiliate badge */
.badge {
  font-size: 12px;
  color: var(--ink-2);
  background: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
}

/* Footer legal buttons */
.footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  justify-content: center;
}
.footer-links a {
  font-size: 13px;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: background 0.2s;
}
.footer-links a.legal {
  background: #eef2ff;      /* soft blue background */
  color: #1d4ed8;           /* brand blue text */
  border-color: #cfd7ff;
}
.footer-links a.legal:hover { background: #dbe1ff; }

/* Featured block for rank #1 on subcategory pages */
.seo-intro {
  margin: 18px 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
}
.featured-wrap { margin: 12px 0 20px; }

.card--featured {
  background: #eef2ff;
  border: 1px solid #dbe1ff;
  padding: 18px;
}

/* Featured image box a bit taller on desktop */
@media (min-width: 901px) {
  .card--featured .imgbox { height: 230px; }
}

/* Make the rank badge larger on featured */
.card--featured .rank-badge {
  width: 48px;
  height: 48px;
  line-height: 48px;
  font-size: 18px;
}

/* 3-across grid for subcategory 'rest' */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}
@media (max-width: 560px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* Spec badges under the title */
.spec-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 6px;
}
.spec-badge {
  font-size: 12px;
  color: var(--ink);
  background: #eef2ff;
  border: 1px solid #dbe1ff;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1.2;
}
.card--featured .spec-badge {
  background: #e5e7ff;
  border-color: #cfd7ff;
}

/* ============= Desktop categories dropdown ============= */
.nav-left { display: flex; align-items: center; gap: 10px; }
.dropdown { position: relative; }
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.dropdown-toggle:hover { background: var(--muted); }
.dropdown-toggle:focus { outline: 2px solid #c7d2fe; outline-offset: 2px; }
.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 520px;
  max-width: min(90vw, 900px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.08);
  padding: 14px;
  display: none; /* default hidden */
  z-index: 1000;
}
.dropdown-panel[data-open="true"] { display: block; }
.dropdown-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px 14px;
}
.dropdown-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2);
  border: 1px solid transparent;
}
.dropdown-link:hover {
  background: var(--muted);
  border-color: var(--border);
  color: var(--ink);
}

/* =========================
   Responsive tweaks
   ========================= */

/* Medium screens */
@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* Tablet and below */
@media (max-width: 900px) {
  .header .header-wrap {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .menu-toggle { display: inline-flex; } /* show hamburger */

  /* MOBILE PANEL (fixed, non-scrolling container) */
  .nav {
  position: fixed;
  top: 58px;
  left: 0;
  right: 0;
  z-index: 10000;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);

  display: none;                /* closed by default */
  flex-direction: column;
  gap: 14px;

  padding: 20px 16px 20px;
    height: 90dvh;               /* full height */
    max-height: 90dvh;

    /* ✨ KEY CHANGE: panel no longer scrolls, only the list does */
    overflow: hidden;             /* was overflow-y: auto */
  }
  .nav[data-open="true"] { display: flex; }

  /* hide desktop dropdown in mobile panel */
  .dropdown { display: none; }

  /* Scroll only the category list; search stays visible */
  .nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;

    flex: 1 1 auto;               /* take remaining vertical space */
    min-height: 0;                 /* CRITICAL for flex scrolling in Safari */
    overflow-y: auto;              /* list scrolls if too long */
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile link styling (unchanged) */
  .nav-links a {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--muted);
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    border: 1px solid var(--border);
    transition: background 0.2s, transform 0.08s ease-in-out;
  }
  .nav-links a:hover { background: #e0e7ff; }
  .nav-links a:active { transform: scale(0.98); }

  /* Search area stays visible at the bottom of the drawer */
  .search { width: 100%; }
  .search input { min-width: 0; flex: 1; width: 100%; }

  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .hero p  { font-size: 14px; }

  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

  /* Mobile image box heights (for cards) */
  .card .imgbox { height: 140px; }
  .card--featured .imgbox { height: 180px; }
}

/* Cookie notice banner (brand styled) */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1d4ed8; /* brand blue */
  color: #fff;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10000;
}
.cookie-banner p { margin: 0; padding-right: 12px; }
.cookie-banner a { color: #facc15; text-decoration: underline; }
.cookie-banner button {
  background: #facc15;
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
}
.cookie-banner button:hover { background: #eab308; }

/* =========================
   Contact drawer (sidebar)
   ========================= */
.drawer{
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: block;                /* always in DOM */
  pointer-events: none;          /* ignore clicks when closed */
}
.drawer__panel{
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform .3s ease-in-out;
  padding: 20px;
  overflow: auto;
  border-left: 1px solid var(--border);
}
.drawer__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity .2s ease-in-out;
}
.drawer[data-open="true"]{ pointer-events: auto; }
.drawer[data-open="true"] .drawer__panel{ transform: translateX(0); }
.drawer[data-open="true"] .drawer__backdrop{ opacity: 1; }

.drawer__title{ margin: 0 0 4px; }
.drawer__muted{ color: var(--ink-2); margin: 0 0 14px; font-size: 14px; }
.drawer__close{
  position: absolute; top: 8px; right: 10px;
  border: 0; background: transparent; font-size: 28px; cursor: pointer;
}
.contact-form label{ display:block; margin:10px 0; }
.contact-form label span{ display:block; font-size:13px; color:var(--ink-2); margin-bottom:6px; }
.contact-form input, .contact-form textarea{
  width:100%; padding:10px; border:1px solid var(--border); border-radius:8px;
}
.contact-form .btn{ padding:10px 14px; border:1px solid var(--ink); background:#fff; border-radius:8px; cursor:pointer; }
.drawer__note{ font-size:14px; color:var(--ink-2); margin-top:8px; }
