/* LETHE
   Grayscale only. The single colour in the sheet is oxide, and it is never decoration:
   it marks a key that has been spent.

   One page is set in negative: /hole, the one about the problem. */

:root {
  --void: #000000;
  --paper: #d6d2c8;
  --ink: #0c0c0d;

  --fg: #d9d5cb;        /* texte courant */
  --fg-dim: #8f8a81;    /* texte secondaire */
  --fg-faint: #5e5c58;  /* etiquettes */
  --halo: #f6f1e6;      /* ce qui doit briller */
  --rule: rgba(190, 185, 175, 0.15);
  --rule-hard: rgba(190, 185, 175, 0.28);
  --panel: rgba(8, 8, 9, 0.6);
  --oxide: #9c3620;

  --mono: "Azeret Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --didot: "GFS Didot", Georgia, serif;

  --gut: clamp(1.25rem, 5vw, 3rem);
  --margin-w: clamp(0rem, 8vw, 7.5rem);
  --nav-h: 58px;
  --measure: 56ch;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--void);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.68;
  letter-spacing: -0.005em;
  overflow-x: hidden;
}
@media (min-width: 48rem) { body { font-size: 16px; } }

::selection { background: var(--halo); color: var(--void); }

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--halo);
  outline-offset: 3px;
}

/* --- la page en negatif ------------------------------------------------------ */

body[data-page="hole"] {
  --fg: #26241f;
  --fg-dim: #4e4a43;
  --fg-faint: #6f6a61;
  --halo: #0a0a0a;
  --rule: rgba(12, 12, 13, 0.22);
  --rule-hard: rgba(12, 12, 13, 0.45);
  --panel: rgba(214, 210, 200, 0.78);
  color: var(--fg);
}
/* La page en negatif est une feuille, pas un fond sombre eclairci : le fleuve se retire
   entierement et laisse le grain du papier. */
body[data-page="hole"] { background: var(--paper); }
body[data-page="hole"] #river { display: none; }
body[data-page="hole"]::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(120% 90% at 50% 40%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.1) 86%, rgba(0, 0, 0, 0.22) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  opacity: 0.55;
}
body[data-page="hole"] ::selection { background: var(--ink); color: var(--paper); }

/* --- le sol ------------------------------------------------------------------ */

#river {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  background: var(--void);
}
/* 🔴 Pas de `body > *:not(#river)` ici : `:not(#river)` compte comme un id, donc la regle
   pesait plus lourd que `.margin` et lui reprenait son `position: fixed`. Chaque couche
   dit sa propre place. */
.page, .foot { position: relative; z-index: 1; }

/* --- la marge : la signature de la page, imprimee le long du bord ------------- */

.margin {
  position: fixed;
  left: 0;
  top: var(--nav-h);
  bottom: 0;
  width: var(--margin-w);
  padding: 1.2rem 0 1.2rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
  font-size: 8.5px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.margin span { opacity: 0.14; white-space: nowrap; transition: opacity 0.18s linear; }
.margin span[data-on="1"] { opacity: 0.6; }
@media (max-width: 62rem) { .margin { display: none; } }

/* --- la barre ---------------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: clamp(1rem, 4vw, 2.5rem);
  padding: 0 var(--gut);
  border-bottom: 1px solid transparent;
  transition: background 0.25s linear, border-color 0.25s linear;
}
.nav--sunk {
  background: color-mix(in srgb, var(--void) 72%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--rule);
}
body[data-page="hole"] .nav--sunk { background: color-mix(in srgb, var(--paper) 80%, transparent); }

.nav-mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--halo);
  flex: 0 0 auto;
}
.nav-mark svg { width: 17px; height: 17px; display: block; }
.nav-mark span {
  font-family: var(--didot);
  font-size: 1.12rem;
  letter-spacing: 0.08em;
  line-height: 1;
}

.nav-links {
  display: flex;
  gap: clamp(0.85rem, 2.4vw, 1.9rem);
  font-size: 0.78rem;
  color: var(--fg-faint);
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1 1 auto;
}
.nav-links::-webkit-scrollbar { display: none; }
/* Sur un telephone la rangee defile : un fondu sur le bord le dit. */
@media (max-width: 52rem) {
  .nav-links {
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent 100%);
    mask-image: linear-gradient(to right, #000 85%, transparent 100%);
  }
}
.nav-links a { white-space: nowrap; padding: 0.35rem 0; border-bottom: 1px solid transparent; }
.nav-links a:hover { color: var(--fg); }
.nav-links a[data-on="1"] { color: var(--halo); border-bottom-color: var(--halo); }

.nav-chain {
  font-size: 0.72rem;
  color: var(--fg-faint);
  white-space: nowrap;
  flex: 0 0 auto;
}
@media (max-width: 40rem) { .nav-chain { display: none; } }

/* --- la mise en page --------------------------------------------------------- */

.wrap {
  max-width: 74rem;
  margin: 0 auto;
  padding-left: calc(var(--margin-w) + var(--gut));
  padding-right: var(--gut);
}
@media (max-width: 62rem) { .wrap { padding-left: var(--gut); } }

.band { padding: clamp(3.5rem, 11vh, 7rem) 0; border-top: 1px solid var(--rule); }
.band--open { padding-top: clamp(2.5rem, 7vh, 4.5rem); border-top: 0; }

/* Le fleuve passe sous le texte, jamais dedans : une bande de lecture le tempere.
   Seule la tete de la page d'entree reste a nu, c'est la qu'il doit se voir. */
body:not([data-page="hole"]) .band {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.74) 45%, rgba(0, 0, 0, 0.82));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* --- la tete de la page d'entree --------------------------------------------- */

