/* Shared base: one typeface, one size, underlines instead of effects. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.lnk { min-height: 24px; display: inline-flex; align-items: center; }
.lnk:hover, .lnk:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.on { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }
.logo { display: inline-flex; width: 24px; height: 16px; }
.logo svg { width: 24px; height: 16px; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Entry ---------- */
.enter { position: fixed; inset: 0; overflow: hidden; background: #0c0c0c; color: #f2f2f2; }
.enter .photo { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0; cursor: none; }
.enter .photo img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.05); /* hides the light edges of the scan */ filter: grayscale(1) brightness(.82) contrast(1.06); transition: filter .6s; }
.enter.locked .photo img { filter: grayscale(1) brightness(.45) contrast(1.06); }
.enter .shade { position: absolute; left: 0; right: 0; top: 0; height: 160px; background: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,0)); pointer-events: none; }
.enter .shade.bottom { top: auto; bottom: 0; height: 120px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.6)); }
.enter header { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 22px 24px; pointer-events: none; }
.enter header a, .enter header nav { pointer-events: auto; }
.enter .ul { text-decoration: underline; text-underline-offset: 3px; min-height: 24px; display: inline-flex; align-items: center; }
.enter footer { position: absolute; left: 24px; right: 24px; bottom: 18px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: #c4c4c4; pointer-events: none; }
.enter .cursor { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; color: #fff; mix-blend-mode: difference; }
.enter .cursor[hidden] { display: none; }

/* 404 */
.lost { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 14px; white-space: nowrap; }

/* Code gate: five dots */
.gate { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.gate[hidden] { display: none; }
.dots { display: flex; gap: 18px; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid #fff; }
.dot.full { background: #fff; }
.gate input { position: absolute; inset: -20px; opacity: 0; font-size: 16px; border: 0; background: transparent; color: transparent; caret-color: transparent; }
.gate .hint { color: #c4c4c4; }
.gate.wrong .dots { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (pointer: coarse) {
  .enter .photo { cursor: pointer; }
}

/* ---------- Work (boards) ---------- */
.work { --bg: #f8f7f4; --fg: #1a1a1a; --muted: #6b6a66; background: var(--bg); color: var(--fg); transition: background .6s, color .6s; }
.work.dark { --bg: #0e0e0d; --fg: #e8e6e1; --muted: #9b9a96; }
.page { display: flex; min-height: 100vh; }
.side { flex: 0 0 220px; padding: 22px 24px; display: flex; flex-direction: column; gap: 36px; height: 100vh; position: sticky; top: 0; transition: opacity .6s; }
.side .series { display: flex; flex-direction: column; }
.side .series i { font-style: italic; }
.side .controls { display: flex; flex-direction: column; }
.side .meta { margin-top: auto; display: flex; flex-direction: column; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 22px 40px 40px 0; display: flex; flex-direction: column; gap: 18px; }
.main .title { min-height: 18px; transition: opacity .6s; }
.sheet { position: relative; width: min(100%, calc((100vh - 120px) * 1.6)); aspect-ratio: 16 / 10; }
.sheet .layer { position: absolute; inset: 0; animation: fi 1s ease both; }
.frame { position: absolute; overflow: hidden; }
.frame img { display: block; height: auto; }
.sheet .nav { position: absolute; top: 0; bottom: 0; width: 50%; }
.sheet .nav.prev { left: 0; cursor: w-resize; }
.sheet .nav.next { right: 0; cursor: e-resize; }
@keyframes fi { from { opacity: 0; } to { opacity: 1; } }

.work.playing.idle, .work.playing.idle .sheet .nav { cursor: none; }
.work.playing.idle .side, .work.playing.idle .main .title { opacity: 0; pointer-events: none; }

/* Phone: the column goes on top, each board becomes a simple column of its frames. */
@media (max-width: 819px) {
  .page { flex-direction: column; }
  .side { position: static; height: auto; flex: none; gap: 18px; padding: 18px 18px 8px; }
  .side .series { flex-direction: row; flex-wrap: wrap; column-gap: 16px; }
  .side .controls { flex-direction: row; gap: 16px; }
  .side .meta { margin-top: 0; flex-direction: row; gap: 16px; }
  .main { padding: 8px 18px 40px; }
  .main .title { display: none; }
  .sheet { width: 100%; aspect-ratio: auto; }
  .sheet .layer { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
  .frame { position: relative; left: auto !important; top: auto !important; width: 100% !important; }
  .frame.portrait { width: 78% !important; }
  .sheet .nav { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet .layer { animation: none; }
}
html.dark-pre .work { --bg: #0e0e0d; --fg: #e8e6e1; --muted: #9b9a96; }

/* Rearrange (desktop, hold Shift): move frames, resize by the corners. */
.frame img { -webkit-user-drag: none; user-select: none; }
.frame .h { display: none; position: absolute; width: 9px; height: 9px; background: var(--bg); border: 1px solid var(--fg); z-index: 2; }
.frame .h.nw { left: 0; top: 0; cursor: nwse-resize; }
.frame .h.ne { right: 0; top: 0; cursor: nesw-resize; }
.frame .h.sw { left: 0; bottom: 0; cursor: nesw-resize; }
.frame .h.se { right: 0; bottom: 0; cursor: nwse-resize; }
.work.arrange .frame { cursor: move; outline: 1px solid var(--muted); }
.work.arrange .frame .h { display: block; }
.work.arrange .sheet .nav { pointer-events: none; }
.work.arrange, .work.arranging { user-select: none; }
.side button[hidden] { display: none; }
