/* たぬの実験工房
   文字はすべて普通の HTML。3D は背面の canvas 1 枚だけで、文字の下には
   不透明に近い面を敷くか、3D を置かない場所にする。 */

:root {
  --bg: #f3f6fb;
  --ink: #12263c;
  --muted: #4a5d74;
  --faint: #7a8da3;
  --card: rgba(255, 255, 255, 0.96);
  --card-solid: #ffffff;
  --line: rgba(18, 38, 60, 0.12);
  --line-strong: rgba(18, 38, 60, 0.22);
  --accent: #1d5fd0;
  --accent-soft: rgba(29, 95, 208, 0.1);
  --on-accent: #ffffff;
  --note: #0f7a63;
  --note-soft: rgba(15, 122, 99, 0.1);
  --btn-bg: #12263c;
  --btn-ink: #ffffff;
  --glow-a: rgba(72, 140, 255, 0.2);
  --glow-b: rgba(46, 204, 170, 0.16);
  --glow-c: rgba(255, 190, 110, 0.14);
  --header: rgba(243, 246, 251, 0.78);
  --shadow: 0 1px 2px rgba(18, 38, 60, 0.05), 0 14px 34px -16px rgba(18, 38, 60, 0.22);
  --shadow-up: 0 2px 4px rgba(18, 38, 60, 0.06), 0 26px 48px -18px rgba(18, 38, 60, 0.32);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --radius: 18px;
}

html[data-theme="dark"] {
  --bg: #0a121e;
  --ink: #eaf1f9;
  --muted: #a9b9cc;
  --faint: #7689a0;
  --card: rgba(17, 28, 44, 0.96);
  --card-solid: #111c2c;
  --line: rgba(234, 241, 249, 0.12);
  --line-strong: rgba(234, 241, 249, 0.24);
  --accent: #8db8ff;
  --accent-soft: rgba(141, 184, 255, 0.12);
  --on-accent: #0a121e;
  --note: #5fd9bd;
  --note-soft: rgba(95, 217, 189, 0.12);
  --btn-bg: #eaf1f9;
  --btn-ink: #0a121e;
  --glow-a: rgba(60, 120, 255, 0.2);
  --glow-b: rgba(30, 190, 160, 0.12);
  --glow-c: rgba(255, 150, 90, 0.08);
  --header: rgba(10, 18, 30, 0.74);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 34px -16px rgba(0, 0, 0, 0.6);
  --shadow-up: 0 2px 4px rgba(0, 0, 0, 0.3), 0 26px 48px -18px rgba(0, 0, 0, 0.75);
}

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

html {
  background: var(--bg);
  color-scheme: light;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  font-feature-settings: "palt";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 背景：色のにじみ（CSS）→ 3D（canvas）→ 本文 の順に重ねる */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60vw 50vh at 85% 8%, var(--glow-a), transparent 70%),
    radial-gradient(50vw 50vh at 5% 55%, var(--glow-b), transparent 70%),
    radial-gradient(50vw 45vh at 90% 95%, var(--glow-c), transparent 70%);
  pointer-events: none;
}
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
}
html.scene-ready #scene { opacity: 1; }
html.no-webgl #scene { display: none; }

.wrap { width: min(1140px, 100% - 48px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 50; padding: 10px 16px; border-radius: 10px; background: var(--btn-bg); color: var(--btn-ink); transition: top 0.2s; }
.skip:focus { top: 12px; }

a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ── ヘッダー ───────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: 0.02em; white-space: nowrap; }
.brand-mark {
  display: block; flex: none; width: 32px; height: 32px; border-radius: 7px;
  box-shadow: 0 5px 12px -7px rgba(29, 95, 208, 0.5);
}
.site-header nav { display: flex; gap: 4px; margin-left: auto; }
.site-header nav a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.site-header nav a:hover { background: var(--accent-soft); color: var(--ink); }
.header-tools { display: flex; gap: 6px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; transition: border-color 0.2s, transform 0.2s;
}
.icon-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#motion-toggle .i-play { display: none; fill: currentColor; stroke: none; }
#motion-toggle[aria-pressed="false"] .i-play { display: block; }
#motion-toggle[aria-pressed="false"] .i-pause { display: none; }
html[data-theme="dark"] .i-moon { display: none; }
html[data-theme="light"] .i-sun { display: none; }
html.no-webgl #motion-toggle { display: none; }

