/* ==========================================================================
   Keifa Unit Converter - SEO pages & components
   Breadcrumbs, category navigation, hero, chips, tables, info cards,
   search results, favorites, share menu, natural-language box.
   Loaded AFTER styles.css; 100% Theme-Aware (Light & Dark).
   ========================================================================== */

/* --- Skip link & accessibility ------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  z-index: 200;
  background: var(--amber);
  color: var(--amber-ink);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 800;
  text-decoration: none;
  transition: top var(--trans);
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Breadcrumb ----------------------------------------------------------- */
.breadcrumb {
  margin: 18px auto 6px;
}

.breadcrumb ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb li + li::before {
  content: "›";
  color: var(--line);
  margin-inline-end: 2px;
}

[dir="rtl"] .breadcrumb li + li::before {
  content: "‹";
}

.breadcrumb a {
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--trans);
}

.breadcrumb a:hover {
  color: var(--amber);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--ink);
  font-weight: 800;
}

/* --- Hero ----------------------------------------------------------------- */
.app-hero {
  padding: 14px 0 6px;
}

.app-hero .hero-copy {
  max-width: 900px;
}

.app-hero h1 {
  font-size: clamp(1.6rem, 3.6vw, 2.7rem);
  line-height: 1.2;
  margin: 10px 0 12px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.hero-lead {
  color: var(--ink-secondary);
  font-size: 1.05rem;
  max-width: 76ch;
  margin: 0 0 18px;
}

/* --- Natural-language box ------------------------------------------------- */
.nl-box {
  border: 1px solid var(--hair);
  background: var(--panel-glass);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 18px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.nl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.nl-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

.nl-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nl-row input {
  flex: 1 1 260px;
  min-width: 0;
  background: var(--input-box-bg);
  border: 1px solid var(--input-box-border);
  border-radius: var(--radius-md);
  color: var(--input-text);
  padding: 12px 16px;
  font: inherit;
  font-size: 1rem;
  transition: border-color var(--trans), box-shadow var(--trans);
}

.nl-row input::placeholder {
  color: var(--input-placeholder);
}

.nl-row input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
  outline: none;
}

.nl-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.nl-ex-label {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 700;
}

.nl-results {
  margin-top: 10px;
}

.nl-error {
  color: var(--coral);
  font-size: 0.9rem;
  margin: 0 0 8px;
  font-weight: 600;
}

.nl-suggest-label {
  color: var(--ink-muted);
  font-size: 0.8rem;
  margin: 0 6px 6px 0;
}

.nl-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Search --------------------------------------------------------------- */
.search-box-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--input-box-bg);
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  padding: 4px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--trans), box-shadow var(--trans);
}

.search-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--input-text);
  padding: 12px 0;
  font: inherit;
  font-size: 0.98rem;
}

.search-box input::placeholder {
  color: var(--input-placeholder);
}

.search-box input:focus {
  outline: none;
}

.search-results {
  position: absolute;
  z-index: 40;
  inset-inline: 0;
  margin-top: 8px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  max-height: 60vh;
  overflow: auto;
  backdrop-filter: blur(20px);
}

.search-group {
  margin-bottom: 14px;
}

.search-group:last-child {
  margin-bottom: 0;
}

.search-group-title {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 800;
  margin-bottom: 8px;
}

/* --- Category navigation -------------------------------------------------- */
.category-nav {
  margin-top: 12px;
  display: grid;
  gap: 14px;
}

.cat-group {
  display: grid;
  gap: 8px;
}

.cat-group-title {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 800;
}

.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hair);
  background: var(--panel-glass);
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  transition: var(--trans);
  min-height: 40px;
}

.cat-chip:hover {
  border-color: var(--teal);
  color: var(--ink);
  background: var(--teal-soft);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--teal-glow);
}

.cat-chip.active {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
  box-shadow: 0 4px 14px var(--amber-glow);
}

.cat-chip-icon {
  font-size: 1.05rem;
}

.cat-chip-count {
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: var(--hair);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  direction: ltr;
}

/* --- Chips & link sections ------------------------------------------------ */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-grid.compact {
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hair);
  background: var(--panel-glass);
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
  transition: var(--trans);
}

.chip:hover {
  border-color: var(--teal);
  color: var(--ink);
  background: var(--teal-soft);
  transform: translateY(-1px);
}

