/* Barton Forge Help. Colors match the app tokens in web/src/theme.ts. */

@font-face {
  font-family: 'Barlow Semi Condensed';
  font-weight: 600;
  font-display: swap;
  src: url('barlow-semi-condensed-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-weight: 700;
  font-display: swap;
  src: url('barlow-semi-condensed-latin-700-normal.woff2') format('woff2');
}

:root {
  --primary: #3e5c3a;
  --on-primary: #ffffff;
  --page: #ece7de;
  --paper: #ffffff;
  --head: #e3ddd1;
  --text: #1c1916;
  --muted: #5e5850;
  --rule: #d9d1c3;
  --sage: #c5d1b8;
  --tip: #e6eedf;
  --note: #f3efe7;
  --warn: #f6e8d3;
  --warn-edge: #b7791f;
  --shadow: 0 1px 2px rgb(28 25 22 / 8%), 0 4px 16px rgb(28 25 22 / 6%);
  --display: 'Barlow Semi Condensed', system-ui, sans-serif;
  --body: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --header-h: 56px;
  --tabs-h: 44px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --primary: #9dbb94;
  --on-primary: #14120f;
  --page: #171512;
  --paper: #221f1b;
  --head: #2c2823;
  --text: #ede8df;
  --muted: #a8a096;
  --rule: #3a352e;
  --sage: #3b4a36;
  --tip: #26301f;
  --note: #2a2621;
  --warn: #352a19;
  --warn-edge: #d6a456;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(
    var(--header-h) + var(--tabs-h) + 16px + env(safe-area-inset-top)
  );
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 17px/1.6 var(--body);
}

a {
  color: var(--primary);
  text-underline-offset: 2px;
}

:root[data-theme='light'] a {
  color: #2f4a2c;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
}

svg .fill {
  fill: currentcolor;
  stroke: none;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 50;
  padding: 8px 12px;
  background: var(--paper);
}

.skip:focus {
  left: 8px;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0
    env(safe-area-inset-left);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 16px;
  max-width: 1360px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  text-decoration: none;
  font: 700 21px/1 var(--display);
  white-space: nowrap;
}

.brand b {
  color: var(--primary);
}

/* Phone header makes room for the App button: the leaf says Barton Forge. */
.brand-name {
  display: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--head);
}

.search-trigger {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 0 1 340px;
  margin-left: auto;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--page);
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  text-align: left;
}

.search-trigger span {
  flex: 1;
}

kbd {
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
  color: var(--muted);
}

.search-icon {
  margin-left: auto;
}

/* English / Español switch. Shows on a phone too: it's the only way across. */
.lang-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text) !important;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.lang-link:hover {
  background: var(--head);
}

/* Phone header is tight: "ES" / "EN" there, the full word on wider screens. */
.lang-long {
  display: none;
}

/* Way back to the app. Shows on a phone too: a Home Screen app has no back button. */
.app-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  padding: 0 12px 0 6px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary) !important;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}

.app-long {
  display: none;
}

.tabs {
  display: flex;
  gap: 4px;
  height: var(--tabs-h);
  padding: 0 12px;
  max-width: 1360px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 3px solid transparent;
  color: var(--muted) !important;
  font: 600 17px/1 var(--display);
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--text) !important;
}

.tabs a[aria-current] {
  color: var(--text) !important;
  border-bottom-color: var(--primary);
}

/* Layout */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1360px;
  margin: 0 auto;
}

