/* ==============================================
   MAIN STYLES
   Uses tokens from tokens.css
   ============================================== */

/* Base styles */
:root {
  --gap: var(--space-5, 20px);

  font-family: var(--font-family, "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji");
  font-size: var(--font-size-base, 14px);
  line-height: 18px;
  font-weight: var(--font-weight-regular, 400);

  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  color: var(--color-text, #000);
  background: var(--color-background, #fff);
  /* Prevent layout shift when scrollbar appears/disappears */
  scrollbar-gutter: stable;
}

body.is-lightbox-open {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

/* Content wrapper — no blur filter (perf) */

.intro {
  margin: var(--page-margin, 120px) auto;
  width: min(var(--content-width, 420px), calc(100% - 40px));
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
}

h1 {
  margin: 0;
  font-size: var(--font-size-xl, 24px);
  line-height: 1.3;
  font-weight: 400;
}

.blocks {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

p {
  margin: 0;
}

.social {
  display: flex;
  justify-content: center;
  gap: var(--icon-gap, 8px);
}

.social__link {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-icon, #6b6b6b);
  text-decoration: none;
}

@media (hover: hover) {
  .social__link:hover {
    color: var(--color-black, #000);
  }
}

.social__link:active {
  color: var(--color-black, #000);
  opacity: 0.7;
}

.social__link:focus-visible {
  outline: 2px solid var(--color-black, #000);
  outline-offset: 2px;
  border-radius: var(--radius-md, 4px);
}

/* Tabs + gallery */
.work {
  margin: var(--section-gap, 120px) 0;
  padding: 0 var(--grid-gap, 30px);
}

/* Tabs removed — gallery shown directly */

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--grid-gap, 30px);
}

.gallery__item {
  position: relative;
  width: 100%;
  aspect-ratio: 440 / 330;
  overflow: hidden;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}


@media (hover: hover) {
  .gallery__item:hover {
    border-color: var(--color-accent, #0022FF);
  }

  .gallery__item:hover .gallery__img,
  .gallery__item:hover .gallery__video {
    filter: brightness(0.85);
  }
}

.gallery__item:active {
  border-color: var(--color-accent, #0022FF);
  opacity: 0.85;
}

.gallery__img,
.gallery__video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  opacity: 0;
  transform: translateZ(0);
}

.gallery__item.is-loaded .gallery__img,
.gallery__item.is-loaded .gallery__video {
  opacity: 1;
}

.gallery__item.is-loading {
  background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
  background-size: 400% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
}

/* Fullscreen viewer */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal, 999);
  touch-action: none;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
}

.lightbox.is-open {
  display: flex;
}

.lightbox__wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lightbox__media {
  pointer-events: auto;
  max-width: 85vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.lightbox__media.has-controls {
  cursor: default;
}

/* Legacy classes for compatibility */
.lightbox__img,
.lightbox__video {
  max-width: 85vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.lightbox__video {
  background: var(--color-black, #000);
}

@keyframes skeleton {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* Lightbox info bar (mobile only) */
.lightbox__info {
  display: none;
}

@media (max-width: 767px) {
  .lightbox__info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.3;
    z-index: 1002;
    opacity: 0;
    transition: opacity 200ms ease;
    pointer-events: none;
  }

  .lightbox__info.is-visible {
    opacity: 1;
  }

  .lightbox__info-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .lightbox__info-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    flex-shrink: 0;
  }

  .lightbox__info-views svg {
    width: 12px;
    height: 12px;
  }
}

/* Lightbox mobile */
@media (max-width: 767px) {
  .lightbox__media,
  .lightbox__img,
  .lightbox__video {
    max-width: 100vw;
    max-height: 82vh;
  }
}

/* tablet: 2 columns */
@media (min-width: 768px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* laptop: 3 columns */
@media (min-width: 1280px) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* FHD+: 4 columns */
@media (min-width: 1920px) {
  .gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* mobile margins */
@media (max-width: 767px) {
  .main {
    padding-top: calc(var(--page-margin, 60px) + env(safe-area-inset-top, 0px));
  }

  .intro {
    width: min(var(--content-width, 420px), calc(100% - 30px));
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: var(--grid-gap, 8px);
  }
}

/* ======================
   PROJECT FOLDER CARDS
   ====================== */

.gallery__item--project {
  aspect-ratio: 440 / 330;
  border: 1px solid var(--color-border, #E0E0E0);
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

@media (hover: hover) {
  .gallery__item--project:hover {
    border-color: var(--color-accent, #0022FF);
  }

  .gallery__item--project:hover .project-card__grid {
    filter: brightness(0.85);
  }
}

.gallery__item--project:active {
  border-color: var(--color-accent, #0022FF);
  opacity: 0.85;
}

.project-card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  flex: 1;
  min-height: 0;
  background: #f2f2f2;
}

.project-card__thumb {
  overflow: hidden;
  background: #f2f2f2;
}

.project-card__thumb img,
.project-card__thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-card__info {
  padding: var(--space-3, 12px) var(--space-4, 16px);
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 4px);
  border-top: 1px solid var(--color-border, #E0E0E0);
}

.project-card__name {
  font-weight: var(--font-weight-medium, 500);
  font-size: var(--font-size-base, 14px);
  line-height: 18px;
  color: var(--color-text, #000);
}

.project-card__count {
  font-size: var(--font-size-xs, 12px);
  line-height: 16px;
  color: var(--color-text-muted, #7E7E7E);
}

/* ======================
   SLIDER CARD (multi-image)
   ====================== */

.gallery__item--slider {
  position: relative;
}

.slider {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.slider__track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 800ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.slider__slide {
  min-width: 100%;
  width: 100%;
  height: 100%;
  flex-shrink: 0;
}

.slider__slide img,
.slider__slide video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Dots — small horizontal dashes, not circles */
.slider__dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-1, 4px);
  z-index: 2;
  opacity: 0;
  transition: opacity var(--transition-base, 0.2s ease);
  pointer-events: none;
}

.slider__dot {
  width: 12px;
  height: 2px;
  border-radius: 0;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition-base, 0.2s ease), width var(--transition-base, 0.2s ease);
}

.slider__dot.is-active {
  background: var(--color-white, #fff);
  width: 20px;
}

/* Arrows — square, sharp, minimal */
.slider__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.5);
  color: var(--color-white, #fff);
  font-family: var(--font-family);
  font-size: var(--font-size-base, 14px);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-base, 0.2s ease), background var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease);
  pointer-events: none;
  padding: 0;
}

.slider__arrow svg {
  width: 8px;
  height: 12px;
}

.slider__arrow--prev { left: 8px; }
.slider__arrow--next { right: 8px; }

.slider__arrow:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.5);
}

.slider__arrow:active {
  opacity: 0.7;
}

/* Show controls on hover (desktop) */
@media (hover: hover) {
  .gallery__item--slider:hover .slider__dots,
  .gallery__item--slider:hover .slider__arrow {
    opacity: 1;
    pointer-events: auto;
  }

  .gallery__item--slider:hover .slider__slide img,
  .gallery__item--slider:hover .slider__slide video {
    filter: brightness(0.85);
  }
}

/* Always show dots on mobile */
@media (max-width: 767px) {
  .slider__dots {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ======================
   LIGHTBOX THUMBNAILS (multi-image)
   ====================== */

.lightbox__thumbnails {
  display: none;
  gap: 2px;
  justify-content: center;
  align-items: center;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  pointer-events: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  max-width: 90vw;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.lightbox__thumbnails.is-visible {
  display: flex;
}

.lightbox__thumb {
  width: 56px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color var(--transition-base, 0.2s ease), opacity var(--transition-base, 0.2s ease);
  opacity: 0.45;
}

.lightbox__thumb.is-active {
  border-color: var(--color-accent, #0022FF);
  opacity: 1;
}

@media (hover: hover) {
  .lightbox__thumb:hover {
    opacity: 1;
    border-color: var(--color-white, #fff);
  }

  .lightbox__thumb.is-active:hover {
    border-color: var(--color-accent, #0022FF);
  }
}

.lightbox__thumb:active {
  opacity: 0.7;
}

.lightbox__thumb img,
.lightbox__thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Lightbox prev/next arrows (multi-image) — square, sharp */
.lightbox__nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1002;
  width: 36px;
  height: 36px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: var(--color-white, #fff);
  font-family: var(--font-family);
  font-size: var(--font-size-lg, 18px);
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease);
  pointer-events: auto;
  padding: 0;
}

.lightbox__nav svg {
  width: 10px;
  height: 16px;
}

.lightbox__nav.is-visible {
  display: flex;
}

@media (hover: hover) {
  .lightbox__nav:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.45);
  }
}

.lightbox__nav:active {
  opacity: 0.7;
}

.lightbox__nav--prev { left: 16px; }
.lightbox__nav--next { right: 16px; }

@media (max-width: 767px) {
  .lightbox__thumbnails {
    bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
  }

  .lightbox__thumb {
    width: 44px;
    height: 33px;
  }

  .lightbox__nav {
    width: 30px;
    height: 30px;
    font-size: var(--font-size-base, 14px);
  }

  .lightbox__nav--prev { left: 8px; }
  .lightbox__nav--next { right: 8px; }
}

/* ======================
   GALLERY HEADER (project view)
   ====================== */

.gallery-header {
  margin-bottom: var(--space-10, 40px);
}

.gallery-header__meta {
  text-align: center;
  margin-bottom: var(--space-8, 32px);
}

.gallery-header__back {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: var(--font-size-base, 14px);
  line-height: 18px;
  color: var(--color-text-muted, #7E7E7E);
  cursor: pointer;
  margin-bottom: var(--space-3, 12px);
}

@media (hover: hover) {
  .gallery-header__back:hover {
    color: var(--color-text, #000);
  }
}

.gallery-header__back:active {
  opacity: 0.7;
}

.gallery-header__title {
  margin: 0 0 var(--space-1, 4px);
  font-size: var(--font-size-xl, 24px);
  line-height: 31px;
  font-weight: var(--font-weight-medium, 500);
}

.gallery-header__count {
  font-size: var(--font-size-base, 14px);
  line-height: 18px;
  color: var(--color-text-muted, #7E7E7E);
}

.gallery-header__description {
  font-size: var(--font-size-base, 14px);
  line-height: 22px;
  color: var(--color-text, #000);
  text-align: left;
  columns: 2;
  column-gap: var(--space-8, 32px);
}

.gallery-header__description a {
  color: var(--color-blue, #0022FF);
  text-decoration: underline;
}

.gallery-header__description p {
  margin: 0 0 0.6em;
}

.gallery-header__description p:last-child {
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .gallery-header__description {
    columns: 1;
  }
}

/* Icons as SVG masks */
.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.icon--telegram {
  -webkit-mask-image: url("/assets/ic_baseline-telegram.svg");
  mask-image: url("/assets/ic_baseline-telegram.svg");
}

.icon--dribbble {
  -webkit-mask-image: url("/assets/icon-park-solid_dribble.svg");
  mask-image: url("/assets/icon-park-solid_dribble.svg");
}

.icon--linkedin {
  -webkit-mask-image: url("/assets/mdi_linkedin.svg");
  mask-image: url("/assets/mdi_linkedin.svg");
}

.icon--twitter {
  -webkit-mask-image: url("/assets/prime_twitter.svg");
  mask-image: url("/assets/prime_twitter.svg");
}
