/* H@CKERBOY — sitewide enhancements: command palette, back-to-top,
   GitHub stats, project filters, micro-interactions, skill meters, contact form. */

/* Cross-document page transitions */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 320ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Boot screen should not replay on internal navigation */
html.hb-skip-boot .boot-screen {
  display: none !important;
}

/* ---------- Command palette ---------- */
.hb-command {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 999px;
  background: var(--bg-soft, #121418);
  color: var(--muted, #aeaeb2);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.hb-command:hover {
  color: var(--text, #f5f5f7);
  border-color: var(--line-strong, rgba(255, 255, 255, 0.2));
}
.hb-command kbd {
  padding: 2px 6px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 6px;
  color: var(--subtle, #94949a);
  font: inherit;
  font-size: 0.66rem;
}
.hb-command-glyph,
.hb-command-glyph svg {
  display: inline-flex;
  width: 15px;
  height: 15px;
}

.hb-palette {
  width: min(560px, calc(100% - 32px));
  max-height: min(72vh, 660px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.18));
  border-radius: 18px;
  background: var(--surface, #16181d);
  color: var(--text, #f5f5f7);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.hb-palette::backdrop {
  background: rgba(5, 6, 9, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hb-palette-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.12));
}
.hb-palette-search,
.hb-palette-search svg {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: var(--muted, #aeaeb2);
}
.hb-palette-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text, #f5f5f7);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}
.hb-palette-close {
  padding: 4px 8px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  background: transparent;
  color: var(--subtle, #94949a);
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}
.hb-palette-results {
  display: grid;
  gap: 2px;
  max-height: 52vh;
  padding: 6px;
  overflow: auto;
}
.hb-palette-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text, #f5f5f7);
  text-decoration: none;
}
.hb-palette-result:hover,
.hb-palette-result.is-active {
  background: var(--bg-soft, #121418);
}
.hb-palette-result > span:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.hb-palette-result strong {
  font-size: 0.9rem;
  font-weight: 600;
}
.hb-palette-result small {
  overflow: hidden;
  color: var(--muted, #aeaeb2);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hb-palette-arrow,
.hb-palette-arrow svg {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--subtle, #94949a);
}
.hb-palette-empty {
  padding: 18px;
  color: var(--muted, #aeaeb2);
  font-size: 0.85rem;
  text-align: center;
}
.hb-palette-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  color: var(--subtle, #94949a);
  font-size: 0.7rem;
}

/* ---------- Back to top ---------- */
.hb-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 50%;
  background: var(--surface, #16181d);
  color: var(--text, #f5f5f7);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  cursor: pointer;
}
.hb-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.hb-top > svg:not(.hb-top-ring) {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
}
.hb-top-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.hb-top-track {
  fill: none;
  stroke: var(--line, rgba(255, 255, 255, 0.12));
  stroke-width: 2;
}
.hb-top-arc {
  fill: none;
  stroke: var(--accent, #52a8ff);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

/* ---------- GitHub stats ---------- */
.hb-gh {
  padding-top: clamp(32px, 5vw, 56px);
  padding-bottom: clamp(32px, 5vw, 56px);
}
.hb-gh-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}
.hb-gh-stat {
  display: grid;
  gap: 6px;
  padding: 22px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 16px;
  background: var(--surface, #16181d);
}
.hb-gh-stat strong {
  color: var(--text, #f5f5f7);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}
.hb-gh-stat span {
  color: var(--muted, #aeaeb2);
  font-size: 0.8rem;
}
.hb-gh-stat .hb-gh-langs {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
}
.hb-gh-note {
  margin: 16px 0 0;
  color: var(--subtle, #94949a);
  font-size: 0.8rem;
}
.hb-gh-note a {
  color: var(--accent, #52a8ff);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Project filters ---------- */
.hb-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.hb-filter {
  padding: 8px 14px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #aeaeb2);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.hb-filter:hover {
  color: var(--text, #f5f5f7);
  border-color: var(--line-strong, rgba(255, 255, 255, 0.2));
}
.hb-filter[aria-pressed="true"] {
  border-color: transparent;
  background: var(--text, #f5f5f7);
  color: var(--bg, #0b0c0f);
}
.hb-filter-count {
  margin-left: auto;
  color: var(--subtle, #94949a);
  font-size: 0.76rem;
}
.project-card[hidden] {
  display: none !important;
}

/* ---------- Micro-interactions ---------- */
.hb-tilt {
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* ---------- Skill meters ---------- */
.hb-meter {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}
.hb-meter span {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: var(--line, rgba(255, 255, 255, 0.12));
  transform: scaleX(0.35);
  transform-origin: left center;
  opacity: 0.5;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease, background 0.5s ease;
}
.hb-meter span.is-on {
  background: var(--accent, #52a8ff);
}
.hb-meter.is-in span {
  transform: scaleX(1);
  opacity: 1;
}
.hb-meter.is-in span:nth-child(2) { transition-delay: 70ms; }
.hb-meter.is-in span:nth-child(3) { transition-delay: 140ms; }

/* ---------- Contact form ---------- */
.hb-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.hb-form-status {
  margin: 0;
  color: var(--muted, #aeaeb2);
  font-size: 0.84rem;
}
.hb-form-status[data-state="success"] { color: #43c681; }
.hb-form-status[data-state="error"] { color: #ff6b6b; }
.hb-form-status a {
  color: var(--accent, #52a8ff);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.hb-form-submit[disabled] {
  opacity: 0.6;
  cursor: progress;
}

@media (max-width: 760px) {
  .hb-gh-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hb-command-text,
  .hb-command kbd {
    display: none;
  }
  .hb-command {
    width: 38px;
    justify-content: center;
    padding: 0;
  }
}

/* ---------- Portfolio motion ---------- */
.hb-magnetic {
  will-change: translate;
}
.hb-spotlight {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent, #52a8ff) 11%, transparent) 0%, transparent 62%);
  transition: opacity 400ms ease;
  will-change: transform;
}
.hb-spotlight.is-active {
  opacity: 1;
}

/* Shimmering wordmark and button sweep */
.brand small {
  background-image: linear-gradient(90deg, var(--subtle, #94949a) 0%, var(--accent, #52a8ff) 45%, var(--subtle, #94949a) 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: hb-shimmer 7s linear infinite;
}
@keyframes hb-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
.button-primary {
  position: relative;
  overflow: hidden;
}
.button-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform: translateX(-130%);
  background: linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, 0.28) 50%, transparent 75%);
  transition: transform 700ms ease;
}
.button-primary:hover::after,
.button-primary:focus-visible::after {
  transform: translateX(130%);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  .hb-tilt {
    transition: none;
  }
  .hb-meter span {
    transition: none;
    transform: none;
    opacity: 1;
  }
  .hb-spotlight {
    display: none;
  }
  .hb-magnetic {
    will-change: auto;
  }
  .brand small {
    animation: none;
  }
  .button-primary::after {
    display: none;
  }
}


/* ---------- Responsive layout and control sizing ---------- */
/* Keep every card and control inside its available space on every route. */
body.site-redesign,
body.site-redesign *,
body.site-redesign *::before,
body.site-redesign *::after {
  box-sizing: border-box;
}
body.site-redesign :where(
  .container, .shell, .section-shell, .section-container,
  .page-intro, .page-hero, .case-hero, .article-header, .cv-hero,
  .about-grid, .projects-section, .skills-detail-grid,
  .certificate-grid, .contact-page-grid, .case-layout,
  .article-layout, .cv-layout, .learning-section, .expertise-section,
  .articles-section, .journal-section, .stack-overview,
  .project-grid-all, .skills-grid, .posts-grid, .learning-grid,
  .expertise-grid, .latest-grid, .featured-work
) {
  min-width: 0;
}
body.site-redesign :where(
  .card, .project-card, .skill-card, .skill-detail-card,
  .proof-card, .certification-card, .certificate-card,
  .contact-page-card, .composer-card, .case-aside-card,
  .case-section, .post-card, .learning-item, .expertise-item,
  .course-card, .exercise-card, .guided-lab, .cv-section,
  .cv-side-card, .cv-project, .cv-award, .cv-cert-item,
  .featured-primary, .featured-secondary-card, .latest-card,
  .hb-gh-stat
) {
  min-width: 0;
  max-width: 100%;
}
body.site-redesign :where(
  .card, .project-card, .skill-card, .skill-detail-card,
  .certificate-card, .contact-page-card, .post-card,
  .learning-item, .expertise-item, .course-card,
  .exercise-card, .guided-lab, .cv-section, .cv-side-card
) :where(h1, h2, h3, h4, p, a, small, span, li) {
  overflow-wrap: anywhere;
}
body.site-redesign :where(button, .button, .btn, .button-primary,
  .button-secondary, .button-ghost, .header-cta, .copy-email,
  .hb-filter, .theme-toggle, .menu-toggle, .menu-button, .icon-button) {
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  line-height: 1.25;
}
body.site-redesign :where(.button, .btn, .button-primary,
  .button-secondary, .button-ghost, .header-cta, .copy-email) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  text-align: center;
  white-space: normal;
}
body.site-redesign :where(input, select, textarea) {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
body.site-redesign :where(img, video, iframe, canvas, svg) {
  max-width: 100%;
}
body.site-redesign :where(pre, .code-block, .terminal, .featured-terminal) {
  max-width: 100%;
  overflow-x: auto;
}
body.site-redesign :where(.project-grid-all, .certificate-grid,
  .skills-detail-grid, .latest-grid, .posts-grid, .learning-grid,
  .expertise-grid, .course-grid, .hb-gh-grid) > * {
  min-width: 0;
}

@media (max-width: 900px) {
  body.site-redesign :where(.project-grid-all, .certificate-grid,
    .skills-detail-grid, .latest-grid, .posts-grid, .learning-grid,
    .expertise-grid, .course-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.site-redesign :where(.about-grid, .contact-page-grid,
    .case-layout, .article-layout, .cv-layout, .featured-primary) {
    grid-template-columns: minmax(0, 1fr);
  }
  body.site-redesign :where(.project-info) {
    min-height: 0;
  }
  body.site-redesign :where(.project-info, .skill-detail-card,
    .certificate-card, .contact-page-card, .cv-section, .cv-side-card) {
    padding: clamp(16px, 3vw, 22px);
  }
}

@media (max-width: 680px) {
  body.site-redesign :where(.container, .shell, .section-shell,
    .section-container, .page-intro, .page-hero, .case-hero,
    .article-header, .cv-hero, .about-grid, .projects-section,
    .skills-detail-grid, .certificate-grid, .contact-page-grid,
    .case-layout, .article-layout, .cv-layout, .learning-section,
    .expertise-section, .articles-section, .journal-section,
    .stack-overview, .project-grid-all, .skills-grid,
    .posts-grid, .learning-grid, .expertise-grid, .latest-grid,
    .featured-work) {
    width: min(100% - 32px, var(--hb-page-width, 1120px));
    margin-inline: auto;
  }
  body.site-redesign :where(.project-grid-all, .certificate-grid,
    .skills-detail-grid, .latest-grid, .posts-grid, .learning-grid,
    .expertise-grid, .course-grid, .featured-secondary) {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  body.site-redesign :where(.project-card, .certificate-card,
    .skill-detail-card, .contact-page-card, .composer-card,
    .case-aside-card, .post-card, .learning-item, .expertise-item,
    .course-card, .exercise-card, .guided-lab, .cv-section,
    .cv-side-card, .cv-project, .cv-award, .cv-cert-item) {
    padding: 18px;
    border-radius: 14px;
  }
  body.site-redesign :where(.project-info) {
    min-height: 0;
    padding: 18px;
  }
  body.site-redesign :where(.button, .btn, .button-primary,
    .button-secondary, .button-ghost, .header-cta, .copy-email) {
    min-height: 46px;
    padding: 11px 16px;
    font-size: 0.875rem;
  }
  body.site-redesign :where(.composer-actions, .cv-actions,
    .featured-footer, .article-end) {
    align-items: stretch;
    flex-direction: column;
  }
  body.site-redesign :where(.composer-actions .button,
    .cv-actions .button, .featured-footer .button,
    .article-end .button) {
    width: 100%;
  }
  body.site-redesign :where(.composer-fields) {
    grid-template-columns: minmax(0, 1fr);
  }
  body.site-redesign :where(.composer-field--full) {
    grid-column: auto;
  }
  body.site-redesign :where(.featured-primary) {
    padding: 18px;
  }
  body.site-redesign :where(.featured-proof) {
    gap: 14px 20px;
  }
  body.site-redesign :where(.hb-gh-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  body.site-redesign :where(.hb-gh-stat) {
    padding: 16px;
  }
  body.site-redesign :where(.hb-top) {
    right: 14px;
    bottom: 14px;
  }
}

@media (max-width: 380px) {
  body.site-redesign :where(.container, .shell, .section-shell,
    .section-container, .page-intro, .page-hero, .case-hero,
    .article-header, .cv-hero, .about-grid, .projects-section,
    .skills-detail-grid, .certificate-grid, .contact-page-grid,
    .case-layout, .article-layout, .cv-layout, .learning-section,
    .expertise-section, .articles-section, .journal-section,
    .stack-overview, .project-grid-all, .skills-grid,
    .posts-grid, .learning-grid, .expertise-grid, .latest-grid,
    .featured-work) {
    width: calc(100% - 24px);
  }
  body.site-redesign :where(.hb-gh-grid) {
    grid-template-columns: minmax(0, 1fr);
  }
  body.site-redesign :where(.project-info, .skill-detail-card,
    .certificate-card, .contact-page-card, .composer-card,
    .cv-section, .cv-side-card) {
    padding: 15px;
  }
  body.site-redesign :where(.button, .btn, .button-primary,
    .button-secondary, .button-ghost, .header-cta) {
    padding-inline: 13px;
  }
}
