/* ==========================================================================
   BESU — Base: reset, typography, layout primitives, controls
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.no-scroll { overflow: hidden; }

main { flex: 1 0 auto; outline: none; }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; }
h1, h2, h3, h4 { font-weight: 700; color: var(--ink); text-wrap: balance; }
p { text-wrap: pretty; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
code, kbd, pre { font-family: var(--font-mono); }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
[hidden] { display: none !important; }

::selection { background: var(--accent-wash); color: var(--ink); }

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

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  left: 16px; top: calc(var(--safe-top) + 12px);
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-sm);
  font-size: var(--fs-small);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--dur) var(--ease);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(56px, 7vw, 104px); }
.section + .section:not(.section--rule) { padding-top: 0; }
.section--rule { border-top: 1px solid var(--line); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(24px, 3vw, 40px);
}
.section-head h2 {
  font-size: var(--fs-h2);
  letter-spacing: -0.022em;
  line-height: 1.2;
  margin-top: 10px;
}
.section-head p { color: var(--ink-2); margin-top: 8px; max-width: 46ch; }
.section-head > .link { flex: none; white-space: nowrap; padding-bottom: 4px; }
@media (max-width: 599px) {
  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* ---------- Type primitives ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}
.eyebrow--accent { color: var(--accent); }
.eyebrow .tick {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.display {
  font-size: var(--fs-display);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 700;
}

.page-title {
  font-size: var(--fs-title);
  line-height: 1.08;
  letter-spacing: var(--tracking-tight);
  font-weight: 700;
}

.lede {
  font-size: var(--fs-lede);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 40em;
}

.meta {
  font-size: var(--fs-meta);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta-sep::before { content: "·"; margin-inline: 6px; color: var(--faint); }

.num { font-variant-numeric: tabular-nums; }

.link {
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--dur-fast) var(--ease);
}
.link:hover { color: var(--accent-ink); }
.link .icon { transition: transform var(--dur) var(--ease); }
.link:hover .icon { transform: translateX(2px); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  line-height: 1;
}

/* ---------- Icons ---------- */

.icon {
  width: 18px; height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */

.btn {
  --btn-h: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 18px;
  border-radius: var(--r);
  font-size: var(--fs-ui);
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn--sm { --btn-h: 36px; padding: 0 14px; font-size: var(--fs-small); border-radius: 8px; }
.btn--lg { --btn-h: 52px; padding: 0 24px; font-size: 1rem; }

.btn--primary { background: var(--ink); color: var(--bg); }
.btn--primary:hover { background: var(--ink-2); }

.btn--accent { background: var(--accent); color: var(--on-accent); }
.btn--accent:hover { background: var(--accent-ink); }

.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { border-color: var(--ink); }

.btn--quiet { background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn--quiet:hover { color: var(--ink); background: var(--sunken); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r);
  color: var(--ink-2);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative;
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }

/* ---------- Chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-pressed="true"], .chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.chip .count { color: inherit; opacity: 0.6; font-variant-numeric: tabular-nums; }

.chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  padding-bottom: 2px;
}
.chip-scroll::-webkit-scrollbar { display: none; }

/* ---------- Inputs ---------- */

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-size: var(--fs-ui);
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-wash); }

.input-wrap { position: relative; }
.input-wrap .icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-wrap .input { padding-left: 42px; }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 2px;
}
.segmented button {
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink-2);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-soft), 0 0 0 1px var(--line);
}

/* ---------- Page transitions ---------- */

.page { animation: page-in var(--dur-slow) var(--ease-out) both; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Boot / loading ---------- */

.boot {
  min-height: 70vh;
  display: grid;
  place-items: center;
}
.boot-mark {
  display: inline-flex;
  align-items: baseline;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.boot-mark .logo-dot { animation: dot-pulse 1.1s var(--ease) infinite; }
@keyframes dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.55); opacity: 0.5; }
}

.skeleton {
  background: linear-gradient(90deg, var(--sunken), var(--line), var(--sunken));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

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