/**
 * Basic colors
 * Source of truth: https://www.figma.com/design/bkeUfijxwqK48gHOA68MaH/NDS-Foundations?node-id=2325-2&view=variables&var-set-id=744-14230&m=dev
 */
@layer q-fallback-values {
  .s-q-item {
    /** Basic text color */
    /* Light mode */
    --text-color-primary: #121212;
    --text-color-secondary: #434343;
    --text-color-tertiary: rgba(5, 5, 5, 0.57);
    --text-color-accent: #2c32bd;
    --text-color-disabled: rgba(10, 10, 10, 0.26);
    --text-color-error: #e11d48;

    /** Basic background colors */
    --background-color-primary: #ffffff;
    --background-shaded-faint: oklch(from var(--text-color-primary) l c h / 3%); /* Figma: BG/Secondary/Default */
    --background-shaded: oklch(from var(--text-color-primary) l c h / 6%); /* Figma: BG/Secondary/Hover */
    --background-shaded-strong: oklch(from var(--text-color-primary) l c h / 13%); /* Figma: BG/Secondary/Active */

    /* Aliases */
    --ink: var(--text-color-primary);
    --canvas: var(--background-color-primary);
    --q-primary-text-color: var(--text-color-primary);
    --q-secondary-text-color: var(--text-color-secondary);

    /* Q Use Cases */
    --text-color-heading: var(--text-color-primary);
    --text-color-subheading: var(--text-color-primary);

    /* Setting text color for the whole item */
    color: #121212;
    color: var(--text-color-primary);
  }

  .dark .s-q-item:has(.supports-dark-mode) {
    /* Color replacements for dark mode */

    --text-color-primary: #f5f5f5;
    --text-color-secondary: #dedede;
    --text-color-tertiary: rgba(255, 255, 255, 0.57);
    --text-color-accent: #9397e6;
    --text-color-disabled: rgba(250, 250, 250, 0.21);
    --text-color-error: #fb7185;

    --background-color-primary: #121212;
  }

  .dark-mode .s-q-item:has(.supports-dark-mode) {
    /* Color replacements for dark mode */

    --text-color-primary: #f5f5f5;
    --text-color-secondary: #dedede;
    --text-color-tertiary: rgba(255, 255, 255, 0.57);
    --text-color-accent: #9397e6;
    --text-color-disabled: rgba(250, 250, 250, 0.21);
    --text-color-error: #fb7185;

    --background-color-primary: #121212;
  }

  .dark[class*='color-schema']
    .s-q-item.q-custom-code, .dark[class*='color-schema']
    .s-q-item.q-infographic, .dark[class*='color-schema']
    .s-q-item.q-imageslider, .dark[class*='color-schema']
    .s-q-item.q-scrollgraphic, .dark[class*='color-schema']
    .s-q-item.q-grid, .dark-mode[class*='color-schema']
    .s-q-item.q-custom-code, .dark-mode[class*='color-schema']
    .s-q-item.q-infographic, .dark-mode[class*='color-schema']
    .s-q-item.q-imageslider, .dark-mode[class*='color-schema']
    .s-q-item.q-scrollgraphic, .dark-mode[class*='color-schema']
    .s-q-item.q-grid {
    /* Color replacements for dark mode */

    --text-color-primary: #f5f5f5;
    --text-color-secondary: #dedede;
    --text-color-tertiary: rgba(255, 255, 255, 0.57);
    --text-color-accent: #9397e6;
    --text-color-disabled: rgba(250, 250, 250, 0.21);
    --text-color-error: #fb7185;

    --background-color-primary: #121212;
  }
}

/* Sophie overrides */
.s-q-item.s-q-item {
  --q-primary-text-color: var(--text-color-primary);
  --q-secondary-text-color: var(--text-color-secondary);
}
@layer q-fallback-values {
  .s-q-item {
    /* Neutral, default color */
    --cat-neutral: #7e7e8f;

    /* Category Colors */
    /* Using nzz.ch as the default, can be overriden */
    --cat-0: #374e8e;
    --cat-1: #4fbbae;
    --cat-2: #df7c18;
    --cat-3: #ac004f;
    --cat-4: #1b87aa;
    --cat-5: #e3b13e;
    --cat-6: #ce4631;
    --cat-7: #4d313c;
    --cat-8: #8d7a81;
    --cat-9: #d1ccce;
    --cat-10: #6d545d;
    --cat-11: #aea2a6;

    /* Scale colors */
    --scale-0: #374d8e;
    --scale-1: #3f6998;
    --scale-2: #5082a1;
    --scale-3: #6899ab;
    --scale-4: #84b0b6;
    --scale-5: #a7c5c3;
    --scale-6: #cad8d4;
    --scale-7: #ded4b8;
    --scale-8: #c3c18d;
    --scale-9: #9eb06d;
    --scale-10: #72a05c;
    --scale-11: #488d5b;
    --scale-12: #31755c;
    --scale-13: #225d54;
  }
}
/**
 * Contains basic typographic values
 * Source of truth:
 * - https://www.figma.com/design/x502WXdkduTNQmTH6vtE5M/NDS-Web-Components?node-id=9272-1749&t=UopsJvJxYeqDRodX-0
 * - https://www.figma.com/design/bkeUfijxwqK48gHOA68MaH/NDS-Foundations?node-id=2325-2&view=variables&m=dev
 */

