/* ==========================================================================
katakuriko.site — static site stylesheet
モバイルファースト / 外部フレームワーク・CDN不使用 / 手作り
========================================================================== */

:root {
--color-bg: #222831;
--color-text: #EEEEEE;
--color-muted: #EEEEEE;
--color-accent: #2f6f4f;
--color-accent-dark: #222831;
--color-border: #EEEEEE;
--color-surface: #222831;

--font-base: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;

--header-height: 52px;
--header-height-game: 52px;

--max-width: 780px;
}

* {
  box-sizing: border-box;
  }

html,
body {
margin: 0;
padding: 0;
}

body {
font-family: var(--font-base);
color: var(--color-text);
background: var(--color-bg);
line-height: 1.7;
-webkit-font-smoothing: antialiased;
}

a {
color: #5c98f2;
text-decoration:underline;
}

a:hover {
text-decoration: underline;
}

p {
 margin: 0;
}

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

ul {
list-style: none;
margin: 0;
padding: 0;
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {

* {
  transition: none !important;
  animation: none !important;
  }
  }

/* ==========================================================================
Header (通常ページ)
========================================================================== */

.site-header {
position: sticky;
top: 0;
z-index: 100;
height: var(--header-height);
background: var(--color-bg);
border-bottom: 1px solid var(--color-border);
}

.header-inner {
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 16px;
}

.site-logo {
font-weight: 700;
font-size: 1rem;
color: var(--color-text);
}

/* ハンバーガーボタン */
.nav-toggle-input {
position: absolute;
opacity: 0;
pointer-events: none;
}

.nav-toggle-btn {
display: flex;
flex-direction: column;
justify-content: center;
gap: 5px;
width: 44px;
height: 44px;
cursor: pointer;
z-index: 210;
}

.nav-toggle-btn span {
display: block;
width: 22px;
height: 2px;
background: var(--color-text);
margin: 0 auto;
transition: transform 0.2s ease, opacity 0.2s ease;
}

/* オフキャンバスナビゲーション */
.global-nav {
position: fixed;
top: 0;
right: 0;
width: min(80vw, 320px);
height: 100vh;
background: var(--color-bg);
border-left: 1px solid var(--color-border);
transform: translateX(100%);
transition: transform 0.25s ease;
overflow-y: auto;
z-index: 200;
padding-top: var(--header-height);
}

.nav-toggle-input:checked ~ .global-nav {
transform: translateX(0);
}

.nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(1) {
transform: translateY(7px) rotate(45deg);
}

.nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(2) {
opacity: 0;
}

.nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(3) {
transform: translateY(-7px) rotate(-45deg);
}

.nav-list {
padding: 8px 0;
}

.nav-item > a,
.nav-item summary {
display: block;
padding: 14px 20px;
border-bottom: 1px solid var(--color-border);
color: var(--color-text);
cursor: pointer;
list-style: none;
}

.nav-item summary::-webkit-details-marker {
display: none;
}

.nav-item summary::after {
content: "▾";
float: right;
color: var(--color-muted);
}

/* スマホ：サブメニューは閉じた状態 */
.nav-item.has-children .sub-nav {
display: none;
}

/* スマホ：<details>がopenのときだけ表示 */
.nav-item.has-children details[open] > .sub-nav {
display: block;
}

.sub-nav {
min-width: 180px;
background: var(--color-surface);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
border: 1px solid var(--color-border);
z-index: 300;
}

.sub-nav li a {
display: block;
padding: 12px 20px 12px 32px;
border-bottom: 1px solid var(--color-border);
font-size: 0.9rem;
color: var(--color-text);
}

/* ==========================================================================
Header (ゲームページ専用・最小)
========================================================================== */

.site-header--game {
position: sticky;
top: 0;
left: 0;
right: 0;
height: var(--header-height-game);
background: #222831;
border-bottom: 1px solid var(--color-border);
display: flex;
align-items: center;
}

.site-header--game .header-inner {
width: 100%;
}

.site-header--game .nav-toggle-btn {
width: 36px;
height: 36px;
}

.site-main--game {
padding-top: var(--header-height-game);
}

/* ==========================================================================
Layout
========================================================================== */

.site-main {
padding-top: 0;
}

.home-page,
.category-page,
.post {
max-width: var(--max-width);
margin: 0 auto;
padding: 24px 16px 48px;
}

.home-title,
.category-title,
.post-title {
font-size: 1.4rem;
line-height: 1.4;
margin: 0 0 8px;
}

.home-lead {
color: var(--color-muted);
margin-bottom: 24px;
}

/* ==========================================================================
投稿一覧 (カテゴリーページ・トップページ共通)
========================================================================== */

.post-list {
display: flex;
flex-direction: column;
gap: 4px;
}

.post-item a {
display: block;
padding: 16px 4px;
border-bottom: 1px solid var(--color-border);
color: var(--color-text);
}

.post-item a:hover {
background: var(--color-surface);
text-decoration: none;
}

.post-item-title {
display: block;
font-weight: 600;
margin-bottom: 4px;
}

.post-item-meta {
display: block;
font-size: 0.8rem;
color: var(--color-muted);
margin-bottom: 6px;
}

.post-item-excerpt {
margin: 0;
font-size: 0.9rem;
color: var(--color-muted);
}

.pagination {
display: flex;
justify-content: space-between;
margin-top: 24px;
}

.pagination a {
padding: 8px 14px;
border: 1px solid var(--color-border);
border-radius: 4px;
}

/* ==========================================================================
投稿詳細 (記事タイプ)
========================================================================== */

.post-meta {
color: var(--color-muted);
font-size: 0.85rem;
margin-bottom: 24px;
}

.post-categories {
margin-left: 8px;
}

.post-content h2 {
font-size: 1.15rem;
margin-top: 2em;
}

.post-content pre {
background: var(--color-surface);
padding: 12px;
overflow-x: auto;
border-radius: 4px;
}

.post-content code {
background: var(--color-surface);
padding: 2px 4px;
border-radius: 3px;
font-size: 0.9em;
}

/* ==========================================================================
ゲームページ (埋め込み全画面優先レイアウト)
========================================================================== */

.game-page-inner {
display: flex;
flex-direction: column;
}

.game-embed {
position: relative;
width: 100%;
height: calc(90dvh - var(--header-height-game));
background: #000;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
/*
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(300px, 1fr)
  );
  gap: 20px;
*/
}

.game-embed iframe,
.game-embed canvas {
width: 100%;
height: 100%;
border: 0;
display: block;
}

/* JSが動的に生成する全画面ボタン */
.game-fullscreen-btn {
position: absolute;
right: 12px;
bottom: 12px;
z-index: 50;
padding: 8px 14px;
font-size: 0.8rem;
color: #fff;
background: rgba(0, 0, 0, 0.55);
border: 1px solid rgba(255, 255, 255, 0.4);
border-radius: 4px;
cursor: pointer;
}

.game-fullscreen-btn:hover {
background: rgba(0, 0, 0, 0.75);
}

/* 画面いっぱい表示モード(ブラウザのFullscreen APIは使わない。
   iOS Safariがdiv/iframeのrequestFullscreen()に対応していないため、
   CSSでヘッダー・メニュー・フッターを隠し、ゲーム部分をposition:fixedで
   画面全体に固定する方式に統一している。PC/スマホ共通の挙動になる) */
html.is-game-fillscreen,
html.is-game-fillscreen body {
overflow: hidden;
}

html.is-game-fillscreen .site-header--game,
html.is-game-fillscreen .game-meta {
display: none;
}

html.is-game-fillscreen .game-embed {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100vw;
height: 100dvh;
z-index: 9999;
touch-action: none;
}

.game-meta {
max-width: var(--max-width);
margin: 0 auto;
padding: 20px 16px 48px;
width: 100%;
}

/* ==========================================================================
フッター
========================================================================== */

.site-footer {
border-top: 1px solid var(--color-border);
padding: 24px 16px;
text-align: center;
color: var(--color-muted);
font-size: 0.85rem;
}

.footer-nav ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 12px;
margin-bottom: 12px;
}

