/* ==========================================================================
   onlineconvert.net — main.css

   Design note. The subject is equivalence: two different names for one physical
   quantity. So the page is built around a single horizontal bar where the two
   expressions sit either side of a large equals sign, with the defining factor
   set beneath it. That bar is the only loud thing on the page; everything else
   stays quiet.

   Typographic rule, applied without exception: quantities, unit symbols and
   formulas are set in IBM Plex Mono. Prose is set in IBM Plex Sans. The reader
   can tell data from language at a glance because the typeface says so.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  --paper:    #f7f7f5;
  --surface:  #ffffff;
  --ink:      #16181d;
  --ink-2:    #5a5f6b;
  --ink-3:    #8b8f99;
  --rule:     #e3e3de;
  --rule-2:   #f0f0ec;

  --accent:      #2b44ff;
  --accent-soft: #eceeff;
  --accent-ink:  #1a2bb8;
  --exact:       #0f6b53;
  --exact-soft:  #e4f2ed;

  /* The header is dark in BOTH themes, so it cannot read --ink: that token
     inverts. Anything that must keep its colour through a theme flip gets its
     own variable here. This is not tidiness, it is the bug that made the old
     project's navbar go transparent. */
  --nav-bg:     #16181d;
  --nav-panel:  #1f222a;
  --nav-fg:     #b9bdc7;
  --nav-fg-on:  #ffffff;
  --nav-line:   #2e323c;
  --nav-hover:  #262a33;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --shadow:    0 1px 2px rgba(20, 22, 28, .06), 0 4px 14px rgba(20, 22, 28, .05);
  --shadow-lg: 0 2px 6px rgba(20, 22, 28, .07), 0 18px 44px rgba(20, 22, 28, .10);
  --t: 160ms cubic-bezier(.4, 0, .2, 1);

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --paper:    #101216;
  --surface:  #181b21;
  --ink:      #eceef2;
  --ink-2:    #9aa0ac;
  --ink-3:    #6d737f;
  --rule:     #262a32;
  --rule-2:   #1e222a;

  --accent:      #8b9bff;
  --accent-soft: #1c2140;
  --accent-ink:  #b3bdff;
  --exact:       #4fc4a1;
  --exact-soft:  #12302a;

  --shadow:    0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

/* The hidden attribute loses to any display declaration. Without this rule
   panels stack on top of each other the first time you write display:flex. */
[hidden] { display: none !important; }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .5em; }
h2 { font-size: 1.125rem; font-weight: 600; }
p  { margin: 0 0 1em; }
a  { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-ink); }

