:root {
  --content-max: 1200px;
  --gap: 20px;
  --radius: 8px;

  /* Fallbacks */
  --color-text: #777;
  --color-accent: #007bff;
  --color-surface: #fff;

  /* Sticky header height (used to center hero area) */
  --header-h: 56px;

  /* Category grid sizing */
  --cat-col-pc: 180px;   /* desktop column width (5 cols) */
  --cat-col-mob: 160px;  /* mobile column width (2 cols) */
  --cat-row-h: 60px;     /* fixed tile height ≈ two lines of text */
  --cat-row-h-mobile: 50px;     /* fixed tile height ≈ two lines of text */
}

/* ===== Hero wrapper: centered both axes under sticky header ===== */
.main-wrap {
  /* max-width: var(--content-max); */
  max-width: none;
  margin: 0 auto;
  padding: var(--gap);
  text-align: center;

  display: flex;
  flex-direction: column;
  justify-content: center;                 /* vertical center */
  align-items: center;                     /* horizontal center */

  min-height: calc(100svh - var(--header-h));
}
.main-wrap > *:first-child { margin-top: 0; }

h1 {
  font-size: 3.0rem;
  margin: 0 0 20px;
  color: var(--color-accent);
  cursor: default;
}

/* Ensure header.css doesn't mess with the hero title */
.index-body #mainTitle {
  font-size: 3.0rem;
  margin: 0 0 20px;
  color: var(--color-accent);
  text-align: center;
}

/* Subtitle / description */
.subtitle {
  opacity: 0;
  transition: opacity 0.9s ease;
  margin: 10px 0;
  font-size: 1.5rem;
  color: #777; /* or var(--color-text) */
}

p#description.description {
  font-size: 1.2rem;
  line-height: 1.7rem;
  margin: 20px auto 0;
  max-width: 700px;
  color: #777; /* or var(--color-text) */
  opacity: 0;
  transition: opacity 0.9s ease;
}

/* =========================================================
   Search + area-of-interest button
   ========================================================= */

/* ORIGINAL layout: flex, centered, ? to the right */
.search-form {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;                 /* space between input and ? */
  margin-bottom: 20px;
}

/* ORIGINAL search input look (rect corners, radius token) */
.search-input {
  font-size: 1rem;
  padding: 8px 12px;
  width: 100%;
  width: 480px;   /* was 480px – now wide enough for rotating hints */
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  margin-left: 20px;
}

.search-input::placeholder {
  color: var(--color-text);
  opacity: 0.4;   /* much lighter hint */
}

.search-input:focus {
  border-color: var(--color-text);
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

/* Round question-mark button */
.interest-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-accent);
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.interest-btn:hover {
  background: var(--color-accent);
  color: #000;
  border-color: var(--color-accent);
}

.interest-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* A11y helper */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

/* =========================================================
   CATEGORIES — fixed equal grid, fixed row height (2 lines)
   ========================================================= */

/* Desktop (default): 5 equal columns */
.category-container {
  /* The centering power trio: */
  display: inline-grid;                          /* shrink to content width */
  margin: 0 auto;                                /* center as block */
  align-self: center;                            /* center as flex item */

  grid-template-columns: repeat(5, var(--cat-col-pc));
  grid-auto-rows: var(--cat-row-h);
  gap: 10px;

  background-color: var(--color-surface);
  padding: 0;
}

/* Tile visuals: vertically & horizontally centered text */
.category-container div {
  /* Center content */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  overflow: hidden;
  position: relative;          /* allow tiny number in corner */
  padding-right: 26px;         /* space for the tiny count badge */

  color: var(--color-text);
  background-color: var(--color-bg);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 1.1rem;
  line-height: 1.2;

  /* Desktop font for category labels */
  font-family: "Oswald", system-ui, sans-serif;

  cursor: pointer;
  transition: background-color .2s, border-color .2s, box-shadow .2s, color .2s, transform .05s;
}

/* Tiny count badge in bottom-right corner */
.category-container .cat-count {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--color-muted, #999);
  opacity: 0.7;
}

/* Hover / focus / active / selected */
.category-container div:hover {
  border-color: var(--color-text);
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.category-container div:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.category-container div:active { transform: translateY(0); }
.category-container div[aria-pressed="true"] {
  background-color: color-mix(in srgb, var(--color-accent) 10%, transparent);
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: 600;
}

/* =========================================================
   Interest modal (areas of interest)
   ========================================================= */

/* Root overlay */
.interest-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  align-items: center;
  justify-items: center;
}

/* Hidden state (controlled by JS via [hidden]) */
.interest-modal[hidden] {
  display: none;
}

/* Dark backdrop */
.interest-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

/* Dialog card */
.interest-modal-dialog {
  position: relative;
  z-index: 1001;
  max-width: 640px;
  width: min(640px, 100% - 2rem);
  max-height: min(80vh, 770px);
  overflow: hidden;
  border-radius: 16px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #333);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  padding: 1.5rem 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.interest-modal-dialog h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.25rem;
  font-family: "Oswald", system-ui, sans-serif;
}

