/* ==========================================================================
   Ledgerline — site styles
   Tailwind (CDN) carries layout and colour. This file carries the things
   Tailwind utility classes shouldn't: font fallbacks, the paper grain,
   ruled-ledger dividers, the bank-feed ticker, reveal motion, focus rings
   and print behaviour.
   ========================================================================== */

:root {
  --paper: #F6F2EA;
  --paper-50: #FCFAF6;
  --paper-300: #E3DACB;
  --ink: #16130F;
  --ink-400: #8C8275;
  --stamp: #C2410C;
  --stamp-600: #9A3412;
  --ledger: #0F5132;
  --rule: rgba(22, 19, 15, 0.14);
}

* { -webkit-tap-highlight-color: rgba(194, 65, 12, 0.12); }

html { -webkit-text-size-adjust: 100%; }

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1;
  overflow-x: hidden;
}

/* Anchors must clear the sticky header */
:target { scroll-margin-top: 6rem; }
section[id], span[id] { scroll-margin-top: 5.5rem; }

h1, h2, h3, .font-display {
  font-variation-settings: "SOFT" 0, "WONK" 0;
}

/* ---------- Accessibility helpers ---------- */

.sr-only-focusable {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--ink);
  color: var(--paper-50);
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}
.sr-only-focusable:focus {
  left: 1rem;
  top: 1rem;
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Paper grain ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* ---------- Ruled ledger divider ---------- */

.rule {
  height: 8px;
  border-top: 1px solid var(--rule);
  background-image: repeating-linear-gradient(
    to right,
    var(--rule) 0 1px,
    transparent 1px 14px
  );
}

/* ---------- Bank-feed ticker ---------- */

.ticker-mask {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
}

.ticker {
  animation: ticker-scroll 48s linear infinite;
  will-change: transform;
}

.ticker-mask:hover .ticker { animation-play-state: paused; }

@keyframes ticker-scroll {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}

/* ---------- Live-sync dot ---------- */

.pulse-dot { position: relative; }
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 9999px;
  background: var(--ledger);
  opacity: 0.35;
  animation: pulse-ring 2.4s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(0.7); opacity: 0.35; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* ---------- Scroll reveal ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- FAQ disclosure ---------- */

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary:hover span:first-child { color: var(--stamp-600); }

.disclosure {
  transition: transform 0.25s ease;
  display: inline-flex;
}
details[open] .disclosure { transform: rotate(45deg); }

details[open] > p {
  animation: faq-in 0.28s ease-out;
}

@keyframes faq-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Numbers ---------- */

.tabular-nums,
.font-mono { font-variant-numeric: tabular-nums; }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .ticker { animation: none; }
  .pulse-dot::after { animation: none; opacity: 0; }
  details[open] > p { animation: none; }
  .disclosure { transition: none; }
}

/* ---------- Print ---------- */

@media print {
  .grain,
  header,
  .ticker-mask,
  form { display: none !important; }

  body { background: #fff; color: #000; }
  .reveal { opacity: 1 !important; transform: none !important; }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #555;
  }

  section, article, figure { break-inside: avoid; }
}
