/* ── Portable nav + contact (mobile + tablet) ────────────────────────────── */

.nav--portable {
  display: block;
}

@media (min-width: 1280px) {
  .nav--portable {
    display: none;
  }
}

.nav--portable {
  margin-top: var(--space-bio-top);
  padding-inline: var(--space-page-x);
}

@media (max-width: 1279px) {
  .nav--portable {
    position: sticky;
    top: var(--space-bio-top);
    z-index: calc(var(--z-content) + 1);
  }
}

.nav--portable .nav__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-nav-gap);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav--portable .nav__row--subnav {
  margin-top: var(--space-nav-row-gap);
}

.nav--portable:not(.nav--subnav-open) .nav__row--subnav {
  display: none;
}

.nav--portable.nav--contact-open .nav__row--subnav {
  display: none;
}

.nav--portable .nav__item {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.nav--portable .nav__item--active {
  text-decoration: underline;
  text-underline-position: from-font;
  line-height: var(--line-height-underline);
}

.nav--portable .nav__item--inert {
  cursor: default;
}

.nav--portable .nav__toggle-btn {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.contact--portable {
  display: none;
  flex-direction: column;
  gap: var(--space-nav-gap);
  margin-top: var(--space-nav-row-gap);
  padding-inline: var(--space-page-x);
}

.contact--portable:not([hidden]) {
  display: flex;
}

@media (min-width: 1280px) {
  .contact--portable {
    display: none !important;
  }
}

.contact--portable p {
  margin: 0;
}

.contact--portable a {
  color: inherit;
}

/* ── Desktop contact (bottom-left) ───────────────────────────────────────── */

.contact--desktop {
  display: none;
}

@media (min-width: 1280px) {
  .contact--desktop {
    display: flex;
    flex-direction: column;
    gap: var(--space-nav-gap);
    position: fixed;
    left: var(--space-page-x-desktop);
    bottom: var(--space-contact-bottom-desktop);
    z-index: var(--z-content);
    width: var(--space-content-max-width);
    margin: 0;
    padding: 0;
    border: 0;
  }

  .contact--desktop p {
    margin: 0;
  }

  .contact--desktop a {
    color: inherit;
  }
}

/* ── Desktop nav (bottom-right) ──────────────────────────────────────────── */

.nav--desktop {
  display: none;
}

@media (min-width: 1280px) {
  .nav--desktop {
    display: block;
    position: fixed;
    right: var(--space-nav-right-desktop);
    bottom: var(--space-contact-bottom-desktop);
    z-index: var(--z-content);
    width: var(--space-content-max-width);
    text-align: right;
  }

  .nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-nav-gap);
  }

  .nav__item {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-align: right;
    width: 100%;
    white-space: nowrap;
    text-decoration: none;
  }

  .nav__item--active {
    text-decoration: underline;
    text-underline-position: from-font;
    line-height: var(--line-height-underline);
  }

  .nav__item--inert {
    cursor: default;
  }

  .nav--desktop:not(.nav--subnav-open) .nav__subnav-item {
    display: none;
  }

  .nav__arrow {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 18px;
    height: 18px;
    margin-left: auto;
  }

  .nav__arrow-label {
    display: block;
    white-space: nowrap;
    transform: rotate(-90deg);
  }
}

/* ── Work tiles ──────────────────────────────────────────────────────────── */

.work-tile {
  pointer-events: auto;
  display: block;
  box-sizing: border-box;
  width: min(100%, var(--tile-max-width));
  max-width: var(--tile-max-width);
  height: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-tile);
  background: rgba(251, 0, 255, 0.2);
  cursor: pointer;
  overflow: visible;
  align-self: start;
  justify-self: start;
}

.work-tile:has(.work-tile__image) {
  width: fit-content;
  max-width: 100%;
  overflow: visible;
  background: transparent;
}