.content {
  min-width: 0;
  padding: 16px 16px 32px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: min(320px, 86vw);
  padding: calc(8px + env(safe-area-inset-top)) 16px
    calc(32px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  overflow-y: auto;
  background: var(--paper);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.nav-open .sidebar {
  transform: none;
  box-shadow: var(--shadow);
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(0 0 0 / 40%);
}

.nav-open .backdrop {
  display: block;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.side-group {
  margin-top: 16px;
}

.side-title {
  margin: 0 0 4px;
  font: 700 14px/1.2 var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar li a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text) !important;
  font-size: 15px;
  line-height: 1.35;
  text-decoration: none;
}

.sidebar li a:hover {
  background: var(--head);
}

.sidebar li a[aria-current] {
  background: var(--sage);
  font-weight: 600;
}

.toc {
  display: none;
}

@media (min-width: 720px) {
  .search-trigger {
    display: flex;
  }

  .search-icon {
    display: none;
  }

  .app-long,
  .brand-name {
    display: inline;
  }

  .app-short {
    display: none;
  }

  .lang-long {
    display: inline;
  }

  .lang-short {
    display: none;
  }

  .content {
    padding: 24px 32px 40px;
  }
}

@media (min-width: 960px) {
  .shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .menu-btn,
  .side-head .icon-btn,
  .backdrop {
    display: none !important;
  }

  .sidebar {
    position: sticky;
    top: calc(var(--header-h) + var(--tabs-h));
    z-index: auto;
    width: auto;
    height: calc(100vh - var(--header-h) - var(--tabs-h));
    padding: 16px 16px 40px;
    transform: none;
    background: transparent;
    border-right: 1px solid var(--rule);
    box-shadow: none !important;
  }

  .side-head {
    display: none;
  }

  .side-group:first-of-type {
    margin-top: 0;
  }
}

@media (min-width: 1240px) {
  .shell {
    grid-template-columns: 260px minmax(0, 1fr) 220px;
  }

  .home .shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .toc {
    display: block;
    position: sticky;
    top: calc(var(--header-h) + var(--tabs-h));
    align-self: start;
    padding: 32px 16px 0 0;
    font-size: 14px;
  }

  .toc ul {
    margin: 0;
    padding: 0 0 0 12px;
    list-style: none;
    border-left: 1px solid var(--rule);
  }

  .toc li {
    margin: 6px 0;
  }

  .toc a {
    color: var(--muted) !important;
    text-decoration: none;
  }

  .toc a:hover {
    color: var(--text) !important;
  }

  .toc-title {
    margin: 0 0 8px;
    font: 700 14px/1 var(--display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
}

/* Article */

.crumbs {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.crumbs a {
  color: var(--muted) !important;
}

.article {
  max-width: 720px;
}

.article h1,
.hero h1 {
  margin: 8px 0 4px;
  font: 700 clamp(30px, 6vw, 40px) / 1.1 var(--display);
}

.lead {
  margin: 0 0 24px;
  font-size: 19px;
  color: var(--muted);
}

.article h2 {
  margin: 36px 0 8px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font: 700 26px/1.2 var(--display);
}

.article h3 {
  margin: 24px 0 4px;
  font: 600 21px/1.25 var(--display);
}

.article h2,
.article h3 {
  position: relative;
}

.anchor {
  position: absolute;
  left: -0.9em;
  color: var(--muted) !important;
  text-decoration: none;
  opacity: 0;
}

h2:hover .anchor,
h3:hover .anchor {
  opacity: 1;
}

.article p,
.article li {
  max-width: 68ch;
}

.article ul,
.article ol {
  padding-left: 1.4em;
}

.article li {
  margin: 6px 0;
}

.article ol {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.article ol > li {
  counter-increment: step;
  position: relative;
  padding-left: 42px;
  min-height: 30px;
  margin: 10px 0;
}

.article ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font: 700 16px/1 var(--display);
}

.ui {
  display: inline-block;
  padding: 0 7px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 1px 0 var(--rule);
  font-weight: 600;
  font-size: 0.92em;
  line-height: 1.5;
  white-space: nowrap;
}

.callout {
  margin: 20px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0;
  background: var(--tip);
}

.callout-note {
  border-left-color: var(--muted);
  background: var(--note);
}

.callout-warning {
  border-left-color: var(--warn-edge);
  background: var(--warn);
}

.callout p {
  margin: 4px 0;
}

.callout-title {
  font: 700 16px/1.2 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-wrap {
  margin: 16px 0;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--head);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--head);
  font: 0.9em ui-monospace, Consolas, monospace;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 720px;
  margin-top: 40px;
}

.pager a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--text) !important;
  font-weight: 600;
  text-decoration: none;
}

.pager a:hover {
  border-color: var(--primary);
}

.pager span {
  display: block;
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.pager .next {
  text-align: right;
}

.site-footer {
  max-width: 720px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  color: var(--muted);
}

/* Home */

.hero {
  max-width: 760px;
  padding: 16px 0 8px;
}

.hero > p {
  margin: 0 0 20px;
  font-size: 19px;
  color: var(--muted);
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 2px solid var(--primary);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-search input,
.search-bar input {
  flex: 1;
  min-width: 0;
  height: 54px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
}

.popular {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 16px;
  font-size: 15px;
}

.popular p {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.popular ul {
  display: contents;
  list-style: none;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.card {
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
}

.card h2 {
  margin: 0;
  font: 700 24px/1.2 var(--display);
}

.card h2 a {
  color: var(--text) !important;
  text-decoration: none;
}

.card > p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 15px;
}

.card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 15px;
}

.card li {
  margin: 4px 0;
}

/* Search */

.search-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  padding: 0;
  background: rgb(0 0 0 / 45%);
}

.search-dialog[hidden] {
  display: none;
}

.search-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: env(safe-area-inset-top);
  background: var(--paper);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--rule);
}

.text-btn {
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
}

.search-results {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
}

.search-results:empty {
  display: none;
}

.search-results.inline {
  margin-top: 8px;
  max-height: 420px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.search-results a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text) !important;
  text-decoration: none;
}

.search-results a:hover,
.search-results [aria-selected='true'] a {
  background: var(--sage);
}

.r-meta {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.r-title {
  display: block;
  font-weight: 600;
}

.r-snippet {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.r-snippet mark {
  background: none;
  color: var(--text);
  font-weight: 700;
}

.r-empty {
  padding: 12px;
  color: var(--muted);
}

@media (min-width: 720px) {
  .search-dialog {
    padding: 10vh 16px;
  }

  .search-panel {
    max-width: 640px;
    height: auto;
    padding-top: 0;
    max-height: 76vh;
    margin: 0 auto;
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}

@media print {
  .site-header,
  .sidebar,
  .toc,
  .pager,
  .site-footer {
    display: none;
  }
}
