@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Inter:wght@300;400;500&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  --royal-purple: #5E2A5E;
  --deep-teal: #1E4D4D;
  --antique-gold: #D4AF37;
  --ivory-white: #FDF8F0;
  --dark-ink: #1A1A2E;
}

body {
  background-color: var(--ivory-white);
  color: var(--dark-ink);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background-image: url('parchment-bg.jpg');
  background-blend-mode: multiply;
  background-size: cover;
  background-attachment: fixed;
  animation: ambient-breathe 8s ease-in-out infinite alternate;
  position: relative;
}

/* Global Noise Layer */
body::after {
  content: "";
  position: fixed;
  top: -100%;
  left: -100%;
  width: 300%;
  height: 300%;
  background-image: url("https://www.transparenttextures.com/patterns/natural-paper.png");
  opacity: 0.15;
  pointer-events: none;
  z-index: 100;
  animation: grain 8s steps(10) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -5%); }
  20% { transform: translate(-10%, 5%); }
  30% { transform: translate(5%, -10%); }
  40% { transform: translate(-5%, 15%); }
  50% { transform: translate(-10%, 5%); }
  60% { transform: translate(15%, 0); }
  70% { transform: translate(0, 10%); }
  80% { transform: translate(-15%, 0); }
  90% { transform: translate(10%, 5%); }
  100% { transform: translate(5%, 0); }
}

@keyframes ambient-breathe {
  0% { background-color: rgba(253, 248, 240, 1); }
  100% { background-color: rgba(240, 230, 215, 1); }
}

/* Scroll Reveal */
.reveal-hidden {
  opacity: 0;
  transform: translateY(20px);
  transition: all 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-active {
  opacity: 1;
  transform: translateY(0);
}

h1, h2, h3, h4, h5, h6, .font-serif {
  font-family: 'Playfair Display', serif;
}

.font-mono {
  font-family: 'Fira Code', monospace;
}

/* Custom Selection */
::selection {
  background: var(--antique-gold);
  color: var(--dark-ink);
}

/* Scrollbar Override */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--ivory-white);
}
::-webkit-scrollbar-thumb {
  background: var(--dark-ink);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--royal-purple);
}

.custom-scrollbar-wide::-webkit-scrollbar {
  width: 10px;
}
.custom-scrollbar-wide::-webkit-scrollbar-thumb {
  background: rgba(26, 26, 46, 0.4);
  border: 2px solid var(--ivory-white);
}

body {
  background-color: var(--ivory-white);
  color: var(--dark-ink);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background-image: url('parchment-bg.jpg');
  background-blend-mode: multiply;
  background-size: cover;
  background-attachment: fixed;
  position: relative;
}
.ledger-border:hover {
  box-shadow: inset 0 0 15px rgba(0,0,0,0.05), 
              12px 12px 25px rgba(0, 0, 0, 0.2),
              16px 16px 0px rgba(212, 175, 55, 0.1); 
  transform: translateY(-2px);
}

.wax-seal-container {
  position: relative;
  display: inline-block;
  transition: transform 0.3s ease;
}
.wax-seal-container:hover {
  transform: scale(1.05);
}
.wax-seal-container::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 120%;
  border-radius: 50%;
  box-shadow: inset 0 0 20px rgba(212, 175, 55, 0);
  transition: all 0.3s ease;
  pointer-events: none;
}
.wax-seal-container:hover::after {
  box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.5);
}

/* Ledger interactions */
.ledger-cover {
  cursor: pointer;
  perspective: 1000px;
}

/* Smooth Compass scroll */
html {
  scroll-behavior: smooth;
}
.compass-point {
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}
.compass-point:hover {
  color: var(--antique-gold);
  transform: scale(1.15);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}
.compass-point:hover p {
  opacity: 0.8;
  transform: translateY(-5px);
}

/* Horizontal scroll hide */
.hide-scroll::-webkit-scrollbar {
  display: none;
}
.hide-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Ledger flip effect */
.folio-card {
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: left center;
  position: relative;
  overflow: hidden;
}
.folio-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: 0.5s;
}
.folio-card:hover::before {
  left: 100%;
}
.folio-card:hover {
  border-color: var(--antique-gold);
}
.folio-card:hover .pull-tab {
  background-color: var(--antique-gold);
  color: var(--ivory-white);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

/* Ink Bleed Effect */
.ink-spread {
  position: relative;
}
.ink-spread::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; width: 0; height: 1px;
  background: var(--royal-purple);
  transition: width 0.3s ease;
  filter: blur(1px);
}
.ink-spread:hover::after {
  width: 100%;
}

/* Hand drawn lines */
.drawn-line {
  width: 100%;
  height: 2px;
  background-image: linear-gradient(to right, transparent, var(--dark-ink), var(--royal-purple), var(--dark-ink), transparent);
  background-size: 200% auto;
  opacity: 0.6;
  animation: ink-flow 4s linear infinite;
}
@keyframes ink-flow {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.ticker-wrap {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  border-top: 1px solid var(--dark-ink);
  border-bottom: 1px solid var(--dark-ink);
  background: rgba(253, 248, 240, 0.95);
}
.ticker-move {
  display: inline-block;
  animation: ticker 40s linear infinite;
}
.ticker-move:hover {
  animation-play-state: paused;
}
@keyframes ticker {
  0% { transform: translateX(10%); }
  100% { transform: translateX(-100%); }
}

/* Drawer interactions */
.drawer {
  border: 1px solid var(--dark-ink);
  background: var(--ivory-white);
  box-shadow: inset -2px -2px 5px rgba(0,0,0,0.05), inset 2px 2px 5px rgba(255,255,255,0.5);
  transition: background 0.3s;
}
.drawer:hover {
  background: rgba(212, 175, 55, 0.1);
}

/* Tables */
.ledger-table {
  width: 100%;
  border-collapse: collapse;
}
.ledger-table th {
  border-bottom: 2px solid var(--dark-ink);
  padding: 12px 8px;
  text-align: left;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: var(--royal-purple);
}
.ledger-table td {
  padding: 12px 8px;
  border-bottom: 1px dotted rgba(26, 26, 46, 0.3);
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
}

/* Input Fields */
.scroll-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--dark-ink);
  outline: none;
  font-family: 'Fira Code', monospace;
  color: var(--deep-teal);
  padding: 2px 0;
  border-radius: 0;
}
.scroll-input:focus {
  border-bottom: 1px solid var(--antique-gold);
}
