/* Personal artwork: corner titles, full caption text, and local software icons. */
.personal-work-selects .section-heading h2 {
  font-size: clamp(2.5rem, 5vw, 5rem);
}

.personal-work-selects .personal-work-mosaic {
  display: block;
  height: auto;
  column-count: auto;
}

.personal-work-selects .personal-work-mosaic > * {
  display: block;
  min-width: 0;
  margin: 0 0 clamp(70px, 10vw, 140px);
  break-inside: avoid;
}

.personal-work-selects .personal-work-mosaic > :first-child {
  column-span: all;
}

.personal-work-item {
  position: relative;
  isolation: isolate;
  background: transparent;
}

/* Panorama first, then alternating image and text spreads. Direct gallery
   children and their editable captions stay intact for the control panel. */
.personal-work-selects .personal-work-item:not(:first-child) {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: clamp(30px, 5vw, 80px);
  min-height: 560px;
  padding-top: 32px;
  border-top: 1px solid rgba(210, 231, 227, 0.12);
}

.personal-work-item:not(:first-child) .personal-work-visual {
  position: sticky;
  top: 110px;
}

.personal-work-item:nth-child(odd):not(:first-child) {
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.7fr);
}

.personal-work-item:nth-child(odd):not(:first-child) .personal-work-visual {
  grid-column: 2;
  grid-row: 1;
}

.personal-work-item:nth-child(odd):not(:first-child) .personal-work-caption {
  grid-column: 1;
  grid-row: 1;
}

.personal-work-item:not(:first-child) .personal-work-caption {
  align-self: center;
  margin: 24px 0;
  padding: 0 0 0 24px;
  border: 0;
  border-left: 1px solid rgba(188, 228, 213, 0.28);
  background: transparent;
}

.personal-work-visual {
  position: relative;
}

.personal-work-selects .image-expand {
  position: relative;
  display: block;
  height: auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #080e10;
  box-shadow: none;
}

