/* ============================================================
   CalculatorXP — Shared Stylesheet
   Clean black & white, WCAG 2.1 AA accessible
   ============================================================ */

/* ── GOOGLE FONTS ── */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Nunito:wght@300;400;500;600;700&display=swap');

/* ── CSS VARIABLES ── */
:root {
  --white:       #faf8f5;          /* warm off-white background */
  --white-pure:  #ffffff;          /* pure white for cards/inputs */
  --black:       #1c1917;          /* warm near-black, easier to read */
  --grey-50:     #f5f2ee;
  --grey-100:    #ede9e4;
  --grey-200:    #ddd8d1;
  --grey-300:    #c5bfb7;
  --grey-400:    #a09890;
  --grey-500:    #78716c;
  --grey-600:    #57534e;
  --grey-700:    #44403c;
  --grey-800:    #292524;
  --grey-900:    #1c1917;

  --accent:      #1c1917;
  --accent-hover:#292524;
  --focus:       #0066cc;
  --error:       #b91c1c;
  --success:     #15803d;

  --font-mono:   'Space Mono', 'Courier New', monospace;
  --font-body:   'Nunito', 'Helvetica Neue', sans-serif;

  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06);
  --shadow:      0 2px 10px rgba(0,0,0,0.08);
  --shadow-lg:   0 4px 24px rgba(0,0,0,0.10);

  --header-h:    64px;
  --sidebar-w:   240px;
  --max-w:       1200px;

  --transition:  0.15s ease;
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;   /* prevents page-level horizontal scroll */
}

body {
  background: var(--white);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--black); }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); font-size: 1rem; }

/* ── GLOBAL BOX SIZING ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ── SKIP TO CONTENT ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--black);
  color: var(--white);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 16px;
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ── FOCUS STYLES ── */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ── HEADER ── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 56px;
  background: var(--white-pure);
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
  width: 100%;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--black);
  flex-shrink: 0;
}
.header-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--black);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.header-logo-mark svg { color: var(--white); width: 18px; height: 18px; }
.header-logo-text {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-nav {
  display: none; /* hidden on mobile — shown on desktop via min-width query */
  gap: 2px;
  flex: 1;
}
.header-nav a {
  text-decoration: none;
  color: var(--grey-600);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.header-nav a:hover { color: var(--black); background: var(--grey-100); }
.header-nav a.active { color: var(--black); font-weight: 700; }

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 36px;
  width: 100%;
  max-width: 200px;
  margin-left: auto;
  background: var(--white-pure);
  transition: border-color var(--transition);
  box-sizing: border-box;
  flex-shrink: 1;
}
.header-search:focus-within {
  border-color: var(--black);
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.header-search svg { color: var(--grey-400); flex-shrink: 0; width: 16px; height: 16px; }
.header-search input {
  border: none;
  outline: none;
  background: none;
  color: var(--black);
  font-size: 0.875rem;
  width: 100%;
}
.header-search input::placeholder { color: var(--grey-400); }

/* ── PAGE LAYOUT ── */
.page-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  gap: 0;
  box-sizing: border-box;
  /* overflow not set — children must not exceed 100% width */
}

/* ── SIDEBAR ── */
#site-sidebar {
  display: none; /* hidden on mobile/tablet — shown on desktop */
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 28px 0;
  border-right: 1px solid var(--grey-200);
}

.sidebar-section { margin-bottom: 28px; }

.sidebar-section-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-400);
  padding: 0 12px 8px;
  font-family: var(--font-mono);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--grey-600);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
  margin-bottom: 1px;
}
.sidebar-link:hover { color: var(--black); background: var(--grey-100); }
.sidebar-link.active {
  color: var(--black);
  font-weight: 600;
  background: var(--grey-100);
  border-left-color: var(--black);
}
.sidebar-link .icon { font-size: 0.875rem; width: 16px; text-align: center; }

/* ── MAIN CONTENT ── */
#main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 20px 0 32px;
  box-sizing: border-box;
}

