/* ========================================
   Work Detail Page Styles
======================================== */

/* ----------------------------------------
   Work Detail Header
---------------------------------------- */
.work-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: var(--color-background);

  @media screen and (min-width: 768px) {
  }
}

.work-header__inner {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  height: 100%;
  padding: 15px var(--content-padding);
  max-width: 1280px;
  margin: 0 auto;
  @media screen and (min-width: 768px) {
    padding: 23px var(--content-padding);
  }
}

.work-header__logo {
  display: flex;
  align-items: center;

  @media screen and (min-width: 768px) {
    margin-top: 20px;
  }

  img {
    height: 33px;
    width: auto;
    @media screen and (min-width: 768px) {
      height: 54px;
    }
  }
}

.work-header__lang {
  display: flex;
  align-items: center;
}

/* ----------------------------------------
   Work Detail Main
---------------------------------------- */
.work-detail {
  padding-top: var(--header-height, 63px);
  --max-width: 814px;
  position: relative;
  z-index: 1;
}

/* ----------------------------------------
   Hero Section
---------------------------------------- */
.work-detail__hero {
  position: relative;
}

.work-detail__hero-image {
  width: 100%;
  aspect-ratio: 3/2;
  overflow: hidden;
  border-radius: 5px;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.work-detail__hero-note {
  font-family: var(--font-primary);
  font-size: 12px;
  line-height: 1.75;
  color: var(--color-text-disabled);
  text-align: right;
  margin-top: 4px;
  margin-bottom: 0;
}

.work-detail__hero-content {
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);

  @media screen and (min-width: 768px) {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
    max-width: 800px;
  }
}

.work-detail__hero-title {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-bold);
  font-size: 28px;
  line-height: 1.4;
  margin-bottom: var(--spacing-sm);

  @media screen and (min-width: 768px) {
    font-size: 40px;
    margin-bottom: var(--spacing-md);
  }
}

.work-detail__hero-artist {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 16px;
  margin-bottom: var(--spacing-xs);

  @media screen and (min-width: 768px) {
    font-size: 18px;
  }
}

.work-detail__hero-material {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-md);

  @media screen and (min-width: 768px) {
    font-size: 16px;
    margin-bottom: var(--spacing-lg);
  }
}

.work-detail__hero-description {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 14px;
  line-height: 1.8;

  @media screen and (min-width: 768px) {
    font-size: 16px;
  }

  p {
    margin: 0;

    &:not(:last-child) {
      margin-bottom: var(--spacing-xs);
    }
  }

  figure,
  .wp-caption {
    max-width: fit-content;
    height: auto;
  }

  img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-block: var(--spacing-xs);
  }
}

/* ----------------------------------------
   Table of Contents
---------------------------------------- */
.work-detail__toc {
  background-color: var(--color-background-alt);
  padding: 23px 20px;

  @media screen and (min-width: 768px) {
    padding: 23px 35px;
  }
}

.work-detail__toc-inner {
  @media screen and (min-width: 768px) {
    max-width: 800px;
  }
}

.work-detail__toc-list {
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc-counter;
}

.work-detail__toc-item {
  border-bottom: 1px solid var(--color-border);
  counter-increment: toc-counter;
}

.work-detail__toc-item a,
.work-detail__toc-item span {
  display: block;
  padding: 6px 0 6px 1.5em;
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 14px;
  text-decoration: none;
  color: var(--color-text);
  position: relative;
  transition: background-color 0.2s ease;

  @media screen and (min-width: 768px) {
    font-size: 16px;
  }

  &::before {
    content: counter(toc-counter) ". ";
    position: absolute;
    left: 0;
  }
}

@media (hover: hover) {
  .work-detail__toc-item a:hover {
    background-color: rgba(0, 0, 0, 0.02);
  }
}

.work-detail__toc-item--disabled span {
  color: var(--color-text-disabled);
}

/* ----------------------------------------
   Section Common Styles
---------------------------------------- */
.work-detail__section {
  margin: var(--spacing-2xl) 0;

  @media screen and (min-width: 768px) {
    margin: 80px 0;
  }

  .container {
    @media screen and (min-width: 768px) {
      max-width: 960px;
    }
  }
}