.hero { padding-bottom: clamp(3rem, 9vh, 5.5rem); }
.plate { margin: 0 0 clamp(1.6rem, 5vh, 2.6rem); width: 100%; }
#skyline {
  display: block;
  width: 100%;
  height: clamp(140px, 24vh, 240px);
  mix-blend-mode: screen;
  opacity: 0.95;
  image-rendering: pixelated;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 100%);
}
.plate-cap {
  margin: 0 0 clamp(2.4rem, 7vh, 4rem);
  font-size: 0.78rem;
  color: var(--fg-dim);
  max-width: 46ch;
}

.mark {
  font-family: var(--didot);
  font-weight: 400;
  margin: 0;
  line-height: 0.82;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 clamp(0.75rem, 3vw, 2rem);
}
.mark-el {
  font-size: clamp(3.75rem, 16vw, 10rem);
  letter-spacing: 0.02em;
  color: var(--halo);
}
.mark-la {
  font-family: var(--mono);
  font-size: clamp(0.85rem, 2vw, 1.2rem);
  letter-spacing: 0.55em;
  color: var(--fg-faint);
  align-self: flex-end;
  padding-bottom: 0.6em;
}

.lede {
  font-family: var(--didot);
  font-size: clamp(1.45rem, 4.2vw, 2.4rem);
  line-height: 1.12;
  margin: clamp(1.4rem, 4vh, 2.2rem) 0 0;
  max-width: 24ch;
  color: var(--halo);
}
.sub { margin: 1.1rem 0 0; max-width: 54ch; color: var(--fg-dim); }

/* --- le signeur de la tete ---------------------------------------------------- */

.sign-live { margin-top: clamp(2.2rem, 6vh, 3.4rem); max-width: 44rem; }
.sign-live label,
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--fg-faint);
  margin-bottom: 0.5rem;
}
.sign-live input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  color: var(--halo);
  font-family: var(--mono);
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  font-weight: 400;
  padding: 0.45rem 0 0.7rem;
}
.sign-live input:focus { outline: 0; border-bottom-color: var(--halo); }

/* --- les bandes de donnees ---------------------------------------------------- */

