/* ==========================================================================
   DEBUG LAYOUT BORDERS - Uncomment to visualize element boundaries
   ========================================================================== */

/* Debug borders disabled - Uncomment the section below to enable */
/*
* {
  outline: 1px solid rgba(255, 0, 0, 0.3) !important;
}

.radar-container {
  outline: 3px solid blue !important;
}

.radar-layout {
  outline: 3px solid green !important;
}

.radar-svg-container {
  outline: 3px solid orange !important;
}

.radar-svg-container svg {
  outline: 3px solid red !important;
}

.radar-legend-column {
  outline: 2px solid purple !important;
}

.legend-section {
  outline: 1px solid cyan !important;
}
*/

/* ==========================================================================
   Base Styles
   ========================================================================== */

body {
  font-family: "Source Sans Pro", arial, helvetica, sans-serif;
  padding-bottom: 50px;
}

h3 {
  margin-top: 50px;
}

li {
  margin: 25px 50px 0 0;
}

table {
  width: 1400px;
  margin: 0 50px 0 50px;
}

td {
  width: 50%;
  vertical-align: top;
  padding-right: 60px;
}

.hover-underline {
  text-decoration: none;
}

.hover-underline:hover {
  text-decoration: underline;
}

.radar-layout {
  display: flex;
  align-items: stretch;
  gap: 24px;
  width: 100%;
  position: relative;
}

.radar-svg-container {
  flex: 0 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
  width: 100%;
}

.radar-svg-container svg {
  width: 100%;
  max-width: none;
  height: auto;
  display: block;
}

.radar-legend-column {
  display: none;
  flex-direction: column;
  gap: 16px;
  font-size: 12px;
  line-height: 1.4;
  justify-content: space-between;
  position: relative;
  height: 100%;
}

.radar-layout .radar-legend-column {
  flex: 1 0 20%;
}

.radar-layout .radar-svg-container {
  flex: 1 1 60%;
}

.left {
  position: absolute;
  left: 0;
  width: 25%;
}

.right {
  position: absolute;
  right: 0;
  width: 25%;
}

.legend-section {
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 0;
}

.legend-quadrant-name {
  font-weight: 600;
}

.legend-rings {
  display: grid;
  grid-template-columns: repeat(var(--legend-columns, 1), 1fr);
  grid-auto-flow: row;
  gap: 10px 14px;
  align-items: start;
}

.legend-ring {
  min-width: 0;
  max-width: 100%;
}

.legend-ring-name {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}

.legend-ring-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-entry {
  font-size: 11px;
  text-decoration: none;
  color: inherit;
  word-break: break-word;
  padding: 2px 4px;
  border-radius: 4px;
}

.legend-entry:hover {
  text-decoration: underline;
}

.legend-highlight {
  background: #333;
  color: #fff;
}

.demo-links {
  margin: 10px 20px;
  font-size: 14px;
}

.demo-links a {
  margin-left: 12px;
  transition: color 0.2s ease;
}

.demo-links a:hover {
  color: #0066cc;
  text-decoration: underline;
}

/* Enhanced SVG element styling */
.blip {
  cursor: pointer;
  transition:
    opacity 0.15s ease,
    filter 0.15s ease;
}

.blip:hover {
  filter: brightness(1.15) drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
}

.blip:active {
  filter: brightness(0.95);
}

/* Improved ring visibility */
.ring {
  stroke-opacity: 0.3;
  transition: stroke-opacity 0.2s ease;
}

.ring:hover {
  stroke-opacity: 0.6;
}

/* Quadrant line styling */
.quadrant-line {
  stroke-opacity: 0.25;
  transition: stroke-opacity 0.2s ease;
}

/* Legend hover effects */
.legend-entry:hover {
  background: rgba(0, 102, 204, 0.1);
  border-radius: 4px;
}

/* Tooltip improvements */
#bubble {
  pointer-events: none;
  transition: opacity 0.15s ease;
}

