/* The landing page (ADR-0175): the storytelling is plain text on the desk; each excerpt is a
   cahier ; a sheet of ruled paper with a red margin, where the engine reads and answers, exactly
   as in the app. Colours are the desktop's (apps/dotmemo-desktop/src/pen.rs): PAPER in light,
   SLATE in dark. Both themes are mandatory and follow the system. */
:root {
  --table: #e7e1d3;
  --page: #fcf9f2;
  --rule: #ebe5d8;
  --red: #dc8a7c;
  --ink: #23242a;
  --quiet: #6d6a60;
  --voice: #1f3fa6;
  --pencil: #6a665c;
  --slip: #ffffff;
  --marker: #ffe88f;
  --shadow: rgba(0, 0, 0, 0.16);
  --brand: #253b31;
  --ui: "Fira Sans", system-ui, sans-serif;
  --site-measure: 54rem;
  --measure: var(--site-measure);
  --prose-measure: 44rem;
  color-scheme: light dark;

  --lh: 1.85rem;
  --gutter: 2.6rem;   /* the cahier's left margin, before the red rule */
  --note: 7.5rem;     /* the category, right-aligned */
  --amt: 6rem;        /* the signed amount, right-aligned */
  --gap: 0.7rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --table: #101413;
    --page: #1b2221;
    --rule: #28312f;
    --red: #8a5a50;
    --ink: #ece8dc;
    --quiet: #a3aaa4;
    --voice: #f4d67e;
    --pencil: #b2b8b1;
    --slip: #273130;
    --marker: #5f5428;
    --shadow: rgba(0, 0, 0, 0.5);
    --brand: #d1e2d5;
  }
}

@font-face {
  font-family: "dotmemo";
  src: url("/fonts/dotmemo-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face { font-family: "Noto Serif"; src: url("/fonts/noto-serif.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url("/fonts/noto-serif-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url("/fonts/noto-serif-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("/fonts/fira-sans.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("/fonts/fira-sans.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("/fonts/fira-sans-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 4.75rem;
  scrollbar-gutter: stable;
}
body {
  margin: 0;
  background: var(--table);
  color: var(--ink);
  font-family: "Noto Serif", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.6;
  padding: 0 1.1rem;
}

body[data-page="spec"] {
  --measure: 68rem;
  --prose-measure: 54rem;
}

:focus-visible {
  outline: 2px solid var(--voice);
  outline-offset: 3px;
}
::selection { background: var(--marker); color: var(--ink); }
.skip-link {
  position: fixed;
  z-index: 4;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--page);
  color: var(--ink);
  clip-path: inset(50%);
}
.skip-link:focus { clip-path: none; }
.site-header, .site-footer {
  max-width: var(--measure);
  margin-inline: auto;
}
.site-bar-inner {
  max-width: var(--site-measure);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 1.25rem;
  font: 0.9rem/1.4 var(--ui);
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--table);
  padding-block: 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 18%, var(--table));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  color: var(--brand);
  font-family: "dotmemo", Georgia, serif;
  font-size: 1.2rem;
  font-weight: 400;
  text-decoration: none;
}
.site-header nav, .site-footer nav {
  display: flex;
  flex-wrap: wrap;
  column-gap: clamp(0.65rem, 2.5vw, 1.15rem);
}
.site-header nav a, .site-footer nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--brand);
  text-underline-offset: 0.22em;
}
.site-header nav a { text-decoration: none; }
.site-header nav a:hover { text-decoration: underline; }
.site-header nav a[href="#try"] { font-weight: 600; }
.site-header .language { min-width: 2.75rem; justify-content: center; }
.site-footer {
  margin-top: clamp(2.75rem, 7vw, 4.5rem);
  padding-block: 0.85rem 1.35rem;
  border-top: 1px solid color-mix(in srgb, var(--ink) 18%, var(--table));
}
.site-footer p { margin: 0.2rem 0; font: 1.1rem/1.4 "dotmemo", Georgia, serif; color: var(--brand); }

.sheet { max-width: var(--measure); margin-inline: auto; }

/* ---- The storytelling, plain on the desk. ---- */
.prose { margin: 0; overflow-wrap: anywhere; }
.prose h1 {
  font-family: "dotmemo", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.35rem, 6vw, 3.65rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin: clamp(2.5rem, 7vw, 4.5rem) 0 0.6rem;
}
.prose h1 + p {
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--brand);
  margin: 0.2rem 0 1.2rem;
}
.prose h2 {
  font-family: "dotmemo", Georgia, serif;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 2.4rem 0 0.4rem;
  scroll-margin-top: 1rem;
  text-wrap: balance;
}
.prose p {
  margin: 0.6rem 0;
  max-width: var(--prose-measure);
  text-wrap: pretty;
}

.prose :is(ul, ol) {
  max-width: var(--prose-measure);
  margin-block: 0.6rem;
  padding-inline-start: 1.4em;
}
.prose li + li { margin-top: 0.25em; }
.prose code {
  font: 0.86em/1.4 ui-monospace, monospace;
  overflow-wrap: anywhere;
}
.prose :not(pre) > code {
  padding: 0.08em 0.25em;
  border-radius: 0.2em;
  background: var(--page);
}
.prose pre {
  overflow: auto;
  padding: 0.7rem 0.9rem;
  background: var(--page);
}
.prose pre code { overflow-wrap: normal; }
.prose .table-scroll { overflow-x: auto; margin-block: 1rem; }
.prose table { width: 100%; border-collapse: collapse; }
.prose :is(th, td) {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 18%, var(--table));
  text-align: start;
  vertical-align: top;
}
.prose th { background: var(--page); }
.prose blockquote {
  margin-inline: 0;
  border-inline-start: 2px solid var(--red);
  padding-inline-start: 1rem;
}
.prose a { color: var(--voice); text-underline-offset: 0.18em; }
.prose img { max-width: 100%; height: auto; }

