/* PlainConvert — calm, paper-like, restrained.
   No gradients, no glow, no colored icon circles. One teal accent. */

/* Satoshi from Fontshare. Variable font for weight 300–900. */
@font-face {
  font-family: 'Satoshi';
  src: url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700&display=swap');
}
@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700&f[]=jetbrains-mono@400&display=swap');

:root {
  /* Paper palette (light) */
  --bg:         #F7F6F2;
  --surface:    #FBFBF8;
  --surface-2:  #F1EFE9;
  --border:     #DCD8CE;
  --border-strong: #C5C0B4;
  --text:       #1F1D17;
  --text-muted: #6E6B62;
  --text-faint: #A8A49A;

  --accent:     #01696F;
  --accent-hover: #054A4F;
  --accent-soft: #E6EEEE;

  --danger:     #A12C7B;
  --success:    #437A22;

  --focus-ring: #01696F;

  --shadow-sm: 0 1px 0 rgba(31, 29, 23, 0.04);
  --shadow-md: 0 1px 2px rgba(31, 29, 23, 0.06), 0 2px 6px rgba(31, 29, 23, 0.04);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --font-sans: 'Satoshi', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --container: 64rem;
  --container-wide: 76rem;

  --step: 0.25rem;
}

[data-theme='dark'] {
  --bg:         #14130F;
  --surface:    #1A1916;
  --surface-2:  #21201C;
  --border:     #2E2C27;
  --border-strong: #3D3A33;
  --text:       #E9E6DD;
  --text-muted: #9A968C;
  --text-faint: #67645C;

  --accent:     #4FA0A8;
  --accent-hover: #6FBCC4;
  --accent-soft: #1B2A2C;

  --danger:     #D77FBE;
  --success:    #7FB857;

  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration-color: var(--accent-hover); }

/* Focus */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skip link */
.skip-link {
  position: absolute; left: 0; top: 0;
  background: var(--text); color: var(--bg);
  padding: 0.6rem 0.9rem; text-decoration: none;
  transform: translateY(-110%);
  transition: transform 120ms ease;
  z-index: 100; font-weight: 500;
}
.skip-link:focus { transform: translateY(0); color: var(--bg); }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.container-wide { max-width: var(--container-wide); }

.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.5rem; }
.stack-xl > * + * { margin-top: 2.5rem; }

/* ─── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(140%) blur(6px);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 0;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--text); text-decoration: none; font-weight: 700;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand__mark { width: 28px; height: 28px; color: var(--accent); }
.brand__name { font-size: 1.05rem; }

.site-nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.site-nav a {
  display: inline-flex; align-items: center;
  padding: 0.55rem 0.7rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500; font-size: 0.94rem;
  min-height: 44px;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); }

/* Hide category links on small screens; keep the All converters entry. */
@media (max-width: 720px) {
  .site-header__inner {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "nav";
    gap: 0.45rem 0.75rem;
    padding: 0.75rem 0;
  }
  .brand { grid-area: brand; }
  .site-nav {
    grid-area: nav;
    justify-content: flex-start;
    gap: 0.1rem;
  }
  .site-nav .theme-toggle { margin-left: auto; }
  .site-nav a {
    padding: 0.35rem 0.7rem;
    min-height: 40px;
  }
  .site-nav a.nav--cat { display: none; }
}
@media (min-width: 721px) {
  .site-nav a.nav--all { display: none; }
}

.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); color: var(--text-muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme='dark'] .theme-toggle .icon-sun { display: block; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }

/* ─── Hero / page intro ────────────────────────────────────────────────────── */
.hero { padding: 4rem 0 2.5rem; }
.hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.1; letter-spacing: -0.02em;
  margin: 0 0 1rem; font-weight: 700; max-width: 32ch;
}
.hero p {
  font-size: 1.125rem; color: var(--text-muted);
  margin: 0; max-width: 56ch;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}
.eyebrow::before {
  content: ''; width: 1.25rem; height: 1px; background: var(--border-strong);
}

/* ─── Cards / lists ────────────────────────────────────────────────────────── */
.category-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.category-list__item {
  background: var(--surface);
  padding: 1.25rem 1.25rem;
}
.category-list a {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem;
  text-decoration: none; color: var(--text);
  min-height: 44px;
}
.category-list a:hover { color: var(--accent); }
.category-list h3 {
  margin: 0 0 0.25rem; font-size: 1.1rem; font-weight: 600;
  letter-spacing: -0.01em;
}
.category-list p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.category-list__arrow { color: var(--text-faint); flex: none; padding-top: 4px; }

/* Converter listing inside a category */
.converter-list { list-style: none; padding: 0; margin: 0; }
.converter-list li + li { border-top: 1px solid var(--border); }
.converter-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 0;
  text-decoration: none; color: var(--text);
  min-height: 44px;
}
.converter-list a:hover { color: var(--accent); }
.converter-list__name { font-weight: 500; }
.converter-list__hint { color: var(--text-muted); font-size: 0.92rem; }

