/* GarminFans UI: a dark, content-first cinema theme.
 *
 * One token layer (--nf-*) maps onto Bootstrap's --bs-* variables, so pages
 * keep using stock Bootstrap classes and only the tokens change. Red is the
 * single accent: #e50914 on #232323 is 2.5:1, so it is used for CTAs, focus
 * rings and selected states that always carry white text or an icon, never for
 * body copy.
 */

:root,
[data-bs-theme="dark"] {
  --nf-red: #e50914;
  --nf-red-hover: #f6121d;
  --nf-red-active: #b20710;
  --nf-bg: #232323;
  --nf-surface: #2d2d2d;
  --nf-surface-hover: #383838;
  --nf-border: #808080;
  --nf-line: #3d3d3d;
  --nf-text: #ffffff;
  --nf-muted: rgba(255, 255, 255, 0.64);

  --nf-radius-sm: 2px;
  --nf-radius-md: 4px;
  --nf-radius-lg: 8px;
  --nf-radius-xl: 16px;

  --nf-shadow-card: 0 0 5px 0 rgba(128, 128, 128, 0.55);
  --nf-shadow-elevated: 0 0 5px 0 #808080, 0 12px 32px rgba(0, 0, 0, 0.45);

  --nf-fast: 200ms;
  --nf-base: 300ms;
  --nf-slow: 500ms;
  --nf-ease: cubic-bezier(0.4, 0, 0.68, 0.06);

  --bs-body-bg: var(--nf-bg);
  --bs-body-color: var(--nf-text);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 0.875rem;
  --bs-emphasis-color: var(--nf-text);
  --bs-secondary-color: var(--nf-muted);
  --bs-secondary-bg: var(--nf-surface);
  --bs-tertiary-bg: var(--nf-surface);
  --bs-border-color: var(--nf-line);
  --bs-border-color-translucent: rgba(128, 128, 128, 0.28);
  --bs-primary: #e50914;
  --bs-primary-rgb: 229, 9, 20;
  --bs-link-color: var(--nf-text);
  --bs-link-hover-color: var(--nf-red);
  --bs-border-radius: var(--nf-radius-md);
  --bs-border-radius-sm: var(--nf-radius-sm);
  --bs-border-radius-lg: var(--nf-radius-lg);
  --bs-card-bg: var(--nf-surface);
  --bs-card-border-color: var(--nf-line);
  --bs-card-border-radius: var(--nf-radius-md);
  --bs-dropdown-bg: var(--nf-surface);
  --bs-dropdown-link-hover-bg: var(--nf-surface-hover);
  --bs-dropdown-link-active-bg: var(--nf-red);
  --bs-focus-ring-color: rgba(229, 9, 20, 0.35);
  --bs-form-control-bg: #1c1c1c;
  --bs-form-select-bg: #1c1c1c;
}

body {
  letter-spacing: 0.005em;
}

a {
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--nf-red);
  outline-offset: 2px;
}

/* --- typography ------------------------------------------------------- */

.site-title,
.display-title {
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nf-muted);
}

.filter-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nf-muted);
}

.meta {
  font-size: 0.75rem;
  color: var(--nf-muted);
}

/* --- navigation ------------------------------------------------------- */

.site-nav {
  background: rgba(35, 35, 35, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--nf-line);
}

.site-nav .navbar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--nf-red);
}

.site-nav .navbar-brand:hover,
.site-nav .navbar-brand:focus {
  color: var(--nf-red-hover);
}

.site-nav-links .nav-link {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--nf-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--nf-fast) var(--nf-ease),
    border-color var(--nf-fast) var(--nf-ease);
}

.site-nav-links .nav-link:hover,
.site-nav-links .nav-link.active {
  color: var(--nf-text);
  border-bottom-color: var(--nf-red);
}

/* Separates the runs of tool links inside the same menu. */
.site-nav-links .nav-divider {
  padding-left: 0.75rem;
  margin-left: 0.5rem;
  border-left: 1px solid var(--nf-line);
}

.site-footer {
  border-top: 1px solid var(--nf-line);
  color: var(--nf-muted);
  font-size: 0.75rem;
}

/* --- language switcher ------------------------------------------------ */

/* <details> keeps the menu usable without JavaScript. */
.lang-switch > summary {
  list-style: none;
  cursor: pointer;
  border-color: rgba(128, 128, 128, 0.45);
  color: var(--nf-text);
  transition: border-color var(--nf-fast) var(--nf-ease),
    color var(--nf-fast) var(--nf-ease);
}

.lang-switch > summary::-webkit-details-marker {
  display: none;
}

.lang-switch > summary:hover,
.lang-switch[open] > summary {
  border-color: var(--nf-red);
  color: var(--nf-red);
}

.lang-switch .dropdown-menu {
  max-height: 60vh;
  overflow: auto;
  border-color: var(--nf-line);
  box-shadow: var(--nf-shadow-elevated);
  z-index: 1040;
}