@layer q-fallback-values {
  .s-q-item {
    /* Font size base values */
    --font-size-primary: 1.125rem; /* Body text is 18px (mobile) or 20px (desktop) */
    --font-size-secondary: 1rem; /* 16px, for UI and secondary text */
    --font-size-tertiary: 0.875rem; /* 14px, for notes and other not that important text */
    --font-size-legal: 0.625rem; /* 10px, for text that needs to be there for "legal" reasons, but should be overlooked otherwise */
    --font-size-body-text: var(--font-size-primary);
    --font-size-ui: var(
      --font-size-secondary
    ); /* UI text (for input fields etc.) Needs to be at least 16px, otherwise iOS Safari will zoom in */

    /* Leading base values */
    --font-leading-tight: 1; /* Used for labels */
    --font-leading-compact: 1.333; /* Used for headings */
    --font-leading-loose: 1.5; /* Used for longer body text */

    /* Font weight base values */
    --font-weight-light: 300;
    --font-weight-regular: 400;
    --font-weight-medium: 500;

    /* Base font family */
    /* Needs to be overwritten by publication */
    --q-item-font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans, sans-serif;
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans, sans-serif, sans-serif;
    font-family: var(--q-item-font-family, sans-serif), sans-serif;
    font-size: 1rem;
    font-size: var(--font-size-secondary);
  }
}

@layer q-helpers {
    /*region ==== Stacks ====*/

    /** Vertical Stack, for stacking things on top of each other
   *  @param --row-gap: 1rlh
   */
    .s-q-item.vertical-stack,.s-q-item .vertical-stack {
      display: -webkit-box;
      display: -webkit-flex;
      display: -moz-box;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      -webkit-flex-direction: column;
         -moz-box-orient: vertical;
         -moz-box-direction: normal;
              flex-direction: column;
      gap: 1rlh;
      gap: var(--row-gap, 1rlh);
    }

    /** Horizontal Stack, for placing things beside each other
   *  @param --column-gap: 1em
   */
    .s-q-item.horizontal-stack,.s-q-item .horizontal-stack {
      display: -webkit-box;
      display: -webkit-flex;
      display: -moz-box;
      display: flex;
      -webkit-box-orient: horizontal;
      -webkit-box-direction: normal;
      -webkit-flex-direction: row;
         -moz-box-orient: horizontal;
         -moz-box-direction: normal;
              flex-direction: row;
      gap: 1em;
      gap: var(--column-gap, 1em);
    }

    .s-q-item .baselinegrid-compensation {
      padding-top: -webkit-calc(1rlh - 1cap);
      padding-top: -moz-calc(1rlh - 1cap);
      padding-top: calc(1rlh - 1cap);
    }
  .s-q-item {

    /*endregion*/

    /*region ====== Contrast Color =======*/

    /*  Configuration for the contrast-color class */
    /** The lightness threshold where the text color flips to black */
    --l-threshold: 0.7;

    /**
      Class for calculating whether black or white text provides the better
      contrast given a background color in `--color`.
      Sets the `color` property.
      Copied from https://lea.verou.me/blog/2024/contrast-color/

      @param --color
   */
  }
    .s-q-item .contrast-color {
      /* Fallback for browsers that don't support RCS */
      color: var(--ink);
      text-shadow:
        0 0 0.075em var(--canvas),
        0 0 0.075em var(--canvas),
        0 0 0.075em var(--canvas),
        0 0 0.075em var(--canvas),
        0 0 0.075em var(--canvas),
        0 0 0.075em var(--canvas);

      /*
          This should be the future browser vendors can give us.
          Problem is it still produces inferior results due to using WCAG values which are _shit_.
         */
    }
      @supports (color: contrast-color(red)) {
    .s-q-item .contrast-color {
        color: contrast-color(var(--color));
        text-shadow: none;
    }
      }

      /*
          For the time being, this function produces better contrast results,
          even if technically it isn't WCAG compliant.
          TODO Remove once browsers catch up and provide `contrast-color()` with
          better default values
         */
      @supports (color: oklch(from red l c h)) {
    .s-q-item .contrast-color {
        --l: clamp(0, (l / var(--l-threshold, 0.7) - 1) * -infinity, 1);
        color: oklch(from var(--color) clamp(0, (l / 0.7 - 1) * -infinity, 1) 0 h);
        text-shadow: none;
    }

@supports (color: lab(from red l 1 1% / calc(alpha + 0.1))) {
.s-q-item .contrast-color {
        color: oklch(from var(--color) var(--l) 0 h);
    }
}
      }

    /*endregion*/

    /*region ======== Tabular Numerals ======= */
    .s-q-item .tabular-nums {
      -webkit-font-feature-settings: tabular-nums lining-nums;
         -moz-font-feature-settings: tabular-nums lining-nums;
              font-feature-settings: tabular-nums lining-nums;
      font-variant-numeric: tabular-nums lining-nums;
    }

    /*endregion*/
}

