/* Widget Builder - Main Stylesheet mit JASP Theming */

/* Font Display Optimization - Explicit fallback for better browser compatibility */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Inter');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: local('Inter');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local('Inter');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Inter');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: local('Inter');
}

/* 1) Basiswerte aus JASP Design System */
:root {
  --primary: #2656a4; /* JASP Blau */
  --success: #0a5630; /* JASP Grün */
  --neutral: #575656; /* JASP Grau */
  --warning: #ffb51e; /* Warnung */
  --danger: #ff3737; /* Fehler */
  --positive: #00b233; /* Positiv */

  /* 2) Schattierungen (oklch für saubere Tints/Shades) */
  --primary-50: color-mix(in oklch, white 90%, var(--primary));
  --primary-100: color-mix(in oklch, white 80%, var(--primary));
  --primary-500: var(--primary);
  --primary-600: color-mix(in oklch, black 15%, var(--primary));
  --primary-700: color-mix(in oklch, black 30%, var(--primary));

  --success-100: color-mix(in oklch, white 80%, var(--success));
  --success-500: var(--success);

  /* 3) Semantische Oberflächen */
  --background: white;
  --foreground: #0a0a0a;

  /* Legacy Variablen (für Abwärtskompatibilität) */
  --color-primary: var(--primary);
  --color-secondary: var(--success);
  --color-success: #607e5a;
  --color-error: var(--danger);
  --color-background: #c1c2c3;
  --color-background-alt: #8f908f;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;

  --transition-fast: 150ms;
  --transition-base: 200ms;
  --transition-slow: 300ms;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1),
    0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Dark Mode: Variablen überschreiben */
.dark {
  --background: #0f1115;
  --foreground: white;
  --primary-600: color-mix(in oklch, black 25%, var(--primary));
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--color-gray-900);
  line-height: 1.6;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-gray-900);
}

h1 {
  font-size: 3rem;
}
h2 {
  font-size: 2.25rem;
}
h3 {
  font-size: 1.875rem;
}
h4 {
  font-size: 1.5rem;
}
h5 {
  font-size: 1.25rem;
}
h6 {
  font-size: 1.125rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-base);
}

a:hover {
  color: #1e4a8a;
}

/* External Link Icon (CSS-only approach) - nur für externe Links */
a[href^="http"]::after {
  content: "↗";
  display: inline-block;
  margin-left: 0.25em;
  font-size: 0.75em;
  vertical-align: super;
  opacity: 0.7;
  transition: opacity var(--transition-base);
}

/* Kein Icon für Links zur eigenen Domain */
a[href^="https://widgetbuilder.de"]::after,
a[href^="https://www.widgetbuilder.de"]::after,
a[href^="http://localhost"]::after
{
  display: none;
}

a[href^="http"]:hover::after,
a[href^="https://"]:hover::after
{
  opacity: 1;
}

/* Disable external link icon when needed */
a.no-external-icon[href^="http"]::after,
a[href^="http"].no-external-icon::after {
  display: none;
}

/* Utility Classes */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.text-primary {
  color: var(--color-primary);
}

.bg-primary {
  background-color: var(--color-primary);
}

.bg-grid-white\/10 {
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

.animate-on-scroll {
  opacity: 0;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: #1e4a8a;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
  background-color: var(--color-gray-50);
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-xl);
}

/* Header Sticky Behavior */
header {
  transition: box-shadow var(--transition-base);
}

header.scrolled {
  box-shadow: var(--shadow-md);
}

/* Responsive Grid */
.grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 768px) {
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Pricing Cards */
.pricing-card {
  position: relative;
  padding: 2rem;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-xl);
  transition: all var(--transition-base);
}

.pricing-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

.pricing-card.popular {
  border-color: var(--color-primary);
  border-width: 2px;
}

.pricing-badge {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--color-primary);
  color: white;
  padding: 0.5rem 1rem;
  border-bottom-left-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 600;
}

/* Feature List */
.feature-list {
  list-style: none;
  padding: 0;
}

.feature-list li {
  padding: 0.75rem 0;
  display: flex;
  align-items: flex-start;
}

.feature-list li::before {
  content: "✓";
  color: var(--color-success);
  font-weight: bold;
  margin-right: 0.75rem;
  font-size: 1.25rem;
}

/* Widget Gallery */
.widget-card {
  background: white;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.widget-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

.widget-card-image {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-card-content {
  padding: 1.5rem;
}

.widget-badge {
  display: inline-block;
  background-color: var(--color-gray-100);
  color: var(--color-primary);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

/* Forms */
input[type="email"],
input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  transition: all var(--transition-base);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(38, 86, 164, 0.1);
}

/* Footer */
footer {
  background-color: var(--color-gray-50);
  border-top: 1px solid var(--color-gray-200);
}

footer a {
  color: var(--color-gray-600);
  transition: color var(--transition-base);
}

footer a:hover {
  color: var(--color-primary);
}

/* Responsive Typography */
@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }
  h2 {
    font-size: 1.75rem;
  }
  h3 {
    font-size: 1.5rem;
  }
}

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Focus Visible for Accessibility */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  header,
  footer,
  .no-print {
    display: none;
  }
}

