/* ============================================================
   SITE HEADER OVERLAY (this page only)
   Let the shared logo/contact header float on top of the hero
   instead of pushing it down, so the hero can fill the viewport.
   ============================================================ */
.site-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  padding-bottom: 0;
}

@media (max-width: 768px) {
  .site-header { padding: 34px 44px 0; }
}

@media (max-width: 640px), (max-height: 700px) {
  .site-header { padding: 20px 24px 0; }
  .nav-contact__email { font-size: 14px; }
  .nav-contact__phone { font-size: 13px; }
}

/* ============================================================
   PORTFOLIO HEADER
   ============================================================ */
.portfolio-header {
  position: relative; z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: clamp(56px, 9vh, 100px);
}

.portfolio-header__title-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}

.portfolio-title {
  font-size: clamp(56px, 16vw, 188px);
  font-weight: 200; letter-spacing: -0.05em; line-height: 1;
  color: var(--ink);
}

/* ============================================================
   TAB NAVIGATION
   ============================================================ */
.tab-nav-wrap {
  position: relative; z-index: 1;
  padding: clamp(32px, 6vh, 64px) 44px clamp(24px, 4vh, 40px);
}

.tab-nav { position: relative; display: flex; justify-content: center; gap: clamp(28px, 5vw, 48px); }

.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: clamp(16px, 2vw, 22px) 2px;
  font-family: var(--sans); font-size: clamp(16px, 1.9vw, 20px); font-weight: 500;
  color: rgba(245, 242, 236, 0.5); letter-spacing: -0.02em;
  transition: color 0.2s;
}
body.light-mode .tab-btn { color: rgba(47, 42, 37, 0.45); }
@media (hover: hover) {
  .tab-btn:hover { color: var(--ink); }
}
.tab-btn.active { color: var(--ink); }

/* ============================================================
   PANELS
   ============================================================ */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-inner {
  max-width: 1400px; margin: 0 auto;
  padding: clamp(44px, 7vw, 72px) 44px clamp(80px, 12vw, 160px);
}

/* ============================================================
   SUB-FILTER
   ============================================================ */
.sub-filter {
  display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(18px, 3vw, 28px);
  margin-bottom: clamp(32px, 5vw, 48px);
}

.sub-btn {
  background: none;
  border: none; cursor: pointer;
  padding: 4px 0;
  font-family: var(--sans); font-size: 16px; font-weight: 400;
  color: var(--muted); letter-spacing: 0.01em;
  transition: color 0.2s;
}
@media (hover: hover) {
  .sub-btn:hover { color: var(--ink); }
}
.sub-btn.active {
  color: var(--ink); font-weight: 500;
}

/* ============================================================
   PROJECTS GRID
   ============================================================ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(48px, 6vw, 80px) clamp(36px, 4.5vw, 60px);
}

.project-card {
  display: flex; flex-direction: column;
  cursor: pointer; text-decoration: none; color: inherit;
}

/* Scroll-reveal: cards start hidden only once JS confirms it can animate
   them back in, so a JS-less load never leaves anything invisible. */
.js .project-card {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.js .project-card.in-view {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .js .project-card { opacity: 1; transform: none; transition: none; }
}
@media (hover: hover) {
  .project-card:hover .project-card__image {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 20px 48px rgba(74,143,255,0.10);
  }
  .project-card:hover .project-card__title { color: var(--accent); }
}
.project-card:active .project-card__image {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 20px 48px rgba(74,143,255,0.10);
}
.project-card:active .project-card__image img { filter: saturate(0.9) brightness(1); }
.project-card:active .project-card__title { color: var(--accent); }

/* Touch devices: a quick press-down scale on tap, since there's no hover
   state to give feedback otherwise. Requires assets/js/components.js's
   touchstart listener for :active to fire on iOS Safari at all. */
@media (hover: none) {
  .project-card,
  .design-card {
    transition: transform 0.15s ease;
  }
  .project-card:active,
  .design-card:active {
    transform: scale(0.97);
  }
}

.project-card__image {
  position: relative;
  width: 100%; height: 248px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, rgba(74,143,255,0.04) 100%);
  border: 1px solid var(--hair); border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; font-family: var(--mono);
  letter-spacing: 0.04em; overflow: hidden;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.project-card__image img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: saturate(0.75) brightness(0.9);
  transition: filter 0.3s;
}

