/* The biblical timeline (public/frise.js), in the administration's preview (/admin/preview) and in the drawer of the
   readings' pages: its own colours over the site's tokens (paper, ink, lines), light and dark like the rest of the site. */

.frise-page,
.frise-drawer {
  --frise-scene: #1d9e75;
  --frise-event: #5f5e5a;
  /* The names of the scenes: barely greyer than the ink of the events’. */
  --frise-scene-ink: #463d37;
  --frise-hatch: rgb(0 0 0 / 0.18);
  --frise-power: #c9b8a2;
  --frise-people: #b9cfe4;
  --frise-book: #cfc8f1;
  --frise-told: #efdcae;
  --frise-other: #dcd6cc;
  --frise-era-1: #efe6d6;
  --frise-era-2: #f6dfd2;
  --frise-era-3: #f8e7c4;
  --frise-era-4: #f3d6dc;
  --frise-era-5: #f0d0cc;
  --frise-era-6: #d7e5f5;
  --frise-era-7: #dceccd;
  --frise-era-8: #ecdcef;
  --frise-era-9: #e2e0d8;
  --frise-era-10: #f7d4c0;
  --frise-era-11: #e3e9cf;
  /* The letter of the timeline: the site's; the children's their own (frise-enfants.css). */
  --frise-font: var(--sans);
  /* The points of the scenes under the line of the story: hollow, in the grey of the events. */
  --frise-scene-mark: var(--frise-event);
  --frise-scene-fill: var(--paper);
}

:root[data-theme='dark'] :is(.frise-page, .frise-drawer) {
  --frise-scene: #3fc195;
  --frise-event: #b4b2a9;
  --frise-scene-ink: #d6ccbf;
  --frise-hatch: rgb(255 255 255 / 0.18);
  --frise-power: #5a4c3c;
  --frise-people: #34495e;
  --frise-book: #3f3a66;
  --frise-told: #4d4126;
  --frise-other: #3d3a35;
  --frise-era-1: #3a332a;
  --frise-era-2: #43302a;
  --frise-era-3: #463b24;
  --frise-era-4: #452c33;
  --frise-era-5: #4a2b28;
  --frise-era-6: #263547;
  --frise-era-7: #2c3d24;
  --frise-era-8: #3b2c40;
  --frise-era-9: #34322d;
  --frise-era-10: #4a3426;
  --frise-era-11: #33392a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) :is(.frise-page, .frise-drawer) {
    --frise-scene: #3fc195;
    --frise-event: #b4b2a9;
    --frise-scene-ink: #d6ccbf;
    --frise-hatch: rgb(255 255 255 / 0.18);
    --frise-power: #5a4c3c;
    --frise-people: #34495e;
    --frise-book: #3f3a66;
    --frise-told: #4d4126;
    --frise-other: #3d3a35;
    --frise-era-1: #3a332a;
    --frise-era-2: #43302a;
    --frise-era-3: #463b24;
    --frise-era-4: #452c33;
    --frise-era-5: #4a2b28;
    --frise-era-6: #263547;
    --frise-era-7: #2c3d24;
    --frise-era-8: #3b2c40;
    --frise-era-9: #34322d;
    --frise-era-10: #4a3426;
    --frise-era-11: #33392a;
  }
}

/* The page as wide as the screen allows: the timeline needs the room. */
main:has(.frise-page) {
  max-width: 90rem;
}

.frise-lede {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.frise-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* The zoom: a magnifying glass (src/views/icons.ts), in the middle of its button. */
.frise-zoom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
}

.frise-zoom .icon {
  display: block;
  flex: none;
}

.frise-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: center;
  margin: 0.6rem 0 0;
}

.frise-search label {
  font-weight: 600;
}

/* The suggestions open under the field, over the timeline. */
.frise-combo {
  position: relative;
  flex: 1 1 18rem;
  max-width: 34rem;
}

.frise-combo input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}

.frise-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 22rem;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  overflow-y: auto;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
}