/* ── 文字まわり ─────────────────────── */
.eyebrow {
  margin: 0 0 14px; font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.2em; color: var(--accent);
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; border-radius: 2px; background: currentColor; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: 0.01em; }
h1 { font-size: clamp(2.3rem, 5.4vw, 4.5rem); font-weight: 800; line-height: 1.2; letter-spacing: 0; }
h1 .hl { color: var(--accent); }
h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 800; }
.lead { margin: 22px 0 0; font-size: clamp(1rem, 1.5vw, 1.15rem); color: var(--muted); }
.intro { margin: 12px 0 0; color: var(--muted); max-width: 34em; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font-weight: 700; font-size: 15px; line-height: 1.3; text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--ink); }
.btn.primary { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
.btn.note-btn { margin-top: 20px; background: var(--note); color: var(--on-accent); border-color: transparent; }
html[data-theme="light"] .btn.note-btn { color: #fff; }

/* ── ヒーロー ───────────────────────── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: center; gap: 24px;
  min-height: min(calc(100vh - 64px), 820px); padding-block: 48px 40px;
}
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero-gallery {
  position: relative; isolation: isolate; width: min(100%, 25rem);
  margin-top: 28px; padding: 8px 12px clamp(26px, 4vw, 42px) 6px;
}
.hero-scene {
  display: block; overflow: hidden; border: 5px solid var(--card-solid);
  border-radius: 16px; background: var(--card-solid); box-shadow: var(--shadow);
  color: var(--ink); text-decoration: none; transition: box-shadow 0.2s;
}
.hero-scene:hover, .hero-scene:focus-visible { box-shadow: var(--shadow-up); }
.hero-scene:focus-visible { z-index: 2; }
.hero-scene-art { display: block; overflow: hidden; aspect-ratio: 16 / 10; }
.hero-scene-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero-scene-title { display: block; padding: 7px 11px; font-size: 14px; font-weight: 750; line-height: 1.3; }
.scene-main { position: relative; margin-right: clamp(24px, 5vw, 40px); transform: rotate(-3deg); }
.scene-small { position: absolute; z-index: 1; right: 9px; bottom: 0; width: 44%; transform: rotate(5deg); }
.scene-small img { width: 185%; height: auto; max-width: none; transform: translate(-23%, -31%); }
.stats { display: flex; gap: 34px; margin: 44px 0 0; }
.hero-gallery + .stats { margin-top: 26px; }
.stats dt { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* 3D の置き場所。中身は空で、canvas 側がこの枠の位置に立体を置く */
.stage { width: 100%; aspect-ratio: 1; max-width: 300px; justify-self: end; }
.stage-hero { max-width: 500px; justify-self: center; }
html.no-webgl .stage { display: none; }

/* ── セクション ─────────────────────── */
.section { padding-block: 56px 40px; }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); align-items: center; gap: 24px; margin-bottom: 26px; }
html.no-webgl .section-head { grid-template-columns: 1fr; }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow);
}
.panel p { margin: 0 0 14px; }
.panel p:last-child { margin-bottom: 0; }
.panel .btn { margin-top: 6px; }
.panel-title { font-size: 1.05rem; margin-bottom: 10px; }

