/*
 * BitStepX base: font, text, layout helpers, shared pieces (button, pill, box, search),
 * header, phone menu and footer. Values come from tokens.css only: no color values here,
 * font sizes only through --text-*, spacing through --space-*.
 *
 * Screen widths: phones first (360px is the reference), 600px tablets, 1100px wide screens.
 */

/*
 * Pretendard Std variable (SIL Open Font License, assets/fonts/OFL.txt), two parts of the
 * pretendard-std 1.3.9 package with the package's own unicode ranges:
 * - latin (dynamic subset 6): English text, typographic quotes and dashes, currency and %.
 *   Preloaded in <head>.
 * - latin-ext (dynamic subset 5): Turkish and Vietnamese letters for translated pages.
 *   The browser fetches it only when a page uses those letters.
 * Where the ranges overlap, the rule written last is tried first, so latin comes last.
 */
@font-face {
  font-family: "Pretendard Std Variable";
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url("../fonts/PretendardStdVariable-latin-ext.woff2") format("woff2-variations"),
    url("../fonts/PretendardStdVariable-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Pretendard Std Variable";
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url("../fonts/PretendardStdVariable-latin.woff2") format("woff2-variations"),
    url("../fonts/PretendardStdVariable-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg-base);
}

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-normal);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-3);
  color: var(--text-strong);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

h5,
h6 {
  font-size: var(--text-md);
}

p {
  margin: 0 0 var(--space-4);
  text-wrap: pretty;
}

/* List items too: a last line of one word is avoided where the browser supports it. */
li {
  text-wrap: pretty;
}

a {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

/* WordPress places the header part, <main> and the footer part side by side here. */
.wp-site-blocks {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.wp-site-blocks > * {
  margin-block: 0;
}

/* ---------- Helpers other screens use ---------- */

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
  word-wrap: normal !important;
}

/* WordPress's "Skip to content" link, shown on keyboard focus: same look as the primary button. */
.skip-link.screen-reader-text:focus {
  top: var(--space-2);
  left: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.bsx-container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.bsx-muted {
  color: var(--text-muted);
}

.bsx-main {
  flex: 1 0 auto;
  padding-block: var(--space-8) var(--space-16);
}

/* Primary button: inverted colors, pill shape. One per screen. */
.bsx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--space-12);
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity var(--duration) var(--ease-out);
}

.bsx-btn:hover {
  opacity: 0.86;
  text-decoration: none;
}

/* Sign-up button (a referral link, bsx_signup_button() and the sign-up box in a post): green fill on
   every screen, so the way to sign up is never missed (2026-11-22 user decision). */
.bsx-btn--signup {
  background: var(--signup-bg);
  color: var(--signup-text);
}

/* Pill: tags, tabs, small links. */
.bsx-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--space-8);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--bg-pill);
  color: var(--text-strong);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  text-decoration: none;
  white-space: nowrap;
}

a.bsx-pill {
  min-height: var(--space-10);
  transition: background var(--duration) var(--ease-out);
}

a.bsx-pill:hover {
  background: var(--bg-pill-hover);
  text-decoration: none;
}

/* Box: key takeaways, risk note. Background one step off the page, no line, no shadow. */
.bsx-box {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--bg-box);
}

.bsx-icon {
  display: block;
  flex: none;
  width: var(--space-6);
  height: var(--space-6);
}

/* Round icon button, 44px tap target. */
.bsx-icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: calc(var(--space-10) + var(--space-1));
  height: calc(var(--space-10) + var(--space-1));
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-strong);
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
}

.bsx-icon-btn:hover {
  background: var(--bg-pill);
}

/* Search form (bsx_search_form). */
.bsx-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
}

.bsx-search__input {
  width: 100%;
  min-height: calc(var(--space-10) + var(--space-1));
  margin: 0;
  padding: 0 var(--space-12) 0 var(--space-4);
  /* Both themes: the edge of a field a visitor types in stands out from the page (WCAG 1.4.11 asks 3:1).
     In the dark theme this is the one control with a line (2026-11-15 decision); its fill alone is 1.33:1. */
  border: 1px solid var(--control-border);
  border-radius: var(--radius-full);
  background: var(--bg-pill);
  color: var(--text-strong);
  font-size: var(--text-sm);
  -webkit-appearance: none;
  appearance: none;
}

