/* Map section. The map is the one bold element; the report stays quiet.
 * Seats are numbered, never colored (docs/design.md). */

:root {
  --tint-red: rgba(239, 90, 95, 0.1);
  --hatch: rgba(160, 169, 207, 0.45);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --tint-red: rgba(180, 60, 60, 0.09);
    --hatch: rgba(80, 91, 125, 0.4);
  }
}

.map-page { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + 48px); }

/* Form */
.map-form label { display: block; margin: 8px 0 6px; font: 600 var(--t-s)/1.3 var(--display); font-stretch: 105%; color: var(--dust); }
.map-form textarea {
  display: block; width: 100%; padding: 12px; resize: vertical;
  background: var(--hull); border: 1px solid var(--seam); border-radius: var(--radius-m);
  font: 400 var(--t-m)/1.4 var(--text); font-variant-numeric: tabular-nums;
}
.map-form textarea:focus-visible { border-color: var(--influence); outline-offset: 0; }
.map-hint { margin: 6px 0 0; min-height: 0; color: var(--warn); font-size: var(--t-s); }
.map-hint:empty { display: none; }
.map-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; }
.btn-primary { min-height: 44px; padding: 0 20px; border-radius: var(--radius-m); background: var(--influence); border-color: var(--influence); color: var(--void); font-stretch: 105%; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--influence); }
.map-example { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.map-empty { margin: 24px 0; color: var(--dust); max-width: 34rem; }

.recent { margin-top: 28px; }
.recent h2 { margin: 0 0 4px; font: 600 var(--t-l)/1.2 var(--display); font-stretch: 110%; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; flex-direction: column; padding: 10px 0; border-top: 1px solid var(--seam); min-height: 44px; }
.recent li .muted { font-size: var(--t-xs); overflow-wrap: anywhere; }

/* Verdict */
.verdict { margin: 28px 0 4px; font: 600 var(--t-xl)/1.2 var(--display); font-stretch: 118%; text-wrap: balance; }
.map-sub { margin: 0 0 12px; color: var(--dust); font-size: var(--t-s); }
.map-error { margin: 24px 0; }

/* The map */
.map-fig { margin: 0 -4px; }
.mapsvg { display: block; width: 100%; height: auto; max-height: 80dvh; user-select: none; -webkit-tap-highlight-color: transparent; }
.mapsvg .hex { cursor: pointer; }
.mapsvg .face { fill: var(--hull); stroke: var(--seam); stroke-width: 0.7; transition: fill 0.15s ease; }
.mapsvg .tint { fill: var(--tint-red); pointer-events: none; }
.mapsvg .shared { fill: url(#hatch); pointer-events: none; }
.mapsvg .hatch-line { stroke: var(--hatch); stroke-width: 1; }
.mapsvg .edge { fill: none; stroke: none; pointer-events: none; }
.mapsvg .hex.sel .face { fill: var(--hull-2); }
.mapsvg .hex.sel .edge { stroke: var(--star); stroke-width: 1.4; stroke-linejoin: round; }
.mapsvg .hex.open .face { fill: none; stroke-dasharray: 2 2.5; }
.mapsvg .hex.lane .face { fill: transparent; }
.mapsvg .hex.mecatol .face { stroke: var(--star); stroke-width: 1.1; }
.mapsvg .hex:focus, .mapsvg .hex:focus-visible { outline: none; }
.mapsvg .hex:focus-visible .edge { stroke: var(--influence); stroke-width: 2; }
.mapsvg .lane-line { fill: none; stroke: var(--dust); stroke-width: 1; stroke-linecap: round; pointer-events: none; }

.mapsvg text { pointer-events: none; font-variant-numeric: tabular-nums; }
.mapsvg .seat-num { font: 700 15px var(--display); font-stretch: 125%; fill: var(--resource); text-anchor: middle; dominant-baseline: central; }
.mapsvg .pr, .mapsvg .pi { font: 600 6.6px var(--display); font-stretch: 115%; }
.mapsvg .pr { fill: var(--resource); }
.mapsvg .pi { fill: var(--influence); }
.mapsvg .planet { pointer-events: none; }
.mapsvg .worm { font: 600 7.5px var(--display); fill: var(--star); text-anchor: middle; }
.mapsvg .glyph { fill: none; stroke: var(--dust); stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.mapsvg .glyph circle:not([r="2"]):not([r="4.4"]):not([r="6.8"]) { fill: var(--dust); stroke: none; }
.mapsvg .legend { fill: none; stroke: var(--resource); stroke-width: 0.9; }
.mapsvg .te-spot { fill: none; stroke: var(--resource); stroke-width: 0.9; stroke-dasharray: 2.2 2; pointer-events: none; }
.mapsvg.art .te-spot { stroke: #f4c542; stroke-width: 1.4; } /* art is dark in both themes */
.mapsvg .skip { stroke: none; }
.skip-green { fill: var(--tech-biotic); background: var(--tech-biotic); }
.skip-blue { fill: var(--tech-propulsion); background: var(--tech-propulsion); }
.skip-yellow { fill: var(--tech-cybernetic); background: var(--tech-cybernetic); }
.skip-red { fill: var(--tech-warfare); background: var(--tech-warfare); }

.te-note { margin: 4px 0 0; color: var(--dust); font-size: var(--t-s); }
.tile-note { min-height: 3em; margin: 8px 0 0; color: var(--dust); font-size: var(--t-s); }

/* Report */
.map-notes { margin: 8px 0 16px; color: var(--dust); font-size: var(--t-s); }
.map-notes summary, .seat summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.map-notes ul { margin: 4px 0 0; padding-left: 1.2em; }
.seats { border-bottom: 1px solid var(--seam); }
.seat { display: grid; grid-template-columns: 3rem 1fr; column-gap: 4px; padding: 16px 0 12px; border-top: 1px solid var(--seam); cursor: pointer; }
.seat.sel { box-shadow: inset 3px 0 0 var(--star); background: var(--hull); padding-left: 10px; margin-left: -10px; }
.seat-n { font: 700 var(--t-2xl)/1 var(--display); font-stretch: 125%; font-variant-numeric: tabular-nums; color: var(--resource); }
.seat h2 { margin: 0; font: 600 var(--t-l)/1.2 var(--display); font-stretch: 110%; }
.seat-pick { min-height: 44px; margin-top: -10px; padding: 10px 0; text-align: left; font: inherit; font-stretch: inherit; color: inherit; }
.seat-pick[aria-pressed="false"]:hover { text-decoration: underline; text-decoration-color: var(--seam); text-underline-offset: 0.2em; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: grid; grid-template-columns: 22px 1fr; align-items: start; padding: 3px 0; }
.mk { width: 14px; height: 14px; margin-top: 5px; stroke-width: 1.6; stroke-linejoin: round; fill: none; }
.mk-warn { fill: var(--warn); stroke: var(--warn); }
.mk-note { stroke: var(--dust); }
.mk-good { stroke: var(--resource); }
.seat details { margin-top: 4px; color: var(--dust); }
.seat summary { font: 600 var(--t-s)/1 var(--display); font-stretch: 105%; }
.metrics { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: var(--t-s); }
.metrics th, .metrics td { padding: 7px 0; border-top: 1px solid var(--seam); text-align: left; vertical-align: top; }
.metrics th { width: 46%; padding-right: 12px; font-weight: 400; color: var(--dust); }
.metrics td { color: var(--star); font-variant-numeric: tabular-nums; }
.n-res { color: var(--resource); font: 700 1em var(--display); font-stretch: 115%; }
.n-inf { color: var(--influence); font: 700 1em var(--display); font-stretch: 115%; }
.skip-tag { display: inline-flex; align-items: center; gap: 5px; margin-right: 10px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* Desktop: map sticky on the left, report scrolling on the right. */
@media (min-width: 960px) {
  .map-page:has(.map-result) { max-width: 76rem; }
  .map-page .map-form { max-width: var(--measure); }
  .map-result { display: grid; grid-template-columns: 55fr 45fr; gap: 40px; align-items: start; }
  .map-left { position: sticky; top: 12px; }
  .map-left .verdict { margin-top: 16px; }
  .mapsvg { max-height: calc(100dvh - 120px); }
  .map-form textarea { height: 76px; }
  .seats { margin-top: 12px; }
}

/* Player name under the numeral on a planned or played game's map. The halo keeps it readable over tile art. */
.mapsvg .seat-name {
  font: 600 4.4px var(--display); font-stretch: 105%; fill: var(--star); text-anchor: middle;
  stroke: var(--void); stroke-width: 1.4px; stroke-linejoin: round; paint-order: stroke;
}

/* Faction symbol above the seat numeral on a home hex. */
.mapsvg .fsym-map { color: var(--dust); fill: currentColor; pointer-events: none; overflow: visible; }

/* View toggle: two quiet text buttons, the chosen one underlined in --influence. */
.view-toggle { display: flex; gap: 20px; margin: 0 0 4px; }
.view-toggle button {
  min-height: 44px; padding: 0 2px; font: 600 var(--t-s)/1 var(--display); font-stretch: 105%;
  color: var(--dust); border-bottom: 2px solid transparent;
}
.view-toggle button[aria-pressed="true"] { color: var(--star); border-bottom-color: var(--influence); }
.view-toggle button:hover:not([aria-pressed="true"]) { color: var(--star); }

/* Tile numbers switch: same quiet style as the view toggle, on its row (wraps on a phone). */
.map-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 20px; margin: 0 0 4px; }
.map-controls .view-toggle { margin: 0; }
.ids-toggle {
  min-height: 44px; padding: 0 2px; font: 600 var(--t-s)/1 var(--display); font-stretch: 105%;
  color: var(--dust); border-bottom: 2px solid transparent;
}
.ids-toggle[aria-pressed="true"] { color: var(--influence); border-bottom-color: var(--influence); }
.ids-toggle:hover:not([aria-pressed="true"]) { color: var(--star); }

/* Tile numbers on hexes. Analysis: a small label at the top edge. Art: bigger, on a dark pill. */
.mapsvg .tile-id { font: 600 5.6px var(--display); font-stretch: 110%; fill: var(--dust); text-anchor: middle; dominant-baseline: central; }
.mapsvg .id-scrim { fill: rgb(0 0 0 / 0.65); pointer-events: none; }
.mapsvg.art .tile-id { font-size: 9px; fill: #fff; }
.mapsvg .tile-id-wrap { pointer-events: none; transition: opacity 0.15s ease; }
.mapsvg.has-sel .hex:not(.sel) .tile-id-wrap { opacity: 0.45; }
@media (prefers-reduced-motion: reduce) { .mapsvg .tile-id-wrap { transition: none; } }

/* Tile art. The face stays underneath as the "before it loads" fill. */
.mapsvg.art .dim { fill: #05070f; opacity: 0; pointer-events: none; transition: opacity 0.15s ease; }
.mapsvg.art.has-sel .hex:not(.sel) .dim { opacity: 0.7; }
.mapsvg.art .hex.sel .face { fill: var(--hull); }
/* Tile art is dark in both themes, so its outlines are always light. */
.mapsvg.art .hex.sel .edge { stroke: #f4f6ff; stroke-width: 1.8; }
.mapsvg.art .shared-edge { fill: none; stroke: #f4f6ff; stroke-width: 1; stroke-dasharray: 3 2.5; opacity: 0.8; pointer-events: none; }
.mapsvg.art .num-scrim { fill: #05070f; opacity: 0.72; pointer-events: none; }
.mapsvg.art .hex.pic .face { fill: var(--hull-2); }
@media (prefers-reduced-motion: reduce) { .mapsvg.art .dim { transition: none; } }

/* Link from a map's seat reports to the plan form. */
.plan-link { margin: 20px 0; }
.plan-link a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* Legendary ability tips: hover or focus with a mouse, tap on a phone. The
   tip spans the line's width below it, so it can't push the page sideways. */
.lines li, .metrics td { position: relative; }
.tip-btn { padding: 0; font: inherit; color: inherit; text-decoration: underline dotted var(--influence); text-underline-offset: 0.25em; cursor: help; }
.tip-body {
  display: none; position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% - 2px);
  padding: 10px 12px; background: var(--hull-2); border: 1px solid var(--seam); border-radius: var(--radius-s);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); color: var(--star); font: 400 var(--t-s)/1.45 var(--text); cursor: auto;
}
.tip-body::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 10px; } /* hover bridge from the name */
.lines .tip-body { left: 22px; }
.tip-body b { color: var(--resource); font-weight: 700; }
.tip-btn[aria-expanded="true"] + .tip-body, .tip-btn:focus-visible + .tip-body { display: block; }
@media (hover: hover) { .tip:hover .tip-body { display: block; } }