#bubble text {
  text-shadow:
    0 0 3px white,
    0 0 3px white,
    0 0 3px white;
  font-weight: 500;
}

/* Responsive text sizing */
@media (max-width: 1024px) {
  .demo-links {
    font-size: 13px;
  }

  .legend-quadrant-name {
    font-size: 14px;
  }

  .legend-ring-name {
    font-size: 10px;
  }

  .legend-entry {
    font-size: 10px;
  }
}

@media (max-width: 768px) {
  .demo-links {
    font-size: 12px;
    flex-wrap: wrap;
  }

  .demo-links a {
    margin: 4px 8px;
  }

  .legend-section {
    padding: 4px;
  }
}

/* Responsive Legend Column Layout - Mobile First Approach */

/* Extra small mobile - Portrait phones: 2 columns (< 480px) */
@media (max-width: 479px) {
  /* Remove horizontal padding to allow full-width radar */
  .radar-container {
    padding-left: 0;
    padding-right: 0;
  }

  /* Rings: 2 columns within each legend */
  .legend-rings {
    --legend-columns: 2;
    gap: 6px 8px;
  }

  .legend-section {
    gap: 6px;
    padding: 6px;
  }

  /* Overall layout: Vertical stacking */
  .radar-layout {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .radar-svg-container {
    order: 1;
    width: 100%;
    min-height: 300px;
    align-items: stretch;
    justify-content: stretch;
  }

  .radar-svg-container svg {
    width: 100%;
    height: auto;
    max-width: none;
  }

  .radar-legend-column {
    width: 100%;
    flex: 1 1 auto;
    font-size: 11px;
    display: flex;
  }

  .left {
    position: relative;
    width: 100%;
    left: auto;
    order: 2;
  }

  .right {
    position: relative;
    width: 100%;
    right: auto;
    order: 3;
  }

  .legend-quadrant-name {
    font-size: 12px;
  }

  .legend-ring-name {
    font-size: 10px;
  }

  .legend-entry {
    font-size: 9px;
    padding: 1px 3px;
  }
}

/* Mobile: 2 columns (480px - 639px) */
@media (min-width: 480px) and (max-width: 639px) {
  /* Remove horizontal padding to allow full-width radar */
  .radar-container {
    padding-left: 0;
    padding-right: 0;
  }

  /* Rings: 2 columns within each legend */
  .legend-rings {
    --legend-columns: 2;
    gap: 8px 10px;
  }

  .legend-section {
    gap: 8px;
  }

  /* Overall layout: Vertical stacking */
  .radar-layout {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }

  .radar-svg-container {
    order: 1;
    width: 100%;
    min-height: 350px;
    align-items: stretch;
    justify-content: stretch;
  }

  .radar-svg-container svg {
    width: 100%;
    height: auto;
    max-width: none;
  }

  .radar-legend-column {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
  }

  .left {
    position: relative;
    width: 100%;
    left: auto;
    order: 2;
  }

  .right {
    position: relative;
    width: 100%;
    right: auto;
    order: 3;
  }

  .legend-quadrant-name {
    font-size: 13px;
  }

  .legend-entry {
    font-size: 10px;
  }
}

/* Portrait tablets: 3 columns, two-row layout (640px - 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
  /* Rings: 3 columns within each legend */
  .legend-rings {
    --legend-columns: 3;
    gap: 8px 12px;
  }

  .legend-section {
    gap: 8px;
  }

  /* Overall layout: Row with wrapping (radar row 1, legends row 2) */
  .radar-layout {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
  }

  .radar-svg-container {
    order: 1;
    flex: 0 0 100%;
    width: 100%;
    min-height: 600px;
    align-items: stretch;
    justify-content: stretch;
  }

  .radar-svg-container svg {
    width: 100%;
    height: auto;
    max-width: none;
  }

  /* Legends side-by-side in row 2, each taking ~50% */
  .radar-layout .radar-legend-column {
    flex: 1 1 calc(50% - 10px);
    display: flex;
  }

  .radar-legend-column.left {
    position: relative;
    left: auto;
    order: 2;
  }

  .radar-legend-column.right {
    position: relative;
    right: auto;
    order: 3;
  }

  .legend-quadrant-name {
    font-size: 14px;
  }

  .legend-entry {
    font-size: 11px;
  }
}

