/* The maps of the periods (public/carte.js), in a drawer of the readings' pages built as the timeline's (frise.css: its
   frame, head, chips, round buttons and detail): its own colours over the site's tokens, light and dark. */

.carte-drawer,
.carte-page {
  --carte-marked: #bc9e76;
  --carte-land: #efe6d2;
  --carte-sea: #c3dbe9;
  /* Beyond the frame of the maps: no land, no sea, what no map draws. */
  --carte-beyond: #dcd6cb;
  --carte-coast: #7d9cb0;
  --carte-river: #6b9cc0;
  --carte-water-ink: #3f6f93;
  --carte-desert-ink: #8a6a3a;
  --carte-region-ink: #5a4636;
  --carte-halo: #f6f0e3;
  --carte-border: #5b4a3d;
  --carte-red: #c8553d;
  --carte-gold: #d1a21c;
  --carte-green: #6f8f3c;
  --carte-blue: #5b6fa8;
  --carte-purple: #8a5a9e;
  --carte-teal: #2f8f86;
  --carte-brown: #8a6440;
  --carte-rose: #b8527d;
  --carte-fill: 1;
  /* The size of the names: larger on the children's maps (carte-enfants.css), which public/carte.js reads to place them. */
  --carte-scale: 1;
}

:root[data-theme='dark'] :is(.carte-drawer, .carte-page) {
  --carte-land: #2c2822;
  --carte-sea: #1d3140;
  --carte-beyond: #171512;
  --carte-coast: #4d6d84;
  --carte-river: #4f7fa6;
  --carte-water-ink: #8db8d8;
  --carte-desert-ink: #c9a46c;
  --carte-region-ink: #d8c8b4;
  --carte-halo: #23201c;
  --carte-border: #b8a690;
  --carte-red: #d9775f;
  --carte-gold: #d9b13c;
  --carte-green: #8aac55;
  --carte-blue: #7d90cc;
  --carte-purple: #b088c4;
  --carte-teal: #5cbfb4;
  --carte-brown: #b68d63;
  --carte-rose: #d886a8;
  --carte-fill: 0.55;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) :is(.carte-drawer, .carte-page) {
    --carte-land: #2c2822;
    --carte-sea: #1d3140;
    --carte-beyond: #171512;
    --carte-coast: #4d6d84;
    --carte-river: #4f7fa6;
    --carte-water-ink: #8db8d8;
    --carte-desert-ink: #c9a46c;
    --carte-region-ink: #d8c8b4;
    --carte-halo: #23201c;
    --carte-border: #b8a690;
    --carte-red: #d9775f;
    --carte-gold: #d9b13c;
    --carte-green: #8aac55;
    --carte-blue: #7d90cc;
    --carte-purple: #b088c4;
    --carte-teal: #5cbfb4;
    --carte-brown: #b68d63;
    --carte-rose: #d886a8;
    --carte-fill: 0.55;
  }
}

/* A map has no height of its own: the drawer takes 70 % of the screen, the map what its head and detail leave. */
.carte-drawer[open] {
  height: 70vh;
  height: 70dvh;
}

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

.carte-drawer .frise-mark {
  --carte-mark-outline: var(--carte-marked);
  border-color: var(--carte-mark-outline);
}

.carte-drawer .frise-mark[aria-pressed='true'] {
  --carte-mark-outline: var(--frise-scene);
}

.carte-drawer .frise-mark:hover {
  border-color: var(--carte-mark-outline);
  box-shadow: inset 0 0 0 1px var(--carte-mark-outline);
}

.carte-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 8rem;
}

/* In the administration's preview, the map takes 70 % of the screen. */
.carte-page .carte-frame {
  height: 70vh;
  height: 70dvh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Dragged and pinched like any map: the browser leaves the gestures to it. */
.carte-box {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--carte-beyond);
  touch-action: none;
  cursor: grab;
  user-select: none;
}

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

.carte-box:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.carte-svg {
  display: block;
}

