/* ==========================================================================
   styles.css - Senior UI Tokens, Premium Typography & Tab Utilities
   ========================================================================== */

/* Import High-Readability Korean Fonts: Pretendard & Noto Sans KR */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;900&display=swap');

/* Global High-Readability Font Stack & Smooth Anti-Aliasing */
*, ::before, ::after {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Base Body Styles */
body {
  font-family: 'Pretendard', 'Noto Sans KR', sans-serif !important;
  line-height: 1.6;
  letter-spacing: -0.02em;
  background-color: #f8fafc;
  color: #0f172a;
}

/* ==========================================================================
   Comprehensive Senior Accessibility Font Scaler (html & body root scaling)
   ========================================================================== */

/* 1. Normal Mode (16px base) */
html.font-scale-normal {
  font-size: 16px !important;
}
body.font-scale-normal {
  font-size: 16px;
  line-height: 1.6;
}

/* 2. Large Mode: '크게' (20px base - 125% scale across all rem/Tailwind units) */
html.font-scale-large {
  font-size: 20px !important;
}
body.font-scale-large {
  font-size: 20px;
  line-height: 1.65;
}
html.font-scale-large h1, body.font-scale-large h1 { font-size: 2.25rem !important; }
html.font-scale-large h2, body.font-scale-large h2 { font-size: 1.95rem !important; }
html.font-scale-large h3, body.font-scale-large h3 { font-size: 1.65rem !important; }
html.font-scale-large h4, body.font-scale-large h4 { font-size: 1.4rem !important; }
html.font-scale-large input, 
html.font-scale-large select, 
html.font-scale-large textarea, 
html.font-scale-large button:not(.font-btn) {
  font-size: 1.15rem !important;
}

/* 3. Extra Large Mode: '아주크게' (26px base - 162.5% scale across all rem/Tailwind units) */
html.font-scale-xlarge {
  font-size: 26px !important;
}
body.font-scale-xlarge {
  font-size: 26px;
  line-height: 1.7;
}
html.font-scale-xlarge h1, body.font-scale-xlarge h1 { font-size: 2.6rem !important; line-height: 1.25 !important; }
html.font-scale-xlarge h2, body.font-scale-xlarge h2 { font-size: 2.2rem !important; line-height: 1.3 !important; }
html.font-scale-xlarge h3, body.font-scale-xlarge h3 { font-size: 1.85rem !important; line-height: 1.35 !important; }
html.font-scale-xlarge h4, body.font-scale-xlarge h4 { font-size: 1.55rem !important; line-height: 1.35 !important; }

html.font-scale-xlarge p,
html.font-scale-xlarge label,
html.font-scale-xlarge .text-sm,
html.font-scale-xlarge .text-xs {
  line-height: 1.65 !important;
}

html.font-scale-xlarge input, 
html.font-scale-xlarge select, 
html.font-scale-xlarge textarea {
  font-size: 1.35rem !important;
  line-height: 1.5 !important;
  padding-top: 0.9rem !important;
  padding-bottom: 0.9rem !important;
}

html.font-scale-xlarge button:not(.font-btn):not(#lang-select) {
  font-size: 1.3rem !important;
  line-height: 1.4 !important;
  padding-top: 0.85rem !important;
  padding-bottom: 0.85rem !important;
}

html.font-scale-xlarge .nav-tab {
  font-size: 1.2rem !important;
  padding: 0.8rem 1.2rem !important;
}

/* Ensure font scale buttons in top bar remain properly proportioned */
.font-btn {
  font-size: 13px !important;
  line-height: 1.2 !important;
}

/* Hide scrollbars for clean navigation scrolling */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* STRICT SINGLE PAGE TAB DISPLAY RULES */
/* Force all non-active tab sections to be completely hidden (display: none !important) */
.content-tab-page {
  display: none !important;
}

/* Display ONLY the single active tab section (display: block !important) */
.content-tab-page.active {
  display: block !important;
  animation: fadeIn 0.25s ease-out;
}

/* Sub Content Pages */
.sub-content-page {
  display: none !important;
}
.sub-content-page.active {
  display: block !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
  animation: fadeIn 0.2s ease-out;
}

/* Memory Game Card Grid */
.memory-card {
  aspect-ratio: 1/1;
  background: #059669;
  color: #ffffff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s;
}

.memory-card.flipped, .memory-card.matched {
  background: #ffffff;
  border: 3px solid #059669;
  color: #1e293b;
}

/* Lotto Ball Badges */
.lotto-ball {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  animation: popIn 0.35s ease-out;
}

.ball-empty { background: #cbd5e1; color: #475569; }
.ball-yellow { background: #eab308; }  /* 1-10 */
.ball-blue { background: #3b82f6; }    /* 11-20 */
.ball-red { background: #ef4444; }     /* 21-30 */
.ball-gray { background: #64748b; }    /* 31-40 */
.ball-green { background: #22c55e; }   /* 41-45 */

@keyframes popIn {
  0% { transform: scale(0.2); opacity: 0; }
  80% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* Stamp Calendar Grid Box */
.stamp-box {
  aspect-ratio: 1/1;
  border: 2px dashed #cbd5e1;
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.85em;
  font-weight: 700;
  color: #64748b;
  background: #ffffff;
}

.stamp-box.stamped {
  border-style: solid;
  border-color: #f59e0b;
  background: #fef3c7;
  color: #b45309;
  font-weight: 900;
}

.stamp-box.stamped i {
  font-size: 1.5rem;
  color: #d97706;
}

/* ==========================================================================
   AI Chatbot (CS Agent 'Mate') Styles & Animations
   ========================================================================== */

/* Chatbot Container Height & Responsive Layout */
.chat-container-card {
  min-height: 480px;
  max-height: 65vh;
}

/* Custom Scrollbar for Chat */
.chat-scrollbar::-webkit-scrollbar {
  width: 6px;
}
.chat-scrollbar::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.4);
  border-radius: 8px;
}
.chat-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 8px;
}
.chat-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.5);
}

/* Senior Font Size Scaling (어르신 맞춤 3단계 글자 크기 스케일러) */
.chat-font-size-md,
.chat-font-size-md .msg-content-body,
.chat-font-size-md .chat-msg-text,
.chat-font-size-md .chat-user-msg,
.chat-font-size-md .msg-content-body p,
.chat-font-size-md .msg-content-body li,
.chat-font-size-md .msg-content-body strong,
.chat-font-size-md .msg-content-body span,
.chat-font-size-md .msg-content-body code {
  font-size: 15px !important;
  line-height: 1.65 !important;
}

.chat-font-size-lg,
.chat-font-size-lg .msg-content-body,
.chat-font-size-lg .chat-msg-text,
.chat-font-size-lg .chat-user-msg,
.chat-font-size-lg .msg-content-body p,
.chat-font-size-lg .msg-content-body li,
.chat-font-size-lg .msg-content-body strong,
.chat-font-size-lg .msg-content-body span,
.chat-font-size-lg .msg-content-body code {
  font-size: 18px !important;
  line-height: 1.75 !important;
}

.chat-font-size-xl,
.chat-font-size-xl .msg-content-body,
.chat-font-size-xl .chat-msg-text,
.chat-font-size-xl .chat-user-msg,
.chat-font-size-xl .msg-content-body p,
.chat-font-size-xl .msg-content-body li,
.chat-font-size-xl .msg-content-body strong,
.chat-font-size-xl .msg-content-body span,
.chat-font-size-xl .msg-content-body code {
  font-size: 22px !important;
  line-height: 1.85 !important;
}

/* Streaming Typing Cursor */
.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 1.15em;
  background-color: #38bdf8;
  vertical-align: sub;
  margin-left: 2px;
  animation: cursorBlink 0.8s infinite;
  border-radius: 2px;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Message Bubble Fade-in */
.chat-msg-fade-in {
  animation: msgFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* AI Markdown Formatting Styles */
.chat-msg-text p {
  margin-bottom: 0.65rem;
}
.chat-msg-text p:last-child {
  margin-bottom: 0;
}
.chat-msg-text ul, .chat-msg-text ol {
  margin-left: 1.25rem;
  margin-bottom: 0.65rem;
}
.chat-msg-text li {
  margin-bottom: 0.25rem;
  list-style-type: disc;
}
.chat-msg-text strong {
  color: #38bdf8;
  font-weight: 700;
}
.chat-msg-text a {
  color: #34d399;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  transition: color 0.15s;
}
.chat-msg-text a:hover {
  color: #6ee7b7;
}
.chat-msg-text code {
  background: rgba(15, 23, 42, 0.8);
  color: #f43f5e;
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Quick Question Chip Hover & Animation */
.quick-chip {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.quick-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(14, 165, 233, 0.15);
  box-shadow: 0 4px 12px -2px rgba(56, 189, 248, 0.2);
}

/* Microphone Recording Pulse Animation */
.mic-recording-pulse {
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* Category Tab Pill Active */
.cs-category-pill.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(52, 211, 153, 0.25));
  border-color: #38bdf8;
  color: #ffffff;
}
