/*      --------------------------------------------------- Basis ---------------------------------------------------        */ 
body, html {
    height: 100%;
    margin: 0px;
    box-sizing: border-box;
    padding: 0;
    font-weight: 300;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--foreground);
    background-color: var(--background);
    line-height: 1.5;  
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/*      --------------------------------------------------- Landing page ---------------------------------------------------        */ 

.landing-page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-page-row {
    display: grid;
    margin: 2vh 18vw;
    padding: 20px;
    background-color: var(--card);
    border-radius: 10px;
    box-shadow: 0px 5px 7px rgba(00, 00, 00, 0.4);
}

#one.landing-page-row, #three.landing-page-row  { 
    grid-template-columns: auto 1fr;
    text-align: right;
}

#one.landing-page-row > div:first-child {
    line-height: 0;
}

#two.landing-page-row  { 
    grid-template-columns: 1fr auto;
}

#landing-page-imagelink {
    display: block;
    line-height: 0;
    font-size: 0;
}

#landing-page-imagelink img {
    display: block;
    height: 200px;
    width: auto;
    max-width: 100%;
}

.landing-page-header {
    background-color: var(--base-1);
    padding: 30px;
    text-align: center;
    font-size: 35px;
    box-shadow: 0px 5px 7px rgba(00, 00, 00, 0.4);
    height: 24px;
    grid-column-start: 1;
    grid-column-end: 3;
}

.landing-page-header-brand {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--light);
}

.landing-page-sub-title {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-4);
}

.landing-page-background-container {
    height: 100vh;
    width: 100%;
    position: fixed;
    overflow: hidden;
    top: 0;
    left: 0;
    z-index: -100;
}

.landing-page-background {   
    background-image: url('https://images.unsplash.com/photo-1560493676-04071c5f467b?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    height: 140%; /*offset, with 100% container*/ 
}

.landing-page-tagline {
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-1);
    margin-left: 30px;
    margin-top: 30px;
}

.landing-page-main-title {
    font-size: 3rem;
    color: var(--grey);
    margin-top: 0px;
    margin-bottom: 2px;
    line-height: 0.9;
}

.landing-page-select-container {
    margin-right: 15%;
    margin-left: 30%;
    margin-top: 20px;
}

.landing-page-chart-container {
    max-width: 180px;
    margin: 0px;
}

.landing-page-chart-container > svg {
    min-width: 200px;
    float: right;
}

footer {
    margin-top: auto;
    background-color: var(--light-grey);
    padding: 2rem 2.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

/*      --------------------------------------------------- Dashboard: Page structure ---------------------------------------------------        */ 


/* Page Heading */
.page-heading {
    margin-top: 10px;
    grid-column-start: 1;
    grid-column-end: 3;
}

.heading-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-1);
    margin-bottom: 0.75rem;
}

.page-title {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.05;
    margin: 0.25rem 0;
}

.page-description {
    margin-bottom: 0px;;
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.6;
    text-align: justify;
    color: var(--grey);
}

.page-container {
    min-height: 100vh;
    margin-left: var(--sidebar-width)
}

.dashboard-main {
    padding: 0;
    container-type: inline-size; /*needed for the responsive @container part on card-grid*/
    container-name: main;
}

.refresh-overlay {
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: rgba(228, 228, 228, 0.5);
    display: none;
    z-index: 100;
}

.loading-overlay {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background-color: white;
}

footer {
    background-color: var(--light-grey);
    margin-top: auto;
    padding: 2rem 2.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
}


/*      --------------------------------------------------- Sidebar ---------------------------------------------------        */ 
.sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    box-sizing: border-box;
    scrollbar-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
    z-index: 101;
}

.sidebar:hover {
    scrollbar-color: rgba(31, 31, 31, 0.233) rgba(0, 0, 0, 0);
}

.back-containter {
    padding: 10px;
    margin-bottom: 10px;
    background-color: var(--sidebar-light);
}

.preset-detials {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--grey);
  padding-bottom: 10px;
  padding-top: 8px;
}

.preset-detials div {
  padding-top: 10px;
  font-size: 0.7rem;
}