/* Prose Styles for Markdown Content */
.prose {
  color: var(--color-gray-700);
  max-width: 65ch;
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h1 {
  color: var(--color-gray-900);
  font-weight: 800;
  font-size: 2.25em;
  margin-top: 0;
  margin-bottom: 0.8888889em;
  line-height: 1.1111111;
}

.prose h2 {
  color: var(--color-gray-900);
  font-weight: 700;
  font-size: 1.875em;
  margin-top: 1.6em;
  margin-bottom: 0.8em;
  line-height: 1.3333333;
}

.prose h3 {
  color: var(--color-gray-900);
  font-weight: 600;
  font-size: 1.5em;
  margin-top: 1.6em;
  margin-bottom: 0.6em;
  line-height: 1.6;
}

.prose h4 {
  color: var(--color-gray-900);
  font-weight: 600;
  font-size: 1.25em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.5;
}

.prose h5 {
  color: var(--color-gray-900);
  font-weight: 600;
  font-size: 1.125em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.5;
}

.prose h6 {
  color: var(--color-gray-900);
  font-weight: 600;
  font-size: 1em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.5;
}

.prose p {
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  line-height: 1.75;
}

.prose a {
  color: var(--color-primary);
  text-decoration: underline;
  font-weight: 500;
}

.prose a:hover {
  color: var(--primary-700);
}

.prose strong {
  color: var(--color-gray-900);
  font-weight: 600;
}

.prose em {
  font-style: italic;
}

.prose ul {
  list-style-type: disc;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  padding-left: 1.625em;
}

.prose ol {
  list-style-type: decimal;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  padding-left: 1.625em;
}

.prose li {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  line-height: 1.75;
}

.prose ul > li::marker {
  color: var(--color-gray-500);
}

.prose ol > li::marker {
  color: var(--color-gray-500);
}

.prose blockquote {
  font-weight: 500;
  font-style: italic;
  color: var(--color-gray-900);
  border-left: 0.25rem solid var(--color-gray-200);
  quotes: "\201C""\201D""\2018""\2019";
  margin-top: 1.6em;
  margin-bottom: 1.6em;
  padding-left: 1em;
}

.prose code {
  color: var(--color-gray-900);
  font-weight: 600;
  font-size: 0.875em;
  background-color: var(--color-gray-100);
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
}

.prose pre {
  color: var(--color-gray-200);
  background-color: var(--color-gray-800);
  overflow-x: auto;
  font-size: 0.875em;
  line-height: 1.7142857;
  margin-top: 1.7142857em;
  margin-bottom: 1.7142857em;
  border-radius: 0.375rem;
  padding: 0.8571429em 1.1428571em;
}

.prose pre code {
  background-color: transparent;
  border-width: 0;
  border-radius: 0;
  padding: 0;
  font-weight: inherit;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.prose table {
  width: 100%;
  table-layout: auto;
  text-align: left;
  margin-top: 2em;
  margin-bottom: 2em;
  font-size: 0.875em;
  line-height: 1.7142857;
}

.prose thead {
  border-bottom: 1px solid var(--color-gray-300);
}

.prose thead th {
  color: var(--color-gray-900);
  font-weight: 600;
  vertical-align: bottom;
  padding-right: 0.5714286em;
  padding-bottom: 0.5714286em;
  padding-left: 0.5714286em;
}

.prose tbody tr {
  border-bottom: 1px solid var(--color-gray-200);
}

.prose tbody tr:last-child {
  border-bottom-width: 0;
}

.prose tbody td {
  vertical-align: baseline;
  padding: 0.5714286em;
}

.prose hr {
  border-color: var(--color-gray-200);
  border-top-width: 1px;
  margin-top: 3em;
  margin-bottom: 3em;
}

.prose img {
  margin-top: 2em;
  margin-bottom: 2em;
  border-radius: 0.5rem;
}

.prose figure {
  margin-top: 2em;
  margin-bottom: 2em;
}

.prose figure figcaption {
  color: var(--color-gray-600);
  font-size: 0.875em;
  line-height: 1.4285714;
  margin-top: 0.8571429em;
}

/* Max-width Override */
.max-w-none {
  max-width: none;
}

/* Lightbox Styles */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.lightbox-modal.active {
  display: flex;
  opacity: 1;
}

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

.lightbox-content {
  position: relative;
  z-index: 10000;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: 90vh;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.lightbox-caption {
  margin-top: 1rem;
  color: white;
  text-align: center;
  font-size: 0.875rem;
  max-width: 600px;
  padding: 0 1rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10001;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-base);
}

.lightbox-close:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10001;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-base);
}

.lightbox-nav:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.lightbox-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-counter {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 600;
}

/* Prevent body scroll when lightbox is open */
body.lightbox-open {
  overflow: hidden;
}

/* Mobile adjustments for lightbox */
@media (max-width: 640px) {
  .lightbox-nav {
    width: 40px;
    height: 40px;
  }
  
  .lightbox-prev {
    left: 0.5rem;
  }
  
  .lightbox-next {
    right: 0.5rem;
  }
  
  .lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
  }
  
  .lightbox-counter {
    bottom: 0.5rem;
  }
  
  .lightbox-image {
    max-height: calc(90vh - 100px);
  }
}
