/* ===========================
   Global Styles
   =========================== */

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #1a202c;
}

/* Basic link styling override for custom sections */
a {
  color: #4f46e5;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===========================
   Header & Navigation
   =========================== */

.header {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.2);
}

/* Logo */
.logo-link {
  text-decoration: none;
}

.main-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.site-title {
  white-space: nowrap;
}

/* Desktop nav links */
.nav-link {
  color: #ffffff;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.25s ease;
  text-decoration: none;
  position: relative;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  transition: width 0.25s ease;
}

.nav-link:hover {
  color: #e5e7eb;
  transform: translateY(-1px);
}

.nav-link:hover::after {
  width: 100%;
}

/* Mobile menu button */
.mobile-menu-btn {
  background: none;
  border: 0;
  color: #ffffff;
  font-size: 1.6rem;
  cursor: pointer;
}

/* ===========================
   Mobile Slide-Down Menu
   =========================== */

.mobile-menu {
  background: #065f46; /* deep green */
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: max-height 0.3s ease, opacity 0.25s ease, transform 0.25s ease;
}

.mobile-menu.open {
  max-height: 520px; /* enough for links */
  opacity: 1;
  transform: translateY(0);
}

.mobile-menu-inner {
  padding: 0.75rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mobile-menu-link {
  color: #e5e7eb;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 0.5rem;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mobile-menu-link:hover {
  background: rgba(16, 185, 129, 0.25);
  transform: translateX(2px);
}

.mobile-menu-section-title {
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a7f3d0;
}

/* ===========================
   Desktop Dropdown (More ▾)
   =========================== */

.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

/* Only show via .open class, not :hover */
.dropdown-content {
  position: absolute;
  top: 110%;
  right: 0;
  min-width: 230px;
  background: #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  padding: 0.4rem 0;
  display: none;
  z-index: 9999;
}

.dropdown.open .dropdown-content {
  display: block;
}

.dropdown-content a {
  display: block;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  color: #374151;
  text-decoration: none;
  transition: background 0.2s ease, padding-left 0.2s ease, color 0.2s ease;
}

.dropdown-content a:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  padding-left: 1.35rem;
}

/* ===========================
   Page Header (Hero Section)
   =========================== */

.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  padding: 4.5rem 1.25rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120'%3E%3Cpath d='M0,0 Q300,60 600,30 T1200,0 L1200,120 L0,120 Z' fill='rgba(255,255,255,0.06)'/%3E%3C/svg%3E")
    repeat-x bottom;
  background-size: 1200px 120px;
  opacity: 0.35;
}

.page-header h1 {
  position: relative;
  z-index: 1;
  font-size: 3rem;
  font-weight: 900;
  margin: 0 0 0.75rem;
  text-shadow: 0 3px 10px rgba(15, 23, 42, 0.35);
}

.page-header p {
  position: relative;
  z-index: 1;
  font-size: 1.2rem;
  opacity: 0.96;
}

/* ===========================
   Calculator Layout
   =========================== */

.calculator-container {
  max-width: 1200px;
  margin: -3.5rem auto 3.5rem;
  padding: 0 1.25rem;
  position: relative;
  z-index: 10;
}

.calculator-card {
  background: #ffffff;
  border-radius: 1.5rem;
  padding: 2.5rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
}

/* Intro text */
.intro-text {
  color: #4a5568;
  font-size: 0.98rem;
  line-height: 1.8;
  margin-bottom: 1.75rem;
  text-align: justify;
}

/* Highlight box (how to use) */
.highlight-box {
  background: linear-gradient(135deg, #f3f4ff 0%, #f8f5ff 100%);
  border-left: 4px solid #6366f1;
  border-radius: 0.9rem;
  padding: 1.25rem 1.25rem 1.15rem;
  margin: 1.35rem 0 1.9rem;
  color: #374151;
  font-size: 0.95rem;
}

.highlight-box ol {
  margin: 0.65rem 0 0.4rem 1.25rem;
  padding: 0;
}

.highlight-box li {
  margin-bottom: 0.2rem;
}

.highlight-box a {
  color: #4f46e5;
  font-weight: 500;
}

.small-highlight {
  font-size: 0.92rem;
}

/* Mode selector */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.mode-option {
  padding: 1.25rem 1.15rem;
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
}

.mode-option:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
  transform: translateY(-1px);
}

.mode-option.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border-color: #4f46e5;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
}