.hidden-sidebar-expander {
    display: none;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    opacity: 0.8;
    width: 15px;
    background-color: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    /* Use box-sizing so that element's outerwidth will match width property */
    box-sizing: border-box;
    z-index: 1;
}

.drag-handler {
    cursor: ew-resize;
    user-select: none;
    touch-action: none;
    position: fixed;
    height: 100%;
    /*right: 0;*/
    left: var(--sidebar-width);
    top: 0;
    bottom: 0;
    width: 5px;
    z-index: 100;
    transition: 200ms;
}

.drag-handler:hover {
    background: var(--base-1);
}

.sidebar-content {
    padding: 12px 12px;
}

.form-group {
    display: block;
    margin-bottom: 14px;
    padding: 10px;
    background: var(--sidebar-light);
}

.sidebar-note {
    font-size: 11px;
    color: var(--grey);
}

.input-label {
    font-size: 0.9rem;
    font-weight: 200;
    margin-top: 12px;
    color: var(--grey);
}

.meat-details summary {
  text-align: right;
  cursor: pointer;
}

.slider-container {
    padding-left: 4px;
    padding-bottom: 18px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--sidebar-foreground);
}

.detail-sliders {
    opacity: 0;
    max-height: 0px;
    transition: 1200ms ease;
}

details:open > .detail-sliders {
    opacity: 1;
    max-height: 1000px;
}

.average-indicator {
    position: absolute;
    left: calc(var(--sidebar-width) / 2 - 32px);
    transform: translateX(-50%);
    font-size: 0.9em;
    pointer-events: none;
}

.unit {
    white-space: nowrap;
    color: var(--grey);
    font-size: 0.7rem;
    font-weight: 200;
}

.slider-with-input {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.slider {
    width: 100%;
    margin-bottom: 0px;
    accent-color: var(--base-1);
    touch-action: pan-y;
}

.gram-input {
    color: var(--grey);
    width: 30px;
    padding: 0px 4px;
    margin: 0px -2px 0px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: right;
    background: white;
}

.gram-input:disabled {
    border: 1px solid transparent;
    background: transparent;
    appearance: none;
    -moz-appearance: textfield; /* Firefox: hide spinner */
    cursor: default;
}

.gram-input:enabled {
    border: 1px solid #ccc;
    margin: 0px 4px 0px 6px;
    background: white;
    cursor: text;
    padding: 2px 4px;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0px;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.slider-category-tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black; /* Add dots under the hoverable text */
  cursor: pointer;
}

.slider-category-tooltip-text {
  visibility: hidden; /* Hidden by default */
  width: 130px;
  font-size: 0.7rem;
  background-color: var(--grey);
  color: #ffffff;
  margin-left: 10px;
  text-align: center;
  padding: 5px;
  opacity: 0;
  transition: 0.3s;
  border-radius: 6px;
  position: absolute;
  z-index: 101; /* Ensure tooltip is displayed above content */
}

.slider-category-tooltip:hover .slider-category-tooltip-text {
  visibility: visible;
  opacity: 1;
}

.form-label {
    display: inline;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    color: var(--grey);
}

.detail-toggle {
    font-size: 0.7em;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    color: var(--grey);
    white-space: nowrap;
    display: flex;
    gap: 0.4em;
    float: right;
    cursor: pointer;
}

.detail-toggle input[type="checkbox"] {
    margin: 0;               /* alle margins raus! */
    cursor: pointer;
}

.detail-toggle.pop {
  animation: togglePop 450ms ease-in-out;
}

@keyframes togglePop {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.select-input {
    width: 100%;
    background-color: transparent;
    border: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.3);
    padding: 0.5rem 0;
    font-size: 1rem;
    font-weight: 100;
    outline: none;
    cursor: pointer;
}

.select-container {
    margin-bottom: 4px;
}

.sidebar-select {
    background-color: white;
    padding: 10px;
}

.select-input:focus {
    border-bottom-color: var(--primary);
}

.button {
    background-color: var(--accent-2);
    box-shadow: 0px 3px 3px rgba(48, 48, 48, 0.219);
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s ease;
    width: 100%;
    /*right-align
    display: block;
    margin-left: auto;
    margin-right: 0;*/
}

.button:hover {
    filter: contrast(120%);
}

.reload {
    display: inline-block;
    transform: rotate(90deg);
    transition: 0.2s ease;
}

.button:hover > .reload {
    filter: contrast(120%);
    transform: translateX(-10%) translateY(10%) rotate(180deg);
}

#download-container {
    text-align: right;
    margin-top: 8px;
}

