/* ===========================
   Global & Layout
   =========================== */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1a202c;
}

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

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

/* Desktop dropdown */
.dropdown {
  position: relative;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 110%;
  right: 0;
  min-width: 220px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  padding: 6px 0;
  z-index: 1100;
}

.dropdown-content a {
  display: block;
  padding: 10px 18px;
  font-size: 14px;
  text-decoration: none;
  color: #4a5568;
  transition: all 0.2s ease;
}

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

/* JS toggles this class */
.dropdown-content.show {
  display: block;
}

/* Mobile hamburger button */
.mobile-menu-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

/* Slide-down mobile menu */
.mobile-menu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform-origin: top;
  transition:
    max-height 0.3s ease,
    opacity 0.3s ease;
  z-index: 999;
}

.mobile-menu-panel.open {
  max-height: 420px; /* enough for all links */
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-inner {
  padding: 10px 18px 16px;
}

.mobile-menu-inner a {
  display: block;
  padding: 10px 8px;
  color: #f0fdf4;
  text-decoration: none;
  font-size: 15px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: background 0.2s ease, transform 0.15s ease;
}

.mobile-menu-inner a:hover {
  background: rgba(15, 118, 110, 0.35);
  transform: translateX(4px);
}

/* Hide mobile menu container on larger screens */
@media (min-width: 768px) {
  .mobile-menu-panel {
    display: none;
  }
}

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

.page-header {
  position: relative;
  color: #ffffff;
  text-align: center;
  padding: 72px 20px 96px;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at top left, rgba(255, 255, 255, 0.14), transparent 55%),
    radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.4), transparent 60%);
  opacity: 0.75;
  pointer-events: none;
}

.page-header h1 {
  position: relative;
  z-index: 1;
  font-size: 2.75rem;
  line-height: 1.2;
  font-weight: 900;
  margin-bottom: 12px;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.page-header p {
  position: relative;
  z-index: 1;
  font-size: 1.05rem;
  max-width: 720px;
  margin: 0 auto;
  opacity: 0.97;
}

@media (min-width: 768px) {
  .page-header h1 {
    font-size: 3.25rem;
  }

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

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

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

.calculator-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 32px 22px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
}

@media (min-width: 768px) {
  .calculator-card {
    padding: 40px;
  }
}

.intro-text {
  color: #4a5568;
  font-size: 0.98rem;
  line-height: 1.7;
  margin-bottom: 26px;
  text-align: justify;
}

/* Input section */

.input-section {
  margin-bottom: 24px;
}

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

.numbers-input {
  width: 100%;
  min-height: 130px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid #cbd5e0;
  font-size: 0.98rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.numbers-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
  transform: translateY(-1px);
}

/* Sample buttons */

.sample-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.sample-btn {
  padding: 7px 14px;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid #cbd5e0;
  background: #f8fafc;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.sample-btn:hover {
  background: #edf2f7;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(148, 163, 184, 0.45);
}

.sample-clear {
  background: #fef2f2;
  border-color: #fecaca;
}

.sample-clear:hover {
  background: #fee2e2;
}

/* Calculate button */

.calculate-btn {
  width: 100%;
  margin-top: 12px;
  padding: 15px 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(88, 101, 242, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.calculate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.45);
  filter: brightness(1.03);
}

.calculate-btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

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

.results-section {
  margin-top: 26px;
  padding: 24px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-left: 4px solid #667eea;
  display: none;
}

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

.result-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 20px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.result-box {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px 16px 18px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.result-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 6px;
}

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

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

.result-note {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #718096;
}

/* Color accents for main stats */

.result-box.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
}

.result-box.primary .result-label,
.result-box.primary .result-value {
  color: #ffffff;
}

