/* ===== Risale-i Nur Lûgat — Global Styles ===== */

/* ---------- CSS Variables ---------- */
:root {
  --rnl-font-size: 18px;
}

/* ---------- Sepia Theme ---------- */
[data-rnl-theme="sepia"] #app {
  filter: sepia(0.35) saturate(0.85) brightness(0.97) hue-rotate(-5deg);
}

/* ---------- Dynamic Font Size ---------- */
.rnl-meaning {
  font-size: var(--rnl-font-size) !important;
  line-height: 1.7 !important;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: #181012;
  overflow-x: hidden;
}

/* ---------- Glassmorphism Utilities ---------- */
.glass-panel {
  background: rgba(35, 21, 24, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.glass-panel-solid {
  background: linear-gradient(145deg, rgba(45, 28, 32, 0.95) 0%, rgba(25, 14, 17, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}
.glass-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}
.glass-card:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.98);
}
.glass-button-primary {
  background: linear-gradient(135deg, rgba(199, 0, 36, 0.9), rgba(158, 0, 29, 0.95));
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px 0 rgba(199, 0, 36, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.glass-button-primary:active {
  transform: scale(0.96);
  box-shadow: 0 4px 16px 0 rgba(199, 0, 36, 0.2);
}

/* ---------- Input Glass ---------- */
.input-glass {
  background: rgba(30, 15, 18, 0.85);
  background-color: rgba(30, 15, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.95);
  caret-color: #ffffff;
  transition: all 0.3s ease;
  -webkit-appearance: none;
  appearance: none;
}
.input-glass::placeholder {
  color: rgba(255, 255, 255, 0.40) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.40) !important;
  opacity: 1;
}
.input-glass:focus {
  background: rgba(0, 0, 0, 0.35);
  border-color: #c70024;
  box-shadow: 0 0 0 2px rgba(199, 0, 36, 0.3);
  outline: none;
}
/* Prevent mobile/browser autofill from forcing white background + unreadable text */
.input-glass:-webkit-autofill,
.input-glass:-webkit-autofill:hover,
.input-glass:-webkit-autofill:focus {
  -webkit-text-fill-color: rgba(255, 255, 255, 0.95) !important;
  -webkit-box-shadow: 0 0 0 1000px rgba(30, 15, 18, 1) inset !important;
  transition: background-color 9999s ease-in-out 0s;
}

/* ---------- Liquid Button ---------- */
.btn-liquid {
  background: linear-gradient(180deg, #d91c3d 0%, #c70024 50%, #9e001d 100%);
  box-shadow: 0 4px 15px rgba(199, 0, 36, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.4), inset 0 -2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.btn-liquid:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(199, 0, 36, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

/* ---------- Liquid Large Button ---------- */
.liquid-button {
  background: linear-gradient(135deg, #e6002a 0%, #a3001d 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3), inset 0 -2px 4px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(199, 0, 36, 0.5);
  position: relative;
  overflow: hidden;
}
.liquid-button::after {
  content: '';
  position: absolute;
  top: 10%; left: 15%;
  width: 30%; height: 20%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0) 100%);
  filter: blur(1px);
}

/* ---------- Background Decorations ---------- */
.calligraphy-bg {
  background-color: #181012;
  background-image: radial-gradient(circle at 50% 50%, rgba(199, 0, 36, 0.08) 0%, transparent 60%);
}
.liquid-gradient-bg {
  background: radial-gradient(circle at 50% 0%, #3a1519 0%, #181012 60%, #000000 100%);
}

/* ---------- Ambient Glow ---------- */
.ambient-glow {
  position: absolute;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(199,0,36,0.25) 0%, rgba(24,16,18,0) 70%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}

/* ---------- Toggle Switch ---------- */
.toggle-track {
  width: 48px; height: 28px;
  border-radius: 14px;
  background: #4a4a4a;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle-track.active { background: #c70024; }
.toggle-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 3px; left: 3px;
  transition: left 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-track.active .toggle-thumb { left: 23px; }

/* ---------- Scanning Animation ---------- */
@keyframes scan {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(200%); }
}
.scan-line {
  background: linear-gradient(to bottom, transparent, rgba(199, 0, 36, 0.5), transparent);
  animation: scan 3s infinite linear;
}

/* ---------- Capture Flash ---------- */
@keyframes capture-flash {
  0%   { opacity: 0; }
  8%   { opacity: 0.92; }
  100% { opacity: 0; }
}
.flash-anim {
  animation: capture-flash 0.55s ease-out forwards !important;
}

/* ---------- Camera zoom-out on capture ---------- */
@keyframes cam-zoom-out {
  from { transform: scale(1.07); }
  to   { transform: scale(1); }
}
.cam-zoom-out { animation: cam-zoom-out 0.4s ease-out forwards; }

/* ---------- Crop canvas ---------- */
#crop-canvas {
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Crimson Glow ---------- */
.crimson-glow {
  box-shadow: 0 0 15px rgba(199, 0, 36, 0.6);
}

/* ---------- Token Chip ---------- */
.token-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.token-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}
.token-chip.selected {
  background: rgba(199, 0, 36, 0.2);
  border-color: rgba(199, 0, 36, 0.6);
  color: #ff8a9e;
  box-shadow: 0 0 20px rgba(199, 0, 36, 0.3);
}

/* ---------- Range Slider ---------- */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #c70024 0%, #4a4a4a 100%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  margin-top: -8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
}

/* ---------- Page Transitions ---------- */
.page { animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(199, 0, 36, 0.3); border-radius: 2px; }

/* ---------- Favorite heart animation ---------- */
@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.heart-pop { animation: heartPop 0.3s ease; }

/* ---------- Spinner ---------- */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #c70024;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-lg {
  width: 64px; height: 64px;
  border-width: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- OCR Overlay ---------- */
#ocr-overlay {
  transition: opacity 0.3s ease;
}

/* ---------- Brush size range slider ---------- */
.brush-size-range {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(139, 92, 246, 0.28);
  outline: none;
  cursor: pointer;
}
.brush-size-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgb(139, 92, 246);
  box-shadow: 0 0 8px rgba(139,92,246,0.65);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
}
.brush-size-range::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgb(139, 92, 246);
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
}
.brush-size-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(139, 92, 246, 0.28);
}
.brush-size-range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(139, 92, 246, 0.28);
}

