/* =========================================================
   MRPack to ZIP Converter — Main Stylesheet
   Responsive design, mobile-first, Web Vitals optimized
   ========================================================= */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  color: #1a1a1a;
  background: #fafafa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: #2563eb;
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ---------- Layout containers ---------- */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

main {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

/* ---------- Skip link for accessibility ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #1a1a1a;
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */
.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.95);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: #111827;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: #2563eb;
}

.brand-logo {
  width: 28px;
  height: 28px;
}

/* ---------- Navigation ---------- */
.main-nav > ul {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin: 0;
  padding: 0;
}

.main-nav a {
  color: #374151;
  font-size: 0.95rem;
  font-weight: 500;
}

.main-nav a:hover {
  color: #2563eb;
  text-decoration: none;
}

.lang-switcher {
  position: relative;
}

/* Native <details>/<summary> disclosure — no JS needed, always hidden by default */
details.lang-switcher > summary {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  user-select: none;
}

details.lang-switcher > summary::-webkit-details-marker {
  display: none;
}

details.lang-switcher > summary::after {
  content: " ▾";
  font-size: 0.8em;
  opacity: 0.7;
}

details.lang-switcher[open] > summary::after {
  content: " ▴";
}

details.lang-switcher > summary:hover {
  background: #e5e7eb;
}

details.lang-switcher > .lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  min-width: 200px;
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  z-index: 60;
  display: block; /* only visible when <details> is open */
}

details.lang-switcher > .lang-menu li {
  margin: 0;
  width: 100%;
}

details.lang-switcher > .lang-menu li a {
  display: block;
  padding: 0.5rem 0.85rem;
  color: #374151;
  font-size: 0.9rem;
  text-decoration: none;
}

details.lang-switcher > .lang-menu li a:hover {
  background: #f3f4f6;
  text-decoration: none;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
}

/* ---------- Hero / Page header ---------- */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  padding: 2.5rem 0 2rem;
  text-align: center;
}

.hero h1 {
  font-size: 1.85rem;
  line-height: 1.25;
  font-weight: 800;
  margin-bottom: 0.75rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.hero .lead {
  font-size: 1.05rem;
  opacity: 0.95;
  max-width: 650px;
  margin: 0 auto;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.badge {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ---------- Converter tool card ---------- */
.tool-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: -1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.tool-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tool-tab {
  background: transparent;
  border: 0;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tool-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 2rem 1rem;
  text-align: center;
  background: #f8fafc;
  transition: all 0.2s;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

.dropzone-text {
  color: #374151;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.dropzone-hint {
  color: #6b7280;
  font-size: 0.85rem;
}

.btn-file {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  margin-top: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  border: 0;
  font-size: 0.95rem;
}

.btn-file:hover {
  background: #1d4ed8;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  flex-direction: column;
}

.input-row input[type="text"],
.input-row input[type="url"] {
  flex: 1;
  padding: 0.7rem 0.85rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

.input-row input:focus {
  border-color: #2563eb;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  border: 0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.progress-area {
  display: none;
  margin-top: 1.25rem;
}

.progress-area.visible {
  display: block;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  width: 0%;
  transition: width 0.3s;
}

.progress-status {
  font-size: 0.9rem;
  color: #4b5563;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.92rem;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.alert-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

/* ---------- Content sections ---------- */
.section {
  margin-top: 2.5rem;
}

.section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #111827;
  line-height: 1.3;
}

.section h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #1f2937;
}

.section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  color: #374151;
}

.section p {
  margin-bottom: 1rem;
  color: #374151;
}

.section ul,
.section ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.section li {
  margin-bottom: 0.35rem;
  color: #374151;
}

.section code {
  background: #f3f4f6;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  color: #be185d;
}

.section pre {
  background: #1f2937;
  color: #f3f4f6;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.section pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

/* Cards grid */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.1rem;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.card h3 {
  margin-top: 0;
  font-size: 1.05rem;
}

.card p {
  font-size: 0.92rem;
  color: #6b7280;
  margin-bottom: 0;
}

.card a {
  display: block;
  color: inherit;
}

.card a:hover {
  text-decoration: none;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #e5e7eb;
}

th {
  background: #f9fafb;
  font-weight: 600;
  color: #111827;
}

/* FAQ accordion */
.faq-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: #fff;
}

.faq-item summary {
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: #111827;
  list-style: none;
  position: relative;
  padding-right: 2.25rem;
}

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

.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  color: #6b7280;
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item .faq-body {
  padding: 0 1rem 1rem;
  color: #374151;
}

/* Steps */
.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.steps li {
  counter-increment: step;
  padding-left: 3rem;
  position: relative;
  margin-bottom: 1rem;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  background: #2563eb;
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 1rem;
}

.breadcrumbs a {
  color: #6b7280;
}

.breadcrumbs a:hover {
  color: #2563eb;
}

.breadcrumbs .sep {
  margin: 0 0.4rem;
  color: #d1d5db;
}

/* ---------- Footer ---------- */
.site-footer {
  background: #111827;
  color: #d1d5db;
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
  font-size: 0.92rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  margin-bottom: 1.75rem;
}

.footer-col h4 {
  color: #fff;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 0.4rem;
}

.footer-col a {
  color: #9ca3af;
}

.footer-col a:hover {
  color: #fff;
  text-decoration: none;
}

.footer-bottom {
  border-top: 1px solid #374151;
  padding-top: 1.25rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

.footer-bottom p {
  margin-bottom: 0.25rem;
}

/* ---------- 404 page ---------- */
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-code {
  font-size: 5rem;
  font-weight: 800;
  color: #2563eb;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-page h1 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  color: #111827;
}

.error-page p {
  color: #6b7280;
  margin-bottom: 1.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.error-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-secondary {
  background: #fff;
  color: #2563eb;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  display: inline-block;
  border: 1px solid #2563eb;
}

.btn-secondary:hover {
  background: #eff6ff;
  text-decoration: none;
}

/* ---------- Tablet (≥ 600px) ---------- */
@media (min-width: 600px) {
  .hero h1 {
    font-size: 2.25rem;
  }
  .hero .lead {
    font-size: 1.15rem;
  }
  .input-row {
    flex-direction: row;
  }
  .btn-primary {
    width: auto;
    flex-shrink: 0;
  }
  .card-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }
}

/* ---------- Desktop (≥ 900px) ---------- */
@media (min-width: 900px) {
  main {
    padding: 2rem 0 4rem;
  }
  .hero {
    padding: 3.5rem 0 2.5rem;
  }
  .hero h1 {
    font-size: 2.6rem;
  }
  .tool-card {
    padding: 2rem;
  }
  .section h2 {
    font-size: 1.75rem;
  }
  .card-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ---------- Mobile-specific (< 768px) ---------- */
@media (max-width: 767px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
  }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 1rem;
  }
  .main-nav.open {
    display: block;
  }
  .main-nav > ul {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  .main-nav > ul > li {
    width: 100%;
  }
  .main-nav > ul > li > a {
    display: block;
    padding: 0.5rem 0;
  }
  /* On mobile, the lang dropdown appears below the summary, full width */
  details.lang-switcher > .lang-menu {
    position: static;
    box-shadow: none;
    border: 1px solid #e5e7eb;
    margin-top: 0.5rem;
    min-width: 100%;
  }
  .header-inner {
    position: relative;
  }
  .hero h1 {
    font-size: 1.55rem;
  }
}

/* ---------- Print ---------- */
@media print {
  .site-header,
  .site-footer,
  .tool-card {
    display: none;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
