/*
 * Sizes are in px or em: the default theme sets html to 62.5%, so 1rem is 10px here.
 *
 * Cairn.fun branding for the HonKit site, taken from cairn-app (DESIGN.md, src/app/globals.css):
 * warm light, white canvas, ink text, terracotta accent, Poppins, 1px hairlines over shadows,
 * 14px radius, pill controls, peach satin light on the brand band only.
 */

@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("../brand/fonts/Poppins-Regular.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("../brand/fonts/Poppins-Medium.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-style: normal; font-display: swap; src: url("../brand/fonts/Poppins-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: url("../brand/fonts/Poppins-Bold.ttf") format("truetype"); }

:root {
  --canvas: #ffffff;
  --well: #f5f5f4;
  --well-2: #efedeb;
  --peach: #fcdccb;
  --peach-soft: #fdf1ea;
  --ink: #0a0a0a;
  --ink-2: #3f3a36;
  --label: #6b635e;
  --accent: #b4502b;
  --accent-film: #c45a32;
  --clay: #963f25;
  --line: #e7e5e4;
  --up: #3f7a5a;
  --down: #a4483a;
  --sans: "Poppins", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* CJK and Cyrillic pages fall back to the system's fonts after Poppins */
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 14px;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
}

/* ---------- base ---------- */

html, body, .book, .book-header, .book-summary,
.book .book-body .page-wrapper .page-inner section.markdown-section {
  font-family: var(--sans);
}
body {
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--peach); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 6px;
}
/* the theme focuses the page container on every navigation: no ring around the whole page */
.book .book-body .page-wrapper:focus,
.book .book-body .page-wrapper:focus-visible {
  outline: none;
}

/* ---------- sidebar ---------- */

.book-summary {
  background: var(--canvas);
  border-right: 1px solid var(--line);
  color: var(--ink-2);
  padding-top: 72px;
}

.cairn-brand {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(115deg, #fbf4f0 0%, #f9e6dc 45%, #f6d7c6 100%);
}
.cairn-brand:hover { text-decoration: none; color: var(--ink); }
.cairn-mark { height: 15px; width: auto; flex: none; }
.cairn-wordmark {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.037em;
  line-height: 1;
}
.cairn-dot { color: var(--accent-film); }
.cairn-badge {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.7);
  box-shadow: inset 0 0 0 1px rgb(10 10 10 / 0.1);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

#book-search-input {
  background: var(--canvas);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  margin: 0 0 6px;
}
#book-search-input input,
#book-search-input input:focus,
#book-search-input input:hover {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--well);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  box-shadow: none;
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
}
#book-search-input input:focus {
  outline: none;
  background: var(--canvas);
  border-color: rgb(10 10 10 / 0.4);
}
#book-search-input input::placeholder { color: var(--label); }

.book-summary ul.summary { padding: 4px 10px 32px; }
.book-summary ul.summary li.header {
  padding: 22px 10px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--label);
}
.book-summary ul.summary li.divider {
  height: 1px;
  margin: 10px 10px;
  background: var(--line);
}
.book-summary ul.summary li a,
.book-summary ul.summary li span {
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.45;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.book-summary ul.summary li a:hover {
  color: var(--ink);
  background: var(--well);
  text-decoration: none;
}
.book-summary ul.summary li.active > a {
  color: var(--ink);
  font-weight: 500;
  background: var(--peach-soft);
  box-shadow: inset 2px 0 0 var(--accent-film);
}
.book-summary ul.summary li ul { padding-left: 12px; }

/* language switcher: one pill select between the brand band and the article list */
.cairn-lang {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.cairn-lang-label {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--label);
}
.cairn-lang-select {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 34px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--well);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b635e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.cairn-lang-select:hover { border-color: rgb(10 10 10 / 0.25); }
.cairn-lang-select:focus { outline: none; }
.cairn-lang-select:focus-visible {
  background-color: var(--canvas);
  border-color: rgb(10 10 10 / 0.4);
}

/* ---------- top bar ---------- */

.book-header {
  height: 56px;
  background: rgb(255 255 255 / 0.92);
  border-bottom: 1px solid var(--line);
  color: var(--label);
}
.book-header h1 {
  line-height: 56px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.book-header h1 a, .book-header h1 a:hover { color: var(--ink); }
.book-header .btn {
  height: 56px;
  line-height: 56px;
  color: var(--label);
}
.book-header .btn:hover { color: var(--ink); }

.cairn-brand-bar { display: none; }

/* ---------- page ---------- */

.book .book-body { background: var(--canvas); color: var(--ink); }
.book .book-body .page-wrapper .page-inner {
  max-width: 820px;
  padding: 32px 32px 96px;
}

.markdown-section {
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.75;
}
.markdown-section p { text-wrap: pretty; }

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4,
.markdown-section h5,
.markdown-section h6 {
  font-family: var(--sans);
  color: var(--ink);
  font-weight: 600;
  text-wrap: balance;
}
.markdown-section h1 {
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  margin: 0.4em 0 0.6em;
  padding: 0;
  border: 0;
}
.markdown-section h2 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-top: 2.4em;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--line);
}
.markdown-section h3 {
  font-size: 19px;
  letter-spacing: -0.02em;
  margin-top: 1.9em;
}
.markdown-section h4 { font-size: 16px; letter-spacing: -0.01em; }
.markdown-section h5, .markdown-section h6 { font-size: 14px; color: var(--label); }

