/* ==========================================================
   RIKI IMAMURA — portfolio
   ========================================================== */

:root {
  --bg: #ffffff;
  --fg: #141414;
  --muted: #727272;
  --line: #e4e4e4;
  --placeholder: #f3f3f1;

  --gutter: clamp(20px, 4.2vw, 64px);
  --space-section: clamp(56px, 8vw, 120px);

  /* 欧文は Helvetica Neue / Helvetica（端末内蔵のものを使用・ファイルは配布しない）、なければ Arial。
     和文は源ノ角ゴシック（assets/css/fonts.css。欧文フォントにない文字だけに適用される） */
  --font: "Helvetica Neue", Helvetica, Arial, "Han Sans JP Web", sans-serif;
  --fs-xs: 11px;
  --fs-s: 13px;
  --fs-m: 15px;
  --fs-l: clamp(20px, 2.3vw, 32px);

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: page-in 0.7s var(--ease) both;
}

body.is-leaving {
  animation: page-out 0.24s ease forwards;
}

@keyframes page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes page-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

h1, h2, h3, p, ul, ol, dl, dd, figure {
  margin: 0;
  padding: 0;
}

ul, ol {
  list-style: none;
}

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

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--fg);
  color: var(--bg);
  font-size: var(--fs-s);
}

.skip-link:focus {
  top: 12px;
}

.label {
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.text-link {
  border-bottom: 1px solid currentColor;
  transition: opacity 0.3s;
}

.text-link:hover {
  opacity: 0.5;
}

/* 画像の読み込み後にフェードイン */
img.fade {
  opacity: 0;
  transition: opacity 0.8s var(--ease), transform 1.2s var(--ease);
}

img.fade.is-loaded {
  opacity: 1;
}

/* ---------- header / footer ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  column-gap: clamp(24px, 4vw, 56px);
  padding: 22px var(--gutter);
  background: rgba(255, 255, 255, 0.94);
  font-size: var(--fs-s);
}

.site-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-social {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.site-social img {
  width: 16px;
  height: 16px;
}

.site-title {
  font-weight: 500;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

/* 英語名を主に、日本語名を小さく併記 */
.site-title__ja,
.profile-name__ja {
  margin-left: 0.9em;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.site-title__ja {
  font-size: var(--fs-xs);
  color: var(--fg);
}

.site-nav ul {
  display: flex;
  gap: clamp(18px, 3vw, 44px);
}

.site-nav a,
.lang-switch {
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

.site-nav a {
  transition: color 0.3s;
}

.site-nav a:hover,
.site-nav a[aria-current="page"],
.lang-switch button:hover,
.lang-switch button[aria-pressed="true"] {
  color: var(--fg);
}

.lang-switch {
  display: flex;
  gap: 6px;
}

.lang-switch button {
  letter-spacing: inherit;
  color: var(--muted);
  transition: color 0.3s;
}

/* 狭い画面：名前・SNS・言語切替を1行目、ナビを2行目に配置 */
@media (max-width: 899px) {
  .site-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "identity lang"
      "nav nav";
    column-gap: 12px;
    row-gap: 10px;
  }

  .site-identity {
    grid-area: identity;
    gap: 8px;
  }

  .lang-switch {
    grid-area: lang;
  }

  .site-nav {
    grid-area: nav;
  }

  .site-nav ul {
    flex-wrap: wrap;
    column-gap: 20px;
  }
}

@media (max-width: 599px) {
  .site-header {
    position: static;
    padding-top: 18px;
    padding-bottom: 0;
  }
}

@media (max-width: 359px) {
  .site-header {
    grid-template-areas:
      "identity identity"
      "nav lang";
  }

  .site-nav ul {
    gap: 14px;
  }
}

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}

main {
  flex: 1;
  padding: 0 var(--gutter);
}

main:focus {
  outline: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
  padding: clamp(80px, 12vw, 180px) var(--gutter) 32px;
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--muted);
}

.site-footer__links {
  display: flex;
  gap: 24px;
}

.site-footer a:hover {
  color: var(--fg);
}

/* ---------- WORKS ---------- */

.work-grid {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 72px;
}

.work-card__link {
  display: block;
}

.work-card__media {
  aspect-ratio: var(--ratio, 1 / 1);
  overflow: hidden;
  background: var(--placeholder);
}

.work-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--position, 50% 50%);
}

.work-card__link:hover .work-card__media img {
  transform: scale(1.025);
}

.work-card__caption {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding-top: 16px;
  font-size: var(--fs-s);
}

.work-card__title {
  font-size: var(--fs-s);
  font-weight: 500;
  letter-spacing: 0.12em;
}