/* Landscape tablets and small desktops: 2-3 columns, side-by-side layout (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
  /* Rings: 2 columns within sidebar legends */
  .legend-rings {
    --legend-columns: 2;
    gap: 8px 12px;
  }

  /* Overall layout: Side by side */
  .radar-layout {
    flex-direction: row;
    align-items: flex-start;
    max-height: calc(100vh - 150px);
  }

  .radar-svg-container svg {
    max-height: calc(100vh - 150px);
  }

  .radar-legend-column {
    display: flex;
    height: auto;
    overflow-y: auto;
  }

  .legend-quadrant-name {
    font-size: 13px;
  }

  .legend-entry {
    font-size: 10px;
  }
}

/* Desktop and laptops: 3 columns (1280px - 1919px) */
@media (min-width: 1280px) and (max-width: 1919px) {
  /* Rings: 3 columns within sidebar legends */
  .legend-rings {
    --legend-columns: 3;
    gap: 8px 12px;
  }

  .legend-section {
    padding: 8px;
  }

  /* Overall layout: Side by side with wider legends */
  .radar-layout {
    flex-direction: row;
    align-items: flex-start;
    max-height: calc(100vh - 150px);
  }

  .radar-svg-container svg {
    max-height: calc(100vh - 150px);
  }

  .radar-layout .radar-legend-column {
    flex: 1 0 24%;
    display: flex;
    height: auto;
    overflow-y: auto;
  }

  .left,
  .right {
    width: 28%;
  }
}

/* Wide screens: 4 columns (1920px - 2559px) */
@media (min-width: 1920px) and (max-width: 2559px) {
  /* Rings: 4 columns within sidebar legends */
  .legend-rings {
    --legend-columns: 4;
    gap: 10px 16px;
  }

  .legend-section {
    padding: 10px;
    gap: 8px;
  }

  .legend-quadrant-name {
    font-size: 14px;
  }

  .legend-ring-name {
    font-size: 12px;
  }

  .legend-entry {
    font-size: 12px;
  }

  /* Overall layout: Side by side with wider legends */
  .radar-layout {
    flex-direction: row;
    align-items: flex-start;
    max-height: calc(100vh - 150px);
  }

  .radar-svg-container svg {
    max-height: calc(100vh - 150px);
  }

  .radar-layout .radar-legend-column {
    flex: 1 0 26%;
    display: flex;
    height: auto;
    overflow-y: auto;
  }

  .left,
  .right {
    width: 30%;
  }
}

/* Ultra-wide displays: 5 columns (≥ 2560px) */
@media (min-width: 2560px) {
  /* Rings: 5 columns within sidebar legends */
  .legend-rings {
    --legend-columns: 5;
    gap: 12px 18px;
  }

  .legend-section {
    padding: 12px;
  }

  .radar-legend-column {
    font-size: 13px;
  }

  .legend-quadrant-name {
    font-size: 15px;
  }

  .legend-ring-name {
    font-size: 13px;
  }

  .legend-entry {
    font-size: 13px;
  }

  /* Overall layout: Side by side with widest legends */
  .radar-layout {
    flex-direction: row;
    align-items: flex-start;
    max-height: calc(100vh - 150px);
  }

  .radar-svg-container svg {
    max-height: calc(100vh - 150px);
  }

  .radar-layout .radar-legend-column {
    flex: 1 0 28%;
    display: flex;
    height: auto;
    overflow-y: auto;
  }

  .left,
  .right {
    width: 32%;
  }
}

/* Accessibility improvements */
.blip:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.legend-entry:focus {
  outline: 2px solid #0066cc;
  outline-offset: 1px;
}