.bsx-search__input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.bsx-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.bsx-search__input:focus-visible {
  outline-offset: 0;
}

.bsx-search__submit {
  position: absolute;
  top: 50%;
  right: var(--space-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-10);
  height: var(--space-10);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.bsx-search__submit:hover {
  color: var(--text-strong);
}

/* ---------- Header ---------- */

.bsx-header {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
}

.bsx-header__bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--space-16);
}

.bsx-logo {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-strong);
  font-size: var(--text-lg);
  font-weight: var(--weight-heavy);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
}

.bsx-logo:hover {
  text-decoration: none;
}

.bsx-logo__icon {
  display: block;
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius);
}

.bsx-nav__list {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bsx-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--space-10);
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  text-decoration: none;
  transition: background var(--duration) var(--ease-out);
}

.bsx-nav__link:hover {
  background: var(--bg-pill);
  color: var(--text-strong);
  text-decoration: none;
}

/* The screen you are on: blue (the one place blue marks something that is not a link in text). */
.bsx-nav__link[aria-current] {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

.bsx-header__nav,
.bsx-header__search,
.bsx-header__cta {
  display: none;
}

/* Exchange screens (one exchange: body.single-exchange, the hub: body.post-type-archive-exchange):
   the page's own sign-up button is the one primary button, and on the hub this button points at the
   page itself. It steps back to an outlined pill. */
:is(.single-exchange, .post-type-archive-exchange) .bsx-header__cta {
  border: 1px solid var(--control-border);
  background: transparent;
  color: var(--text-strong);
  transition: background var(--duration) var(--ease-out);
}

:is(.single-exchange, .post-type-archive-exchange) .bsx-header__cta:hover {
  background: var(--bg-pill);
  opacity: 1;
}

.bsx-header__tools {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

/* Sun in the dark theme (switch to light), moon in the light theme. */
.bsx-theme-toggle .bsx-icon--moon,
:root[data-theme="light"] .bsx-theme-toggle .bsx-icon--sun {
  display: none;
}

:root[data-theme="light"] .bsx-theme-toggle .bsx-icon--moon {
  display: block;
}

/* ---------- Phone menu (below 1100px) ---------- */

.bsx-menu > summary {
  list-style: none;
}

.bsx-menu > summary::-webkit-details-marker {
  display: none;
}

.bsx-menu[open] > summary {
  background: var(--bg-pill);
}

.bsx-menu[open] .bsx-icon--menu,
.bsx-menu:not([open]) .bsx-icon--x {
  display: none;
}

/* Opens under the bar, over the page. top: 100% starts inside the header's bottom line, so the
   panel draws that line again on its own top edge. */
.bsx-menu__panel {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  display: grid;
  gap: var(--space-4);
  max-height: calc(100vh - var(--space-16));
  overflow-y: auto;
  padding: var(--space-3) var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
}

.bsx-menu__nav .bsx-nav__list {
  flex-direction: column;
  gap: 0;
}

/* Text lines up with the search placeholder below it. */
.bsx-menu__nav .bsx-nav__link {
  display: flex;
  min-height: var(--space-12);
  padding: 0 var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
}

.bsx-menu__cta {
  width: 100%;
}

/* ---------- Footer ---------- */

.bsx-footer {
  padding-block: var(--space-12) var(--space-10);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

.bsx-footer__top {
  display: grid;
  gap: var(--space-10);
}

.bsx-footer__brand {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: var(--space-3);
}

.bsx-footer__intro {
  margin: 0;
  color: var(--text-muted);
}

.bsx-footer__social {
  display: flex;
  gap: var(--space-1);
}

.bsx-footer__nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-8) var(--space-6);
}

.bsx-footer__title {
  margin: 0 0 var(--space-2);
  color: var(--text-strong);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-normal);
}

.bsx-footer__list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bsx-footer__list a {
  display: inline-flex;
  align-items: center;
  min-height: var(--space-10);
  color: var(--text-body);
}

