/* Mise en page : un carnet posé sur la scène. Titre en haut à gauche, époques et points de vue dans le folio,
   les mots de Hugo en bas, les instruments en haut à droite. */
:root {
  --ink: #0e1116;
  --ink-2: #171b22;
  --panel: rgba(13, 16, 21, 0.74);
  --panel-solid: #12161c;
  --paper: #e9e0cb;
  --paper-dim: #a69d89;
  --rule: rgba(233, 224, 203, 0.16);
  --brass: #c9a35f;
  --brass-dim: rgba(201, 163, 95, 0.18);
  --blue: #86a3c4;
  --f-display: "IM Fell French Canon", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --f-body: "EB Garamond", Garamond, "Times New Roman", Georgia, serif;
  --f-ui: "IBM Plex Sans Condensed", "Arial Narrow", "Helvetica Neue", system-ui, sans-serif;
  --gutter: 16px;
  --dw: min(400px, 32vw);
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--ink); color: var(--paper); font-family: var(--f-body); overflow: hidden; }
#app { position: fixed; inset: 0; overflow: hidden; --capL: 304px; --capR: 262px; }
#app.no-keys { --capR: 16px; }
#app.drawing-open { --capR: calc(var(--dw) + 32px); }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(5,6,8,0.42) 100%); }

/* Title */
#title { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 18px); left: 20px; pointer-events: none; max-width: min(420px, calc(100vw - 32px)); text-shadow: 0 1px 12px rgba(0,0,0,.55); }
#title h1 { font-family: var(--f-display); font-weight: 400; font-size: 46px; line-height: 1; margin: 0 0 6px; letter-spacing: .01em; text-wrap: balance; }
/* on its own dark backing so it reads over sky, stone or forest alike */
#title .eyebrow { display: inline-block; font-family: var(--f-ui); font-weight: 500; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper); background: rgba(12, 14, 18, 0.62); border: 1px solid var(--rule); border-radius: 2px; padding: 3px 8px; text-shadow: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* Folio (left panel) */
#folio { position: absolute; left: 16px; top: calc(env(safe-area-inset-top, 0px) + 104px); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: 272px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding: 14px 14px 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
#folio h2 { font-family: var(--f-ui); font-weight: 600; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--paper-dim); margin: 0 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
#folio h2 small { font-weight: 400; letter-spacing: .04em; text-transform: none; font-size: 11px; color: var(--paper-dim); opacity: .8; }
.list { display: flex; flex-direction: column; gap: 2px; }
.item { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 54px 1fr; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 2px; cursor: pointer; color: var(--paper); border-left: 2px solid transparent; }
.item:hover { background: rgba(233,224,203,.06); }
.item:focus-visible { outline: 1px solid var(--brass); outline-offset: 1px; }
.item[aria-pressed="true"] { background: var(--brass-dim); border-left-color: var(--brass); }
.item .k { font-family: var(--f-ui); font-size: 11px; letter-spacing: .06em; color: var(--paper-dim); font-variant-numeric: tabular-nums; }
.item .v { font-family: var(--f-body); font-size: 16px; line-height: 1.15; }
.item .v em { display: block; font-size: 13px; color: var(--paper-dim); font-style: italic; margin-top: 1px; }
.views .item { grid-template-columns: 22px 1fr; }
.views .item .k { font-family: var(--f-display); font-size: 15px; color: var(--brass); letter-spacing: 0; }
.views .item[data-scene-only] .v::after { content: attr(data-scene-only); font-family: var(--f-ui); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); margin-left: 6px; }