.num, .sym, kbd, .working__l, .equiv__n, .equiv__u {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.wrap { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .7rem 1.1rem;
  border-radius: 0 0 var(--r-sm) 0; font-weight: 600;
}
.skip:focus { left: 0; }

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

/* --------------------------------------------------------------------------
   3. Header
   -------------------------------------------------------------------------- */

.nav {
  position: sticky; top: 0; z-index: 40;
  /* Literal fallback first: if --nav-bg ever goes missing the header must still
     be opaque rather than invisible. */
  background: #16181d;
  background: var(--nav-bg, #16181d);
  color: var(--nav-fg, #b9bdc7);
  border-bottom: 1px solid var(--nav-line, #2e323c);
}

.nav__bar {
  display: flex; align-items: center; gap: .75rem;
  min-height: 56px; padding-block: .5rem;
  flex-wrap: wrap;
}

.nav__brand {
  display: inline-flex; align-items: center; gap: .5rem;
  color: var(--nav-fg-on, #fff); text-decoration: none;
  font-weight: 600; letter-spacing: -.02em;
  margin-right: auto;
}

/* The mark is the site's signature compressed to one glyph. */
.nav__mark {
  font-family: var(--mono);
  font-size: 1.15rem; font-weight: 600; line-height: 1;
  color: #2b44ff; color: var(--accent, #2b44ff);
  background: rgba(43, 68, 255, .16);
  width: 1.6rem; height: 1.6rem;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
}

.nav__toggle, .nav__theme {
  background: transparent; border: 1px solid var(--nav-line, #2e323c);
  color: inherit; border-radius: var(--r-sm);
  width: 38px; height: 38px; padding: 0;
  cursor: pointer; display: grid; place-items: center;
  transition: background var(--t);
}
.nav__toggle:hover, .nav__theme:hover { background: var(--nav-hover, #262a33); }

.nav__bars, .nav__bars::before, .nav__bars::after {
  content: ""; display: block; width: 16px; height: 1.5px;
  background: currentColor; border-radius: 2px;
}
.nav__bars { position: relative; }
.nav__bars::before { position: absolute; top: -5px; }
.nav__bars::after  { position: absolute; top:  5px; }

.nav__themeicon {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* Normal flow inside the sticky header — no fixed positioning with a guessed
   top offset, because the header grows when the brand wraps on small screens. */
.nav__panel {
  flex-basis: 100%;
  padding: .75rem 0 1rem;
  border-top: 1px solid var(--nav-line, #2e323c);
  margin-top: .5rem;
}

.nav__search { position: relative; }
.nav__search input {
  width: 100%; padding: .65rem 2.4rem .65rem .8rem;
  background: var(--nav-panel, #1f222a);
  border: 1px solid var(--nav-line, #2e323c);
  border-radius: var(--r-sm);
  color: var(--nav-fg-on, #fff);
  font: inherit;
}
.nav__search input::placeholder { color: var(--nav-fg, #b9bdc7); opacity: .7; }
.nav__kbd {
  position: absolute; right: .55rem; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: .75rem;
  border: 1px solid var(--nav-line, #2e323c); border-radius: 4px;
  padding: 0 .35rem; color: var(--nav-fg, #b9bdc7);
}

.nav__results { list-style: none; margin: .5rem 0 0; padding: 0; }
.nav__results li a {
  display: block; padding: .5rem .6rem; border-radius: var(--r-sm);
  color: var(--nav-fg-on, #fff); text-decoration: none;
}
.nav__results li a:hover, .nav__results li a:focus { background: var(--nav-hover, #262a33); }
.nav__results .hit__why { color: var(--nav-fg, #b9bdc7); font-size: .85rem; }

.nav__cols {
  display: grid; gap: 1.25rem 2rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 1rem;
}
.nav__grouph {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--nav-fg, #b9bdc7);
  margin: 0 0 .5rem;
}
.nav__cols ul { list-style: none; margin: 0; padding: 0; }
.nav__cols a {
  display: block; padding: .3rem 0; color: var(--nav-fg-on, #fff);
  text-decoration: none; font-size: .95rem;
}
.nav__cols a:hover { color: var(--accent, #8b9bff); }
.nav__cols a[aria-current="page"] { color: var(--accent, #8b9bff); }

@media (min-width: 900px) {
  .nav__panel { display: block !important; }
  .nav__toggle { display: none; }
  .nav__panel { flex-basis: 100%; }
}

/* --------------------------------------------------------------------------
   4. Layout blocks
   -------------------------------------------------------------------------- */

main { padding-block: 1.5rem 4rem; }

.crumbs {
  font-family: var(--mono); font-size: .78rem;
  color: var(--ink-3); display: flex; gap: .45rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.cols { display: grid; gap: 1rem; }
@media (min-width: 820px) { .cols { grid-template-columns: 1fr 1fr; } }
.cols > .panel { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   5. The equivalence bar — the signature element
   -------------------------------------------------------------------------- */

.equiv {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 1.5rem 1.25rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.equiv__row {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: .4rem 1rem;
}

.equiv__side { display: inline-flex; align-items: baseline; gap: .35rem; min-width: 0; }

.equiv__n {
  font-size: clamp(1.9rem, 7vw, 3.4rem);
  font-weight: 500; letter-spacing: -.03em; line-height: 1;
  overflow-wrap: anywhere;
}
.equiv__side--out .equiv__n { color: var(--accent); font-weight: 600; }

.equiv__u {
  font-size: clamp(.95rem, 2.4vw, 1.2rem);
  color: var(--ink-2); font-weight: 500;
}

.equiv__eq {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 5vw, 2.6rem);
  color: var(--ink-3); line-height: 1;
}

.equiv__def, .equiv__break {
  font-family: var(--mono); font-size: .82rem;
  color: var(--ink-2); margin: 1rem 0 0;
  padding-top: .8rem; border-top: 1px solid var(--rule-2);
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.equiv__notice {
  font-family: var(--mono); font-size: .74rem; color: var(--ink-3);
  margin: .6rem 0 0; line-height: 1.5;
}
.equiv__break { border-top: 0; padding-top: 0; margin-top: .35rem; color: var(--ink-3); }

.tag {
  font-family: var(--mono); font-size: .66rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .18rem .45rem; border-radius: 4px;
}
.tag--exact { background: var(--exact-soft); color: var(--exact); }

/* --------------------------------------------------------------------------
   6. Converter form
   -------------------------------------------------------------------------- */

.convert__grid {
  display: grid; gap: .75rem;
  grid-template-columns: 1fr;
  align-items: end;
}
@media (min-width: 700px) {
  .convert__grid { grid-template-columns: 1fr 1.3fr auto 1.3fr; }
}

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field__l {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}
.field__i {
  width: 100%; padding: .6rem .7rem;
  border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink);
  font: inherit;
}
input.field__i { font-family: var(--mono); font-size: 1.05rem; }
select.field__i { appearance: none; padding-right: 1.8rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1rem center, right .75rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field__i:focus-visible { border-color: var(--accent); }

.swap {
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink-2);
  border-radius: var(--r-sm); height: 42px; width: 42px;
  cursor: pointer; font-size: 1.1rem; justify-self: center;
  transition: color var(--t), border-color var(--t);
}
.swap:hover { color: var(--accent); border-color: var(--accent); }

.convert__acts {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  font: inherit; font-weight: 500; cursor: pointer;
  padding: .5rem .9rem; border-radius: var(--r-sm);
  background: var(--accent); color: #fff; border: 1px solid transparent;
  transition: filter var(--t);
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--rule); }
.btn--ghost:hover { color: var(--accent); border-color: var(--accent); }

.convert__status {
  font-family: var(--mono); font-size: .78rem; color: var(--exact);
}

.recent {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--rule-2);
}
.recent__l {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}
.recent__list { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   7. Tables, chips, prose
   -------------------------------------------------------------------------- */

.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--rule-2); }
.tbl thead th {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
}
.tbl tbody th { font-weight: 500; }
.tbl tr:last-child th, .tbl tr:last-child td { border-bottom: 0; }
.tbl td.num { text-align: right; white-space: nowrap; }
.tbl td.sym { color: var(--ink-3); font-family: var(--mono); font-size: .85rem; }
.tbl a { text-decoration: none; color: inherit; }
.tbl a:hover { color: var(--accent); text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  font-family: var(--mono); font-size: .82rem;
  padding: .3rem .6rem; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--ink-2);
  text-decoration: none; background: var(--paper);
  transition: color var(--t), border-color var(--t);
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chips--sm .chip { font-size: .76rem; }

.prose { max-width: 68ch; }
.prose p { color: var(--ink-2); }

.working {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-sm); padding: .6rem .75rem;
  font-family: var(--mono); font-size: .88rem;
}
.working__l {
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
}
.spelled { font-size: .9rem; color: var(--ink-3); }

.faq { border-bottom: 1px solid var(--rule-2); }
.faq:last-of-type { border-bottom: 0; }
.faq summary {
  cursor: pointer; padding: .7rem 0; font-weight: 500;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--mono); color: var(--ink-3); }
.faq[open] summary::after { content: "−"; }
.faq__a { padding-bottom: .5rem; color: var(--ink-2); max-width: 68ch; }
.faq__a p { margin: 0; }

.discover__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .discover__list { grid-template-columns: 1fr 1fr; } }
.discover__list a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .4rem .5rem; border-radius: var(--r-sm);
  font-family: var(--mono); font-size: .85rem;
  color: var(--ink-2); text-decoration: none;
}
.discover__list a:hover { background: var(--paper); color: var(--accent); }
.discover__cat {
  font-size: .66rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap;
}

.guide__toc .chips { margin-top: .25rem; }
.guide__unit { scroll-margin-top: 5rem; }
.guide__h {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  font-size: 1.2rem;
}
.guide__sym {
  font-family: var(--mono); font-size: .85rem; font-weight: 500;
  color: var(--ink-3);
}
.guide__eq {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  font-size: .88rem; color: var(--ink-2);
  padding: .5rem .7rem; margin-bottom: .9rem;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-sm);
}
.guide__unit > p { max-width: 68ch; color: var(--ink-2); }
.guide__promo p { margin: 0; color: var(--ink-2); }

/* --------------------------------------------------------------------------
   8. Hub
   -------------------------------------------------------------------------- */

.hero { padding: 2rem 0 2.5rem; }
.hero__eyebrow {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: .8rem;
}
.hero__h {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: .5rem 1rem;
  font-family: var(--mono); font-weight: 500;
  font-size: clamp(1.6rem, 6vw, 3rem); letter-spacing: -.03em;
  margin-bottom: 1rem;
}
.hero__b { color: var(--accent); }
.hero__eq { color: var(--ink-3); }
.hero__note {
  max-width: 60ch; color: var(--ink-2); font-size: .95rem;
  display: flex; gap: .6rem; align-items: flex-start; flex-wrap: wrap;
}

.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin-bottom: 1.5rem;
}
.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r); padding: 1.1rem;
  transition: border-color var(--t), box-shadow var(--t);
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card__h { font-size: 1.05rem; margin-bottom: .35rem; }
.card__h a { color: inherit; text-decoration: none; }
.card__p { font-size: .88rem; color: var(--ink-2); margin-bottom: .8rem; }

.lede { max-width: 60ch; margin-bottom: 1.5rem; }
.lede h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.lede p { color: var(--ink-2); }

/* --------------------------------------------------------------------------
   9. Footer
   -------------------------------------------------------------------------- */

.foot {
  background: #16181d;
  background: var(--nav-bg, #16181d);
  color: var(--nav-fg, #b9bdc7);
  padding: 2.5rem 0;
  font-size: .88rem;
}
.foot__in { display: grid; gap: 1.25rem; }
.foot__brand { display: flex; gap: .75rem; align-items: flex-start; max-width: 62ch; }
.foot__brand p { margin: 0; }
.foot__links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.foot__links a { color: var(--nav-fg-on, #fff); text-decoration: none; }
.foot__links a:hover { color: var(--accent, #8b9bff); }
.foot__copy { font-family: var(--mono); font-size: .78rem; color: var(--nav-fg, #b9bdc7); margin: 0; }

/* --------------------------------------------------------------------------
   10. Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .nav, .foot, .convert__acts, .recent { display: none; }
  .panel, .equiv { border-color: #ccc; box-shadow: none; }
}
