/* ====================================================
   DEBUGGER PANEL - Engineering Draftsmanship Theme
   Viewport and Layout Diagnostics
   ==================================================== */

:root {
  /* Dynamic viewport units (set by JS for JS-based strategies) */
  --vh: 1vh;
  --vvh: 1vh;
  --sh: 1vh;

  /* Neutral engineering palette */
  --dbg-bg: #f8fafc;               /* panel background wrapper */
  --dbg-panel: #ffffff;            /* inner card */
  --dbg-text: #0f172a;             /* slate-900 */
  --dbg-muted: #475569;            /* slate-600 */
  --dbg-accent: #334155;           /* slate-700 */
  --dbg-accent-2: #1f2937;         /* gray-800 for active state text */
  --dbg-border: #e5e7eb;           /* gray-200 */
  --dbg-border-strong: #cbd5e1;    /* slate-300 */
  --dbg-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
  --dbg-shadow-hover: 0 6px 18px rgba(15, 23, 42, 0.12);
  --dbg-radius: 10px;
  --dbg-radius-sm: 6px;
  --dbg-gap: 16px;
  --dbg-gap-lg: 24px;

  /* Mono for metrics/labels, system for UI */
  --font-ui: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Safe area variables */
:root {
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

/* Panel container */
.debugger-panel {
  background: var(--dbg-panel);
  border: 1px solid var(--dbg-border);
  border-radius: var(--dbg-radius);
  padding: clamp(16px, 4vw, 28px);
  margin: var(--dbg-gap-lg);
  box-shadow: var(--dbg-shadow);
  position: relative;
  overflow: hidden;
}

/* Remove decorative flowers from previous theme */
.debugger-panel::before,
.debugger-panel::after {
  content: none;
}

/* Titles */
.debugger-title {
  font-family: var(--font-ui);
  font-size: clamp(1.25rem, 3.5vw, 1.6rem);
  font-weight: 700;
  color: var(--dbg-text);
  text-align: left;
  margin: 0 0 6px 0;
  letter-spacing: 0.02em;
}

.debugger-subtitle {
  font-family: var(--font-ui);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: var(--dbg-muted);
  text-align: left;
  margin: 0 0 var(--dbg-gap-lg) 0;
  font-style: normal;
}

/* Sections */
.control-section {
  background: #fff;
  border: 1px solid var(--dbg-border);
  border-radius: var(--dbg-radius);
  padding: var(--dbg-gap);
  margin-bottom: var(--dbg-gap);
  box-shadow: var(--dbg-shadow);
  position: relative;
  z-index: 1;
}

.section-title {
  font-family: var(--font-ui);
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 700;
  color: var(--dbg-text);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Select */
.debugger-select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--dbg-border);
  border-radius: var(--dbg-radius-sm);
  padding: 10px 14px;
  background: #fff;
  color: var(--dbg-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: none;
}

.debugger-select:hover {
  border-color: var(--dbg-border-strong);
}

.debugger-select:focus {
  outline: none;
  border-color: var(--dbg-accent);
  box-shadow: 0 0 0 3px rgba(51, 65, 85, 0.15);
}

/* Toggles */
.debugger-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "slider label"
    ". desc";
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  padding: 10px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.debugger-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  grid-area: slider;
  position: relative;
  width: 48px;
  height: 26px;
  background: #e2e8f0; /* slate-200 */
  border: 1px solid var(--dbg-border);
  border-radius: 999px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border: 1px solid var(--dbg-border);
  border-radius: 50%;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.debugger-toggle input:checked + .toggle-slider {
  background: #cbd5e1; /* slate-300 */
  border-color: #94a3b8; /* slate-400 */
}

.debugger-toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
  border-color: #94a3b8;
}

.toggle-label {
  grid-area: label;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--dbg-text);
  user-select: none;
}

.toggle-desc {
  grid-area: desc;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--dbg-muted);
  line-height: 1.3;
}

/* Button Grid */
.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

@media (max-width: 500px) {
  .button-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.debugger-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  border: 1px solid var(--dbg-border);
  border-radius: var(--dbg-radius-sm);
  background: #fff;
  color: var(--dbg-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
  box-shadow: var(--dbg-shadow);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 76px;
}

.debugger-button:hover {
  border-color: var(--dbg-border-strong);
  box-shadow: var(--dbg-shadow-hover);
  transform: translateY(-1px);
}

.debugger-button:active {
  transform: translateY(0);
}

.debugger-button.active {
  background: #eef2f7;
  color: var(--dbg-accent-2);
  border-color: #94a3b8; /* slate-400 */
}

.button-icon {
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1;
}

/* Metrics Section */
.metrics-section {
  background: #f8fafc; /* neutral */
  border-color: var(--dbg-border);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  background: white;
  border: 1px solid var(--dbg-border);
  border-radius: var(--dbg-radius-sm);
  box-shadow: var(--dbg-shadow);
}

.metric-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--dbg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--dbg-text);
}