.lang-switch .dropdown-item {
  font-size: 0.8125rem;
}

/* --- tools menu ------------------------------------------------------- */

/* Same <details> trick as the language switcher: the tools that did not stay in
 * the front row still open with JavaScript off. */
.nav-switch > summary {
  list-style: none;
  cursor: pointer;
}

.nav-switch > summary::-webkit-details-marker {
  display: none;
}

.nav-switch[open] > summary {
  color: var(--nf-text);
  border-bottom-color: var(--nf-red);
}

.nav-switch .dropdown-menu {
  min-width: 12rem;
  border-color: var(--nf-line);
  box-shadow: var(--nf-shadow-elevated);
  z-index: 1040;
}

.nav-switch .dropdown-header {
  color: var(--nf-muted);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-switch .dropdown-item {
  font-size: 0.8125rem;
}

/* Bootstrap makes a dropdown inside `.navbar-nav` static, which is right in the
 * collapsed (small screen) menu: the list pushes the page down instead of
 * floating over it. In the expanded row it would widen the bar and wrap, so the
 * menu overlays there, anchored to its own item. 1200px is `navbar-expand-xl`. */
@media (min-width: 1200px) {
  .nav-switch {
    position: relative;
  }

  .nav-switch .dropdown-menu {
    position: absolute;
    inset-inline-start: 0;
    top: 100%;
  }
}

/* --- buttons ---------------------------------------------------------- */

.btn {
  --bs-btn-font-size: 0.8125rem;
  --bs-btn-font-weight: 600;
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 1rem;
  --bs-btn-border-radius: var(--nf-radius-md);
  min-height: 2.5rem;
  transition: background-color var(--nf-fast) var(--nf-ease),
    border-color var(--nf-fast) var(--nf-ease), color var(--nf-fast) var(--nf-ease),
    transform var(--nf-fast) var(--nf-ease);
}

.btn-sm {
  --bs-btn-padding-y: 0.3rem;
  --bs-btn-padding-x: 0.7rem;
  min-height: 2rem;
}

.btn-primary {
  --bs-btn-bg: var(--nf-red);
  --bs-btn-border-color: var(--nf-red);
  --bs-btn-color: #ffffff;
  --bs-btn-hover-bg: var(--nf-red-hover);
  --bs-btn-hover-border-color: var(--nf-red-hover);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-active-bg: var(--nf-red-active);
  --bs-btn-active-border-color: var(--nf-red-active);
  --bs-btn-active-color: #ffffff;
  --bs-btn-disabled-bg: #6b0509;
  --bs-btn-disabled-border-color: #6b0509;
}

.btn-outline-secondary {
  --bs-btn-color: var(--nf-text);
  --bs-btn-border-color: rgba(128, 128, 128, 0.6);
  --bs-btn-hover-bg: var(--nf-surface-hover);
  --bs-btn-hover-border-color: var(--nf-text);
  --bs-btn-hover-color: var(--nf-text);
  --bs-btn-active-bg: var(--nf-surface-hover);
  --bs-btn-active-border-color: var(--nf-text);
}

/* --- forms ------------------------------------------------------------ */

.form-control,
.form-select {
  background-color: #1c1c1c;
  border-color: rgba(128, 128, 128, 0.45);
  color: var(--nf-text);
  transition: border-color var(--nf-fast) var(--nf-ease),
    box-shadow var(--nf-fast) var(--nf-ease);
}

.form-control::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.form-control:focus,
.form-select:focus {
  background-color: #1c1c1c;
  border-color: var(--nf-red);
  color: var(--nf-text);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.3);
}

/* --- surfaces and cards ----------------------------------------------- */

.panel {
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  border-radius: var(--nf-radius-lg);
}

.stat-card {
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  border-radius: var(--nf-radius-md);
  padding: 1rem 1.125rem;
}

.stat-card .stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nf-muted);
}

.stat-card .stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
}

.app-card {
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  border-radius: var(--nf-radius-md);
  overflow: hidden;
  transition: transform var(--nf-fast) var(--nf-ease),
    box-shadow var(--nf-base) var(--nf-ease), border-color var(--nf-fast) var(--nf-ease);
}

.app-card:hover,
.app-card:focus-within {
  transform: translateY(-3px);
  border-color: var(--nf-red);
  box-shadow: var(--nf-shadow-card);
}

.app-card-poster {
  display: block;
  background: #191919;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.app-card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--nf-base) var(--nf-ease);
}

.app-card:hover .app-card-poster img {
  transform: scale(1.04);
}

.app-card .card-body {
  padding: 0.75rem 0.875rem 0.875rem;
}

.app-card-heading {
  margin: 0;
}

.app-card-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--nf-text);
  transition: color var(--nf-fast) var(--nf-ease);
}

.app-card-title:hover {
  color: var(--nf-red);
}

.app-card-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  color: var(--nf-muted);
}

