/* =========================================================
   KonSaudi — shared stylesheet
   Design: "ledger / official receipt" — precise, documentary,
   built around showing the formula, not hiding it.
   ========================================================= */

:root {
  /* Color */
  --paper: #F2EFE4;
  --paper-2: #FBFAF3;
  --ink: #1E2A23;
  --ink-soft: #52604F;
  --ink-faint: #8A9186;
  --line: #CBC2A4;
  --line-soft: #DED7C0;
  --green: #0B6E4F;
  --green-deep: #093F30;
  --green-tint: #E3ECE3;
  --brass: #A66A22;
  --brass-deep: #7C4E17;
  --brass-tint: #F2E4C9;
  --white: #ffffff;

  /* Type */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Layout */
  --maxw: 1120px;
  --radius: 3px;
  --shadow-card: 0 1px 0 rgba(30,42,35,0.04), 0 8px 24px -12px rgba(30,42,35,0.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

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

/* faint paper texture via layered gradients — no external image needed */
body {
  background-image:
    radial-gradient(rgba(30,42,35,0.035) 1px, transparent 1px);
  background-size: 3px 3px;
}

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

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  margin: 0 0 0.4em;
  color: var(--ink);
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; color: var(--ink-soft); }

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

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-deep);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.eyebrow::before {
  content: "";
  width: 16px;
  height: 1px;
  background: var(--brass-deep);
  display: inline-block;
}

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(242,239,228,0.92);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

nav.main-nav { display: flex; align-items: center; gap: 4px; }
nav.main-nav a {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius);
}
nav.main-nav a:hover { color: var(--green-deep); text-decoration: none; background: var(--green-tint); }
nav.main-nav a.active { color: var(--green-deep); background: var(--green-tint); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; }

@media (max-width: 860px) {
  nav.main-nav {
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    display: none;
  }
  nav.main-nav.open { display: flex; }
  nav.main-nav a { padding: 12px 14px; }
  .nav-toggle { display: inline-flex; }
}

/* ---------------- Hero ---------------- */
.hero {
  padding: 76px 0 56px;
  border-bottom: 1px solid var(--line);
}
.hero h1 {
  font-size: clamp(34px, 5.2vw, 58px);
  max-width: 15ch;
}
.hero .lede {
  font-size: 18px;
  max-width: 56ch;
  color: var(--ink-soft);
}
.hero-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: var(--paper-2); }

/* ---------------- Tool ticket cards (signature element) ---------------- */
.tools-section { padding: 56px 0 88px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 8px; }
.section-head h2 { font-size: 28px; }

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.ticket {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.ticket:hover { transform: translateY(-3px); box-shadow: 0 1px 0 rgba(30,42,35,0.04), 0 16px 30px -14px rgba(30,42,35,0.28); }

.ticket::before {
  /* perforation notches, like a torn ticket stub */
  content: "";
  position: absolute;
  top: -8px;
  left: 22px;
  width: 14px;
  height: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
}
.ticket::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.ticket-index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}
.ticket h3 {
  font-size: 21px;
  margin: 0;
}
.ticket p { font-size: 14px; margin: 0; color: var(--ink-soft); }
.ticket-formula {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--brass-deep);
  background: var(--brass-tint);
  border: 1px dashed var(--brass);
  border-radius: 2px;
  padding: 8px 10px;
  margin-top: 4px;
  overflow-x: auto;
  white-space: nowrap;
}
.ticket-link {
  margin-top: auto;
  padding-top: 8px;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ticket-link svg { width: 14px; height: 14px; transition: transform 150ms ease; }
.ticket:hover .ticket-link svg { transform: translateX(3px); }

/* ---------------- Page (inner tool) header ---------------- */
.page-header { padding: 48px 0 8px; }
.page-header h1 { font-size: clamp(28px, 4vw, 40px); }
.page-header .lede { font-size: 16px; max-width: 62ch; }
.source-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 10px;
}
.source-note a { color: var(--ink-faint); text-decoration: underline; }

/* ---------------- Calculator layout ---------------- */
.calc-wrap {
  padding: 24px 0 96px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 860px) {
  .calc-wrap { grid-template-columns: 1fr; }
}

.panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-card);
}
.panel h2 { font-size: 18px; margin-bottom: 18px; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

input[type="number"],
input[type="text"],
select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white);
  color: var(--ink);
}
input[type="number"]:focus,
input[type="text"]:focus,
select:focus { border-color: var(--green); }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
}
.radio-pill input { accent-color: var(--green); }
.radio-pill.selected { border-color: var(--green); background: var(--green-tint); }

table.course-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
table.course-table th {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-align: left;
  padding: 0 8px 8px 0;
  font-weight: 500;
}
table.course-table td { padding: 4px 8px 4px 0; vertical-align: middle; }
table.course-table td:first-child { width: 40%; }
.row-remove {
  background: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
}
.row-remove:hover { border-color: var(--brass); color: var(--brass-deep); }

/* ---------------- Receipt-style result panel ---------------- */
.receipt {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 26px 24px;
  position: relative;
}
.receipt-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.receipt-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.receipt-id { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }

.receipt-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 6px 0;
  color: var(--ink-soft);
}
.receipt-line span:last-child { color: var(--ink); }

.receipt-total {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.receipt-total .label {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.receipt-total .value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 30px;
  color: var(--brass-deep);
}

.receipt-formula {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green-deep);
  background: var(--green-tint);
  border-radius: 2px;
  padding: 10px 12px;
  overflow-x: auto;
}

.receipt-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faint);
}

.zig {
  height: 8px;
  background:
    linear-gradient(-45deg, var(--paper) 6px, transparent 0),
    linear-gradient(45deg, var(--paper) 6px, transparent 0);
  background-position: bottom;
  background-repeat: repeat-x;
  background-size: 12px 12px;
}

/* ---------------- Explainer / info section on tool pages ---------------- */
.explainer {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}
.explainer h2 { font-size: 20px; }
.explainer ul { padding-left: 20px; color: var(--ink-soft); }
.explainer li { margin-bottom: 6px; }

/* ---------------- FAQ accordion ---------------- */
.faq-item {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.faq-item:first-of-type { border-top: 1px solid var(--line); }
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-family: var(--font-mono);
  color: var(--ink-faint);
  font-size: 19px;
  flex: none;
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ---------------- Footer ---------------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 40px 0;
  margin-top: 40px;
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.site-footer p {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin: 0;
  max-width: 60ch;
}
.footer-links { display: flex; gap: 18px; }
.footer-links a { font-size: 13px; color: var(--ink-soft); }

/* utility */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}