.bsx-footer__list a:hover {
  color: var(--text-strong);
}

/* ---------- Pages, the fallback list and 404 ---------- */

.bsx-page-title {
  margin: 0 0 var(--space-6);
  font-size: var(--text-2xl);
}

/* Long text: one line stays under --measure, relaxed line height. article.css (later) adds more. */
.bsx-prose {
  max-width: var(--measure);
  line-height: var(--leading-relaxed);
}

.bsx-prose > * {
  margin-block: 0;
}

.bsx-prose > * + * {
  margin-block-start: var(--space-5);
}

.bsx-prose > h2,
.bsx-prose > h3 {
  margin-block-start: var(--space-10);
}

.bsx-prose a {
  text-decoration: underline;
}

.bsx-prose ul,
.bsx-prose ol {
  padding-left: var(--space-6);
}

.bsx-list__items {
  display: grid;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bsx-list__items > li,
.bsx-list__items > li > * {
  margin-block: 0;
}

.bsx-list__items > li > * + * {
  margin-block-start: var(--space-2);
}

.bsx-list__title {
  font-size: var(--text-xl);
}

.bsx-list__title a {
  color: var(--text-strong);
}

.bsx-list__excerpt {
  max-width: var(--measure);
}

.bsx-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-10);
  font-variant-numeric: tabular-nums;
}

.bsx-pagination a,
.bsx-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  min-height: var(--space-10);
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  background: var(--bg-pill);
  color: var(--text-strong);
  text-decoration: none;
}

.bsx-pagination .current {
  background: var(--btn-bg);
  color: var(--btn-text);
}

/* ---------- Light theme: control edges ---------- */

/* In the light theme a pill fill (--bg-pill) is almost the page color (1.05:1), so tabs, pills, page
   numbers, round icon buttons, the search field, the "On this page" toggle (article.css) and the sort
   buttons of the comparison table (components.css) also draw their edge in --control-border, which
   stands out from the page and from a box (2026-11-12 decision). The dark theme keeps its fills
   without a line, except the search field, which has its edge in both themes (2026-11-15 decision).
   The inverted tab and page number are already dark: their edge takes their own fill.
   :where() keeps the list at the weight of the theme selector alone, so the rules below win. */
:root[data-theme="light"] :where(a.bsx-pill, .bsx-pagination a, .bsx-pagination .page-numbers:not(.dots), .bsx-icon-btn,
  .bsx-search__input, .bsx-toc__summary, .bsx-sort) {
  border: 1px solid var(--control-border);
}

:root[data-theme="light"] :is(.bsx-tabs__tab[aria-current], .bsx-pagination .current) {
  border-color: var(--btn-bg);
}

/* Two outlined round buttons side by side in the phone header (color switch, menu): a little air
   between the rings, the gap the wide-screen header already has. */
:root[data-theme="light"] .bsx-header__tools {
  gap: var(--space-2);
}

.bsx-notfound {
  display: grid;
  align-content: start;
  gap: var(--space-6);
}

.bsx-notfound > * {
  margin: 0;
}

.bsx-notfound__text {
  max-width: var(--measure);
}

.bsx-search-block {
  max-width: calc(var(--space-16) * 7);
}

.bsx-notfound__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---------- Wider screens ---------- */

@media (min-width: 600px) {
  .bsx-container {
    padding-inline: var(--space-6);
  }

  .bsx-box {
    padding: var(--space-6);
  }

  .bsx-menu__panel {
    padding-inline: var(--space-6);
  }

  .bsx-footer__nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .bsx-container {
    padding-inline: var(--space-8);
  }

  .bsx-header__bar {
    gap: var(--space-6);
  }

  .bsx-header__nav {
    display: block;
  }

  .bsx-header__tools {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: var(--space-2);
    min-width: 0;
  }

  .bsx-header__search {
    display: block;
    flex: 0 1 calc(var(--space-16) * 4);
    min-width: 0;
  }

  .bsx-header__cta {
    display: inline-flex;
    min-height: var(--space-10);
  }

  .bsx-menu {
    display: none;
  }

  .bsx-footer__top {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }
}

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