/* Six columns leave ~190px per card: a stat must wrap as a whole, not mid-phrase. */
.app-card-stats > span {
  white-space: nowrap;
}

/* --- filter bar --------------------------------------------------------- */
/* Controls pack from the left and the keyword field takes the leftover width;
   narrow viewports wrap them instead of squeezing six selects into one row. */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.filter-field {
  flex: 0 1 10rem;
  min-width: 0;
}

.filter-field-search {
  flex: 1 1 12rem;
  min-width: 0;
}

.filter-field-device {
  flex: 0 1 11rem;
  min-width: 0;
}

.filter-field-narrow {
  flex: 0 1 4.5rem;
  min-width: 0;
}

/* Inline filter for the long option lists; small enough to sit on the label row
   so every control in the bar keeps the same height. */
.filter-input {
  width: 6.5rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.6875rem;
  color: var(--nf-text);
  background: transparent;
  border: 1px solid var(--nf-line);
  border-radius: var(--nf-radius-sm);
}

.filter-input:focus {
  border-color: var(--nf-red);
  outline: none;
}

/* --- result grid -------------------------------------------------------- */
/* Density is the visitor's choice (`?cols=`, 2-6, capped server-side) and only
   applies where a card can still hold a two-line title: narrow screens stay at
   two columns whatever the parameter says. The count is a class, not a custom
   property: an empty or invalid custom property would silently collapse the grid
   to a single column, while an unknown class falls back to the base layout. */
.app-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 992px) {
  .app-grid {
    gap: 1.25rem;
  }

  .app-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .app-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .app-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Grid items default to min-content, which lets a long title widen its column. */
.app-grid > * {
  min-width: 0;
}

.app-grid-empty {
  grid-column: 1 / -1;
}

.chip {
  display: inline-block;
  padding: 0.125rem 0.4rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: var(--nf-radius-sm);
  border: 1px solid rgba(128, 128, 128, 0.5);
  color: var(--nf-text);
  white-space: nowrap;
}

.chip-paid {
  background: var(--nf-red);
  border-color: var(--nf-red);
  color: #ffffff;
}

.chip-free {
  background: rgba(255, 255, 255, 0.1);
}

.chip-filter {
  transition: background-color var(--nf-fast) var(--nf-ease),
    border-color var(--nf-fast) var(--nf-ease);
}

.chip-filter:hover {
  border-color: var(--nf-text);
  color: var(--nf-text);
}

.chip-filter.selected {
  background: var(--nf-red);
  border-color: var(--nf-red);
  color: #ffffff;
}

/* --- tables ----------------------------------------------------------- */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--nf-text);
  --bs-table-border-color: var(--nf-line);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
  font-size: 0.8125rem;
}

.table thead th {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nf-muted);
  border-bottom-color: rgba(128, 128, 128, 0.45);
}

.table > :not(caption) > * > * {
  padding: 0.55rem 0.6rem;
}

/* --- detail page ------------------------------------------------------ */

.app-hero {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.app-hero-icon {
  flex: 0 0 auto;
  width: 6rem;
  height: 6rem;
  border-radius: var(--nf-radius-lg);
  overflow: hidden;
  background: #191919;
  border: 1px solid var(--nf-line);
}

.app-hero-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.definition-list dt {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nf-muted);
  padding-top: 0.4rem;
}

.definition-list dd {
  padding-top: 0.4rem;
  margin-bottom: 0.4rem;
}

.text-pre-wrap {
  white-space: pre-wrap;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.86);
}

.screenshot-thumb {
  height: 260px;
  width: auto;
  flex: 0 0 auto;
}

/* --- small helpers ---------------------------------------------------- */

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sparkline {
  width: 100%;
  height: 48px;
}

.sparkline polyline {
  fill: none;
  stroke: var(--nf-red);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.sticky-lg-top {
  top: 5rem;
  z-index: 1;
}

/* htmx scrolls the swapped panel to the top; keep it clear of the sticky nav. */
#catalog-panel {
  scroll-margin-top: 5.5rem;
}

.empty-state {
  border: 1px dashed rgba(128, 128, 128, 0.4);
  border-radius: var(--nf-radius-lg);
  padding: 2rem;
  text-align: center;
  color: var(--nf-muted);
}

@media (max-width: 991.98px) {
  .screenshot-thumb {
    height: 180px;
  }

  .app-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .app-card:hover {
    transform: none;
  }
}

/* Tool pages: a link inside prose has to be distinguishable without relying on
   colour alone (Lighthouse link-in-text-block), and the FAQ summaries are touch
   targets that need the 24px minimum height. */
.tool-page p a,
.tool-page li a {
  text-decoration: underline;
}

.tool-page details summary {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.error-page {
  max-width: 720px;
}

.error-status {
  font-size: clamp(4rem, 12vw, 6rem);
  font-weight: 800;
  line-height: 1;
  color: var(--nf-muted);
}