.frise-results li {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.frise-results li[role='option']:hover,
.frise-results li[aria-selected='true'] {
  background: var(--bg);
}

/* The name of a line of the timeline, over its items, in the full list. */
.frise-results li.group {
  padding-top: 0.6rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: default;
}

.frise-results li[aria-selected='true'] {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.frise-results .name {
  font-weight: 600;
}

.frise-results .meta {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.frise-status {
  min-height: 1.3em;
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Dragged and pinched like a map: the browser leaves the gestures to the timeline. */
.frise-box {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  touch-action: none;
  cursor: grab;
  user-select: none;
}

/* In the preview, as in the drawer, the tracks scroll in a box of their own, which keeps its height: what is under the
   eyes stays there while rows come and go around it (public/frise.js). Its scrollbar keeps its room, so that its width
   does not change with it. */
.frise-page .frise-box {
  height: 70vh;
  height: 70dvh;
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.frise-box.dragging {
  cursor: grabbing;
}

.frise-box svg {
  display: block;
  width: 100%;
}

.frise-box text {
  font-family: var(--frise-font);
}

/* The line of the story, between the events over it and the scenes under it. */
.frise-line {
  stroke: var(--line);
  stroke-width: 1.5px;
}

/* The colours of the eras behind the story. */
.frise-era-bg {
  fill-opacity: 0.55;
}

/* Labels stay readable over lines and hatching: a halo of the colour under them (its stroke attribute). */
.frise-halo {
  paint-order: stroke;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.frise-detail {
  min-height: 4rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.frise-detail h2 {
  margin: 0 0 0.15rem;
  font-size: 1rem;
}

.frise-detail .when,
.frise-hint {
  color: var(--muted);
}

.frise-detail .track {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.frise-detail .remark {
  margin: 0.3rem 0 0;
}

/* What a note's chronology names this item by (its JSON, in the correction of a note). */
.frise-detail .id {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.frise-hint {
  margin: 0;
  font-size: 0.85rem;
}

/* The axis in an SVG of its own: it stays at the top while the tracks scroll under it (the drawer). */
.frise-axis {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
}

/* ---- The drawer of the readings' pages: from the bottom, as wide as the screen, as high as the timeline and 70 % of
   the screen at most (its tracks scroll beyond). A
   non-modal dialog: the page stays usable around it (it keeps room under its content for it, styles.css). */
.frise-drawer {
  display: none;
  flex-direction: column;
  position: fixed;
  /* Above the line of the switches (styles.css). */
  inset: auto 0 var(--switches-bar, 0px);
  z-index: 60;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  max-height: 70vh;
  max-height: 70dvh;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgb(0 0 0 / 0.18);
  font-family: var(--sans);
}

.frise-drawer[open] {
  display: flex;
  animation: frise-up 0.25s ease;
}

.frise-drawer.is-sliding-out:not([open]) {
  display: flex;
  pointer-events: none;
  z-index: 59;
}

@keyframes frise-up {
  from {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .frise-drawer[open] {
    animation: none;
  }
}

/* Its title, the buttons of the note's items, the zoom and the cross on one line; on phones the items below. */
.frise-drawer-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.25rem 0.5rem;
  padding: 0.25rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 40rem) {
  .frise-drawer-head {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .frise-marks {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

.frise-drawer-title {
  margin: 0;
  overflow: hidden;
  font-size: 0.9rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.frise-drawer-ref {
  color: var(--muted);
  font-weight: 400;
}

/* The icon of the drawer beside its name, as on the buttons that open it. */
.frise-drawer-title .icon {
  width: 0.95rem;
  height: 0.95rem;
  margin-right: 0.15rem;
  vertical-align: -0.15em;
  color: var(--accent);
}

.frise-marks {
  display: flex;
  gap: 0.25rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.frise-mark {
  flex: none;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--frise-scene);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
}

.frise-mark-role {
  color: var(--muted);
}

/* The pin of a chip of the timeline: the instant it goes to. */
.frise-mark-pin {
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.25em;
  vertical-align: -0.1em;
}

.frise-mark-pin path {
  fill: var(--accent);
}

.frise-mark-pin circle {
  fill: var(--bg);
}

.frise-zooms {
  display: flex;
  gap: 0.2rem;
}

/* Left of the zoom, the other drawer: the maps from the timeline, the timeline from the maps (public/frise.js, carte.js).
   Hidden until the note has something to open there. */
.frise-switch {
  margin-right: 0.3rem;
}

.frise-switch[hidden] {
  display: none;
}

/* Small round buttons, still over the 24px minimum of WCAG 2.5.8. Two bars draw the cross, in the middle whatever the
   font; borders, which forced colours keep. */
.frise-drawer .frise-zoom,
.frise-close {
  position: relative;
  width: 1.6rem;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

:is(.frise-mark, .frise-drawer .frise-zoom, .frise-close):hover {
  border-color: var(--accent);
}

.frise-close::before,
.frise-close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.7rem;
  height: 0;
  border-top: 2px solid currentColor;
  border-radius: 1px;
  transform: translate(-50%, -50%);
}

.frise-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.frise-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* The tracks scroll up and down in what is left; the detail of the chosen item stays under them, short. */
.frise-drawer .frise-box {
  flex: 1 1 auto;
  min-height: 5rem;
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 0;
  border-radius: 0;
}

/* While the data of the timeline still load (a click before they are there, public/frise.js): about the height the
   tracks take once drawn (about 280 to 520 px), not the least one. */
.frise-drawer.frise-loading .frise-box {
  min-height: min(30rem, 50vh);
  min-height: min(30rem, 50dvh);
}

/* On phones, the tracks get most of the little height there is. */
@media (max-width: 40rem) {
  .frise-drawer .frise-detail {
    max-height: 3.9rem;
  }
}

/* The button of a track of context in the drawer (public/frise.js), where its row is: its name, how many items it has
   in the view while folded, and a chevron that turns as it opens. Under the axis, which stays over it. */
/* The item chosen, in the drawer (public/frise.js): a bar with its name, stuck to the bottom right of the drawer, on
   the line of the switches, as wide as the name and a third of the drawer at most (the whole width on phones); on its
   top edge, a tab with an arrow, as the maps' under the period's name but rising from the bottom: it opens the details
   (the dating, the sentence, the remark), which slide up above the bar, over the timeline, which keeps its height (its
   scroll gets the room of the bar under its last row). The bar, the details and the tab have one background. */
.frise-chosen {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  width: max-content;
  max-width: max(33.333%, 14rem);
  pointer-events: none;
  color: var(--ink);
  font: 0.85rem/1.4 var(--frise-font, var(--sans));
}

@media (max-width: 40rem) {
  .frise-chosen {
    left: 0;
    width: auto;
    max-width: none;
  }
}

/* The slide of the details: a grid row from 0fr to 1fr (an auto height does not transition, a grid row does), the
   details cut to the row; folded, hidden once the slide is over, out of the keyboard and the screen readers. */
.frise-chosen-slide {
  display: grid;
  grid-template-rows: 0fr;
  width: 100%;
  visibility: hidden;
  pointer-events: auto;
  transition:
    grid-template-rows 0.25s ease,
    visibility 0s linear 0.25s;
}

.frise-chosen.is-open > .frise-chosen-slide {
  grid-template-rows: 1fr;
  visibility: visible;
  transition:
    grid-template-rows 0.25s ease,
    visibility 0s linear 0s;
}

.frise-chosen-clip {
  min-height: 0;
  overflow: hidden;
}

/* Over the bar, joined to it: no edge between them. */
.frise-chosen-info {
  box-sizing: border-box;
  max-height: min(16rem, 50vh);
  padding: 0.4rem 0.6rem 0.3rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0.6rem 0.6rem 0 0;
  background: var(--paper);
  text-align: left;
}

/* The bar: the name of the item, on the line of the switches, no edge below. */
.frise-chosen-bar {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0.3rem 0.6rem 0.35rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0.6rem 0.6rem 0 0;
  background: var(--paper);
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  pointer-events: auto;
  cursor: pointer;
}

.frise-chosen.is-open > .frise-chosen-bar {
  border-top: 0;
  border-radius: 0;
}

/* The tab, as the maps' (carte.css) turned upside down: its drawing at the very bottom of the button, on the edge of
   the bar or of the open details, which it carries on; the rest of the button, above it, only makes it easier to tap. */
.frise-more {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 24px;
  height: 18px;
  margin: 0 auto -0.5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  pointer-events: auto;
  cursor: pointer;
}

.frise-more svg {
  display: block;
  overflow: visible;
  transform: scaleY(-1);
}

.frise-more-fill {
  fill: var(--paper);
}

.frise-more-line {
  fill: none;
  stroke: var(--line);
}

.frise-more-chevron {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: 12px 7px;
  transition: transform 0.25s ease;
}

.frise-chosen.is-open .frise-more-chevron {
  transform: rotate(180deg);
}

.frise-chosen .track {
  margin-right: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.frise-chosen .when {
  color: var(--muted);
}

.frise-chosen .about {
  margin: 0.25rem 0 0.1rem;
}

.frise-chosen .remark {
  margin: 0.15rem 0 0.1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.frise-track {
  position: absolute;
  left: 4px;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 20px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  color: var(--muted);
  font: 700 11px/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.frise-track::after {
  content: '';
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.frise-track[aria-expanded='true']::after {
  transform: translateY(-0.12em) rotate(45deg);
}

.frise-track:hover {
  color: var(--ink);
}

.frise-track:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
