/* Minecraft map chrome and controls use platform UI roles. Terrain is geographic. */

:root {
  color-scheme: dark;
  --map-bg: var(--soto-map-land);
  --map-panel: var(--soto-surface);
  --map-line: var(--soto-border);
  --map-text: var(--soto-text);
  --map-muted: var(--soto-text-muted);
  --map-accent: var(--soto-accent);
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--map-bg);
  color: var(--map-text);
  font: 400 14px/20px var(--soto-font);
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--map-bg);
  color: var(--map-text);
  font: 400 14px/20px var(--soto-font);
}

summary {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .45;
}

a {
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}

::selection {
  background: var(--soto-surface-active);
  color: var(--soto-text);
}

button:focus-visible {
  outline: 2px solid var(--map-accent);
  outline-offset: 3px;
}

a:focus-visible {
  outline: 2px solid var(--map-accent);
  outline-offset: 3px;
}

summary:focus-visible {
  outline: 2px solid var(--map-accent);
  outline-offset: 3px;
}

canvas:focus-visible {
  outline: 2px solid var(--map-accent);
  outline-offset: -4px;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.icon-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.maps-shell {
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  height: 100dvh;
  min-width: 0;
}

.map-site-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 13px 24px;
  background: var(--soto-surface);
  border-bottom: 1px solid var(--map-line);
  min-width: 0;
}

.map-brand {
  display: block;
  flex: none;
}

.map-brand img {
  display: block;
  width: 96px;
  height: 53px;
  object-fit: contain;
}

.map-heading {
  min-width: 0;
  flex: 1;
}

.map-heading h1 {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 500;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-heading p {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 3px 0 0;
  color: var(--map-muted);
  font-size: 12px;
  line-height: 20px;
}

.heading-divider {
  height: 12px;
  width: 1px;
  background: var(--map-line);
}

.site-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.map-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--map-line);
  border-radius: 7px;
  padding: 7px 11px;
  background: var(--soto-surface-raised);
  color: var(--soto-text);
  font-size: 12px;
  line-height: 20px;
  transition: background .15s,color .15s;
}

.map-action svg {
  width: 15px;
  height: 15px;
}

.map-action:hover:enabled {
  background: var(--soto-surface-hover);
  color: var(--soto-text);
}

.map-surface {
  position: relative;
  min-height: 0;
  min-width: 0;
  isolation: isolate;
  overflow: hidden;
  background: var(--map-bg);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

canvas.is-dragging {
  cursor: grabbing;
}

.viewport-top {
  position: absolute;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
  top: 16px;
  align-items: flex-start;
}

.map-context {
  display: flex;
  align-items: center;
  gap: 7px;
}

.map-info {
  position: relative;
  pointer-events: auto;
}

.map-info summary {
  display: grid;
  place-items: center;
  list-style: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--map-line);
  background: color-mix(in srgb, var(--soto-surface-raised) 96%, transparent);
  color: var(--map-muted);
  cursor: pointer;
}

.map-info summary::-webkit-details-marker {
  display: none;
}

.map-info summary:hover {
  background: var(--soto-surface-hover);
  color: var(--soto-text);
}

.map-info-body {
  position: absolute;
  top: 43px;
  left: 0;
  width: 282px;
  max-width: calc(100vw - 75px);
  padding: 14px 16px;
  background: var(--soto-surface-raised);
  border: 1px solid var(--map-line);
  border-radius: 10px;
  box-shadow: none;
  line-height: 20px;
}

.map-info-body strong {
  font-size: 14px;
  font-weight: 500;
}

.map-info-body p {
  margin: 7px 0 0;
  color: var(--map-muted);
  font-size: 12px;
}

.map-info-body .map-info-note {
  border-top: 1px solid var(--map-line);
  padding-top: 10px;
  margin-top: 10px;
}

.embedded-world {
  display: none;
}

.embedded-state {
  display: none;
}

.map-coordinate-group output span {
  color: var(--soto-text-secondary);
  margin: 0 4px;
}