.work-tile:not(:has(.work-tile__image)) {
  aspect-ratio: 4 / 3;
  min-height: 48px;
}

.work-tile[data-aspect="portrait"]:not(:has(.work-tile__image)) {
  aspect-ratio: 3 / 4;
}

@media (min-width: 744px) and (max-width: 1279px) {
  /* Fill 3-column tablet span; avoids narrow portrait tiles in padded layout. */
  .work-tile[data-aspect="portrait"]:not(:has(.work-tile__image)) {
    width: 100%;
    max-width: none;
    aspect-ratio: 3 / 4;
  }
}

.work-tile__label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 9px;
  font-family: var(--font-mono, monospace);
  color: rgba(180, 0, 200, 0.8);
  word-break: break-all;
  text-align: center;
  padding: 4px;
  box-sizing: border-box;
  pointer-events: none;
  line-height: 1.3;
}

.work-tile__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: var(--tile-max-height);
  object-fit: scale-down;
  object-position: left top;
  border-radius: var(--radius-tile);
  transition:
    transform 0.25s ease,
    filter 0.25s ease;
}

@media (hover: hover) {
  .work-tile:hover .work-tile__image {
    transform: scale(1.02);
    filter: drop-shadow(var(--shadow-tile));
    position: relative;
    z-index: var(--z-tile-hover);
  }
}

@media (max-width: 743px) {
  .work-tile__image {
    height: auto;
    max-height: calc(var(--canvas-row-height) * var(--tile-row-span, 2));
  }
}

@media (min-width: 1280px) {
  .work-tile {
    width: 100%;
    max-width: none;
    align-self: start;
    justify-self: start;
  }

  .work-tile:has(.work-tile__image) {
    width: fit-content;
    max-width: 100%;
    overflow: visible;
  }

  .work-tile__image {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: none;
    object-fit: initial;
  }
}

/* ── Work modal (desktop) ────────────────────────────────────────────────── */

.modal {
  display: none;
}

.modal:not([hidden]) {
  display: block;
}

/* Shared modal gallery image styles */
.modal__gallery-cell {
  width: 100%;
}

.modal__gallery-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-tile);
}

.modal__gallery-cell--placeholder {
  aspect-ratio: 4 / 3;
  background: rgba(251, 0, 255, 0.2);
  border-radius: var(--radius-tile);
}

.modal__gallery-cell[data-width="0.5"] {
  display: flex;
  align-self: stretch;
  overflow: hidden;
  border-radius: var(--radius-tile);
}

.modal__gallery-cell[data-width="0.5"] .modal__gallery-image {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  border-radius: 0;
  object-fit: cover;
  object-position: center;
}

.modal__back {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.modal__title {
  margin: 0;
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-body);
}

.modal__meta-details {
  line-height: var(--line-height-metadata);
}

.modal__meta-details p {
  margin: 0;
}

/* ── Work modal (stacked: tablet + mobile) ───────────────────────────────── */

