/* css/style.css */
:root {
  --paper: #f7f7f5;
  --ink: #111111;
  --line: rgba(17, 17, 17, 0.16);
  /* 前回版から約1.5倍。中央カードを優先したサイズ */
  --card-width: clamp(330px, 45vw, 645px);
  --card-height: calc(var(--card-width) * 1.333333);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  overflow-x: hidden;
}

body.is-lightbox-open,
body.is-index-open {
  overflow: hidden;
}

button,
a {
  color: inherit;
}

button {
  border: 0;
  font: inherit;
}

.site-header {
  position: fixed;
  z-index: 500;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 82px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 245, 0.82);
  backdrop-filter: blur(12px);
}

.brand,
.index-button,
.close-index,
.gallery-hint {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.brand {
  font-weight: 700;
}

.index-button,
.close-index {
  padding: 12px 0;
  background: transparent;
  cursor: pointer;
}

.index-button:hover,
.close-index:hover {
  opacity: 0.5;
}

.gallery {
  position: relative;
  min-height: 100svh;
  padding-top: 82px;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: pan-y;
}

.carousel {
  position: relative;
  width: 100%;
  height: min(74svh, 760px);
  outline: none;
  touch-action: pan-y;
}

.work-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--card-width);
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 17, 0.2);
  background: #e9e9e5;
  cursor: zoom-in;
  opacity: var(--opacity);
  transform: translate(-50%, -50%) translateX(var(--x)) rotate(var(--rotate)) scale(var(--scale));
  transform-origin: center center;
  transition: transform 420ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 300ms ease;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.06);
}

.work-card img,
.index-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.work-card:focus-visible,
.index-card:focus-visible,
.index-button:focus-visible,
.close-index:focus-visible,
.lightbox-close:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.gallery-hint {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.48;
}

.index-panel {
  position: fixed;
  z-index: 800;
  inset: 0;
  overflow-y: auto;
  padding: 110px 4vw 6vw;
  background: var(--paper);
}

.index-panel-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 36px;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(18px, 3vw, 48px);
  max-width: 1440px;
  margin: 0 auto;
}

.index-card {
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 17, 0.18);
  background: #e9e9e5;
  cursor: zoom-in;
}

.index-top-button {
  position: fixed;
  z-index: 810;
  right: 24px;
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(17, 17, 17, 0.3);
  border-radius: 50%;
  background: #ffffff;
  color: #111111;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.index-top-button:hover {
  background: #f0f0ee;
}

.mobile-lightbox-hint {
  display: none;
}

@media (max-width: 600px) {
  .index-top-button {
    right: 16px;
    bottom: 16px;
  }

  .mobile-lightbox-hint {
    position: fixed;
    z-index: 2;
    left: 50%;
    bottom: 22px;
    display: block;
    transform: translateX(-50%);
    color: #777777;
    font-size: 10px;
    letter-spacing: 0.16em;
    pointer-events: none;
  }
}

.lightbox[hidden],
.index-panel[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(247, 247, 245, 0.96);
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  cursor: zoom-out;
}

.lightbox-stage {
  position: relative;
  z-index: 1;
  height: 95vh;
  max-width: 94vw;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
}

  .lightbox-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    cursor: grab;
    touch-action: pan-y;
  }

  @media (min-width: 601px) {
    .lightbox-stage,
    .lightbox-image {
      cursor: grab;
    }

    .lightbox-stage.is-dragging,
    .lightbox-stage.is-dragging .lightbox-image {
      cursor: grabbing;
    }
  }

  /* ライトボックス内では前後の画像を同時に表示せず、選択画像だけを表示 */
  .lightbox-stage {
    overflow: hidden;
  }

/* ライトボックスの閉じるボタン：トップページ／INDEX共通 */
.lightbox-close {
  position: fixed !important;
  z-index: 10000 !important;
  top: max(16px, env(safe-area-inset-top)) !important;
  right: max(16px, env(safe-area-inset-right)) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  visibility: visible !important;
  opacity: 1 !important;
  width: 48px !important;
  height: 48px !important;
  padding: 0 !important;
  border: 1px solid rgba(17, 17, 17, 0.35) !important;
  border-radius: 50%;
  background: #ffffff !important;
  color: #111111 !important;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

.lightbox-close:hover {
  background: #f0f0ee !important;
}

.lightbox-close:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 3px;
}

@media (max-width: 900px) {
  :root {
    /* スマホの中央カードは画面幅に合わせて大きく表示 */
    --card-width: min(87vw, 465px);
  }

  .lightbox-stage {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: none;
    aspect-ratio: 3 / 4;
  }

  .lightbox-image {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: contain;
  }

  .index-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lightbox-stage {
    height: 88vh;
    max-width: 88vw;
  }

  /* 閉じるボタンは共通の画面右上固定設定を使用 */
}

@media (max-width: 600px) {
  .site-header {
    height: 68px;
    padding: 0 20px;
  }

  .gallery {
    padding-top: 68px;
  }

  .carousel {
    height: 74svh;
  }

  .gallery-hint {
    bottom: 22px;
    font-size: 10px;
  }

  .index-panel {
    padding: 92px 18px 32px;
  }

  .index-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .lightbox-stage {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: none;
    aspect-ratio: 3 / 4;
  }

  .lightbox-image {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: contain;
  }

  /* 閉じるボタンは共通の画面右上固定設定を使用 */
}

@media (prefers-reduced-motion: reduce) {
  .work-card {
    transition: none;
  }
}