/*
 * Phone and tablet layout (owner, 2026-11-05), both layouts (Classic + LokoOwneD Rework). Loaded on every page, after the
 * page's own styles (core/hook/index-start_out_var_output.php; only the menu's navsub, navsearch and cursor come later). Nothing here runs on a computer: every rule is inside a max-width block.
 *   991.98px = where the top bar becomes the single menu button (same as navbar-expand-lg in themes/rfocp/body.html)
 *   767.98px = phone sizes (bigger touch targets, tighter page margins)
 *   575.98px = narrow phones (wide tables of player pages become cards, mobile.js decides which)
 */

/* ------------------------------------------------------------------ the single menu */
@media (max-width: 991.98px) {
  body nav.navbar { padding: 6px 10px; min-height: 56px; }
  nav.navbar > .container-fluid { flex-wrap: nowrap; justify-content: flex-start; gap: 10px; padding: 0; }
  nav.navbar .navbar-toggler { flex: none; width: 44px; height: 44px; padding: 0; margin: 0; display: grid; place-items: center; border-radius: 10px; border-color: rgb(255 255 255 / 16%); cursor: pointer; transition: background-color .15s, border-color .15s; }
  nav.navbar .navbar-toggler[aria-expanded='true'] { background: rgb(240 180 76 / 16%); border-color: #f0b44c; }
  nav.navbar .navbar-brand { flex: 1 1 auto; min-width: 0; margin: 0; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #btn-nav-previous, #btn-nav-next { display: none !important; }
  /* the old box clips and scrolls sideways: here it only holds the panel, which is placed against the navbar */
  nav.navbar .menu-inner-box { position: static; flex: none; width: 0; margin: 0; overflow: visible; white-space: normal; }

  /* the panel that drops from the left */
  #navbarResponsive { position: absolute; top: calc(100% + 6px); left: 8px; width: min(380px, calc(100vw - 16px)); max-height: calc(100vh - 76px); max-height: calc(100dvh - 76px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 8px; background: #111418; border: 1px solid rgb(255 255 255 / 10%); border-radius: 12px; box-shadow: 0 14px 40px rgb(0 0 0 / 60%); }
  #navbarResponsive.show, #navbarResponsive.collapsing { display: flex; flex-direction: column; }
  #navbarResponsive > .navbar-nav { width: 100%; flex-direction: column; float: none; margin: 0 !important; }
  /* search first, then the Roleta shortcut, the menus and, last, the logout */
  #navbarResponsive > ul.ml-auto { display: contents; }
  #navbarResponsive > ul.ml-auto > li { order: 1; width: 100%; }
  #navbarResponsive > ul.ml-auto > li.rw-search { order: -2; margin: 0 0 8px; }
  #navbarResponsive > ul > li.rol-nav-item { order: -1; }

  /* a group: a full-width row, opens below itself (Bootstrap keeps only one open) */
  #navbarResponsive .nav-link { display: flex !important; align-items: center; min-height: 48px; padding: 8px 10px !important; border-radius: 8px; color: #e9ecef !important; font-weight: 600; cursor: pointer; transition: background-color .15s; }
  #navbarResponsive .nav-link:active, #navbarResponsive .show > .nav-link { background: rgb(255 255 255 / 7%); }
  #navbarResponsive .dropdown-toggle::after { margin-left: auto; transition: transform .15s; }
  #navbarResponsive .show > .dropdown-toggle::after { transform: rotate(180deg); }
  #navbarResponsive .dropdown-menu { position: static !important; top: auto !important; left: auto !important; right: auto !important; transform: none !important; float: none; width: 100%; min-width: 0; margin: 0; padding: 2px 0 6px 8px; background: transparent !important; border: 0 !important; box-shadow: none; }
  #navbarResponsive .dropdown-item, .gcp-m-bar .dropdown-item { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: #cfd6dc; white-space: normal; }
  #navbarResponsive .dropdown-item.active, .gcp-m-bar .dropdown-item.active { background: rgb(240 180 76 / 16%); color: #fff; }
  #navbarResponsive .dropdown-item:hover, #navbarResponsive .dropdown-item:focus { background: rgb(255 255 255 / 7%); color: #fff; }
  #navbarResponsive .dropdown-header { padding: 8px 12px 2px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #9aa3ad; }
  #navbarResponsive .dropdown-divider { margin: 6px 12px; border-color: rgb(255 255 255 / 8%); }

  /* logout: a full row with its word (the Rework's is only an icon) */
  body nav.navbar #navbarResponsive #logout { width: 100%; min-height: 44px; padding: 8px 12px; margin: 8px 0 2px; }
  #navbarResponsive .rw-logout::after { content: 'Logout'; margin-left: 8px; }

  /* the account icon lives in the bar here (mobile.js moves it, and back on a wider screen) */
  .gcp-m-bar { flex: none; flex-direction: row; margin: 0; }
  .gcp-m-bar .nav-link { display: grid !important; place-items: center; width: 44px; height: 44px; padding: 0 !important; font-size: 22px; color: #e9ecef !important; cursor: pointer; }
  .gcp-m-bar .dropdown-toggle::after { display: none; }
  body nav.navbar .gcp-m-bar .dropdown-menu { position: absolute !important; top: calc(100% + 6px) !important; left: auto !important; right: 8px !important; transform: none !important; width: min(300px, calc(100vw - 16px)); max-height: calc(100vh - 76px); overflow-y: auto; padding: 6px; background: #111418 !important; border: 1px solid rgb(255 255 255 / 10%) !important; border-radius: 12px; box-shadow: 0 14px 40px rgb(0 0 0 / 60%); }

  /* dims the page behind the open menu; a tap on it closes the menu (mobile.js) */
  body.gcp-m-open::before { content: ''; position: fixed; inset: 0; z-index: 1065; background: rgb(0 0 0 / 55%); }
  body.gcp-m-open nav.navbar { z-index: 1070 !important; }
  /* body: navsearch.css is added when the menu is built, after this file */
  body .rw-search-list { z-index: 1071; }
}

/* ------------------------------------------------------------------ pages: nothing wider than the screen */
/* One element wider than the screen is what makes a phone zoom out and draw the page like a computer's. */
@media (max-width: 991.98px) {
  html, body { overflow-x: clip; }
  main img, main video, main iframe, main embed, main object, main input, main select, main textarea { max-width: 100%; }
  main input[type=file] { min-width: 0; width: 100%; }
  main pre { max-width: 100%; overflow-x: auto; }
  main { overflow-wrap: break-word; }

  /* tables keep their width and roll inside their own box (mobile.js wraps them) */
  .gcp-tscroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1rem; }
  .gcp-tscroll > table { margin-bottom: 0; }

  /* tabs: one strip that rolls sideways instead of a staircase of rows */
  main .nav-tabs:not(.flex-column), main .nav-pills:not(.flex-column) { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  main .nav-tabs:not(.flex-column)::-webkit-scrollbar, main .nav-pills:not(.flex-column)::-webkit-scrollbar { display: none; }
  main .nav-tabs:not(.flex-column) > *, main .nav-pills:not(.flex-column) > * { flex: 0 0 auto; }
  main .nav-tabs:not(.flex-column) .nav-link, main .nav-pills:not(.flex-column) .nav-link { white-space: nowrap; }

  /* 3D: smaller on the screen, so the information arrives sooner (the 3D itself gets lighter in js/rw3d.js) */
  /* Servidor 3D / Guild page: a flex row on wide screens squeezed the map to a sliver next to the guild list */
  .rw-guild { display: block; }
  .rw-guild .rw-cena { width: 100%; }
  #rw-home:not(.rw-lobby) .rw-cena, .rw-equipsearch .rw-cena, .rw-guild .rw-cena { height: 44vh; }
  .rw-equipsearch .es-all, .rwg-all { top: calc(44vh - 60px); }
}

@media (max-width: 767.98px) {
  /* 8 + 8 = the 16px a Bootstrap .row needs for its negative margins (-15px), or it pokes out of the screen */
  main.container-fluid { padding-left: 8px; padding-right: 8px; }
  #panel-container { padding: 8px 8px 88px !important; }
  main .pagination { flex-wrap: wrap; }
  main .col-12.mx-3 { margin-left: 0 !important; margin-right: 0 !important; }
  /* 16px stops the iPhone zooming in on a field; 44px is a comfortable finger */
  main .form-control, main select, main textarea, main input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]) { font-size: 16px; }
  main .form-control, main select, main input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]) { min-height: 44px; }
  main .btn { min-height: 44px; }
  main .btn-sm, main .btn-xs { min-height: 38px; }
  main .page-link { min-width: 40px; min-height: 40px; text-align: center; }
  main .dataTables_wrapper .dataTables_filter input { width: 100%; margin-left: 0; }
  main .dataTables_wrapper .dataTables_filter label { display: block; width: 100%; }
  main .dataTables_wrapper .dataTables_paginate { overflow-x: auto; }
  .modal-dialog { margin: 8px; }
  .tk-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; }
  .footer { padding-bottom: 76px !important; }
}

