/* Illustrated map and scene appearance for the B workspace.
   Link this file after workspace.css. It paints only the class hooks emitted by
   renderMapBase(..., true) and renderScene(..., {styled: true}); geometry,
   ordering, hatch, holes, ghost opacity and hit targets stay in the SVG markup.
   The declaration fallbacks are the Clean preset, so a page that has not called
   applyAppearance() still renders the legible flat drawing. */


/* Panes ------------------------------------------------------------------ */

.stage { position: relative; }
#map, #scene { position: relative; }

/* Pixel-space artwork behind the scene: independent of either SVG camera. */
.stage .paper-backdrop {
  position: absolute;
  inset: 0;
  background: var(--psfc-paper, #fffdf5);
  pointer-events: none;
}
.psfc-grain { opacity: var(--psfc-grain-amount, 0); }
#paper-map .psfc-grain { fill: url(#psfc-grain-map); }
#paper-scene .psfc-grain { fill: url(#psfc-grain-scene); }

#map .psfc-land,
#scene .psfc-land {
  fill: var(--psfc-fill-land, #edf0df);
}

#map .psfc-bma {
  fill: var(--psfc-fill-roof, #a0b3ac);
  stroke: var(--psfc-footprint-ink, #957849);
  stroke-width: calc(0.35px * var(--psfc-building-weight, 1));
}

#map .psfc-osm {
  stroke: var(--psfc-footprint-ink, #957849);
  stroke-width: calc(0.85px * var(--psfc-building-weight, 1));
}

#scene .psfc-osm {
  stroke: var(--psfc-footprint-ink, #957849);
  stroke-width: calc(1.2px * var(--psfc-building-weight, 1));
}

#map .psfc-road {
  stroke: var(--psfc-road-ink, #718c83);
  stroke-width: calc(2.4px * var(--psfc-road-weight, 1));
}

#scene .psfc-road {
  stroke: var(--psfc-road-ink, #718c83);
  stroke-width: calc(3.6px * var(--psfc-road-weight, 1));
}

#map .psfc-casing {
  stroke: var(--psfc-paper, #fffdf5);
  stroke-width: calc(1.38px * var(--psfc-road-weight, 1));
}

#scene .psfc-casing {
  stroke: var(--psfc-paper, #fffdf5);
  stroke-width: calc(2.2px * var(--psfc-road-weight, 1));
}

#scene .psfc-face-bma {
  stroke: var(--psfc-dark-face, #596f6a);
  stroke-width: calc(0.65px * var(--psfc-building-weight, 1));
}

#scene .psfc-face-bma.psfc-roof {
  fill: var(--psfc-fill-roof, #a0b3ac);
}

#scene .psfc-face-bma.psfc-side {
  fill: var(--psfc-fill-side, #788e88);
}

#scene .psfc-face-bma.psfc-side-dark {
  fill: var(--psfc-fill-side-dark, #788e88);
}

/* Shared dry ink. The overlay repeats a contextual line exactly; the pattern
   only adds translucent ink inside that stroke, so the base ink stays crisp. */
.psfc-texture {
  pointer-events: none;
  opacity: var(--psfc-ink-opacity, 0);
}

#map[data-illustration='illustrated'] .psfc-ink-road {
  stroke: url(#psfc-ink-road-map);
  stroke-width: calc(2.4px * var(--psfc-road-weight, 1));
}

#scene[data-illustration='illustrated'] .psfc-ink-road {
  stroke: url(#psfc-ink-road-scene);
  stroke-width: calc(3.6px * var(--psfc-road-weight, 1));
}

#map[data-illustration='illustrated'] .psfc-ink-foot {
  stroke: url(#psfc-ink-foot-map);
  stroke-width: calc(.85px * var(--psfc-building-weight, 1));
}

#scene[data-illustration='illustrated'] .psfc-ink-foot {
  stroke: url(#psfc-ink-foot-scene);
  stroke-width: calc(1.2px * var(--psfc-building-weight, 1));
}

/* Seeded defs ------------------------------------------------------------ */

.psfc-swatch-land {
  fill: var(--psfc-fill-land, #edf0df);
}

.psfc-swatch-roof {
  fill: var(--psfc-fill-roof, #a0b3ac);
}

.psfc-wash {
  pointer-events: none;
  opacity: calc(var(--psfc-wash-strength, 0) * 0.6);
}

.psfc-blot {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: calc(var(--psfc-ink-opacity, 0) * 0.45);
}

.psfc-blot-road {
  stroke: var(--psfc-road-ink, #718c83);
}

.psfc-blot-foot {
  stroke: var(--psfc-footprint-ink, #957849);
}

.psfc-blot-land {
  stroke: var(--psfc-land-ink, #a8b4ad);
  opacity: calc(var(--psfc-ink-opacity, 0) * 0.55);
}

.psfc-stroke-blot { opacity: .8; }
.psfc-stroke-blot.psfc-blot-road { stroke: color-mix(in srgb, var(--psfc-road-ink) 42%, #132720); }
.psfc-stroke-blot.psfc-blot-foot { stroke: color-mix(in srgb, var(--psfc-footprint-ink) 42%, #382622); }

.psfc-grain-dot {
  fill: var(--psfc-grain-ink, #7c6347);
}

/* Clean bypasses effects, not geometry. The flat colours above remain. */
:root:not([data-illustration='illustrated'], [data-illustration='desert']) svg.paper-backdrop,
:root:not([data-illustration='illustrated'], [data-illustration='desert']) .psfc-grain,
:root:not([data-illustration='illustrated'], [data-illustration='desert']) .psfc-texture,
:root:not([data-illustration='illustrated'], [data-illustration='desert']) .psfc-wash {
  display: none;
}

/* Illustrated: pattern fills stay inside each contextual feature. */
:root:is([data-illustration='illustrated'], [data-illustration='desert']) #map[data-illustration='illustrated'] .psfc-land {
  fill: url(#psfc-land-map);
  fill-opacity: .86;
}

:root:is([data-illustration='illustrated'], [data-illustration='desert']) #scene[data-illustration='illustrated'] .psfc-land {
  fill: url(#psfc-land-scene);
  fill-opacity: .86;
}

:root:is([data-illustration='illustrated'], [data-illustration='desert']) #map[data-illustration='illustrated'] .psfc-bma {
  fill: url(#psfc-bma-map);
}

:root[data-illustration='desert'] :is(#map, #scene) .psfc-casing {
  stroke: color-mix(in srgb, var(--psfc-accent) 65%, var(--psfc-paper));
}
