/* ============================================================
   Vanilla port of the CircularCarousel (React Bits) — content
   cards on a 3D ring. Adapted for full project cards.
   ============================================================ */

/* Site integration: let the projects scroller sit a little wider
   than the text column by bleeding into the container padding. */
.projects-stage {
  --cc-bleed: 40px;
  margin-inline: calc(-1 * var(--cc-bleed));
}

.circular-carousel {
  --cc-w: 360px;
  --cc-h: 500px;
  --cc-fade: #0A0D12;
  position: relative;
  width: 100%;
  height: clamp(560px, 72vh, 720px);
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.circular-carousel[data-draggable] { cursor: grab; }
.circular-carousel[data-dragging] { cursor: grabbing; }
.circular-carousel:focus-visible { box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), 0.5); border-radius: 14px; }

.circular-carousel__view {
  position: absolute;
  inset: 0 0 66px 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 8%, #000 92%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 8%, #000 92%, transparent 100%);
}

.circular-carousel__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.circular-carousel[data-ready] .circular-carousel__stage { opacity: 1; }

.circular-carousel__camera,
.circular-carousel__ring {
  position: relative;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}
.circular-carousel__ring { position: absolute; left: 0; top: 0; }

/* ---- card face ---- */
.cc-card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cc-w);
  height: var(--cc-h);
  margin-left: calc(var(--cc-w) / -2);
  margin-top: calc(var(--cc-h) / -2);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.circular-carousel[data-ready] .cc-card { opacity: 1; }
.cc-card[hidden] { display: none; }
.cc-card a { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }

.cc-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: var(--cc-fade);
  opacity: var(--cc-depth, 0);
  pointer-events: none;
  z-index: 30;
}

.cc-card .work-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(180deg, #171E2A 0%, #10151E 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.5s var(--ease), box-shadow 0.5s var(--ease), transform 0.5s var(--ease);
}
.cc-card .work-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.55), transparent);
  opacity: 0.5;
  z-index: 7;
  pointer-events: none;
}
.cc-card::before {
  content: '\2197';
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1;
  color: var(--muted);
  background: rgba(10, 13, 18, 0.66);
  border: 1px solid var(--border-w);
  border-radius: 9px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease), color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
  z-index: 25;
  pointer-events: none;
}
.cc-card[data-active]::before { opacity: 1; transform: translateY(0); }
.cc-card:hover::before { color: var(--orange); border-color: rgba(var(--accent-rgb), 0.35); background: var(--orange-dim); }
.cc-card .work-card:hover { transform: translateY(-4px); }

.cc-card[data-active] .work-card {
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.6), 0 0 44px rgba(var(--accent-rgb), 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cc-card .wc-1::after { display: none; }
.cc-card .wc-1:hover .term-preview { opacity: 1; filter: none; }
.cc-card .work-card:hover .work-card-overlay { opacity: 1; }

.cc-card .work-card-thumb,
.cc-card .wc-1 .work-card-thumb {
  height: 42%;
  flex: 0 0 42%;
  border-bottom: 1px solid var(--border-w);
}
.cc-card .work-card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 13, 18, 0) 42%, rgba(11, 15, 22, 0.9) 100%);
  z-index: 3;
  pointer-events: none;
}
.cc-card .wc-icon-art { z-index: 1; }
.cc-card .wc-icon-art svg { width: 118px; height: 118px; }
.cc-card .work-card-overlay { z-index: 4; }
.cc-card .term-preview { z-index: 5; }

.cc-card .work-card-body {
  flex: 1 1 58%;
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  overflow: hidden;
  min-height: 0;
}
.cc-card .work-card h3 {
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}
.cc-card .work-card .wc-subtitle { font-size: 0.56rem; margin-bottom: 8px; }
.cc-card .work-card .wc-desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cc-card .wc-contrib-tags { margin-top: 12px; gap: 5px; }
.cc-card .wc-result { margin-top: auto; padding-top: 14px; gap: 10px; }
.cc-card .wc-result-num { font-size: 1.4rem; }
.cc-card .term-preview {
  font-size: 0.56rem;
  line-height: 1.52;
  padding: 14px 18px;
  box-shadow: none;
}

/* ---- controls ---- */
.cc-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 40;
}
.cc-nav {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 1.05rem;
  color: var(--muted);
  background: rgba(16, 21, 32, 0.4);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-w);
  border-radius: 10px;
  cursor: none;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.25s var(--ease);
}
.cc-nav:hover { color: var(--orange); border-color: var(--border); background: var(--orange-dim); }
.cc-nav:active { transform: scale(0.94); }
.cc-counter {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  min-width: 62px;
  text-align: center;
}
.cc-cur { color: var(--orange); }

