/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  /* Sand/beige palette — locked in as the site's permanent theme.
     Contrast-checked at 4.5:1+ AA for all text/background pairs. */
  --paper: #f2ead9;
  --paper-alt: #e8dcc3;
  --ink: #2c2417;
  --ink-soft: #4a3f2f;
  --ink-faint: #6b5c46;
  --brass: #b8863b;
  --brass-dark: #8f6423;
  --verdigris: #3f6b62;
  --line: #ddd0b4;
  --line-strong: #2c2417;
  --white: #faf6ec;
  --rust: #9c3b2e;

  --font-display: "Libre Caslon Display", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 2px;
  --max-width: 960px;
}

/* Former grey/paper palette, kept here for reference only — not applied.
   --paper: #eef1ef; --paper-alt: #e2e7e3; --ink: #16283d;
   --ink-soft: #3e5164; --ink-faint: #5f7078; --verdigris: #4b7a70;
   --line: #c9cfc9; --line-strong: #16283d; --white: #fbfbf9;
*/

/* ==========================================================================
   Reset & base
   ========================================================================== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  margin: 0;
}

a {
  color: var(--verdigris);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--brass-dark);
}

button, select, input {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-dark);
}

/* ==========================================================================
   Signature element: the ruler rule
   Used as a structural divider throughout — tall ticks every 40px,
   fine ticks every 8px, like the edge of a measuring rule.
   ========================================================================== */
.ruler {
  height: 18px;
  background:
    repeating-linear-gradient(
      to right,
      var(--ink) 0,
      var(--ink) 1px,
      transparent 1px,
      transparent 40px
    )
    bottom / 100% 14px no-repeat,
    repeating-linear-gradient(
      to right,
      var(--line) 0,
      var(--line) 1px,
      transparent 1px,
      transparent 8px
    )
    bottom / 100% 7px no-repeat;
  border-bottom: 1px solid var(--ink);
}

.ruler--tight {
  height: 12px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  background: var(--white);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  max-width: var(--max-width);
  margin: 0 auto;
  gap: 16px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

.wordmark:hover {
  color: var(--ink);
}

.wordmark span {
  color: var(--brass-dark);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 2px;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--brass-dark);
  border-bottom-color: var(--brass);
}

.site-nav .is-muted {
  color: var(--ink-faint);
  cursor: default;
}

.site-nav .is-muted:hover {
  color: var(--ink-faint);
  border-bottom-color: transparent;
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding: 56px 0 40px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.15;
  margin: 14px 0 16px;
  max-width: 16ch;
}

.hero p {
  color: var(--ink-soft);
  max-width: 46ch;
  font-size: 1.05rem;
}

.breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.breadcrumb a {
  color: var(--ink-faint);
}

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

/* ==========================================================================
   Quick converter (homepage)
   ========================================================================== */