#download-link {
    color: var(--grey);
    font-size: 0.75rem;
    cursor: pointer;
}

#download-link:hover {
    color: var(--base-1);
}

#slider-popup-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 101;
}

.slider-popup {
  position: fixed;
  bottom: calc(85%); /* Position above slider */
  background: #333;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 102;
  
  /* Arrow positioning */
  --arrow-offset: 0px;
}

.slider-popup::after {
  content: '';
  position: absolute;
  top: 100%; /* Bottom of popup */
  left: 50%;
  /* Use custom property to offset arrow */
  transform: translateX(calc(-50% + var(--arrow-offset, 0px)));
  
  /* Arrow triangle */
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #333;
}

/*      --------------------------------------------------- Dashboard: Card grid ---------------------------------------------------        */ 
.card-grid {
    display: grid;
    gap: 1.5rem;
    padding: 0px 30px 30px 30px;
    grid-auto-rows: auto;
    grid-template-columns: repeat(2, 1fr);
    max-width: 1850px;
    margin-inline: auto; /* centers grid when zoomed out */
}

.card {
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: var(--card);
    min-height: 400px;
    padding: 1.5rem;
    margin: 0;
}

.water-container {
    float: right;
    width: 48%;
    margin: 0px 0px 0px 16px;
}

.card-heading {
    margin-top: 0px;
    border-bottom: 1px solid var(--border);
}

.section-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-1);
    margin: 0px;
}

#blue {
    color: var(--accent-3);
}

#green {
    color: var(--accent-2);
}

.modifiable-text {
    color: var(--light);
    background-color: var(--accent-4);
    display: inline-block;
    padding: 2px 4px;
    border-radius: 4px;
    transition: transform 0.2s ease, color 0.2s ease;
    margin: 1px 0;
}

.modifiable-text.pop {
  animation: valuePop 400ms;
}

@keyframes valuePop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.9);
    background-color: var(--accent-3);
  }
  55% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.section-title {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin: 12px 0;
}


/* ===== citation block ===== */

.about-grid {
  grid-column: 1 / 3;
  border: 2px solid var(--border);
  border-radius: 8px;
  background-color: #eaeaea;
  margin: 200px 10vw 10px 10vw;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.about-heading {
  margin: 0;
}

.about-text {
    grid-column: 1 / 3;
}

.citation-section {
    border: 1px solid #ccc;
    background-color: var(--light);
    padding: 16px;
    border-radius: 8px;
    font-family: 'Arial', sans-serif;
    background-color: #fff;
}

.citation-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.citation-heading .cite {
    font-weight: bold;
    font-size: 1em;
    color: var(--base-1);
}

.citation-heading button {
    background-color: var(--base-1);
    filter: contrast(80%);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: 0.3s ease;
    min-width: 110px;
    line-height: 1;
    text-align: center;
}

.citation-heading button:hover {
    filter: contrast(100%);
}

.citation-body {
    font-size: 0.9em;
    color: #333333;
}

.citation-body p {
    margin-top: 8px;
    line-height: 1.5em;
}

.citation-body strong {
    font-weight: bold;
}

.citation-body em {
    font-style: italic;
}

.citation-body a:hover {
    text-decoration: underline;
}

#github-link {
    font-size: 0.9em;
    font-family: monospace;
    background-color: #ececec;
    padding: 10px;
    border-radius: 4px;
}

/* ===== Comparison Quote ===== */
.comparison-quote {
    margin: 0px 10px;
    border-left: 2px solid var(--accent-1);
    padding-left: 1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.9rem;
    font-weight: 300;
    line-height: 1.6;
    color: var(--grey);
}

/* ===== related to charts ===== */
.chart-section {
    padding-top: 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#barchart svg {
  width: 100%;
  height: auto;
  max-width: 850px;
  min-width: 350px;
}

#water_piechart svg {
  width: 100%;
  height: auto;
}

