/*
Theme Name: Studio Theme
Theme URI: https://loubte.com
Author: umbitt
Description: Minimal portfolio theme — masonry grid
Version: 4.9.0
License: GNU General Public License v2 or later
Text Domain: studio-theme
*/

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Variables ─── */
:root {
  --bg:      #ffffff;
  --ink:     #0a0a0a;
  --mid:     #555;
  --dim:     #aaa;
  --border:  rgba(0,0,0,0.08);
  --px:      clamp(16px, 3vw, 44px);
  --font:    'Outfit', system-ui, sans-serif;
}

/* ─── Base ─── */
html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 200;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ─── Page ─── */
#page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ════════════════════════════════════════
   HEADER
════════════════════════════════════════ */
#site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px var(--px);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

#site-logo {
  display: flex;
  align-items: center;
  color: var(--ink);
  flex-shrink: 0;
}

#site-logo .custom-logo {
  height: 28px;
  width: auto;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.04em;
}

#site-tagline { display: none; } /* show only if description is set */
#live-time { font-variant-numeric: tabular-nums; color: var(--ink); }

/* ════════════════════════════════════════
   MASONRY GRID
════════════════════════════════════════ */
#works-masonry {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  grid-auto-flow: dense;
  flex: 1;
  padding: 24px clamp(14px, 2vw, 28px);
  gap: 8px 0;
}

.masonry-col { display: contents; } /* 後方互換: 古いPHPテンプレート用 */

/* ─── Each Work Item ─── */
.masonry-item {
  display: block;
  margin-bottom: 0;
  cursor: pointer;
  padding: 0 clamp(10px, 1.5vw, 20px);
}

/* Image */
.masonry-img {
  position: relative;
  width: 100%;
  overflow: hidden;
  margin-bottom: 8px;
  /* 3:2 アスペクト比で高さを揃え、ズレを防ぐ */
  aspect-ratio: 3 / 2;
  background: transparent;
  /* reveal: starts hidden — opacity only, transformはimgに任せる */
  opacity: 0;
  transition: opacity 0.7s ease;
}

/* ─── Fluid Gradient Canvas ─── */
.masonry-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.masonry-item:hover .masonry-canvas {
  transform: scale(1.04);
}

.masonry-img img {
  display: none;
}

/* Body (title + scope + initial) */
.masonry-body {
  padding: 0 2px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: 0.12s;
}

/* Revealed state */
.masonry-item.revealed .masonry-img {
  opacity: 1;
  transition-delay: var(--reveal-delay, 0ms);
}

.masonry-item.revealed .masonry-body {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--reveal-delay, 0ms) + 120ms);
}

/* ─── Title ─── */
.masonry-title {
  font-size: clamp(11px, 1.15vw, 15px);
  font-weight: 300;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 8px;
  min-height: 1.25em; /* スクランブル中もレイアウトが崩れないよう確保 */
}

/* スクランブル中のランダム文字 */
.masonry-title .sc-rand {
  display: inline-block;
  color: var(--dim);
  opacity: 0.7;
}

/* 確定済みの文字 */
.masonry-title .sc-done {
  display: inline-block;
  color: var(--ink);
}

/* 未到達の空スペース */
.masonry-title .sc-empty {
  display: inline-block;
  opacity: 0;
}

/* ─── Scope tags ─── */
.masonry-scope {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 10px;
}

.masonry-scope span {
  font-size: 9.5px;
  color: var(--mid);
  font-weight: 200;
  line-height: 1.8;
  letter-spacing: 0.01em;
}

/* ─── Site initial letter ─── */
.masonry-initial {
  display: block;
  font-size: 13px;
  font-weight: 200;
  color: var(--dim);
  letter-spacing: -0.02em;
  margin-top: 8px;
  opacity: 0.5;
}

/* ════════════════════════════════════════
   FOOTER
════════════════════════════════════════ */
#site-footer {
  border-top: 1px solid var(--border);
  padding: 32px var(--px) 28px;
  margin-top: auto;
}

#footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

#footer-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#footer-tagline {
  font-size: 10px;
  color: var(--mid);
  letter-spacing: 0.04em;
}

#footer-time {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

#footer-nav ul {
  display: flex;
  gap: 24px;
}

#footer-nav ul li a {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--mid);
  transition: color 0.2s;
}

#footer-nav ul li a:hover,
#footer-nav ul li.current-menu-item a { color: var(--ink); }

#footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.footer-copy {
  font-size: 9px;
  color: var(--ink);
  letter-spacing: 0.04em;
}

#footer-social {
  display: flex;
  gap: 16px;
}

#footer-social a {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.06em;
  transition: color 0.2s;
}