/* note */
.note-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.articles { list-style: none; margin: 0; padding: 0; }
.articles li + li { border-top: 1px solid var(--line); }
.articles a {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) 20px; gap: 12px; align-items: baseline; padding: 14px 8px; margin-inline: -8px;
  border-radius: 10px; text-decoration: none; font-weight: 600; line-height: 1.6; transition: background 0.2s;
}
.articles a::after { content: "↗"; color: var(--faint); transition: transform 0.2s, color 0.2s; }
.articles a:hover { background: var(--note-soft); }
.articles a:hover::after { color: var(--note); transform: translate(2px, -2px); }
.articles time { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--note); }
.socials { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.socials a {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 16px 20px; border-radius: var(--radius);
  background: var(--social-background, var(--card)); border: 1px solid var(--social-border, var(--line));
  box-shadow: var(--shadow); text-decoration: none; transition: transform 0.2s, border-color 0.2s;
}
.social-github { --social-background: #e5efff; --social-border: #bfd3f2; }
.social-youtube { --social-background: #fff0ec; --social-border: #e7c5ba; }
.social-x { --social-background: #edf3fa; --social-border: #c7d5e6; }
html[data-theme="dark"] .social-github { --social-background: #182944; --social-border: #36527a; }
html[data-theme="dark"] .social-youtube { --social-background: #372429; --social-border: #62404a; }
html[data-theme="dark"] .social-x { --social-background: #202c3d; --social-border: #42546b; }
.socials a:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.soc-name { font-weight: 800; }
.soc-desc { grid-column: 1; font-size: 13px; color: var(--muted); }
.socials .arrow { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--faint); }

/* 作品カード */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  --rx: 0deg; --ry: 0deg;
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
  will-change: transform;
}
.card:hover { box-shadow: var(--shadow-up); border-color: var(--line-strong); }
.card.tilting { transition: transform 0.08s linear, box-shadow 0.3s, border-color 0.3s; }
.thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: linear-gradient(135deg, var(--accent-soft), var(--note-soft)); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.card:hover .thumb img { transform: scale(1.045); }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 16px 18px 18px; }
.tag { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--accent); }
.card h3 { font-size: 1.08rem; }
.card-desc { margin: 8px 0 14px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.link {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; text-decoration: none;
  border: 1px solid var(--line-strong); transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.link:hover { border-color: var(--ink); }
.link.main { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.link.main:hover { filter: brightness(1.08); }

/* push-guard の見本（画像の代わり） */
.guard {
  aspect-ratio: 16 / 9; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 14px 16px;
  background: #0e1a2a; color: #dbe7f5; font-family: var(--mono); font-size: 12px; line-height: 1.5; text-decoration: none;
}
.guard-label { font-family: var(--font); font-size: 11px; color: #8ea3bb; }
.guard-cmd { color: #9fd0ff; }
.guard-stop { color: #ff8f8f; font-weight: 700; font-family: var(--font); font-size: 13px; }
.guard-detail { font-family: var(--font); color: #c5d3e3; }

.more { margin-top: 20px; }
.more summary {
  list-style: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 20px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line-strong); font-weight: 700; transition: border-color 0.2s, transform 0.2s;
}
.more summary::-webkit-details-marker { display: none; }
.more summary:hover { border-color: var(--ink); transform: translateY(-1px); }
.more-hide { display: none; }
.more[open] .more-show { display: none; }
.more[open] .more-hide { display: inline; }
.more-icon { width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.25s; }
.more[open] .more-icon { transform: rotate(-135deg) translate(-2px, -2px); }
.more .cards { margin-top: 20px; }

/* Sites */
.sites { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sites a {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 16px; height: 100%; padding: 18px 20px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.sites a:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-up); }
.site-no { grid-row: 1 / span 3; font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1.3; color: var(--accent); font-variant-numeric: tabular-nums; }
.sites h3 { font-size: 1rem; }
.sites p { margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--muted); }
.site-link { font-size: 13px; font-weight: 700; color: var(--accent); margin-top: 4px; }
.site-link::after { content: " ↗"; }

.twin { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.twin .eyebrow { margin-bottom: 8px; }

/* フッター */
.site-credit { margin-block: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.8; }
.site-footer { margin-top: 56px; border-top: 1px solid var(--line); background: var(--header); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 26px; font-size: 14px; color: var(--muted); }
.footer-inner p { margin: 0; }
.footer-inner ul { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; }
.footer-inner a { font-weight: 700; text-decoration: none; color: var(--ink); }
.footer-inner a:hover { text-decoration: underline; }

/* 現れる動き（JS が動いていて、動きを減らす設定でないときだけ） */
html.js.motion-on .reveal { opacity: 0; transform: translateY(18px); }
html.js.motion-on .reveal.in { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--d, 0ms); }
html.js.motion-on .card.reveal.in { transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)); }
html.js.motion-on .card.reveal.in.settled { transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.3s, border-color 0.3s; transition-delay: 0ms; }
html.js.motion-on .card.reveal.in.settled.tilting { transition: transform 0.08s linear, box-shadow 0.3s, border-color 0.3s; }

/* ── 幅の狭い画面 ───────────────────── */
@media (max-width: 1000px) {
  .cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards, .sites { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-grid { grid-template-columns: 1fr; }
  .socials { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wrap { width: min(1140px, 100% - 32px); }
  .header-inner { height: 56px; gap: 10px; }
  .site-header nav { display: none; }
  .header-tools { margin-left: auto; }
  html { scroll-padding-top: 70px; }
  .hero { grid-template-columns: 1fr; min-height: 0; padding-block: 12px 24px; gap: 4px; }
  .stage-hero { order: -1; max-width: 250px; margin-bottom: 20px; }
  .stats { gap: 24px; margin-top: 30px; }
  .stats dd { font-size: 24px; }
  .section { padding-block: 36px 28px; }
  .section-head { grid-template-columns: 1fr; gap: 4px; }
  .section-head .stage { order: -1; max-width: 170px; justify-self: start; margin-bottom: 22px; }
  .cards, .cards-4, .sites, .twin { grid-template-columns: 1fr; }
  .socials { grid-template-columns: 1fr; }
  .articles a { grid-template-columns: 48px minmax(0, 1fr); }
  .articles a::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
