/* Pappy & Co Kudos — shared styles */

:root {
  --surface: #161311;
  --surface-container-low: #1f1b19;
  --surface-container: #231f1d;
  --surface-container-high: #2e2927;
  --surface-container-highest: #393431;
  --primary: #f3be55;
  --primary-container: #735300;
  --on-surface: #eae1dd;
  --on-surface-variant: #dac2b6;
  --outline-variant: #54433a;
  --secondary: #dec1b3;
}

html, body {
  background-color: var(--surface);
  color: var(--on-surface);
  font-family: 'Manrope', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  display: inline-block;
  line-height: 1;
  user-select: none;
}

.font-headline { font-family: 'Newsreader', serif; }
.font-body,
.font-label { font-family: 'Manrope', sans-serif; }

/* Ghost border — felt, not seen. 15% opacity outline-variant. */
.ghost-border {
  border: 1px solid rgba(84, 67, 58, 0.15);
}

/* Glassmorphism for overlays — the heavy decanter look. */
.glass-panel {
  background-color: rgba(35, 31, 29, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Brass-plate CTA gradient. */
.primary-gradient {
  background: linear-gradient(135deg, #f3be55 0%, #735300 100%);
}

/* The Kudos Seal — circular reward chip. */
.kudos-seal {
  box-shadow: 0 0 20px rgba(243, 190, 85, 0.2);
}

/* Ambient shadow — soft glow rather than hard drop. */
.ambient-shadow {
  box-shadow: 0 32px 64px rgba(234, 225, 221, 0.06);
}

/* No-scrollbar helper for horizontal scrollers. */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Toast animation */
.toast {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Badge tile idle pulse */
@keyframes sealGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(243, 190, 85, 0); }
  50% { box-shadow: 0 0 28px rgba(243, 190, 85, 0.18); }
}
.seal-glow {
  animation: sealGlow 3.2s ease-in-out infinite;
}

/* Focus ring — sophisticated tertiary instead of primary gold */
:focus-visible {
  outline: 2px solid #ffb3ae;
  outline-offset: 2px;
}

/* Underline input style — Editorial Ledger */
.input-underline {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(84, 67, 58, 0.4);
  color: var(--on-surface);
  -webkit-text-fill-color: var(--on-surface);
  caret-color: #f3be55;
  padding: 0.75rem 0;
  width: 100%;
  font-family: 'Manrope', sans-serif;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}
.input-underline:focus {
  outline: none;
  border-bottom-color: #ffb3ae;
}

/* Kill Safari / Chrome autofill — the yellow/blue tint and the override of
   foreground color that makes typed text look faint on iOS in particular. */
input.input-underline:-webkit-autofill,
input.input-underline:-webkit-autofill:hover,
input.input-underline:-webkit-autofill:focus,
input.input-underline:-webkit-autofill:active,
textarea.reply-input:-webkit-autofill,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--on-surface) !important;
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
  box-shadow: 0 0 0 1000px transparent inset !important;
  transition: background-color 99999s ease-in-out 0s, color 99999s ease-in-out 0s;
  caret-color: #f3be55;
}

/* Reply composer textarea — ensure text is explicitly readable. */
.reply-input {
  color: var(--on-surface);
  -webkit-text-fill-color: var(--on-surface);
  caret-color: #f3be55;
}

/* Page transitions */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up {
  animation: fadeUp 0.45s ease-out both;
}

/* Modal backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background-color: rgba(22, 19, 17, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-backdrop.active { display: flex; }

/* Page loader — shown until the shared ledger arrives from the server. */
#page-loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #161311;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  transition: opacity 0.25s ease;
}
#page-loader.is-hidden { opacity: 0; pointer-events: none; }
#page-loader .loader-inner { display: flex; flex-direction: column; align-items: center; }
#page-loader .loader-spinner {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(243, 190, 85, 0.2);
  border-top-color: #f3be55;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.25rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Light mode — "Aged Parchment"
   Activated by setting data-theme="light" on <html>. Inverts the surface
   tiers to warm cream/tan tones and flips the text palette to deep brown.
   ========================================================================== */
[data-theme="light"] {
  --surface: #faf6f0;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f3ebda;
  --surface-container: #eadfc8;
  --surface-container-high: #e0d2b6;
  --surface-container-highest: #d6c5a3;
  --surface-bright: #fffaf0;
  --surface-variant: #e6d8be;
  --on-surface: #1d1a17;
  --on-surface-variant: #5a493c;
  --secondary: #6b4f3c;
  --outline-variant: #a89b87;
}

[data-theme="light"] body,
[data-theme="light"] html {
  background-color: var(--surface);
  color: var(--on-surface);
}