@media (max-width: 1279px) {
  .modal:not([hidden]).modal--work {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal-overlay);
  }

  .modal--work .modal__overlay {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(var(--blur-modal-backdrop-mobile));
    background: var(--color-modal-tint-mobile);
  }

  .modal--work .modal__chrome {
    margin: 0;
    padding:
      var(--space-bio-top)
      var(--space-page-x)
      0;
  }

  .modal--work .modal__site-name {
    margin: 0;
  }

  .modal--work .modal__back {
    position: absolute;
    top: 24px;
    right: var(--space-page-x);
    z-index: calc(var(--z-modal-content) + 1);
  }

  .modal--work .modal__body {
    position: absolute;
    inset: 0;
    z-index: var(--z-modal-content);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: none;
    padding-bottom: var(--space-page-x);
  }

  .modal--work .modal__body > * {
    pointer-events: auto;
  }

  .modal--work .modal__gallery {
    width: min(var(--width-gallery), calc(100vw - 2 * var(--space-modal-scale-inset)));
    margin-top: calc(var(--space-modal-body-top-mobile) - var(--space-bio-top) - var(--line-height-body));
    margin-inline: auto;
  }

  .modal--work .modal__gallery-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-gallery-gap);
    width: 100%;
  }

  .modal--work .modal__gallery-cell[data-width="0.5"] {
    width: calc(50% - var(--space-gallery-gap) / 2);
  }

  .modal--work .modal__details {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-modal-details-gap-mobile);
    margin-top: var(--space-modal-gallery-to-info-mobile);
    margin-inline: auto;
    width: min(var(--width-gallery), calc(100vw - 2 * var(--space-modal-scale-inset)));
    align-items: flex-start;
  }

  .modal--work .modal__meta {
    flex: 0 0 var(--width-modal-meta-mobile);
    width: var(--width-modal-meta-mobile);
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .modal--work .modal__title {
    text-shadow:
      calc(-1 * var(--shadow-text-offset)) calc(-1 * var(--shadow-text-offset)) var(--shadow-text-blur) var(--color-text-shadow),
      var(--shadow-text-offset) var(--shadow-text-offset) var(--shadow-text-blur) var(--color-text-shadow);
  }

  .modal--work .modal__description {
    flex: 0 0 var(--width-modal-desc-mobile);
    width: var(--width-modal-desc-mobile);
    margin: 0;
    line-height: var(--line-height-metadata);
    text-shadow:
      calc(-1 * var(--shadow-text-offset)) calc(-1 * var(--shadow-text-offset)) var(--shadow-text-blur) var(--color-text-shadow),
      var(--shadow-text-offset) var(--shadow-text-offset) var(--shadow-text-blur) var(--color-text-shadow);
  }
}

@media (max-width: 743px) {
  .modal--work:has(.modal__gallery-scroll > :only-child) .modal__body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }

  .modal--work:has(.modal__gallery-scroll > :only-child) .modal__chrome {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
  }

  .modal--work:has(.modal__gallery-scroll > :only-child) .modal__gallery {
    margin-top: auto;
  }

  .modal--work:has(.modal__gallery-scroll > :only-child) .modal__details {
    margin-bottom: auto;
  }
}

/* Stack work info when gallery width shrinks below the mobile design width. */
@media (max-width: 376px) {
  .modal--work .modal__details {
    flex-direction: column;
  }

  .modal--work .modal__meta,
  .modal--work .modal__description {
    flex: none;
    width: 100%;
  }
}

@media (min-width: 744px) and (max-width: 1279px) {
  .modal--work .modal__back {
    top: var(--space-bio-top-tablet);
  }

  .modal--work .modal__gallery {
    margin-top: calc(var(--space-modal-body-top-tablet) - var(--space-bio-top-tablet) - var(--line-height-body));
  }

  .modal--work .modal__details {
    gap: var(--space-modal-details-gap-tablet);
    margin-top: var(--space-modal-gallery-to-info-tablet);
  }

  .modal--work .modal__meta {
    flex-basis: var(--width-modal-meta-tablet);
    width: var(--width-modal-meta-tablet);
  }

  .modal--work .modal__description {
    flex-basis: var(--width-modal-desc-tablet);
    width: var(--width-modal-desc-tablet);
  }
}