/* JSON Toolbar styles - Floating overlay */
.demo-toolbar {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.demo-toolbar:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.demo-toolbar__controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.demo-toolbar__button {
  background: #1976d2;
  border: none;
  color: #fff;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Icon button variant */
.demo-toolbar__button--icon {
  padding: 0.625rem;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1rem;
}

.demo-toolbar__button--icon i {
  pointer-events: none;
}

.demo-toolbar__button:hover {
  background: #1565c0;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

.demo-toolbar__button--icon:hover {
  transform: translateY(-1px) scale(1.05);
}

.demo-toolbar__button:active {
  background: #0d47a1;
  transform: translateY(0);
}

.demo-toolbar__button--icon:active {
  transform: translateY(0) scale(0.95);
}

.demo-toolbar__message {
  position: absolute;
  bottom: -36px;
  right: 0;
  left: 0;
  font-size: 0.8125rem;
  color: #1976d2;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.demo-toolbar__message:empty {
  display: none;
}

.demo-toolbar__message[data-state="error"] {
  color: #d32f2f;
  border-color: rgba(211, 47, 47, 0.2);
}

.demo-toolbar__message[data-state="success"] {
  color: #2e7d32;
  border-color: rgba(46, 125, 50, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .demo-toolbar {
    top: 10px;
    right: 10px;
    padding: 0.5rem 0.75rem;
  }

  .demo-toolbar__button {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* Print styles */
@media print {
  .demo-links,
  .demo-toolbar {
    display: none;
  }

  .blip:hover {
    transform: none;
    filter: none;
  }

  nav,
  footer {
    page-break-inside: avoid;
  }
}

/* Description Modal Styles */
.tech-radar-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.tech-radar-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tech-radar-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 10001;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tech-radar-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.tech-radar-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #333;
}

.tech-radar-modal-close:active {
  background: rgba(0, 0, 0, 0.1);
}

.tech-radar-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.tech-radar-modal-logo {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e0e0e0;
}

.tech-radar-modal-title {
  margin: 0 32px 0 0;
  font-size: 24px;
  font-weight: 600;
  color: #333;
  line-height: 1.3;
  flex: 1;
}

.tech-radar-modal-body {
  font-size: 15px;
  line-height: 1.6;
  color: #555;
}

.tech-radar-modal-body p {
  margin: 0 0 12px 0;
}

.tech-radar-modal-body p:last-child {
  margin-bottom: 0;
}

.tech-radar-modal-body h1,
.tech-radar-modal-body h2,
.tech-radar-modal-body h3 {
  margin: 20px 0 12px 0;
  color: #333;
}

.tech-radar-modal-body h1:first-child,
.tech-radar-modal-body h2:first-child,
.tech-radar-modal-body h3:first-child {
  margin-top: 0;
}

.tech-radar-modal-body ul,
.tech-radar-modal-body ol {
  margin: 12px 0;
  padding-left: 24px;
}

.tech-radar-modal-body li {
  margin: 6px 0;
}

.tech-radar-modal-body a {
  color: #1976d2;
  text-decoration: none;
  transition: color 0.2s ease;
}

.tech-radar-modal-body a:hover {
  color: #1565c0;
  text-decoration: underline;
}

.tech-radar-modal-body code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 0.9em;
}

.tech-radar-modal-body pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 12px 0;
}

.tech-radar-modal-body pre code {
  background: none;
  padding: 0;
}

.tech-radar-modal-link {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.tech-radar-modal-link a {
  display: inline-block;
  color: #1976d2;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.tech-radar-modal-link a:hover {
  color: #1565c0;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .tech-radar-modal-content {
    width: 95%;
    max-height: 90vh;
    padding: 24px;
  }

  .tech-radar-modal-header {
    gap: 12px;
  }

  .tech-radar-modal-logo {
    width: 48px;
    height: 48px;
  }

  .tech-radar-modal-title {
    font-size: 20px;
    margin-right: 24px;
  }

  .tech-radar-modal-body {
    font-size: 14px;
  }
}
