@import "_contrast.scss";
@function tint($color, $percentage) {
  @return mix(white, $color, $percentage);
}

@function shade($color, $percentage) {
  @return mix(black, $color, $percentage);
}

@function url-friendly-colour($colour) {
  @return '%23' + str-slice('#{$colour}', 2, -1)
}

$widget: false !default;

// Input variables that may be overridden by event themes.
$in-font-family-sans-serif: "Open Sans", "OpenSans", "Helvetica Neue", Helvetica, Arial, sans-serif !default;
$in-brand-primary: #7f5a91 !default;
$in-brand-success: #50a167 !default;
$in-brand-info: #5f9cd4 !default;
$in-brand-warning: #ffb419 !default;
$in-brand-danger: #c44f4f !default;
$in-body-bg: #FFFFFF !default;
$in-border-radius-base: 3px !default;
$in-border-radius-large: 4px !default;
$in-border-radius-small: 2px !default;

:root {
  @if (not $widget) {
    --pretix-font-family-sans-serif: #{$in-font-family-sans-serif};
  }

  --pretix-brand-primary: #{$in-brand-primary};
  --pretix-brand-success: #{$in-brand-success};
  --pretix-brand-info: #{$in-brand-info};
  --pretix-brand-warning: #{$in-brand-warning};
  --pretix-brand-danger: #{$in-brand-danger};

  --pretix-link-contrast-color: #{choose-contrast-color($in-body-bg, white, $in-brand-primary)};
  --pretix-link-hover-contrast-color: #{choose-contrast-color($in-body-bg, white, darken($in-brand-primary, 15%))};

  --pretix-brand-primary-lighten-5: #{lighten($in-brand-primary, 5%)};
  --pretix-brand-primary-lighten-20: #{lighten($in-brand-primary, 20%)};
  --pretix-brand-primary-lighten-30: #{lighten($in-brand-primary, 30%)};
  --pretix-brand-primary-lighten-40: #{lighten($in-brand-primary, 40%)};
  --pretix-brand-primary-lighten-48: #{lighten($in-brand-primary, 48%)};
  --pretix-brand-primary-lighten-50: #{lighten($in-brand-primary, 50%)};
  --pretix-brand-primary-lighten-53: #{lighten($in-brand-primary, 53%)};
  --pretix-brand-primary-lighten-55: #{lighten($in-brand-primary, 55%)};
  --pretix-brand-primary-darken-5: #{darken($in-brand-primary, 5%)};
  --pretix-brand-primary-darken-10: #{darken($in-brand-primary, 10%)};
  --pretix-brand-primary-darken-15: #{darken($in-brand-primary, 15%)};
  --pretix-brand-primary-darken-17: #{darken($in-brand-primary, 17%)};
  --pretix-brand-primary-darken-20: #{darken($in-brand-primary, 20%)};
  --pretix-brand-primary-darken-30: #{darken($in-brand-primary, 30%)};
  --pretix-brand-primary-shade-25: #{shade($in-brand-primary, 25%)};
  --pretix-brand-primary-lighten-28-saturate-20: #{saturate(lighten($in-brand-primary, 28%), 20%)};
  --pretix-brand-primary-lighten-23-saturate-2: #{saturate(lighten($in-brand-primary, 23%), 2%)};

  --pretix-brand-success-lighten-10: #{lighten($in-brand-success, 10%)};
  --pretix-brand-success-lighten-20: #{lighten($in-brand-success, 20%)};
  --pretix-brand-success-lighten-30: #{lighten($in-brand-success, 30%)};
  --pretix-brand-success-lighten-35: #{lighten($in-brand-success, 35%)};
  --pretix-brand-success-lighten-38: #{lighten($in-brand-success, 38%)};
  --pretix-brand-success-lighten-40: #{lighten($in-brand-success, 40%)};
  --pretix-brand-success-lighten-48: #{lighten($in-brand-success, 48%)};
  --pretix-brand-success-lighten-50: #{lighten($in-brand-success, 50%)};
  --pretix-brand-success-darken-5: #{darken($in-brand-success, 5%)};
  --pretix-brand-success-darken-10: #{darken($in-brand-success, 10%)};
  --pretix-brand-success-darken-12: #{darken($in-brand-success, 12%)};
  --pretix-brand-success-darken-15: #{darken($in-brand-success, 15%)};
  --pretix-brand-success-darken-17: #{darken($in-brand-success, 17%)};
  --pretix-brand-success-darken-20: #{darken($in-brand-success, 20%)};
  --pretix-brand-success-darken-30: #{darken($in-brand-success, 30%)};
  --pretix-brand-success-tint-50: #{tint($in-brand-success, 50%)};
  --pretix-brand-success-tint-85: #{tint($in-brand-success, 85%)};
  --pretix-brand-success-shade-25: #{shade($in-brand-success, 25%)};
  --pretix-brand-success-shade-42: #{shade($in-brand-success, 42%)};

  --pretix-brand-info-lighten-23: #{lighten($in-brand-info, 23%)};
  --pretix-brand-info-lighten-25: #{lighten($in-brand-info, 25%)};
  --pretix-brand-info-lighten-30: #{lighten($in-brand-info, 30%)};
  --pretix-brand-info-lighten-33: #{lighten($in-brand-info, 33%)};
  --pretix-brand-info-darken-5: #{darken($in-brand-info, 5%)};
  --pretix-brand-info-darken-10: #{darken($in-brand-info, 10%)};
  --pretix-brand-info-darken-17: #{darken($in-brand-info, 17%)};
  --pretix-brand-info-darken-20: #{darken($in-brand-info, 20%)};
  --pretix-brand-info-darken-30: #{darken($in-brand-info, 30%)};
  --pretix-brand-info-tint-85: #{tint($in-brand-info, 85%)};
  --pretix-brand-info-shade-25: #{shade($in-brand-info, 25%)};
  --pretix-brand-info-shade-42: #{shade($in-brand-info, 42%)};

  --pretix-brand-warning-lighten-12: #{lighten($in-brand-warning, 12%)};
  --pretix-brand-warning-lighten-31: #{lighten($in-brand-warning, 31%)};
  --pretix-brand-warning-lighten-35: #{lighten($in-brand-warning, 35%)};
  --pretix-brand-warning-lighten-40: #{lighten($in-brand-warning, 40%)};
  --pretix-brand-warning-lighten-41: #{lighten($in-brand-warning, 41%)};
  --pretix-brand-warning-lighten-43: #{lighten($in-brand-warning, 43%)};
  --pretix-brand-warning-darken-5: #{darken($in-brand-warning, 5%)};
  --pretix-brand-warning-darken-10: #{darken($in-brand-warning, 10%)};
  --pretix-brand-warning-darken-15: #{darken($in-brand-warning, 15%)};
  --pretix-brand-warning-darken-17: #{darken($in-brand-warning, 17%)};
  --pretix-brand-warning-darken-20: #{darken($in-brand-warning, 20%)};
  --pretix-brand-warning-darken-25: #{darken($in-brand-warning, 25%)};
  --pretix-brand-warning-darken-30: #{darken($in-brand-warning, 30%)};
  --pretix-brand-warning-darken-35: #{darken($in-brand-warning, 35%)};
  --pretix-brand-warning-tint-50: #{tint($in-brand-warning, 50%)};
  --pretix-brand-warning-tint-85: #{tint($in-brand-warning, 85%)};
  --pretix-brand-warning-shade-25: #{shade($in-brand-warning, 25%)};
  --pretix-brand-warning-shade-42: #{shade($in-brand-warning, 42%)};
  --pretix-brand-warning-transparent-60: #{transparentize($in-brand-warning, 0.6)};

  --pretix-brand-danger-lighten-5: #{lighten($in-brand-danger, 5%)};
  --pretix-brand-danger-lighten-15: #{lighten($in-brand-danger, 15%)};
  --pretix-brand-danger-lighten-25: #{lighten($in-brand-danger, 25%)};
  --pretix-brand-danger-lighten-30: #{lighten($in-brand-danger, 30%)};
  --pretix-brand-danger-lighten-33: #{lighten($in-brand-danger, 33%)};
  --pretix-brand-danger-lighten-43: #{lighten($in-brand-danger, 43%)};
  --pretix-brand-danger-lighten-45: #{lighten($in-brand-danger, 45%)};
  --pretix-brand-danger-darken-5: #{darken($in-brand-danger, 5%)};
  --pretix-brand-danger-darken-10: #{darken($in-brand-danger, 10%)};
  --pretix-brand-danger-darken-15: #{darken($in-brand-danger, 15%)};
  --pretix-brand-danger-darken-17: #{darken($in-brand-danger, 17%)};
  --pretix-brand-danger-darken-20: #{darken($in-brand-danger, 20%)};
  --pretix-brand-danger-darken-30: #{darken($in-brand-danger, 30%)};
  --pretix-brand-danger-tint-50: #{tint($in-brand-danger, 50%)};
  --pretix-brand-danger-tint-85: #{tint($in-brand-danger, 85%)};
  --pretix-brand-danger-shade-25: #{shade($in-brand-danger, 25%)};
  --pretix-brand-danger-shade-42: #{shade($in-brand-danger, 42%)};

  --pretix-border-radius-base: #{$in-border-radius-base};
  --pretix-border-radius-large: #{$in-border-radius-large};
  --pretix-border-radius-small: #{$in-border-radius-small};

  @if (not $widget) {
    --pretix-body-bg: #{$in-body-bg};
    --pretix-warning-icon: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2036%2036'%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%3E%3Cpath%20d='M20.04%202.89a2.2%202.2%200%200%200-3.87%200L2.88%2027.24a2.22%202.22%200%200%200%201.94%203.27h26.57a2.22%202.22%200%200%200%201.94-3.27L20.04%202.89Z'%20fill='%23fff'/%3E%3Cpath%20d='M19.92%2025.22c0%20.26-.2.47-.45.47h-2.73a.46.46%200%200%201-.45-.47v-2.7c0-.25.2-.46.45-.46h2.73c.25%200%20.45.21.45.47v2.7Zm-.02-5.31c-.02.19-.24.33-.5.33h-2.62c-.27%200-.48-.14-.48-.33l-.24-6.48c0-.09.04-.23.14-.3.09-.07.21-.16.34-.16h3.12c.13%200%20.26.09.35.16.1.07.14.18.14.27l-.26%206.51Z'%20fill='#{url-friendly-colour(darken($in-brand-warning, 25%))}'/%3E%3C/svg%3E");
    --pretix-info-icon: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2036%2036'%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%3E%3Ccircle%20cx='18'%20cy='18'%20r='16'%20fill='%23fff'/%3E%3Cpath%20d='M21.74%2022.66a.7.7%200%200%200-.7-.7h-.7v-6.28a.7.7%200%200%200-.7-.7h-4.19a.7.7%200%200%200-.7.7v1.4c0%20.38.32.7.7.7h.7v4.19h-.7a.7.7%200%200%200-.7.7v1.4c0%20.37.32.7.7.7h5.6a.7.7%200%200%200%20.69-.7v-1.4Zm-1.4-12.57a.7.7%200%200%200-.7-.7h-2.8a.7.7%200%200%200-.69.7v2.1c0%20.38.32.7.7.7h2.8a.7.7%200%200%200%20.7-.7v-2.1Z'%20fill='#{url-friendly-colour(darken($in-brand-info, 20%))}'/%3E%3C/svg%3E%0A");
    --pretix-success-icon: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2036%2036'%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%3E%3Crect%20x='5'%20y='5'%20width='26'%20height='26'%20fill='%23fff'/%3E%3Cpath%20d='M25.57%2014.65c0-.23-.1-.46-.26-.62l-1.24-1.24a.89.89%200%200%200-1.24%200l-5.98%206-2.68-2.7a.89.89%200%200%200-1.24%200l-1.24%201.24a.88.88%200%200%200%200%201.24l4.54%204.54a.88.88%200%200%200%201.24%200l7.84-7.84c.17-.16.26-.4.26-.62Z'%20fill='#{url-friendly-colour(darken($in-brand-success, 10%))}'/%3E%3C/svg%3E%0A");
    --pretix-legal-icon: url("data:image/svg+xml,%3Csvg%20viewBox='0%200%2036%2036'%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%3E%3Ccircle%20cx='18'%20cy='18'%20r='16'%20fill='%23fff'/%3E%3Cpath%20d='M19.41%2011.55c0-.43.2-.79.58-1.08-.42-.27-.99-.4-1.7-.4-.62%200-1.1.13-1.46.4-.36.26-.54.62-.54%201.08%200%20.42.13.76.38%201.01.18.15.5.33.95.57l1.77.85c1.04.48%201.79.9%202.25%201.25.51.36.88.8%201.1%201.3h-.02c.18.38.27.76.27%201.14%200%201.1-.62%202.18-1.85%203.22.48.46.81.9%201%201.3a3.84%203.84%200%200%201-.05%203.07c-.22.5-.54.91-.95%201.26-.42.34-.92.61-1.5.8a6.45%206.45%200%200%201-3.91%200%205.44%205.44%200%200%201-1.6-.79%203.67%203.67%200%200%201-1.1-1.22%203.11%203.11%200%200%201-.36-1.5c0-.66.17-1.2.52-1.59.36-.39.83-.59%201.42-.59.46%200%20.87.16%201.22.48.36.32.53.7.53%201.16%200%20.56-.33%201.03-1%201.41.03.05.07.1.13.13l.2.16a3.24%203.24%200%200%200%201.9.53c.67%200%201.2-.15%201.6-.46.38-.3.58-.7.58-1.22%200-.37-.13-.69-.38-.96a4.46%204.46%200%200%200-1.16-.82l-.9-.44A24.66%2024.66%200%200%201%2015%2020.44a7.7%207.7%200%200%201-.9-.6c-.86-.73-1.29-1.54-1.29-2.45%200-1.16.62-2.23%201.87-3.22a4.7%204.7%200%200%201-.79-1.16%203.38%203.38%200%200%201%20.95-3.98A5.02%205.02%200%200%201%2018.14%208c1.3%200%202.37.3%203.21.91V8.9c.92.6%201.37%201.38%201.37%202.33%200%20.51-.16.93-.49%201.27-.33.34-.75.5-1.26.5a1.6%201.6%200%200%201-1.12-.4c-.3-.28-.44-.62-.44-1.04Zm-1.27%204.66a26.2%2026.2%200%200%201-1.73-.84c-.6.6-.89%201.13-.89%201.6%200%20.34.13.63.39.87.17.15.42.31.74.5a30.57%2030.57%200%200%200%201.93%201l.85.45c.58-.58.87-1.14.87-1.68%200-.36-.15-.67-.46-.94-.3-.27-.87-.6-1.7-.96Z'%20fill='#{url-friendly-colour(darken($in-brand-info, 20%))}'/%3E%3C/svg%3E");

    @if ($in-body-bg = #FFFFFF) {
      --pretix-body-bg-white-1: 1;
      --pretix-body-bg-white-0: 0;
    }
    @if ($in-body-bg != #FFFFFF) {
      --pretix-body-bg-white-1: 0;
      --pretix-body-bg-white-0: 1;
    }
  }
}
