/* Calculator page styles — sidebar layout + calc UI */

/* Two-column layout: sidebar + content */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px 24px 0;
}
.layout .content {
  min-width: 0;          /* prevents grid blowout from long table content */
  max-width: 760px;
}

/* Sidebar */
.sidebar {
  font-size: 12px;
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.sb-section { padding-bottom: 16px; }
.sb-h {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.sb-cats {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sb-cat { margin-bottom: 4px; }
.sb-cat summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sb-cat summary::-webkit-details-marker { display: none; }
.sb-cat summary::before {
  content: '▸';
  display: inline-block;
  width: 12px;
  margin-right: 4px;
  font-size: 9px;
  transition: transform 0.15s;
}
.sb-cat[open] summary::before,
.sb-cat details[open] summary::before { transform: rotate(90deg); }
.sb-cat.active summary { font-weight: 600; }
.sb-cnt {
  font-size: 9px;
  font-weight: 400;
  color: #666;
}
.sb-tools {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0 0 0 16px;
  border-left: 1px solid #ddd;
}
.sb-tool { margin: 0; }
.sb-tool a {
  display: block;
  font-size: 11px;
  text-decoration: none;
  color: #444;
  padding: 4px 0;
  line-height: 1.4;
}
.sb-tool a:hover { color: #000; }
.sb-tool.active a {
  color: #000;
  font-weight: 600;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.bc-sep { margin: 0 6px; }
.bc-current { font-weight: 500; }

/* Back link + heading row */
.back {
  font-size: 11px;
  display: inline-block;
  margin-bottom: 20px;
  text-decoration: none;
  color: #000;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.brand {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.counter { font-size: 11px; }
.sub {
  font-size: 12px;
  font-weight: 300;
}

/* Inputs */
.lbl {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}
.fg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.fg input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 12px;
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
  outline: none;
  width: 100%;
}
.hint {
  font-size: 10px;
  margin-top: 3px;
  display: block;
}

/* Big result row */
.big-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 20px;
}
.big-val {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

/* Result grid (3 columns) */
.rg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1px solid #000;
}
.rg > div { padding: 12px 14px; }
.rg > div:not(:last-child) { border-right: 1px solid #000; }
.rl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.rv {
  font-size: 16px;
  font-weight: 500;
}

/* Status pill */
.status {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  margin-top: 12px;
  border: 1px solid #000;
}

/* Tables (scenario, comparison) */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th {
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid #000;
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid #000;
}

/* Breakeven box */
.be-box {
  border: 1px solid #000;
  padding: 14px;
}
.be-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.be-bar {
  height: 6px;
  background: #ddd;
  margin: 14px 0 6px;
}
.be-fill {
  height: 100%;
  background: #000;
}

/* Related tools */
.related {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid #000;
}
.rel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.rel-card {
  padding: 12px 14px;
  border: 1px solid #000;
  text-decoration: none;
  color: #000;
  display: block;
}
.rel-card:hover { background: #f5f5f5; }
.rel-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.rel-desc {
  font-size: 11px;
  line-height: 1.5;
}

/* Calc-page SEO + FAQ */
.seo {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid #000;
}
.seo p {
  font-size: 12px;
  line-height: 1.9;
}
.seo p + p { margin-top: 12px; }
.faq {
  margin-top: 32px;
}
.faq-item {
  border-top: 1px solid #ddd;
  padding: 14px 0;
}
.faq-q {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}
.faq-a {
  font-size: 12px;
  line-height: 1.8;
}

/* Hidden results container until inputs are filled */
.results-hidden { display: none; }

/* Hamburger toggle + drawer (mobile only) */
.sidebar-toggle,
.sidebar-backdrop,
.sidebar-close {
  display: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #000;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 9px 14px;
    cursor: pointer;
    margin-bottom: 18px;
    align-self: flex-start;
  }
  .sidebar-toggle:hover { background: #f5f5f5; }
  .sidebar-toggle-icon {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
  }
  .sidebar-toggle-icon span {
    display: block;
    width: 14px;
    height: 1.5px;
    background: #000;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 105;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    background: #fff;
    z-index: 110;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding: 28px 22px 24px;
    margin: 0;
    border: none;
    border-right: 1px solid #000;
    box-shadow: 4px 0 24px -8px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    max-height: none;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: 0;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    font-family: 'JetBrains Mono', monospace;
    color: #000;
  }
  .sidebar-close:hover { background: #f5f5f5; }
}
@media (max-width: 600px) {
  .fg, .rel-grid { grid-template-columns: 1fr; }
  .rg { grid-template-columns: 1fr; }
  .rg > div:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid #000;
  }
  table { font-size: 11px; }
  th, td { padding: 6px 8px; }
}

/* --- Share + PDF buttons (next to H1) ---------------------------------- */
.wrap h1, .content h1 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.h1-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: normal;
}
.share-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}
.share-btn:hover { background: #f5f5f5; }
.share-btn.is-copied { background: #000; color: #fff; }
.share-btn-icon { font-size: 11px; }
.print-btn .share-btn-icon { font-size: 13px; }
@media (max-width: 600px) {
  .h1-actions { margin-left: 0; width: 100%; }
  .share-btn { font-size: 9px; padding: 5px 8px; }
}

/* --- Print stylesheet (Save as PDF) ----------------------------------- */
@media print {
  .site-nav, .sidebar, .sidebar-backdrop, .sidebar-toggle, .foot,
  .h1-actions, .share-btn, .print-btn, .modal,
  .auto-link { color: inherit !important; text-decoration: none !important; }
  .site-nav, .sidebar, .sidebar-backdrop, .sidebar-toggle, .foot,
  .h1-actions, .modal { display: none !important; }
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .layout { display: block !important; padding: 0 !important; }
  main.content, main.wrap {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  hr, .seo, .faq, table { page-break-inside: avoid; }
  .meta-block { margin: 4px 0 12px; color: #555 !important; font-size: 9pt; }
  h1 { margin-top: 0 !important; font-size: 18pt; }
  h2 { font-size: 13pt; }
  table { font-size: 9pt; }
  /* Force background colors on results to print */
  .big-row, .big-val, .status, tr[style*="background"] {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* --- Auto-linked tool mentions (in .seo and .faq blocks) -------------- */
.auto-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: rgba(0, 0, 0, 0.35);
}
.auto-link:hover {
  text-decoration-color: #000;
  background: rgba(0, 0, 0, 0.04);
}

/* --- Last-updated + author meta block (under breadcrumbs) ------------- */
.meta-block {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 400;
  color: #777;
  margin: 4px 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.meta-block a { color: #555; text-decoration: none; border-bottom: 1px dotted #ccc; }
.meta-block a:hover { color: #000; border-bottom-color: #000; }
.meta-block .meta-sep { color: #ccc; }
.meta-block time { color: #555; font-weight: 500; }

/* --- Embed mode (when calc page is loaded inside iframe via /embed/<slug>) --- */
body.embed {
  padding: 16px 18px 8px;
  background: #fff;
}
.embed-wrap {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}
body.embed .h1-actions,
body.embed .breadcrumbs,
body.embed .meta-block,
body.embed .home-seo,
body.embed .modal { display: none !important; }
body.embed-hide-related .related { display: none !important; }
body.embed-hide-faq     .faq     { display: none !important; }
body.embed-hide-about   .seo     { display: none !important; }
/* Keep .related-tools for legacy class (some calc files used it) */
body.embed .related-tools, body.embed #related { display: none !important; }
body.embed h1 {
  font-size: 18px;
  margin: 0 0 6px;
}
body.embed .sub { font-size: 11px; margin-bottom: 8px; color: #555; }
body.embed hr { margin: 8px 0; }
.embed-attribution {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 18px;
  padding: 6px 10px;
  border: 1px solid #000;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #000;
  text-decoration: none;
  background: #fff;
}
.embed-attribution:hover { background: #000; color: #fff; }
.embed-attribution-arrow { font-size: 11px; }

/* --- Embed-code modal --- */
.embed-code {
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 10px;
  border: 1px solid #000;
  background: #fafafa;
  resize: vertical;
}
.embed-preview-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-decoration: none;
  color: #555;
  border-bottom: 1px dotted #ccc;
}
.embed-preview-link:hover { color: #000; border-bottom-color: #000; }

/* --- Embed-modal options checkboxes ----------------------------------- */
.embed-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 14px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid #ddd;
}
.embed-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  margin: 0;
}
.embed-options input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: #000;
}

/* --- Saved scenarios pill rail (under meta-block) ----------------------- */
.saved-scenarios {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 14px;
}
.saved-scenarios-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #555;
  margin-right: 4px;
}
.saved-pill {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #000;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: #fff;
}
.saved-pill-load {
  background: transparent;
  border: 0;
  padding: 5px 8px;
  font-family: inherit;
  font-size: inherit;
  color: #000;
  cursor: pointer;
  max-width: 200px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.saved-pill-load:hover { background: #000; color: #fff; }
.saved-pill-x {
  background: transparent;
  border: 0;
  border-left: 1px solid #ccc;
  padding: 4px 6px 5px;
  color: #999;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.saved-pill-x:hover { color: #000; background: #f5f5f5; }
