/* =========================
   Reset / Base
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* grid density */
  --grid-cols: 8;         /* 旧: メディアクエリ用に残す */
  --grid-columns: 8;      /* 新: gallery.js が上書きする */
  --grid-gap: 0px;        /* gallery.js が上書きする */

  --header-h: 50px;

  /* ===== News Grid Overlay Knobs =====
     Scope: /news (Grid)
     Goal : overlay layout tunable by knobs
  */

  /* hover zoom */
  --news-card-zoom: 1.06;

  /* overlay band */
  --news-grid-ov-bg: rgba(255,255,255,0.55);
  --news-grid-ov-blur: 2px;

  /* overlay padding */
  --news-grid-ov-pad-t: 14px;
  --news-grid-ov-pad-r: 12px;
  --news-grid-ov-pad-b: 26px;  /* keep date clear */
  --news-grid-ov-pad-l: 12px;

  /* overlay min height */
  --news-grid-ov-min-h: 64px;

  /* title typography */
  --news-grid-title-size: 13px;
  --news-grid-title-weight: 600;
  --news-grid-title-lh: 1.2;
  --news-grid-title-tracking: 0.01em;

  /* title spacing */
  --news-grid-title-mt: 0px;
  --news-grid-title-mb: 0px;
  --news-grid-title-pt: 0px;
  --news-grid-title-pb: 0px;

  /* date typography */
  --news-grid-date-size: 11px;
  --news-grid-date-lh: 1.1;
  --news-grid-date-opacity: 0.85;
  --news-grid-date-tracking: 0.0em;

  /* date placement */
  --news-grid-date-right: 4px;
  --news-grid-date-bottom: 4px;

  /* date chip */
  --news-grid-date-chip-bg: rgba(255,255,255,0.85);
  --news-grid-date-chip-pad-y: 2px;
  --news-grid-date-chip-pad-x: 4px;
  --news-grid-date-chip-radius: 999px;

  /* no-thumb fallback */
  --news-fallback-logo-scale: 0.58;

  /* News List thumb fit: cover / contain */
  --news-list-thumb-fit: cover;

  /* ===== /News Grid Overlay Knobs ===== */

  --text: #333;
  --bg: #fff;
  --border: #eee;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: var(--text);
}

ul {
  list-style: none;
}

#gallery-container {
  width: 100%;
  margin-top: var(--header-h, 60px);
  padding: 0;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
}

/* ===== Grid view ===== */
#gallery-container.grid-view {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 4), minmax(0, 1fr));
  gap: var(--grid-gap, 0px);
}

#gallery-container.grid-view .gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.2) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    linear-gradient(135deg, #ffffff 0%, #f4f4f4 71%, #f0f0f0 100%);

  /* ===== Grid Thumbnail Tuning Knobs =====
     調整はまずここだけ触る
     - 画像余白
     - 影量
     - 縦横正方形ごとの見せ方
  ===================================== */
  --grid-thumb-shadow-1-x: 12px;
  --grid-thumb-shadow-1-y: 12px;
  --grid-thumb-shadow-1-blur: 18px;
  --grid-thumb-shadow-1-color: rgba(0, 0, 0, 0.2);
  --grid-thumb-shadow-2-x: 4px;
  --grid-thumb-shadow-2-y: 4px;
  --grid-thumb-shadow-2-blur: 8px;
  --grid-thumb-shadow-2-color: rgba(0, 0, 0, 0.07);
  --grid-thumb-shadow-3-x: 2px;
  --grid-thumb-shadow-3-y: 2px;
  --grid-thumb-shadow-3-blur: 3px;
  --grid-thumb-shadow-3-color: rgba(0, 0, 0, 0.07);

  --grid-thumb-inset-portrait: 33px;
  --grid-thumb-inset-landscape: 32px;
  --grid-thumb-inset-square: 55px;
  --grid-thumb-inset-default: 36px;
}

#gallery-container.grid-view .gallery-item .thumb-frame {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  width: fit-content;
  height: fit-content;
  z-index: 1;
  transform: scale(1);
  transition: transform 0.22s ease;
}

#gallery-container.grid-view .gallery-item .thumb-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.6) 0%,
      rgba(255, 255, 255, 0.12) 50%,
      rgba(255, 255, 255, 0) 100%
    ),
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.5) 0.1%,
      rgba(255, 255, 255, 0.1) 15%,
      rgba(255, 255, 255, 0) 30%
    );
}

