/* Category page v2 - docs/design/pages-h/W1_Category.html (desktop) and W1_Category_m.html (phones), visual system H.
   Depends on tokens.css + components.css. Phones (<= 900px): the list head is the sticky top bar, filters are a
   bottom sheet (#cg-filters, opened by :target or by Scripts/v2/category.js), and a bottom tab bar replaces the header. */

/* ---- Category tab bar ------------------------------------------------------------------------------- */
.cg-cats { background: var(--ground); border-bottom: 1px solid var(--border); }
.cg-cats__in { display: flex; align-items: center; gap: 16px; }
.cg-cats__list { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.cg-cats__list::-webkit-scrollbar { display: none; }
.cg-body a.cg-cat { flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 76px; padding: 12px 14px 10px;
  border-bottom: 3px solid transparent; color: var(--ink-caption); font-size: 14px; font-weight: var(--w-strong); }
.cg-body a.cg-cat:hover { color: var(--ink); border-bottom-color: var(--border); }
.cg-body a.cg-cat[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }
.cg-body a.cg-mapview { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--radius-pill);
  background: var(--surface-soft); color: var(--ink); font-size: 15px; font-weight: var(--w-strong); white-space: nowrap; }
.cg-body a.cg-mapview:hover { background: var(--surface-warm-strong); color: var(--ink); }

/* ---- Page grid: filters (3/12) | list (9/12) -------------------------------------------------------- */
.cg-catpage { display: flex; flex-direction: column; gap: 22px; padding-block: 18px 64px; }
.cg-catgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 32px; align-items: start; }

/* ---- Filters ----------------------------------------------------------------------------------------- */
.cg-filters { grid-column: span 3; position: sticky; top: 20px; }
.cg-filters__backdrop, .cg-filters__x { display: none; }
.cg-filters__panel { display: flex; flex-direction: column; gap: 22px; }
.cg-filters__form { display: flex; flex-direction: column; gap: 22px; }
.cg-fhead { display: flex; align-items: baseline; gap: 12px; }
.cg-fhead h2 { flex: 1; font: italic var(--w-regular) 32px/1 var(--font-display); }
.cg-body .cg-fhead > a:not(.cg-btn) { font-size: 14px; font-weight: var(--w-strong); display: inline-flex; align-items: center; min-height: 44px; }
.cg-fgroup { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cg-fgroup legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: var(--w-strong); color: var(--ink); }
.cg-check { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 15px; cursor: pointer; }
.cg-check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.cg-check__n { margin-left: auto; color: var(--ink-caption); font-size: 13px; font-weight: var(--w-strong); }
.cg-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-pill { position: relative; cursor: pointer; }
.cg-pill span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--radius-pill); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; white-space: nowrap; }
.cg-pill:hover span { border-color: var(--ink-caption); }
.cg-pill input:checked + span { border-color: var(--ink); background: var(--surface-warm-strong); font-weight: var(--w-strong); }
.cg-pill input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.cg-fnote { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-caption); }
.cg-filters__apply .cg-btn { width: 100%; height: 46px; font-size: 15px; }
body.cg-js .cg-filters__apply { display: none; }
.cg-safe { padding: 18px 20px; border-radius: var(--radius-l); background: var(--warn-tint); color: var(--warn); display: flex; flex-direction: column; gap: 8px; }
.cg-safe__h { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.cg-safe ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.55; }
.cg-body .cg-safe a { color: var(--warn); font-weight: var(--w-strong); text-decoration: underline; text-decoration-color: rgba(122, 67, 0, .35); }

