/* OrdnungKI — design tokens + base styles */

:root {
  --font-display: 'Inter', system-ui, sans-serif;
  --font-sans: 'Inter', system-ui, sans-serif;

  /* Cream */
  --cream-50: #FDFBF5;
  --cream-100: #FAF6EC;
  --cream-200: #F2EBD9;
  --cream-300: #E8DEC2;

  /* Ink (deep blue) */
  --ink-50: #EEF2F7;
  --ink-100: #D9E1ED;
  --ink-400: #5B7BA8;
  --ink-600: #2C4B7E;
  --ink-700: #1F3963;
  --ink-900: #0F1E3A;

  /* Terra */
  --terra-50: #FBF0EA;
  --terra-100: #F5DBCB;
  --terra-400: #D88A66;
  --terra-600: #B05A35;
  --terra-700: #8B4424;

  /* Sage */
  --sage-50: #EEF3EC;
  --sage-100: #D6E1D2;
  --sage-400: #7FA177;
  --sage-600: #4F7A48;
  --sage-700: #3A5C35;

  /* Mustard */
  --mustard-50: #FAF2DC;
  --mustard-100: #F2E0A8;
  --mustard-400: #D9B14A;
  --mustard-600: #A37D1F;
  --mustard-700: #7A5C12;

  /* Ink text neutrals */
  --ink-text-900: #1A1815;
  --ink-text-700: #3D3A33;
  --ink-text-500: #6B665C;
  --ink-text-400: #8B8578;

  /* Shadows */
  --shadow-soft: 0 1px 2px rgba(26, 24, 21, 0.04), 0 2px 6px rgba(26, 24, 21, 0.04);
  --shadow-card: 0 1px 3px rgba(26, 24, 21, 0.04), 0 8px 24px rgba(26, 24, 21, 0.06);
  --shadow-lift: 0 4px 6px rgba(26, 24, 21, 0.06), 0 16px 40px rgba(26, 24, 21, 0.12);
  --glass-bg: rgba(250, 246, 236, 0.85);
  --glass-border: rgba(26, 24, 21, 0.08);
}

[data-theme="dark"] {
  --cream-50: #0F1E3A;
  --cream-100: #0A1428;
  --cream-200: #1F3963;
  --cream-300: #2C4B7E;
  
  --ink-text-900: #FAF6EC;
  --ink-text-700: #F2EBD9;
  --ink-text-500: #D9E1ED;
  --ink-text-400: #5B7BA8;

  --ink-900: #FAF6EC;
  --ink-700: #EEF2F7;
  
  --glass-bg: rgba(10, 20, 40, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
  
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream-100);
  color: var(--ink-text-900);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease, color 0.3s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.3;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

#app { position: relative; z-index: 1; }

.premium-card {
  background: var(--cream-50);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.premium-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: rgba(26, 24, 21, 0.15);
}

::selection {
  background: var(--ink-600);
  color: var(--cream-100);
}

button { font-family: inherit; cursor: pointer; }

.display-text {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  font-weight: 500;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.subtle-grid {
  background-image:
    linear-gradient(to right, rgba(26,24,21,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(26,24,21,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

.shimmer-bg {
  background: linear-gradient(
    100deg,
    var(--cream-200) 0%,
    var(--cream-300) 40%,
    var(--cream-200) 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.animate-pulse-dot { animation: pulseDot 1.6s ease-in-out infinite; }

.fade-up { animation: fadeUp 0.5s cubic-bezier(0.2, 0.6, 0.2, 1) both; }
.fade-in { animation: fadeIn 0.4s ease-out both; }
.scale-in { animation: scaleIn 0.25s cubic-bezier(0.2, 0.6, 0.2, 1) both; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--cream-100); }
::-webkit-scrollbar-thumb { background: var(--cream-300); border-radius: 8px; border: 2px solid var(--cream-100); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-text-400); }

/* Focus */
button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--ink-600);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Modal overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 58, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
}

/* Custom Features */
.checklist-item {
  transition: background 0.15s ease;
}
.checklist-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.trans-btn {
  transition: all 0.2s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.trans-btn:hover {
  transform: translateY(-1px);
}

.risk-alert {
  border-left: 4px solid var(--terra-600) !important;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* Accessibility Modes */
:root {
  --a11y-scale: 1;
}

/* Apply filters ONLY to the content, not the accessibility UI */
body.a11y-grayscale #app-content { filter: grayscale(100%) !important; }
body.a11y-invert #app-content { filter: invert(100%) hue-rotate(180deg) !important; }

body.a11y-high-contrast {
  --cream-50: #000 !important;
  --cream-100: #000 !important;
  --cream-200: #333 !important;
  --ink-900: #FFFF00 !important;
  --ink-700: #FFFF00 !important;
  --ink-text-900: #FFFF00 !important;
  --ink-text-700: #FFFF00 !important;
  --ink-text-500: #FFFF00 !important;
  --glass-bg: #000 !important;
  --glass-border: #FFFF00 !important;
}

body.a11y-dyslexia {
  font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
}

html {
  /* Base size */
}

#app-content {
  zoom: var(--a11y-scale);
  transform-origin: top center;
  transition: zoom 0.2s ease-out;
}

/* Floating Accessibility Button - ALWAYS FIXED */
.a11y-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--ink-700);
  color: white;
  border: 4px solid white;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2000; /* Extremely high */
  transition: all 0.2s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.a11y-fab:hover {
  transform: scale(1.05) translateY(-2px);
  background: var(--ink-900);
}

.a11y-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 340px;
  max-width: calc(100vw - 48px);
  background: white;
  color: #1a1815; /* Always dark text for panel */
  border-radius: 24px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.3);
  border: 2px solid var(--ink-700);
  padding: 24px;
  z-index: 2001;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Reset filters for panel */
  filter: none !important;
}

/* High Contrast Override for Panel itself */
body.a11y-high-contrast .a11y-panel {
  background: #000 !important;
  border-color: #FFFF00 !important;
  color: #FFFF00 !important;
}
body.a11y-high-contrast .a11y-fab {
  background: #FFFF00 !important;
  color: #000 !important;
  border-color: #000 !important;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.a11y-label {
  font-size: 15px;
  font-weight: 700;
}
.a11y-toggle {
  width: 50px;
  height: 28px;
  background: #eee;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  border: 2px solid #ddd;
  transition: all 0.2s;
}
.a11y-toggle.active {
  background: var(--ink-700);
  border-color: var(--ink-700);
}
body.a11y-high-contrast .a11y-toggle.active {
  background: #FFFF00 !important;
  border-color: #FFFF00 !important;
}
.a11y-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 999px;
  transition: transform 0.2s;
}
.a11y-toggle.active::after {
  transform: translateX(22px);
}
body.a11y-high-contrast .a11y-toggle::after {
  background: #000;
}