.work-detail__section-title {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 32px;
  line-height: 1.75;
  margin-bottom: var(--spacing-lg);
  @media screen and (min-width: 768px) {
    font-size: 44px;
    margin-bottom: var(--spacing-xl);
  }
}

.work-detail__section-lead {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);

  @media screen and (min-width: 768px) {
    font-size: 16px;
    margin-bottom: var(--spacing-xl);
  }
}

/* ----------------------------------------
   Artist Section
---------------------------------------- */
.work-detail__artist-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);

  @media screen and (min-width: 768px) {
    flex-direction: row;
    gap: var(--spacing-xl);
    align-items: flex-start;
  }
}

.work-detail__artist-image {
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  margin: 0;
  border-radius: 5px;
  overflow: hidden;

  @media screen and (min-width: 768px) {
    width: 200px;
    height: 200px;
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.work-detail__artist-info {
  flex: 1;
}

.work-detail__artist-name {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 20px;
  margin-bottom: var(--spacing-md);

  @media screen and (min-width: 768px) {
    font-size: 24px;
  }
}

.work-detail__artist-name-kana {
  display: block;
  font-weight: var(--font-weight-regular);
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 4px;

  @media screen and (min-width: 768px) {
    display: inline;
    margin-top: 0;
    margin-left: var(--spacing-sm);
  }
}

.work-detail__artist-bio {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 14px;
  line-height: 1.8;

  @media screen and (min-width: 768px) {
    font-size: 16px;
  }

  figure,
  .wp-caption {
    max-width: fit-content;
    height: auto;
  }

  img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-block: var(--spacing-xs);
  }

  figcaption {
    font-size: 12px;
  }
}

.work-detail__artist-actions {
  margin-top: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;

  @media screen and (min-width: 768px) {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px 32px;
  }
}

.work-detail__artist-action {
  display: block;
  width: 100%;
  padding: 12px 48px;
  background-color: var(--color-background);
  border: 1px solid var(--color-text);
  border-radius: 60px;
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 18px;
  line-height: 1.75;
  color: var(--color-text);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease;

  @media (hover: hover) {
    &:hover {
      background-color: var(--color-background-hover);
    }
  }

  @media screen and (min-width: 768px) {
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    text-align: left;

    @media (hover: hover) {
      &:hover {
        background: none;
        opacity: 0.7;
      }
    }
  }
}

.work-detail__artist-action-arrow {
  display: none;

  @media screen and (min-width: 768px) {
    display: block;
    width: 55px;
    height: auto;
  }
}

/* ----------------------------------------
   Gallery Section
---------------------------------------- */

/* Gallery List - Vertical stack layout */
.work-detail__gallery-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.work-detail__gallery-item {
  margin: 0;
}

/* Landscape item - Single wide image */
.work-detail__gallery-item--landscape {
  img {
    width: 100%;
    aspect-ratio: 352 / 226;
    object-fit: cover;
    border-radius: 4px;
  }
}

/* Portrait pair item - Two vertical images side by side */
.work-detail__gallery-item--portrait-pair .work-detail__gallery-images {
  display: flex;
  gap: 8px;

  img {
    flex: 1;
    min-width: 0;
    aspect-ratio: 172 / 227;
    object-fit: cover;
    border-radius: 4px;
  }
}

.work-detail__gallery-caption {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  font-size: 13px;
  line-height: 1.75;
  color: var(--color-text-muted);
  margin-top: 8px;
  @media screen and (min-width: 768px) {
    text-align: center;
  }
}

/* ----------------------------------------
   Team Section
---------------------------------------- */
.work-detail__team-list {
  display: grid;
  gap: 0;

  @media screen and (min-width: 768px) {
    grid-template-columns: repeat(2, 1fr);
    max-width: 940px;
  }
}

.work-detail__team-item {
  &:not(:first-child) {
    border-top: 1px solid var(--color-border);
    padding-top: 24px;
    margin-top: 24px;

    @media screen and (min-width: 768px) {
      border-top: none;
      padding-top: 0;
      margin-top: 0;
    }
  }

  @media screen and (min-width: 768px) {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 32px;
    padding-right: 40px;

    &:nth-child(even) {
      padding-right: 0;
      padding-left: 40px;
      border-left: 1px solid var(--color-border);
    }

    &:nth-child(n+3) {
      padding-top: 32px;
    }

    &:last-child,
    &:nth-last-child(2):nth-child(odd) {
      border-bottom: none;
      padding-bottom: 0;
    }
  }
}

.work-detail__team-name {
  display: block;
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 20px;
  line-height: 1.75;
}

.work-detail__team-role {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 14px;
  line-height: 1.75;
  margin-top: 14px;
}

.work-detail__team-description {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-text);
  text-align: justify;
  margin-top: 14px;
}