/* ---------- Brush size ghost preview ---------- */
.brush-size-ghost {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.brush-size-ghost.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.brush-size-ghost-circle {
  border-radius: 9999px;
  border: 2px solid rgba(139, 92, 246, 0.92);
  background: rgba(139, 92, 246, 0.18);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.18) inset, 0 0 26px rgba(139,92,246,0.45);
}
.brush-size-ghost-label {
  margin-top: 8px;
  text-align: center;
  color: rgba(210, 180, 255, 0.95);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

/* ---------- Quick Suggest Panel ---------- */
#quick-suggest-panel {
  will-change: transform;
}
.qs-word-main:active {
  background: rgba(255, 255, 255, 0.08) !important;
}
.qs-word-chip:active,
.qs-token-chip:active {
  background: rgba(199, 0, 36, 0.15);
  border-color: rgba(199, 0, 36, 0.4);
}

/* ---------- Settings glass panel ---------- */
.settings-glass {
  background: linear-gradient(145deg, rgba(40, 40, 40, 0.4) 0%, rgba(20, 20, 20, 0.4) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* ---------- Live Text Word Chip ---------- */
.word-chip {
  position: absolute;
  border-radius: 3px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  pointer-events: all;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
.word-chip:active,
.word-chip.active {
  background: rgba(199, 0, 36, 0.38);
  border-color: rgba(199, 0, 36, 1);
  box-shadow: 0 0 0 2px rgba(199, 0, 36, 0.35), 0 0 14px rgba(199, 0, 36, 0.5);
}
