body { scroll-behavior: smooth; }

/* Keep the logo tidy in the navbar */
.navbar-brand img { height: 40px; width: auto; }

/* Footer link hover */
footer .nav-link:hover { text-decoration: underline; }

/* Base: both anchors and the logout button-link */
.navbar .navbar-nav a.nav-link,
.navbar .navbar-nav .btn-link.nav-link {
  position: relative;
  text-decoration: none !important;
}

/* The underline line */
.navbar .navbar-nav a.nav-link::after,
.navbar .navbar-nav .btn-link.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: .2rem;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .2s ease;
}

/* Show underline on hover/focus/active for both */
.navbar .navbar-nav a.nav-link:hover::after,
.navbar .navbar-nav a.nav-link:focus::after,
.navbar .navbar-nav a.nav-link.active::after,
.navbar .navbar-nav .btn-link.nav-link:hover::after,
.navbar .navbar-nav .btn-link.nav-link:focus::after,
.navbar .navbar-nav .btn-link.nav-link:active::after {
  transform: scaleX(1);
}

/* Mobile/collapsed navbar: make underline match text width */
@media (max-width: 991.98px) { /* Bootstrap lg breakpoint */
  .navbar .navbar-nav .nav-link,
  .navbar .navbar-nav .btn-link.nav-link {
    display: inline-block;  /* not full-width */
    padding-left: 0;
    padding-right: 0;
  }

  /* Keep the underline just under the text */
  .navbar .navbar-nav .nav-link::after {
    left: 0;
    right: auto;   /* don't stretch across the full row */
    width: 100%;
  }
}

/* Pretty accordion arrows */
.accordion-button::after { transition: transform .2s ease; }
.accordion-button:not(.collapsed)::after { transform: rotate(-180deg); }

/* Compact manufacturer checkboxes – flow inline inside card */
.card #div_id_manufacturers .form-check {
  display: inline-block;
  margin-right: 1rem;
}

/* Compact extra-display radios – flow inline inside card */
.card #div_id_extra_display .form-check {
  display: inline-block;
  margin-right: 1rem;
}

/* Fade the plot while htmx is loading a new one */
#plot-output.htmx-request { opacity: 0.5; transition: opacity .2s; }

/* ── Blog ── */
.card:hover { box-shadow: 0 .25rem .75rem rgba(0,0,0,.08); transition: box-shadow .2s ease; }
.equation-block { font-size: 1.15em; overflow-x: auto; }
.blog-body img { max-width: 100%; height: auto; }
.blog-tag-toggle { cursor: pointer; transition: background-color .15s ease; }

/* Focus block – callout with left accent border */
.focus-block {
  border-left: 4px solid;
  border-radius: .375rem;
}

/* Code block – subtle container around pre/code */
.code-block pre {
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: .375rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 0;
}
.code-block code {
  font-size: .9em;
}

/* ── Glass Compare ── */
#compare-tray .list-group-item { font-size: 0.85rem; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
#search-results .list-group-item:hover .add-to-compare { opacity: 1; }
#search-results .add-to-compare { opacity: 0.6; transition: opacity .15s; }
.table-compare {
  border-collapse: separate;
  border-spacing: 0;
}
.table-compare th,
.table-compare td {
  border: 1px solid #dee2e6;
  white-space: nowrap;
}
.table-compare th:first-child,
.table-compare td:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
  min-width: 180px;
  box-shadow: 2px 0 4px rgba(0,0,0,.08);
}
.table-compare thead th {
  background: #f8f9fa;
}
.table-compare thead th:first-child {
  background: #f8f9fa;
  z-index: 3;
}

/* Error report chevron rotation */
.error-report-chevron { transition: transform .2s ease; }
[aria-expanded="true"] .error-report-chevron { transform: rotate(180deg); }

/* Compare tray flash animation on add/re-add */
@keyframes tray-flash {
  0%   { background-color: #0d6efd; color: #fff; }
  100% { background-color: transparent; color: inherit; }
}
.tray-flash { animation: tray-flash 0.8s ease-out; }