/* ----------------------------------------
   Related Works Section
---------------------------------------- */
.work-detail__related {
  position: relative;
  background-color: var(--color-background-warm);
  padding: 56px 0 80px;

  @media screen and (min-width: 768px) {
    padding: 64px 0 100px;
  }
}

.work-detail__related-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--content-padding);
}

.work-detail__related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;

  @media screen and (min-width: 768px) {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

.work-detail__related-item {
  display: block;
  text-decoration: none;
  color: inherit;
}

.work-detail__related-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 5px;
  background-color: var(--color-card-background);

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.work-detail__related-title {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 18px;
  line-height: 1.75;
  margin-top: 14px;
  margin-bottom: 0;

  @media screen and (min-width: 768px) {
    font-size: 16px;
  }
}

.work-detail__related-artist {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: 18px;
  line-height: 1.75;
  color: var(--color-text);

  @media screen and (min-width: 768px) {
    font-size: 16px;
  }
}

/* ----------------------------------------
   Modal
---------------------------------------- */
.work-detail__modal {
  border: none;
  border-radius: 0;
  padding: 0;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  background: none;

  &:focus {
    outline: none;
  }
}

.work-detail__modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.work-detail__modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.work-detail__modal-content {
  padding: 20px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 80px);
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background-color: var(--color-background-warm);

  @media screen and (min-width: 768px) {
    width: 750px;
    max-width: 750px;
    height: auto;
    max-height: 90dvh;
    padding: 45px;
  }
}

.work-detail__modal-content h3 {
  font-size: 32px;
  font-weight: var(--font-weight-regular);
  line-height: 0.95;
  margin-top: 54px;
  margin-bottom: var(--spacing-lg);

  @media screen and (min-width: 768px) {
    font-size: 44px;
    margin-top: 33px;
  }
}

.work-detail__modal-entry {
  padding-top: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  position: relative;
  font-size: 14px;

  p {
    margin-block: var(--spacing-sm);
    &:empty,
    &:has(> br:only-child) {
      margin-block: 0;
    }
    &:has(span.is-small-text) {
      margin-block: var(--spacing-xs);
    }
  }

  figure,
  .wp-caption {
    max-width: fit-content;
    height: auto;
  }

  img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-block: var(--spacing-xs);
  }

  figcaption {
    font-size: 12px;
  }
}

.work-detail__modal-entry + .work-detail__modal-entry {
  &:before {
    content: "";
    display: block;
    background: #000;
    position: absolute;
    top: 0;
    width: 100%;
    height: 1px;

    @media screen and (min-width: 768px) {
      max-width: 310px;
    }
  }
}

.work-detail__modal-content h4 {
  font-size: 20px;
  font-weight: var(--font-weight-regular);
  margin-bottom: var(--spacing-md);
}

.work-detail__modal-close {
  position: absolute;
  top: 24px;
  right: 20px;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}

/* ----------------------------------------
   Background Lines (Detail Pages)
---------------------------------------- */
body.page-work-detail {
  --bg-lines-top: 212px;
  --bg-lines-width: 100vw;
  @media screen and (min-width: 768px) {
    --bg-lines-top: 268px;
  }
}