/* ── AD SLOTS ── */
.ad-slot {
  background: transparent;
  border: none;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  max-width: 100%;
  box-sizing: border-box;
}
.ad-slot::before { content: ''; display: none; }
/* Uncomment below to show placeholder boxes during development:
.ad-slot { background: var(--grey-50); border: 1.5px dashed var(--grey-300); color: var(--grey-400); }
.ad-slot::before { content: attr(data-label); display: flex; } */
.ad-leaderboard {
  width: 100%;
  min-height: 0;
  height: auto;
  margin-bottom: 0;
}
.ad-rectangle {
  width: 100%;
  max-width: 300px;
  min-height: 0;
  height: auto;
  margin: 0 auto 0;
}
.ad-incontent {
  width: 100%;
  min-height: 0;
  height: auto;
  margin: 0;
}
/* When AdSense is active, restore dimensions:
.ad-leaderboard { height: 90px; margin-bottom: 28px; }
.ad-rectangle   { height: 250px; margin: 0 auto 24px; }
.ad-incontent   { height: 90px; margin: 32px 0; }
*/


/* ── No-sidebar page content wrapper ── */
.ns-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  width: 100%;
  box-sizing: border-box;
}
@media(min-width:640px)  { .ns-wrap { padding: 28px 24px 48px; } }
@media(min-width:1024px) { .ns-wrap { padding: 32px 32px 64px; } }

/* ── BREADCRUMB ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--grey-200);
}
.breadcrumb a {
  color: var(--grey-500);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color var(--transition);
}
.breadcrumb a:hover { color: var(--black); text-decoration: underline; }
.breadcrumb-sep {
  color: var(--grey-300);
  font-size: 0.8rem;
  user-select: none;
}
.breadcrumb-current {
  color: var(--black);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── PAGE TITLE ── */
.page-title {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin-bottom: 6px;
}
.page-subtitle {
  color: var(--grey-500);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ── CALCULATOR CARD ── */
.calc-card {
  background: var(--white-pure);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  width: 100%;
  box-sizing: border-box;
}
.calc-card-header {
  background: var(--grey-900);
  color: var(--white-pure);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.calc-card-title {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.calc-card-body {
  padding: 16px;
  box-sizing: border-box;
  width: 100%;
}

/* ── FORM ELEMENTS ── */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--black);
}
.form-group .hint {
  font-size: 0.78rem;
  color: var(--grey-500);
  margin-top: 4px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.input-prefix,
.input-suffix {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--grey-500);
  pointer-events: none;
  font-weight: 600;
}
.input-prefix { left: 12px; }
.input-suffix { right: 12px; }
.input-wrap input.has-prefix { padding-left: 28px; }
.input-wrap input.has-suffix { padding-right: 28px; }

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  background: var(--white-pure);
  color: var(--black);
  font-size: 1rem;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--grey-500); }
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--black);
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--error);
}

select {
  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='%23525252' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── TOGGLE UNIT SWITCH ── */
.unit-toggle {
  display: inline-flex;
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.unit-toggle button {
  background: var(--white);
  border: none;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--grey-500);
  transition: background var(--transition), color var(--transition);
  border-right: 1px solid var(--grey-300);
  letter-spacing: 0.02em;
}
.unit-toggle button:last-child { border-right: none; }
.unit-toggle button.active {
  background: var(--black);
  color: var(--white);
}
.unit-toggle button:hover:not(.active) {
  background: var(--grey-100);
  color: var(--black);
}

/* ── CURRENCY SELECTOR ── */
.currency-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.currency-selector label {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}
.currency-selector select {
  width: auto;
  min-width: 140px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 0.05s;
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.btn-primary:hover { background: var(--grey-800); border-color: var(--grey-800); }

.btn-secondary {
  background: var(--white);
  color: var(--black);
  border-color: var(--grey-300);
}
.btn-secondary:hover { border-color: var(--black); background: var(--grey-50); }

.btn-ghost {
  background: none;
  color: var(--grey-600);
  border-color: transparent;
  padding: 8px 14px;
  font-size: 0.8rem;
}
.btn-ghost:hover { color: var(--black); background: var(--grey-100); }

.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* ── RESULT DISPLAY ── */
.result-box {
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin: 20px 0;
}
.result-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-500);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.result-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -1px;
  line-height: 1.1;
  word-break: break-all;
}
.result-value.large { font-size: 2.5rem; }
.result-sub {
  font-size: 0.85rem;
  color: var(--grey-500);
  margin-top: 4px;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr; /* single col on mobile */
  gap: 12px;
  margin: 20px 0;
}
.result-item {
  background: var(--white);
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.result-item .result-label { font-size: 0.72rem; }
.result-item .result-value { font-size: 1.3rem; }

/* ── DISCLAIMER ── */
.disclaimer {
  background: var(--grey-50);
  border-left: 3px solid var(--grey-400);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 20px 0;
  font-size: 0.8rem;
  color: var(--grey-600);
  line-height: 1.5;
}
.disclaimer strong { color: var(--black); }

/* ── EXPLANATION SECTION ── */
.explanation {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--grey-200);
}
.explanation h2 {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}
.explanation h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 20px 0 8px;
}
.explanation p {
  font-size: 0.9rem;
  color: var(--grey-700);
  line-height: 1.7;
  margin-bottom: 12px;
}
.explanation ul, .explanation ol {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 12px;
}
.explanation li {
  font-size: 0.9rem;
  color: var(--grey-700);
  margin-bottom: 4px;
}
.formula-box {
  background: var(--grey-900);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 12px 0;
  overflow-x: auto;
  white-space: pre;
}