/* ─── Converter UI ─────────────────────────────────────────────────────────── */
.converter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 640px) { .converter { padding: 2rem; } }

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
  font-size: 0.92rem; font-weight: 500; color: var(--text-muted);
}
.input-row {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input-row input,
.input-row select {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  padding: 0.85rem 1rem;
  font-size: 1.1rem; font-variant-numeric: tabular-nums lining-nums;
  min-height: 44px;
}
.input-row input[readonly] {
  color: var(--text);
  font-weight: 500;
}
.input-row .unit {
  display: inline-flex; align-items: center;
  padding: 0 1rem;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  font-size: 0.95rem;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
.input-row select {
  background: var(--surface-2);
  flex: 0 0 auto;
  padding-right: 2rem;
  border: 0;
}
/* Adjacent select gets a left divider; sole select fills the row. */
.input-row > input + select,
.input-row > select + select {
  border-left: 1px solid var(--border);
}
.input-row > select:only-child {
  flex: 1 1 auto;
  background: transparent;
  border-left: 0;
}
.input-row .copy-btn {
  border: 0; border-left: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
  padding: 0 0.9rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.88rem; font-weight: 500;
  transition: color 120ms ease, background 120ms ease;
  min-width: 44px;
}
.input-row .copy-btn:hover { color: var(--text); background: var(--bg); }
.input-row .copy-btn[data-copied="true"] { color: var(--success); }
.input-row .copy-btn svg { width: 14px; height: 14px; }

.swap-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.7rem; font-size: 0.88rem;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-muted);
  cursor: pointer;
  min-height: 36px;
}
.swap-btn:hover { color: var(--text); border-color: var(--border-strong); }
.swap-btn svg { width: 14px; height: 14px; }

.error-text {
  color: var(--danger); font-size: 0.9rem; margin: 0;
}

.formula {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  display: inline-block;
}

/* ─── Reference table ──────────────────────────────────────────────────────── */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}
.ref-table caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}
.ref-table th, .ref-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.ref-table th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.ref-table tbody tr:last-child td { border-bottom: 0; }

/* ─── Sections ─────────────────────────────────────────────────────────────── */
.section { padding: 2.5rem 0; }
.section + .section { padding-top: 0; }
.section h2 {
  font-size: 1.4rem; letter-spacing: -0.01em; margin: 0 0 1rem;
  font-weight: 600;
}
.section h3 {
  font-size: 1.1rem; margin: 0 0 0.5rem; font-weight: 600;
}
.section p { margin: 0 0 0.75rem; color: var(--text); max-width: 70ch; }
.section .muted { color: var(--text-muted); }
.section ul { padding-left: 1.2rem; }
.section li { margin-bottom: 0.35rem; }

/* Breadcrumbs */
.crumbs {
  font-size: 0.9rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  margin: 1.5rem 0 0.75rem;
}
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs__sep { color: var(--text-faint); }

/* Related */
.related {
  display: grid; gap: 1px;
  grid-template-columns: 1fr;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
@media (min-width: 640px) {
  .related { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
}
.related a {
  display: block; padding: 0.85rem 1rem;
  background: var(--surface);
  text-decoration: none; color: var(--text);
  font-weight: 500;
  min-height: 44px;
  display: flex; align-items: center;
}
.related a:hover { color: var(--accent); background: var(--surface-2); }

/* Textarea for json/base64 */
.textarea-row {
  display: flex; flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  overflow: hidden;
}
.textarea-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.textarea-row textarea {
  width: 100%; min-height: 9rem;
  border: 0; outline: 0; resize: vertical;
  padding: 0.85rem 1rem;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.5;
}
.textarea-row__toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.86rem; color: var(--text-muted);
  flex-wrap: wrap; gap: 0.5rem;
}
.textarea-row__toolbar .toolbar-buttons {
  display: inline-flex; gap: 0.4rem; flex-wrap: wrap;
}
.tool-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.86rem; font-weight: 500;
  color: var(--text-muted);
  min-height: 36px;
}
.tool-btn:hover { color: var(--text); border-color: var(--border-strong); }
.tool-btn--primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
[data-theme='dark'] .tool-btn--primary { color: var(--bg); }
.tool-btn--primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
  color: #fff;
}
[data-theme='dark'] .tool-btn--primary:hover { color: var(--bg); }

/* Grid for inputs that need 2 fields side-by-side */
.grid-2 {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ─── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 2.5rem;
  margin-top: 4rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.site-footer__inner {
  display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: baseline;
  justify-content: space-between;
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  margin-right: 1rem;
}
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer__nav { display: flex; flex-wrap: wrap; }

/* ─── Utility ──────────────────────────────────────────────────────────────── */
.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;
}
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.tabular { font-variant-numeric: tabular-nums lining-nums; }

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