.mode-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.45rem;
}

.mode-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.mode-desc {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Input Section */
.input-section {
  margin-bottom: 1.75rem;
}

.input-label {
  display: block;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 0.6rem;
  font-size: 0.97rem;
}

.numbers-input {
  width: 100%;
  min-height: 140px;
  padding: 0.9rem 1rem;
  border-radius: 0.85rem;
  border: 2px solid #cbd5e0;
  font-size: 0.95rem;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.numbers-input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
}

/* Input buttons (samples, clear) */
.input-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.chip-button {
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  background: #f9fafb;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.chip-button:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  transform: translateY(-0.5px);
}

.chip-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.chip-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Calculate button */
.calculate-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  border-radius: 0.9rem;
  border: none;
  cursor: pointer;
  font-size: 1.02rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.48);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.calculate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(79, 70, 229, 0.6);
}

.calculate-btn:active {
  transform: scale(0.98);
}

/* ===========================
   Results Section
   =========================== */

.results-section {
  margin-top: 1.9rem;
  padding: 1.9rem 1.6rem 1.8rem;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-radius: 1rem;
  border-left: 4px solid #4f46e5;
  display: none;
}

.results-section.show {
  display: block;
}

.result-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2d3748;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.15rem;
}

/* Result hero (big SD value) */
.result-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: 1rem;
  padding: 1.4rem 1.2rem;
  text-align: center;
  color: #ffffff;
  margin-bottom: 1.5rem;
}

.result-hero-label {
  font-size: 0.92rem;
  opacity: 0.9;
  margin-bottom: 0.4rem;
}

.result-hero-value {
  font-size: 2.4rem;
  font-weight: 900;
}

.result-hero-sub {
  font-size: 0.8rem;
  margin-top: 0.25rem;
  opacity: 0.9;
}

/* Grid for main stats */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.3rem;
}

.main-stats {
  margin-bottom: 1.4rem;
}

/* Result boxes */
.result-box {
  background: #ffffff;
  border-radius: 0.85rem;
  padding: 0.9rem 0.9rem 0.8rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.result-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #4f46e5;
}

/* Error box in results */
.error-box {
  border-left: 4px solid #ef4444;
}

.error-label {
  color: #b91c1c;
}

.error-message {
  font-size: 0.95rem;
  color: #b91c1c;
}

/* Gradient stat cards */
.gradient-box {
  color: #ffffff;
}

.purple-box {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
}

.blue-box {
  background: linear-gradient(135deg, #0ea5e9 0%, #22d3ee 100%);
}

.warm-box {
  background: linear-gradient(135deg, #f97316 0%, #facc15 100%);
}

.light-label {
  color: rgba(255, 255, 255, 0.9);
}

.big-value {
  font-size: 1.6rem;
  font-weight: 800;
}

/* Sorted data area */
.sorted-data {
  background: #f7fafc;
  padding: 0.8rem;
  border-radius: 0.7rem;
  max-height: 150px;
  overflow-y: auto;
}

.sorted-data-inner {
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: #1f2933;
  line-height: 1.7;
}

/* Step-by-step section */
.step-by-step {
  background: #111827;
  color: #e5e7eb;
  padding: 1rem 1.1rem;
  border-radius: 0.8rem;
  font-family: "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.75;
  max-height: 420px;
  overflow-y: auto;
}

.step {
  position: relative;
  padding-left: 1.2rem;
  margin-bottom: 0.45rem;
}

.step::before {
  content: "→";
  position: absolute;
  left: 0;
  top: 0;
  color: #60a5fa;
}

/* Interpretation box */
.interpretation-box {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border-left: 4px solid #4f46e5;
}

.interpretation-label {
  color: #4338ca;
}

.interpretation-text {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.75;
  margin-top: 0.45rem;
}

.interpretation-list {
  margin: 0.45rem 0 0.2rem 1.3rem;
  padding: 0;
}

.interpretation-list li {
  margin-bottom: 0.2rem;
}

/* Download buttons */
.download-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.download-btn {
  flex: 1 1 150px;
  padding: 0.65rem 1rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 0.75rem;
  border: none;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.download-btn:hover {
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

/* ===========================
   Info Cards Section
   =========================== */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.4rem;
  margin-top: 2.1rem;
}

.info-card {
  background: #ffffff;
  padding: 1.4rem 1.25rem;
  border-radius: 1rem;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.1);
  border-left: 4px solid #6366f1;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.info-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(79, 70, 229, 0.25);
}

.info-card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.info-card p {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #4b5563;
}

/* ===========================
   Blog Section
   =========================== */

.blog-section {
  max-width: 900px;
  margin: 3.5rem auto 3.75rem;
  padding: 0 1.25rem;
}

.blog-content {
  background: #ffffff;
  border-radius: 1.5rem;
  padding: 2.6rem 2.7rem;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.15);
  line-height: 1.9;
}

.blog-content h2 {
  font-size: 2.1rem;
  font-weight: 900;
  margin-top: 0;
  margin-bottom: 1.75rem;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.blog-content h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #111827;
  margin-top: 2rem;
  margin-bottom: 0.8rem;
}

.blog-content h4 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1f2937;
  margin-top: 1.4rem;
  margin-bottom: 0.5rem;
}

