/* ==========================================================================
   ct-gallery.css - project gallery overlay for portfolio.html
   --------------------------------------------------------------------------
   Owned by hand, NOT by _build/restructure-site.ps1 (which rewrites
   css/style.css). Linked from portfolio.html immediately after css/style.css so
   it is the last stylesheet on the page, per the README convention.
   Every class is prefixed ctg- or ct-pf-link so nothing here can collide with
   Elementor's own selector namespace.

   WHY EVERY RULE BELOW IS ROOTED AT #ctg
     js/ct-gallery.js appends the overlay to <body>, and <body> carries the
     Elementor kit class, so the kit stylesheet reaches the overlay too:
       .elementor-kit-8 button { color:#FFFFFF; background-color:#000000;
                                 border-style:solid; border-width:1px;
                                 border-color:#000000; border-radius:0;
                                 padding:20px 40px }            (post-8.css:155)
       .elementor-kit-8 h2     { color:#000000; ... }            (post-8.css:115)
     "one class + one type" out-specifies a lone class, so those rules were
     winning over .ctg__btn / .ctg__thumb / .ctg__cap / .ctg__title even though
     this file loads later: the three round icon buttons rendered as big opaque
     black rectangles (their padding grew the box to 122x82px and squared the
     corners, hiding the arrow glyphs), the title was drawn black on black, and
     the 56px thumbnails had 80px of horizontal padding inside them, which
     collapsed their content box to zero width so their images never showed.
     Rooting each rule at #ctg (specificity 1,1,0 and up) puts the overlay back
     in front of the kit, whatever order the stylesheets end up loading in.

   Structure, created at runtime by js/ct-gallery.js:
     .ctg
       .ctg__backdrop
       .ctg__frame            role=dialog
         .ctg__bar            project name, subtitle, counter, close
         .ctg__stage          prev arrow, figure, next arrow
         .ctg__bar--bottom    prev-project cap, thumbnails, next-project cap
   ========================================================================== */

/* --- the tile itself becomes a link ---------------------------------------- */

.elementor-155 .ct-pf-img a.ct-pf-link {
  display: block;
  position: relative;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* a hint that the tile is now clickable, on top of Elementor's float hover */
.elementor-155 .ct-pf-img a.ct-pf-link::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0);
  transition: background-color .3s ease;
  pointer-events: none;
}

.elementor-155 .ct-pf-img a.ct-pf-link:hover::after,
.elementor-155 .ct-pf-img a.ct-pf-link:focus-visible::after {
  background: rgba(26, 26, 26, .12);
}

.elementor-155 .ct-pf-img a.ct-pf-link:focus-visible {
  outline: 2px solid var(--ct-accent, #b08d4f);
  outline-offset: 4px;
}

/* --- overlay shell --------------------------------------------------------- */

#ctg {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  color: #f4f2ef;
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#ctg.is-open {
  display: block;
}

#ctg .ctg__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, .96);
}

/* Chrome >= 76 / Edge: a touch of blur so the grid reads as "behind glass" */
@supports (backdrop-filter: blur(2px)) {
  #ctg .ctg__backdrop {
    background: rgba(10, 10, 10, .94);
    backdrop-filter: blur(3px);
  }
}

#ctg .ctg__frame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  outline: none;
}

body.ctg-locked {
  overflow: hidden;
}

/* --- top bar --------------------------------------------------------------- */

#ctg .ctg__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

#ctg .ctg__meta {
  min-width: 0;
  flex: 1 1 auto;
}

#ctg .ctg__title {
  margin: 0;
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ctg .ctg__sub {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: .06em;
  color: rgba(244, 242, 239, .62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the project name flashes gold when you cross into a different project */
#ctg .ctg__title.is-changed,
#ctg .ctg__sub.is-changed {
  animation: ctg-flash 1.1s ease;
}

@keyframes ctg-flash {
  0%   { color: var(--ct-accent, #b08d4f); }
  100% { color: inherit; }
}

#ctg .ctg__count {
  flex: 0 0 auto;
  font-size: 12px;
  letter-spacing: .1em;
  color: rgba(244, 242, 239, .62);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#ctg .ctg__count b {
  font-weight: 600;
  color: #fff;
}

/* --- buttons --------------------------------------------------------------- */

/* Neutral box for the gallery's own controls. css/post-8.css dresses every bare
   <button> on the page with the kit's scale (padding 20px 40px, square corners,
   opaque black fill, its own type size and casing); the controls in here are
   icon buttons and pills that carry their own geometry, so start from zero and
   let each class below set exactly what it needs. */
#ctg button {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: none;
  -webkit-appearance: none;
  appearance: none;
}

#ctg .ctg__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: rgba(255, 255, 255, .04);
  color: #fff;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}

#ctg .ctg__btn:hover:not([disabled]) {
  background: var(--ct-accent, #b08d4f);
  border-color: var(--ct-accent, #b08d4f);
  color: #fff;
}

#ctg .ctg__btn[disabled] {
  opacity: .22;
  cursor: default;
}

#ctg .ctg__btn:focus-visible {
  outline: 2px solid var(--ct-accent, #b08d4f);
  outline-offset: 3px;
}

#ctg .ctg__btn svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* --- stage ----------------------------------------------------------------- */

#ctg .ctg__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 76px;
}

#ctg .ctg__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

#ctg .ctg__nav--prev { left: 18px; }
#ctg .ctg__nav--next { right: 18px; }

