/* ————— Self-hosted fonts ————— */
/* Instrument Serif (display) — brand display font, loaded via @font-face. */
@font-face {
    font-family: "Instrument Serif";
    src: url("fonts/InstrumentSerif-Regular.5eb8d8adf794.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Instrument Serif";
    src: url("fonts/InstrumentSerif-Italic.3e1d24645b0d.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

/* Instrument Sans (body/sans) — primary UI font. */
@font-face {
    font-family: "Instrument Sans";
    src: url("fonts/InstrumentSans-Regular.9f0f2f6fae7d.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Instrument Sans";
    src: url("fonts/InstrumentSans-Medium.9f66f61a3c1e.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Instrument Sans";
    src: url("fonts/InstrumentSans-SemiBold.0cc1ab9c861e.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Instrument Sans";
    src: url("fonts/InstrumentSans-Bold.9507ef68b69d.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* IBM Plex Mono (monospace) — for code, addresses, labels. */
@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/IBMPlexMono-Regular.560033d0c7f2.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/IBMPlexMono-Medium.63c2dc54dd9c.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/IBMPlexMono-SemiBold.4c2f3714b6a4.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ————— SPayFi design system · scroll entry, ambient, ledger ————— */
/* Companion to the Tailwind token layer defined in base.html. Motion only  */
/* ever animates transform + opacity. Nothing layout-triggering.            */

/* Scroll entry ------------------------------------------------------- */
/* Hidden state only applies when JS confirmed it is present (.js), so  */
/* pages stay fully readable if the static file ever fails to load.     */
.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: calc(var(--index, 0) * 80ms);
  will-change: transform, opacity;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Card lift hover (diffuse, near-invisible shadow) ------------------- */
.lift {
  transition:
    box-shadow 200ms ease,
    transform 200ms ease;
}

.lift:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.lift:active {
  transform: scale(0.985);
}

/* Ledger "watching the chain" tick ----------------------------------- */
.ledger-tick {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background-color: #346538;
  animation: ledger-pulse 2.4s ease-in-out infinite;
}

.ledger-tick::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  border: 1px solid rgba(52, 101, 56, 0.35);
  animation: ledger-ripple 2.4s ease-out infinite;
}

@keyframes ledger-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes ledger-ripple {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Ambient radial light (hero atmosphere) ------------------------------ */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.ambient::before,
.ambient::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
}

.ambient::before {
  width: 640px;
  height: 640px;
  top: -180px;
  right: -120px;
  background: radial-gradient(circle, rgba(225, 243, 254, 0.55), transparent 70%);
}

.ambient::after {
  width: 520px;
  height: 520px;
  bottom: -200px;
  left: -160px;
  background: radial-gradient(circle, rgba(243, 235, 205, 0.5), transparent 70%);
}

/* Slow drifting blob (optional hero atmosphere) ------------------------ */
.drift {
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(40px, 16px, 0) scale(1.06); }
}

/* Keystrokes & micro meta --------------------------------------------- */
kbd {
  display: inline-block;
  border: 1px solid #eaeaea;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f7f6f3;
  padding: 1px 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  color: #2f3437;
}

/* Selection ----------------------------------------------------------- */
::selection {
  background: #e1f3fe;
  color: #1f6c9f;
}

/* Focus visibility (quality floor) ------------------------------------ */
:focus-visible {
  outline: 2px solid #1f6c9f;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Hairline helpers ---------------------------------------------------- */
.hairline {
  border: 1px solid #eaeaea;
}

/* App shell sidebar --------------------------------------------------- */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 400;
  color: #787774;
  transition: background-color 150ms ease, color 150ms ease;
}

.sidebar-link svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background-color: #f1f0ee;
  color: #111111;
}

.sidebar-link.active {
  background-color: #f1f0ee;
  color: #111111;
  font-weight: 500;
}

html.dark .sidebar-link {
  color: #a19f9d;
}

html.dark .sidebar-link:hover {
  background-color: #262625;
  color: #f5f5f4;
}

html.dark .sidebar-link.active {
  background-color: #262625;
  color: #f5f5f4;
}

html.dark .hover\:bg-bone:hover,
html.dark .divide-hairline tr:hover {
  background-color: #1a1a19 !important;
}

/* Reduced motion: kill everything, keep states ------------------------ */
@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    transition: none;
    transform: none;
  }

  .reveal.is-visible {
    opacity: 1;
  }

  .lift,
  .ledger-tick,
  .ledger-tick::after,
  .drift {
    animation: none !important;
    transition: none !important;
  }

  * {
    scroll-behavior: auto !important;
  }
}

/* Dark mode overrides ------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  .js .reveal {
    /* reveal animation still runs in dark mode */
  }
}

html.dark .ambient::before {
  background: radial-gradient(circle, rgba(42, 66, 96, 0.55), transparent 70%);
}

html.dark .ambient::after {
  background: radial-gradient(circle, rgba(63, 58, 50, 0.5), transparent 70%);
}

html.dark ::selection {
  background: #3b527b;
  color: #93c5fd;
}

html.dark :focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

html.dark .hairline {
  border-color: #2e2e2d;
}

html.dark .lift:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dark mode color overrides */
html.dark .bg-canvas { background-color: #0f0f0e; }
html.dark .bg-surface\/80 { background-color: rgba(23, 23, 22, 0.85); }
html.dark .bg-surface\/50 { background-color: rgba(23, 23, 22, 0.5); }
html.dark .bg-ink { background-color: #f5f5f4; }
html.dark .hover\:bg-charcoal:hover { background-color: #3a3835; }
html.dark .bg-surface { background-color: #171716; }
html.dark .bg-bone { background-color: #1c1c1b; }
html.dark .bg-pale-green-bg { background-color: #142d1c; }
html.dark .bg-pale-blue-bg { background-color: #142240; }
html.dark .bg-pale-yellow-bg { background-color: #3d2a0c; }
html.dark .bg-pale-red-bg { background-color: #4a1a18; }
html.dark .text-ink { color: #f5f5f4; }
html.dark .text-charcoal { color: #d4d0cb; }
html.dark .text-muted { color: #a19f9d; }
html.dark .text-muted-bright { color: #8a857c; }
html.dark .text-pale-green { color: #4ade80; }
html.dark .text-pale-blue { color: #60a5fa; }
html.dark .text-pale-yellow { color: #fbbf24; }
html.dark .text-pale-red { color: #ff6b6b; }
html.dark .border-hairline { border-color: #2e2e2d; }
html.dark .border-hairline-dark { border-color: #3a3835; }
html.dark .bg-black\/30 { background-color: rgba(0,0,0,0.3); }

/* Dark mode input/textarea/select overrides */
html.dark input,
html.dark textarea,
html.dark select {
    background-color: #1c1c1b !important;
    color: #f5f5f4 !important;
    border-color: #2e2e2d !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: #8a857c !important;
}

html.dark input:focus,
html.dark textarea:focus,
html.dark select:focus {
    border-color: #60a5fa !important;
    outline: none;
}
html.dark .bg-white\/10 { background-color: rgba(255,255,255,0.06); }
html.dark .bg-white\/30 { background-color: rgba(255,255,255,0.12); }
html.dark .bg-white\/50 { background-color: rgba(255,255,255,0.2); }
html.dark .text-canvas\/90 { color: rgba(245,245,244,0.9); }
html.dark .text-white\/40 { color: rgba(245,245,244,0.4); }
html.dark .text-white\/50 { color: rgba(245,245,244,0.5); }
html.dark .divide-hairline > :not([hidden]) ~ :not([hidden]) { border-top-color: #2e2e2d; }

/* Dark mode code element overrides */
html.dark code {
    background-color: #1c1c1b !important;
    color: #60a5fa !important;
    padding: 0.125rem 0.375rem !important;
    border-radius: 4px !important;
    border: 1px solid #2e2e2d !important;
}

html.dark .text-pale-blue,
html.dark .text-pale-green,
html.dark .text-pale-yellow,
html.dark .text-pale-red {
    color: #60a5fa !important;
}

html.dark code.text-pale-blue,
html.dark code.text-pale-green,
html.dark code.text-pale-yellow,
html.dark code.text-pale-red {
    background-color: #1c1c1b !important;
    border: 1px solid #2e2e2d !important;
    border-radius: 4px !important;
    padding: 0.125rem 0.375rem !important;
}


/* ————— API Reference (Stripe-style docs) ————— */
.code-scroll::-webkit-scrollbar { height: 8px; }
.code-scroll::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 4px; }
.code-scroll::-webkit-scrollbar-track { background: transparent; }

.method-badge {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-weight: 600;
    letter-spacing: 0.02em;
}
