/* ───────── Writing — after sasukeharaguchi.com/works ───────── */
html, body.writing { height: 100%; overflow: hidden; }
body.writing { background: var(--white); color: var(--ink); --split: 42vw; --cell: clamp(34px, 4.2vw, 64px); }

.writing .mono { text-transform: none; font-size: 12px; letter-spacing: 0; }

/* Squares used by the rail and the sound toggle */
.sq {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
  font: 400 17px/1 var(--f-serif); transition: background .25s, color .25s;
}
.sq:hover { background: var(--ink); color: var(--paper); }
.sq.is-on { background: var(--ink); color: var(--paper); }

/* Left warm shelf */
.shelf {
  position: fixed; inset: 0 auto 0 0; width: var(--split); background: var(--paper); overflow: hidden;
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.4px);
  background-size: var(--cell) var(--cell); background-position: calc(var(--cell) / 2) calc(var(--cell) / 2);
}
.rail { position: absolute; left: 30px; top: 30px; bottom: 30px; display: flex; flex-direction: column; justify-content: space-between; z-index: 3; }
.rail__nav { display: flex; flex-direction: column; margin-top: 26px; margin-bottom: auto; }
.rail__nav .sq + .sq { border-top: 0; }
/* Labels next to the rail squares, always visible */
.rail .sq[data-name] { position: relative; }
.rail .sq[data-name]::after {
  content: attr(data-name); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  font: 400 11px/1 var(--f-mono); color: var(--mute); white-space: nowrap; pointer-events: none; transition: color .25s;
}
.rail .sq[data-name]:hover::after, .rail .sq.is-on::after { color: var(--ink); }
.rail .sq.is-on:hover, .rail .sq:hover { color: var(--paper); }
.sq--theme { margin-top: 14px; border-top: 1px solid var(--line) !important; font: 400 16px/1 var(--f-body); }
.sq--logo { font: 700 13px/1 var(--f-display); letter-spacing: -.02em; }
.sq--ask { font: 400 15px/1 var(--f-mono); }

.covers { position: absolute; left: calc(30px + 38px + clamp(96px, 9vw, 130px)); top: 0; width: clamp(170px, 19vw, 330px); height: 100%; }
.covers__track { position: absolute; left: 0; right: 0; top: 0; transition: transform .9s var(--ease); will-change: transform; }
.cover { display: block; position: relative; width: 100%; margin: 0 0 22vh; cursor: pointer; }
.cover__sq { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--paper-2); border: 1px solid var(--line); transition: transform .9s var(--ease), filter .6s; }
.cover__sq img { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover__bg { object-fit: cover; filter: blur(22px) saturate(1.15) brightness(.95); transform: scale(1.35); }
.cover__fg { object-fit: contain; }
.cover:not(.is-current) .cover__sq { filter: grayscale(.85) contrast(.9); transform: scale(.92); }
.cover:not(.is-current):hover .cover__sq { filter: none; }
.cover__cap { margin: 10px 0 0; color: var(--mute); transition: color .4s; }
.cover__no { color: var(--mute); }
.cover.is-current .cover__cap, .cover.is-pointed .cover__cap { color: var(--ink); }
.cover__hint { margin: 6px 0 0; color: var(--mute); opacity: 0; transition: opacity .3s; pointer-events: none; }
.cover.is-current:not(.is-open) .cover__hint { opacity: 1; transition-delay: .4s; animation: blink 1.6s steps(1) infinite .4s; }
@keyframes blink { 50% { opacity: .35; } }

/* Pixel staircase straddling the split */
.stairs { position: fixed; top: 0; bottom: 0; left: calc(var(--split) - var(--cell) * 2); width: calc(var(--cell) * 4); z-index: 2; pointer-events: none; display: grid; grid-template-columns: repeat(4, var(--cell)); grid-auto-rows: var(--cell); }
.stairs i { display: block; background: var(--white); transform: scaleX(0); transform-origin: left; transition: transform .55s var(--ease); }
.stairs i.warm { background: var(--paper); }
.stairs i.on { transform: scaleX(1); }
.stairs i:nth-child(4n+1), .stairs i:nth-child(4n+2) { transform-origin: right; }

/* Right white dotted field */
.field {
  position: fixed; inset: 0 0 0 var(--split); padding: 30px 30px 30px calc(var(--cell) * 2.4);
  background-image: radial-gradient(circle, var(--dot-2) 1px, transparent 1.4px);
  background-size: var(--cell) var(--cell); background-position: calc(var(--cell) / 2) calc(var(--cell) / 2);
}
.shelf__tagline { display: none; }
.tagline { position: absolute; top: 30px; left: calc(var(--cell) * 2.4); margin: 0; max-width: calc(100% - var(--cell) * 2.4 - min(300px, 34%) - 70px); color: var(--mute); }
.meta { position: absolute; top: 30px; right: 30px; margin: 0; width: min(300px, 34%); line-height: 1.5; color: var(--ink-2); }
.meta dt { color: var(--mute); }
.meta dd { margin: 0 0 14px; }

.pn { position: absolute; left: calc(var(--cell) * 2.4); white-space: nowrap; max-width: calc(100% - var(--cell) * 2.4 - min(280px, 34%) - 60px); overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); padding: 6px 4px; background: var(--white); }
.pn:hover { color: var(--accent); }
.pn[hidden] { display: none; }
.pn--prev { top: 13vh; }
.pn--next { bottom: 17vh; }

