/* ==============================
   bruch-rechner.de – Custom Styles
   Design System v2 (from UX spec)
   ============================== */

/* --- Design Tokens --- */
:root {
  --color-navy-900: #0F172A;
  --color-navy-800: #1E3A8A;
  --color-blue-600: #2563EB;
  --color-blue-500: #3B82F6;
  --color-blue-100: #DBEAFE;
  --color-emerald-600: #059669;
  --color-emerald-500: #34D399;
  --color-emerald-100: #D1FAE5;
  --color-emerald-50: #ECFDF5;
  --color-amber-500: #F59E0B;
  --color-amber-50: #FFFBEB;
  --color-slate-50: #F8FAFC;
  --color-slate-200: #E2E8F0;
  --color-slate-400: #94A3B8;
  --color-slate-600: #475569;
  --color-slate-900: #0F172A;
  --color-red-600: #DC2626;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* --- Self-hosted Fonts (GDPR-compliant) --- */

/* Lexend – Headings & Calculator Result */
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/lexend-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/lexend-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Source Sans 3 – Body Text */
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/source-sans-3-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/source-sans-3-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* IBM Plex Mono – Formulas & Calculation Steps */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Hero Section --- */
.hero {
  background: linear-gradient(135deg, var(--color-navy-800) 0%, var(--color-blue-600) 50%, var(--color-blue-500) 100%);
  padding: var(--space-2xl) var(--space-md) var(--space-3xl);
  text-align: center;
  position: relative;
}
@media (min-width: 768px) {
  .hero {
    padding: var(--space-3xl) var(--space-lg) 80px;
  }
}
.hero h1 {
  font-family: 'Lexend', sans-serif;
  font-weight: 700;
  font-size: 28px;
  color: #fff;
  margin: 0 0 var(--space-sm);
}
@media (min-width: 768px) {
  .hero h1 { font-size: 40px; }
}
.hero .tagline {
  font-family: 'Source Sans 3', sans-serif;
  color: rgba(255,255,255,0.85);
  font-size: 16px;
  margin: 0;
}
@media (min-width: 768px) {
  .hero .tagline { font-size: 18px; }
}

/* --- Calculator Card --- */
.calc-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  padding: var(--space-lg);
  margin-top: -40px;
  position: relative;
  z-index: 10;
}
@media (min-width: 768px) {
  .calc-card {
    padding: var(--space-xl);
  }
}

/* --- Result Animation --- */
@keyframes resultFade {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}
.result-fade {
  animation: resultFade 200ms ease-out;
}

/* --- Fraction bar animated width --- */
@keyframes barGrow {
  from { width: 0; }
  to   { width: 100%; }
}

/* --- Fraction Display (inline, for content) --- */
.fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.15em;
}
.fraction .num,
.fraction .den {
  display: block;
  text-align: center;
  padding: 0 0.2em;
  line-height: 1.3;
}
.fraction .num {
  border-bottom: 2px solid currentColor;
}

/* --- Fraction Input Group --- */
.fraction-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.fraction-input input {
  width: 80px;
  text-align: center;
  padding: 12px 8px;
  border: 1.5px solid var(--color-slate-200);
  border-radius: var(--radius-sm);
  font-size: 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  background: var(--color-slate-50);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  min-height: 48px;
}
@media (min-width: 768px) {
  .fraction-input input {
    width: 120px;
    font-size: 24px;
  }
}
.fraction-input input:focus {
  outline: none;
  border-color: var(--color-blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.fraction-input .frac-line {
  width: 100%;
  height: 2px;
  background: var(--color-slate-900);
  margin: 2px 0;
}

/* --- Input Validation --- */
.input-valid input {
  border-color: var(--color-emerald-600) !important;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15) !important;
}
.input-invalid input {
  border-color: var(--color-red-600) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15) !important;
}

/* --- Operator Pills (single row) --- */
.op-pills {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: nowrap;
}
.op-btn {
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  font-size: 1.35rem;
  font-weight: 700;
  border: 1.5px solid var(--color-slate-200);
  background: #fff;
  color: var(--color-slate-600);
  cursor: pointer;
  transition: all 200ms ease;
}
@media (min-width: 768px) {
  .op-btn { min-width: 64px; }
}
.op-btn:hover {
  border-color: var(--color-blue-500);
  color: var(--color-navy-800);
}
.op-btn.active {
  background: linear-gradient(135deg, var(--color-navy-800), var(--color-blue-600));
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

/* --- Mode Pill Buttons --- */
.mode-btn {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1.5px solid var(--color-slate-200);
  background: var(--color-slate-50);
  color: var(--color-slate-600);
  cursor: pointer;
  transition: all 200ms ease;
  white-space: nowrap;
}
.mode-btn:hover {
  border-color: var(--color-blue-500);
  color: var(--color-navy-800);
}
.mode-btn.active {
  background: linear-gradient(135deg, var(--color-navy-800), var(--color-blue-600));
  color: #fff;
  border-color: transparent;
}

/* --- Result Section --- */
.result-box {
  background: linear-gradient(135deg, var(--color-emerald-50), var(--color-emerald-100));
  border-left: 4px solid var(--color-emerald-600);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
}
.result-box .result-fraction {
  font-family: 'Lexend', sans-serif;
  font-weight: 700;
  font-size: 32px;
  color: var(--color-emerald-600);
}
@media (min-width: 768px) {
  .result-box .result-fraction { font-size: 48px; }
}
.result-box .result-frac-line {
  height: 3px;
  background: var(--color-emerald-600);
  margin: 2px auto;
  animation: barGrow 200ms ease-out;
}
.result-box .result-decimal {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  color: var(--color-slate-600);
  margin-top: var(--space-sm);
}

/* --- Error State in Result --- */
.result-box.error {
  background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
  border-left-color: var(--color-red-600);
}
.result-box.error .result-fraction {
  color: var(--color-red-600);
}

/* --- Rechenweg (Calculation Steps) --- */
.rechenweg {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.8;
  background: var(--color-slate-50);
  border-left: 3px solid var(--color-blue-500);
  padding: var(--space-md) var(--space-lg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}
.rechenweg .step {
  color: var(--color-slate-600);
}
.rechenweg .step-result {
  color: var(--color-emerald-600);
  font-weight: 600;
}

/* --- Quick Guide --- */
.quick-guide {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}
@media (min-width: 768px) {
  .quick-guide {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
  }
}
.quick-guide-step {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
}
.quick-guide-step .step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-navy-800), var(--color-blue-600));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lexend', sans-serif;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: var(--space-sm);
}
.quick-guide-step h3 {
  font-family: 'Lexend', sans-serif;
  font-weight: 600;
  font-size: 16px;
  margin: var(--space-sm) 0 var(--space-xs);
  color: var(--color-slate-900);
}
.quick-guide-step p {
  font-size: 14px;
  color: var(--color-slate-600);
  margin: 0;
}

/* --- Content Cards --- */
.content-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  padding: var(--space-xl);
}
@media (max-width: 767px) {
  .content-card {
    padding: var(--space-lg);
  }
}

/* --- Footer --- */
.footer-gradient {
  background: linear-gradient(135deg, var(--color-navy-800), var(--color-navy-900));
}

/* --- Copy Button --- */
.copy-success {
  color: var(--color-emerald-600) !important;
}

/* --- Scroll margin for anchors --- */
[id] {
  scroll-margin-top: 80px;
}

/* --- Accessibility: Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .result-fade { animation: none; }
  .result-box .result-frac-line { animation: none; }
  .rechenweg { transition: none; }
}