#gallery-container.grid-view .gallery-item img.thumb-img {
  position: relative;
  z-index: 1;
  display: block;
  width: auto;
  height: auto;

  box-shadow:
    var(--grid-thumb-shadow-1-x, 3px)
    var(--grid-thumb-shadow-1-y, 3px)
    var(--grid-thumb-shadow-1-blur, 12px)
    var(--grid-thumb-shadow-1-color, rgba(0, 0, 0, 0.07)),
    var(--grid-thumb-shadow-2-x, 0px)
    var(--grid-thumb-shadow-2-y, 1px)
    var(--grid-thumb-shadow-2-blur, 4px)
    var(--grid-thumb-shadow-2-color, rgba(0, 0, 0, 0.12)),
    var(--grid-thumb-shadow-3-x, 0px)
    var(--grid-thumb-shadow-3-y, 1px)
    var(--grid-thumb-shadow-3-blur, 2px)
    var(--grid-thumb-shadow-3-color, rgba(0, 0, 0, 0.08));
}

#gallery-container.grid-view .gallery-item.is-portrait .thumb-frame {
  height: calc(100% - var(--grid-thumb-inset-portrait, 24px));
  width: fit-content;
  max-width: calc(100% - var(--grid-thumb-inset-portrait, 24px));
  max-height: calc(100% - var(--grid-thumb-inset-portrait, 24px));
}

#gallery-container.grid-view .gallery-item.is-portrait img.thumb-img {
  width: auto;
  height: 100%;
  max-width: none;
  max-height: none;
}

#gallery-container.grid-view .gallery-item.is-landscape .thumb-frame {
  width: calc(100% - var(--grid-thumb-inset-landscape, 36px));
  height: fit-content;
  max-width: calc(100% - var(--grid-thumb-inset-landscape, 36px));
  max-height: calc(100% - var(--grid-thumb-inset-landscape, 36px));
}

#gallery-container.grid-view .gallery-item.is-landscape img.thumb-img {
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
}

#gallery-container.grid-view .gallery-item.is-square .thumb-frame {
  width: calc(100% - var(--grid-thumb-inset-square, 56px));
  height: calc(100% - var(--grid-thumb-inset-square, 56px));
  max-width: calc(100% - var(--grid-thumb-inset-square, 56px));
  max-height: calc(100% - var(--grid-thumb-inset-square, 56px));
}

#gallery-container.grid-view .gallery-item.is-square img.thumb-img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

/* 判定前の初期表示は landscape を基準にする */
#gallery-container.grid-view .gallery-item:not(.is-portrait):not(.is-landscape):not(.is-square) .thumb-frame {
  width: calc(100% - var(--grid-thumb-inset-default, 36px));
  height: fit-content;
  max-width: calc(100% - var(--grid-thumb-inset-default, 36px));
  max-height: calc(100% - var(--grid-thumb-inset-default, 36px));
}

#gallery-container.grid-view .gallery-item:not(.is-portrait):not(.is-landscape):not(.is-square) img.thumb-img {
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
}

/* featured badge retired */
#gallery-container.grid-view .gallery-item::before {
  content: none;
}

#gallery-container.grid-view .gallery-item.is-new::after {
  content: "NEW";
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
  pointer-events: none;
}

#gallery-container.grid-view .gallery-item:hover .thumb-frame { transform: scale(1.03); }
#gallery-container.grid-view .item-info { display: none; }

/* ===== List view ===== */
#gallery-container.list-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#gallery-container.list-view .gallery-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: auto;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

#gallery-container.list-view .gallery-item img.thumb-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
}

#gallery-container.list-view .item-info {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  padding: 0;
}

#gallery-container.list-view .item-info h3,
#gallery-container.list-view .item-info p {
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#gallery-container.list-view .item-info h3 {
  font-size: 14px;
  font-weight: 600;
}

#gallery-container.list-view .item-info p {
  font-size: 12px;
  opacity: 0.8;
}

/* ===== Works Detail Static Tuning Knobs =====
   調整はまずここだけ触る
   - 詳細メイン画像の影
   - 連番サムネのサイズと間隔
========================================== */
body.works-detail-page {
  --works-detail-main-shadow-x: 4px;
  --works-detail-main-shadow-y: 4px;
  --works-detail-main-shadow-blur: 0px;
  --works-detail-main-shadow-color: rgba(0, 0, 0, 0.1);

  --works-detail-thumb-size: 56px;
  --works-detail-thumb-gap: 12px;
}

/* =========================
   Detail overlay (existing)
========================= */

/* ===== Moved: Detail Overlay styles (canonical: css/overlay.css) ===== */

