/* Layer: 07-responsive.css
 * mobile layout and mobile chrome
 *
 * Split out of app.css, which had grown to 8346 lines. Loaded in
 * order by app.css; do not reorder the @import lines there. Several rules in
 * the later layers override earlier ones by source order alone.
 */
/* Mobile / forced mobile layout */
body,
.app-body {
  overflow-x: hidden;
  max-width: 100vw;
}

.header-tools__more {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 60;
}

.header-tools__more-toggle {
  list-style: none;
  cursor: pointer;
}

.header-tools__more-toggle::-webkit-details-marker {
  display: none;
}

.header-tools__more-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

html:not([data-layout='mobile']) .header-tools__more {
  display: inline-flex;
  align-items: center;
}

html:not([data-layout='mobile']) .header-tools__more-toggle {
  display: none;
}

html:not([data-layout='mobile']) .header-tools__more-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

@media (max-width: 720px) {
  html:not([data-layout='desktop']) .header-tools__more-toggle {
    display: inline-flex;
  }

  html:not([data-layout='desktop']) .header-tools__more:not([open]) .header-tools__more-panel {
    display: none;
  }

  html:not([data-layout='desktop']) .header-tools__more[open] .header-tools__more-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 160px;
    padding: 8px;
    border: 2px solid var(--border, #4a2c14);
    border-radius: 6px;
    background: linear-gradient(180deg, #faebc8, #f0d8a0);
    box-shadow: var(--bevel-out);
  }
}

html[data-layout='mobile'] .header-tools__more-toggle {
  display: inline-flex;
}

html[data-layout='mobile'] .header-tools__more:not([open]) .header-tools__more-panel {
  display: none;
}

html[data-layout='mobile'] .header-tools__more[open] .header-tools__more-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 160px;
  padding: 8px;
  border: 2px solid var(--border, #4a2c14);
  border-radius: 6px;
  background: linear-gradient(180deg, #faebc8, #f0d8a0);
  box-shadow: var(--bevel-out);
}

@media (max-width: 720px) {
  .app-header__actions .header-tools__primary .btn {
    min-height: 40px;
  }

  .map-hud__board {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .hud-vault {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .room-nav .nav-btn,
  .btn {
    min-height: 40px;
    padding: 8px 12px;
  }

  .app-header__row {
    flex-direction: column;
    align-items: stretch;
  }

  .header-tools {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  #chat-toggle-btn:not([hidden]) {
    display: inline-flex;
  }

  .guild-chat:not(.guild-chat--collapsed) {
    max-height: 36vh;
  }
}

html[data-layout='mobile'] .map-hud__board {
  grid-template-columns: 1fr;
}

html[data-layout='mobile'] .hud-vault {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Mobile chrome: brand | Chat | Войти; nav 4-up one row; scroll to map */
html[data-layout='mobile'] .app-header__row {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* Without this the row keeps flexbox's default `min-width: auto` and cannot be
   * narrowed below its content, so the header would still widen the document
   * even once the actions block is allowed to shrink. */
  min-width: 0;
}

html[data-layout='mobile'] .app-header__brand {
  flex: 1 1 auto;
  min-width: 0;
}

html[data-layout='mobile'] .app-header__brand--sign {
  max-width: min(100%, calc(100vw - 130px));
  padding: 0 2px;
  min-height: 0;
  background: transparent !important;
  background-image: none !important;
  border: none;
  box-shadow: none;
}

html[data-layout='mobile'] .app-header__brand--sign h1 {
  font-size: clamp(1.05rem, 4.4vw, 1.3rem) !important;
  font-family: var(--font-lore, Georgia, 'Times New Roman', serif) !important;
  font-weight: 700 !important;
  line-height: 1.15;
  color: #f7edd8 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

html[data-layout='mobile'] .app-header__brand h1 {
  font-size: clamp(0.85rem, 3.6vw, 1.05rem);
  line-height: 1.15;
}

html[data-layout='mobile'] .app-header__actions.header-tools {
  /* Was `flex: 0 0 auto` with `flex-wrap: nowrap`, which told the block to hold
   * its full 478px no matter how narrow the screen was - the direct cause of the
   * 481px document on phones. `1 1 auto` lets it shrink, and `min-width: 0`
   * overrides the flex default that otherwise refuses to go below content width.
   * `wrap` means that if the actions ever outgrow the row again, they reflow
   * instead of pushing the page sideways. */
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
}

html[data-layout='mobile'] #app-role {
  display: none !important;
}

/* The layout toggle ("Авто → Компакт → Широкий") is hidden on phones.
 *
 * It used to be forced visible here, and that is what broke every mobile screen.
 * The actions block does not shrink (see the flex rules below), so its children
 * have to fit in ~345px. Measured at a 375px viewport the block needed 478px:
 *
 *     btn--layout "Авто"        88px
 *     btn--ghost  "Чат"         50px
 *     header-tools__primary    236px   (always 168 + more 63)
 *     #auth-btn   "Войти"       86px
 *                              ─────
 *                              478px
 *
 * The overflow escaped into the document because .app-header sits outside
 * .app-body, where the overflow-x: hidden guard lives. Result: the page was
 * 481px wide on every phone (375/390/430) and in every room, since the header
 * is on all of them.
 *
 * The toggle is the right thing to drop here. It picks a *layout* - auto,
 * compact or wide - which is a choice that only means something once there is
 * room to lay out; on a 375px screen all three states land on the same single
 * column, so it spends 88px of 345px on a control that cannot visibly do
 * anything. The width-based rules in this file already decide the phone layout
 * on their own.
 *
 * The element itself is kept and hidden by attribute, so the aria/JS wiring
 * that owns it keeps working and a desktop user sees no change. */
html[data-layout='mobile'] #layout-toggle-btn {
  display: none !important;
}

html[data-layout='mobile'] .header-tools__primary:not(:has(.btn:not([hidden]))) {
  display: none;
}

html[data-layout='mobile'] .header-tools__more:not(:has(.header-tools__more-panel .btn:not([hidden]))) {
  display: none;
}

html[data-layout='mobile'] #chat-toggle-btn:not([hidden]) {
  display: inline-flex;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

html[data-layout='mobile'] #auth-btn {
  display: inline-flex;
  min-height: 36px;
  padding: 6px 12px;
  white-space: nowrap;
}

html[data-layout='mobile'] #room-nav.room-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
  align-items: stretch;
}

html[data-layout='mobile'] #room-nav > .nav-btn,
html[data-layout='mobile'] #room-nav > .nav-more {
  min-width: 0;
  width: 100%;
}

html[data-layout='mobile'] #room-nav .nav-btn {
  min-height: 40px;
  padding: 6px 4px;
  font-size: clamp(0.72rem, 2.8vw, 0.88rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: center;
}

html[data-layout='mobile'] #room-nav .nav-more {
  display: block;
  position: relative;
}

html[data-layout='mobile'] #room-nav .nav-more__toggle {
  width: 100%;
}

html[data-layout='mobile'] #room-nav .nav-more__panel {
  left: auto;
  right: 0;
  min-width: min(200px, 70vw);
}

html[data-layout='mobile'] .room-nav .nav-btn,
html[data-layout='mobile'] .btn {
  min-height: 40px;
}

html[data-layout='mobile'] body {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
  min-height: 100dvh;
}

html[data-layout='mobile'] .app-body {
  overflow-x: hidden;
  overflow-y: visible;
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
}

html[data-layout='mobile'] .room-root:has(.map-room--bleed) {
  overflow: visible;
  height: auto;
  min-height: 0;
}

html[data-layout='mobile'] .map-room,
html[data-layout='mobile'] .map-room--bleed,
html[data-layout='mobile'] .map-stage {
  overflow: visible;
  height: auto;
  max-height: none;
  min-height: 0;
}

html[data-layout='mobile'] .guild-chat:not(.guild-chat--collapsed) {
  max-height: 36vh;
  max-height: 36dvh;
}

.nav-btn--deep {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  white-space: nowrap !important;
}