.blog-content p {
  font-size: 0.98rem;
  color: #4b5563;
  margin-bottom: 0.9rem;
}

.blog-content ul {
  margin: 0.4rem 0 0.9rem 1.3rem;
  padding-left: 0;
  color: #4b5563;
}

.blog-content li {
  margin-bottom: 0.25rem;
}

.blog-content strong {
  color: #4f46e5;
}

/* Formula box in blog */
.formula-box {
  background: #111827;
  color: #e5e7eb;
  border-radius: 0.9rem;
  padding: 1rem 1.1rem;
  margin: 1.1rem 0;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  overflow-x: auto;
}

/* ===========================
   FAQ Section
   =========================== */

.faq-section {
  max-width: 900px;
  margin: 0 auto 4rem;
  padding: 0 1.25rem;
}

.faq-inner {
  background: #ffffff;
  border-radius: 1.4rem;
  padding: 2.3rem 2.6rem;
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.15);
}

.faq-inner h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 0;
  margin-bottom: 1.4rem;
  color: #111827;
}

.faq-item + .faq-item {
  border-top: 1px solid #e5e7eb;
  padding-top: 0.9rem;
  margin-top: 0.9rem;
}

.faq-item h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.25rem;
}

.faq-item p {
  font-size: 0.95rem;
  color: #4b5563;
  line-height: 1.8;
}

.faq-item code {
  background: #f3f4f6;
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.86rem;
}

/* ===========================
   Footer
   =========================== */

.footer {
  background: linear-gradient(135deg, #111827 0%, #020617 100%);
  color: #ffffff;
  padding: 3.2rem 0 1.6rem;
  margin-top: 3.5rem;
}

.footer-column h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.7rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column ul li {
  margin-bottom: 0.35rem;
}

.footer-column ul li a {
  color: #d1d5db;
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.footer-column ul li a:hover {
  color: #818cf8;
  transform: translateX(3px);
}

.footer-bottom {
  border-top: 1px solid rgba(55, 65, 81, 0.8);
  margin-top: 2rem;
  padding-top: 1.2rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* ===========================
   Responsive Styles
   =========================== */

@media (max-width: 1024px) {
  .calculator-card {
    padding: 2rem 1.8rem;
  }

  .blog-content {
    padding: 2.1rem 2.0rem;
  }

  .faq-inner {
    padding: 2rem 1.9rem;
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: 3.2rem 1.1rem 3.3rem;
  }

  .page-header h1 {
    font-size: 2.1rem;
  }

  .page-header p {
    font-size: 1rem;
  }

  .calculator-container {
    margin: -2.8rem  auto 2.5rem;
  }

  .calculator-card {
    padding: 1.7rem 1.4rem;
  }

  .mode-selector {
    grid-template-columns: 1fr;
  }

  .results-section {
    padding: 1.5rem 1.2rem 1.4rem;
  }

  .blog-content {
    padding: 1.7rem 1.5rem;
  }

  .blog-content h2 {
    font-size: 1.7rem;
  }

  .faq-inner {
    padding: 1.7rem 1.45rem;
  }

  .info-grid {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .page-header h1 {
    font-size: 1.8rem;
  }

  .intro-text {
    font-size: 0.9rem;
  }

  .numbers-input {
    font-size: 0.9rem;
  }

  .calculate-btn {
    font-size: 0.97rem;
  }

  .result-hero-value {
    font-size: 2rem;
  }

  .download-buttons {
    flex-direction: column;
  }
}