/* ── RELATED CALCULATORS ── */
.related-section {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--grey-200);
}
.related-section h2 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-500);
  margin-bottom: 16px;
}
.related-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 2 cols on mobile */
  gap: 8px;
}
.related-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--black);
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.related-card:hover {
  border-color: var(--black);
  background: var(--grey-50);
  transform: translateY(-1px);
}
.related-card .icon { font-size: 1.1rem; }

/* ── INFO CARDS ── */
.info-card {
  background: var(--grey-50);
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.info-card h3 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey-500);
  margin-bottom: 10px;
}
.info-card p { font-size: 0.85rem; color: var(--grey-700); line-height: 1.6; }

/* ── CATEGORY CARDS (homepage) ── */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 2 cols on mobile */
  gap: 10px;
  margin-top: 16px;
}
.category-card {
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-xl);
  padding: 20px 18px;
  text-decoration: none;
  color: var(--black);
  transition: border-color var(--transition), box-shadow var(--transition), transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.category-card:hover {
  border-color: var(--black);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.category-card .cat-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grey-100);
  border-radius: var(--radius);
}
.category-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
}
.category-card p {
  font-size: 0.78rem;
  color: var(--grey-500);
  line-height: 1.4;
}
.category-card .count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--grey-400);
  margin-top: auto;
}

/* ── BASIC CALCULATOR (homepage) ── */
.basic-calc {
  background: var(--white-pure);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  width: 100%;
  max-width: 100%; /* full width on mobile */
  box-shadow: var(--shadow-lg);
}
.basic-calc-display {
  background: var(--grey-900);
  padding: 24px 24px 20px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
}
.basic-calc-expr {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--grey-400);
  min-height: 20px;
  text-align: right;
  word-break: break-all;
}
.basic-calc-result {
  font-family: var(--font-mono);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--white-pure);
  text-align: right;
  word-break: break-all;
  line-height: 1.1;
  transition: font-size 0.1s;
}
.basic-calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--grey-200);
}
.calc-btn {
  background: var(--white-pure);
  border: none;
  color: var(--black);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  cursor: pointer;
  user-select: none;
}
.calc-btn:hover { background: var(--grey-50); }
.calc-btn:active { background: var(--grey-100); transform: scale(0.96); }
.calc-btn.op { color: var(--grey-500); font-size: 1.3rem; }
.calc-btn.ac { background: var(--grey-100); font-size: 0.9rem; color: var(--grey-700); }
.calc-btn.fn { font-size: 0.9rem; color: var(--grey-600); background: var(--grey-50); }
.calc-btn.eq {
  background: var(--black);
  color: var(--white-pure);
  grid-row: span 2;
  font-size: 1.4rem;
}
.calc-btn.eq:hover { background: var(--grey-800); }
.calc-btn.zero { grid-column: span 2; justify-content: flex-start; padding-left: 28px; }

/* ── FOOTER ── */
#site-footer {
  background: var(--grey-900);
  color: var(--grey-400);
  margin-top: auto;
  padding: 32px 16px 20px;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.footer-top {
  display: grid;
  grid-template-columns: 1fr; /* single col on mobile */
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--grey-700);
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.footer-brand-mark {
  width: 30px;
  height: 30px;
  background: var(--white);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}