.work-card__year {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 760px) {
  .work-grid {
    grid-template-columns: 1fr 1fr;
    column-gap: clamp(32px, 6vw, 120px);
    row-gap: clamp(80px, 9vw, 160px);
    align-items: start;
  }
}

/* ---------- section blocks (detail / about / contact) ---------- */

.block {
  display: grid;
  gap: 20px;
  padding: var(--space-section) 0;
  border-top: 1px solid var(--line);
}

.block__body {
  min-width: 0;
}

@media (min-width: 900px) {
  .block {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
  }

  .block__label {
    grid-column: 1 / 4;
  }

  .block__body {
    grid-column: 4 / 11;
  }

  .block--wide .block__label {
    grid-column: 1 / -1;
    margin-bottom: 16px;
  }

  .block--wide .block__body {
    grid-column: 1 / -1;
  }
}

.prose {
  max-width: 40em;
}

.prose p + p,
.lead p + p {
  margin-top: 1.2em;
}

.lead {
  max-width: 30em;
  font-size: var(--fs-l);
  line-height: 1.5;
  letter-spacing: -0.005em;
}

/* 全ページ共通のページ見出し（PROJECTS / ABOUT / CONTACT など）。
   ページを追加するときも <header class="page-head"><h1 class="page-title"> を使えば揃う。
   写真や本文が早く見えるよう、小さな文字と控えめな余白にしている */
.page-head {
  padding: clamp(28px, 5vw, 72px) 0 clamp(20px, 3vw, 40px);
}

.page-title {
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* 作品詳細の作品名：.page-title と同じスタイル（長い作品名も折り返す） */
.work-title {
  overflow-wrap: anywhere;
}

.page-head__note {
  margin: 32px 0 24px;
  color: var(--muted);
}

/* ---------- PROJECT DETAIL ---------- */

/* 詳細ページの余白（セクション間・画像・前後ナビゲーションで共通） */
[data-page="work"] {
  --work-space: clamp(36px, 4.5vw, 64px);
}

[data-page="work"] .block {
  gap: 12px;
  padding: var(--work-space) 0;
}

.work-head {
  padding: clamp(28px, 5vw, 72px) 0 clamp(16px, 2vw, 28px);
}

.back-link {
  display: inline-block;
  margin-bottom: clamp(16px, 2.5vw, 32px);
  transition: color 0.3s;
}

.back-link:hover {
  color: var(--fg);
}

.work-year {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
}

/* メイン画像：本来の縦横比のまま、縦長・横長どちらも画面内に収める */
.work-hero {
  margin-bottom: var(--work-space);
}

.work-hero .zoom {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: top;
}

.work-hero img,
.work-hero .zoom img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 92vh;
  aspect-ratio: auto;
}