.chip small {
  color: var(--ink-muted);
  font-weight: 500;
}

.pair-chip .pair-arrow {
  color: var(--amber);
  font-weight: 900;
}

.chip-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
  border: 1px solid var(--teal);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-weight: 800;
}

.eng-chip {
  border-color: rgba(245, 158, 11, 0.35);
}

.eng-chip:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-soft);
}

.link-section {
  margin-top: 28px;
}

.link-section-title {
  font-size: 1.05rem;
  margin: 0 0 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.pair-actions {
  margin: 6px auto 0;
}

.reverse-btn {
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: var(--amber);
}

/* --- SEO content blocks --------------------------------------------------- */
.seo-block {
  margin-top: 32px;
}

.seo-title {
  font-size: 1.32rem;
  margin: 0 0 12px;
  font-weight: 900;
  color: var(--ink);
}

.seo-lead {
  color: var(--ink-secondary);
  max-width: 80ch;
  margin: 0 0 14px;
  line-height: 1.65;
}

.seo-note {
  border-inline-start: 4px solid var(--teal);
  background: var(--teal-soft);
  padding: 12px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--ink-secondary);
  font-size: 0.94rem;
  margin: 0 0 18px;
  line-height: 1.6;
}

.seo-uses {
  color: var(--ink-secondary);
  margin: 0 0 18px;
  padding-inline-start: 22px;
  line-height: 1.65;
}

.seo-uses li {
  margin-bottom: 6px;
}

.seo-block h3 {
  font-size: 1.05rem;
  margin: 22px 0 12px;
  font-weight: 800;
  color: var(--ink);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.info-card {
  border: 1px solid var(--hair);
  background: var(--panel-glass);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  color: var(--ink-secondary);
}

.info-card h3 {
  margin: 0 0 10px;
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--ink);
}

.formula-line {
  font-family: var(--font-mono);
  font-size: 0.94rem;
  color: var(--teal);
  margin: 6px 0;
  word-break: break-word;
}

.formula-line.muted {
  color: var(--ink-muted);
}

.worked {
  font-family: var(--font-mono);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--amber);
  margin: 6px 0 10px;
}

.unit-info-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.u-sym-lg {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--amber);
}

.unit-info-name {
  font-weight: 800;
  color: var(--ink);
}

.unit-info-def {
  color: var(--ink-secondary);
  margin: 0 0 8px;
  line-height: 1.55;
}

.unit-info-rel {
  font-family: var(--font-mono);
  color: var(--teal);
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.unit-info-sig {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.si-badge {
  background: var(--green-soft);
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-weight: 800;
}

.nonsi-badge {
  background: var(--hair);
  border: 1px solid var(--hair-strong);
  color: var(--ink-muted);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-weight: 700;
}

.badge-si-base {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #10b981;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-weight: 800;
}

.badge-si-derived {
  background: rgba(14, 165, 233, 0.14);
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #0ea5e9;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-weight: 700;
}

.badge-si-accepted {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #f59e0b;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-weight: 700;
}

.badge-non-si {
  background: var(--hair);
  border: 1px solid var(--hair-strong);
  color: var(--ink-muted);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-weight: 600;
}

.badge-historical {
  background: rgba(217, 119, 6, 0.14);
  border: 1px solid rgba(217, 119, 6, 0.4);
  color: #d97706;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-weight: 700;
}

.badge-special {
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #8b5cf6;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-weight: 700;
}

.badge-approx {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  border-radius: var(--radius-pill);
  padding: 1px 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-sm {
  font-size: 0.72rem;
  padding: 1px 6px;
  white-space: nowrap;
}

.unit-info-note {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(217, 119, 6, 0.08);
  border-inline-start: 3px solid #d97706;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-secondary);
}

/* --- Conversion table ---------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  background: var(--panel-glass);
  box-shadow: var(--shadow-sm);
}

.conv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums slashed-zero;
  min-width: 320px;
}

.conv-table th, .conv-table td {
  text-align: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.conv-table thead th {
  background: var(--table-head-bg);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.conv-table tbody tr:last-child td {
  border-bottom: 0;
}

.conv-table tbody tr:hover td {
  background: var(--table-row-hover);
}

.conv-table .u-sym {
  font-family: var(--font-mono);
  color: var(--amber);
  font-weight: 700;
}

.conv-table .u-def {
  color: var(--ink-secondary);
}

.conv-table .u-si {
  color: var(--ink-muted);
}

/* --- Category overview grid ---------------------------------------------- */
.cat-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.cat-overview-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--hair);
  background: var(--panel-glass);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--ink);
  transition: var(--trans);
  box-shadow: var(--shadow-sm);
}