@media (min-width: 1280px) {
  .modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal-overlay);
  }

  .modal--work .modal__chrome {
    display: none;
  }

  .modal__overlay {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(var(--blur-modal-backdrop));
    background: var(--color-modal-tint);
  }

  .modal--work .modal__body {
    position: absolute;
    inset: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: none;
    z-index: var(--z-modal-content);
    padding-bottom: var(--space-page-x-desktop);
  }

  .modal--work .modal__body > * {
    pointer-events: auto;
  }

  .modal--work .modal__details {
    display: contents;
  }

  .modal--work .modal__back {
    position: absolute;
    left: var(--space-page-x-desktop);
    top: 480px;
    z-index: var(--z-modal-content);
    text-shadow: none;
  }

  .modal--work .modal__gallery {
    position: relative;
    width: var(--width-gallery-desktop);
    margin-top: var(--space-bio-top-desktop);
    margin-left: calc(50vw - (var(--canvas-width-desktop) / 2 - 374px));
    margin-right: auto;
    z-index: var(--z-modal-content);
  }

  .modal--work .modal__gallery-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-gallery-gap-desktop);
    width: 100%;
  }

  .modal--work .modal__gallery-cell[data-width="0.5"] {
    width: calc(50% - var(--space-gallery-gap-desktop) / 2);
  }

  .modal--work:has(.modal__gallery-scroll > :only-child) .modal__gallery {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    margin-top: 0;
  }

  .modal--work .modal__meta {
    position: fixed;
    left: var(--space-page-x-desktop);
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-modal-content);
    display: flex;
    flex-direction: column;
    gap: var(--space-nav-gap);
    width: var(--space-content-max-width);
  }

  .modal--work .modal__description {
    position: fixed;
    right: var(--space-nav-right-desktop);
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-modal-content);
    width: var(--space-content-max-width);
    margin: 0;
    text-align: right;
    line-height: var(--line-height-metadata);
    text-shadow: none;
  }

  /* ── Archive modal (desktop) ─────────────────────────────────────────────── */

  .modal--archive .modal__back {
    position: fixed;
    left: var(--space-page-x-desktop);
    top: var(--space-bio-top-desktop);
    z-index: var(--z-modal-content);
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
  }

  .dual-col-gallery {
    position: fixed;
    top: var(--space-bio-top-desktop);
    left: calc(50vw - (var(--canvas-width-desktop) / 2 - 374px));
    z-index: var(--z-modal-content);
    display: flex;
    gap: var(--space-gallery-col-gap);
    width: var(--width-gallery-desktop);
    max-height: calc(100dvh - var(--space-bio-top-desktop));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .dual-col-gallery__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-gallery-row-gap);
    min-width: 0;
  }

  .dual-col-gallery__col--left {
    align-items: flex-end;
  }

  .dual-col-gallery__col--right {
    align-items: flex-start;
  }

  .dual-col-gallery__item {
    display: flex;
    flex-direction: column;
    gap: var(--space-gallery-caption-gap);
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: inherit;
  }

  .dual-col-gallery__col--left .dual-col-gallery__item {
    align-items: flex-end;
  }

  .dual-col-gallery__col--right .dual-col-gallery__item {
    align-items: flex-start;
  }

  .dual-col-gallery__image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-tile);
  }

  .dual-col-gallery__image--placeholder {
    width: 183px;
    aspect-ratio: 4 / 3;
    background: rgba(251, 0, 255, 0.2);
    border-radius: var(--radius-tile);
  }

  .dual-col-gallery__title {
    margin: 0;
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-body);
  }

  .dual-col-gallery__specs {
    line-height: var(--line-height-metadata);
  }

  .dual-col-gallery__specs p {
    margin: 0;
  }
}

/* ── Work tile cursor label ──────────────────────────────────────────────── */

@media (hover: hover) {
  .work-cursor-label {
    position: fixed;
    pointer-events: none;
    z-index: var(--z-tile-hover);
    white-space: nowrap;
    text-shadow:
      calc(-1 * var(--shadow-text-offset)) calc(-1 * var(--shadow-text-offset))
        var(--shadow-text-blur) var(--color-text-shadow),
      var(--shadow-text-offset) var(--shadow-text-offset) var(--shadow-text-blur)
        var(--color-text-shadow);
    opacity: 0;
    transition: opacity 0.1s ease;
  }

  .work-cursor-label--visible {
    opacity: 1;
  }

  .work-cursor-label--guides {
    color: rgba(180, 0, 200, 0.9);
  }
}