.markdown-section a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgb(180 80 43 / 0.35);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease);
}
.markdown-section a:hover {
  color: var(--clay);
  text-decoration-color: currentColor;
}
.markdown-section strong { color: var(--ink); font-weight: 600; }

.markdown-section hr {
  height: 1px;
  margin: 2.4em 0;
  background: var(--line);
}

.markdown-section ul, .markdown-section ol { padding-left: 1.4em; }
.markdown-section li::marker { color: var(--accent-film); }

/* code */
.markdown-section code,
.markdown-section pre {
  font-family: var(--mono);
}
.markdown-section code {
  padding: 0.15em 0.4em;
  font-size: 0.84em;
  color: var(--ink);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.markdown-section pre {
  padding: 16px 18px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.86em;
  line-height: 1.6;
}
.markdown-section pre > code {
  padding: 0;
  font-size: 1em;
  background: transparent;
  border: 0;
  border-radius: 0;
}

/* blockquote */
.markdown-section blockquote {
  margin: 1.4em 0;
  padding: 14px 20px;
  color: var(--ink-2);
  background: var(--peach-soft);
  border: 0;
  border-left: 3px solid var(--accent-film);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown-section blockquote > :first-child { margin-top: 0; }
.markdown-section blockquote > :last-child { margin-bottom: 0; }

/* tables: the ledger look of the app, hairlines and tabular figures */
.markdown-section table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.markdown-section table tr,
.markdown-section table tr:nth-child(2n) {
  background: var(--canvas);
  border-top: 1px solid var(--line);
}
.markdown-section table thead tr { background: var(--well); border-top: 0; }
.markdown-section table th,
.markdown-section table td {
  padding: 10px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  vertical-align: top;
}
.markdown-section table th:last-child,
.markdown-section table td:last-child { border-right: 0; }
.markdown-section table th {
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
  text-align: left;
}

.markdown-section img { border-radius: var(--radius); }

/* ---------- hints ---------- */

.markdown-section .alert.hints-alert {
  display: flex;
  gap: 12px;
  margin: 1.4em 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--well);
  color: var(--ink-2);
}
.markdown-section .hints-alert .hints-icon {
  display: block;
  padding: 0;
  flex: none;
  line-height: 1.75;
  color: var(--label);
}
.markdown-section .hints-alert .hints-container { display: block; min-width: 0; }
.markdown-section .hints-alert .hints-container > :first-child { margin-top: 0; }
.markdown-section .hints-alert .hints-container > :last-child { margin-bottom: 0; }

.markdown-section .alert-info.hints-alert { background: var(--well); }
.markdown-section .alert-info .hints-icon { color: var(--ink-2); }

/* the plugin has no "warning" style: those hints render as alert-undefined */
.markdown-section .alert-warning.hints-alert,
.markdown-section .alert-undefined.hints-alert {
  background: var(--peach-soft);
  border-color: #f3c9b3;
}
.markdown-section .alert-warning .hints-icon,
.markdown-section .alert-undefined .hints-icon { color: var(--accent); }
.markdown-section .alert-undefined .hints-icon i::before {
  font-family: FontAwesome;
  content: "\f071";
}

.markdown-section .alert-danger.hints-alert {
  background: #fbefec;
  border-color: #efc9c1;
}
.markdown-section .alert-danger .hints-icon { color: var(--down); }

.markdown-section .alert-success.hints-alert {
  background: #eef5f1;
  border-color: #cfe2d7;
}
.markdown-section .alert-success .hints-icon { color: var(--up); }

/* ---------- mermaid ---------- */

.markdown-section .mermaid,
.markdown-section svg[id^="mermaid"] {
  font-family: var(--sans);
}

/* ---------- previous / next ---------- */

.navigation {
  color: var(--label);
  font-size: 32px;
  top: 56px;
  transition: color 150ms var(--ease), background 150ms var(--ease);
}
.navigation:hover { color: var(--ink); background: var(--well); }

/* ---------- search results ---------- */

#book-search-results .search-results .search-results-title {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}
#book-search-results .search-results .has-results .search-results-item {
  color: var(--ink-2);
  font-family: var(--sans);
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
#book-search-results .search-results .has-results .search-results-item h3 a {
  color: var(--ink);
  font-weight: 600;
}
#book-search-results .search-results .has-results .search-results-item a { color: var(--accent); }
.search-highlight-keyword,
.markdown-section mark {
  background: var(--peach);
  color: var(--ink);
  border-radius: 3px;
}

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  .cairn-brand-bar {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 56px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    text-decoration: none;
  }
  .cairn-brand-bar .cairn-mark { height: 12px; }
  .cairn-brand-bar .cairn-wordmark { font-size: 17px; }
  .book-header h1 { display: none; }
  .book .book-body .page-wrapper .page-inner { padding: 20px 16px 72px; }
  .markdown-section { font-size: 15px; }
  .markdown-section h1 { font-size: 30px; }
  .markdown-section h2 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
