/* H27-38: physical materials, lit from the upper left. Scoped to the map. */
.map-page #mapa {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  padding: 10px;
  background: linear-gradient(135deg, #30312d, #11120f 34%, #080907 74%, #292b25);
  box-shadow: inset 0 1px 1px #65665b, inset 0 -1px 2px #000, 0 5px 18px #0008;
}
.map-page #mapa .map-viewport { height: 100%; min-height: 0; border: 1px solid #1a130c; border-radius: 2px; overscroll-behavior: contain; }
.map-page #mapa .map-stage { min-width: 1120px; min-height: 620px; height: 100%; }
.map-page #mapa[data-board-theme="cork"] .map-stage {
  background: linear-gradient(120deg, #ffe5b228, transparent 46%, #43251126), url('assets/cork.png') center / cover no-repeat, #ae8053;
  box-shadow: inset 2px 3px 6px #321b13a6, inset -1px -1px 3px #f4d7a860;
}
.map-page #mapa .map-stage::after {
  z-index: 0;
  background: linear-gradient(145deg, #fff2cd0c, transparent 48%, #26180d16);
  box-shadow: inset 0 0 28px #17130b35;
}
.map-page .board-label {
  top: 32px; left: 38px; color: #302318; font-size: 10px; letter-spacing: .2em;
  padding-bottom: 9px; border-bottom: 1px solid #49362165; text-shadow: 0 1px #f5dab845;
}
.map-page #mapa:not([data-board-theme="cork"]) .board-label { color: #d2d4c6; border-color: #d2d4c655; text-shadow: none; }
.map-page #mapa .map-status { top: 22px; right: 24px; font-size: 10px; background: #171b16ed; opacity: 1; font-weight: 500; }
.map-page #mapa .board-plaque { bottom: 74px; right: 27px; background: #171914; font-size: 8px; color: #bdbdaf; }

/* The tool shelf participates in layout. It can never cover the board. */
.map-page #mapa .board-toolbar {
  position: relative; inset: auto; display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 24px; min-height: 60px; padding: 8px 10px 0;
  border: 0; border-radius: 0; background: transparent; backdrop-filter: none;
}
.map-page #mapa .board-toolbar .map-controls {
  grid-column: auto; display: flex; flex-wrap: nowrap; gap: 4px; min-width: 0;
  overflow-x: auto; scrollbar-width: thin; padding: 3px 2px;
}
.map-page #mapa .board-toolbar .filter,
.map-page #mapa .board-toolbar .theme-option,
.map-page #mapa .project-trigger {
  min-height: 36px; padding: 8px 11px; font-size: 10px;
  font-weight: 600; letter-spacing: .01em; text-transform: none;
}
.map-page #mapa .board-toolbar .filter { border-color: transparent; }
.map-page #mapa .board-toolbar .filter.is-active { background: #eee9da; color: #1d2118; }
.map-page #mapa .board-toolbar .theme-switcher { gap: 3px; flex-wrap: nowrap; }
.map-page #mapa .board-toolbar .theme-switcher > span { font-size: 9px; margin-right: 7px; color: #aaa99f; }
.map-page #mapa .project-trigger { border-radius: 4px; min-width: 126px; }
.map-page #mapa .chat-teaser { right: 26px; bottom: 32px; width: 220px; padding: 10px 12px; box-shadow: 2px 4px 6px #291d1440; }
.map-page #mapa .chat-teaser em { font-size: 9px; color: #b5b5a8; }
.map-page #mapa .chat-teaser small { font-size: 8px; }
.map-page #mapa .chat-teaser strong { font-size: 11px; }
.map-page #mapa .chat-dot { width: 32px; height: 32px; }
.map-navigation { display: none; }