/* ============================================================
   DESIGN — scrollable showcase
   Two horizontally-snapping rows grouped by category (Package →
   Banners → Cards, then Social Media), separated by vertical
   divider tabs. Dedicated classes so Web Dev / AI Cinema's shared
   .project-card grid is untouched.
   ============================================================ */
#panel-design .panel-inner {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.design-showcase {
  /* Top padding intentionally omitted — #panel-design .panel-inner already
     supplies the standard tab-to-content gap (same as Web Dev/AI Cinema);
     adding more here was stacking on top of it and doubling the gap. */
  padding: 0 0 clamp(40px, 6vw, 56px);
}

.design-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 28px;
  margin: 0 0 clamp(28px, 4vw, 40px);
  padding: 0 40px;
}
.design-pills .sub-btn {
  font-size: 15px;
  font-weight: 500;
  color: #9aa4c2;
  padding: 4px 0 6px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
@media (hover: hover) {
  .design-pills .sub-btn:hover { color: #fff; }
}
.design-pills .sub-btn.active {
  color: #fff;
  font-weight: 700;
  border-bottom-color: #6f8dff;
}

.design-wall {
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4vw, 44px);
  max-width: 1400px;
  margin: 0 auto;
}

.design-row {
  display: flex;
  align-items: flex-end;
  /* "safe" keeps this sane once a row overflows and needs scrolling —
     plain center can otherwise strand the start of the content off the
     scrollable area in some browsers. Centers a row's cards when they're
     narrower than the page (e.g. after filtering to one category);
     falls back to the natural start-aligned flow once content overflows. */
  justify-content: center; /* fallback for engines that don't parse "safe" */
  justify-content: safe center;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 40px 14px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge/IE */
  cursor: grab;
  touch-action: pan-y; /* horizontal panning is handled by our own drag JS */
  -webkit-tap-highlight-color: transparent;
}
.design-row::-webkit-scrollbar { display: none; } /* Chrome/Safari/Edge */

/* While actively dragging: no snap (fights manual scrollLeft), no smooth
   easing (would lag behind the pointer), no text/image selection. */
.design-row.dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  scroll-behavior: auto;
  user-select: none;
}
.design-row.dragging * { pointer-events: none; }
.design-row img { -webkit-user-drag: none; user-select: none; }

/* Desktop: divider keeps its footprint as a plain spacer between category
   groups (same gap as before) but no longer shows a border or label —
   the category is only named in the filter pills now. */
.design-divider {
  flex: 0 0 70px;
  width: 70px;
  height: 320px;
  scroll-snap-align: start;
}

.design-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  scroll-snap-align: start;
}
.design-card img {
  height: 320px;
  width: 100%;
  border-radius: 8px;
  display: block;
  background: none;
  filter: saturate(0.75) brightness(0.9);
  transition: filter 0.3s;
}
@media (hover: hover) {
  .design-card:hover img { filter: saturate(0.9) brightness(1); }
}

/* Per-item caption — only shown on mobile (see media query below), where
   cards run one-per-line and the desktop divider labels no longer apply. */
.design-card__label {
  display: none;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b93b8;
}

/* Card widths derive from height (320px) × aspect ratio per category */
.design-card--social   img { width: 256px; object-fit: cover; }    /* 320 × 0.8  — matches IG portrait crop */
.design-card--package  img { width: 320px; object-fit: contain; }  /* 320 × 1.0  */
.design-card--banners  img { width: 198px; object-fit: contain; }  /* 320 × 0.62 */
/* Cards sits smaller than the others by request — its own height, not the
   row's shared 320px — width still follows the 1.75 aspect ratio. */
.design-card--cards    img { height: 220px; width: 385px; object-fit: contain; }