.circular-carousel__live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- libraries subsection ---- */
.libs { margin-top: 128px; }
.libs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 44px;
}
.libs-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin-top: 16px;
}
.libs-title em { font-style: normal; color: var(--orange); }
.libs-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.libs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}
.lib-lang {
  position: relative;
  background: linear-gradient(180deg, #141A24 0%, #10151D 100%);
  border: 1px solid var(--border-w);
  border-radius: 14px;
  padding: 20px 20px 6px;
  overflow: hidden;
  transition: border-color 0.5s var(--ease), box-shadow 0.5s var(--ease), transform 0.5s var(--ease);
}
.lib-lang::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.55), transparent);
  opacity: 0.55;
}
.lib-lang:hover {
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 0 30px rgba(var(--accent-rgb), 0.05);
  transform: translateY(-2px);
}
.lib-lang-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 18px;
  border-bottom: 1px solid var(--border-w);
  margin-bottom: 4px;
}
.lib-lang-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(92, 255, 184, 0.6);
  flex-shrink: 0;
}
.lib-lang-name {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange);
}
.lib-lang-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  border: 1px solid var(--border-w);
  border-radius: 20px;
  padding: 2px 9px;
}
.lib-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 8px 16px 4px;
  border-radius: 10px;
  border-bottom: 1px solid var(--border-w);
  text-decoration: none;
  color: inherit;
  transition: background 0.35s var(--ease);
}
.lib-lang .lib-item:last-child { border-bottom: none; }
.lib-item:hover { background: rgba(var(--accent-rgb), 0.045); }
.lib-idx {
  flex-shrink: 0;
  padding-top: 3px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.3s ease;
}
.lib-item:hover .lib-idx { color: var(--orange); }
.lib-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lib-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  transition: color 0.25s ease;
}
.lib-item:hover .lib-name { color: var(--orange); }
.lib-desc {
  color: var(--text-2);
  font-size: 0.8rem;
  line-height: 1.6;
  font-weight: 300;
}
.lib-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}
.lib-meta span {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-w);
  padding: 2px 7px;
  border-radius: 2px;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.lib-item:hover .lib-meta span { color: var(--text-2); border-color: rgba(var(--accent-rgb), 0.18); }
.lib-arrow {
  flex-shrink: 0;
  align-self: center;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid var(--border-w);
  color: var(--muted);
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease, transform 0.3s var(--ease);
}
.lib-arrow svg { width: 14px; height: 14px; stroke: currentColor; }
.lib-item:hover .lib-arrow {
  color: var(--orange);
  border-color: rgba(var(--accent-rgb), 0.3);
  background: var(--orange-dim);
  transform: translate(2px, -2px);
}

@media (max-width: 768px) {
  .circular-carousel { height: clamp(500px, 74vh, 600px); }
  .circular-carousel__view { inset: 0 0 60px 0; }
  .libs { margin-top: 96px; }
  .libs-grid { gap: 14px; }
  .cc-nav { width: 38px; height: 38px; }
  .cc-card .work-card-body { padding: 18px 20px; }
  .cc-card .work-card h3 { font-size: 1.05rem; }
  .cc-card .work-card .wc-desc { font-size: 0.8rem; }
}
@media (max-width: 560px) {
  .cc-card .work-card-body { padding: 15px 17px; }
  .cc-card .work-card h3 { font-size: 1rem; }
  .cc-card .work-card .wc-subtitle { display: none; }
  .cc-card .work-card .wc-desc { font-size: 0.76rem; line-height: 1.55; }
  .cc-card .wc-contrib-tags { margin-top: 9px; }
  .cc-card .wc-contrib-tags span { font-size: 0.46rem; padding: 2px 6px; }
  .cc-card .wc-result { padding-top: 11px; }
  .cc-card .wc-result-num { font-size: 1.2rem; }
  .cc-card .term-preview { font-size: 0.52rem; line-height: 1.48; padding: 12px 14px; }
}
@media (max-width: 480px) {
  .circular-carousel { height: 460px; }
  .cc-nav { width: 34px; height: 34px; font-size: 0.9rem; }
}

@media (max-width: 1200px) {
  .projects-stage { --cc-bleed: 30px; }
}
@media (max-width: 980px) {
  .projects-stage { --cc-bleed: 20px; }
}
@media (max-width: 768px) {
  .projects-stage { --cc-bleed: 16px; }
}
@media (max-width: 600px) {
  .projects-stage { --cc-bleed: 14px; }
}
@media (max-width: 400px) {
  .projects-stage { --cc-bleed: 12px; }
}
@media (max-width: 375px) {
  .projects-stage { --cc-bleed: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .circular-carousel__stage,
  .cc-card { transition: none; }
}
html.no-motion .circular-carousel__stage,
html.no-motion .cc-card { transition: none; }
html.no-motion .work-card:hover { animation: none; }