.strip, .readout { margin: 1.6rem 0 0; display: grid; gap: 0.5rem; }
.strip > div, .readout > div {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 0.6rem;
  align-items: start;
}
.strip dt, .readout dt { color: var(--fg-faint); font-size: 0.76rem; }
.strip dd, .readout dd {
  margin: 0;
  font-size: 0.76rem;
  color: var(--fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.readout .dd--wrap {
  white-space: normal;
  max-height: 4.6em;
  overflow: hidden;
  line-height: 1.5;
  color: var(--fg-faint);
}
@media (max-width: 44rem) {
  .strip > div, .readout > div { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* --- les titres et le texte ---------------------------------------------------- */

.say {
  font-family: var(--didot);
  font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 1.04;
  margin: 0 0 clamp(1.8rem, 5vh, 2.8rem);
  max-width: 20ch;
  color: var(--halo);
  text-wrap: balance;
}
.say--wide { max-width: 26ch; }
.say--small { font-size: clamp(1.5rem, 3.4vw, 2.2rem); margin-top: clamp(3rem, 8vh, 4.5rem); }

.prose { max-width: var(--measure); color: var(--fg-dim); }
.prose p { margin: 0 0 1.25em; }
.prose--tight { max-width: 58ch; }
.prose .turn { color: var(--halo); }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 0.05em 0.3em;
  background: color-mix(in srgb, var(--fg) 14%, transparent);
}

.more { margin: clamp(2.2rem, 6vh, 3.2rem) 0 0; font-size: 0.82rem; }
.more a {
  color: var(--halo);
  border-bottom: 1px solid var(--rule-hard);
  padding-bottom: 0.15rem;
}
.more a:hover { border-bottom-color: var(--halo); }

/* --- les trois appuis de la page d'entree -------------------------------------- */

.hold { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-width: 62rem; }
.hold li { padding: 1.4rem 0; border-top: 1px solid var(--rule); }
.hold h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.95rem;
  margin: 0 0 0.45rem;
  color: var(--halo);
}
.hold p { margin: 0; color: var(--fg-dim); max-width: 60ch; font-size: 0.9rem; }
@media (min-width: 64rem) {
  .hold li { display: grid; grid-template-columns: 22rem 1fr; gap: 2.5rem; align-items: baseline; }
  .hold h3 { margin: 0; }
}

/* --- les mouvements de la page « how » ----------------------------------------- */

.movement {
  max-width: 100%;
  padding-top: clamp(1.8rem, 5vh, 2.6rem);
  margin-top: clamp(1.8rem, 5vh, 2.6rem);
  border-top: 1px solid var(--rule);
}
.movement:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.movement h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1rem;
  margin: 0 0 0.9rem;
  color: var(--halo);
}
.movement p { margin: 0 0 1.1em; color: var(--fg-dim); max-width: var(--measure); }
.diagram { margin: 1.6rem 0 0; border-top: 1px solid var(--rule-hard); padding-top: 1rem; max-width: 34rem; }
.diagram svg { display: block; width: 100%; height: auto; }

@media (min-width: 64rem) {
  .movement { display: grid; grid-template-columns: minmax(0, 52ch) minmax(0, 1fr); column-gap: clamp(2rem, 5vw, 4rem); align-items: start; }
  .movement h3 { grid-column: 1 / -1; }
  .movement p { grid-column: 1; }
  .movement .diagram { grid-column: 2; grid-row: 2 / span 4; margin-top: 0.35rem; }
}

/* --- l'instrument et le porte-monnaie ------------------------------------------- */

.tool {
  margin-top: clamp(2.2rem, 6vh, 3.2rem);
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--rule);
  padding: clamp(1.4rem, 4vw, 2.1rem);
  max-width: 60rem;
}
.tool h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--halo);
}
.tool-note { margin: 0 0 1.6rem; color: var(--fg-faint); font-size: 0.85rem; max-width: 58ch; }

.field { margin-bottom: 1.1rem; }
.field-row { display: flex; gap: 0.75rem; align-items: stretch; flex-wrap: wrap; }
.field-row--tight { margin-top: 0.85rem; align-items: center; }
.field-row input { flex: 1 1 24rem; }
.field input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  color: var(--halo);
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 300;
  padding: 0.4rem 0 0.6rem;
}
.field input:focus { outline: 0; border-bottom-color: var(--halo); }

#in-phrase {
  width: 100%;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--halo);
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 300;
  line-height: 1.6;
  padding: 0.7rem 0.8rem;
  resize: vertical;
}
#in-phrase:focus { outline: 0; border-color: var(--fg-dim); }

button {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--rule-hard);
  padding: 0.5rem 1rem;
  cursor: pointer;
}
button:hover { border-color: var(--halo); color: var(--halo); }

.hint { font-size: 0.78rem; color: var(--fg-faint); }
.hint[data-kind="bad"] { color: var(--oxide); }

.verdict {
  margin: 1.6rem 0 0;
  font-size: 0.85rem;
  color: var(--fg-dim);
  border-left: 2px solid var(--rule-hard);
  padding-left: 0.9rem;
}
.verdict[data-state="ok"] { border-left-color: var(--halo); color: var(--halo); }
.verdict .spent { display: block; margin-top: 0.5rem; color: var(--oxide); }

/* --- la liste des comptes -------------------------------------------------------- */

