/*
Theme Name: Yuransen Graphic
Description: 遊覧船グラフィック ポートフォリオサイト用テーマ（statichtml4からの変換）
Author: Yuransen Graphic
Version: 1.0.0
Text Domain: yuransen-graphic
*/

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg: #ffffff;
  --card-bg: #ffffff;
  --text: #1e2f36;
  --text-soft: #4b6570;
  --accent: #2c5c6b;
  --border: rgba(30, 47, 54, 0.12);
  --header-h: 84px;
  --sidebar-w: 220px;
  --gap: 28px;
  --frame: 2px;
  --arrow-size: 56px;
  --arrow-stroke: 1.5px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ===== Header ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px;
}

.site-logo {
  display: block;
  flex-shrink: 0;
}

.site-logo img {
  display: block;
  /* 幅を固定するとロゴの実寸より小さい画像が拡大表示されてぼやけるため、
     実寸を上限(401px)まで許容しつつ、それより大きい画像だけ縮小する */
  width: auto;
  max-width: 401px;
  height: auto;
}

/* モバイル用ロゴが設定されている場合の出し分け。
   未設定(.site-logo-mobileが無い)ときは通常のロゴがそのまま表示される。 */
.site-logo-mobile {
  display: none;
}

/* min-width:0で本来のflexアイテムの最小幅制限を外し、max-width:100%で
   親(.site-header)の幅を超えないようにする。この2つがあることで、
   ナビの中身(ul)が入りきらないときにJSがscrollWidth > clientWidthで
   検知できるようになる(=文字数が増えて収まらなくなったら自動でハンバーガーに切り替える仕組み) */
.main-nav {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.main-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 32px;
  margin: 0;
  padding: 0;
}

.main-nav a {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: border-color 0.25s ease;
  white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.is-active,
.main-nav li.current-menu-item a,
.main-nav li.current_page_item a,
.main-nav li.current-menu-parent a,
.main-nav li.current_page_parent a {
  border-color: var(--accent);
}

/* ハンバーガーボタン。通常は非表示で、JSがナビの入りきらなさを検知したときだけ
   .site-header に .nav-collapsible が付き、表示に切り替わる */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
}

.site-header.nav-collapsible .nav-toggle {
  display: flex;
}

.site-header.nav-collapsible .main-nav ul {
  display: none;
}

.site-header.nav-collapsible .main-nav.is-open ul {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  overflow: visible;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 160px;
  gap: 12px;
  padding: 20px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(30, 47, 54, 0.08);
  z-index: 10;
}

/* mobile category toggle button, hidden on desktop */
.category-toggle {
  display: none;
}

/* ===== Layout ===== */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 32px 80px;
}

/* ===== Category filter (centered, above the grid) ===== */
.category-filter {
  text-align: center;
  margin: 0 0 32px;
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 28px;
}

.category-list a {
  display: block;
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 4px 0;
  color: var(--text-soft);
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.category-list a:hover,
.category-list a.is-active {
  color: var(--text);
  border-color: var(--accent);
}

/* ===== Portfolio grid: 235px square タイル、edge-to-edge =====
   固定 repeat(5, 235px) だと、5列ぶん(1175px)より画面が狭い場合に
   横にはみ出してしまう(900px前後〜1240px弱の間で発生していた)。
   auto-fill + minmax で、どの画面幅でも収まる列数に自動で折り返す。 */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(235px, 100%), 1fr));
  gap: 0;
  justify-content: center;
}

.work-card {
  display: block;
  position: relative;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.work-card:hover {
  z-index: 2;
}

.work-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.work-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.work-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.4s ease, transform 0.4s ease;
}

.work-card:hover .work-thumb img {
  filter: blur(3px) brightness(0.85);
  /* ぼかしが要素の端で透明側をサンプルして縁が明るく見えるのを防ぐため、
     ホバー時だけ少し拡大してぼかしの逃げ場を作る */
  transform: scale(1.1);
}