.cat-overview-card:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cov-icon {
  font-size: 1.35rem;
}

.cov-body {
  display: flex;
  flex-direction: column;
}

.cov-body b {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.cov-body small {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

/* --- Related tools ------------------------------------------------------- */
.tools-links {
  margin-top: 32px;
}

.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.link-card {
  border: 1px solid var(--hair);
  background: var(--panel-glass);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.link-card h3 {
  margin: 0 0 8px;
  font-size: 0.96rem;
  color: var(--ink);
}

.link-card a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.link-card a:hover {
  color: var(--amber);
}

.link-card ul {
  margin: 0;
  padding-inline-start: 18px;
  color: var(--ink-secondary);
}

/* --- Converter additions ------------------------------------------------- */
.all-units-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.units-filter {
  flex: 1 1 220px;
  min-width: 0;
  background: var(--input-box-bg);
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  color: var(--input-text);
  padding: 10px 14px;
  font: inherit;
  transition: border-color var(--trans), box-shadow var(--trans);
}

.units-filter::placeholder {
  color: var(--input-placeholder);
}

.units-filter:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.control-group.compact {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.input-error {
  margin: 12px 0 0;
  color: var(--coral);
  font-size: 0.9rem;
  font-weight: 700;
}

.pair-hint {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.pair-hint a {
  color: var(--amber);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dashed var(--amber);
}

.pair-hint a:hover {
  border-bottom-style: solid;
}

.formula-card > summary {
  cursor: pointer;
  list-style: none;
}

.formula-card > summary::-webkit-details-marker {
  display: none;
}

.formula-card > summary::after {
  content: "▾";
  margin-inline-start: auto;
  color: var(--ink-muted);
}

.formula-card[open] > summary::after {
  content: "▴";
}

.formula-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
}

.formula-result {
  color: var(--amber);
  font-weight: 700;
}

/* --- Share menu ---------------------------------------------------------- */
.share-wrap {
  position: relative;
}

.share-menu {
  position: absolute;
  z-index: 50;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: grid;
  gap: 4px;
  backdrop-filter: blur(20px);
}

.share-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: start;
  font-family: inherit;
  transition: var(--trans);
}

.share-item:hover {
  background: var(--teal-soft);
  color: var(--ink);
}

/* --- Favorites & tools cards --------------------------------------------- */
.favoriteBtn.is-favorite,
#favoriteBtn.is-favorite {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-soft);
}

.fav-link, .history-reuse {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: start;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

a.fav-link {
  text-decoration: none;
}

.fav-link:hover .history-equation {
  color: var(--amber);
}

/* --- Mobile refinements -------------------------------------------------- */
@media (max-width: 720px) {
  .app-hero h1 {
    font-size: 1.55rem;
  }
  .nl-row {
    flex-direction: column;
  }
  .nl-row .btn {
    width: 100%;
  }
  .converter-actions-row .btn {
    flex: 1 1 140px;
  }
  .cat-chip {
    font-size: 0.85rem;
    padding: 7px 11px;
  }
  .cat-overview {
    grid-template-columns: 1fr 1fr;
  }
  .cat-overview-card {
    padding: 11px;
    gap: 9px;
  }
  .conv-table {
    font-size: 0.85rem;
  }
  .search-results {
    position: static;
  }
}

@media (max-width: 420px) {
  .cat-overview {
    grid-template-columns: 1fr;
  }
}

/* --- RTL: keep technical strings LTR ------------------------------------- */
[dir="rtl"] .conv-table .u-sym,
[dir="rtl"] .formula-line,
[dir="rtl"] .worked,
[dir="rtl"] .u-sym-lg,
[dir="rtl"] .unit-info-rel,
[dir="rtl"] .cat-chip-count {
  direction: ltr;
  unicode-bidi: isolate;
}

/* --- Print --------------------------------------------------------------- */
@media print {
  .topbar, .ad-wrapper, .search-box-wrap, .category-nav, .share-wrap,
  .favorites-card, .history-card, .nl-box, .link-section, .tools-links {
    display: none !important;
  }
}
