/* Minecraft live map — BlueMap embed */

html:has(body.map-page) {
  height: 100%;
  overflow: hidden;
}

body.map-page {
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-page__header {
  flex: 0 0 auto;
}

.map-toolbar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.85rem 1.35rem;
  border-bottom: 1px solid rgba(92, 219, 74, 0.35);
  background:
    radial-gradient(ellipse 120% 180% at 0% 50%, rgba(92, 219, 74, 0.14), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(74, 222, 128, 0.1), transparent 45%),
    linear-gradient(180deg, rgba(14, 20, 14, 0.98), rgba(8, 12, 10, 0.96));
  backdrop-filter: blur(12px);
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(92, 219, 74, 0.12) inset,
    0 12px 32px -16px rgba(0, 0, 0, 0.65);
}

.map-toolbar > :not(.map-toolbar__texture) {
  position: relative;
  z-index: 1;
}

.map-toolbar__texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-toolbar__texture--grid {
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(92, 219, 74, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 219, 74, 0.11) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: linear-gradient(105deg, black 0%, black 35%, transparent 72%);
}

.map-toolbar__texture--scan {
  opacity: 0.35;
  background: repeating-linear-gradient(
    -55deg,
    transparent,
    transparent 10px,
    rgba(92, 219, 74, 0.045) 10px,
    rgba(92, 219, 74, 0.045) 11px
  );
}

.map-toolbar__texture--glow {
  background:
    linear-gradient(90deg, rgba(92, 219, 74, 0.22), transparent 28%),
    linear-gradient(180deg, transparent 85%, rgba(92, 219, 74, 0.35) 100%);
  opacity: 0.7;
}

.map-toolbar__main {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.map-toolbar__back {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 52px;
  padding: 0.7rem 1.15rem;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #dcfce7;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid rgba(92, 219, 74, 0.45);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(92, 219, 74, 0.22), rgba(21, 128, 61, 0.18)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 2px,
      transparent 2px,
      transparent 6px
    );
  box-shadow:
    0 0 0 1px rgba(92, 219, 74, 0.08) inset,
    0 4px 16px -4px rgba(92, 219, 74, 0.35);
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.map-toolbar__back:hover {
  border-color: rgba(134, 239, 172, 0.65);
  background:
    linear-gradient(180deg, rgba(92, 219, 74, 0.32), rgba(21, 128, 61, 0.24)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 2px,
      transparent 2px,
      transparent 6px
    );
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(134, 239, 172, 0.15) inset,
    0 8px 22px -6px rgba(92, 219, 74, 0.45);
}

.map-toolbar__back-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(92, 219, 74, 0.45));
}

.map-toolbar__title-group {
  min-width: 0;
}

.map-toolbar__title {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1.2;
}

.map-toolbar__title .is-narrow {
  display: none;
}

.map-toolbar__open-label.is-narrow {
  display: none;
}

.map-toolbar__open-icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
}

.map-toolbar__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
  margin-top: 0.15rem;
  font-size: var(--text-ui-xs);
  color: var(--text-muted);
}

.map-toolbar__meta code {
  font-size: inherit;
  color: #86efac;
}

.map-toolbar__dot {
  opacity: 0.45;
}

.map-toolbar__stats {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem 1.25rem;
}

.map-stat {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.map-stat__value {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--minecraft);
  white-space: nowrap;
}

.map-stat__label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.map-toolbar__actions {
  flex-shrink: 0;
}

.map-toolbar__open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.5rem 0.9rem;
  font-size: var(--text-ui-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bg-deep);
  background: var(--minecraft);
  border-radius: 6px;
  white-space: nowrap;
  transition: filter 0.2s, transform 0.2s;
}

.map-toolbar__open:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.map-frame-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  background: #0a0e14;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.map-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0a0e14;
}

.map-frame-wrap.is-loaded .map-frame__loading {
  opacity: 0;
  pointer-events: none;
}

.map-frame__loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  background: rgba(8, 10, 16, 0.92);
  transition: opacity 0.35s ease;
  pointer-events: none;
}

/* Tablet */
@media (max-width: 1024px) {
  .map-toolbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "main actions"
      "stats stats";
  }

  .map-toolbar__main {
    grid-area: main;
  }

  .map-toolbar__stats {
    grid-area: stats;
  }

  .map-toolbar__actions {
    grid-area: actions;
    justify-self: end;
  }

  .map-stat--views .map-stat__value {
    font-size: 0.8rem;
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --nav-height: 64px;
  }

  body.map-page {
    height: 100dvh;
    height: 100svh;
  }

  .map-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem;
    padding-top: calc(0.4rem + env(safe-area-inset-top, 0px));
  }

  .map-toolbar__texture--grid,
  .map-toolbar__texture--scan {
    display: none;
  }

  .map-toolbar__main {
    flex: 1 1 auto;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
  }

  .map-toolbar__back {
    min-height: 0;
    padding: 0.35rem 0.45rem;
    gap: 0;
    border-radius: 6px;
    font-size: 0;
  }

  .map-toolbar__back-label {
    display: none;
  }

  .map-toolbar__back-icon {
    width: 22px;
    height: 22px;
  }

  .map-toolbar__title-group {
    flex: 1 1 auto;
    min-width: 0;
  }

  .map-toolbar__title .is-wide {
    display: none;
  }

  .map-toolbar__title .is-narrow {
    display: block;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .map-toolbar__meta {
    display: none;
  }

  .map-toolbar__stats {
    flex: 0 0 auto;
    width: auto;
    gap: 0;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    background: rgba(92, 219, 74, 0.08);
    border: 1px solid rgba(92, 219, 74, 0.2);
  }

  .map-stat {
    flex-direction: row;
    align-items: center;
    gap: 0.2rem;
  }

  .map-stat:not(:first-child) {
    display: none;
  }

  .map-stat__value {
    font-size: 0.78rem;
    line-height: 1;
  }

  .map-stat__label {
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    line-height: 1;
  }

  .map-toolbar__actions {
    flex: 0 0 auto;
  }

  .map-toolbar__open {
    min-height: 0;
    min-width: 34px;
    padding: 0.35rem 0.45rem;
    border-radius: 6px;
  }

  .map-toolbar__open-label.is-wide {
    display: none;
  }

  .map-toolbar__open-label.is-narrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
  }
}

.map-toolbar__back-label .is-narrow {
  display: none;
}

@media (max-width: 480px) {
  .map-toolbar__back-label .is-wide {
    display: none;
  }

  .map-toolbar__back-label .is-narrow {
    display: inline;
  }

  .map-toolbar__back-label {
    max-width: none;
  }

  .map-toolbar__meta span:not(:first-child):not(.map-toolbar__dot) {
    display: none;
  }

  .map-toolbar__meta .map-toolbar__dot {
    display: none;
  }
}