.work-overlay-title {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.7;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.work-card:hover .work-overlay-title {
  opacity: 1;
}

/* ===== Work gallery (single page, multiple images) =====
   画像ごとに縦横比が異なるため、高さは固定し幅は比率どおりに可変させる。
   矢印は左右のフレックス隣接要素として並べているだけなので、
   画像の実際の描画幅に応じて自動的に位置が追従する。
   .work-detail の幅(720px)より画像が横に広くなるケースがあるため、
   .gallery-wrap はビューポート全幅までブリードさせて中央寄せしている。 */
.gallery-wrap {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: 16px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.work-gallery[data-mode="fit"] {
  /* 585px = 従来の表示高さ。矢印・余白・最横長画像(16:9)の合計幅が
     ビューポート幅を超えないよう、狭い画面では高さ側を縮めて安全側に倒す */
  height: min(585px, calc((100vw - 220px) / 1.778));
  flex-shrink: 0;
}

/* viewportが実際のクリップ枠。トラックを画像1枚分横に動かして
   現在の画像を押し出しながら次の画像を引き込む(旧statichtml3のtranslateX方式)。
   画像ごとに横幅が違うので、遷移中だけJSでviewport幅を固定してクリップさせている */
.work-gallery[data-mode="fit"] .gallery-viewport {
  height: 100%;
  width: fit-content;
  overflow: hidden;
}

.work-gallery[data-mode="fit"] .gallery-track {
  height: 100%;
  width: fit-content;
  display: flex;
  align-items: stretch;
}

.work-gallery[data-mode="fit"] .gallery-image {
  height: 100%;
  width: auto;
  max-width: none;
  display: block;
  flex: none;
}

.gallery-arrow {
  flex: none;
  width: var(--arrow-size);
  height: var(--arrow-size);
  border: none;
  background: none;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.gallery-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke-width: var(--arrow-stroke);
}

.gallery-arrow svg polyline {
  vector-effect: non-scaling-stroke;
}

.gallery-arrow:hover { opacity: 0.6; }

@media (max-width: 900px) {
  :root { --arrow-size: 26px; }

  /* スマートフォン表示では画像が小さくなりすぎるため高さを1.5倍、
     さらにその高さを130%(x1.3)に拡大。
     ただし横長(16:9)画像だとその分だけ横にはみ出しやすくなるので、
     矢印を画像の左右から下に移動して、横方向に必要な余白を減らしている */
  .work-gallery[data-mode="fit"] {
    height: calc((100vw - 96px) / 1.778 * 1.5 * 1.3);
    order: 1;
    flex-basis: 100%;
    /* 画像より枠(flex-basis:100%)のほうが横に広くなるケースがあるため、
       枠の中で画像を中央寄せする(指定しないと左寄せになってしまう) */
    display: flex;
    justify-content: center;
  }

  .gallery-wrap {
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 12px;
  }

  .gallery-prev { order: 2; }
  .gallery-next { order: 3; }
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 0 32px;
}

.gallery-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.gallery-dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 64px;
  font-size: 14px;
}

.pagination a,
.pagination span {
  padding: 6px 12px;
  color: var(--text-soft);
}

.pagination a:hover { color: var(--text); }
.pagination .is-current,
.pagination .current { color: var(--text); font-weight: 700; }
.pagination .dots { padding: 6px 4px; }

/* ===== Single work text ===== */
.work-detail {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 32px 100px;
}

.work-detail h1 {
  font-size: 20px;
  font-weight: 500;
  text-align: center;
  margin: 8px 0 24px;
}

.work-detail .desc {
  line-height: 2;
  color: var(--text-soft);
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 40px;
  font-size: 13px;
  color: var(--text-soft);
}

/* ===== Static pages (About / Contacts) ===== */
.page-content {
  flex: 1;
  padding: 40px 0 100px;
  max-width: 640px;
  margin-left: calc(var(--sidebar-w) + 48px);
}

.page-content h1 {
  font-size: 24px;
  margin-bottom: 24px;
}

.page-content p {
  line-height: 2;
  color: var(--text-soft);
  margin-bottom: 1.4em;
}

.contact-form { margin-top: 24px; }
.contact-form label {
  display: block;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 20px;
}
.contact-form input,
.contact-form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 2px;
}
.contact-form textarea { resize: vertical; }
.contact-form button {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.1em;
  padding: 10px 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 2px;
  cursor: pointer;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 32px;
  font-size: 12px;
  color: var(--text-soft);
}

/* ===== Mobile ===== */
@media (max-width: 900px) {
  :root { --gap: 16px; }

  .site-header {
    padding: 16px 20px;
    flex-direction: column;
    align-items: center;
    gap: 28px;
  }
  .layout { padding: 0 20px 60px; }
  .page-content { margin-left: 0; max-width: none; }

  .main-nav ul { gap: 24px; } /* 現在(16px)の150% */
  .main-nav a { font-size: 14px; }

  /* ロゴは280pxを上限に、狭い画面では画面幅の80%程度まで縮めて
     画面からはみ出さないようにする。ロゴ・ナビともヘッダー内で中央寄せ */
  .site-logo img {
    width: min(280px, 80vw);
  }

  /* モバイル用ロゴが設定されている(.has-mobile-logo)ときだけ、
     ギャラリーの切り替えと同じ900px以下で入れ替える。
     未設定の場合はこのルールが効かず、通常のロゴがそのまま表示され続ける */
  .site-logo.has-mobile-logo .site-logo-desktop {
    display: none;
  }
  .site-logo.has-mobile-logo .site-logo-mobile {
    display: block;
  }

  /* モバイル用ロゴは実寸の70%で表示(等倍だと縁がぼやけて見えるため)。
     ただし画面からはみ出さないよう、280px/画面幅80%の上限は従来どおり優先する */
  .site-logo-mobile img {
    width: min(calc(var(--mobile-logo-native-width, 400px) * 0.7), 280px, 80vw);
  }

  .category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    letter-spacing: 0.1em;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
  }

  .category-toggle .arrow {
    display: inline-block;
    font-size: 2.5em;
    line-height: 1;
    transition: transform 0.2s ease;
  }

  .category-toggle[aria-expanded="true"] .arrow {
    transform: rotate(180deg);
  }

  .category-filter {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin: 0;
    text-align: left;
  }

  .category-filter.is-open {
    max-height: 500px;
    padding-bottom: 16px;
  }

  .category-list {
    justify-content: flex-start;
    gap: 8px 16px;
    padding-top: 16px;
  }

  .portfolio-grid {
    padding-top: 20px;
  }
}
