/* ==========================================================================
   SIDE SKILLS — VERSION 3 (MINIMAL DESIGN SYSTEM)
   Based on TypeUI Minimal Skill Guidelines
   Principles: Maximum clarity, high contrast, clean typography, whitespace rhythm.
   WCAG 2.2 AA compliant, Dark & Light mode only.
   ========================================================================== */

/* ── 1. RESET & FOUNDATIONS ─────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Spacing Scale (4/8/12/16/24/32/48) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', 'Inconsolata', ui-monospace, SFMono-Regular, monospace;

  /* Transitions */
  --trans-fast: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --trans-base: 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  --trans-theme: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;

  /* LIGHT THEME (Crisp, High-Contrast Minimal Paper) */
  --bg:          #fafaf9;
  --s1:          #ffffff;
  --s2:          #f4f4f5;
  --s3:          #e4e4e7;

  --b1:          #e4e4e7;
  --b2:          #d4d4d8;
  --b3:          #71717a;

  --tx:          #09090b;
  --tx2:         #52525b;
  --tx3:         #71717a;

  --ac:          #09090b;
  --ac-inv:      #ffffff;
  --ac-lo:       rgba(9, 9, 11, 0.04);
  --ac-mid:      rgba(9, 9, 11, 0.08);
  --ac-hi:       #18181b;

  --card-hover:  #ffffff;
  --ring:        rgba(9, 9, 11, 0.18);
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg:   0 12px 28px rgba(0, 0, 0, 0.07);

  --badge-bg:    #f4f4f5;
  --badge-tx:    #27272a;
  --badge-b:     #e4e4e7;
}

/* ── 2. DARK THEME ───────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #09090b;
  --s1:          #111113;
  --s2:          #18181b;
  --s3:          #27272a;

  --b1:          rgba(255, 255, 255, 0.08);
  --b2:          rgba(255, 255, 255, 0.16);
  --b3:          rgba(255, 255, 255, 0.28);

  --tx:          #f4f4f5;
  --tx2:         #a1a1aa;
  --tx3:         #71717a;

  --ac:          #ffffff;
  --ac-inv:      #09090b;
  --ac-lo:       rgba(255, 255, 255, 0.06);
  --ac-mid:      rgba(255, 255, 255, 0.12);
  --ac-hi:       #fafafa;

  --card-hover:  #141417;
  --ring:        rgba(255, 255, 255, 0.22);
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg:   0 12px 32px rgba(0, 0, 0, 0.65);

  --badge-bg:    #18181b;
  --badge-tx:    #e4e4e7;
  --badge-b:     rgba(255, 255, 255, 0.1);
}

/* ── 3. BASE STYLES ──────────────────────────────────────────────────────── */
html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--tx);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: var(--trans-theme);
}

::selection {
  background: var(--ac);
  color: var(--ac-inv);
}

/* Glow in v3 is clean & subtle or hidden for minimal elegance */
#glow {
  position: fixed;
  top: -150px;
  left: 50%;
  translate: -50% 0;
  width: 900px;
  height: 400px;
  background: radial-gradient(
    ellipse 50% 40% at 50% 20%,
    var(--ac-lo) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

/* ── 4. PAGE CONTAINER ───────────────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px 120px;
}

/* ── 5. NAVIGATION BAR ───────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--b1);
  margin-bottom: 40px;
  transition: var(--trans-theme);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.wordmark {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--tx);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Minimal Version Selector */
.version-selector-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.version-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-sm);
  padding: 4px 24px 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--tx);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: var(--trans-fast);
}

.version-select:hover {
  background-color: var(--s3);
  border-color: var(--b2);
}

.version-select:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 1px;
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--tx3);
  background: var(--s2);
  border: 1px solid var(--b1);
  padding: 3px 10px;
  border-radius: var(--r-full);
  letter-spacing: 0.02em;
  transition: var(--trans-theme);
}

/* Minimalist Dark / Light Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 28px;
  cursor: pointer;
  user-select: none;
}

.switch .input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background-color: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-full);
  transition: var(--trans-base);
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background-color: var(--s1);
  box-shadow: var(--shadow-sm);
  transition: transform var(--trans-base), background-color var(--trans-base);
  z-index: 2;
}

.switch .sun svg,
.switch .moon svg {
  position: absolute;
  top: 5px;
  width: 16px;
  height: 16px;
  z-index: 1;
  transition: opacity var(--trans-fast), fill var(--trans-fast);
}

.switch .sun svg {
  right: 6px;
}

.switch .sun svg g {
  fill: var(--tx3);
}

.switch .moon svg {
  left: 6px;
  fill: var(--tx3);
}

.switch .input:checked + .slider {
  background-color: var(--s2);
  border-color: var(--b2);
}

.switch .input:checked + .slider::before {
  transform: translateX(26px);
  background-color: var(--ac);
}

.switch:has(.input:checked) .moon svg {
  fill: var(--ac);
}

.switch:has(.input:checked) .sun svg g {
  fill: var(--tx3);
}

.switch:not(:has(.input:checked)) .sun svg g {
  fill: var(--tx);
}

.switch .input:focus-visible + .slider {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

/* ── 6. SEARCH WRAPPER ───────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: 24px;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  translate: 0 -50%;
  width: 18px;
  height: 18px;
  stroke: var(--tx3);
  pointer-events: none;
  transition: stroke var(--trans-fast);
}

.search-wrap input {
  width: 100%;
  height: 50px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-md);
  padding: 0 46px 0 46px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--tx);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-theme);
}

.search-wrap input::placeholder {
  color: var(--tx3);
  font-weight: 400;
}

.search-wrap input:hover {
  border-color: var(--b2);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--ac);
  box-shadow: 0 0 0 3px var(--ring), var(--shadow-sm);
}

.search-wrap input:focus + .search-icon,
.search-wrap:focus-within .search-icon {
  stroke: var(--tx);
}

.search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--tx3);
  cursor: pointer;
  border-radius: var(--r-xs);
  background: var(--s2);
  transition: color var(--trans-fast), background var(--trans-fast);
}

.search-clear:hover {
  color: var(--tx);
  background: var(--s3);
}

/* ── 7. FILTERS ──────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--tx2);
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  transition: var(--trans-fast);
}

.tab:hover {
  color: var(--tx);
  background: var(--s2);
  border-color: var(--b2);
}

.tab.on {
  color: var(--ac-inv);
  background: var(--ac);
  border-color: var(--ac);
}

.tab-n {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--tx3);
  background: var(--s2);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  transition: var(--trans-fast);
}

.tab.on .tab-n {
  color: var(--ac);
  background: var(--ac-inv);
}

.tab:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 1px;
}

/* ── 8. SECTION BAR & TALLY ──────────────────────────────────────────────── */
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.c, .section-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tx);
}