/* ---- List column ------------------------------------------------------------------------------------- */
.cg-list { grid-column: span 9; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cg-lhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.cg-lhead__round, .cg-lhead__sub { display: none !important; }
.cg-lhead__title { min-width: 0; }
.cg-lhead__h { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.cg-catpage h1 { font: italic var(--w-regular) 50px/1 var(--font-display); letter-spacing: -.015em; }
.cg-lhead__n { font: var(--w-strong) 18px/1 var(--font-sans); color: var(--ink-caption); white-space: nowrap; }
.cg-sortsel { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: var(--w-strong); color: var(--ink-caption); white-space: nowrap; }
.cg-sortsel select { height: 44px; padding: 0 14px; border-radius: var(--radius-pill); border: 1.5px solid var(--border); background: var(--surface);
  font: var(--w-strong) 14px var(--font-sans); color: var(--ink); cursor: pointer; }
.cg-fbar { display: none; }
.cg-catintro { margin: 0; max-width: 760px; font-size: 16px; line-height: 1.6; color: var(--ink-muted); }
.cg-catintro a { font-weight: var(--w-strong); }
.cg-status { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 14px; color: var(--ink-caption); }
.cg-fchip { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 12px; border-radius: var(--radius-pill); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: var(--w-strong); }
.cg-fchip--all { padding-right: 12px; }
.cg-body .cg-fchip a { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; color: var(--ink-caption); font-size: 17px; line-height: 1; }
.cg-body .cg-fchip a:hover { background: var(--surface-soft); color: var(--ink); }

/* ---- Cards ------------------------------------------------------------------------------------------- */
.cg-cards { display: flex; flex-direction: column; gap: 16px; }
.cg-body a.cg-ccard { display: flex; gap: 20px; padding: 14px; border-radius: var(--radius-l); background: var(--surface); color: var(--ink); }
.cg-body a.cg-ccard:hover { color: var(--ink); box-shadow: 0 0 0 1.5px var(--border); }
.cg-ccard:hover .cg-ccard__name { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.cg-ccard__media { position: relative; flex: none; display: block; width: 200px; height: 150px; border-radius: 18px; overflow: hidden; background: var(--surface-soft); }
.cg-ccard__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cg-ccard__media--none { display: flex; align-items: center; justify-content: center; color: var(--ink-caption); background: var(--surface-warm); }
.cg-ccard__body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cg-ccard__top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; }
.cg-ccard__name { font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.cg-ccard__where { font-size: 14px; color: var(--ink-caption); }
.cg-ccard__text { font-size: 15px; line-height: 1.55; color: var(--ink-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cg-ccard__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-tag--warn { background: var(--warn-tint); color: var(--warn); }
.cg-ccard__meta { margin-top: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--ink-caption); }
.cg-ccard__meta > span { white-space: nowrap; }
.cg-fresh { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: var(--radius-pill); background: var(--live-tint); color: var(--on-live); font-weight: var(--w-strong); }
.cg-fresh--old { background: var(--warn-tint); color: var(--warn); }
.cg-fresh--plain { background: var(--surface-warm); color: var(--ink-muted); }
.cg-body .cg-ccard__meta .cg-ccard__q { flex: 1 1 100%; white-space: normal; font-size: 14px; color: var(--ink-muted); }
.cg-ccard__q b { color: var(--ink); }
.cg-ccard__qdot { display: none; }

/* In-list extras after the 3rd card: the Sponsored strip (and on phones the Safe cruising strip). */
.cg-cat-spons .cg-sponsored__creative { min-height: 0; }
.cg-safestrip { display: none; }

.cg-empty-list { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 22px 24px; border-radius: var(--radius-l); background: var(--surface); }
.cg-empty-list p { margin: 0; font-size: 16px; }

/* ---- Pager + Add a spot ------------------------------------------------------------------------------ */
.cg-pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px 18px 24px; border-radius: var(--radius-l); background: var(--surface); }
.cg-pager__tx { flex: 1 1 280px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cg-pager__tx strong { font-size: 16px; }
.cg-pager__tx > span { font-size: 14px; color: var(--ink-muted); }
.cg-pager__ctl { flex: none; max-width: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cg-body .cg-pager__more { height: 44px; font-size: 15px; }
.cg-pages { display: flex; flex-wrap: wrap; gap: 2px; }
.cg-pg--gap { width: 24px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-caption); font-size: 15px; }
.cg-body a.cg-pg { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); font-size: 15px; }
.cg-body a.cg-pg:hover { background: var(--surface-soft); color: var(--ink); }
.cg-body a.cg-pg[aria-current] { background: var(--surface-warm-strong); box-shadow: inset 0 0 0 1.5px var(--ink); font-weight: var(--w-strong); }
.cg-addspot { display: flex; align-items: center; gap: 16px; padding: 18px 18px 18px 20px; border-radius: var(--radius-l); background: var(--surface-warm-strong); }
.cg-addspot__ic { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.cg-addspot__tx { flex: 1; font-size: 15px; line-height: 1.5; color: var(--ink-muted); min-width: 0; }
.cg-addspot__tx strong { color: var(--ink); font-size: 17px; }
.cg-addspot .cg-btn { flex: none; }

.cg-tabs { display: none; }

@media (max-width: 1180px) and (min-width: 901px) {
  .cg-catpage h1 { font-size: 44px; }
  .cg-catgrid { gap: 24px; }
  .cg-filters { grid-column: span 4; }
  .cg-list { grid-column: span 8; }
  .cg-ccard__media { width: 160px; height: 140px; }
}

/* ---- Phones (W1_Category_m) ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
  body.cg-page-category .cg-top, .cg-cats { display: none; }
  .cg-catpage { padding-block: 0 24px; gap: 12px; }
  .cg-catpage > .cg-crumbs { display: none; }
  .cg-catgrid { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .cg-fhead h2:focus { outline: none; }
  .cg-list { gap: 12px; }

  /* Top bar: back · city/country over the H1 + count · map */
  .cg-lhead { position: sticky; top: 0; z-index: 900; flex-wrap: nowrap; align-items: center; gap: 10px; margin-inline: calc(-1 * var(--gutter));
    padding: 12px var(--gutter); padding-top: calc(12px + env(safe-area-inset-top, 0px)); background: var(--surface); border-radius: 0 0 var(--radius-l) var(--radius-l);
    box-shadow: 0 8px 24px -14px rgba(61, 15, 36, .25); }
  .cg-lhead__round { display: inline-flex !important; }
  .cg-lhead__sub { display: block !important; margin: 0 0 2px; font-size: 13px; font-weight: var(--w-strong); color: var(--ink-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cg-lhead__title { flex: 1; }
  .cg-lhead__h { display: block; }
  .cg-catpage h1 { display: inline; font-size: 26px; line-height: 1.05; }
  .cg-lhead__n { font-size: 14px; margin-left: 6px; }
  .cg-sortsel { display: none; }

  /* Filter chips, scrolling sideways */
  .cg-fbar { display: flex; gap: 6px; overflow-x: auto; overflow-y: visible; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 2px; scrollbar-width: none; }
  .cg-fbar::-webkit-scrollbar { display: none; }
  .cg-fb, .cg-body a.cg-fb { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border-radius: var(--radius-pill);
    border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); font-size: 14px; white-space: nowrap; cursor: pointer; list-style: none; }
  .cg-fb::-webkit-details-marker { display: none; }
  .cg-fb[aria-pressed="true"], .cg-body a.cg-fb[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-warm-strong); font-weight: var(--w-strong); }
  .cg-fbmenu { flex: none; position: static; }
  .cg-fbmenu__panel { position: absolute; z-index: 950; margin-top: 6px; min-width: 210px; padding: 6px; border-radius: var(--radius-m); background: var(--surface); box-shadow: var(--shadow-card); display: flex; flex-direction: column; }
  .cg-body .cg-fbmenu__panel a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--radius-s); color: var(--ink); }
  .cg-body .cg-fbmenu__panel a[aria-current] { background: var(--surface-soft); font-weight: var(--w-strong); }

  .cg-catintro { font-size: 15px; line-height: 1.5; }
  .cg-body .cg-catintro a { display: inline-block; padding: 12px 0; margin: -12px 0; }
  .cg-status { font-size: 13px; gap: 8px; }
  .cg-body .cg-fchip a { width: 40px; height: 40px; margin: -6px -2px -6px 0; }

  /* Cards: 80 x 116 media, compact text */
  .cg-cards { gap: 12px; }
  .cg-body a.cg-ccard { gap: 10px; padding: 8px 10px 8px 8px; border-radius: 22px; }
  .cg-ccard__media { width: 80px; height: 116px; border-radius: 16px; }
  .cg-ccard__body { gap: 4px; }
  .cg-ccard__top { display: flex; flex-direction: column; gap: 0; }
  .cg-ccard__name { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .cg-ccard__where { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .cg-ccard__text { font-size: 14px; line-height: 1.4; }
  .cg-ccard__tags { gap: 4px; }
  .cg-ccard__tags .cg-tag { padding: 1px 7px; }
  .cg-ccard__tags .cg-tag:nth-child(n+3) { display: none; }
  .cg-ccard__tags .cg-tag--warn { display: inline-flex !important; }
  .cg-ccard__meta { gap: 2px 4px; margin-top: 0; }
  .cg-fresh { padding: 0; background: none; gap: 3px; }
  .cg-fresh--old { padding: 0 8px; background: var(--warn-tint); }
  .cg-fresh--plain { background: none; color: var(--ink-caption); font-weight: var(--w-regular); }
  .cg-body .cg-ccard__meta .cg-ccard__q { flex: none; white-space: nowrap; font-size: 13px; color: var(--ink-caption); }
  .cg-ccard__qtext { display: none; }
  .cg-ccard__qdot { display: inline; }

  .cg-safestrip { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 22px; background: var(--warn-tint); color: var(--warn); font-size: 14px; line-height: 1.45; }
  .cg-safestrip .cg-icon { flex: none; }

  .cg-pager { padding: 16px; gap: 12px; }
  .cg-pager__ctl { width: 100%; justify-content: space-between; }
  .cg-body .cg-pager__more { flex: 1 1 auto; }
  .cg-addspot { flex-wrap: wrap; padding: 16px; }
  .cg-addspot .cg-btn { width: 100%; }

  /* Filters: a bottom sheet over the page */
  .cg-filters { display: none; position: fixed; inset: 0; z-index: 2500; }
  .cg-filters:target, .cg-filters.is-open { display: block; }
  .cg-body a.cg-filters__backdrop { display: block; position: absolute; inset: 0; background: rgba(40, 8, 24, .55); }
  .cg-filters__panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; padding: 18px var(--gutter) calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; background: var(--surface); box-shadow: 0 -14px 40px -10px rgba(40, 8, 24, .45); }
  .cg-filters__x { display: inline-flex; }
  .cg-fhead h2 { font-size: 28px; }
  .cg-check { min-height: 44px; }
  .cg-pill span { height: 44px; }
  body.cg-js .cg-filters__apply { display: block; position: sticky; bottom: 0; padding-top: 8px; background: var(--surface); }
  .cg-filters .cg-safe { display: none; }
  body.cg-sheet-open { overflow: hidden; }

  /* Bottom tab bar */
  .cg-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    padding: 6px 8px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-radius: var(--radius-l) var(--radius-l) 0 0; box-shadow: 0 -8px 24px -10px rgba(61, 15, 36, .25); }
  .cg-body .cg-tabs a, .cg-tabs button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px;
    border: 0; background: none; padding: 0; color: var(--ink-caption); font-size: 13px; font-weight: var(--w-strong); }
  body.cg-page-category .cg-footer .cg-wrap { padding-bottom: calc(24px + 76px + env(safe-area-inset-bottom, 0px)); }
  body.cg-gate-open .cg-tabs, body.cg-sheet-open .cg-tabs { display: none; }
}