#chain-rows { display: grid; gap: 0; margin-top: 1.6rem; }
.acct {
  display: grid;
  grid-template-columns: 2rem 1fr auto auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8rem;
}
.acct[data-open="1"] { cursor: pointer; }
.acct[data-open="1"]:hover { background: color-mix(in srgb, var(--halo) 5%, transparent); }
.acct[data-chosen="1"] { background: color-mix(in srgb, var(--halo) 8%, transparent); }
.acct-n { color: var(--fg-faint); }
.acct-addr { color: var(--fg-dim); overflow-wrap: anywhere; }
.acct[data-funded="1"] .acct-addr { color: var(--halo); }
.acct-bal { color: var(--halo); white-space: nowrap; }
.acct[data-spent="1"] .acct-bal { color: var(--oxide); }
.acct-copy { padding: 0.25rem 0.6rem; font-size: 0.72rem; }

#spend {
  margin-top: clamp(1.8rem, 4vh, 2.4rem);
  padding-top: clamp(1.4rem, 3vh, 1.9rem);
  border-top: 1px solid var(--rule);
}
#spend h4 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  color: var(--halo);
}
.readout--tight { margin-top: 1.2rem; gap: 0.5rem; }
#form-spend .readout--tight { margin-bottom: 1.6rem; }
#spend-state a { color: var(--halo); }

@media (max-width: 44rem) {
  .acct { grid-template-columns: 1.6rem 1fr auto; }
  .acct-copy { grid-column: 2 / -1; justify-self: start; margin-top: 0.3rem; }
}

/* --- les parametres ------------------------------------------------------------- */

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 0 clamp(1.5rem, 5vw, 4rem);
}
.spec-grid dl { margin: 0; }
.spec-grid > dl > div {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.82rem;
}
.spec-grid dt { color: var(--fg-faint); }
.spec-grid dd { margin: 0; color: var(--fg-dim); }

.figures { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-width: 100%; }
.figures li {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1.25rem;
  align-items: baseline;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--rule);
}
.figures li:first-child { border-top: 1px solid var(--rule-hard); }
.figures b {
  font-family: var(--didot);
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 400;
  line-height: 1;
  text-align: right;
  color: var(--halo);
}
.figures span { color: var(--fg-dim); font-size: 0.85rem; }
@media (min-width: 64rem) {
  .figures li { grid-template-columns: 9rem minmax(0, 36ch) 1fr; }
  .figures li > span { grid-column: 2; }
}
@media (max-width: 34rem) {
  .figures li { grid-template-columns: 1fr; gap: 0.1rem; }
  .figures b { text-align: left; }
}

/* --- le pied --------------------------------------------------------------------- */

.foot { border-top: 1px solid var(--rule); padding: 2.2rem 0; margin-top: clamp(3rem, 9vh, 6rem); }
.foot-in { display: flex; justify-content: space-between; align-items: baseline; gap: 1.5rem; flex-wrap: wrap; }
.foot-mark { font-family: var(--didot); font-size: 1.5rem; color: var(--fg-faint); }
.foot-line { font-size: 0.76rem; color: var(--fg-faint); }
.foot-chain { font-size: 0.72rem; color: var(--fg-faint); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

/* --- le portefeuille branche ---------------------------------------------------- */

.nav-connect {
  flex: 0 0 auto;
  padding: 0.35rem 0.8rem;
  font-size: 0.72rem;
  border-color: var(--rule);
  color: var(--fg-dim);
}
.nav-connect:hover { border-color: var(--halo); color: var(--halo); }
.nav-connect[data-on="1"] { color: var(--halo); border-color: var(--rule-hard); }

.aside {
  margin-top: 1.4rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--rule-hard);
  font-size: 0.84rem;
  color: var(--fg-faint);
}

.picker {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: var(--gut);
}
.picker-in {
  background: var(--panel);
  border: 1px solid var(--rule-hard);
  padding: 1.6rem;
  min-width: min(26rem, 100%);
}
.picker h4 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
  color: var(--halo);
}
.picker p { margin: 0 0 1.2rem; font-size: 0.8rem; color: var(--fg-faint); }
.picker ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.picker button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  justify-content: flex-start;
  padding: 0.6rem 0.8rem;
}
.picker img { width: 18px; height: 18px; display: block; }

.acct-fund { padding: 0.25rem 0.6rem; font-size: 0.72rem; }
