/* Haptra Official Global Stylesheet — Modern Web Standards & 60fps Motion */

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

:root {
  --haptra-sky: #0284c7;
  --haptra-cyan: #0ea5e9;
  --haptra-indigo: #4f46e5;
  --haptra-purple: #6d28d9;
  --haptra-obsidian: #0f172a;
  --haptra-emerald: #059669;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--haptra-cyan);
  outline-offset: 2px;
}

/* Native <dialog> Scroll Containment */
dialog:modal {
  overscroll-behavior: contain;
}
dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  overflow: hidden;
  overscroll-behavior: contain;
}

/* Adaptive Responsive Site Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
}

.header-inner {
  max-width: 82rem;
  margin-inline: auto;
  padding-inline: 1rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-inner > * {
  flex-shrink: 0;
  white-space: nowrap;
}

.site-header.is-measuring * {
  transition: none !important;
}

.menu-button {
  anchor-name: --menu-button;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border-radius: 9999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
}

.site-menu {
  position: fixed;
  inset: auto;
  inset-block-start: 4.5rem;
  inset-block-start: anchor(--menu-button bottom);
  inset-inline-end: 1rem;
  inline-size: min(88dvw, 24rem);
  max-inline-size: calc(100dvw - 2rem);
  block-size: fit-content;
  max-block-size: calc(100dvh - 6rem);
  margin-block-start: 0.5rem;
  overflow: auto;
  padding: 1rem;
  border-radius: 1.25rem;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  list-style: none;
}

.site-menu a,
.site-menu .dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.65rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.site-menu a:hover,
.site-menu .dropdown-trigger:hover {
  background: #f0f9ff;
  color: #0284c7;
}

.site-menu a[aria-current="page"] {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 800;
  box-shadow: inset 3px 0 0 #0284c7;
}

.dropdown-list {
  list-style: none;
  padding: 0.35rem 0 0.35rem 0.75rem;
  margin: 0;
}

.dropdown-list[hidden] {
  display: none;
}

@supports not selector(:popover-open) {
  [popover]:not(.\:popover-open) {
    display: none;
  }
}

.site-header.is-wide .menu-button {
  display: none;
}

.site-header.is-wide .site-menu {
  position: static;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  inline-size: auto;
  max-inline-size: none;
  block-size: auto;
  max-block-size: none;
  overflow: visible;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.site-header.is-wide .site-menu::backdrop {
  display: none;
}

.site-header.is-wide .site-menu > li > a,
.site-header.is-wide .site-menu .dropdown-trigger {
  width: auto;
  padding: 0.45rem 0.7rem;
  font-size: 0.8125rem;
}

.site-header.is-wide .site-menu a[aria-current="page"] {
  box-shadow: inset 0 -2.5px 0 #0284c7;
  background: #f0f9ff;
}

.site-header.is-wide .dropdown-list[popover] {
  position: absolute;
  position-area: block-end span-inline-end;
  position-try-fallbacks: flip-block, flip-inline;
  inset: auto;
  height: auto;
  inline-size: max-content;
  min-inline-size: 16.5rem;
  margin-block-start: 0.5rem;
  padding: 0.5rem;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.18);
  overflow: visible;
  gap: 0.25rem;
}

@supports not (position-area: block-end) {
  .site-header.is-wide .dropdown-list[popover] {
    position: fixed;
    margin: 0;
  }
}

.site-header.is-wide .dropdown-list::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 100%;
  block-size: 0.65rem;
}

.site-header.is-wide .dropdown-list:not(:is(:popover-open, .\:popover-open)) {
  display: none;
}

.site-header.is-wide .dropdown-list:is(:popover-open, .\:popover-open) {
  display: grid;
}

/* Responsive Data Tables */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  container-type: inline-size;
}

.spec-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  text-align: left;
}

.spec-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #0f172a;
  color: #ffffff;
}

.spec-table th,
.spec-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.spec-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  min-width: 12rem;
  z-index: 1;
}

.spec-table tbody tr:hover td {
  background: #f0f9ff;
}

@container (width < 580px) {
  .spec-table,
  .spec-table thead,
  .spec-table tbody,
  .spec-table tr,
  .spec-table th,
  .spec-table td {
    display: block;
  }

  .spec-table thead {
    display: none;
  }

  .spec-table tr {
    margin-block-end: 0.75rem;
    border-bottom: 2px solid #cbd5e1;
  }

  .spec-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
  }

  .spec-table td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: #0369a1;
    display: inline-block;
    margin-inline-end: 0.35rem;
  }
}

/* Explicit Multi-Stop pH Spectrum Slider */
.ph-spectrum-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.875rem;
  border-radius: 9999px;
  background: linear-gradient(90deg, #e11d48 0%, #f59e0b 25%, #10b981 50%, #0ea5e9 75%, #6d28d9 100%);
  cursor: pointer;
}

.ph-spectrum-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 3px solid #0f172a;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.35);
}

/* 60fps SVG Hydration & Electrolysis Motion (Respects Reduced Motion) */
@keyframes glide-micro {
  0% { transform: translateX(-28px); opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(132px); opacity: 0; }
}

@keyframes bounce-macro {
  0%, 100% { transform: translateX(0px); }
  45% { transform: translateX(48px); }
  55% { transform: translateX(44px); }
}

@keyframes bubble-rise {
  0% { transform: translateY(0px) scale(0.8); opacity: 0; }
  25% { opacity: 0.95; }
  100% { transform: translateY(-76px) scale(1.15); opacity: 0; }
}

@keyframes flow-dash {
  to { stroke-dashoffset: -32; }
}

@media (prefers-reduced-motion: no-preference) {
  .anim-glide-micro { animation: glide-micro 2.8s ease-in-out infinite; }
  .anim-glide-micro-d1 { animation: glide-micro 2.8s ease-in-out 0.9s infinite; }
  .anim-glide-micro-d2 { animation: glide-micro 2.8s ease-in-out 1.8s infinite; }
  .anim-bounce-macro { animation: bounce-macro 2.6s ease-in-out infinite; }
  .anim-bubble-1 { animation: bubble-rise 2.2s ease-out infinite; }
  .anim-bubble-2 { animation: bubble-rise 2.5s ease-out 0.7s infinite; }
  .anim-bubble-3 { animation: bubble-rise 2.0s ease-out 1.3s infinite; }
  .anim-flow-dash { stroke-dasharray: 8 8; animation: flow-dash 0.9s linear infinite; }
}