.read { position: absolute; left: calc(var(--cell) * 2.4); right: 30px; top: 50%; transform: translateY(-50%); max-width: 760px; }
.read__idx { color: var(--mute); margin: 0 0 18px; }
.read__title { font: 400 clamp(34px, 3.9vw, 68px)/1.02 var(--f-serif); letter-spacing: -.01em; margin: 0 0 22px; max-width: 16ch; }
.read__title .ln { display: inline-block; overflow: hidden; padding-bottom: .08em; margin-bottom: -.08em; vertical-align: top; }
.read__title .ln > span { display: inline-block; transform: translateY(105%); transition: transform .9s var(--ease-out); }
.read__title.in .ln > span { transform: none; }
.read__excerpt { max-width: 46ch; font-size: 15px; line-height: 1.55; color: var(--ink-2); margin: 0 0 26px; opacity: 0; transform: translateY(8px); transition: opacity .6s .15s, transform .8s .15s var(--ease-out); }
.read__excerpt.in { opacity: 1; transform: none; }
.read__go { display: inline-flex; align-items: center; gap: 12px; border: 1px solid var(--ink); padding: 10px 14px; font-size: 13px; background: var(--white); transition: background .25s, color .25s; }
.read__go:hover { background: var(--ink); color: var(--white); }

.hint { position: absolute; left: calc(var(--cell) * 2.4); bottom: 30px; margin: 0; color: var(--mute); }

.sound { position: absolute; right: 30px; bottom: 30px; display: flex; flex-direction: column; align-items: flex-end; }
.sound .sq[data-name] { position: relative; }
.sound .sq[data-name]::before { content: attr(data-name); position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); font: 400 11px/1 var(--f-mono); color: var(--mute); white-space: nowrap; }
.sound .sq { border-color: var(--line); background: var(--white); }
.sq--glyph { font: 400 16px/1 var(--f-body); border-bottom: 0 !important; }
.sq--toggle { display: flex; align-items: center; justify-content: center; width: auto; min-width: 38px; padding: 0 7px; font: 400 10px/1 var(--f-mono); color: var(--mute); white-space: nowrap; }
.sq--toggle b { font-weight: 400; }
.sq--toggle[aria-pressed="true"] b:first-child, .sq--toggle[aria-pressed="false"] b:last-child { color: var(--ink); }
.sq--toggle:hover { background: var(--ink); color: var(--paper); }
.sq--toggle:hover b { color: inherit !important; }

/* Inline details under a cover — used on small screens */
.cover__more { display: none; }

/* ───────── Small screens: a plain scrolling list, no arm, no snapping ───────── */
@media (max-width: 860px) {
  html, body.writing { height: auto; overflow: visible; }
  body.writing { background: var(--paper); }
  .shelf { position: static; width: auto; min-height: 100svh; padding: 0 16px 60px; overflow: visible; }
  .rail { position: sticky; top: 0; left: auto; right: auto; bottom: auto; z-index: 5; flex-direction: row; align-items: center; justify-content: flex-start; padding: 16px 0; background: var(--paper); }
  .rail__nav { flex-direction: row; margin: 0 0 0 auto; }
  .rail__nav .sq + .sq { border-top: 1px solid var(--line); border-left: 0; }
  .sq--ask { display: none; }
  .sq--theme { margin: 0 0 0 10px; border-left: 1px solid var(--line) !important; }
  .rail .sq[data-name]::after { display: none; }
  .shelf__tagline { display: block; margin: 4px 0 18px; color: var(--mute); font-size: 11px; }
  .covers { position: static; width: auto; height: auto; padding-top: 12px; }
  .covers__track { position: static; transform: none !important; transition: none; }
  .cover { margin: 0 0 44px; }
  .cover__sq, .cover:not(.is-current) .cover__sq { transform: none; filter: none; }
  .cover__cap { font-size: 12px; color: var(--ink); }
  .cover__hint { display: none; }
  .cover__more { display: block; max-height: 0; overflow: hidden; transition: max-height .5s var(--ease); }
  .cover.is-open .cover__more { max-height: 260px; }
  .cover__more p { margin: 10px 0 12px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
  .cover__more span { display: inline-flex; gap: 10px; border: 1px solid var(--ink); padding: 9px 12px; font-size: 13px; }
  .stairs, .field, .arm { display: none; }
}

/* ───────── Character-drawn arm (canvas) + pointing state ───────── */
.arm { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.meta { opacity: 0; transform: translateY(-6px); transition: opacity .35s, transform .5s var(--ease-out); z-index: 5; }
/* Hidden until a cover is clicked */
.read__title, .read__excerpt, .read__go, .pn { opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s .4s; }
.field.is-revealed .meta { opacity: 1; transform: none; }
.field.is-revealed .read__title, .field.is-revealed .read__go, .field.is-revealed .pn { opacity: 1; visibility: visible; transition: opacity .4s; }
.field.is-revealed .read__excerpt { visibility: visible; }
.field { z-index: 1; }
.cover.is-pointed .cover__sq { filter: none !important; transform: scale(.97) !important; }

.sq--lang { font: 500 10px/1 var(--f-mono); letter-spacing: .04em; }