.quick-convert {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.quick-convert__footnote {
  margin: 0 0 32px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.quick-convert__arrow {
  font-family: var(--font-mono);
  color: var(--brass);
  padding-bottom: 12px;
  font-size: 1.1rem;
}

@media (max-width: 640px) {
  .quick-convert {
    grid-template-columns: 1fr;
  }
  .quick-convert__arrow {
    display: none;
  }
}

/* ==========================================================================
   Category grid
   ========================================================================== */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 0 20px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 56px;
}

.category-card {
  background: var(--white);
  padding: 22px 20px;
  text-decoration: none;
  color: inherit;
  position: relative;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background 0.15s ease;
}

.category-card:hover {
  background: var(--paper-alt);
}

.category-card--soon {
  color: var(--ink-faint);
  cursor: default;
}

.category-card--soon:hover {
  background: var(--white);
}

.category-card h3 {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 6px;
}

.category-card--soon h3 {
  color: var(--ink-faint);
}

.category-card .examples {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.category-card .tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 14px;
}

.category-card .tag--live {
  color: var(--verdigris);
}

.category-card .tag--soon {
  color: var(--ink-faint);
}

@media (max-width: 720px) {
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* ==========================================================================
   Full converter card (converter pages)
   ========================================================================== */
.converter {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 32px;
  margin: 32px 0 40px;
}

.converter__row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: end;
}

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

.field input[type="number"],
.field select {
  width: 100%;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}

.field input[type="number"] {
  font-family: var(--font-mono);
  font-size: 1.25rem;
}

.field select {
  font-family: var(--font-body);
  font-size: 1rem;
}

.field input:focus,
.field select:focus {
  border-color: var(--brass);
}

.field--output input {
  color: var(--ink);
  font-weight: 500;
  background: var(--paper-alt);
}

.output-row {
  display: flex;
  gap: 8px;
}

.output-row input {
  flex: 1;
  min-width: 0;
}

.result-secondary {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 6px;
  min-height: 1.1em;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.copy-btn:hover {
  border-color: var(--brass);
  color: var(--brass-dark);
}

.copy-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  flex-shrink: 0;
}

.copy-btn .icon-check {
  display: none;
}

.copy-btn.is-copied {
  border-color: var(--verdigris);
  color: var(--verdigris);
}

.copy-btn.is-copied .icon-copy {
  display: none;
}

.copy-btn.is-copied .icon-check {
  display: inline-block;
}

.copy-btn--inline {
  padding: 4px 10px;
  min-height: 0;
}

/* ==========================================================================
   Roman numeral converter — bidirectional field pair, since both sides
   are directly editable (unlike every other converter, where "from" and
   "to" have fixed roles).
   ========================================================================== */
.field-note {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 6px;
  min-height: 1.1em;
}

.field-note--error {
  color: var(--rust);
}

.field-note code {
  font-family: var(--font-mono);
  background: var(--paper-alt);
  padding: 1px 5px;
  border-radius: var(--radius);
  color: var(--brass-dark);
  font-size: 0.95em;
}

.field--bidirectional input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field--bidirectional input[type="text"]:focus {
  border-color: var(--brass);
}

.field--bidirectional .output-row input[type="text"] {
  text-transform: uppercase;
}

@media (max-width: 380px) {
  .copy-btn .copy-label {
    display: none;
  }
}

/* Swap button: caliper-inspired toggle */
.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
  margin-bottom: 2px;
  justify-self: center;
  transition: transform 0.2s ease, border-color 0.15s ease;
}

.swap-btn:hover {
  border-color: var(--brass);
}

.swap-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--brass-dark);
}

.swap-btn.is-swapping {
  transform: rotate(180deg);
}

@media (max-width: 640px) {
  .swap-btn {
    transform: rotate(90deg);
    justify-self: start;
  }
  .swap-btn.is-swapping {
    transform: rotate(270deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .swap-btn,
  .category-card,
  html {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Quick-select pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 40px;
}

.pill {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 11px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-soft);
}

.pill:hover {
  border-color: var(--brass);
  color: var(--brass-dark);
}

/* ==========================================================================
   Reference table
   ========================================================================== */
.ref-table-wrap {
  margin-bottom: 56px;
}

.ref-table-wrap h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.ref-table-wrap .sub {
  color: var(--ink-faint);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

table.ref-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--line);
}

table.ref-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 400;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-strong);
}

table.ref-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

table.ref-table tr:nth-child(even) td {
  background: var(--paper-alt);
}

table.ref-table td.unit-name {
  font-family: var(--font-body);
  color: var(--ink-soft);
}

/* ==========================================================================
   Ad slots
   Reserved, fixed-height placeholders so a real ad unit can be dropped in
   later without causing layout shift (bad for users and for AdSense/SEO
   performance alike). Replace the placeholder <div> contents with the
   real AdSense <ins> snippet once the account is approved.
   ========================================================================== */
.ad-slot {
  width: 100%;
  min-height: 100px;
  margin: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--paper-alt);
}

@media (min-width: 768px) {
  .ad-slot--incontent {
    min-height: 250px;
  }
}