.map-north {
  background: color-mix(in srgb, var(--soto-surface-raised) 95%, transparent);
  border: 1px solid var(--map-line);
  border-radius: 7px;
  color: var(--soto-text);
  font-size: 12px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
}

.map-north svg {
  width: 15px;
  height: 15px;
  color: var(--soto-text);
}

.map-north span {
  font-size: 12px;
  color: var(--soto-text-secondary);
}

.zoom-controls button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--soto-text);
}

.zoom-controls button:hover:enabled {
  background: var(--soto-surface-hover);
  color: var(--soto-text);
}

.zoom-controls output {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--map-muted);
}

.control-divider {
  height: 18px;
  width: 1px;
  background: var(--map-line);
  margin: 0 3px;
}

.map-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 350px;
  max-width: calc(100% - 40px);
  text-align: center;
  background: color-mix(in srgb, var(--soto-surface-raised) 95%, transparent);
  border: 1px solid var(--map-line);
  border-radius: 12px;
  padding: 25px 24px;
  z-index: 3;
}

.map-message h2 {
  font-size: 18px;
  line-height: 26px;
  letter-spacing: -.01em;
  font-weight: 500;
  margin: 0 0 8px;
}

.map-message p {
  margin: 0;
  color: var(--map-muted);
  font-size: 14px;
  line-height: 21px;
}

.map-message button {
  margin-top: 17px;
}

.map-loading-symbol {
  width: 44px;
  height: 4px;
  border: 0;
  border-radius: var(--soto-radius-pill);
  margin: 0 auto 16px;
  background: var(--soto-surface-active);
  animation: map-loading-opacity 1s var(--soto-ease) infinite alternate;
}

.map-message.is-error .map-loading-symbol {
  display: none;
}

.map-notice {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(420px,calc(100% - 130px));
  padding: 9px 13px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--soto-surface-raised) 96%, transparent);
  border: 1px solid var(--soto-border-strong);
  color: var(--soto-text);
  font-size: 12px;
  line-height: 19px;
  z-index: 3;
}

[data-embed=launcher] .map-site-header {
  display: none;
}

[data-embed=launcher] .maps-shell {
  grid-template-rows: minmax(0,1fr);
}

[data-embed=launcher] .embedded-world {
  display: block;
  background: color-mix(in srgb, var(--soto-surface-raised) 95%, transparent);
  border: 1px solid var(--map-line);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12px;
  line-height: 20px;
  color: var(--soto-text);
}

[data-embed=launcher] .embedded-state {
  display: block;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 20px;
  background: color-mix(in srgb, var(--soto-surface-raised) 93%, transparent);
  border: 1px solid var(--map-line);
  border-radius: 8px;
}

[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-thumb {
  background: var(--soto-surface-hover);
  border-radius: 5px;
}

.viewport-bottom {
  position: absolute;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
  bottom: max(16px,env(safe-area-inset-bottom));
  flex-wrap: wrap;
}

.map-coordinate-group {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
}

.map-coordinate-group>output {
  background: color-mix(in srgb, var(--soto-surface-raised) 95%, transparent);
  border: 1px solid var(--map-line);
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--soto-text);
  font-size: 12px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: calc(100vw - 84px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  pointer-events: auto;
  border: 1px solid var(--map-line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--soto-surface-raised) 96%, transparent);
  padding: 3px;
  margin-left: auto;
}

.player-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.player-marker {
  position: absolute;
  transform: translate(-50%,-50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--soto-text);
  font: 500 12px/18px var(--soto-font);
}

.player-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border: 2px solid var(--soto-border-strong);
  border-radius: 50%;
  background: var(--soto-surface-hover);
  box-shadow: none;
}

.player-name {
  position: absolute;
  left: 50%;
  top: 33px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--soto-surface-raised) 95%, transparent);
  color: var(--soto-text);
}

.player-marker:hover .player-dot {
  background: var(--soto-surface-active);
}