#footer-social a:hover { color: var(--ink); }

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 1100px) {
  #works-masonry { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 800px) {
  #works-masonry { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 520px) {
  #works-masonry { grid-template-columns: repeat(2, 1fr); }
  #footer-inner { flex-direction: column; }
  #footer-nav ul { flex-wrap: wrap; gap: 12px; }
}

/* ════════════════════════════════════════
   DARK MODE
════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:     #0a0a0a;
    --ink:    #efefef;
    --mid:    #888;
    --dim:    #555;
    --border: rgba(255,255,255,0.08);
  }
}

[data-theme="dark"] {
  --bg:     #0a0a0a;
  --ink:    #efefef;
  --mid:    #888;
  --dim:    #555;
  --border: rgba(255,255,255,0.08);
}

[data-theme="light"] {
  --bg:      #ffffff;
  --ink:     #0a0a0a;
  --mid:     #555;
  --dim:     #aaa;
  --border:  rgba(0,0,0,0.08);
}

/* ─── Theme Toggle Button ─── */
#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  outline: none;
  transition: opacity 0.2s ease;
}

#theme-toggle:hover { opacity: 0.5; }

#icon-sun,
#icon-moon {
  width: 18px;
  height: 18px;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

/* ライトモード: 太陽を表示、月を非表示 */
#icon-sun  { opacity: 1; transform: scale(1); }
#icon-moon { opacity: 0; transform: scale(0.7); }

/* ダークモード: 月を表示、太陽を非表示 */
[data-theme="dark"] #icon-sun,
.is-dark #icon-sun  { opacity: 0; transform: scale(0.7); }
[data-theme="dark"] #icon-moon,
.is-dark #icon-moon { opacity: 1; transform: scale(1); }

/* ════════════════════════════════════════
   INNER PAGES
════════════════════════════════════════ */
.inner-page {
  padding: clamp(40px, 6vw, 80px) var(--px);
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.inner-page-header h1 {
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 200;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 16px;
  text-align: center;
}

.inner-content {
  max-width: 480px;
  font-size: 13px;
  line-height: 1.85;
  color: var(--mid);
  font-weight: 200;
}

/* ─── Single Work Canvas Image ─── */
.single-work-canvas-img {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  margin-bottom: 48px;
}

.single-work-canvas-img .masonry-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: none;
}

/* ─── Single Work ─── */
.single-work-wrap {
  padding: clamp(32px, 5vw, 72px) var(--px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

/* Back link */
.work-back {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 40px;
  transition: color 0.2s;
}
.work-back:hover { color: var(--ink); }

.single-work-title {
  font-size: clamp(20px, 4vw, 42px);
  font-weight: 200;
  letter-spacing: -0.03em;
  line-height: 1;
  text-align: center;
  margin-bottom: 24px;
  width: 100%;
}

.single-work-meta {
  font-size: 9.5px;
  color: var(--dim);
  letter-spacing: 0.06em;
  margin-bottom: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.work-link {
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s;
}
.work-link:hover { opacity: 0.6; }

.single-work-scope {
  margin-bottom: 36px;
}

.scope-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 8px;
}

.single-work-scope p {
  font-size: 11px;
  color: var(--mid);
  line-height: 1.9;
}

.single-work-body {
  width: 100%;
  font-size: 13px;
  line-height: 1.85;
  color: var(--mid);
  margin-bottom: 48px;
}

/* コンテンツ内の画像（wp-block-image など） */
.single-work-body img {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 4px;
}

/* ★ アイキャッチ（.wp-post-image）をシングルページで非表示 */
.single-template-default .wp-post-image,
.single-work .wp-post-image {
  display: none;
}

/* ════════════════════════════════════════
   CUSTOM CURSOR
════════════════════════════════════════ */
*, *::before, *::after { cursor: none !important; }

#custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.3s ease,
    border-color 0.3s ease;
  will-change: transform;
}

.cursor-label {
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--bg);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-weight: 300;
  user-select: none;
}

#custom-cursor.cursor--view {
  width: 72px;
  height: 72px;
  background: var(--ink);
  border-color: var(--ink);
}

#custom-cursor.cursor--view .cursor-label {
  opacity: 1;
}

#custom-cursor.cursor--link {
  width: 16px;
  height: 16px;
  background: var(--ink);
  border-color: var(--ink);
}

/* ════════════════════════════════════════
   PAGE TRANSITION CURTAIN
════════════════════════════════════════ */
#page-curtain {
  position: fixed;
  inset: 0;
  background: var(--ink);
  z-index: 9000;
  transform: translateY(0%);
  transition: transform 0.5s cubic-bezier(0.76, 0, 0.24, 1);
}

#page-curtain.curtain--out {
  transform: translateY(-100%);
}

#page-curtain.curtain--in {
  transform: translateY(0%);
}