@media (max-width: 768px) {
  .design-showcase { padding: 0 0 32px; }
  .design-pills { gap: 16px; padding: 0 20px; }

  /* One design per line, scrolling down instead of dragging sideways. */
  .design-row {
    flex-direction: column;
    align-items: center;
    gap: 36px;
    overflow-x: visible;
    padding: 0 20px;
    cursor: default;
    touch-action: auto;
  }
  .design-divider { display: none; }
  .design-card__label { display: block; }

  /* Full-width single-column images replace the small side-by-side
     thumbnail sizing — each design gets its own natural aspect ratio. */
  .design-card--social  img,
  .design-card--package img,
  .design-card--banners img,
  .design-card--cards   img {
    width: min(85vw, 360px);
    height: auto;
    object-fit: contain;
  }
}

@media (hover: hover) {
  .project-card:hover .project-card__image img { filter: saturate(0.9) brightness(1); }
}

.project-card__body {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px;
  flex-wrap: wrap;
  padding: 14px 2px 0;
}

.project-card__title {
  font-size: 15px; font-weight: 400;
  letter-spacing: -0.01em; color: var(--ink); line-height: 1.3;
  transition: color 0.2s;
}

.project-card__tags {
  font-size: 13px; color: var(--muted);
  letter-spacing: 0.02em; white-space: nowrap;
}

@media (max-width: 1024px) {
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   AI CINEMA — video variant of the shared project-card
   ============================================================ */
.project-card__image video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.project-card__play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid rgba(245,242,236,0.7);
  background: rgba(245,242,236,0.08);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s, border-color 0.3s;
  pointer-events: none;
}
.project-card__play-icon {
  width: 0; height: 0; margin-left: 3px;
  border-top: 7px solid transparent; border-bottom: 7px solid transparent;
  border-left: 11px solid rgba(245,242,236,0.9);
}
@media (hover: hover) {
  .project-card:hover .project-card__play { transform: translate(-50%, -50%) scale(1.08); border-color: var(--ink); }
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
/* The particle field stays put everywhere else on the site — dimming it
   only here keeps the focused viewing moment calm without removing it. */
body.lightbox-open #particles-global { opacity: 0.12; }

.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 10, 28, 0.92);
  display: none; flex-direction: column; align-items: center;
  padding: 28px 32px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.lightbox.open { display: flex; }

.lightbox__head {
  display: none;
  flex-shrink: 0; /* stays full height — the image shrinks to make room, never this */
  width: 100%; max-width: 1100px;
  align-items: baseline; justify-content: center; gap: 16px;
  margin-bottom: 18px;
  padding-right: 56px; /* clears the fixed close button */
}
.lightbox__head.show { display: flex; }
.lightbox__head-left { display: flex; align-items: baseline; gap: 12px; }
.lightbox__title { font-size: 16px; font-weight: 400; color: var(--ink); }
.lightbox__count { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }

.lightbox__stage-row {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; align-items: stretch; justify-content: center; gap: 18px;
}

/* stretch (not center) so .lightbox__stage always receives a definite
   height equal to whatever space is actually left after the header and
   filmstrip — that's what lets the image's max-height:100% below stay
   correct at any viewport ratio, instead of a fixed vh guess that could
   run taller than the real space and overlap the head/filmstrip. Width
   is capped 100px short of each edge so the image never sits under the
   prev/next arrows (~16px offset + 52px circle ≈ 68px from the edge). */
.lightbox__stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  max-width: min(1100px, calc(100vw - 200px));
  max-height: 100%;
}

/* Image: allow large display but don't go edge-to-edge. max-width/height
   are percentages of .lightbox__stage (not viewport units) so the image
   is always bounded by the actual space available, in both axes, at any
   screen size or aspect ratio — it can only shrink to fit, never overlap
   neighboring elements. */
.lightbox__img {
  display: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  opacity: 1;
  transition: opacity 0.18s ease;
}

/* Video slot: 100%×100% so it's a definite box for the video's own
   percentage max-width/height to resolve against (same reasoning as the
   image above) — kept at 860px on very large screens, not the whole
   available width, so playback stays a comfortable size. */
.lightbox__video-slot {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 860px;
}

.lightbox__video-slot video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 10px;
  display: block;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  object-fit: contain;
  background: #000;
}