/* The button's center is exactly the insertion point, independent of label width. */
.map-page #mapa .pins { pointer-events: none; }
.map-page #mapa .pin {
  display: block; width: 44px; height: 44px; min-height: 44px; max-width: none;
  padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none;
  transform: translate(-50%, -50%); filter: none; pointer-events: auto;
  transition: opacity 180ms ease;
}
.map-page #mapa .pin::after { display: none; }
.map-page #mapa .pin-point {
  position: absolute; left: 19px; top: 20px; width: 6px; height: 4px;
  border-radius: 50%; background: #302116;
  box-shadow: 0 1px 1px #e7bb7d, 1px 2px 3px #27180bb3, 6px 8px 7px 2px #25180b50;
}
.map-page #mapa .pin-shaft {
  position: absolute; z-index: 1; left: 20px; top: 8px; width: 4px; height: 15px;
  transform: rotate(-24deg); transform-origin: 50% 100%; border-radius: 1px 1px 2px 2px;
  background: linear-gradient(90deg, #4d4c42, #faf4df 36%, #b8b9b0 58%, #4a4943 85%);
  box-shadow: 3px 4px 3px #2e1e164d;
}
.map-page #mapa .pin-head {
  position: absolute; z-index: 2; left: 4px; top: -2px;
  width: 27px; height: 23px; border: 0; border-radius: 48% !important;
  background:
    radial-gradient(ellipse at 29% 23%, #ffffedbf 0, #ffffed50 12%, transparent 30%),
    radial-gradient(ellipse at 40% 32%, var(--pin-color) 24%, color-mix(in srgb, var(--pin-color) 78%, #20140e) 65%, color-mix(in srgb, var(--pin-color) 38%, #1c100b) 100%);
  box-shadow: inset 0 1px 1px #ffffeac9, inset 1px 0 1px #fff5da73, inset -2px -3px 2px #24140c6b, 1px 2px 0 color-mix(in srgb, var(--pin-color) 42%, #1e120c), 4px 8px 5px #2d1c125e;
  animation: none; transition: filter 160ms ease;
}
.map-page #mapa .pin-label {
  position: absolute; left: 39px; top: 10px;
  display: flex; align-items: center; gap: 6px; width: max-content; max-width: 178px;
  padding: 5px 8px 6px; color: #292b24;
  background: linear-gradient(170deg, #f6f0df, #e8dfc9);
  border: 1px solid #fff5dfb3; border-bottom-color: #b7a688;
  border-radius: 1px 2px 2px 1px; box-shadow: 1px 2px 2px #3927184d, 3px 5px 7px #39271826;
  font-size: 11px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2;
  transform: rotate(var(--label-angle)); transform-origin: 0 50%;
}
.map-page #mapa .pin-label > span { display: flex; flex: 0 0 auto; color: #5d5f51; }
.map-page #mapa .pin-label .pin-icon { width: 13px; height: 13px; stroke-width: 1.8; }
.map-page #mapa .pin[data-node-id="ty"] { z-index: 7; }
.map-page #mapa .pin[data-node-id="ty"] .pin-head { width: 36px; height: 30px; left: -2px; top: -10px; animation: ty-tremor 8s ease-in-out infinite; }
.map-page #mapa .pin[data-node-id="ty"] .pin-label { left: 42px; top: 5px; padding: 7px 15px; font-size: 18px; background: #eff0ce; text-transform: none; }
.map-page #mapa .pin[data-node-id="ty"] .pin-label > span { display: none; }
.map-page #mapa .pin[data-node-id="my"] .pin-label { padding: 6px 10px; font-size: 12px; }
.map-page #mapa .pin[data-node-id="my"] .pin-monogram { font-size: 9px; color: #9a3928; }
.map-page #mapa .pin:hover,
.map-page #mapa .pin:focus-visible,
.map-page #mapa .pin.is-active,
.map-page #mapa .pin.is-preview,
.map-page #mapa .pin.is-preview-related { background: none; filter: none; transform: translate(-50%, -50%); }
.map-page #mapa .pin:is(:hover, :focus-visible, .is-active, .is-preview) .pin-label { border-color: #282a22; box-shadow: 0 0 0 2px #fbf1d5, 3px 5px 7px #281b1255; }
.map-page #mapa .pin:is(:hover, :focus-visible, .is-active, .is-preview) .pin-head { filter: brightness(1.1); animation-play-state: paused; }
.map-page #mapa .pin:is(.is-preview-muted, .is-muted) { opacity: .3; }
.map-page #mapa .pin.is-hidden { opacity: .1; pointer-events: none; }
.map-page #mapa .pin:focus-visible { outline: 2px solid #17221a; outline-offset: 4px; }
.map-page #mapa:not([data-board-theme="cork"]) .pin:focus-visible { outline-color: #f3efdc; }

/* Opaque plies and a local shadow make over/under crossings legible. */
.map-page #mapa #threads g[data-from] { opacity: .96; filter: none; transition: opacity 180ms ease; }
.map-page #mapa #threads .thread { stroke: var(--thread-color); fill: none; filter: none; stroke-dasharray: none; }
.map-page #mapa #threads .thread-shadow { stroke: #20140c; stroke-width: 4.8; opacity: .28; transform: translate(1.4px, 2.4px); }
.map-page #mapa #threads .thread-bed { stroke: color-mix(in srgb, var(--thread-color) 48%, #2c211a); stroke-width: 3.4; opacity: 1; }
.map-page #mapa #threads .thread-core { stroke-width: 2.5; opacity: 1; }
.map-page #mapa #threads .thread-ply { stroke: color-mix(in srgb, var(--thread-color) 70%, #37251a); stroke-width: .6; opacity: .8; }
.map-page #mapa #threads .thread-highlight { stroke: #fff5d9; stroke-width: .55; opacity: .55; }
.map-page #mapa #threads .thread-fiber { stroke: color-mix(in srgb, var(--thread-color) 75%, #fff6e2); stroke-width: .5; opacity: .65; }
.map-page #mapa #threads .thread-knot { fill: none; stroke: #dfd3b8; stroke-width: 1.7; filter: drop-shadow(1px 1px 1px #312014); }
.map-page #mapa #threads g:is(.is-preview, .is-active) { opacity: 1; filter: none; }
.map-page #mapa #threads g:is(.is-preview, .is-active) .thread-core { stroke-width: 2.8; }
.map-page #mapa #threads g:is(.is-preview-muted, .is-muted) { opacity: .12; }
.map-page #mapa #threads g.is-filtered { opacity: .045; }
.map-page #mapa #threads g.is-short .thread-label { display: none; }
.map-page #mapa .thread-label { font-size: 11px; letter-spacing: 0; fill: #30291e; stroke: #f0e4cc; stroke-width: 4px; }
.map-page #mapa #threads g.is-preview .thread-label { opacity: 1; }
.map-page #mapa #threads g[data-from="my"].is-preview .thread-label { opacity: 0; }
/* My previews the whole structure; its 50+ captions would obscure the map. */
.map-page #mapa:has(.pin[data-node-id="my"].is-preview) .thread-label { opacity: 0; }

.map-page #mapa .inspector { inset: 3%; background: #f2ecdb; }
.map-page #mapa .inspector-sheet {
  background: linear-gradient(110deg, #fbf7eb, #eee5cf);
  padding: clamp(24px, 3.5vw, 52px);
}
.map-page #mapa .inspector-block h3 { color: #5e594c; line-height: 1.6; font-size: 10px; }
.map-page #mapa .inspector-category { color: #5c592c; }
.map-page #mapa .inspector-symbol { border-width: 4px; box-shadow: inset -4px -7px 10px #17221b38, inset 2px 3px 4px #fff9, 5px 10px 12px #33271340; }
.map-page #mapa .inspector-symbol .pin-monogram { font-size: 24px; }
.map-page #mapa .project-close { min-height: 44px; padding: 10px; }
.map-page #mapa .project-card.is-selected { filter: none; }
.map-page #mapa .project-card.is-selected::before { box-shadow: none; }

@media (min-width: 1700px) {
  .map-page #mapa .pin-label { font-size: 12px; padding: 6px 9px; }
  .map-page #mapa .pin-label .pin-icon { width: 14px; height: 14px; }
  .map-page #mapa .board-toolbar { min-height: 66px; }
}
@media (max-width: 1150px) {
  .map-page #mapa .pin[data-node-id="matematyka"] .pin-label { left: 39px; top: 30px; }
  .map-page #mapa .board-toolbar { gap: 10px; grid-template-columns: minmax(0, 1fr) auto; }
  .map-page #mapa .board-toolbar .map-controls { grid-column: 1 / -1; }
  .map-page #mapa .board-toolbar .theme-switcher { justify-self: end; }
}
@media (max-width: 700px) {
  .map-page { min-height: 0; height: 100svh; grid-template-rows: 60px minmax(0, 1fr) 24px; }
  .map-page .site-header { min-height: 60px; padding: 0 14px; }
  .map-page .brand-name { display: none; }
  .map-page .site-header nav { gap: 13px; font-size: 11px; }
  .map-page .site-header .nav-cta { padding: 10px 12px; }
  .map-page #mapa { margin: 0 6px; height: 100%; padding: 5px; grid-template-rows: minmax(0, 1fr) auto auto; }
  .map-page #mapa .map-stage { height: 680px; min-height: 680px; }
  .map-page #mapa .board-label { display: none; }
  .map-page #mapa .board-plaque { display: none; }
  .map-page #mapa .map-status { font-size: 9px; top: 14px; right: 14px; max-width: calc(100% - 28px); pointer-events: none; }
  .map-page #mapa .map-navigation { display: flex; align-items: center; gap: 3px; padding: 2px 6px; border-bottom: 1px solid #ffffff17; }
  .map-navigation span { flex: 1; max-width: 160px; font-size: 10px; line-height: 1.5; color: #b6b9ab; }
  .map-navigation button { flex: 0 0 auto; min-width: 44px; height: 44px; padding: 0 8px; font: inherit; font-size: 12px; color: #e9eddf; background: transparent; border: 0; cursor: pointer; }
  .map-page #mapa .board-toolbar { padding: 3px 3px 2px; gap: 2px 6px; min-width: 0; }
  .map-page #mapa .board-toolbar .map-controls { gap: 2px; padding: 0; }
  .map-page #mapa .board-toolbar .filter,
  .map-page #mapa .board-toolbar .theme-option,
  .map-page #mapa .project-trigger { min-height: 44px; font-size: 10px; padding: 9px 10px; }
  .map-page #mapa .project-trigger { min-width: 95px; }
  .map-page #mapa .board-toolbar .theme-switcher { gap: 2px; }
  .map-page #mapa .board-toolbar .theme-switcher > span { display: none; }
  .map-page #mapa .inspector { inset: 6px; max-height: none; }
  .map-page #mapa .inspector-sheet { padding: 20px; }
  .map-page #mapa .inspector-close { top: 0; min-height: 44px; float: none; display: flex; width: max-content; margin-left: auto; }
  .map-page #mapa .inspector-detail { margin-top: -44px; }
  .map-page #mapa .inspector-symbol { width: 64px; margin-top: 0; }
  .map-page #mapa .project-drawer { inset: 6px; padding: 64px 22px 24px; }
  .map-page #mapa .project-copy h2 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .map-page #mapa .pin[data-node-id="ty"] .pin-head { animation: none; }
}
