/* =====================================================================
 *  QuTech Lab — iPhone ホーム画面風ポートフォリオ
 * ===================================================================== */
:root {
  --bg: #050a12;
  --ink: #eaf6ff;
  --ink-dim: rgba(234, 246, 255, 0.62);
  --cyan: #67d9ff;
  --cyan-soft: #bfe5ff;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.18);
  /* iOS ホーム画面の実寸（1pt = 1px）: アイコン 60pt・列間 32pt・行間 18pt・角丸 22.37% */
  --icon: 60px;
  --icon-radius: 22.37%;
  --cols: 4;
  --gap-x: 32px;
  --gap-y: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Helvetica Neue", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
a { color: inherit; }

/* ---------- 壁紙（iOS 18 / iPhone 16 デフォルト壁紙の CSS 再現） ---------- */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(80% 55% at 10% -5%, #b4ecff 0%, rgba(180, 236, 255, 0) 65%),
    radial-gradient(70% 50% at 90% 5%, #2f6fe0 0%, rgba(47, 111, 224, 0) 70%),
    radial-gradient(90% 50% at 20% 100%, #ff63b0 0%, #d83fa4 35%, rgba(216, 63, 164, 0) 75%),
    radial-gradient(60% 45% at 100% 95%, #5d2fb8 0%, rgba(93, 47, 184, 0) 70%),
    linear-gradient(180deg, #4a86e3 0%, #4e69d2 40%, #7d4dc2 70%, #5f2b93 100%);
}
/* 中央を斜めに横切るオレンジ〜ピーチの光（回転した楕円をぼかして描く） */
.wallpaper::before,
.wallpaper::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.wallpaper::before {
  width: 160vmax;
  height: 28vmax;
  transform: translate(-50%, -50%) rotate(-16deg);
  background: radial-gradient(50% 50% at 50% 50%, #ffa85a 0%, #ff7f52 45%, rgba(255, 127, 82, 0) 100%);
  opacity: 1;
}
.wallpaper::after {
  width: 70vmax;
  height: 26vmax;
  transform: translate(-50%, -46%) translate(-22vmax, 0) rotate(-16deg);
  background: radial-gradient(50% 50% at 50% 50%, #ffe0a0 0%, rgba(255, 224, 160, 0) 100%);
  opacity: 0.9;
}

/* ---------- ホーム ---------- */
.home {
  position: relative;
  z-index: 1;
  min-height: 100%;
  padding: calc(var(--safe-top) + 52px) 27px calc(var(--safe-bottom) + 150px);
  max-width: 680px;
  margin: 0 auto;
}
.hero {
  text-align: center;
  margin: 6px 0 26px;
}
.hero-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 16px rgba(103, 217, 255, 0.35);
}
.hero-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-dim);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--icon));
  gap: var(--gap-y) var(--gap-x);
  justify-content: center;
  justify-items: center;
}
.empty {
  text-align: center;
  color: var(--ink-dim);
  font-size: 14px;
  padding: 40px 0;
}

/* ---------- アプリアイコン ---------- */
.tile {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  width: var(--icon);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  animation: pop-in 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.2) forwards;
  animation-delay: calc(var(--i, 0) * 35ms);
  transition: transform 0.15s ease;
  text-decoration: none;
}
@keyframes pop-in { to { opacity: 1; transform: none; } }
.tile:active .icon { transform: scale(0.88); filter: brightness(0.8); }
.tile:focus-visible .icon { outline: 2px solid var(--cyan); outline-offset: 3px; }

.icon {
  position: relative;
  width: var(--icon);
  height: var(--icon);
  border-radius: var(--icon-radius);
  display: grid;
  place-items: center;
  font-size: calc(var(--icon) * 0.5);
  line-height: 1;
  background: linear-gradient(145deg, var(--c1, #444), var(--c2, #222));
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, filter 0.12s ease;
  overflow: hidden;
  user-select: none;
}
.icon::before {
  /* ガラス感のハイライト */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 48%);
  pointer-events: none;
}
.icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.icon .glyph {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
  transform: translateY(1px);
}
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 6px;
  border-radius: 999px;
  border: 2px solid rgba(5, 10, 18, 0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  z-index: 2;
}
.tile.has-badge { overflow: visible; }
.tile.has-badge .icon { overflow: visible; }
.tile.has-badge .icon::before { border-radius: var(--icon-radius); }
.tile.has-badge .icon img { border-radius: var(--icon-radius); }

.label {
  flex: none;
  width: calc(var(--icon) + var(--gap-x) - 8px); /* iOS 同様、ラベルはアイコン幅より少し広くてよい */
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Dock（iOS 実寸: 幅 358pt・高さ 96pt・角丸 38pt・左右余白 16pt・下余白 8pt） ---------- */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 8px);
  transform: translateX(-50%);
  z-index: 5;
  width: min(358px, calc(100% - 32px));
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  padding: 0;
  border-radius: 38px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}
.dock .tile { gap: 0; animation: none; opacity: 1; transform: none; max-width: none; width: auto; }
.dock .label { display: none; }

/* ---------- アプリ オーバーレイ ---------- */
.app {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #000;
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: app-open 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.app.closing { animation: app-close 0.26s ease-in forwards; }
@keyframes app-open {
  from { opacity: 0; transform: scale(0.2); border-radius: 40px; }
  to   { opacity: 1; transform: scale(1); border-radius: 0; }
}
@keyframes app-close {
  to { opacity: 0; transform: scale(0.25); border-radius: 40px; }
}
.app-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 8px) 10px 8px;
  background: rgba(8, 14, 24, 0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.app-back, .app-ext {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--cyan);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
}
.app-back:active, .app-ext:active { background: rgba(255,255,255,0.1); }
.app-titles {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.2;
}
.app-titles strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-titles small { display: block; font-size: 11px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-body { flex: 1; position: relative; min-height: 0; }
#app-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
.app-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #05090f;
  transition: opacity 0.3s ease;
}
.app-loading.done { opacity: 0; pointer-events: none; }
.app-loading span {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(103, 217, 255, 0.25);
  border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- About シート ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 30px 26px calc(var(--safe-bottom) + 30px);
  border-radius: 28px 28px 0 0;
  background: rgba(16, 24, 38, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-bottom: 0;
  text-align: center;
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 640px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 28px; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 30px; }
}
.sheet-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.sheet-avatar {
  width: 84px; height: 84px;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.sheet-title { margin: 14px 0 4px; font-size: 20px; }
.sheet-bio { color: var(--ink-dim); font-size: 14px; line-height: 1.8; }
.sheet-bio p { margin: 0; }
.sheet-links { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.sheet-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  text-decoration: none;
  font-size: 15px;
}
.sheet-links a:hover { background: rgba(255,255,255,0.14); }
.sheet-links a span:first-child { width: 24px; text-align: center; }
.sheet-links a span:last-child { margin-left: auto; color: var(--ink-dim); }

/* ---------- レスポンシブ ---------- */
@media (min-width: 480px) {
  :root { --cols: 5; }
}
@media (min-width: 720px) {
  :root { --cols: 6; }
  .home { max-width: 760px; }
  .hero-title { font-size: 34px; }
  .tile:hover .icon { transform: translateY(-3px) scale(1.04); filter: brightness(1.08); }
}
@media (hover: hover) {
  .dock .tile:hover .icon { transform: translateY(-6px) scale(1.08); }
}

/* =====================================================================
 *  作品詳細ポップアップ（コンパクト）
 * ===================================================================== */
.detail {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: fade 0.2s ease;
}
.detail-card {
  position: relative;
  width: min(360px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 22px 20px 18px;
  border-radius: 26px;
  background: rgba(20, 26, 44, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: detail-open 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}
.detail.closing .detail-card { animation: detail-close 0.18s ease-in forwards; }
.detail.closing .detail-backdrop { animation: fade-out 0.18s ease-in forwards; }
@keyframes detail-open {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes detail-close { to { opacity: 0; transform: scale(0.8); } }
@keyframes fade-out { to { opacity: 0; } }

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  cursor: pointer;
}
.detail-close:hover { background: rgba(255, 255, 255, 0.22); }

/* ---- ヘッダー ---- */
.detail-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-right: 28px;
}
.detail-icon {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 22.37%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 32px;
  line-height: 1;
  background: linear-gradient(145deg, var(--c1, #444), var(--c2, #222));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.detail-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-head-text { min-width: 0; }
.detail-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.detail-desc {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-dim);
}
.detail-kicker {
  margin: 5px 0 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
}

/* ---- CTA ---- */
.cta {
  appearance: none;
  display: block;
  width: 100%;
  margin: 16px 0 0;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #04101c;
  background: linear-gradient(90deg, #67d9ff, #8bc6ff);
  box-shadow: 0 8px 24px rgba(103, 217, 255, 0.3);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.cta:hover { filter: brightness(1.06); }
.cta:active { transform: scale(0.97); }
.cta:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.cta-alt {
  display: block;
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-dim);
  text-decoration: none;
}
.cta-alt:hover { color: var(--ink); }

/* ---- 情報一覧 ---- */
.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12.5px;
  line-height: 1.5;
}
.meta dt { color: var(--ink-dim); white-space: nowrap; }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.meta dd.unset { color: var(--ink-dim); }
.meta-label {
  margin: 14px 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.prompt {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(103, 217, 255, 0.08);
  border: 1px solid rgba(103, 217, 255, 0.2);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--cyan-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- 制作について（折りたたみ） ---- */
.story {
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}
.story summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-dim);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.story summary::-webkit-details-marker { display: none; }
.story summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-left: 2px;
}
.story[open] summary::before { transform: rotate(45deg); }
.story summary:hover { color: var(--ink); }
.story-body { padding-top: 8px; }
.story-body p {
  margin: 0 0 8px;
  font-size: 12.5px;
  line-height: 1.75;
  color: rgba(234, 246, 255, 0.85);
}
.story-body p:last-child { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  .detail-card, .app { animation-duration: 0.01s; }
}