.result-box.accent-pink {
  background: linear-gradient(135deg, #f973a1 0%, #f43f5e 100%);
  color: #ffffff;
}

.result-box.accent-pink .result-label,
.result-box.accent-pink .result-value {
  color: #ffffff;
}

.result-box.accent-blue {
  background: linear-gradient(135deg, #38bdf8 0%, #06b6d4 100%);
  color: #ffffff;
}

.result-box.accent-blue .result-label,
.result-box.accent-blue .result-value {
  color: #ffffff;
}

/* Sorted data block */

.sorted-data {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f7fafc;
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  color: #1a202c;
  font-size: 0.85rem;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.7;
}

/* Step-by-step explanation */

.step-by-step {
  margin-top: 10px;
  padding: 16px 16px 14px;
  border-radius: 12px;
  background: #1f2937;
  color: #e5e7eb;
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.8;
}

.step-by-step .step {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
}

.step-by-step .step::before {
  content: '→';
  position: absolute;
  left: 0;
  top: 0;
  color: #818cf8;
  font-weight: bold;
}

/* Error message styling */

.error-box {
  border-left: 4px solid #ef4444;
}

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

/* Mode text slightly smaller to handle long strings */
.mode-text {
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Download buttons */

.download-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.download-btn {
  flex: 1;
  min-width: 160px;
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

.download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(16, 185, 129, 0.4);
  filter: brightness(1.04);
}

.download-btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.35);
}

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

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

.info-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.13);
  border-left: 4px solid #667eea;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.info-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #1f2937;
}

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

.info-card a {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 600;
}

.info-card a:hover {
  text-decoration: underline;
}

.info-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  border-color: #4f46e5;
}

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

.blog-section {
  max-width: 900px;
  margin: 70px auto 40px;
  padding: 0 18px;
}

.blog-content {
  background: #ffffff;
  border-radius: 24px;
  padding: 32px 22px 40px;
  box-shadow: 0 10px 38px rgba(15, 23, 42, 0.18);
  line-height: 1.8;
}

@media (min-width: 768px) {
  .blog-content {
    padding: 40px 40px 46px;
  }
}

.blog-content h2 {
  font-size: 2.1rem;
  margin-bottom: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.blog-content h3 {
  font-size: 1.4rem;
  margin-top: 28px;
  margin-bottom: 10px;
  font-weight: 700;
  color: #1f2937;
}

.blog-content h4 {
  font-size: 1.1rem;
  margin-top: 18px;
  margin-bottom: 8px;
  font-weight: 600;
  color: #374151;
}

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

.blog-content a {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 600;
}

.blog-content a:hover {
  text-decoration: underline;
}

.blog-content ul {
  margin: 10px 0 14px 24px;
  padding: 0;
  color: #4b5563;
  font-size: 0.96rem;
}

.blog-content li {
  margin-bottom: 6px;
}

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

/* Formula & highlight boxes */

.formula-box {
  margin: 16px 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #111827;
  color: #e5e7eb;
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.86rem;
  line-height: 1.8;
  overflow-x: auto;
}

.highlight-box {
  margin: 18px 0 16px;
  padding: 16px 18px;
  border-radius: 14px;
  border-left: 4px solid #4f46e5;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  font-size: 0.95rem;
  color: #374151;
}

.highlight-box ul {
  margin: 8px 0 0 20px;
}

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

.faq-section {
  max-width: 900px;
  margin: 40px auto 60px;
  padding: 0 18px;
}

.faq-inner {
  background: #ffffff;
  border-radius: 24px;
  padding: 26px 22px 30px;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
}

@media (min-width: 768px) {
  .faq-inner {
    padding: 30px 32px 34px;
  }
}

.faq-section h2 {
  font-size: 1.6rem;
  margin-bottom: 14px;
  font-weight: 800;
  color: #111827;
}

.faq-inner details {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  margin-top: 8px;
  background: #f9fafb;
}

.faq-inner summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.96rem;
  color: #111827;
}

.faq-inner summary::-webkit-details-marker {
  display: none;
}

.faq-inner summary::after {
  content: '+';
  float: right;
  font-weight: 700;
  color: #4f46e5;
}

.faq-inner details[open] summary::after {
  content: '−';
}

.faq-inner p {
  margin: 8px 0 4px;
  font-size: 0.9rem;
  color: #4b5563;
}

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

.footer {
  margin-top: 60px;
  padding: 50px 0 20px;
  background: linear-gradient(135deg, #1f2933 0%, #111827 100%);
  color: #e5e7eb;
}

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

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

.footer-column ul li {
  margin-bottom: 8px;
}

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

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

.footer-bottom {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
  text-align: center;
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ===========================
   Responsive tweaks
   =========================== */

@media (max-width: 640px) {
  .calculator-card {
    border-radius: 20px;
  }

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

  .result-value.big {
    font-size: 1.4rem;
  }
}
