/* Clean SAG Layout - From Scratch */

/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Font Declarations */
@font-face {
  font-family: "KBH Sans";
  src: url("../fonts/KBH-Light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "KBH Sans";
  src: url("../fonts/KBH-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "KBH Sans";
  src: url("../fonts/KBH-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "KBH Sans";
  src: url("../fonts/KBH-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "KBH Tekst";
  src: url("../fonts/KBHTekst-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "KBH Tekst";
  src: url("../fonts/KBHTekst-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Typography */
body {
  font-family:
    "KBH Tekst",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-weight: 400;
  line-height: 1.5;
  background-color: rgba(0, 95, 128, 0.2);
  overflow: hidden; /* Prevent scrolling - fullscreen only */
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family:
    "KBH Sans",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-weight: 500;
  line-height: 1.2;
}

/* CSS Variables */
:root {
  /* Colors */
  --sag-blue: #005f80;
  --sag-blue-light: rgba(0, 95, 128, 0.85);
  --sag-popover-color: var(--sag-blue); /* Default popover color, can be overridden per row */
  /* Category colors are defined dynamically in the template */

  /* Layout */
  --corner-width: 380px;
  --top-height: 120px;
  --gap: 20px;
  --radius: 8px;
  --bottom-height: 200px;
}

#cmplz-manage-consent .cmplz-manage-consent {
  right: auto !important;
  left: 40px;
}

/* Main Container - Fullscreen */
.sag-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--gap);
  gap: var(--gap);
}

/* Top Section */
.sag-top {
  height: var(--top-height);
  display: flex;
  gap: var(--gap);
  flex-shrink: 0;
}

.sag-corner-box {
  width: var(--corner-width);
  height: 100%;
  background: var(--sag-blue);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-end;
  padding: var(--gap);
  color: white;
}

.sag-corner-box h3 {
  font-size: 28px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0;
}

.sag-years-box {
  flex: 1;
  height: 100%;
  background: var(--sag-blue);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-end;
  padding: 0;
  color: white;
  overflow: hidden;
}

.sag-year-header {
  color: white;
  text-decoration: none;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  flex: 1;
  height: 100%;
  padding: var(--gap);
  position: relative;
  overflow: auto;
}

.sag-year-header h2 {
  font-size: 60px;
  font-weight: 500;
  margin: 0;
  line-height: 1;
}

.sag-column-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  position: absolute;
  bottom: var(--gap);
  right: var(--gap);
  transition: transform 0.3s ease;
}

.sag-column-nav__text {
  font-size: 14px;
}

.sag-nav-hint {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
}

.sag-year-header:hover .sag-column-nav {
  transform: translateX(5px);
  will-change: transform; /* Optimize for hover animations */
}

/* Middle Section - Expands to fill space */
.sag-middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0; /* Important for flex shrinking */
}

.sag-row {
  flex: 1;
  display: flex;
  gap: var(--gap);
  min-height: 0;
}

.sag-category-box {
  width: var(--corner-width);
  flex-shrink: 0;
}

.sag-category {
  width: 100%;
  height: 100%;
  background-color: var(--category-color);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  padding: var(--gap);
  color: white;
  font-size: 22px;
  font-weight: 500;
  font-family: "KBH Sans", sans-serif;
}

/* Category colors are set dynamically in the template via data-category attribute */

.sag-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.sag-svg-area {
  flex: 1;
  background: transparent;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  min-height: 60px; /* Ensure minimum height */
}

.sag-svg {
  width: 100%;
  height: auto;
  display: block;
  min-height: 60px; /* Ensure SVG has minimum height */
  shape-rendering: geometricPrecision; /* Crisp SVG rendering */
  image-rendering: -webkit-optimize-contrast; /* Webkit crisp rendering */
  image-rendering: crisp-edges; /* Standard crisp rendering */
}

/* Row colors for inline SVGs - uses category color from template */
.sag-row .sag-svg {
  color: var(--category-color) !important;
}

/* Ensure SVG elements inherit the color */
.sag-svg,
.sag-svg * {
  fill: currentColor !important;
  stroke: currentColor !important;
}

.sag-links-area {
  margin-top: 0;
  padding-bottom: calc(var(--gap) * 1);
}

/* Link preview for index page - 3 columns matching year headers */
.sag-link-preview {
  display: flex;
  gap: var(--gap);
}

.sag-preview-column {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: flex-start;
  justify-content: center;
  align-content: flex-start;
}

.sag-link-text {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  display: inline-block;
  white-space: nowrap;
  margin: 0;
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  text-decoration: none;
  transition: background 0.2s ease;
}

.sag-link-text:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Category colors for preview text pills - uses category color from template */
.sag-row .sag-link-text {
  background: var(--category-color);
  color: white;
}

.sag-row .sag-link-text:hover {
  background: color-mix(in srgb, var(--category-color) 80%, transparent);
}

/* Bottom Section - Takes remaining space */
.sag-bottom {
  display: flex;
  gap: var(--gap);
  flex-shrink: 0;
  height: var(--bottom-height);
}

.sag-info-box {
  width: var(--corner-width);
  height: 100%;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius);
  padding: var(--gap);
  font-size: 14px;
  line-height: 1.4;
  overflow: auto;
}

.sag-info-box h4 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--sag-blue);
}