.footer-nav a {
color: var(--color-muted);
}

/* ==========================================================================
404
========================================================================== */

.error-page {
max-width: var(--max-width);
margin: 0 auto;
padding: 64px 16px;
text-align: center;
}

.error-links {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 12px;
}

.error-links a {
padding: 8px 14px;
border: 1px solid var(--color-border);
border-radius: 4px;
}

/* ==========================================================================
フォーカス可視化 (アクセシビリティ)
========================================================================== */

a:focus-visible,
.nav-toggle-btn:focus-visible {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}

/* ==========================================================================
PC (768px以上) — mobile-first拡張
========================================================================== */

@media (min-width: 768px) {
:root {
--header-height: 60px;
--max-width: 900px;
}

.site-logo {
font-size: 1.1rem;
}

/* PCではハンバーガーボタンを非表示 */
.nav-toggle-btn {
display: none;
}

/* PCでは通常の横並びメニュー */
.global-nav {
position: static;
display: block;
width: auto;
height: 100%;
transform: none;
border-left: none;
padding-top: 0;
margin-left: auto;
overflow: visible;
}

.nav-list {
display: flex;
align-items: center;
padding: 0;
margin: 0;
}

.nav-item {
position: relative;
}

.nav-item > a,
.nav-item summary {
border-bottom: none;
padding: 0 16px;
height: var(--header-height);
display: flex;
align-items: center;
}

.nav-item details summary {
height: var(--header-height);
}

/* PC：通常は非表示 (JS側でopen属性をhoverに合わせて切り替える。
   表示自体は187行目の details[open] > .sub-nav ルールに任せる) */
.nav-item.has-children .sub-nav {
display: none;
}

.sub-nav {
position: absolute;
top: 100%;
left: 0;
min-width: 180px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
border: 1px solid var(--color-border);
z-index: 300;
}

.sub-nav li a {
padding: 10px 16px;
}

.home-title,
.category-title,
.post-title {
font-size: 1.8rem;
}
}