.carte-land {
  fill: var(--carte-land);
}

/* Who rules: tints over the land, lighter in the dark, where they would weigh. */
.carte-regions {
  opacity: var(--carte-fill);
}

.carte-sea {
  fill: var(--carte-sea);
  stroke: var(--carte-coast);
  stroke-width: 0.8px;
}

.carte-lakes {
  fill: var(--carte-sea);
  stroke: var(--carte-coast);
  stroke-width: 0.6px;
}

.carte-rivers {
  fill: none;
  stroke: var(--carte-river);
  stroke-width: 1.1px;
  stroke-linejoin: round;
}

.carte-outer {
  fill: none;
  stroke: var(--carte-border);
  stroke-width: 1.2px;
  stroke-linejoin: round;
  stroke-opacity: 0.75;
}

.carte-inner {
  fill: none;
  stroke: var(--carte-border);
  stroke-width: 0.9px;
  stroke-dasharray: 3 3;
  stroke-opacity: 0.6;
}

/* The shapes of the note's places, and the one chosen: their borders on land (the sea covers the rest), the colour of
   who rules left as it is. */
.carte-outlines path {
  fill: none;
  stroke-width: 2.5px;
  stroke-linejoin: round;
}

.carte-outlines .is-marked {
  stroke: var(--carte-marked);
}

.carte-outlines .is-chosen {
  stroke: var(--frise-scene);
  stroke-width: 3px;
}

/* Where a scene on the way may have taken place: a light disc, its edge dashed, under the way and the names. */
.carte-zone {
  fill: var(--frise-scene);
  fill-opacity: 0.18;
  stroke: var(--frise-scene);
  stroke-width: 1.5px;
  stroke-dasharray: 5 4;
}

/* The journey of a scene on the way: a dashed curve between its two stages, on a halo that keeps it readable. */
.carte-route,
.carte-route-halo {
  fill: none;
  stroke-linecap: round;
}

.carte-route-halo {
  stroke: var(--carte-halo);
  stroke-width: 7px;
  stroke-opacity: 0.85;
}

.carte-route {
  stroke: var(--frise-scene);
  stroke-width: 3.5px;
  stroke-dasharray: 9 6;
}

