/* Header & Brand Logo Containment Guards */
header img.brand-logo,
.header-inner img.brand-logo,
.brand img.brand-logo,
img.brand-logo {
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  min-width: 40px;
  min-height: 40px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

header .brand,
.header-inner .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  text-decoration: none;
}

header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

header .main-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Handgun Size & Spec Comparison Tool - Dark Tactical Aesthetic */
.compare-page {
  padding: 2.25rem 0 4rem;
  color: #e6edf3;
}

.compare-hero {
  text-align: center;
  margin-bottom: 1.75rem;
}

.eyebrow-badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(212, 168, 67, 0.14);
  color: #e5b84b;
  border: 1px solid rgba(212, 168, 67, 0.35);
  margin-bottom: 0.65rem;
}

.compare-hero h1 {
  font-size: clamp(1.55rem, 2.8vw, 2.3rem);
  font-weight: 800;
  color: #ffffff;
  margin: 0.25rem 0 0.6rem;
}

.hero-sub {
  max-width: 760px;
  margin: 0 auto;
  color: #9fb0c3;
  font-size: 0.98rem;
  line-height: 1.55;
}

/* Selector Bar */
.selector-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: end;
  background: #131922;
  border: 1px solid #263242;
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

.selector-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9fb0c3;
  margin-bottom: 0.45rem;
}

.select-row {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 0.6rem;
}

.select-row select {
  width: 100%;
  background: #0d1219;
  color: #f3f6fa;
  border: 1px solid #303f54;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease;
}

.select-row select:hover,
.select-row select:focus {
  border-color: #e5b84b;
  outline: none;
}

.swap-btn {
  height: 42px;
  width: 46px;
  border-radius: 8px;
  border: 1px solid #384961;
  background: #1c2635;
  color: #ffffff;
  font-size: 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.swap-btn:hover {
  background: #e5b84b;
  color: #0d1219;
  border-color: #e5b84b;
}

/* View Tabs & Toolbar */
.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.view-tabs {
  display: inline-flex;
  background: #131922;
  border: 1px solid #2b384b;
  border-radius: 8px;
  overflow: hidden;
}

.view-tab {
  background: transparent;
  color: #c5d1de;
  border: none;
  border-right: 1px solid #2b384b;
  padding: 0.58rem 1.05rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.view-tab:last-child {
  border-right: none;
}

.view-tab:hover {
  background: #1d2736;
  color: #ffffff;
}

.view-tab.active {
  background: #e5b84b;
  color: #0d1219;
  font-weight: 700;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.grid-unit-note {
  font-size: 0.84rem;
  color: #9fb0c3;
}

.download-btn {
  background: #1c2635;
  color: #f3f6fa;
  border: 1px solid #35465e;
  border-radius: 7px;
  padding: 0.5rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.download-btn:hover {
  border-color: #e5b84b;
  color: #e5b84b;
}

/* White Precision Ruler Stage */
.grid-stage-wrapper {
  background: #ffffff;
  border: 1px solid #2d3a4d;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  margin-bottom: 2rem;
}

.grid-stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  height: 580px;
  margin: 0 auto;
  background: #ffffff;
  overflow: hidden;
}

#rulerCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.gun-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.gun-item {
  position: absolute;
  transform-origin: center center;
  transition: all 0.22s ease;
}

.gun-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.stage-corner-label {
  position: absolute;
  top: 10px;
  z-index: 10;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cbd5e1;
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  pointer-events: none;
  max-width: 44%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-corner-label.left-label {
  left: 14px;
  text-align: left;
}

.stage-corner-label.right-label {
  right: 14px;
  text-align: right;
}

.delta-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  background: #f1f5f9;
  border-top: 1px solid #cbd5e1;
  color: #0f172a;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.delta-strip span strong {
  color: #020617;
}

/* Specs Table */
.specs-panel,
.analysis-panel {
  background: #131922;
  border: 1px solid #263242;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

.panel-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  color: #ffffff;
}

.panel-header p {
  margin: 0 0 1.15rem;
  color: #9fb0c3;
  font-size: 0.92rem;
}

.table-scroll {
  overflow-x: auto;
}

.specs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.specs-table th,
.specs-table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid #222d3c;
}

.specs-table th {
  background: #0e131b;
  color: #e5b84b;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.specs-table td:first-child {
  font-weight: 600;
  color: #9fb0c3;
  width: 22%;
}

.specs-table td:nth-child(2),
.specs-table td:nth-child(3) {
  color: #f8fafc;
  font-weight: 600;
  width: 26%;
}

.specs-table td:nth-child(4) {
  color: #cbd5e1;
  font-size: 0.87rem;
}

.specs-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Detailed Editorial Comparison & Pros/Cons */
.editorial-summary {
  background: #0e131b;
  border-left: 4px solid #e5b84b;
  border-radius: 8px;
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.35rem;
  line-height: 1.65;
  color: #dbe4ee;
}

.editorial-summary h3 {
  margin: 0 0 0.55rem;
  font-size: 1.08rem;
  color: #ffffff;
}

.editorial-summary p {
  margin: 0 0 0.75rem;
}

.editorial-summary p:last-child {
  margin-bottom: 0;
}

.pros-cons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.35rem;
}

.pc-card {
  background: #0e131b;
  border: 1px solid #263242;
  border-radius: 10px;
  padding: 1.2rem;
}

.pc-card h3 {
  margin: 0 0 0.25rem;
  color: #ffffff;
  font-size: 1.12rem;
}

.pc-role-tag {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  color: #e5b84b;
  margin-bottom: 0.85rem;
}

.pc-card h4 {
  margin: 0.75rem 0 0.45rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pc-card h4.pros-title {
  color: #4ade80;
}

.pc-card h4.cons-title {
  color: #f87171;
}

.pc-card ul {
  margin: 0;
  padding-left: 1.15rem;
  color: #cbd5e1;
  font-size: 0.91rem;
  line-height: 1.5;
}

.pc-card li {
  margin-bottom: 0.35rem;
}

.verdict-box {
  background: rgba(229, 184, 75, 0.08);
  border: 1px solid rgba(229, 184, 75, 0.32);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  color: #f1f5f9;
  line-height: 1.6;
}

.verdict-box strong {
  color: #e5b84b;
}

@media (max-width: 820px) {
  .selector-bar {
    grid-template-columns: 1fr;
  }
  .swap-btn {
    width: 100%;
    height: 38px;
  }
  .pros-cons-grid {
    grid-template-columns: 1fr;
  }
  .grid-stage {
    height: 440px;
  }
}

/* Mobile Menu & Viewport Containment Guards */
@media (max-width: 768px) {
  header .main-nav:not(.open) {
    display: none !important;
  }
  header .main-nav.open {
    display: flex !important;
  }
  .compare-page {
    overflow-x: hidden;
  }
  .grid-stage-wrapper {
    width: 100%;
    overflow-x: hidden;
  }
  .grid-stage {
    width: 100%;
    height: auto !important;
    aspect-ratio: 1100 / 580;
    min-height: 240px;
  }
}