.section-tally {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--tx3);
  letter-spacing: 0.02em;
}

.section-tally em {
  font-style: normal;
  font-weight: 600;
  color: var(--tx);
}

.section-line {
  height: 1px;
  background: var(--b1);
  margin-bottom: 24px;
  transition: background var(--trans-theme);
}

/* ── 9. BOOKMARKS GRID ───────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ── 10. MINIMAL CARD ────────────────────────────────────────────────────── */
.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-md);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--trans-fast), border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-theme);
  position: relative;
}

.card:hover {
  border-color: var(--b2);
  background: var(--card-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

/* Card Header */
.ch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.c-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--r-xs);
  background: var(--s2);
}

.c-icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}

.c-icon .fallback {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--tx3);
}

.c-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--tx);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--trans-fast);
}

.card:hover .c-title {
  color: var(--tx);
}

.c-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: opacity var(--trans-fast), transform var(--trans-fast);
  flex-shrink: 0;
}

.c-arrow svg {
  width: 12px;
  height: 12px;
  stroke: var(--tx);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card:hover .c-arrow {
  opacity: 1;
  transform: translate(2px, -2px);
}

/* Card Body */
.c-desc {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--tx2);
  line-height: 1.55;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
}

/* Card Footer */
.cf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--b1);
  transition: border-color var(--trans-theme);
}

.c-type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--badge-tx);
  background: var(--badge-bg);
  border: 1px solid var(--badge-b);
  padding: 2px 7px;
  border-radius: var(--r-xs);
  transition: var(--trans-theme);
}

.c-url {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--tx3);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty State */
.empty {
  grid-column: 1 / -1;
  padding: 72px 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--tx3);
  letter-spacing: 0.04em;
  background: var(--s1);
  border: 1px dashed var(--b2);
  border-radius: var(--r-md);
}

/* ── 11. FOOTER ──────────────────────────────────────────────────────────── */
.minimal-footer {
  border-top: 1px solid var(--b1);
  background: var(--s1);
  margin-top: 60px;
  transition: var(--trans-theme);
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 28px 32px;
}

.footer-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand-col {
  max-width: 440px;
}

.brand-logo {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tx);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 8px;
}

.brand-description {
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.6;
  margin-bottom: 18px;
}

.author-area {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 8px;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-full);
  transition: var(--trans-fast);
}

.author-area:hover {
  background: var(--s3);
  border-color: var(--b2);
}

.author-avatar img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.author-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--tx);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.author-link .arrow-icon {
  width: 12px;
  height: 12px;
  transition: transform var(--trans-fast);
}

.author-area:hover .arrow-icon {
  transform: translate(2px, -2px);
}

.footer-nav .nav-group h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tx3);
  margin-bottom: 12px;
}

.footer-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-nav a {
  font-size: 13px;
  color: var(--tx2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color var(--trans-fast);
}

.footer-nav a:hover {
  color: var(--tx);
}

.footer-bottom {
  padding-top: 20px;
  border-top: 1px solid var(--b1);
}

.copyright {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tx3);
}

/* ── 12. FLOATING BACK TO TOP ────────────────────────────────────────────── */
.float-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--s1);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  color: var(--tx);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--trans-fast), transform var(--trans-fast), background var(--trans-fast), border-color var(--trans-fast);
  z-index: 50;
}

.float-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.float-top:hover {
  background: var(--s2);
  border-color: var(--b3);
}

.float-top:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

.float-top svg {
  width: 16px;
  height: 16px;
}

/* ── 13. RESPONSIVE BREAKPOINTS ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .page {
    padding: 0 16px 80px;
  }
  
  nav {
    padding: 18px 0 16px;
    margin-bottom: 28px;
  }
  
  .wordmark {
    font-size: 15px;
  }

  .nav-badge {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .footer-main {
    flex-direction: column;
    gap: 28px;
  }

  .float-top {
    bottom: 18px;
    right: 18px;
  }
}

/* ── 14. ACCESSIBILITY UTILITIES ─────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
