/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --bg:           #F5F4F0;
  --surface:      #FFFFFF;
  --border:       #D4D0C8;
  --text:         #1A1A18;
  --text-muted:   #6B6860;
  --accent:       #C8440A;
  --accent-hover: #A33508;
  --font-display: 'Ovo', Georgia, serif;
  --font-body:    'Mulish', system-ui, sans-serif;
  --font-mono:    'Victor Mono', 'Courier New', monospace;
  --radius:       2px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08);
}

/* ============================================================
   Base Reset
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* Monospace for formulae and inline code */
strong, code, .formula {
  font-family: var(--font-mono);
  font-weight: 500;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   Global Typography (applies to all pages)
   ============================================================ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: 2.25rem; margin-bottom: 8px; }
h2 { font-size: 1.5rem; margin-bottom: 16px; }
h3 { font-size: 1.15rem; margin-bottom: 12px; }

p { line-height: 1.7; }

/* ============================================================
   Navigation
   ============================================================ */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-nav__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 52px;
}

.site-nav__logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}

.site-nav__logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
}

.site-nav__links::-webkit-scrollbar {
  display: none;
}

.site-nav__links a {
  font-family: var(--font-body);
  font-size: 0.825rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.site-nav__links a:hover {
  color: var(--accent);
  background: rgba(200, 68, 10, 0.06);
  text-decoration: none;
}

.site-nav__links a.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

/* Nav: category/pair page markup (no inner wrapper) */
.site-nav > .nav-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  padding: 0 32px;
}

.site-nav > .nav-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav > .nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  padding: 0 32px 0 0;
}

.site-nav > .nav-links::-webkit-scrollbar { display: none; }

.site-nav > .nav-links a {
  font-family: var(--font-body);
  font-size: 0.825rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.site-nav > .nav-links a:hover {
  color: var(--accent);
  background: rgba(200, 68, 10, 0.06);
  text-decoration: none;
}

.site-nav > .nav-links a.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

/* Make .site-nav itself flex so the direct-child nav works */
.site-nav {
  display: flex;
  align-items: center;
  height: 52px;
}

/* ============================================================
   Main Layout
   ============================================================ */
.site-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px;
  width: 100%;
}

.layout-with-sidebar {
  display: flex;
  flex-direction: row;
  gap: 32px;
  align-items: flex-start;
}

.layout-with-sidebar .main-content {
  flex: 1;
  min-width: 0;
}

.layout-with-sidebar .sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Category/pair pages use .page-layout instead of .site-main */
.page-layout {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px;
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 32px;
  align-items: flex-start;
}

.page-layout > main {
  flex: 1;
  min-width: 0;
}

.page-layout > aside {
  width: 320px;
  flex-shrink: 0;
}

.page-layout .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 6px;
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================================
   Converter Card
   ============================================================ */
.converter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

/* ============================================================
   Converter Inputs
   ============================================================ */
.converter-inputs {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 24px;
}

.input-group {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Number inputs */
input[type="number"] {
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"]:focus {
  border-color: var(--accent);
  background: var(--surface);
}

/* Selects */
select {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 32px 8px 10px;
  width: 100%;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6860' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}

select:focus {
  border-color: var(--accent);
}

select:hover {
  border-color: var(--text-muted);
}

/* Swap button */
.swap-area {
  display: flex;
  align-items: flex-end;
  padding-bottom: 10px;
  flex-shrink: 0;
}

#btn-swap {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}

#btn-swap:hover {
  background: var(--accent-hover);
  transform: rotate(180deg);
}

#btn-swap:active {
  transform: rotate(180deg) scale(0.92);
}

/* ============================================================
   Result Display
   ============================================================ */
.result-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  min-height: 64px;
}

#result-display {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  flex: 1;
}

.input-row {
  display: flex;
  align-items: stretch;
}

.input-row input[type="number"] {
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
  flex: 1;
  min-width: 0;
}

.btn-copy {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0 12px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-copy:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(200, 68, 10, 0.04);
}

.btn-copy.copied {
  color: var(--accent);
}

/* ============================================================
   Recent Conversions
   ============================================================ */
#recent-list {
  margin-top: 24px;
}