/* ==========================================
独自カードレイアウト (.k-grid- シリーズ)
========================================== */

/* リスト全体のコンテナ */
.k-grid-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
list-style: none;
padding: 0;
margin: 2rem 0;
}

/* カードの枠組み */
.k-grid-item {
background-color: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* カードのホバー効果 */
.k-grid-item:hover {
transform: translateY(-4px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* カード内のリンクエリア */
.k-grid-link {
display: flex !important;
flex-direction: column;
height: 100%;
padding: 1.5rem;
color: #ffffff !important;
text-decoration: none !important;
}

/* タイトル */
.k-grid-title {
display: block;
font-size: 1.25rem;
font-weight: bold;
margin-bottom: 0.5rem;
line-height: 1.4;
color: #2d3748;
}

/* メタ情報（日付とバッジの並び） */
.k-grid-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
font-size: 0.85rem;
color: #718096;
margin-bottom: 1rem;
}

/* カテゴリタグ */
.k-grid-badge {
background-color: #edf2f7;
color: #4a5568;
padding: 0.2rem 0.5rem;
border-radius: 4px;
font-size: 0.75rem;
font-weight: 500;
display: inline-block;
}

/* 記事の抜粋テキスト */
.k-grid-excerpt {
font-size: 0.95rem;
line-height: 1.6;
color: #4a5568;
margin: 0;
flex-grow: 1;
}

/* カード内の画像コンテナ */
.k-grid-thumbnail {
width: 100%;
aspect-ratio: 16 / 9;
overflow: hidden;
background: var(--color-surface);
}

.k-grid-thumbnail img {
width: 100%;
height: 100%;
object-fit: contain;
transition: transform 0.3s ease;
}

.k-grid-item:hover .k-grid-thumbnail img {
transform: scale(1.05);
}

/* カードの下半分（テキストエリア） */
.k-grid-body {
padding: 1rem;
}

/* game comment */
.iframe-game-comment {
height: 600px;
}

/* gdevelop game iframe */
.gdev-iframe-game {
  width: 80%; 
  max-width: 384px;
  aspect-ratio: 384 / 683;
  height: auto;
  border: none;
  display: block;
  margin: 0 auto;
}