#barchart {
    min-height: 400px;
}

#treemap, #worldmap {
    min-height: 410px;
}

#worldmap {
  position: relative;
  container-type: inline-size;
  z-index: 0;
}

.worldmap-toplist {
  position: absolute;
  top: 2cqw;
  left: 2cqw;
  width: 24cqw;
  padding: 1cqw 1.5cqw;
  background: rgba(80, 80, 80, 0.65);
  color: #ffffff;
  border-radius: 4px;
  font-size: 1.8cqw;             /* scales with chart like the SVG (cqw = "container query width") */
  line-height: 1.4;
}

.worldmap-toplist .toplist-title {
  font-weight: 600;
  margin-bottom: 0.4em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 0.3em;
}

.worldmap-toplist ol {
  margin: 0;
  padding-left: .5em;
}

.worldmap-toplist li {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
}










#chart-popup-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;  /* Allow clicks to pass through */
  z-index: 10000;
}

#chart-float-text {
  position: fixed;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  z-index: 102;
}

.center {
    text-align: center;
}

.chart-label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    color: var(--muted-foreground);
    margin: 0.25rem 0px;
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0rem;
}

.chart-subtitle {
    color: var(--grey);
    font-weight: 300;
    letter-spacing: 0.01em;
    font-size: 0.75rem;
}









/*      --------------------------------------------------- Loading animations ---------------------------------------------------        */ 

#slider_form {
    transition: opacity 150ms ease-in;
}

#slider_form.loading {
    opacity: 0;
    transition: none;
    pointer-events: none;
}

.worldmap-toplist {
    transition: opacity 250ms ease-in;
}

.worldmap-toplist.loading {
    opacity: 0;
    transition: none;
    pointer-events: none;
}

@keyframes loading-slide {
    from { background-position: 0 0; }
    to   { background-position: 200% 0; }
}

.modifiable-text.loading {
    pointer-events: none;
    cursor: wait;
    user-select: none;

    color: transparent;

    min-width: 50px;

    background: repeating-linear-gradient(
        90deg,
        #d0d0d0 0%,
        #f0f0f0 25%,
        #d0d0d0 50%
    );
    background-size: 200% 100%;
    animation: loading-slide 1.2s linear infinite;
}


/* Container must anchor the absolute overlay */
#treemap, #worldmap {
    position: relative;
}

/* Overlay: hidden by default, visible only while container has .loading */
.chart-spinner-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6); /* dims stale chart if one exists */
    z-index: 10;
}

.loading > .chart-spinner-overlay {
    display: flex;
}

/* The spinner itself */
.chart-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #d0d0d0;      /* matches your shimmer palette */
    border-top-color: #8b5e3c;       /* accent — brownish to fit the treemap scale */
    border-radius: 50%;
    animation: spinner-rotate 0.9s linear infinite;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}




/*      --------------------------------------------------- Responsive ---------------------------------------------------        */ 

@media (pointer: coarse) {
    .drag-handler {
        margin-left: -12px;
        width: 24px; 
        z-index: 1000;
    }
}

/* Responsive card stacking if the container is too small */
@container main (width < 1100px) {
    .card-grid {
        display: block;
    }

    .card {
        padding: 1rem;
        margin: 1rem 0;
    }
}

@media (max-width: 800px) {
    .landing-page-row {
        margin: 20px;
    }

    .landing-page-select-container {
        margin: 10px;
    }

    #landing-page-imagelink img {
        width: 134px;
        height: auto;
    }

    .landing-page-chart-container {
        max-width: 80px;
        margin-left: 10px;
    }

    .sidebar {
        position: static; /* oder Toggle-Menü über JS */
        width: 100%;
        height: auto;
    }

    .page-container {
        margin-left: 0;
    }

    .card-grid {
        display: block;
    }

    #barchart svg {
        min-width: initial;
    }

    .card {
        padding: 1rem;
        margin: 1rem 0;
    }

    #treemap, #barchart, #worldmap  {
        min-height: 0px;
    }

    #slider_form {
        display: none;
    }

    .water-container {
        float: none;
        width: 100%;
        max-width: 500px;
        margin: 16px auto;
    }    
}