/* Tailwind surface utilities */
[data-theme="light"] .bg-background,
[data-theme="light"] .bg-surface,
[data-theme="light"] .bg-surface-dim { background-color: var(--surface); }
[data-theme="light"] .bg-surface-container-low { background-color: var(--surface-container-low); }
[data-theme="light"] .bg-surface-container { background-color: var(--surface-container); }
[data-theme="light"] .bg-surface-container-high { background-color: var(--surface-container-high); }
[data-theme="light"] .bg-surface-container-highest { background-color: var(--surface-container-highest); }
[data-theme="light"] .bg-surface-container-lowest { background-color: var(--surface-container-lowest); }
[data-theme="light"] .bg-surface-bright { background-color: var(--surface-bright); }
[data-theme="light"] .bg-surface-variant { background-color: var(--surface-variant); }

/* Hardcoded hex backgrounds used in headers/nav */
[data-theme="light"] .bg-\[\#161311\] { background-color: var(--surface); }
[data-theme="light"] .bg-\[\#1f1b19\] { background-color: var(--surface-container-low); }
[data-theme="light"] .bg-\[\#231f1d\] { background-color: var(--surface-container); }
[data-theme="light"] .bg-\[\#2e2927\] { background-color: var(--surface-container-high); }

/* Text */
[data-theme="light"] .text-on-background,
[data-theme="light"] .text-on-surface { color: var(--on-surface); }
[data-theme="light"] .text-on-surface-variant { color: var(--on-surface-variant); }
[data-theme="light"] .text-secondary,
[data-theme="light"] .text-secondary-fixed-dim { color: var(--secondary); }
[data-theme="light"] .text-outline { color: #8a7a6c; }
[data-theme="light"] .text-outline-variant { color: var(--outline-variant); }
[data-theme="light"] .text-\[\#eae1dd\] { color: var(--on-surface); }
[data-theme="light"] .text-\[\#dec1b3\] { color: var(--secondary); }

/* Primary gold keeps hue but becomes slightly richer on cream */
[data-theme="light"] .text-primary,
[data-theme="light"] .text-\[\#f3be55\] { color: #8b5c00; }

/* Glass panel (bottom nav) */
[data-theme="light"] .glass-panel { background-color: rgba(234, 223, 200, 0.85); }
[data-theme="light"] .bg-\[\#1f1b19\]\/80 { background-color: rgba(243, 235, 218, 0.85); }

/* Ghost border — slightly stronger on light so edges remain felt */
[data-theme="light"] .ghost-border { border-color: rgba(90, 73, 60, 0.2); }
[data-theme="light"] .border-outline-variant\/10 { border-color: rgba(90, 73, 60, 0.15); }
[data-theme="light"] .border-outline-variant\/15 { border-color: rgba(90, 73, 60, 0.2); }
[data-theme="light"] .border-outline-variant\/30 { border-color: rgba(90, 73, 60, 0.3); }
[data-theme="light"] .border-outline\/10 { border-color: rgba(90, 73, 60, 0.15); }
[data-theme="light"] .border-outline\/20 { border-color: rgba(90, 73, 60, 0.2); }

/* Inputs — dark text on light container */
[data-theme="light"] .input-underline {
  color: var(--on-surface);
  -webkit-text-fill-color: var(--on-surface);
  border-bottom-color: rgba(90, 73, 60, 0.3);
}
[data-theme="light"] .input-underline::placeholder { color: #8a7a6c; }
[data-theme="light"] input.input-underline:-webkit-autofill,
[data-theme="light"] textarea.reply-input:-webkit-autofill,
[data-theme="light"] textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--on-surface) !important;
}
[data-theme="light"] .reply-input { color: var(--on-surface); -webkit-text-fill-color: var(--on-surface); }

/* Placeholder tokens across textarea/inputs */
[data-theme="light"] textarea::placeholder,
[data-theme="light"] input::placeholder { color: #8a7a6c; }

/* Loader matches surface */
[data-theme="light"] #page-loader { background: var(--surface); }

/* Login hero gradient */
[data-theme="light"] .login-hero {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(243,190,85,0.18), transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(139,92,0,0.10), transparent 60%),
    var(--surface);
}

/* Ambient shadow is subtler on light bg */
[data-theme="light"] .ambient-shadow {
  box-shadow: 0 16px 40px rgba(90, 73, 60, 0.08);
}

/* Crop mask — the outer darkening ring */
[data-theme="light"] .crop-mask {
  box-shadow: 0 0 0 9999px rgba(250, 246, 240, 0.82);
}

/* Image overlay gradient on profile portrait hover */
[data-theme="light"] .image-overlay {
  background: linear-gradient(0deg, rgba(29,26,23,0.75) 0%, rgba(29,26,23,0) 100%);
}

/* Safe area for iOS bottom nav */
.pb-nav {
  padding-bottom: calc(8rem + env(safe-area-inset-bottom));
}
.bottom-nav {
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}