.s-q-item {
  /* Custom Properties go here */
}

/** Support for Dark Mode */
.dark-mode .s-q-item:not(:has(.supports-dark-mode)) {
      /* Background Color for all cases where we don't explicitly support dark mode */
      background-color: #f4f4f4;
      background-color: var(--alwaysWhite, #f4f4f4);

      /* Padding due to background color */
      padding-left: 24px;
      padding-right: 24px;
      padding-left: var(--inline-spacing, 24px);
      padding-right: var(--inline-spacing, 24px);
      padding-top: 24px;
      padding-bottom: 24px;
      padding-top: var(--block-spacing, 24px);
      padding-bottom: var(--block-spacing, 24px);
    }
@media screen and (max-width: 767px) {
.dark-mode .s-q-item:not(:has(.supports-dark-mode)) {
        /* On mobile compensate the necessary padding and extend the coloured background to the margins */
        margin-left: -webkit-calc(-1 * 24px);
        margin-left: -moz-calc(-1 * 24px);
        margin-left: calc(-1 * 24px);
        margin-right: -webkit-calc(-1 * 24px);
        margin-right: -moz-calc(-1 * 24px);
        margin-right: calc(-1 * 24px);
        margin-left: -webkit-calc(-1 * var(--inline-spacing, 24px));
        margin-left: -moz-calc(-1 * var(--inline-spacing, 24px));
        margin-left: calc(-1 * var(--inline-spacing, 24px));
        margin-right: -webkit-calc(-1 * var(--inline-spacing, 24px));
        margin-right: -moz-calc(-1 * var(--inline-spacing, 24px));
        margin-right: calc(-1 * var(--inline-spacing, 24px));
    }
      }
/* Fallback for fullwidth-items – */
/* these will always extend to the edges of the container */
.dark-mode .q-embed.widget--fullwidth .s-q-item:not(:has(.supports-dark-mode)) {
      margin-left: -webkit-calc(-1 * 24px);
      margin-left: -moz-calc(-1 * 24px);
      margin-left: calc(-1 * 24px);
      margin-right: -webkit-calc(-1 * 24px);
      margin-right: -moz-calc(-1 * 24px);
      margin-right: calc(-1 * 24px);
      margin-left: -webkit-calc(-1 * var(--inline-spacing, 24px));
      margin-left: -moz-calc(-1 * var(--inline-spacing, 24px));
      margin-left: calc(-1 * var(--inline-spacing, 24px));
      margin-right: -webkit-calc(-1 * var(--inline-spacing, 24px));
      margin-right: -moz-calc(-1 * var(--inline-spacing, 24px));
      margin-right: calc(-1 * var(--inline-spacing, 24px));
    }

/* Handle Custom Code / infographic / scroll graphic items in dark mode */
/* (imageslider and grid keep their padding – they render text content, not just background) */
.dark-mode .q-embed.widget--fullwidth .q-custom-code.no-titlegroup,.dark-mode .q-embed.widget--fullwidth .q-infographic.no-titlegroup,.dark-mode .q-embed.widget--fullwidth .q-scrollgraphic.no-titlegroup {
        padding-top: 0;
        padding-top: initial;
      }
.dark-mode .q-embed.widget--fullwidth .q-custom-code.no-footer,.dark-mode .q-embed.widget--fullwidth .q-infographic.no-footer,.dark-mode .q-embed.widget--fullwidth .q-scrollgraphic.no-footer {
        padding-bottom: 0;
        padding-bottom: initial;
      }
/* Only apply this to items in an article with fixed background color */
.dark-mode[class*='color-schema'] .s-q-item.q-custom-code,.dark-mode[class*='color-schema'] .s-q-item.q-infographic,.dark-mode[class*='color-schema'] .s-q-item.q-imageslider,.dark-mode[class*='color-schema'] .s-q-item.q-scrollgraphic,.dark-mode[class*='color-schema'] .s-q-item.q-grid {
        /* unsetting all the background stuff */
        background-color: transparent;
        padding-left: 0;
        padding-left: initial;
        padding-right: 0;
        padding-right: initial;
        padding-top: 0;
        padding-top: initial;
        padding-bottom: 0;
        padding-bottom: initial;
        margin-left: 0;
        margin-left: initial;
        margin-right: 0;
        margin-right: initial;
      }
.s-q-item.s-q-item {
  --q-item-font-family: var(--nzz-font-sans, 'NZZ Sans');
}
