/* ============================================
   CovertItAll UX Polish — v1.9.1
   Additive layer. Does NOT replace any existing CSS.
   ============================================ */

/* --- PART 1: Input & Converter UX --- */

/* Auto-select on click/tap */
.large-input { cursor: text; }
.large-input:focus { caret-color: var(--accent-color); }

/* Numeric inputs: hide spinners for cleaner look */
.large-input[type="number"]::-webkit-inner-spin-button,
.large-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.large-input[type="number"] { -moz-appearance: textfield; }

/* Stronger focus ring */
.large-input:focus,
.calc-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .18);
}

/* Quick value buttons: better touch targets + states */
.quick-btn {
  min-height: 36px;
  min-width: 44px;
  padding: 6px 12px;
  font-weight: 600;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.quick-btn:active {
  background: var(--accent-color);
  color: var(--bg-color);
  border-color: var(--accent-color);
  transform: scale(.96);
}
.quick-btn:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Swap button: smoother interaction */
.swap-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.swap-btn:active {
  transform: scale(.92);
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: var(--bg-color);
}
@media (max-width: 768px) {
  .swap-btn:active { transform: rotate(90deg) scale(.92); }
}
.swap-btn:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Copy feedback inline */
.btn-primary.copied {
  background: var(--success-color);
  color: #fff;
}

/* --- PART 2: Result Area --- */

/* Inline explanation / result text: more prominent */
.inline-explanation,
#resultText,
#inline-explanation {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-color);
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(56, 189, 248, .06);
  border: 1px solid rgba(56, 189, 248, .12);
  margin-top: 14px;
  line-height: 1.4;
  min-height: 44px;
}
html[data-theme="light"] .inline-explanation,
html[data-theme="light"] #resultText,
html[data-theme="light"] #inline-explanation {
  background: rgba(2, 132, 199, .06);
  border-color: rgba(2, 132, 199, .12);
}

/* --- PART 3: Mobile UX --- */

/* Sticky compact mobile header */
@media (max-width: 768px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 200;
    overflow: hidden;
    max-height: none;
  }

  /* Collapse sidebar nav on mobile by default */
  .sidebar .nav-menu,
  .sidebar .sidebar-tagline {
    display: none;
  }

  /* Show minimal mobile header */
  .sidebar .sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
  }

  .sidebar .search-container {
    padding: 6px 16px 10px;
  }

  /* Mobile menu toggle */
  .sidebar.menu-open .nav-menu {
    display: block;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
  }

  .sidebar.menu-open .sidebar-tagline { display: block; }

  /* Mobile: converter above fold */
  .hero-section {
    margin-bottom: 12px;
  }

  .hero-section p {
    font-size: .92rem;
  }

  /* Touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-item {
    min-height: 44px;
  }

  /* FAQ compact on mobile */
  details.faq-item > summary,
  .faq-item h4 {
    cursor: pointer;
  }

  /* Table horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent jumpiness */
  .converter-card {
    contain: layout style;
  }
}

/* Mobile hamburger button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
}
.mobile-menu-btn:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Theme toggle: compact on mobile */
@media (max-width: 768px) {
  .theme-toggle {
    padding: 6px 10px;
    font-size: .85rem;
    margin-top: 0;
    width: auto;
  }
}

/* --- PART 5: Technical SEO --- */

/* Breadcrumbs: consistent styling */
.breadcrumbs {
  color: var(--text-muted);
  font-size: .85rem;
}
.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.breadcrumbs a:hover {
  color: var(--accent-color);
}

/* Last updated: subtle */
.last-updated {
  color: var(--text-muted);
  font-size: .82rem;
  margin-bottom: 14px;
}

/* --- PART 6: Session State --- */

/* Recently used converters */
.recent-converters-section {
  margin-top: 16px;
}
.recent-converters-section h3 {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

/* --- PART 7: Performance --- */

/* Prevent CLS on ad containers */
.ad-container {
  min-height: 90px;
  contain: layout style;
}

/* Content visibility for below-fold sections */
.section.content,
.info-card,
.related-tools-block {
  content-visibility: auto;
  contain-intrinsic-size: auto 200px;
}

/* --- PART 10: Micro UX Polish --- */

/* Smoother transitions site-wide */
.btn,
.quick-btn,
.swap-btn,
.pill-link,
.link-card,
.card,
.nav-item,
.theme-toggle,
.chip {
  transition: all .15s ease;
}

/* Better keyboard focus states */
.btn:focus-visible,
.pill-link:focus-visible,
.link-card:focus-visible,
.card:focus-visible,
.chip:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 12px 20px;
  background: var(--accent-color);
  color: var(--bg-color);
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top .2s;
}
.skip-link:focus {
  top: 16px;
}

/* Related tools block */
.related-tools-block {
  margin-top: 24px;
}
.related-tools-block h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

/* Site footer: consistent */
.site-footer {
  margin-top: 40px;
  padding: 24px 0 16px;
  border-top: 1px solid var(--border-color);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 24px;
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.site-footer a:hover {
  color: var(--accent-color);
}
.site-footer .muted {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.4;
}
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .site-footer {
    margin-top: 28px;
    padding: 18px 0 12px;
  }
}

/* Print: hide non-essential */
@media print {
  .sidebar, .ad-container, .mobile-menu-btn,
  .theme-toggle, .skip-link { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
}