.sag-piano-area {
  flex: 1;
  height: 100%;
}

.sag-piano {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius);
  display: flex;
}

.sag-key-container {
  flex: 1;
  height: 100%;
  position: relative;
}

.sag-key {
  width: 100%;
  height: 100%;
  background: white;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.sag-key:hover {
  background: #eaeaea;
}

.sag-key-label {
  font-family: "KBH Sans", sans-serif;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding-bottom: 15px;
  font-size: 14px;
}

/* Piano rounded corners */
.sag-piano .sag-key-container:first-child .sag-key {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.sag-piano .sag-key-container:last-child .sag-key {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* Black keys */
.sag-piano .sag-key-container:nth-child(7n + 1):not(:last-child)::after,
.sag-piano .sag-key-container:nth-child(7n + 2):not(:last-child)::after,
.sag-piano .sag-key-container:nth-child(7n + 4):not(:last-child)::after,
.sag-piano .sag-key-container:nth-child(7n + 5):not(:last-child)::after,
.sag-piano .sag-key-container:nth-child(7n + 6):not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0;
  left: 100%;
  transform: translateX(-50%);
  width: 60%;
  height: 60%;
  background: #111;
  border-radius: 0 0 4px 4px;
  z-index: 2;
}

/* Column overlay system - CSS handles styling, JS handles positioning */
.sag-column-overlays {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  display: flex;
}

.sag-column-overlay {
  flex: 1; /* Equal width for 3 columns */
  height: 100%;
  pointer-events: auto;
  text-decoration: none;
  color: transparent;
  background: transparent;
  transition: background 0.3s ease;
}

/* Only 2nd column has default tint */
.sag-column-overlay:nth-child(2) {
  background: rgba(255, 255, 255, 0.05);
}

/* Hover effects - pure CSS solution */
.sag-column-overlay:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Keep original header hover states working */
.sag-year-header:hover .sag-column-nav,
.sag-year-header.overlay-hover .sag-column-nav {
  transform: translateX(5px);
}

/* Year page back button should animate left */
.sag-year .sag-year-header:hover .sag-column-nav {
  transform: translateX(-5px);
}

/* New Global Popover System */
.sag-popover {
  position: fixed;
  z-index: 1000;
  width: 400px;
  background: var(--sag-popover-color, var(--sag-blue));
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: white;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition:
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  will-change: opacity, transform;
}

.sag-popover.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Arrow styles */
.sag-popover-arrow {
  position: absolute;
  width: 0;
  height: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* Arrow pointing down (when popover is above element) */
.sag-popover-above .sag-popover-arrow {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--sag-popover-color, var(--sag-blue));
  bottom: -8px;
}

/* Arrow pointing up (when popover is below element) */
.sag-popover-below .sag-popover-arrow {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--sag-popover-color, var(--sag-blue));
  top: -8px;
}

.sag-popover-header {
  margin: var(--gap) var(--gap) 0;
  font-size: 1.1em;
  font-weight: bold;
  font-family:
    "KBH Sans",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

.sag-popover-body {
  padding: var(--gap);
  font-family:
    "KBH Tekst",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

.sag-popover-body p {
  margin: 0 0 var(--gap) 0;
  line-height: 1.4;
}

.sag-popover-body p:last-child {
  margin-bottom: 0;
}

.sag-popover-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 0;
}

.sag-popover-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  color: white;
  text-decoration: none;
  font-weight: 400;
  padding: var(--gap);
  border-radius: var(--radius);
  transition: background-color 0.2s ease;
  font-family:
    "KBH Tekst",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

.sag-popover-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

/* Universal arrow design - same for all arrows */
.sag-nav-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 1em;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
  margin-left: 8px;
}

.sag-popover-link:hover .sag-nav-hint {
  transform: translateX(2px);
}

/* Row colors will be added later */

/* Link row under each SVG in year view */
.sag-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--gap) / 2);
  justify-content: space-between;
}

.sag-link {
  display: inline-block;
  padding: 8px 12px;
  border-radius: var(--radius);
  text-align: center;
  transition: background 0.2s ease;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
}

/* Category-specific link colors - uses category color from template */
.sag-row .sag-link {
  background: var(--category-color);
  color: white;
}

.sag-row .sag-link:hover {
  background: color-mix(in srgb, var(--category-color) 80%, transparent);
  color: white;
}

/* Link container for popover positioning */
.sag-link-container {
  position: relative;
  display: inline-block;
}