.map-players {
  position: absolute;
  top: 64px;
  right: 18px;
  z-index: 3;
  max-width: calc(100% - 36px);
  color: var(--map-text);
}

.map-players summary {
  list-style: none;
  cursor: pointer;
  background: color-mix(in srgb, var(--soto-surface-raised) 96%, transparent);
  border: 1px solid var(--map-line);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  line-height: 20px;
}

.players-list {
  width: 220px;
  max-width: 100%;
  max-height: 230px;
  overflow: auto;
  margin-top: 5px;
  padding: 6px;
  border-radius: 8px;
  background: var(--soto-surface-raised);
  border: 1px solid var(--map-line);
}

.players-list:empty {
  display: none;
}

.players-list button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--map-text);
  padding: 9px 7px;
  text-align: left;
  font: 500 12px/18px var(--soto-font);
}

.players-list button:hover:enabled {
  background: var(--soto-surface-hover);
}

.players-list .is-selected {
  background: var(--soto-surface-hover);
}

.players-list small {
  font-size: 12px;
  color: var(--map-muted);
  text-align: right;
}

.players-list p {
  margin: 7px;
  color: var(--map-muted);
  font-size: 12px;
  line-height: 18px;
}

html.platform-map {
  height: 100%;
  min-height: 0;
}

html.platform-map body {
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

html.platform-map .maps-shell {
  flex: 1;
  min-height: 0;
  height: auto;
}

html[data-platform-embedded="true"] .map-site-header {
  display: none;
}

html[data-platform-embedded="true"] .maps-shell {
  grid-template-rows: minmax(0, 1fr);
}

.server-state.is-online {
  color: var(--soto-success);
}

.embedded-state.is-online {
  color: var(--soto-success);
}

.server-state.is-offline {
  color: var(--soto-text-muted);
}

.embedded-state.is-offline {
  color: var(--soto-text-muted);
}

.server-state.is-checking {
  color: var(--soto-info);
}

.embedded-state.is-checking {
  color: var(--soto-info);
}

.players-demo {
  position: absolute;
  left: 18px;
  top: 64px;
  z-index: 3;
  max-width: calc(100% - 36px);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--soto-warning);
  background: var(--soto-warning-bg);
}

@media (max-width:640px) {
  .map-site-header {
    padding: 10px 14px;
    gap: 10px;
  }

  .map-brand img {
    width: 65px;
    height: 42px;
  }

  .map-heading h1 {
    font-size: 18px;
    line-height: 24px;
  }

  .map-heading p {
    font-size: 12px;
    gap: 6px;
  }

  .site-actions {
    gap: 5px;
  }

  .site-actions button {
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .site-actions button span {
    display: none;
  }

  .viewport-top {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .viewport-bottom {
    left: 12px;
    right: 12px;
    bottom: max(12px,env(safe-area-inset-bottom));
  }

  .map-north span {
    display: none;
  }

  .map-coordinate-group>output {
    padding: 7px 8px;
    font-size: 12px;
  }

  .zoom-controls button {
    width: 34px;
    height: 36px;
  }

  .zoom-controls output {
    min-width: 38px;
    font-size: 12px;
  }

  .control-divider {
    margin: 0 1px;
  }

  .map-notice {
    top: 57px;
    max-width: calc(100% - 24px);
    width: max-content;
  }

  .map-info summary {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion:reduce) {
  * {
    transition: none !important;
  }

  .map-loading-symbol {
    animation: none;
  }
}

@media (max-width:640px) {
  .site-actions button {
    width: 44px;
    height: 44px;
  }

  .map-info summary {
    width: 44px;
    height: 44px;
  }

  .zoom-controls button {
    width: 44px;
    height: 44px;
  }
}

@media (max-width:640px) {
  .map-players {
    right: 12px;
    top: 68px;
  }

  .players-demo {
    left: 12px;
    top: 112px;
  }

  .player-marker {
    font-size: 12px;
  }
}

@keyframes map-loading-opacity { from { opacity: .4; } to { opacity: 1; } }
