/* ==========================================================================
   Components: buttons, header and navigation, theme controls, tags, toast
   ========================================================================== */

/* ---------- Buttons and links ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.875rem;
  padding: 0.55rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 650 var(--text-sm) / 1.2 var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 1.125rem;
  height: 1.125rem;
}

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

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 84%, var(--text));
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--surface);
}

.btn-sm {
  min-height: 2.5rem;
  padding: 0.4rem 0.95rem;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.link .icon {
  width: 1em;
  height: 1em;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  background: var(--surface-2);
}

.icon-btn .icon {
  width: 1.35rem;
  height: 1.35rem;
}

/* ---------- Header and navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--header-h);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: calc(var(--radius) * 0.7);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0;
}

.site-nav {
  margin-left: auto;
}

.site-nav ul {
  display: flex;
  gap: 0.25rem;
  padding: 0;
  list-style: none;
}

.site-nav a {
  position: relative;
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) * 0.7);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="true"] {
  color: var(--text);
}

.site-nav a[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.15rem;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.nav-resume {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-toggle {
  display: none;
}

/* ---------- Theme controls ---------- */
.theme-menu {
  position: relative;
}

.theme-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6rem);
  z-index: 60;
  width: 19.5rem;
  max-width: calc(100vw - 2 * var(--gutter));
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.6);
  box-shadow: var(--shadow);
}

.theme-popover[hidden] {
  display: none;
}

.theme-popover fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.theme-popover legend {
  margin-bottom: 0.75rem;
  padding: 0;
  font-weight: 700;
}

.theme-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.theme-opt {
  position: relative;
  display: block;
}

.theme-opt input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-opt-body {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 0.8);
  font-size: var(--text-sm);
  font-weight: 550;
}

.theme-opt:hover .theme-opt-body {
  background: var(--surface-2);
}

.theme-opt input:checked + .theme-opt-body {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-opt input:focus-visible + .theme-opt-body {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Swatch that shows a theme's own background and accent (the element carries data-theme) */
.theme-dot {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--text) 25%, transparent);
  background: linear-gradient(135deg, var(--bg) 50%, var(--accent) 50%);
}

.theme-hint {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-xs);
}

kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 0.35rem;
  background: var(--surface-2);
  color: var(--text);
  font: 600 0.75rem / 1.5 var(--font-mono);
  text-align: center;
}

/* ---------- Tags and lists ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 0.6);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 550;
  line-height: 1.5;
}

.bullets {
  display: grid;
  gap: 0.7rem;
  padding: 0;
  list-style: none;
}

.bullets li {
  position: relative;
  padding-left: 1.25rem;
}

.bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 1px;
  background: var(--accent);
}

code {
  padding: 0.05rem 0.3rem;
  border-radius: 0.3rem;
  background: var(--surface-2);
  font: 400 0.875em / 1.4 var(--font-mono);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 80;
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.5rem);
  transition: opacity 0.2s, transform 0.2s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .nav-toggle {
    display: inline-grid;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    margin: 0;
    padding: 0.5rem var(--gutter) 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }

  .site-nav.is-open {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .site-nav a {
    padding: 0.8rem 0;
    font-size: var(--text-base);
  }

  .site-nav a[aria-current="true"]::after {
    left: 0;
    right: auto;
    width: 1.5rem;
    bottom: 0.45rem;
  }

  .header-actions {
    margin-left: auto;
  }
}

@media (max-width: 560px) {
  .header-actions .btn {
    display: none;
  }

  .nav-resume {
    display: block;
  }
}