.lightbox__close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(245,242,236,0.08);
  border: 1px solid var(--hair); border-radius: 50%; cursor: pointer;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--muted);
  transition: all 0.2s; z-index: 201;
}
@media (hover: hover) {
  .lightbox__close:hover { color: var(--ink); background: rgba(245,242,236,0.14); border-color: var(--accent); }
}

.lightbox__prev,
.lightbox__next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(245,242,236,0.06);
  border: 1px solid var(--hair); border-radius: 50%; cursor: pointer;
  width: 52px; height: 52px; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--ink);
  transition: all 0.2s; z-index: 201;
}
.lightbox__prev { left: 16px; padding-right: 2px; }
.lightbox__next { right: 16px; padding-left: 2px; }
@media (hover: hover) {
  .lightbox__prev:hover,
  .lightbox__next:hover {
    background: rgba(245,242,236,0.12);
    border-color: var(--accent);
  }
}

/* Two rows of thumbnails flowing into columns, so the strip reads as a
   compact preview grid while staying horizontally scrollable. */
.lightbox__filmstrip {
  display: none;
  flex-shrink: 0; /* both thumbnail rows always stay fully visible — the
                      image shrinks to make room, never this */
  width: 100%; max-width: 1100px;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, 60px);
  grid-auto-columns: 88px;
  gap: 10px; overflow-x: auto;
  margin-top: 18px; padding-bottom: 4px;
  scrollbar-width: thin; /* Firefox */
}
.lightbox__filmstrip.show { display: grid; }
.lightbox__filmstrip::-webkit-scrollbar { height: 6px; } /* Chrome, Safari, Edge */
.lightbox__filmstrip::-webkit-scrollbar-thumb { background: var(--hair-2); border-radius: 3px; }
.lightbox__filmstrip::-webkit-scrollbar-track { background: transparent; }

.lightbox__thumb {
  border-radius: 6px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer; opacity: 0.5;
  padding: 0; background: none;
  transition: opacity 0.2s, border-color 0.2s;
}
.lightbox__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (hover: hover) {
  .lightbox__thumb:hover { opacity: 0.85; }
}
.lightbox__thumb.active { opacity: 1; border-color: var(--accent); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .tab-nav-wrap { padding: clamp(24px, 5vh, 48px) 20px clamp(20px, 3vh, 32px); }
  .tab-nav { gap: 20px; }
  .tab-btn { font-size: clamp(14px, 3.8vw, 17px); padding: 14px 2px; }
  .sub-filter { gap: 14px; }
  .panel-inner { padding: 36px 20px 80px; }
  .projects-grid { grid-template-columns: 1fr; gap: 44px; }

  /* Lightbox mobile — stage width tightened to clear the smaller/closer
     mobile arrows (44px circle at 6px offset ≈ 50px from the edge);
     height still comes from .lightbox__stage-row's flex space (base
     rules), so it stays correct regardless of viewport aspect ratio. */
  .lightbox__stage { max-width: calc(100vw - 120px); }
  /* Video has no prev/next arrows to clear (openVideo hides them), so it
     doesn't need that reserved side margin — let it use nearly the full
     width, matching the lightbox's own 12px side padding at this size. */
  .lightbox.video-open .lightbox__stage { max-width: calc(100vw - 24px); }
  .lightbox__img { border-radius: 6px; }
  .lightbox__video-slot video { border-radius: 6px; }
  .lightbox { padding: 16px 12px; }
  .lightbox__head { padding-right: 48px; margin-bottom: 12px; }
  .lightbox__title { font-size: 14px; }
  .lightbox__close { top: 10px; right: 10px; width: 40px; height: 40px; font-size: 16px; }
  .lightbox__prev  { left: 6px;  width: 44px; height: 44px; font-size: 20px; }
  .lightbox__next  { right: 6px; width: 44px; height: 44px; font-size: 20px; }
  .lightbox__stage-row { gap: 8px; }
  /* Filmstrip stays available — swipe-scrolling is natural on touch, and
     galleries run up to 50+ images where prev/next-only would be painful. */
  .lightbox__filmstrip { grid-template-rows: repeat(2, 48px); grid-auto-columns: 64px; }
}

@media (max-width: 480px) {
  .tab-nav { gap: 14px; }
  .tab-btn { font-size: 13px; padding: 12px 2px; }
}