.carte-overview-arrow {
  fill: var(--frise-scene);
  fill: color-mix(in srgb, var(--frise-scene) 58%, #42ffaa);
  fill-opacity: 0.62;
  stroke: var(--carte-halo);
  stroke-opacity: 0.35;
  stroke-width: 2px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.carte-destination-arrow {
  fill: none;
  stroke: var(--frise-scene);
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.carte-route-chevron {
  fill: var(--frise-scene);
  stroke: var(--carte-halo);
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
  pointer-events: none;
}

/* The names: a halo of the land around them, so that they read over lines and colours. */
.carte-labels text {
  font-family: var(--sans);
  font-size: calc(11px * var(--carte-scale));
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--carte-halo);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.carte-labels .l-region {
  font-size: calc(11px * var(--carte-scale));
  font-weight: 650;
  letter-spacing: 1.4px;
  text-anchor: middle;
  fill: var(--carte-region-ink);
}

.carte-labels .l-sub {
  font-size: calc(10px * var(--carte-scale));
  font-style: italic;
  text-anchor: middle;
  fill: var(--carte-region-ink);
}

.carte-labels .l-district {
  font-size: calc(10.5px * var(--carte-scale));
  font-style: italic;
  letter-spacing: 1px;
  text-anchor: middle;
  fill: var(--carte-region-ink);
}

.carte-labels :is(.l-eau, .l-fleuve) {
  font-style: italic;
  text-anchor: middle;
  fill: var(--carte-water-ink);
  stroke: var(--carte-sea);
}

.carte-labels .l-eau {
  font-size: calc(10.5px * var(--carte-scale));
  letter-spacing: 1px;
}

.carte-labels .l-fleuve {
  font-size: calc(10.5px * var(--carte-scale));
  stroke: var(--carte-halo);
}

.carte-labels .l-desert {
  font-size: calc(10.5px * var(--carte-scale));
  font-style: italic;
  letter-spacing: 1px;
  text-anchor: middle;
  fill: var(--carte-desert-ink);
}

.carte-labels .l-ile {
  font-size: calc(10.5px * var(--carte-scale));
  font-style: italic;
  text-anchor: middle;
}

.carte-labels .l-city1 {
  font-size: calc(12px * var(--carte-scale));
  font-weight: 650;
}

.carte-labels text:is(.is-marked, .is-chosen) {
  font-weight: 700;
}

.carte-labels text.is-marked {
  fill: var(--ink);
}

.carte-labels text.is-chosen {
  fill: var(--frise-scene);
}

.carte-dot,
.carte-peak {
  fill: var(--ink);
  stroke: var(--carte-halo);
  stroke-width: 1px;
}

.carte-peak {
  fill: var(--carte-desert-ink);
}

:is(.carte-dot, .carte-peak).is-marked {
  fill: var(--carte-marked);
}

:is(.carte-dot, .carte-peak).is-chosen {
  fill: var(--frise-scene);
}

.carte-ring {
  fill: none;
  stroke: var(--carte-marked);
  stroke-width: 2px;
}

.carte-ring.is-chosen {
  stroke: var(--frise-scene);
  stroke-width: 2.5px;
}

.carte-scene-ring {
  fill: none;
  stroke: var(--frise-scene);
  stroke-width: 3px;
  pointer-events: none;
}

/* What a finger or a pointer takes: more than the dot. */
.carte-hit {
  fill: transparent;
  stroke: none;
}

/* Over the map: the period and its arrows at the top left, the legend at the bottom left, the source at the bottom
   right. Out of the way of the gestures, but for their buttons. */
/* The background of what stands over the map: plain, so that the tab of the details hides the edge it hangs from. */
.carte-frame {
  --carte-chrome: var(--paper);
}

.carte-period,
.carte-legend,
.carte-credit {
  position: absolute;
  z-index: 1;
  margin: 0;
  background: var(--carte-chrome);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
}

.carte-period {
  border-radius: 1rem;
  top: 0.4rem;
  left: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  max-width: calc(100% - 0.8rem);
  padding: 0.1rem;
}

/* The name of the period, and its dates always under it, the lines close, so that the bar stays as low as its arrows.
   Every period's name in one cell, the current one shown: the bar as wide as the longest, the arrows still from one
   map to the next. */
.carte-period-name {
  display: grid;
  min-width: 0;
  padding: 0 0.35rem;
  font-weight: 650;
  line-height: 1.1;
  text-align: center;
}

.carte-period-option {
  grid-area: 1 / 1;
  display: grid;
  align-content: center;
  visibility: hidden;
}

.carte-period-option.is-current {
  visibility: visible;
}

.carte-period-date {
  color: var(--muted);
  font-size: 0.92em;
  font-weight: 400;
  white-space: nowrap;
}

.carte-step {
  position: relative;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

/* A chevron drawn with borders, which forced colours keep. */
.carte-step::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(-30%, -50%) rotate(45deg);
}

.carte-step[data-carte-step='1']::before {
  transform: translate(-70%, -50%) rotate(-135deg);
}

.carte-step:hover:not(:disabled) {
  background: var(--bg);
}

.carte-step:disabled {
  color: var(--line);
  cursor: default;
}

/* Under the period's name, the details, folded (public/carte.js): open, they slide down below it, attached to it and as
   wide as the name (its arrows outside), over the map, and the tab follows under them. The tab hangs from the edge above it as a drop, its arrow down, up once
   they are open; the bar, the details and the tab have one background, and no shadow (it would fall on the bar). */
.carte-info-wrap {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  /* A layer of their own, their layout apart: the map, drawn again at each frame while it moves, does not draw the open
     details again with it (on phones, the map lagged under them). */
  will-change: transform;
  contain: layout style;
}

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

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

.carte-info-clip {
  min-height: 0;
  overflow: hidden;
}

/* Hung from the bar, over its lower edge: no edge at its top, the bar and the details are one. */
.carte-info {
  max-height: min(14rem, 40vh);
  overflow-y: auto;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 0.6rem 0.6rem;
  background: var(--carte-chrome);
  font-size: 0.85rem;
}

/* The tab, its top on the edge above it (the bar's, or the details'), which it carries on, and nothing above: its
   drawing at the very top of the button (a button centres what it holds); the rest of the button, under it, only makes
   it easier to tap. Its outline starts in the middle of that edge (a pixel thick), which it carries on: half a pixel
   under the edge's top, the bar's or the details' (their last pixel). */
.carte-more {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 24px;
  height: 18px;
  margin: 0.5px auto 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  pointer-events: auto;
  cursor: pointer;
}

.carte-info-wrap.is-open > .carte-more {
  margin-top: -0.5px;
}

.carte-more svg {
  display: block;
  overflow: visible;
}

.carte-more-fill {
  fill: var(--carte-chrome);
}

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

.carte-more-chevron {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.25s ease;
}

.carte-more[aria-expanded='true'] .carte-more-chevron {
  transform: rotate(180deg);
}

.carte-more:focus-visible {
  outline: none;
}

.carte-more:focus-visible .carte-more-line {
  stroke: var(--notes-accent);
  stroke-width: 2.5;
}

@media (prefers-reduced-motion: reduce) {
  .carte-info-wrap,
  .carte-info-slide,
  .carte-more-chevron {
    transition: none;
  }
}

/* For the map, its text alone: its name and its dates are those of the bar above. */
.carte-info[data-kind='map'] :is(.track, h3, .when) {
  display: none;
}

.carte-info .track {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.carte-info h3 {
  margin: 0.1rem 0 0;
  font-size: 0.95rem;
}

.carte-info .when {
  color: var(--muted);
}

.carte-info .remark {
  margin: 0.2rem 0 0;
}

.carte-info[data-kind='map'] .remark {
  margin: 0;
}

/* The legend folds into its title: open on wide screens, closed on phones, where it would hide the map. Its powers one
   under the other. */
.carte-legend {
  bottom: 0.4rem;
  left: 0.4rem;
  max-width: calc(100% - 7rem);
  padding: 0.1rem 0.55rem;
  border-radius: 0.6rem;
}

.carte-legend[hidden] {
  display: none;
}

.carte-legend summary {
  color: var(--muted);
  cursor: pointer;
}

.carte-legend ul {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.1rem 0 0.15rem;
  padding: 0;
  list-style: none;
}

.carte-legend li {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.carte-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--carte-border);
  border-radius: 2px;
}

/* The colour of a power in the legend: its hue (src/carte/cartes.ts), as light as the land shows it. */
.carte-swatch {
  background: color-mix(in srgb, var(--carte-swatch) 45%, var(--carte-land));
}

.carte-swatch-red {
  --carte-swatch: var(--carte-red);
}

.carte-swatch-gold {
  --carte-swatch: var(--carte-gold);
}

.carte-swatch-green {
  --carte-swatch: var(--carte-green);
}

.carte-swatch-blue {
  --carte-swatch: var(--carte-blue);
}

.carte-swatch-purple {
  --carte-swatch: var(--carte-purple);
}

.carte-swatch-teal {
  --carte-swatch: var(--carte-teal);
}

.carte-swatch-brown {
  --carte-swatch: var(--carte-brown);
}
.carte-swatch-rose {
  --carte-swatch: var(--carte-rose);
}

.carte-credit {
  right: 0.4rem;
  bottom: 0.4rem;
  padding: 0 0.45rem;
  color: var(--muted);
  font-size: 0.65rem;
  pointer-events: none;
}

/* On phones the legend takes less room. */
@media (max-width: 40rem) {
  .carte-legend {
    font-size: 0.68rem;
  }
}