/* Strategy variants - height targets for the Hero section */
.strategy--css-100svh .Hero {
  min-height: 100svh;
}
.strategy--css-100dvh .Hero {
  min-height: 100dvh;
}
.strategy--css-100lvh .Hero {
  min-height: 100lvh;
}
.strategy--css-100vh .Hero {
  min-height: 100vh;
}

/* -webkit-fill-available requires propagating the height */
.strategy--css-fill-available html,
.strategy--css-fill-available body {
  height: -webkit-fill-available;
}
.strategy--css-fill-available .Hero {
  min-height: -webkit-fill-available;
  /* Fallback for non-webkit */
  min-height: 100dvh;
}

/* JS-driven strategies */
.strategy--js-innerHeight .Hero {
  min-height: calc(var(--vh, 1vh) * 100);
}
.strategy--js-visualViewport .Hero {
  min-height: calc(var(--vvh, 1vh) * 100);
}
.strategy--js-screenHeight .Hero {
  height: calc(var(--sh, 1vh) * 100);
  min-height: 0;
}

/* Apply safe-area insets only when toggled on */
.apply-safe-area .Hero {
  padding-top: var(--safe-area-inset-top);
  padding-bottom: var(--safe-area-inset-bottom);
}

/* Optional: strongest lock - remove from flow and pin to screen */
.fixed-hero .Hero {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--sh, 1vh) * 100);
  z-index: 1;
}

/* Debug overlay for Hero (kept for the Hero Debug tool) */
.debug-hero .Hero,
.debug-hero .Hero div {
  outline: 0.5px solid rgba(185, 28, 28, 0.33); /* red-700 at 33% */
}

.debug-hero .Hero div {
  position: relative;
}

.igdebug-label {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  background: rgba(255, 255, 255, 0.95);
  color: #991b1b; /* red-800 */
  border: 1px solid rgba(185, 28, 28, 0.33);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
  z-index: 2147483647;
  pointer-events: none;
  border-radius: 2px;
  white-space: nowrap;
}

/* Debug overlay for ALL divs (kept for the All Divs tool, restyled) */
.debug-all-divs div {
  outline: 0.5px solid rgba(185, 28, 28, 0.33) !important;
  position: relative;
}

.debug-all-divs div::before {
  content: attr(data-debug-info);
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  background: rgba(255, 255, 255, 0.95);
  color: #991b1b;
  border: 1px solid rgba(185, 28, 28, 0.33);
  font-size: 10px;
  font-family: var(--font-mono);
  line-height: 1.2;
  padding: 2px 4px;
  z-index: 2147483647;
  pointer-events: none;
  border-radius: 2px;
  white-space: nowrap;
  font-weight: 600;
}

.debug-all-divs div::after {
  content: "";
  position: absolute;
  left: 4px;
  top: -2px;
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 3px solid rgba(185, 28, 28, 0.33);
  z-index: 2147483646;
  pointer-events: none;
}

/* Boundaries overlay - global, excludes the debugger itself */
.debug-boundaries * {
  outline: 0.5px solid rgba(185, 28, 28, 0.33); /* 33% opacity, ~0.5px */
}

/* Do not outline the debugger UI */
.debug-boundaries .debugger-panel,
.debug-boundaries .debugger-panel * {
  outline: none !important;
}

/* Labels for all elements under Boundaries mode
   - Do not affect flow (absolute, pointer-events none)
   - Stuck to the border (top-left, translated outside) */
.dbg-labeled {
  position: relative; /* establish containing block for the label */
}

.dbg-labeled::before {
  content: attr(data-debug-name);
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  background: rgba(255, 255, 255, 0.95);
  color: #991b1b; /* red-800 */
  border: 1px solid rgba(185, 28, 28, 0.33);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
  z-index: 2147483647;
  pointer-events: none;
  border-radius: 2px;
  white-space: nowrap;
}

/* Remove previous highlight mode (feature removed) */
/* (intentionally left blank - highlight mode deprecated) */

/* Hide debugger panel (keep debugger.js logic active) */
.debugger-panel {
  display: none !important;
}
