@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600;1,700&family=Noto+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Earthy light palette */
  --bg:           #F4ECD9;     /* warm cream — page bg */
  --bg-elev:      #EBE0C5;     /* deeper cream — elevated section bg */
  --bg-card:      #FBF4E2;     /* lightest cream — card surface */
  --border:       rgba(40, 26, 14, 0.10);
  --border-strong:rgba(176, 90, 48, 0.32);
  --text:         #231811;     /* deep walnut */
  --text-muted:   #5C4D3A;     /* warm brown */
  --text-dim:     #998A72;     /* taupe */
  --accent:       #B05A30;     /* terracotta — Arithmo signature */
  --accent-glow:  rgba(176, 90, 48, 0.22);
  --warn:         #553025;     /* deep rust — for "broken" / Multi-LoRA */
  --info:         #7A6A3D;     /* olive — neutral / Baseline */
  /* Chart axis colors derived from theme */
  --axis:         rgba(40, 26, 14, 0.07);
  --axis-strong:  rgba(40, 26, 14, 0.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif', Georgia, ui-serif, serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.sans { font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
.serif { font-family: 'Noto Serif', Georgia, serif; }

/* Headers always use Noto Sans (the user's chosen pairing) */
h1, h2, h3, h4, h5, h6, .headline {
  font-family: 'Noto Sans', -apple-system, system-ui, sans-serif;
}

/* Subtle paper-grid background — lighter, warmer than the dark version */
.grid-bg {
  background-image:
    linear-gradient(rgba(40, 26, 14, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 26, 14, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
}

/* Soft warm glow */
.glow-mint {
  background: radial-gradient(60% 50% at 50% 40%, var(--accent-glow) 0%, transparent 70%);
}

/* Force the navbar onto its own GPU compositing layer so backdrop-filter
   doesn't trigger full-viewport repaints as the user scrolls past the
   strongly-colored hero gradient. Same trick for the gradient overlay
   itself — pinning it to a layer keeps Chrome from re-rasterizing it on
   every scroll frame, which was causing visible flicker. */
.gpu-layer {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

/* Scroll-reveal base */
.reveal {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 900ms cubic-bezier(0.2, 0.7, 0.2, 1),
              transform 900ms cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: opacity, transform;
}
.reveal.is-visible,
.static .reveal {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Static / print mode — show final state of every animation */
@media print {
  .reveal { opacity: 1 !important; transform: none !important; }
  .bar { transform: scaleY(1) !important; }
  .bar-label, .bar-axis { opacity: 1 !important; }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .bar { transform: scaleY(1) !important; transition: none !important; }
  .bar-label, .bar-axis { opacity: 1 !important; transition: none !important; }
  .pulse { animation: none !important; }
  html { scroll-behavior: auto; }
}

/* Stagger children */
.stagger > .reveal { transition-delay: 0ms; }
.stagger > .reveal:nth-child(2) { transition-delay: 80ms; }
.stagger > .reveal:nth-child(3) { transition-delay: 160ms; }
.stagger > .reveal:nth-child(4) { transition-delay: 240ms; }
.stagger > .reveal:nth-child(5) { transition-delay: 320ms; }
.stagger > .reveal:nth-child(6) { transition-delay: 400ms; }

/* Chart bar grow animation */
.bar {
  transform: scaleY(0);
  transform-box: fill-box;
  transform-origin: bottom;
  transition: transform 1.05s cubic-bezier(0.34, 0, 0.2, 1);
  will-change: transform;
}
.is-visible .bar,
.static .bar { transform: scaleY(1); }
.bar.bar-1 { transition-delay: 60ms;  }
.bar.bar-2 { transition-delay: 180ms; }
.bar.bar-3 { transition-delay: 300ms; }

.bar-label {
  opacity: 0;
  transition: opacity 500ms ease;
}
.is-visible .bar-label,
.static .bar-label { opacity: 1; }
.bar-label.bar-label-1 { transition-delay: 880ms;  }
.bar-label.bar-label-2 { transition-delay: 1000ms; }
.bar-label.bar-label-3 { transition-delay: 1120ms; }

.bar-axis {
  opacity: 0;
  transition: opacity 500ms ease;
  transition-delay: 200ms;
}
.is-visible .bar-axis,
.static .bar-axis { opacity: 1; }

/* Subtle pulse for the brand dot */
@keyframes pulse-accent {
  0%, 100% { box-shadow: 0 0 0 0 rgba(176, 90, 48, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(176, 90, 48, 0); }
}
.pulse { animation: pulse-accent 2.4s ease-out infinite; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 200ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #FBF4E2;
}
.btn-primary:hover {
  background: #C56938;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -8px var(--accent-glow);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
  background: rgba(176, 90, 48, 0.06);
  border-color: var(--accent);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 14px 30px -22px rgba(40, 26, 14, 0.18);
}

/* Card-flat — same shape, no visible chrome (for use on the hero where the
   parent section bg already matches --bg-card, so the card "lays flat"). */
.card-flat {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 14px;
  padding: 1.5rem;
}

/* Mermaid diagram wrapper */
.mermaid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}
.mermaid-wrapper svg {
  max-width: 100%;
  height: auto;
  font-family: 'Noto Sans', system-ui, sans-serif !important;
}

/* "Large" diagram variant — fills its container width.
   Note: do NOT change font-size here, or mermaid's measured rect widths
   won't match the rendered text and labels will overflow. The text size
   is set in mermaid.initialize() (themeVariables.fontSize). */
.mermaid-wrapper.diagram-lg svg {
  width: 100%;
  height: auto;
}

/* Animated flow along mermaid connection lines. Mermaid renders the actual
   stroked edge as <path class="flowchart-link …"> inside .edgePaths. We give
   it a dashed pattern and march the dash offset to suggest data flowing from
   request → shared base → LoRA. */
@keyframes mermaid-flow {
  to { stroke-dashoffset: -24; }
}
/* Animate ONLY the highlighted route: Request B → Shared Base → LoRA B.
   Mermaid v11 stamps each edge with id="L_<src>_<tgt>_<idx>" (sometimes
   with dashes) and class="...LS-<src> LE-<tgt>...". We try all the
   plausible selectors so at least one matches whatever build is loaded. */
.mermaid-wrapper svg path.flowchart-link.LS-R2.LE-S,
.mermaid-wrapper svg path.flowchart-link.LS-S.LE-L2,
.mermaid-wrapper svg path[id^="L_R2_S"],
.mermaid-wrapper svg path[id^="L_S_L2"],
.mermaid-wrapper svg path[id^="L-R2-S"],
.mermaid-wrapper svg path[id^="L-S-L2"],
.mermaid-wrapper svg path.arithmo-flow {
  stroke-dasharray: 6 6 !important;
  animation: mermaid-flow 1.4s linear infinite;
  stroke: var(--accent) !important;
  stroke-width: 2.5px !important;
}
@media (prefers-reduced-motion: reduce) {
  .mermaid-wrapper svg path.flowchart-link.LS-R2.LE-S,
  .mermaid-wrapper svg path.flowchart-link.LS-S.LE-L2,
  .mermaid-wrapper svg path[id^="L_R2_S"],
  .mermaid-wrapper svg path[id^="L_S_L2"],
  .mermaid-wrapper svg path[id^="L-R2-S"],
  .mermaid-wrapper svg path[id^="L-S-L2"],
  .mermaid-wrapper svg path.arithmo-flow {
    animation: none !important;
    stroke-dasharray: none !important;
  }
}

/* Tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(176, 90, 48, 0.10);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* Toggle */
.toggle-group {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.toggle-btn {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 180ms ease;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.04em;
}
.toggle-btn.active {
  background: var(--accent);
  color: #FBF4E2;
}

/* Section dividers */
section { position: relative; }
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* Headline — Noto Sans, modern */
.headline {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.04;
  color: var(--text);
}

/* Soft underline highlight using accent */
.mark-accent {
  background: linear-gradient(180deg, transparent 62%, rgba(176, 90, 48, 0.28) 62%);
  padding: 0 2px;
}

/* Numeric pop — keep monospace for tabular feel */
.metric {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Body text helpers */
.body-text {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text-muted);
}

/* Text selection */
::selection {
  background: var(--accent);
  color: #FBF4E2;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(40, 26, 14, 0.18); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(40, 26, 14, 0.28); }