.personal-work-selects .image-expand > img {
  display: block;
  width: 100%;
  height: auto;
  transform: none;
  transition: transform 800ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* What the Sea Allows: fill the frame by height. The ship's center is at
   65.625% of the source; pin that point to the frame's right-hand third.
   Separate translate and transform keep the existing hover zoom anchored. */
.personal-work-item.personal-work-sea .image-expand {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
}

.personal-work-selects .personal-work-sea .image-expand > img {
  position: absolute;
  top: 0;
  left: 66.666667%;
  width: auto;
  height: 100%;
  max-width: none;
  translate: -65.625% 0;
  transform-origin: 65.625% 66.666667%;
}

@media (min-width: 901px) {
  .personal-work-item.personal-work-sea .personal-work-visual {
    position: relative;
    top: auto;
    align-self: stretch;
    min-height: 480px;
  }

  .personal-work-item.personal-work-sea .image-expand {
    position: absolute;
    inset: 0;
    height: 100%;
    aspect-ratio: auto;
  }

  .personal-work-item.personal-work-sea:first-child .personal-work-visual {
    aspect-ratio: 3 / 2;
  }
}

/* Match the Photography section's small expand cue. */
.personal-work-selects .personal-work-expand {
  position: absolute;
  z-index: 1;
  top: 14px;
  right: 14px;
  bottom: auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(225, 240, 230, 0.2);
  border-radius: 8px;
  color: #eef4ed;
  background: rgba(9, 18, 21, 0.85);
  font-size: 0.85rem;
  line-height: 1;
  opacity: 1;
  pointer-events: none;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: opacity 180ms ease;
}

/* Titles and links stay with the still; longer captions sit underneath it. */
.personal-work-overlay {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 60px 22px 20px;
  color: #f0f3ed;
  background: linear-gradient(180deg, transparent, rgba(5, 12, 16, 0.66) 48%, rgba(5, 12, 16, 0.92));
  pointer-events: none;
}

.personal-work-caption {
  position: relative;
  padding: clamp(22px, 2.5vw, 32px);
  border-top: 1px solid rgba(225, 240, 230, 0.08);
  background: rgba(20, 34, 39, 0.5);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.personal-work-overlay h3 {
  min-width: 0;
  max-width: 26ch;
  margin: 0;
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  line-height: 1.25;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.personal-work-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.personal-work-artstation {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(225, 240, 230, 0.2);
  border-radius: 8px;
  background: rgba(8, 17, 21, 0.75);
  pointer-events: auto;
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.personal-work-artstation img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.personal-work-artstation:is(:hover, :focus-visible) {
  border-color: #13aff0;
  background-color: rgba(19, 175, 240, 0.14);
}

.personal-work-story {
  max-width: 72ch;
}

.personal-work-story p {
  margin: 0;
  color: #c8d0ca;
  font-size: clamp(0.9rem, 1vw, 1rem);
  line-height: 1.8;
  text-wrap: pretty;
}

.personal-work-story p + p {
  margin-top: 16px;
}

.personal-work-item:not(:first-child) .personal-work-story > p:first-child {
  color: #e4ece1;
  font-size: clamp(1.04rem, 1.4vw, 1.26rem);
  line-height: 1.6;
}

.personal-work-software {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 236px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.personal-work-software li {
  display: block;
  margin: 0;
  padding: 0;
}

.software-badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(225, 240, 230, 0.15);
  border-radius: 6px;
  background: rgba(8, 17, 21, 0.7);
  pointer-events: auto;
  cursor: help;
}

.personal-work-software .software-badge img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.software-tooltip {
  position: absolute;
  z-index: 3;
  right: -1px;
  bottom: calc(100% + 8px);
  width: max-content;
  padding: 6px 9px;
  border: 1px solid rgba(225, 240, 230, 0.2);
  border-radius: 5px;
  color: #eef4ed;
  background: #101d22;
  font-size: 0.68rem;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.software-badge:is(:hover, :focus-visible) {
  border-color: var(--accent);
}

.software-badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.software-badge:is(:hover, :focus-visible) .software-tooltip {
  opacity: 1;
  visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
  .personal-work-selects .personal-work-expand {
    opacity: 0;
  }

  .personal-work-item:is(:hover, :focus-within) .personal-work-expand {
    opacity: 1;
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .personal-work-item:is(:hover, :focus-within) .image-expand > img {
    transform: scale(1.035);
  }
}

/* The wide opening piece gives its first paragraph a little more room. */
@media (min-width: 901px) {
  .personal-work-item:first-child .personal-work-story {
    display: grid;
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1fr);
    gap: 16px clamp(32px, 5vw, 72px);
    max-width: none;
  }

  .personal-work-item:first-child .personal-work-story > p:first-child {
    grid-column: 1;
    grid-row: 1 / span 2;
    max-width: 26ch;
    margin: 0;
    color: #eef3ec;
    font-size: clamp(1.1rem, 1.6vw, 1.45rem);
    line-height: 1.5;
  }

  .personal-work-item:first-child .personal-work-story > p:not(:first-child) {
    grid-column: 2;
    margin: 0;
  }
}

/* Small cards keep the image unobstructed, with its title and links below. */
@media (max-width: 600px) {
  .personal-work-overlay {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
    background: #10191c;
  }

  .personal-work-overlay h3 {
    max-width: none;
  }

  .personal-work-meta {
    justify-self: end;
  }
}

@media (max-width: 900px) {
  .personal-work-selects .personal-work-item:not(:first-child) {
    display: block;
    min-height: 0;
    padding-top: 0;
    border-top: 0;
  }

  .personal-work-item:not(:first-child) .personal-work-visual {
    position: relative;
    top: auto;
  }

  .personal-work-item:not(:first-child) .personal-work-caption {
    margin: 0;
    padding: clamp(22px, 4vw, 36px);
    border: 0;
    border-top: 1px solid rgba(225, 240, 230, 0.08);
    background: rgba(20, 34, 39, 0.5);
  }
}

@media (max-width: 600px) {
  .personal-work-selects .personal-work-mosaic {
    column-count: 1;
  }

  .personal-work-selects .personal-work-expand {
    top: 10px;
    right: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .personal-work-selects .image-expand > img,
  .personal-work-selects .personal-work-expand,
  .personal-work-artstation,
  .software-tooltip {
    transition: none;
  }
}