/* ==========================================================================
   Info blocks — explanatory article content sitting alongside converters
   ========================================================================== */
.info-block {
  border-left: 3px solid var(--brass);
  padding: 4px 0 4px 24px;
  margin: 40px 0;
}

.info-block h2 {
  font-size: 1.4rem;
  margin-bottom: 14px;
}

.info-block p {
  color: var(--ink-soft);
  max-width: 68ch;
  margin: 0 0 14px;
}

.info-block p:last-child {
  margin-bottom: 0;
}

.info-block .quick-fact {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--paper-alt);
  padding: 14px 18px;
  margin: 18px 0;
  color: var(--ink);
  max-width: 68ch;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 56px 0 0;
}

.panel-heading h2 {
  font-size: 1.5rem;
}

.panel-heading .sub {
  color: var(--ink-faint);
  font-size: 0.92rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  margin-top: 40px;
}

.site-footer p {
  color: var(--ink-faint);
  font-size: 0.85rem;
  max-width: 60ch;
}

.site-footer .in-progress {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--verdigris);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Desktop tightening pass
   Reduces breathing room in boxes, tables, and section spacing on wider
   screens only. Deliberately does NOT touch: .pill, .copy-btn, .site-nav a,
   or .field select/input font-size — those sizes were set to meet 44px
   minimum touch targets and 16px inputs (prevents iOS auto-zoom), and
   apply on every screen size regardless of width.
   ========================================================================== */
@media (min-width: 900px) {
  .container {
    padding: 0 20px;
  }

  .site-header__bar {
    padding: 14px 20px 12px;
  }

  .ruler {
    height: 14px;
  }

  .hero {
    padding: 24px 0 18px;
  }

  .hero h1 {
    margin: 8px 0 10px;
  }

  .hero p {
    font-size: 0.98rem;
  }

  .quick-convert {
    padding: 14px 18px;
    margin-bottom: 10px;
  }

  .section-label {
    margin: 0 0 12px;
  }

  .category-grid {
    margin-bottom: 28px;
  }

  .category-card {
    padding: 12px 16px;
    min-height: 78px;
  }

  .category-card .tag {
    margin-top: 8px;
  }

  .converter {
    padding: 16px 20px;
    margin: 16px 0 20px;
  }

  .converter__row {
    gap: 14px;
  }

  .field input[type="number"] {
    padding: 7px 10px;
    font-size: 1.1rem;
  }

  .field--bidirectional input[type="text"] {
    padding: 7px 10px;
    font-size: 1.1rem;
  }

  .field select {
    padding: 7px 10px;
  }

  .field label {
    margin-bottom: 4px;
  }

  .pills {
    margin: 10px 0 20px;
    gap: 6px;
  }

  .ref-table-wrap {
    margin-bottom: 24px;
  }

  .ref-table-wrap h2 {
    margin-bottom: 2px;
  }

  .ref-table-wrap .sub {
    margin-bottom: 10px;
  }

  table.ref-table th {
    padding: 6px 14px;
  }

  table.ref-table td {
    padding: 6px 14px;
  }

  .ad-slot {
    margin: 18px 0;
    min-height: 90px;
  }

  /* min-height for .ad-slot--incontent intentionally NOT reduced further
     here — it's set to 250px at 768px+ (see the .ad-slot--incontent rule
     above) to match a standard IAB medium-rectangle ad unit. Shrinking
     it just for visual density would undercut the whole reason these
     placeholders exist: matching a real ad's footprint in advance so
     nothing shifts when live ad code drops in later. */

  .info-block {
    margin: 18px 0;
    padding: 2px 0 2px 18px;
  }

  .info-block h2 {
    margin-bottom: 8px;
  }

  .info-block p {
    margin: 0 0 10px;
  }

  .info-block .quick-fact {
    padding: 10px 14px;
    margin: 12px 0;
  }

  .panel-heading {
    margin: 24px 0 0;
  }

  .site-footer {
    padding: 14px 0 22px;
    margin-top: 16px;
  }
}
