@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css");

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --secondary: #3b82f6;
  --accent: #f59e0b;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --header-height: 84px;
}

body {
  font-family:
    "Pretendard",
    -apple-system,
    sans-serif;
  scroll-behavior: smooth;
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* Glassmorphism Header */
header {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: var(--header-height);
}

@media (max-width: 1024px) {
  header {
    height: auto;
    min-height: 70px;
  }
  :root {
    --header-height: 70px;
  }
}

.subject-tab {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.subject-tab::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: var(--primary);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}
.subject-tab-active {
  color: white !important;
  background: rgba(16, 185, 129, 0.15);
}
.subject-tab-active::after {
  width: 100%;
}

/* Sidebar Refinement */
.side-link {
  position: relative;
  transition: all 0.2s ease;
}
.side-link:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}
.nav-active {
  background: linear-gradient(
    90deg,
    rgba(16, 185, 129, 0.2) 0%,
    rgba(16, 185, 129, 0) 100%
  );
  color: var(--primary);
  font-weight: 700;
  border-left: 4px solid var(--primary);
}

/* Concept Cards */
.concept-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  padding: 2.5rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}
@media (max-width: 768px) {
  .concept-card {
    padding: 1.5rem;
    border-radius: 1rem;
  }
}
.concept-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.exam-tag {
  background: #ecfdf5;
  border: 1px solid #10b981;
  color: #065f46;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}

/* Modal Refinement */
#modal-overlay {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#modal-overlay.active {
  display: flex;
  opacity: 1;
}
.modal-content {
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 2rem;
}
@media (max-width: 768px) {
  .modal-content {
    border-radius: 1.5rem;
    max-height: 95vh;
  }
}
#modal-overlay.active .modal-content {
  transform: scale(1);
}

.opt-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.opt-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f0fdf4;
  transform: translateX(8px);
}
.opt-correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
  box-shadow: 0 0 0 4px #d1fae5;
}
.opt-incorrect {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
  box-shadow: 0 0 0 4px #fee2e2;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
  margin: 0 auto;
}

.atm-item {
  transition: all 0.3s;
  cursor: pointer;
  border-left: 4px solid transparent;
}
.atm-item:hover {
  background: rgba(16, 185, 129, 0.05);
  transform: translateX(8px);
}
.atm-item.active {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: var(--primary);
  transform: translateX(12px);
  font-weight: 800;
}

/* Animation */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.animate-slide-up {
  animation: slideUp 0.5s ease-out forwards;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.content-area {
  display: none;
}
.content-area.active {
  display: block;
}

.feedback-badge {
  display: none;
  padding: 0.5rem 1.2rem;
  border-radius: 9999px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Mobile Drawer */
@media (max-width: 1024px) {
  aside {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    height: 100vh !important;
    z-index: 210;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px !important;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
  }
  aside.open {
    transform: translateX(0);
  }
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 205;
  }
  #sidebar-overlay.active {
    display: block;
  }
  main {
    padding: 1.5rem 1rem !important;
  }
  .content-area > div:not(.mb-12) {
    margin-top: 0;
  }
  nav {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar {
    display: none;
  }
}

/* Markdown Emphasize */
b,
strong {
  color: var(--primary);
  font-weight: 900;
}
.md-bold {
  font-weight: 800;
  color: inherit;
  text-decoration: underline decoration-emerald-500/30 decoration-4
    underline-offset-4;
}
.hl-text {
  color: #ef4444;
  font-weight: 900;
}

/* Subject 5 Visuals */
.vs-badge {
  background: linear-gradient(135deg, #f43f5e, #881337);
  color: white;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 900;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.4);
}
@media (max-width: 768px) {
  .vs-badge {
    display: none;
  }
}

/* Section spacing: padding around each section for breathing room */
section {
  padding-top: 1rem;
  padding-bottom: 2rem;
}

/* Ensure scroll-to sections are not hidden behind sticky header */
html {
  scroll-padding-top: 130px;
}
@media (max-width: 1024px) {
  html {
    scroll-padding-top: 160px;
  }
}

/* Mobile typography & spacing */
@media (max-width: 768px) {
  .subject-heading {
    font-size: 1.875rem !important; /* text-3xl */
  }
  .section-heading {
    font-size: 1.5rem !important; /* text-2xl */
  }
  /* Disable hover lift on touch devices */
  .concept-card:hover {
    transform: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  }
}

/* MathJax: no scrollbars — parent .overflow-x-auto wrapper handles overflow */
mjx-container {
  overflow: visible !important;
  max-width: 100%;
}
mjx-container[display="true"] {
  display: block;
}