/* ------------------------------------------------------------------ wide tables of player pages become cards */
@media (max-width: 575.98px) {
  table.gcp-tcards, table.gcp-tcards > tbody, table.gcp-tcards > tbody > tr, table.gcp-tcards > tbody > tr > td, table.gcp-tcards > tbody > tr > th { display: block; width: 100% !important; }
  table.gcp-tcards > thead { display: none; }
  table.gcp-tcards, table.gcp-tcards > tbody > tr > td, table.gcp-tcards > tbody > tr > th { border: 0 !important; }
  table.gcp-tcards { background: transparent !important; }
  table.gcp-tcards > tbody > tr { margin-bottom: 10px; padding: 6px 0; border: 1px solid rgb(255 255 255 / 12%) !important; border-radius: 10px; background: rgb(255 255 255 / 3%) !important; }
  table.gcp-tcards > tbody > tr > td, table.gcp-tcards > tbody > tr > th { position: relative; min-height: 32px; padding: 6px 12px 6px 44% !important; text-align: left !important; white-space: normal !important; overflow-wrap: anywhere; background: transparent !important; }
  table.gcp-tcards > tbody > tr > td * { white-space: normal !important; }
  table.gcp-tcards > tbody > tr > [data-label]::before { content: attr(data-label); position: absolute; left: 12px; top: 6px; width: calc(44% - 20px); color: #9aa3ad; font-size: 13px; font-weight: 600; }
  table.gcp-tcards > tbody > tr > td.gcp-td-full, table.gcp-tcards > tbody > tr > td:not([data-label]) { padding-left: 12px !important; }
}

@media (prefers-reduced-motion: reduce) {
  nav.navbar .navbar-toggler, #navbarResponsive .nav-link, #navbarResponsive .dropdown-toggle::after { transition: none; }
  #navbarResponsive.collapsing { transition: none; }
}
