/* ==========================================================================
   Madar Platform (madar.hooshiwa.ir) - v7.0 Mega-Enterprise Responsive Stylesheet
   Mobile-First Architecture, 20-Theme Engine, LinkedIn Animated Reaction Dock,
   Telegram Animated Stickers, Instagram Story Player, & Multi-Theme IDE
   ========================================================================== */

@font-face {
  font-family: 'Dana';
  src: url('../fonts/DanaFaNum-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Dana';
  src: url('../fonts/DanaFaNum-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Dana';
  src: url('../fonts/DanaFaNum-Black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-elevated: #f8fafc;
  --border-subtle: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --brand-accent: #4f46e5;
}

html.dark {
  --bg-main: #060911;
  --bg-card: #0c1322;
  --bg-elevated: #111a2e;
  --border-subtle: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --brand-accent: #6366f1;
}

/* 20 Built-In Custom Theme Presets */
html[data-theme="hooshiwa_gold"] { --bg-main: #0c0a06; --bg-card: #17130a; --bg-elevated: #221c0e; --border-subtle: #3d3117; --text-primary: #fef3c7; --text-secondary: #d97706; }
html[data-theme="dracula"] { --bg-main: #191a21; --bg-card: #282a36; --bg-elevated: #343746; --border-subtle: #44475a; --text-primary: #f8f8f2; --text-secondary: #bd93f9; }
html[data-theme="cyberpunk"] { --bg-main: #090414; --bg-card: #140826; --bg-elevated: #1f0d3d; --border-subtle: #ec4899; --text-primary: #fdf4ff; --text-secondary: #22d3ee; }
html[data-theme="matrix"] { --bg-main: #020b05; --bg-card: #06160b; --bg-elevated: #0a2412; --border-subtle: #10b981; --text-primary: #d1fae5; --text-secondary: #34d399; }
html[data-theme="nord"] { --bg-main: #242933; --bg-card: #2e3440; --bg-elevated: #3b4252; --border-subtle: #4c566a; --text-primary: #eceff4; --text-secondary: #88c0d0; }
html[data-theme="ocean"] { --bg-main: #04131d; --bg-card: #082032; --bg-elevated: #0d2e47; --border-subtle: #0284c7; --text-primary: #f0f9ff; --text-secondary: #38bdf8; }
html[data-theme="sunset"] { --bg-main: #180814; --bg-card: #280e21; --bg-elevated: #38142e; --border-subtle: #f43f5e; --text-primary: #fff1f2; --text-secondary: #fb7185; }
html[data-theme="monokai"] { --bg-main: #1e1f1c; --bg-card: #272822; --bg-elevated: #3e3d32; --border-subtle: #75715e; --text-primary: #f8f8f2; --text-secondary: #a6e22e; }
html[data-theme="solarized_dark"] { --bg-main: #00212b; --bg-card: #002b36; --bg-elevated: #073642; --border-subtle: #586e75; --text-primary: #fdf6e3; --text-secondary: #2aa198; }
html[data-theme="solarized_light"] { --bg-main: #eee8d5; --bg-card: #fdf6e3; --bg-elevated: #f5efdc; --border-subtle: #d3cbb7; --text-primary: #073642; --text-secondary: #586e75; }
html[data-theme="github_dark"] { --bg-main: #0d1117; --bg-card: #161b22; --bg-elevated: #21262d; --border-subtle: #30363d; --text-primary: #e6edf3; --text-secondary: #8b949e; }
html[data-theme="github_light"] { --bg-main: #f6f8fa; --bg-card: #ffffff; --bg-elevated: #f3f4f6; --border-subtle: #d0d7de; --text-primary: #1f2328; --text-secondary: #656d76; }
html[data-theme="rose_pine"] { --bg-main: #191724; --bg-card: #1f1d2e; --bg-elevated: #26233a; --border-subtle: #403d52; --text-primary: #e0def4; --text-secondary: #ebbcba; }
html[data-theme="tokyo_night"] { --bg-main: #16161e; --bg-card: #1a1b26; --bg-elevated: #24283b; --border-subtle: #414868; --text-primary: #c0caf5; --text-secondary: #7aa2f7; }
html[data-theme="synthwave"] { --bg-main: #1a1025; --bg-card: #261938; --bg-elevated: #34224d; --border-subtle: #f92aad; --text-primary: #ffffff; --text-secondary: #36f9f6; }
html[data-theme="forest"] { --bg-main: #071410; --bg-card: #0c211a; --bg-elevated: #123026; --border-subtle: #059669; --text-primary: #ecfdf5; --text-secondary: #6ee7b7; }
html[data-theme="coffee"] { --bg-main: #17110e; --bg-card: #241b16; --bg-elevated: #31251e; --border-subtle: #78350f; --text-primary: #fef3c7; --text-secondary: #f59e0b; }
html[data-theme="amoled"] { --bg-main: #000000; --bg-card: #080808; --bg-elevated: #121212; --border-subtle: #262626; --text-primary: #ffffff; --text-secondary: #a3a3a3; }

*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Dana', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, textarea, select {
  font: inherit;
}

[x-cloak] {
  display: none !important;
}

.dir-ltr {
  direction: ltr;
  text-align: left;
  unicode-bidi: embed;
}

/* CRITICAL FIX: Toast Notifications & Upload Progress Always Above Modal Backdrops */
.madar-toast-layer {
  z-index: 999999 !important;
}

.madar-upload-layer {
  z-index: 999995 !important;
}

.madar-modal-backdrop {
  z-index: 9990 !important;
}

/* Top Progress Bar */
#madarTopProgress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  z-index: 999999;
  pointer-events: none;
  overflow: hidden;
}

#madarTopProgress .bar {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4 0%, #6366f1 50%, #f59e0b 100%);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.8);
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

/* Shimmer Skeleton Loader */
@keyframes shimmerWave {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.shimmer-box {
  background: linear-gradient(90deg, rgba(148,163,184,0.12) 25%, rgba(148,163,184,0.24) 50%, rgba(148,163,184,0.12) 75%);
  background-size: 200% 100%;
  animation: shimmerWave 1.5s infinite linear;
}

.dark .shimmer-box {
  background: linear-gradient(90deg, rgba(30,41,59,0.5) 25%, rgba(51,65,85,0.8) 50%, rgba(30,41,59,0.5) 75%);
  background-size: 200% 100%;
}

/* Telegram & LinkedIn Animated Reactions & Stickers */
@keyframes emojiBounce {
  0% { transform: scale(0.8); }
  45% { transform: scale(1.28) rotate(-6deg); }
  75% { transform: scale(0.95) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes floatUpBurst {
  0% { opacity: 1; transform: translateY(0) scale(0.8); }
  60% { opacity: 1; transform: translateY(-42px) scale(1.35); }
  100% { opacity: 0; transform: translateY(-75px) scale(0.9); }
}

@keyframes stickerFloat {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}

@keyframes goldPulseGlow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.65)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.95)); transform: scale(1.07); }
}

.founder-gold-tick {
  animation: goldPulseGlow 2.4s infinite ease-in-out;
}

.animated-sticker-pill {
  animation: stickerFloat 3s ease-in-out infinite;
}

.emoji-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.24rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  cursor: pointer;
}

.emoji-pill:hover {
  transform: translateY(-2px) scale(1.06);
}

.emoji-pill:active {
  animation: emojiBounce 0.35s ease;
}

.linkedin-reaction-dock {
  animation: emojiBounce 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.linkedin-reaction-btn {
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.linkedin-reaction-btn:hover {
  transform: translateY(-6px) scale(1.38);
}

/* LinkedIn-Style Nested Reply Indentation & Connector Line */
.reply-depth-0 { margin-right: 0; }
.reply-depth-1 {
  margin-right: 1rem;
  border-right: 2px solid rgba(99, 102, 241, 0.35);
  padding-right: 0.75rem;
}
.reply-depth-2 {
  margin-right: 1.85rem;
  border-right: 2px solid rgba(6, 182, 212, 0.4);
  padding-right: 0.75rem;
}
.reply-depth-3 {
  margin-right: 2.5rem;
  border-right: 2px solid rgba(16, 185, 129, 0.45);
  padding-right: 0.75rem;
}

@media (max-width: 640px) {
  .reply-depth-1 { margin-right: 0.55rem; padding-right: 0.5rem; }
  .reply-depth-2 { margin-right: 1.05rem; padding-right: 0.5rem; }
  .reply-depth-3 { margin-right: 1.45rem; padding-right: 0.5rem; }
}

/* Instagram / Telegram Story Ring Gradient */
.story-ring {
  background: linear-gradient(135deg, #f59e0b 0%, #ec4899 35%, #6366f1 70%, #06b6d4 100%);
  padding: 2.5px;
  border-radius: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-ring:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px -2px rgba(236, 72, 153, 0.4);
}

.story-ring.viewed {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  opacity: 0.82;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.75);
}
.dark ::-webkit-scrollbar-thumb {
  background: rgba(51, 65, 85, 0.8);
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Technical & Scientific Prose */
.scientific-prose {
  user-select: text;
  line-height: 1.85;
  word-break: break-word;
}

.scientific-prose code.inline-code {
  direction: ltr;
  unicode-bidi: embed;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84em;
  padding: 0.14rem 0.42rem;
  border-radius: 0.4rem;
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.dark .scientific-prose code.inline-code {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.28);
}

.math-block {
  direction: ltr;
  unicode-bidi: isolate;
  overflow-x: auto;
  padding: 0.75rem 1rem;
  margin: 0.65rem 0;
  border-radius: 0.85rem;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.9);
  text-align: center;
}

.dark .math-block {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(51, 65, 85, 0.75);
}

.math-inline {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  padding: 0 0.2rem;
}

/* Multi-Theme Cloud IDE & Code Editor Styling (Fixes Stuck Dark Mode) */
.code-lab-container {
  direction: ltr;
  text-align: left;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  tab-size: 2;
  line-height: 1.65;
  user-select: text;
}

.ide-theme-light {
  background-color: #f8fafc !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}
.ide-theme-light textarea, .ide-theme-light pre {
  background-color: #ffffff !important;
  color: #1e293b !important;
  border-color: #e2e8f0 !important;
}

.ide-theme-dark {
  background-color: #090d16 !important;
  color: #f1f5f9 !important;
  border-color: #1e293b !important;
}
.ide-theme-dark textarea, .ide-theme-dark pre {
  background-color: #0f172a !important;
  color: #34d399 !important;
  border-color: #1e293b !important;
}

.ide-theme-dracula {
  background-color: #21222c !important;
  color: #f8f8f2 !important;
  border-color: #44475a !important;
}
.ide-theme-dracula textarea, .ide-theme-dracula pre {
  background-color: #282a36 !important;
  color: #ff79c6 !important;
  border-color: #6272a4 !important;
}

.ide-theme-monokai {
  background-color: #1e1f1c !important;
  color: #f8f8f2 !important;
  border-color: #49483e !important;
}
.ide-theme-monokai textarea, .ide-theme-monokai pre {
  background-color: #272822 !important;
  color: #a6e22e !important;
  border-color: #75715e !important;
}

/* Glass Surfaces & Mobile Navigation */
.glass-panel {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.dark .glass-panel {
  background: rgba(12, 19, 34, 0.94);
}

.glass-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.dark .glass-header {
  background: rgba(6, 9, 17, 0.95);
}

.enterprise-card {
  background-color: var(--bg-card);
  box-shadow: 0 2px 16px -4px rgba(15, 23, 42, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.dark .enterprise-card {
  box-shadow: 0 6px 24px -6px rgba(0, 0, 0, 0.4);
}

.mobile-bottom-nav {
  padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

/* FIXED Mobile Modal Styling: Preserves Internal Padding & Margins Cleanly */
@media (max-width: 640px) {
  .mobile-sheet-modal {
    max-height: 90vh !important;
    width: calc(100% - 1rem) !important;
    margin: 0.5rem auto !important;
    border-radius: 1.5rem !important;
  }
  .mobile-sheet-content {
    max-height: 90vh !important;
    width: 100% !important;
    border-radius: 1.5rem !important;
  }
}

/* Print Stylesheet for Developer CV */
@media print {
  header, nav, aside, .no-print {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
  }
  .print-card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}