.footer-brand-mark svg { width: 16px; height: 16px; }
.footer-brand-name {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}
.footer-tagline {
  font-size: 0.82rem;
  color: var(--grey-500);
  line-height: 1.5;
  max-width: 280px;
}
.footer-links-group { display: flex; gap: 32px; flex-wrap: wrap; }
.footer-col h4 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-300);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}
.footer-col a {
  display: block;
  color: var(--grey-500);
  text-decoration: none;
  font-size: 0.82rem;
  margin-bottom: 8px;
  transition: color var(--transition);
}
.footer-col a:hover { color: var(--white); }
.footer-bottom {
  display: flex;
  flex-direction: column; /* stack on mobile */
  align-items: flex-start;
  gap: 10px;
}
.footer-bottom p { font-size: 0.78rem; color: var(--grey-600); }
.footer-legal {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-legal a {
  color: var(--grey-500);
  text-decoration: none;
  font-size: 0.78rem;
  transition: color var(--transition);
}
.footer-legal a:hover { color: var(--white); }
#manage-cookies-btn {
  background: none;
  border: none;
  color: var(--grey-500);
  font-size: 0.78rem;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
  text-decoration: underline;
}
#manage-cookies-btn:hover { color: var(--white); }

/* ── COOKIE BANNER ── */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 2px solid var(--black);
  padding: 20px 24px;
  z-index: 1000;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  display: none;
}
#cookie-banner.visible { display: block; }
.cookie-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.cookie-text {
  font-size: 0.875rem;
  color: var(--grey-700);
  margin-bottom: 16px;
  line-height: 1.6;
}
.cookie-text a { color: var(--black); font-weight: 600; }
.cookie-toggles {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.cookie-toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--grey-700);
}
.cookie-toggle-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--black);
  cursor: pointer;
}
.cookie-toggle-item span.required {
  font-size: 0.72rem;
  color: var(--grey-400);
  margin-left: 4px;
}
.cookie-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── ARIA LIVE REGION ── */
.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;
}
/* screen reader only */

/* ── HAMBURGER BUTTON ── */
.nav-burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.nav-burger:hover { background: var(--grey-100); }
.burger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--black);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── MOBILE NAV OVERLAY ── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.nav-overlay.open {
  display: block;
  opacity: 1;
}

/* ── MOBILE NAV DRAWER ── */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 80%;
  max-width: 320px;
  background: var(--white-pure);
  z-index: 400;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.mobile-nav-drawer.open {
  transform: translateX(0);
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-200);
  position: sticky;
  top: 0;
  background: var(--white-pure);
  z-index: 1;
}
.drawer-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
}
.drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--black);
  transition: background var(--transition);
}
.drawer-close:hover { background: var(--grey-100); }
.drawer-body {
  padding: 16px 0 32px;
}
.drawer-section {
  margin-bottom: 8px;
}
.drawer-category {
  display: block;
  padding: 10px 20px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-500);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: color var(--transition);
}
.drawer-category:hover,
.drawer-category.active { color: var(--black); }
.drawer-links {
  display: flex;
  flex-direction: column;
}
.drawer-link {
  display: block;
  padding: 9px 20px 9px 28px;
  font-size: 0.875rem;
  color: var(--grey-600);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.drawer-link:hover {
  color: var(--black);
  background: var(--grey-50);
  border-left-color: var(--black);
}
.drawer-more {
  color: var(--grey-400);
  font-size: 0.8rem;
  margin-top: 2px;
}

/* ============================================================
   RESPONSIVE — MOBILE FIRST
   Base styles above = mobile (< 640px)
   Tablet  = min-width: 640px
   Desktop = min-width: 1024px
   ============================================================ */

/* ── TABLET (640px+) ── */
@media (min-width: 640px) {

  #site-header {
    height: var(--header-h);
    padding: 0 24px;
    gap: 16px;
  }

  .header-search {
    max-width: 240px;
  }

  .page-wrapper {
    padding: 0 24px;
  }

  #main-content {
    padding: 28px 0 40px;
  }

  .page-title { font-size: 1.6rem; }

  /* 3-col category grid on tablet */
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  /* 3-col related grid on tablet */
  .related-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  /* 2-col results on tablet */
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Basic calc: cap width on tablet */
  .basic-calc {
    max-width: 380px;
  }

  /* Footer: 2-col on tablet */
  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

}

