/* Studio Ever Empty
   見た目は素朴な文字のページ。裏で新しい CSS が少しだけ動く。
   - ページの移り変わり：View Transitions（ページをまたぐ）
   - 区切りの線と一番下の雲：スクロール連動アニメーション
   - 鳥がよそ見：:has()
   - 「ちゅぴ」：@starting-style
   動きを減らす設定の人と、対応していないブラウザでは、ただの素朴なページになる。 */

@view-transition { navigation: auto; }
@property --fill { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

:root {
  --bg: #FFFFFF; --fg: #222222; --sub: #6F6F6F; --link: #1A0DAB; --visited: #5C2D91;
  --rule: #DDDDDD; --moss: #9DAE2F; --sel: #E6EEB8; --edge: transparent;
  --f: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1D1F; --fg: #E4E4E0; --sub: #A2A29C; --link: #8AB4F8; --visited: #C58AF9;
    --rule: #3A3C3E; --moss: #C3D35A; --sel: #4A5222; --edge: #C9CCC4;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f);
  font-size: 16px; line-height: 1.9;
  padding: 32px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
}
main { max-width: 620px; margin: 0 auto; }
::selection { background: var(--sel); }
p, li { text-wrap: pretty; }
img { max-width: 100%; height: auto; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px;
    transition: text-decoration-thickness .2s, text-underline-offset .2s; }
a:visited { color: var(--visited); }
a:hover { text-decoration-thickness: 2px; text-underline-offset: 5px; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.name { margin: 0; font-size: 20px; font-weight: bold; display: flex; align-items: flex-end; gap: 6px; line-height: 1.3; }
.name a { color: var(--fg); text-decoration: none; }
.name a:hover { text-decoration: underline; }
nav { margin: 6px 0 0; font-size: 15px; display: flex; flex-wrap: wrap; gap: 0 .9em; }
nav a[aria-current="page"] { color: var(--fg); text-decoration: none; }
nav .lang { margin-left: auto; }

h1 { font-size: 18px; margin: 8px 0 12px; }
h2 { font-size: 16px; margin: 36px 0 6px; }
p { margin: 0 0 12px; }
ul { margin: 0 0 12px; padding-left: 1.3em; }
li { margin: 2px 0; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 28px 0; }
.sub { color: var(--sub); font-size: 14px; }
.date { color: var(--sub); font-variant-numeric: tabular-nums; margin-right: .8em; }
dl { display: grid; grid-template-columns: 7em 1fr; gap: 2px 12px; margin: 0 0 12px; }
dt { color: var(--sub); } dd { margin: 0; }
.shot { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; margin: 8px 0 12px;
        background: color-mix(in oklab, var(--fg) 6%, var(--bg)); }
.slot { display: flex; align-items: center; justify-content: center; color: var(--sub); font-size: 14px; }
article.entry { margin: 0 0 28px; }
article.entry h2 { margin-top: 0; }

/* 鳥 */
#bird { width: 32px; height: 32px; padding: 0; border: 0; background: none; cursor: pointer; flex: none; view-transition-name: bird; }
#bird img { display: block; width: 32px; height: 32px; image-rendering: pixelated; transform-origin: 50% 90%;
  filter: drop-shadow(1px 0 0 var(--edge)) drop-shadow(-1px 0 0 var(--edge)) drop-shadow(0 -1px 0 var(--edge));
  transition: rotate .25s steps(2); animation: idle 9s steps(1) infinite; }
#bird.look-left img { scale: -1 1; }
#bird.hop img { animation: hop .45s steps(3); }
@keyframes idle { 0%, 93% { translate: 0 0 } 94% { translate: 0 -3px } 96% { translate: 0 0 } 97% { translate: 0 -2px } 98%, 100% { translate: 0 0 } }
@keyframes hop { 0% { translate: 0 0 } 40% { translate: 0 -8px } 70% { translate: 0 -2px } 100% { translate: 0 0 } }
body:has(.games a:hover, .games a:focus-visible) #bird img { rotate: 14deg; }
#chirp { font-size: 14px; color: var(--sub); font-weight: normal; transition: opacity .3s, translate .3s; }
#chirp[hidden] { display: none; }
@starting-style { #chirp { opacity: 0; translate: 0 4px; } }

/* 作品の名前は、一覧から作品ページの見出しへそのまま移る */
.vt-ouka { view-transition-name: ouka-title; width: fit-content; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; }
::view-transition-group(ouka-title) { animation-duration: .45s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }

/* 区切りの線：読み進めた分だけ黄緑に */
.line { height: 1px; margin: 28px 0; background: linear-gradient(to right, var(--moss) var(--fill), var(--rule) var(--fill)); }
.foot { position: relative; margin: 0; }
.cloud { position: absolute; right: 240px; bottom: 2px; width: 27px; height: 9px; fill: var(--rule); }

@supports (animation-timeline: scroll()) {
  .line { animation: fill linear both; animation-timeline: scroll(root); }
  @keyframes fill { to { --fill: 100%; } }
  .games li, .news li, article.entry { animation: near linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  @keyframes near { from { translate: 6px 0; } to { translate: 0 0; } }
  .cloud { animation: drift linear both; animation-timeline: scroll(root); }
  @keyframes drift { from { translate: 0 0; } to { translate: 220px 0; } }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  #bird img, .cloud, .games li, .news li, article.entry, .line { animation: none !important; }
}
@media (max-width: 520px) { .cloud { right: 110px; } dl { grid-template-columns: 5.5em 1fr; } }
