/* Phone fixes from the mobile audit. Loaded last. */

/* Floating combat numbers never draw over dialogs or the menu. */
#modal:has(.overlay) ~ #floats { display: none; }

@media (max-width: 960px) {
  /* ---- Gear: the item grid was squeezed to a few pixels ---- */
  .gear-page .gear-bag { flex: none; height: auto; min-height: 0; }
  .gear-page .gear-bag .bag-items { flex: none; height: auto; min-height: 0; max-height: none; overflow: visible; }
  .gear-page .item-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }

  /* ---- Skills: single-column cards with readable buttons ---- */
  #view .gather-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  #view .gather-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 4px 12px;
    text-align: left;
  }
  #view .gather-card > span:first-child { grid-row: 1 / 3; font-size: 32px; text-align: center; }
  #view .gather-card h3 { margin: 0; font-size: 16px; }
  #view .gather-card p { margin: 0; font-size: 12.5px; }
  #view .gather-card > :not(span:first-child, h3, p) { grid-column: 1 / -1; }
  #view .gather-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #view .gather-grid button { min-height: 40px; font-size: 13px; }
  #view .recipe-grid { grid-template-columns: minmax(0, 1fr); }
  #view .recipe-grid button { min-height: 36px; font-size: 12px; }
  #view .profession-progress { gap: 6px; }

  /* ---- Dock: hint that the tab row scrolls ---- */
  .dock-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  .dock-tabs::-webkit-scrollbar { display: none; }
  .dock-tabs button { flex: 0 0 auto; min-height: 38px; padding: 0 11px; }
  .dock-line time, .dock-chat time { font-size: 11px; }
  .dock-compose input, .dock-compose button { min-height: 40px; font-size: 15px; }

  /* ---- Abilities: bigger reorder arrows ---- */
  #ability-config .ab-slot .priority-controls { flex-direction: row; }
  #ability-config .ab-slot .priority-controls button { min-width: 40px; min-height: 36px; font-size: 15px; }
  #ability-config .ab-switch-track { width: 40px; height: 22px; }
  #ability-config .ab-switch-track::after { width: 16px; height: 16px; }
  #ability-config .ab-switch input:checked + .ab-switch-track::after { transform: translateX(18px); }
  #ability-config .ab-book-item { min-height: 0; }

  /* ---- Bestiary: Grave buttons show the numeral and progress, not a cut-off name ---- */
  .bestiary .bx-grave { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 7px 4px; }
  .bestiary .bx-grave-num { grid-row: auto; }
  .bestiary .bx-grave-name { display: none; }
  .bestiary .bx-grave-progress { width: 100%; }
  .bestiary .bx-grave small { grid-column: auto; }

  /* ---- Build: loadout buttons big enough to tap ---- */
  .bd-loadouts button { min-height: 38px; }
}

/* ---- Combat hotbar on phones: five slots fit; Automation lives in the footer ---- */
@media (max-width: 760px) {
  .hunt-hotbar-row .hunt-hotbar, .hunt-hotbar { --slot: min(58px, calc((100vw - 92px) / 5)); }
  .hot-gear-cell { display: none; }
  .hot-tray { gap: 8px; padding: 9px 10px 6px; }
  .hot-name { max-width: var(--slot); font-size: 11px; }
  .hot-cost { right: -3px; bottom: -5px; min-width: 18px; height: 16px; padding: 0 3px; font-size: 11px; }
  .hot-key { top: -5px; left: -5px; min-width: 16px; height: 16px; font-size: 11px; }
  .hot-energy { height: 16px; }
  .hot-energy span { font-size: 11px; line-height: 15px; }
}

/* ---- Dock tab row never shrinks (it was squashed to a thin strip in a column layout) ---- */
.dock-tabs { flex: 0 0 auto; }
.dock-peek { display: none; }