/* ---- The cahier: a sheet of ruled paper laid on the desk. ---- */
.cahier {
  position: relative;
  margin: 1.4rem 0 2.2rem;
  background: var(--page);
  border-radius: 3px;
  box-shadow: 0 1px 2px var(--shadow), 0 12px 30px var(--shadow);
  padding: 1.3rem 1.3rem 1.3rem var(--gutter);
  background-image: repeating-linear-gradient(var(--page), var(--page) calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px), var(--rule) var(--lh));
  background-position: 0 1.3rem;
  font-size: 1.05rem;
  line-height: var(--lh);
}
.cahier::before {
  content: "";
  position: absolute;
  top: 0.6rem; bottom: 0.6rem;
  left: calc(var(--gutter) - 0.8rem);
  border-left: 2px solid var(--red);
}

/* One line of the notebook: the text, then the voice of the cahier on the right. */
.cahier .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--note) var(--amt);
  align-items: baseline;
  column-gap: var(--gap);
  min-height: var(--lh);
  position: relative;
}
.cahier .row .t {
  font-family: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
  margin: 0;
  padding: 0;
}
.cahier .row .t:empty::after { content: "\200b"; }

.cahier .row .note, .cahier .row .amt {
  font-family: "Fira Sans", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.cahier .row .note { color: var(--quiet); }
.cahier .row .amt { color: var(--voice); }
.cahier .row .amt.prob { border-bottom: 2px dotted var(--voice); line-height: 1.3; align-self: center; }
.cahier .row .amt.pencil { color: var(--pencil); font-style: italic; }
.cahier .row .amt.value { color: var(--quiet); }

.cahier .t .sure { text-decoration: underline solid var(--voice); text-underline-offset: 4px; }
.cahier .t .prob { text-decoration: underline dotted var(--voice); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cahier .t .doubt { text-decoration: underline wavy var(--pencil); text-underline-offset: 4px; }
.cahier .t .tag, .cahier .t .link, .cahier .t .mention { color: var(--voice); }

.cahier .row.task.done .t { color: var(--quiet); }

/* The editable trial: two exactly-stacked layers. Without JavaScript, the text shows as it is. */
.cahier .saisie {
  position: absolute;
  top: 1.3rem;
  left: var(--gutter);
  width: calc(100% - var(--gutter) - 1.3rem - var(--note) - var(--amt) - 2 * var(--gap));
  margin: 0; padding: 0; border: 0;
  background: transparent;
  color: var(--ink);
  caret-color: var(--voice);
  font-family: inherit;
  font-size: 1.05rem;
  line-height: var(--lh);
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
  resize: none;
  overflow: hidden;
}
.cahier.live .rows .t { color: transparent; }
.cahier.live .saisie { display: block; }

.cahier .pied {
  margin: 0.4rem 0 0;
  border-top: 1.5px solid var(--ink);
  padding-top: 0.4rem;
  font-family: "Fira Sans", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.cahier .pied:empty { display: none; }
.cahier .pied .row-foot { display: flex; justify-content: space-between; }
.cahier .pied .sums { color: var(--voice); font-weight: 600; }
.cahier .pied .q { color: var(--quiet); }
.cahier .remettre {
  position: absolute;
  top: 0.5rem; right: 0.6rem;
  background: transparent;
  border: 0;
  color: var(--quiet);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.2rem;
}
.cahier .remettre:hover { color: var(--voice); }
.cahier .row .amt.pencil { overflow: visible; }
.crayon {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0.3rem 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* The doubt card, a slip laid on the page. */
.fiche {
  background: var(--slip);
  box-shadow: 0 2px 10px var(--shadow);
  border-radius: 10px;
  padding: 0.5rem;
  position: absolute;
  z-index: 1;
  right: 0;
  max-width: 100%;
  margin: 0.2rem 0;
  font-family: "Fira Sans", system-ui, sans-serif;
  font-size: 0.85rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.fiche button { font: inherit; cursor: pointer; border: 1px solid var(--rule); background: var(--page); color: var(--ink); border-radius: 1rem; padding: 0.3rem 0.7rem; min-height: 2rem; }
.fiche button:hover { border-color: var(--voice); color: var(--voice); }
.plein { font-family: "Fira Sans", system-ui, sans-serif; font-size: 0.8rem; color: var(--quiet); margin-top: 0.3rem; }

/* A narrow screen: the signed amount only; the category drops. */
@media (max-width: 34rem) {
  :root { --note: 0rem; --amt: 5.2rem; --gutter: 2.2rem; }
  html { scroll-padding-top: 7rem; }
  .site-header { padding-block: 0.25rem; }
  .prose h1 + p { font-size: 1.15rem; }
  .cahier .row { grid-template-columns: minmax(0, 1fr) var(--amt); }
  .cahier .row .note { display: none; }
  .cahier .saisie { width: calc(100% - var(--gutter) - 1.3rem - var(--amt) - var(--gap)); }
}

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