:root {
  --page-max-width: 1000px;
  --text-color: #0f172a; /* slate-900 */
  --muted-color: #475569; /* slate-600 */
  --line-color: rgba(15, 23, 42, 0.2);
  --bg-color: rgb(253, 250, 242);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.4;
}

.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px;
  background: var(--bg-color);
  max-width: calc(var(--page-max-width) + 40px);
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1003;
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-link {
  color: rgb(153, 68, 151);
  text-decoration: none;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.nav-link:hover {
  opacity: 0.7;
}

.hamburger {
  display: none;
  cursor: pointer;
  padding: 4px;
  z-index: 1004;
  position: relative;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
}

.hamburger-icon {
  font-size: 28px;
  color: #000000;
  transition: opacity 0.3s ease;
}

.close-icon {
  font-size: 28px;
  color: #000000;
  position: absolute;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hamburger.active .hamburger-icon {
  opacity: 0;
}

.hamburger.active .close-icon {
  opacity: 1;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  width: 100%;
  height: calc(100vh - 60px);
  background: var(--bg-color);
  z-index: 998;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 40px;
}

.mobile-nav.active {
  display: flex;
}

.mobile-link {
  color: #000000;
  text-decoration: none;
  font-family: "Poppins", sans-serif;
  font-size: 24px;
  font-weight: 500;
  transition: opacity 0.3s ease;
}

.mobile-link:hover {
  opacity: 0.7;
}

.header {
  text-align: center;
  padding: 20px 46px 2px;
}

.company-logo {
  display: inline-block;
  height: 22px;
  max-height: 22px;
  width: auto;
}

.subtitle {
  margin: 2px 0 -20px 0;
  font-weight: 500;
  color: #000000;
  font-size: clamp(1rem, 3.5vw, 1.75rem);
}

.subtitle-purple {
  color: rgb(153, 68, 151);
}

.chart-section {
  padding: 0px 12px 24px;
  flex: 1;
  display: flex;
}

.chart-container {
  position: relative;
  width: 100%;
  max-width: var(--page-max-width);
  margin: 0 auto;
  min-height: 400px;
  height: auto;
}

.chart-frame { position: relative; width: 100%; height: 100%; z-index: 1; }
.chart-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.axis-label {
  position: absolute;
  color: var(--muted-color);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.axis-label-x { left: 50%; bottom: -5px; transform: translateX(-50%); }

.axis-label-y { left: -5px; top: calc(50% - 100px); writing-mode: vertical-rl; transform: rotate(180deg) translateY(-50%); }

.quadrant-label {
  position: absolute;
  color: var(--muted-color);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  pointer-events: none;
  z-index: -10;
}

.quadrant-label div {
  margin: 2px 0;
}

.quadrant-top-left { top: 60px; left: 30px; text-align: left; }
.quadrant-bottom-left { bottom: 30px; left: 30px; text-align: left; }
.quadrant-top-right { top: 60px; right: 30px; text-align: right; }
.quadrant-bottom-right { bottom: 30px; right: 30px; text-align: right; }

/* Ensure Chart.js tooltips appear above quadrant labels */
.chartjs-tooltip {
  z-index: 1000 !important;
}

/* =============================================================================
   D3.JS SPECIFIC STYLES - CONSOLIDATED FROM d3-styles.css
   ============================================================================= */

/* D3 Tooltip Styles */
.d3-tooltip {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  color: #000000;
  padding: 12px;
  border-radius: 8px;
  font-family: "Poppins", sans-serif;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  width: max-content;
  max-width: 280px;
  border: none;
  border-width: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.d3-tooltip h3 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: #000000;
  font-family: "Poppins", sans-serif;
}

.d3-tooltip p {
  margin: 0 0 4px 0;
  font-size: 12px;
  color: #000000;
  font-family: "Poppins", sans-serif;
}

.d3-tooltip p:last-of-type {
  margin-bottom: 12px; /* Extra space before button */
}

.d3-tooltip button {
  background: rgb(153, 68, 151);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-family: "Poppins", sans-serif;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s ease;
}

.d3-tooltip button:hover {
  background: rgb(173, 88, 171);
}

.d3-tooltip button:active {
  background: rgb(133, 48, 131);
}

/* D3 Chart Elements */
.d3-chart-frame {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1; /* Above corner labels */
}

.d3-chart-frame svg {
  width: 100%;
  height: 100%;
}

.d3-bubble {
  cursor: pointer;
  transition: r 0.2s ease;
}

/* Remove hover outline - only show outline when selected */
.d3-bubble:hover {
  stroke: transparent;
  stroke-width: 0;
}

.d3-bubble.selected {
  stroke: rgb(153, 68, 151);
  stroke-width: 3;
}

.d3-grid-line {
  stroke: rgba(0, 0, 0, 0.06);
  stroke-width: 1;
}

.d3-axis-line {
  stroke: #000000;
  stroke-width: 1;
}

.d3-axis-label {
  font-family: "Poppins", sans-serif;
  font-size: 12px;
  fill: #666;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* D3-specific positioning adjustments for labels */
.d3-chart-frame .quadrant-bottom-left,
.d3-chart-frame .quadrant-bottom-right {
  bottom: 25px !important; /* Positioned within chart boundaries */
}

.d3-chart-frame .quadrant-top-left,
.d3-chart-frame .quadrant-top-right {
  top: 25px !important; /* Positioned within chart boundaries */
}

.d3-chart-frame .axis-label-y {
  left: 2px !important; /* Move "RATE OF GROWTH" a few pixels farther away */
  top: calc(50% - 110px) !important; /* Move up from calc(50% - 100px) to calc(50% - 110px) */
}

.d3-chart-frame .axis-label-x {
  bottom: 0px !important; /* Move "COMPETITIVENESS" closer to bottom edge */
}

/* Purple "View Strategy" text for desktop tooltips */
.view-strategy-text {
  color: rgb(153, 68, 151) !important;
  font-weight: 500;
  font-size: 12px;
}

/* =============================================================================
   ENHANCED RESPONSIVE DESIGN - FIXES MOBILE LANDSCAPE & TABLET ISSUES
   ============================================================================= */

/* Mobile Portrait (phones in portrait) */
@media (max-width: 640px) and (orientation: portrait) {
  .top-nav {
    padding: 12px 16px;
    justify-content: space-between;
  }
  .hamburger {
    display: flex;
  }
  .nav-links {
    display: none;
  }
  .company-logo-link {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .header {
    padding: 5px 46px 2px;
  }
  .subtitle {
    margin: 15px 0 -30px 0;
    font-size: 1.5rem;
  }
  .chart-section {
    padding: 8px 8px 16px;
  }
  .chart-container { 
    min-height: 0; 
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .chart-frame { 
    height: auto; 
    min-height: 60vh;
    aspect-ratio: 1/1;
  }

  /* D3-specific mobile adjustments */
  .chart-section {
    padding: 8px 0px 16px !important; /* Remove side padding to create ~20px margins */
  }
  
  .chart-container {
    max-width: 100% !important; /* Allow full width on mobile like Chart.js */
    margin: 0 auto !important; /* Keep centered */
    max-height: 60vh !important; /* Prevent chart from extending to bottom of screen */
  }
  
  .subtitle {
    margin: 5px 0 0px 0 !important; /* Reduce spacing to match Chart.js 38-40px */
  }
  
  .header {
    padding-top: 15px !important; /* Same header spacing on mobile */
  }
}

/* Mobile Landscape (phones in landscape) - FIXES TITLE WRAPPING & HAMBURGER */
@media (max-width: 896px) and (orientation: landscape), 
       (max-height: 500px) and (orientation: landscape) {
  .top-nav {
    padding: 4px 16px 8px 16px; /* INCREASED BOTTOM PADDING FOR MORE SPACE TO TITLE */
    justify-content: space-between;
  }
  .hamburger {
    display: flex; /* KEEPS HAMBURGER IN LANDSCAPE */
  }
  .nav-links {
    display: none;
  }
  .company-logo-link {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .header {
    padding: 0px 20px 0px; /* REDUCED FROM 2px */
  }
  .subtitle {
    margin: 4px 0 8px 0; /* INCREASED BOTTOM MARGIN FOR MORE SPACE TO CHART */
    font-size: 1.1rem; /* SMALLER FONT - PREVENTS LINE WRAPPING */
    line-height: 1.2;
  }
  .chart-section {
    padding: 4px 8px 8px;
  }
  .chart-container { 
    min-height: 0; 
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .chart-frame { 
    height: auto; 
    min-height: 70vh;
    aspect-ratio: 1/1;
  }
}

/* Tablet Portrait (small tablets) - PROPER TABLET SUPPORT */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: portrait) {
  .top-nav {
    padding: 16px 20px;
    justify-content: space-between;
  }
  .hamburger {
    display: flex; /* HAMBURGER FOR TABLETS */
  }
  .nav-links {
    display: none;
  }
  .company-logo-link {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .header {
    padding: 10px 40px 5px;
  }
  .subtitle {
    margin: 20px 0 -25px 0;
    font-size: 1.8rem;
  }
  .chart-section {
    padding: 10px 16px 20px;
  }
  .chart-container { 
    min-height: 0; 
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .chart-frame { 
    height: auto; 
    min-height: 65vh;
    aspect-ratio: 1/1;
  }
}

/* Tablet Landscape (tablets in landscape) - HANDLES LARGE TABLETS */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: landscape) {
  .top-nav {
    padding: 12px 20px;
    justify-content: space-between;
  }
  .hamburger {
    display: flex; /* HAMBURGER FOR TABLET LANDSCAPE */
  }
  .nav-links {
    display: none;
  }
  .company-logo-link {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .header {
    padding: 5px 30px 2px;
  }
  .subtitle {
    margin: 10px 0 -20px 0;
    font-size: 1.3rem; /* SMALLER FOR LANDSCAPE */
    line-height: 1.2;
  }
  .chart-section {
    padding: 6px 12px 12px;
  }
  .chart-container { 
    min-height: 0; 
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .chart-frame { 
    height: auto; 
    min-height: 75vh;
    aspect-ratio: 1/1;
  }
}

/* Touch Device Detection - ENSURES HAMBURGER ON ALL TOUCH DEVICES */
@media (hover: none) and (pointer: coarse) {
  .hamburger {
    display: flex !important;
  }
  .nav-links {
    display: none !important;
  }
  .company-logo-link {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}

/* Desktop Only - TRADITIONAL DESKTOP NAVIGATION */
@media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
  .page { 
    height: 100vh; 
  }
  .hamburger {
    display: none;
  }
  .nav-links {
    display: flex;
  }
  .company-logo-link {
    position: static;
    transform: none;
  }
  .header {
    padding: 15px 46px 2px;
  }
  .subtitle {
    margin: 20px 0 0px 0;
    font-size: 2.00rem;
  }
  .chart-section { 
    height: calc(100vh - 140px); 
  }
  .chart-container { 
    height: 100%; 
    min-height: 560px; 
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .chart-frame { 
    height: 100%; 
    aspect-ratio: unset; 
  }
}