/* ============================================================
   Unit Converter — Production CSS
   Syne + DM Mono · Ink & Paper · Gold accents · WCAG AA
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Mono:ital,wght@0,400;0,500;1,400&display=swap");

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --ink: #0f0e0d;
  --ink-2: #3a3835;
  --ink-3: #6b6762;
  --paper: #f7f5f1;
  --paper-2: #eeeae3;
  --paper-3: #e4dfd6;
  --line: #d8d2c8;
  --white: #ffffff;

  --gold: #c8a84b;
  --gold-pale: #f5edda;
  --gold-glow: rgba(200, 168, 75, 0.18);
  --gold-stripe: linear-gradient(90deg, #c8a84b, #e8c86e, #c8a84b);

  --red: #b91c1c;
  --red-pale: #fef2f2;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --sh-card: 0 2px 1px rgba(0, 0, 0, 0.04), 0 6px 24px rgba(0, 0, 0, 0.07);
  --sh-inset: inset 0 1px 3px rgba(0, 0, 0, 0.08);
  --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.08);

  --ff-head: "Syne", sans-serif;
  --ff-mono: "DM Mono", monospace;

  --ease: cubic-bezier(0.22, 0.68, 0, 1.2);
  --t: 180ms;
}

/* ── Reset helpers ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--ff-head);
  background: var(--paper);
  color: var(--ink);
}

/* ── Container ────────────────────────────────────────────── */
.container {
  max-width: 680px;
}

/* ── Wrap ─────────────────────────────────────────────────── */
.wrap {
  padding-bottom: 48px;
}

/* ── Page title (outer section) ───────────────────────────── */
section.page-title {
  padding: 40px 16px 28px;
}

section.page-title h1 {
  font-family: var(--ff-head);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 10px;
}

section.page-title p {
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--ink-3);
  max-width: 520px;
}

section.page-title p strong {
  color: var(--ink-2);
  font-weight: 700;
}

/* ── Inner page-title (icon + h2) ─────────────────────────── */
.wrap .page-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.wrap .page-title .icon {
  width: 46px;
  height: 46px;
  background: var(--ink);
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wrap .page-title .icon svg {
  width: 22px;
  height: 22px;
  color: var(--gold);
}

.wrap .page-title h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1;
  color: var(--ink);
  margin: 0;
}

.wrap .page-title p {
  font-size: 0.8rem;
  color: var(--ink-3);
  margin: 4px 0 0;
}

/* ── Converter card ───────────────────────────────────────── */
.converter-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-card);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Gold accent stripe at the top */
.converter-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--gold-stripe);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

@media (min-width: 600px) {
  .converter-card {
    padding: 24px;
  }
}

/* ── Category pills ───────────────────────────────────────── */
.category-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.category-btn {
  appearance: none;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 15px;
  min-height: 38px;
  font-family: var(--ff-head);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition:
    background var(--t),
    border-color var(--t),
    color var(--t),
    transform var(--t) var(--ease),
    box-shadow var(--t);
}

.category-btn:hover {
  border-color: var(--ink-3);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

.category-btn:active {
  transform: translateY(0);
}

.category-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--gold);
}

.category-btn:focus-visible {
  outline: 2.5px solid var(--gold);
  outline-offset: 2px;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

/* ── Converter form ───────────────────────────────────────── */
.converter-form {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
}

@media (max-width: 480px) {
  .converter-form {
    grid-template-columns: 1fr;
  }
  .swap-col {
    display: flex;
    justify-content: center;
  }
}

/* ── Input groups ─────────────────────────────────────────── */
.input-group {
  display: grid;
  gap: 6px;
}

.input-group label {
  font-family: var(--ff-head);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--ink-3);
}

.input-group input,
.input-group select {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font-family: var(--ff-mono);
  font-size: 0.97rem;
  transition:
    border-color var(--t),
    box-shadow var(--t);
  box-shadow: var(--sh-inset);
}

.input-group input::placeholder {
  color: var(--ink-3);
}

.input-group input:focus-visible,
.input-group select:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow:
    0 0 0 3px var(--gold-glow),
    var(--sh-inset);
}

.input-group input[readonly] {
  background: var(--paper-2);
  color: var(--ink);
  cursor: default;
}

.input-group input:disabled,
.input-group select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Custom select arrow */
.input-group select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6762' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) 50%;
  cursor: pointer;
}

/* ── Swap column + button ─────────────────────────────────── */
.swap-col {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.swap-btn {
  width: 44px;
  height: 48px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background var(--t),
    border-color var(--t),
    transform var(--t) var(--ease),
    box-shadow var(--t);
  user-select: none;
}

.swap-btn svg {
  width: 18px;
  height: 18px;
  color: var(--ink-2);
  transition: transform 300ms var(--ease);
}

.swap-btn:hover {
  background: var(--gold-pale);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.swap-btn:hover svg {
  transform: rotate(180deg);
}
.swap-btn:active {
  transform: scale(0.94);
}

.swap-btn:focus-visible {
  outline: 2.5px solid var(--gold);
  outline-offset: 2px;
}

/* ── Result panel ─────────────────────────────────────────── */
.result {
  margin-top: 18px;
  background: var(--ink);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

/* Decorative glow orb */
.result::after {
  content: "";
  position: absolute;
  bottom: -24px;
  right: -24px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(200, 168, 75, 0.22),
    transparent 70%
  );
  pointer-events: none;
}

.result-label {
  font-family: var(--ff-head);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  margin-bottom: 6px;
}

#conversion-result {
  font-family: var(--ff-mono);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--white);
}