.interest-description {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text);
}

/* "Select all" row */
.interest-select-all {
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.interest-select-all label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Grid for the 30 checkboxes */
.interest-grid {
  margin-top: 0.75rem;
  padding: 0.5rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--color-text);
  display: grid;
  grid-template-columns: auto auto;
  /* grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); */
  gap: 0.35rem 0.75rem;
  overflow-y: auto;
}

/* Each category checkbox row */
.interest-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  padding: 0.2rem 0.3rem;
  border-radius: 999px;
}

.interest-item:hover {
  background: rgba(0, 123, 255, 0.08); /* soft accent-ish */
}

.interest-item input[type="checkbox"] {
  accent-color: var(--color-accent);
}

/* Action buttons at bottom */
.interest-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Rely on global .btn styles if they exist (from theme/header),
   but these defaults are safe if not */
.interest-actions .btn {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--color-text);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
}

.interest-actions .btn.primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.interest-actions .btn:hover {
  filter: brightness(1.05);
}

/* =========================================================
   Behaviors & themes
   ========================================================= */

/* Hover behavior for description (PC only) */
@media (min-width: 768px) {
  h1:hover + .search-form + p#description.description { opacity: 1; }
}

/* Dark mode */
[data-theme="dark"] .index-body { background: #1a1a1a; }
[data-theme="dark"] p#description.description { color: #fff; }
[data-theme="dark"] .search-input {
  background: #2a2a2a; color: #fff; border-color: #e67e00;
}
[data-theme="dark"] .search-input:focus {
  border-color: #fff; box-shadow: 0 0 5px rgba(230, 126, 0, 0.3);
}
[data-theme="dark"] .interest-modal-dialog {
  background: #111;
  color: #f5f5f5;
  border: 1px solid #333;
}
[data-theme="dark"] .interest-grid {
  background: rgba(255, 255, 255, 0.02);
  border-color: #333;
}
[data-theme="dark"] .interest-item:hover {
  background: rgba(230, 126, 0, 0.12);
}

/* Modern mode */
[data-theme="modern"] .index-body { background: #182036; }
[data-theme="modern"] p#description.description { color: #fff; }
[data-theme="modern"] .search-input {
  background: #2a2a2a; color: #fff; border-color: #e67e00;
}
[data-theme="modern"] .search-input:focus {
  border-color: #fff; box-shadow: 0 0 5px rgba(230, 126, 0, 0.3);
}
[data-theme="modern"] .interest-modal-dialog {
  background: #151b2e;
  color: #f5f5f5;
  border: 1px solid #2c3654;
}

/* Light mode tweak */
[data-theme="light"] .search-input:focus {
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

/* =========================================================
   Responsive — Mobile: 2 equal columns
   ========================================================= */
@media (max-width: 768px) {

  h1 { font-size: 1.9rem !Important; }

  /* Ensure header.css doesn't mess with the hero title */
  #mainTitle {
    font-size: 1.9rem !Important;
    margin: 0 0 10px;
    color: var(--color-accent);
    text-align: center;
  }

  p#description.description {
    font-size: 1rem;
    max-width: 90%;
    opacity: 1;
  }

  /* Make search row fit small screens nicely */
  .search-form {
    display: flex;             /* ensure flex on mobile */
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 90vw;
    margin: 0 auto 20px;
  }

  .search-input {
    width: 100%;               /* override desktop width: 440px */
    max-width: 100%;
  }

  .interest-btn {
    flex: 0 0 auto;            /* stay snug to the right */
  }

  .category-container {
    grid-template-columns: repeat(2, var(--cat-col-mob));
    grid-auto-rows: var(--cat-row-h-mobile);
  }

  .category-container div {
    padding: 4px 6px;

    /* Mobile-friendly UI font */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !Important;
  }

  .interest-modal-dialog {
    width: calc(100% - 1.5rem);
    padding: 1.25rem 1.25rem 1rem;
  }
  .interest-grid {
    max-height: 45vh;
  }
}

/* High-res small screens */
@media (min-width: 481px) and (max-width: 767px),
       (max-width: 767px) and (min-resolution: 2dppx) {

  h1 { font-size: 1.9rem; }

  p#description.description {
    font-size: 0.9rem;
    line-height: 1rem;
    max-width: 95%;
    opacity: 0.0;
  }
  .query-display { margin-top: 5px; }

  .category-container {
    grid-template-columns: repeat(2, var(--cat-col-mob)) !important;
    grid-auto-rows: var(--cat-row-h-mobile);
  }

  .category-container div {
    padding: 4px 6px;

    /* Mobile-friendly UI font */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  /* Keep search input constrained on high-res small screens too */
  .search-input {
    width: 100%;
    max-width: 100%;
  }
}