/* =========================
   Responsive: grid density
========================= */
@media screen and (max-width: 1199px) {
  :root { --grid-cols: 4; --grid-columns: 4; }
}
@media screen and (max-width: 899px) {
  :root { --grid-cols: 3; --grid-columns: 3; }
}
@media screen and (max-width: 599px) {
  :root { --grid-cols: 2; --grid-columns: 2; }
}

/* ===== Footer Copyright ===== */
#site-copyright {
  position: fixed;
  right: 14px;
  bottom: 14px;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0em;
  opacity: 0.55;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== Works Detail Static (match overlay) ===== */
body.works-detail-page .work-detail{
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  padding: calc(var(--header-h) + 20px) 0 40px;
  box-sizing: border-box;
}

body.works-detail-page .work-detail__grid{
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  column-gap: 20px;
  row-gap: 12px;
  align-items: stretch;
}

body.works-detail-page #work-main-image.work-detail__main{
  display: block;
  width: 100%;
  height: auto !important;
  max-height: 82vh;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(var(--works-detail-main-shadow-x, 0px) var(--works-detail-main-shadow-y, 4px) var(--works-detail-main-shadow-blur, 12px) var(--works-detail-main-shadow-color, rgba(0, 0, 0, 0.14)));
}

body.works-detail-page #work-thumbs.work-detail__thumbs{
  display: flex;
  gap: var(--works-detail-thumb-gap, 8px);
  overflow-x: auto;
  padding-bottom: 4px;
  margin-top: 12px;
  flex-wrap: nowrap;
  align-items: center;
}

body.works-detail-page .work-thumb{
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  opacity: 0.9;
}
body.works-detail-page .work-thumb:hover{ opacity: 1; }

body.works-detail-page .work-thumb img{
  width: var(--works-detail-thumb-size, 56px);
  height: var(--works-detail-thumb-size, 56px);
  object-fit: cover;
  display: block;
  border-radius: 2px;
}

body.works-detail-page .work-detail__info{
  margin: 0;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

body.works-detail-page .work-detail__title{
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 10px;
}

body.works-detail-page .work-detail__meta{
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
  opacity: .9;
}

body.works-detail-page .work-detail__desc{
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
}

body.works-detail-page .work-detail__back{
  margin: 12px 0 0 0;
  font-size: 12px;
  line-height: 1;
  opacity: .8;
}

/* related: same as overlay */
body.works-detail-page .related-works{
  margin-top: auto;
  padding-top: 20px;
}

body.works-detail-page .related-works h3{
  margin: 0 0 10px;
  font-size: 11px;
  opacity: 0.7;
  font-weight: 200;
  line-height: 1.2;
}

body.works-detail-page .related-grid{
  display: grid;
  grid-template-columns: repeat(4, 71px);
  gap: 12px;
}

body.works-detail-page .related-item{
  display: block;
  width: 71px;
  height: 71px;
  overflow: hidden;
  border-radius: 6px;
}

body.works-detail-page .related-item img{
  display: block;
  width: 71px;
  height: 71px;
  object-fit: contain;
  object-position: center;
}

body.works-detail-page .related-title{ display: none; }

@media screen and (max-width: 820px){
  body.works-detail-page .work-detail{
    width: calc(100% - 16px);
    padding: calc(var(--header-h) + 20px) 0 32px;
  }

  body.works-detail-page .work-detail__grid{
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: 12px;
  }

  body.works-detail-page .work-detail__info{
    max-width: none;
    height: auto;
  }
}

/* ===== Works Detail Static: Tags ===== */
body.works-detail-page [data-role="detail-tags"]{
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  margin:10px 0 0 0;
  padding:0;
}
body.works-detail-page .detail-tag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 6px;
  border:1px solid rgba(0,0,0,0.18);
  border-radius:777px;
  background:rgba(0,0,0,0.02);
  color:#333;
  text-decoration:none;
  font-size:10px;
  line-height:1;
  letter-spacing:0.01em;
}
body.works-detail-page .detail-tag:hover{
  background:rgba(0,0,0,0.06);
  border-color:rgba(0,0,0,0.26);
  color:#111;
}
/* ===== /Works Detail Static: Tags ===== */

/* ===== Works Detail Static: Close button (fixed) ===== */
body.works-detail-page #close-work.work-close{
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 12px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;
  font-size: 28px;
  line-height: 1;
  text-decoration: none;
  color: inherit;

  opacity: 0.85;
  z-index: 2001;

  background: transparent;
  border: 0;
  cursor: pointer;
}

body.works-detail-page #close-work.work-close:hover{ opacity: 1; }
/* ===== /Works Detail Static: Close button (fixed) ===== */