.work-hero figcaption,
figcaption {
  margin-top: 10px;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* 詳細ページの項目は罫線で区切らず、余白で分ける */
.specs > div {
  display: grid;
  grid-template-columns: minmax(7em, 1fr) 2fr;
  gap: 16px;
}

.specs > div + div,
.work .records li + li,
.links li + li {
  margin-top: 14px;
}

.work .records li,
.work .records li:first-child {
  padding: 0;
  border: 0;
}

.specs dt {
  color: var(--muted);
  font-size: var(--fs-s);
}

/* 下部の作品画像（見出しなし） */
.work-photos {
  padding: var(--work-space) 0;
  border-top: 1px solid var(--line);
}

.gallery {
  display: grid;
  gap: clamp(12px, 1.8vw, 28px);
}

@media (min-width: 760px) {
  .gallery {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .gallery__item.is-landscape,
  .gallery__item.is-full {
    grid-column: 1 / -1;
  }
}

.zoom {
  display: block;
  width: 100%;
  cursor: zoom-in;
}

.zoom img {
  width: 100%;
  aspect-ratio: auto 4 / 5;
  background: var(--placeholder);
}

/* 縦長写真を全幅指定したときは中央に収める */
.gallery__item.is-full.is-portrait .zoom img {
  width: auto;
  max-height: 92vh;
  margin: 0 auto;
}

.records li {
  display: grid;
  grid-template-columns: 6em minmax(0, 1fr);
  gap: 2px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.records li:first-child {
  border-top: 1px solid var(--line);
}

.records__year {
  color: var(--muted);
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
  line-height: 2;
}

.records__detail {
  grid-column: 2;
  color: var(--muted);
  font-size: var(--fs-s);
}

@media (max-width: 599px) {
  .records li {
    grid-template-columns: 3.6em minmax(0, 1fr);
  }
}

/* 学歴など、年月と状態をタイトルの上に置く形式 */
.records li.is-stacked {
  grid-template-columns: minmax(0, 1fr);
}

.records li.is-stacked .records__detail {
  grid-column: 1;
}

.records__date {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: var(--fs-s);
}

.links li {
  display: grid;
  gap: 2px;
}

.links__detail {
  color: var(--muted);
  font-size: var(--fs-s);
}

.records-group + .records-group {
  margin-top: 48px;
}

.work .records-group + .records-group {
  margin-top: 32px;
}

[data-page="work"] .site-footer {
  padding-top: clamp(56px, 7vw, 104px);
}

.records-group > .label {
  display: block;
  margin-bottom: 12px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: var(--work-space) 0 0;
  border-top: 1px solid var(--line);
}

.pager__link {
  display: block;
  min-width: 0;
}

.pager__link--next {
  text-align: right;
}

/* 作品名は一覧のキャプションと同じ大きさ */
.pager__title {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.12em;
  overflow-wrap: anywhere;
  transition: opacity 0.3s;
}

.pager__link:hover .pager__title {
  opacity: 0.45;
}

/* ---------- ABOUT ---------- */

.about-intro {
  display: grid;
  gap: 32px;
  padding-bottom: clamp(40px, 5vw, 72px);
}

/* ABOUT はセクション間を少し詰める */
[data-page="about"] .block {
  padding: clamp(40px, 5.5vw, 80px) 0;
}

.about-intro__portrait {
  max-width: 420px;
}

.about-intro__portrait img {
  width: 100%;
  aspect-ratio: auto 4 / 5;
  object-fit: cover;
}

@media (min-width: 900px) {
  .about-intro {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
    align-items: end;
  }

  .about-intro__portrait {
    grid-column: 1 / 5;
  }

  .about-intro__body {
    grid-column: 6 / 12;
  }

  .about-intro--text .about-intro__body {
    grid-column: 4 / 11;
  }
}

/* 名前を大きく、その下に生年月日・年齢を並べる */
.profile {
  display: flex;
  flex-wrap: wrap;
  gap: 24px clamp(40px, 5vw, 72px);
}

.profile > div {
  min-width: 0;
}

.profile__name {
  flex-basis: 100%;
}

.profile dd {
  margin-top: 4px;
  font-size: var(--fs-m);
}

.profile__name dd {
  font-size: var(--fs-l);
  line-height: 1.3;
}

.profile-name__ja {
  font-size: 0.6em;
}

/* 略歴：名前・生年月日・年齢の下に続けて表示 */
.about-bio {
  margin-top: clamp(32px, 4vw, 48px);
}

@media (max-width: 599px) {
  [data-page="about"] .profile > div:not(.profile__name) dd,
  [data-page="about"] .about-bio,
  [data-page="about"] .records__title,
  [data-page="about"] .records__detail,
  [data-page="about"] .records__year,
  [data-page="about"] .records__date {
    font-size: 14px;
  }

  [data-page="about"] .profile > div:not(.profile__name) dt {
    font-size: var(--fs-s);
  }
}

/* ---------- CONTACT ---------- */

/* 見出しのすぐ下は罫線なしで続ける */
[data-page="contact"] .block {
  border-top: 0;
  padding-top: clamp(8px, 2vw, 24px);
}

.contact-list {
  margin-top: 40px;
}

.contact-list li {
  display: grid;
  gap: 4px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.contact-list li:first-child {
  border-top: 1px solid var(--line);
}

.contact-list__value {
  font-size: clamp(17px, 1.6vw, 22px);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

a.contact-list__value {
  transition: opacity 0.3s;
}

a.contact-list__value:hover {
  opacity: 0.45;
}

.contact-note {
  margin-top: 20px;
  color: var(--muted);
  font-size: var(--fs-s);
}

@media (max-width: 599px) {
  [data-page="contact"] .prose,
  [data-page="contact"] .contact-list__value {
    font-size: 14px;
  }
}

/* ---------- lightbox ---------- */

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--fg);
}

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.lightbox::backdrop {
  background: var(--bg);
}

.lightbox__bar,
.lightbox__nav {
  display: flex;
  justify-content: space-between;
  padding: 20px var(--gutter);
}

.lightbox__nav[hidden] {
  display: none;
}

.lightbox button:hover {
  color: var(--fg);
}

.lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 var(--gutter);
}

.lightbox__img {
  max-width: 100%;
  max-height: calc(100% - 32px);
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ---------- Japanese typography ---------- */

:lang(ja) body,
body:lang(ja) {
  line-height: 1.9;
  letter-spacing: 0.04em;
  line-break: strict;
}

:lang(ja) .lead {
  font-size: clamp(18px, 1.9vw, 26px);
  line-height: 1.75;
  letter-spacing: 0.04em;
}

:lang(ja) .profile dd,
:lang(ja) .contact-list__value {
  letter-spacing: 0.02em;
}

:lang(ja) .label {
  letter-spacing: 0.1em;
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  img.fade {
    opacity: 1;
  }
}