/* ── DESKTOP (1024px+) ── */
@media (min-width: 1024px) {

  #site-header {
    padding: 0 32px;
    gap: 24px;
  }

  /* Show nav on desktop */
  .header-nav {
    display: flex;
  }

  /* Hide hamburger on desktop */
  .nav-burger {
    display: none;
  }

  .header-search {
    max-width: 260px;
  }

  .page-wrapper {
    padding: 0 32px;
    gap: 32px;
  }

  /* Show sidebar on desktop */
  #site-sidebar {
    display: block;
  }

  /* No-sidebar pages (homepage, search, about etc) */
  body.no-sidebar #site-sidebar {
    display: none !important;
  }
  body.no-sidebar .page-wrapper {
    gap: 0;
  }
  body.no-sidebar #main-content {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
  }

  #main-content {
    padding: 32px 0 48px;
  }

  .page-title { font-size: 1.75rem; }

  /* Auto-fill grids on desktop */
  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
  }

  .related-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }

  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  /* Basic calc: fixed width on desktop */
  .basic-calc {
    max-width: 420px;
  }

  /* Footer: side-by-side on desktop */
  .footer-top {
    grid-template-columns: 1fr auto;
    gap: 40px;
  }

}

/* ── BLOG LINK CARD (calculator -> blog article) ── */
.blog-link-section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--grey-200);
}
.blog-link-section h2 {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-400);
  margin-bottom: 12px;
}
.blog-link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.blog-link-card:hover {
  border-color: var(--black);
  box-shadow: 0 4px 16px rgba(0,0,0,.07);
  transform: translateY(-1px);
}
.blc-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.blc-body {
  flex: 1;
  min-width: 0;
}
.blc-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 3px;
}
.blc-excerpt {
  font-size: 0.75rem;
  color: var(--grey-500);
  line-height: 1.5;
}
.blc-arrow {
  font-size: 1.1rem;
  color: var(--grey-300);
  flex-shrink: 0;
}
.blog-link-card:hover .blc-arrow { color: var(--black); }

/* ── BACK TO TOP BUTTON ── */
#back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  background: var(--grey-900);
  color: var(--white-pure);
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s, transform .2s, background .15s;
  z-index: 999;
}
#back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
#back-to-top:hover {
  background: var(--grey-700);
  transform: translateY(-2px);
}

/* ── PRINT STYLES ── */
@media print {
  /* Hide everything non-essential */
  #site-header, #site-sidebar, #site-footer,
  #cookie-banner, .ad-slot, .export-toolbar,
  .related-section, .blog-link-section,
  #back-to-top, .breadcrumb,
  .calc-tabs, nav { display: none !important; }

  /* Full width layout */
  .page-wrapper { max-width: 100%; padding: 0; gap: 0; }
  #main-content { padding: 8px 0 0; }
  body { font-size: 12pt; color: #000; background: #fff; }

  /* Calculator cards */
  .calc-card {
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
  }

  /* Results sections — keep together */
  .result-box, .mc-results, .mc-summary,
  .ci-results, .inv-results, .ret-summary {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }

  /* Tables — clean print layout */
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    break-inside: auto;
  }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  th, td {
    border: 1px solid #ccc;
    padding: 5px 8px;
    text-align: left;
  }
  th { background: #f5f5f4 !important; font-weight: bold; }

  /* Amortization table — important to print cleanly */
  .mc-amort-wrap, .ci-table-wrap { overflow: visible !important; }
  .mc-amort-table, .ci-tbody { display: table; width: 100%; }

  /* Charts — hide canvas, show text summary instead */
  canvas, .ci-chart-wrap, .mc-pie, .ci-bars { display: none !important; }

  /* Page title */
  .page-title { font-size: 16pt; margin-bottom: 8pt; }
  h2 { font-size: 13pt; }

  /* Print URL after links */
  a[href]:after { content: none; }

  /* Page breaks */
  h2, h3 { break-after: avoid; }
  .mc-amort-section, .ci-table-section { break-before: page; }
}