/* Toolbar */
#toolbar { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 16px); right: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 32px); }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.btn { all: unset; box-sizing: border-box; font-family: var(--f-ui); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; padding: 8px 11px; color: var(--paper); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { background: rgba(233,224,203,.07); }
.btn:focus-visible { outline: 1px solid var(--brass); outline-offset: -2px; }
.btn[aria-pressed="true"] { background: var(--brass-dim); color: #f3e3bf; box-shadow: inset 0 -2px 0 var(--brass); }
.seg .btn + .btn { border-left: 1px solid var(--rule); }
/* the story: a way out of exploring, set apart from its controls, in the accent */
.btn.accent { margin-left: 10px; padding: 8px 14px; background: var(--brass); color: #1a140a; font-weight: 600; border-radius: 3px; box-shadow: 0 6px 22px rgba(201, 163, 95, .28); }
.btn.accent:hover { background: #d8b674; }
.btn.accent:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
/* in the story, of the instruments only the quality of the rendering */
#app.story #toolbar > :not(#segTools), #app.story #segTools > :not(#quality) { display: none; }
#app.story #quality { border-left: 0; }
select.btn { appearance: none; -webkit-appearance: none; padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, var(--paper-dim) 50%), linear-gradient(135deg, var(--paper-dim) 50%, transparent 50%); background-position: calc(100% - 12px) 52%, calc(100% - 8px) 52%; background-size: 4px 4px; background-repeat: no-repeat; }
select.btn option { background: var(--panel-solid); color: var(--paper); text-transform: none; }

/* Caption: the book's words, with a pager to turn through the passages */
#caption { position: absolute; left: var(--capL); right: var(--capR); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); max-width: 700px; margin: 0 auto; padding: 14px 20px 8px; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .4s ease; box-sizing: border-box; }
#caption .place { font-family: var(--f-ui); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--brass); margin-bottom: 4px; }
#caption blockquote { margin: 0; font-family: var(--f-body); font-style: italic; font-size: 18px; line-height: 1.38; color: var(--paper); text-wrap: pretty; hyphens: auto; max-height: 30vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; outline: none; }
#caption figcaption { margin-top: 6px; font-family: var(--f-ui); font-size: 11px; letter-spacing: .04em; color: var(--paper-dim); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
#caption figcaption .tools { display: flex; gap: 12px; flex: none; }
#caption .link { all: unset; cursor: pointer; color: var(--paper-dim); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
#caption .link:hover { color: var(--paper); }
#caption .musiclink { display: none; }
#app.story #caption .musiclink { display: inline; }
#caption .storyonly { display: none; }
#app.story #caption .storyonly { display: inline; }
#caption .link:focus-visible { outline: 1px solid var(--brass); outline-offset: 2px; }
#caption #capDraw { color: var(--brass); }
.pager { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--rule); font-family: var(--f-ui); font-size: 12px; color: var(--paper-dim); font-variant-numeric: tabular-nums; user-select: none; }
.pager button { all: unset; box-sizing: border-box; width: 32px; height: 26px; display: grid; place-items: center; border-radius: 2px; font-family: var(--f-display); font-size: 22px; line-height: 1; color: var(--paper); cursor: pointer; }
.pager button:hover:not(:disabled) { background: rgba(233,224,203,.08); color: #f3e3bf; }
.pager button:focus-visible { outline: 1px solid var(--brass); }
.pager button:disabled { opacity: .25; cursor: default; }
.pager span { min-width: 54px; text-align: center; letter-spacing: .08em; }
#caption.min blockquote, #caption.min .place, #caption.min .pager { display: none; }

/* Story mode: a player on the caption, the chapters in the folio */
.storybar, .stprog { display: none; }
#app.story .storybar { display: flex; align-items: center; gap: 2px; margin: -4px -6px 8px; }
/* in the story: no help panel; the caption lighter, the scene seen through it */
#app.story #keys { display: none; }
#app.story { --capR: 16px; }
#app.story #caption { background: rgba(13, 16, 21, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#app.story #caption.min { padding-bottom: 6px; }
#app.music-free #caption #capMusic { display: inline; }
#app.story .stprog { display: block; height: 3px; margin: 0 0 10px; background: var(--rule); cursor: pointer; position: relative; }
.stprog i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--brass); }
.storybar button { all: unset; box-sizing: border-box; width: 30px; height: 28px; display: grid; place-items: center; border-radius: 2px; color: var(--paper); cursor: pointer; }
.storybar button:hover { background: rgba(233,224,203,.08); color: #f3e3bf; }
.storybar button:focus-visible { outline: 1px solid var(--brass); }
.storybar .speed { width: auto; padding: 0 8px; font-family: var(--f-ui); font-size: 12px; letter-spacing: .04em; color: var(--paper-dim); }
.sttitle { flex: 1; min-width: 0; margin-left: 8px; font-family: var(--f-body); font-size: 16px; line-height: 1.2; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sttitle b { font-family: var(--f-display); font-weight: 400; color: var(--brass); margin-right: 4px; }
.sttitle em { font-style: italic; font-size: 13px; color: var(--paper-dim); margin-left: 10px; }
.chapters .item { grid-template-columns: 30px 1fr; }
.chapters .item .k { font-family: var(--f-display); font-size: 15px; color: var(--brass); letter-spacing: 0; }
#app.story #folio .explore { display: none; }
/* while the story plays the folio folds down to the title of the chapter; a click opens it again */
#folio h2 .h2r { display: flex; align-items: baseline; gap: 10px; }
#folio .fold { all: unset; cursor: pointer; font-family: var(--f-ui); font-size: 11px; letter-spacing: .04em; text-transform: none; color: var(--paper-dim); text-decoration: underline; text-underline-offset: 2px; }
#folio .fold:hover { color: var(--paper); }
#folioMini { all: unset; box-sizing: border-box; display: none; width: 100%; align-items: baseline; gap: 10px; cursor: pointer; font-family: var(--f-body); font-size: 16px; line-height: 1.25; color: var(--paper); }
#folioMini .v { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#folioMini .v b { font-family: var(--f-display); font-weight: 400; color: var(--brass); margin-right: 6px; }
#folioMini .more { flex: none; font-family: var(--f-ui); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-dim); }
#folioMini:hover .more { color: var(--paper); }
#folioMini:focus-visible, #folio .fold:focus-visible { outline: 1px solid var(--brass); outline-offset: 2px; }
#app.story.folio-mini #folio { bottom: auto; padding: 10px 14px; overflow: hidden; }
#app.story.folio-mini #folio > section { display: none; }
#app.story.folio-mini #folioMini { display: flex; }
#app:not(.story) #folio .chapters-list { display: none; }
#app.story #title { opacity: .85; }

/* Hugo's drawing */
#drawing { position: absolute; z-index: 8; right: 16px; top: calc(env(safe-area-inset-top, 0px) + 64px); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: var(--dw); box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 14px; background: var(--panel-solid); border: 1px solid var(--rule); border-radius: 3px; }
#drawing header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#drawing h3 { font-family: var(--f-display); font-weight: 400; font-size: 22px; line-height: 1.1; margin: 0; }
#drawing .frame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#drawing img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#drawing p { font-family: var(--f-ui); font-size: 12px; line-height: 1.45; color: var(--paper-dim); margin: 0; }
#drawing p em { color: var(--paper); }
#drawing a { color: var(--blue); }

/* Labels */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; font-family: var(--f-ui); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--paper); white-space: nowrap; padding: 3px 7px 3px; background: rgba(12,14,18,.62); border: 1px solid var(--rule); border-radius: 2px; }
.lbl::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 16px; background: rgba(233,224,203,.45); }
.lbl:hover { border-color: var(--brass); color: #f3e3bf; }
#app:not(.show-labels) #labels { display: none; }

/* Walk HUD */
#cross { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; pointer-events: none; display: none; }
#cross::before, #cross::after { content: ""; position: absolute; background: rgba(233,224,203,.8); }
#cross::before { left: 6px; top: 0; width: 2px; height: 14px; }
#cross::after { top: 6px; left: 0; height: 2px; width: 14px; }
#app.walk #cross { display: block; }
#hint { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font-family: var(--f-ui); font-size: 12px; letter-spacing: .06em; color: var(--paper); background: rgba(12,14,18,.6); padding: 6px 10px; border-radius: 2px; pointer-events: none; opacity: 0; transition: opacity .25s; }
#hint.on { opacity: 1; }
#keys { position: absolute; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: 230px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; font-family: var(--f-ui); font-size: 12px; color: var(--paper-dim); line-height: 1.55; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#keys b { color: var(--paper); font-weight: 500; }
#keys .t { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--paper-dim); margin-bottom: 4px; display: flex; justify-content: space-between; }
#keys .t button { all: unset; cursor: pointer; color: var(--paper-dim); }
kbd { font-family: var(--f-ui); font-size: 11px; padding: 0 4px; border: 1px solid var(--rule); border-radius: 2px; color: var(--paper); }

/* Joystick (touch walk) */
#stick { position: absolute; left: 24px; bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); width: 110px; height: 110px; border-radius: 50%; border: 1px solid var(--rule); background: rgba(12,14,18,.35); display: none; touch-action: none; }
#stick i { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(233,224,203,.35); }
#app.walk.touch #stick { display: block; }

/* Loader */
#loader { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, #1a1f27 0%, var(--ink) 70%); z-index: 20; transition: opacity .8s ease; padding-inline: var(--gutter); }
#loader.done { opacity: 0; pointer-events: none; }
#loader .wrap { display: flex; align-items: center; gap: clamp(28px, 6vw, 80px); width: min(1060px, 100%); }
#loader .box { flex: 1 1 340px; min-width: min(300px, 100%); text-align: left; }
/* Hugo's own drawing while the model loads: what the page is about to raise */
#loader figure { flex: 0 0 auto; margin: 0; height: min(78vh, 780px, calc((100vw - 420px) * 1.5)); aspect-ratio: 1003 / 1500; }
#loader figure img { display: block; height: 100%; width: 100%; object-fit: contain; box-shadow: 0 18px 50px rgba(0,0,0,.55); animation: drawIn 1.6s ease both; }
@keyframes drawIn { from { opacity: 0; } to { opacity: 1; } }
#loader figcaption { margin-top: 10px; font-family: var(--f-body); font-style: italic; font-size: 14px; color: var(--paper-dim); }
@media (max-width: 720px) {
  #loader .wrap { flex-direction: column; align-items: stretch; gap: 18px; }
  #loader .box { flex: none; }
  #loader figure { height: 46vh; align-self: center; }
  #loader.ready figure { height: 34vh; }
  #loader .choose { max-width: none; }
  #loader h2 { font-size: 42px; }
}
#loader h2 { font-family: var(--f-display); font-weight: 400; font-size: 54px; margin: 0; line-height: 1; }
#loader p { font-family: var(--f-body); font-style: italic; font-size: 18px; line-height: 1.4; color: var(--paper-dim); margin: 12px 0 22px; }
#loader .bar { height: 2px; background: var(--rule); position: relative; overflow: hidden; }
#loader .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--brass); transition: width .25s ease; }
#loader .step { margin-top: 8px; font-family: var(--f-ui); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--paper-dim); min-height: 1.4em; }
/* once built: the two ways in, the story first */
#loader.ready .bar, #loader.ready .step { display: none; }
#loader .choose { display: flex; flex-direction: column; gap: 10px; max-width: 430px; animation: drawIn .6s ease both; }
#loader .choose button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 3px; padding: 14px 18px; border-radius: 3px; font-family: var(--f-ui); font-weight: 500; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; transition: background .2s ease, border-color .2s ease, box-shadow .2s ease; }
#loader .choose small { font-family: var(--f-body); font-weight: 400; font-style: italic; font-size: 16px; letter-spacing: 0; text-transform: none; }
#loader .choose .primary { background: var(--brass); color: #1a140a; box-shadow: 0 10px 34px rgba(201, 163, 95, .22); }
#loader .choose .primary small { color: rgba(26, 20, 10, .78); }
#loader .choose .primary:hover { background: #d8b674; box-shadow: 0 12px 40px rgba(201, 163, 95, .32); }
#loader .choose .secondary { border: 1px solid var(--rule); color: var(--paper); background: rgba(233, 224, 203, .03); }
#loader .choose .secondary small { color: var(--paper-dim); }
#loader .choose .secondary:hover { border-color: var(--paper-dim); background: rgba(233, 224, 203, .07); }
#loader .choose button:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
#loader .err { color: #e6a08a; font-family: var(--f-ui); font-size: 13px; margin-top: 12px; white-space: pre-wrap; }

/* Notes sheet */
#notes { position: absolute; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(6,7,9,.55); padding-inline: var(--gutter); }
#notes .sheet { width: min(760px, 100%); max-height: min(82vh, 100% - 40px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--rule); border-radius: 3px; padding: 24px 28px 26px; }
#notes h3 { font-family: var(--f-display); font-weight: 400; font-size: 32px; margin: 0 0 6px; }
#notes h4 { font-family: var(--f-ui); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--brass); margin: 20px 0 6px; font-weight: 600; }
#notes p, #notes li { font-family: var(--f-body); font-size: 17px; line-height: 1.5; color: var(--paper); max-width: 66ch; }
#notes li { margin-bottom: 6px; }
#notes ul { padding-left: 20px; margin: 6px 0; }
#notes q { font-style: italic; quotes: "«\00a0" "\00a0»"; }
#notes table { border-collapse: collapse; font-family: var(--f-ui); font-size: 13px; width: 100%; }
#notes td, #notes th { text-align: left; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
#notes th { color: var(--paper-dim); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; font-size: 11px; }
#notes td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }
#notes .close { float: right; }
#notes a { color: var(--blue); }
.tablewrap { overflow-x: auto; }

#folioToggle { display: none; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

@media (max-width: 760px) {
  #title h1 { font-size: 34px; }
  #title .eyebrow { font-size: 10.5px; letter-spacing: .1em; }
  #folioToggle { display: inline-flex; }
  #folio { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); left: 12px; right: 12px; width: auto; max-height: 52%; z-index: 6; display: none; }
  #app.folio-open #folio { display: flex; }
  #folio .fold, #app.story.folio-mini #folioMini { display: none; }
  #app.story.folio-mini #folio > section.chapters-list { display: flex; flex-direction: column; }
  #app, #app.no-keys, #app.drawing-open { --capL: 12px; --capR: 12px; }
  #caption { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); padding: 10px 14px 6px; }
  #caption blockquote { font-size: 15px; max-height: 24vh; }
  #caption figcaption { flex-wrap: wrap; }
  #drawing { inset: 0; width: auto; z-index: 16; border-radius: 0; border: 0; padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px calc(env(safe-area-inset-bottom, 0px) + 14px); }
  #keys { display: none; }
  #toolbar { top: auto; bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 100px); right: 12px; }
  #stick { bottom: calc(env(safe-area-inset-bottom, 0px) + 140px); }
}
@media (min-width: 761px) and (max-width: 1100px) { #keys { display: none; } #app { --capR: 16px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