/* ---- Phones: chat and the log open in a drawer from the right edge (tab under Gear) ---- */
#chat-handle, #chat-backdrop { display: none; }
@media (max-width: 960px) {
  #app #journal {
    position: fixed; z-index: 152; top: 0; bottom: 0; right: 0; left: auto;
    width: min(92vw, 420px); height: auto; min-height: 0; margin: 0; padding: 0;
    display: block !important; overflow: hidden; border: 0; background: none;
    transform: translateX(104%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
    pointer-events: none;
  }
  #app.phone-dock-open #journal { transform: none; pointer-events: auto; }
  #app #journal > .hunt-dock {
    display: flex; flex-direction: column; height: 100%; margin: 0; border-radius: 0;
    border: 0; border-left: 1px solid #5a3a32;
    background: linear-gradient(180deg, #1c1414, #110c0c); box-shadow: -18px 0 40px #000c;
  }
  .dock-drawer-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid #2e2220; }
  .dock-drawer-head h2 { flex: 1; margin: 0; font-family: var(--title); font-size: 20px; color: #f4e6d4; }
  .dock-drawer-close { width: 34px; height: 34px; padding: 0 !important; min-height: 0 !important; border-radius: 50% !important; font-size: 18px; }
  #app #journal .dock-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 0 4px; overflow: visible; mask-image: none; -webkit-mask-image: none; }
  #app #journal .dock-tabs button { min-width: 0; min-height: 38px; justify-content: center; text-align: center; padding: 0 2px; margin: 0; font-size: 13px; }
  .dock-drawer-tools { flex: none; display: flex; justify-content: flex-end; padding: 4px 10px 0; }
  .dock-drawer-tools .dock-mutes { margin: 0; }
  #app #journal .dock-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #app #journal .dock-compose { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

  #chat-backdrop { display: block; position: fixed; inset: 0; z-index: 151; background: #000a; opacity: 0; pointer-events: none; transition: opacity .25s; }
  #app.phone-dock-open ~ #chat-backdrop, body:has(#app.phone-dock-open) #chat-backdrop { opacity: 1; pointer-events: auto; }
  #chat-handle {
    display: flex; position: fixed; z-index: 153; right: 0; top: calc(50% + 62px); transform: translateY(-50%);
    flex-direction: column; align-items: center; gap: 4px; width: 30px; padding: 10px 0 !important; min-height: 0 !important;
    border-radius: 10px 0 0 10px !important; border: 1px solid #7a5a3a !important; border-right: 0 !important;
    background: linear-gradient(90deg, #2a1d17, #170f0d) !important; box-shadow: -4px 0 14px #000a; color: #e8c99a !important;
    transition: right .28s cubic-bezier(.2,.8,.2,1);
  }
  #chat-handle span { font-size: 13px; }
  #chat-handle b { writing-mode: vertical-rl; transform: rotate(180deg); font-family: var(--title); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
  #chat-handle .ch-badge { position: absolute; top: -7px; left: -8px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #c2372a; color: #fff; font: 700 11px/18px system-ui, sans-serif; font-style: normal; text-align: center; box-shadow: 0 0 0 2px #120c0b; }
  body:has(#app.phone-dock-open) #chat-handle { right: min(92vw, 420px); }
  .gd-handle { top: calc(50% - 62px) !important; }
}


/* ---- Hunt Stop / Resume ---- */
.hunt-overview-head .hunt-state-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 3px 4px 3px 10px;
  border: 1px solid #4d3a38;
  border-radius: 20px;
  background: #181313;
  box-shadow: none;
  color: #b0a48c;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
}
.hunt-overview-head .hunt-state-btn i { width: 7px; height: 7px; border-radius: 50%; background: #7d6462; }
.hunt-overview-head .hunt-state-btn.live { color: #b6d49b; border-color: #4f6a3c; }
.hunt-overview-head .hunt-state-btn.live i { background: #8fd06a; box-shadow: 0 0 7px #8fd06a; }
.hunt-stop { padding: 2px 8px; border-radius: 12px; background: #2a2222; color: #d6c9b8; font-size: 11px; }
.hunt-state-btn:hover .hunt-stop { background: #4a1418; color: #e9dfd3; }
.hunt-overview-head .hunt-state-btn.retreat { padding-right: 10px; border-color: #8a3f3f; color: #f0a2a2; }
.hunt-stopped {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px 22px;
  border: 1px solid #5e4442;
  border-radius: 12px;
  background: #0f0c0ccc;
  backdrop-filter: blur(3px);
  box-shadow: 0 8px 24px #000a;
  text-align: center;
}
.hunt-stopped p { margin: 0; color: #dfd1c1; font-family: var(--title); font-size: 16px; letter-spacing: 1px; }
.hunt-stopped .primary { min-height: 40px; padding: 0 22px; font-size: 14px; }
.hunt-stopped-hint { max-width: 240px; color: #a8998c; font-size: 11.5px; line-height: 1.4; }

/* ---- Phones held sideways: the same layout as upright (status strip, game, tab bar along the bottom).
   Older rules turned the tab bar into a side column that collapsed to a single button or vanished. ---- */
@media (max-width: 960px) and (max-height: 500px) {
  #app, #app.journal-collapsed { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: 32px minmax(0, 1fr) 46px !important; }
  #app #status { grid-column: 1 !important; grid-row: 1 !important; }
  #app #view { grid-column: 1 !important; grid-row: 2 !important; }
  #app #nav { grid-column: 1 !important; grid-row: 3 !important; height: 46px !important; display: block !important; overflow: hidden; }
  #app #nav .mobile-navigation { display: grid !important; grid-template-columns: none !important; grid-auto-flow: column !important; grid-auto-columns: minmax(0, 1fr) !important; flex-direction: row !important; width: 100%; height: 46px !important; overflow: hidden !important; }
  #app #nav .mobile-navigation button { flex-direction: row !important; justify-content: center !important; min-height: 0 !important; height: 46px; gap: 6px !important; padding: 0 4px !important; }
  #app #nav .mobile-navigation button > span:last-child { font-size: 11px !important; }
}

/* Game menu button + left drawer (Nov 2026). The logo reads as a button: bigger, framed, with a ☰ Menu cue. */
.brand-menu-cue { display: none; }
@media (max-width: 960px) {
  .brand-menu-cue { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 6px; border: 1px solid #8e2a2f; border-radius: 999px; background: linear-gradient(180deg, #3a1716, #1c0d0d); color: #f2dcc0; font: 600 11px/1 var(--body, system-ui); letter-spacing: .06em; text-transform: uppercase; box-shadow: 0 0 10px #c2372a40; }
  .brand-menu-cue i { font-style: normal; font-size: 14px; color: #e0a46a; }
  .hunt-header .hunt-brand { gap: 8px; }
}
@media (max-width: 760px) {
  #app:not([data-view="combat"]) .status-brand { width: auto !important; height: 40px !important; display: inline-flex !important; align-items: center; gap: 6px; padding: 0 4px 0 0 !important; margin-right: 8px !important; }
  #app:not([data-view="combat"]) .status-brand img { width: 46px !important; }
}

#menu-drawer { position: fixed; inset: 0; z-index: 160; pointer-events: none; }
#menu-drawer.open, #menu-drawer.dragging { pointer-events: auto; }
.md-backdrop { position: fixed; inset: 0; background: #000b; opacity: 0; transition: opacity .25s; }
#menu-drawer.open .md-backdrop { opacity: 1; }
.md { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 360px); display: flex; flex-direction: column; background: radial-gradient(140% 60% at 0% 0%, #3a1512 0%, transparent 60%), linear-gradient(180deg, #1c1414, #0f0a0a); border-right: 1px solid #5a3a32; box-shadow: 18px 0 40px #000c; transform: translateX(-104%); transition: transform .28s cubic-bezier(.2,.8,.2,1); padding-top: env(safe-area-inset-top); }
#menu-drawer.open .md { transform: none; }
#menu-drawer.dragging .md, #menu-drawer.dragging .md-backdrop { transition: none; }
.md-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 14px; border-bottom: 1px solid #2e2220; }
.md-logo { width: 54px; height: auto; filter: drop-shadow(0 0 8px #c2372a66); }
.md-title { flex: 1; min-width: 0; }
.md-title .eyebrow { font-size: 11px; letter-spacing: .2em; }
.md-title h2 { margin: 2px 0 0; font-family: var(--title); font-size: 22px; color: #f4e6d4; }
.md-close { width: 36px; height: 36px; padding: 0 !important; min-height: 0 !important; border-radius: 50% !important; font-size: 18px; }
.md-body { flex: 1; overflow-y: auto; padding: 12px 12px 24px; overscroll-behavior: contain; }
.md-chars { width: 100%; justify-content: center; margin-bottom: 10px; }
#menu-drawer .md-nav nav { grid-template-columns: minmax(0, 1fr) !important; gap: 2px !important; }
#menu-drawer .md-nav .nav-section { padding: 14px 4px 4px !important; font-size: 11px; letter-spacing: .18em; }
#menu-drawer .md-nav .nav-group-items { display: grid !important; gap: 2px; }
#menu-drawer .md-nav button { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 6px 10px !important; border-radius: 10px; text-align: left; }
#menu-drawer .md-nav button img { width: 36px; height: 36px; }
#menu-drawer .md-nav button[aria-current="page"], .md-nav button.active { background: linear-gradient(90deg, #4a1d19, transparent); border-color: #8e2a2f; }
.md-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #2e2220; font-size: 11px; color: #8f7e74; }
body.menu-drawer-open { overflow: hidden; }

/* Phone header (Nov 2026): Menu + Hunt/Goals/Settings on the first row; the Grave gets one slim line under it,
   about the height of an XP row. flex-shrink:0 matters: .hunt-screen is a flex column and would squeeze the header
   back to its min-height, letting the Grave line spill over the XP bars. */
@media (max-width: 760px) {
  .hunt-header { flex-wrap: wrap; flex-shrink: 0; row-gap: 0 !important; padding: 7px 10px 0 !important; }
  .hunt-header .hunt-brand { order: 1; }
  .hunt-header .hunt-header-actions { order: 2; margin-left: auto; }
  .hunt-header .hunt-location { order: 3; flex: 1 0 100%; display: flex; align-items: baseline; gap: 8px; min-width: 0; height: 26px; margin: 6px -10px 0; padding: 0 12px !important; border-left: 0 !important; border-top: 1px solid #3a2a28; background: linear-gradient(90deg, #2a1414, #1a1212 70%); line-height: 26px; overflow: hidden; }
  .hunt-header .hunt-location > span { flex: none; font-size: 11px !important; letter-spacing: .12em !important; white-space: nowrap; }
  .hunt-header .hunt-location h2 { flex: 0 1 auto; min-width: 0; margin: 0; font-size: 14px !important; line-height: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  .hunt-header .hunt-location .hunt-next { flex: 1 1 0; min-width: 0; margin: 0 0 0 auto; font-size: 11px; line-height: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
}
/* Phone spacing (Nov 2026): icons a touch lower and further apart; XP/Mastery centred between the Grave line and the arena. */
@media (max-width: 760px) {
  .hunt-header { padding-top: 11px !important; }
  .hunt-header .hunt-location { margin-top: 9px; }
  .hunt-header .hunt-header-actions { gap: 18px !important; align-items: flex-end !important; }
  .xp-strip { margin: 8px 0 2px !important; }
}