#ctg .ctg__fig {
  position: relative;
  box-sizing: border-box;
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The photograph fills the whole figure box and object-fit letterboxes it
   inside, so every slide is drawn as large as the stage allows - a 400px-wide
   source is scaled up to fill the screen instead of floating tiny in the middle
   of it. Because the box is pinned at 100% x 100% regardless of the source's
   aspect ratio, swapping slides can no longer resize or shift anything around
   it: the arrows, the close button and both caption bars stay exactly put. */
#ctg .ctg__img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity .35s ease;
  /* drop-shadow rather than box-shadow: it hugs the letterboxed photograph
     instead of drawing a rectangle around the empty stage box */
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .55));
}

#ctg .ctg__img.is-ready {
  opacity: 1;
}

/* spinner, shown until the image decodes */
#ctg .ctg__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: var(--ct-accent, #b08d4f);
  border-radius: 50%;
  animation: ctg-spin .8s linear infinite;
}

@keyframes ctg-spin {
  to { transform: rotate(360deg); }
}

#ctg .ctg__img.is-ready + .ctg__spinner,
#ctg .ctg__fig:not(.is-loading) .ctg__spinner {
  display: none;
}

/* --- bottom bar: thumbnails and cross-project caps -------------------------- */

#ctg .ctg__bar--bottom {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

#ctg .ctg__strip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .25) transparent;
}

#ctg .ctg__strip::-webkit-scrollbar { height: 6px; }
#ctg .ctg__strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .25);
  border-radius: 3px;
}

#ctg .ctg__thumb {
  flex: 0 0 auto;
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 3px;
  background: #1a1a1a;
  overflow: hidden;
  cursor: pointer;
  opacity: .55;
  transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
}

#ctg .ctg__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#ctg .ctg__thumb:hover {
  opacity: .9;
  background: #1a1a1a;
}

#ctg .ctg__thumb[aria-current="true"] {
  opacity: 1;
  border-color: var(--ct-accent, #b08d4f);
  box-shadow: 0 0 0 1px var(--ct-accent, #b08d4f);
}

#ctg .ctg__thumb:focus-visible {
  outline: 2px solid var(--ct-accent, #b08d4f);
  outline-offset: 2px;
}

/* a divider plus a labelled pill: "there is another project this way" */
#ctg .ctg__cap {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 14px 0 8px;
  border: 1px dashed rgba(255, 255, 255, .22);
  border-radius: 3px;
  background: transparent;
  color: rgba(244, 242, 239, .78);
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}

#ctg .ctg__cap:hover {
  border-color: var(--ct-accent, #b08d4f);
  color: #fff;
  background: rgba(255, 255, 255, .05);
}

#ctg .ctg__cap:focus-visible {
  outline: 2px solid var(--ct-accent, #b08d4f);
  outline-offset: 2px;
}

#ctg .ctg__cap img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 2px;
  opacity: .8;
}

#ctg .ctg__cap span {
  font-size: 10px;
  line-height: 1.15;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

#ctg .ctg__cap small {
  display: block;
  font-size: 9px;
  letter-spacing: .1em;
  opacity: .55;
}

#ctg .ctg__cap--prev { padding: 0 8px 0 14px; }
#ctg .ctg__cap--prev img { order: -1; }

#ctg .ctg__sep {
  flex: 0 0 auto;
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, .16);
}

/* --- tablet ---------------------------------------------------------------- */

@media (max-width: 1024px) {
  #ctg .ctg__stage { padding: 12px 62px; }
  #ctg .ctg__nav--prev { left: 12px; }
  #ctg .ctg__nav--next { right: 12px; }
}

/* --- phone ----------------------------------------------------------------- */

@media (max-width: 767px) {
  #ctg .ctg__bar {
    padding: 12px 14px;
    gap: 10px;
  }

  #ctg .ctg__title { font-size: 13px; letter-spacing: .1em; }
  #ctg .ctg__sub { font-size: 11px; }

  #ctg .ctg__stage { padding: 10px 8px 0; }

  /* arrows move to the bottom corners so they never cover the photograph */
  #ctg .ctg__nav {
    top: auto;
    bottom: 6px;
    transform: none;
  }

  #ctg .ctg__nav--prev { left: 10px; }
  #ctg .ctg__nav--next { right: 10px; }

  #ctg .ctg__fig { padding-bottom: 54px; }

  #ctg .ctg__btn { width: 38px; height: 38px; }
  #ctg .ctg__btn svg { width: 15px; height: 15px; }

  #ctg .ctg__bar--bottom {
    padding: 10px 10px 12px;
    gap: 6px;
  }

  #ctg .ctg__thumb { width: 44px; height: 44px; }

  /* the cap keeps its meaning without its label eating the strip */
  #ctg .ctg__cap { height: 44px; padding: 0 8px; gap: 0; }
  #ctg .ctg__cap img { width: 30px; height: 30px; }
  #ctg .ctg__cap span { display: none; }
}

@media (max-width: 420px) {
  #ctg .ctg__count { font-size: 11px; }
  #ctg .ctg__sep { display: none; }
}

/* --- motion and print ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  #ctg .ctg__img,
  #ctg .ctg__thumb,
  #ctg .ctg__btn,
  #ctg .ctg__cap,
  .elementor-155 .ct-pf-img a.ct-pf-link::after {
    transition-duration: 0s;
  }
  #ctg .ctg__title.is-changed,
  #ctg .ctg__sub.is-changed { animation: none; }
  #ctg .ctg__spinner { animation-duration: 1.6s; }
}

@media print {
  #ctg { display: none !important; }
}