.recent-heading {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.recent-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recent-items li {
  font-size: 0.875rem;
}

.recent-items a {
  color: var(--text-muted);
  text-decoration: none;
}

.recent-items a:hover {
  color: var(--accent);
}

/* ============================================================
   Ad Zones
   ============================================================ */
.ad-leaderboard {
  width: 728px;
  height: 90px;
  max-width: 100%;
  background: var(--border);
  margin: 16px auto;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-body);
}

.ad-sidebar {
  width: 300px;
  height: 250px;
  background: var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-body);
}

.ad-rectangle {
  width: 336px;
  height: 280px;
  max-width: 100%;
  background: var(--border);
  margin: 24px auto;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-body);
}

/* ============================================================
   Reference Section
   ============================================================ */
.reference-section {
  margin-top: 40px;
}

.reference-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.reference-section p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
  line-height: 1.7;
}

/* ============================================================
   Quick Reference Tables
   ============================================================ */
.quick-ref {
  margin-top: 32px;
}

.quick-ref h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 24px;
}

thead {
  background: var(--bg);
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(0,0,0,0.015);
}

/* ============================================================
   FAQ Section
   ============================================================ */
.faq-section {
  margin-top: 40px;
}

.faq-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 16px;
}

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
  overflow: hidden;
}

details[open] {
  border-color: var(--accent);
}

summary {
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '+';
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 400;
  flex-shrink: 0;
  margin-left: 12px;
}

details[open] summary::after {
  content: '−';
}

details p, details div {
  padding: 0 16px 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ============================================================
   Related Links
   ============================================================ */
.related-links {
  margin-top: 32px;
}

.related-links h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 12px;
}

.related-links ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.related-links li a {
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
}

.related-links li a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  margin-top: auto;
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* ============================================================
   Home Page: Category Grid
   ============================================================ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 32px 0;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  display: block;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow);
}

.category-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(200, 68, 10, 0.12);
  transform: translateY(-2px);
  text-decoration: none;
}

.category-card__icon {
  font-size: 2rem;
  margin-bottom: 10px;
  display: block;
}

.category-card__name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.category-card__examples {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.category-card__examples li a {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
}

.category-card__examples li a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ============================================================
   All Conversions Section (Homepage)
   ============================================================ */
.all-conversions {
  margin: 48px 0 0;
}

.all-conversions > h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 32px;
  color: var(--text);
}

.conversion-group {
  margin-bottom: 40px;
}

.conversion-group h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.conversion-group h3 a {
  color: var(--text);
  text-decoration: none;
}

.conversion-group h3 a:hover {
  color: var(--accent);
}

.conversion-group ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.conversion-group ul li a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.conversion-group ul li a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ============================================================
   Home Intro
   ============================================================ */
.home-intro {
  max-width: 720px;
  margin: 0 auto 32px;
  text-align: center;
}

.home-intro p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.75;
}

/* ============================================================
   Sidebar Card
   ============================================================ */
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.sidebar-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
}

.sidebar-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-card ul li a {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

.sidebar-card ul li a:hover {
  color: var(--accent);
}

/* ============================================================
   Responsive: Tablet and Mobile (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .layout-with-sidebar,
  .page-layout {
    flex-direction: column;
  }

  .layout-with-sidebar .sidebar,
  .page-layout > aside {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .ad-sidebar {
    width: 100%;
    height: 90px;
  }
}

/* ============================================================
   Responsive: Mobile (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
  .site-main,
  .page-layout {
    padding: 24px 20px;
  }

  .site-nav__inner {
    padding: 0 20px;
  }

  .site-nav > .nav-logo {
    padding: 0 20px;
  }

  .site-nav > .nav-links {
    padding: 0 20px 0 0;
  }

  h1 { font-size: 1.6rem; }

  .page-header h1 {
    font-size: 1.6rem;
  }

  .converter-card {
    padding: 16px;
  }

  .converter-inputs {
    flex-direction: column;
    gap: 16px;
  }

  .swap-area {
    align-self: center;
    padding-bottom: 0;
    transform: rotate(90deg);
  }

  input[type="number"] {
    font-size: 1.5rem;
  }

  #result-display {
    font-size: 1.2rem;
  }

  .ad-leaderboard {
    width: 320px;
    height: 50px;
  }

  .ad-sidebar {
    width: 100%;
    height: 50px;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .category-card {
    padding: 14px;
  }

  .category-card__icon {
    font-size: 1.5rem;
  }

  .category-card__name {
    font-size: 1rem;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 8px 8px;
  }
}

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