#conversion-result strong {
  color: var(--gold);
  font-weight: 500;
}

/* ── History section ──────────────────────────────────────── */
.history-section {
  margin-top: 14px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-card);
  padding: 20px;
}

@media (min-width: 600px) {
  .history-section {
    padding: 24px;
  }
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.history-header h2 {
  font-family: var(--ff-head);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0;
}

.history-count {
  font-family: var(--ff-mono);
  font-size: 0.73rem;
  color: var(--ink-3);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

/* List */
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  color: var(--ink);
  line-height: 1.4;
  border-top: 1px solid var(--line);
  font-family: var(--ff-mono);
  font-size: 0.86rem;
  transition: background var(--t);
}

.history-list li:first-child {
  border-top: 0;
}
.history-list li:hover {
  background: var(--paper-2);
}

.history-list li .meta {
  color: var(--ink-3);
  font-size: 0.73rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Empty state */
.history-list.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  border-style: dashed;
  background: transparent;
  overflow: visible;
}

.history-list.is-empty::before {
  content: "No conversions yet — results will appear here";
  display: block;
  color: var(--ink-3);
  font-family: var(--ff-head);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Clear button */
.clear-history {
  margin-top: 12px;
  width: 100%;
  min-height: 42px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-3);
  font-family: var(--ff-head);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition:
    background var(--t),
    border-color var(--t),
    color var(--t),
    transform var(--t) var(--ease);
}

.clear-history:hover {
  background: var(--red-pale);
  border-color: var(--red);
  color: var(--red);
  transform: translateY(-1px);
}

.clear-history:active {
  transform: translateY(0);
}

.clear-history:focus-visible {
  outline: 2.5px solid var(--red);
  outline-offset: 2px;
}

.clear-history:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
  .swap-btn:hover svg,
  .category-btn:hover,
  .swap-btn:hover {
    transform: none !important;
  }
}

/* related tools  */
/* related tools  */
/* related tools  */
/* related tools  */
/* related tools  */

/* ============================================================
   Converter Directory — Search + Category Grid
   Uses provided design tokens exclusively
   ============================================================ */

/* ── Search box ───────────────────────────────────────────── */
.search-box {
  margin-bottom: 32px;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.97rem;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

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

.search-box input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* ── Section headings ─────────────────────────────────────── */
.container > h2 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 28px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.container > h2:first-of-type {
  margin-top: 0;
}

/* ── Links grid ───────────────────────────────────────────── */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

@media (max-width: 480px) {
  .links-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}

/* ── Tool link cards ──────────────────────────────────────── */
.tool-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition),
    transform 160ms cubic-bezier(0.22, 0.68, 0, 1.2);
}

/* Arrow indicator */
.tool-link::after {
  content: "→";
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--muted-2);
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity var(--transition),
    transform var(--transition),
    color var(--transition);
}

.tool-link:hover {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tool-link:hover::after {
  opacity: 1;
  transform: translateX(0);
  color: var(--primary);
}

.tool-link:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.tool-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── No results message ───────────────────────────────────── */
.no-results {
  display: none;
  margin-top: 40px;
  padding: 24px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.no-results span {
  color: var(--text);
  font-weight: 700;
}

.no-results.visible {
  display: block;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tool-link,
  .tool-link::after,
  .search-box input {
    transition: none !important;
  }
  .tool-link:hover {
    transform: none !important;
  }
}

.seo-content {
  padding: 5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  margin: 5rem 0;
}

.seo-content h2 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.2px;
  color: var(--text);
}

.seo-content h3 {
  margin: 18px 0 10px;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -0.15px;
  color: var(--text);
}

.seo-content p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.seo-content strong {
  color: var(--text);
  font-weight: 800;
}

/* Steps */
.seo-steps {
  margin: 10px 0 0 18px;
  padding: 0;
  color: var(--muted);
}

.seo-steps li {
  margin: 8px 0;
  padding-left: 2px;
}

.seo-steps li strong {
  color: var(--text);
}

/* Grid of cards */
.seo-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.seo-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px;
}

.seo-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--text);
}

.seo-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
}

.seo-card ul {
  margin: 10px 0 0 18px;
  padding: 0;
  color: var(--muted);
}

.seo-card li {
  margin: 6px 0;
}

/* Highlight note */
.seo-note {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--highlight-bg);
  border: 1px solid var(--highlight-border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

/* Table */
.table-wrap {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.table-wrap:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
}

.seo-table th,
.seo-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.seo-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.seo-table tbody td {
  color: var(--text);
  font-size: 14.5px;
  font-weight: 650;
}

.seo-table tbody tr:hover td {
  background: var(--primary-soft);
}
