/* ==========================================================================
   Responsive site shell (loaded last — overrides the old 3/6/3 Bootstrap grid)

   >= 1200px : left menu | content | right menu   (fixed-width sidebars, fluid content)
   992-1199  : left menu | content, right menu goes under the content
   < 992     : content only, right menu below it, left menu opens as a drawer (☰)
   ========================================================================== */

:root {
    --po-shell-max: 1640px;
    --po-shell-pad: 26px;
    --po-side-w: 250px;
    --po-gap: 20px;
}

@media (min-width: 1400px) {
    :root { --po-side-w: 270px; --po-gap: 24px; }
}

/* Shared page width for header + body (replaces Bootstrap .container) */
.po-shell {
    width: 100%;
    max-width: var(--po-shell-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--po-shell-pad);
    padding-right: var(--po-shell-pad);
}

.po-layout__grid {
    display: grid;
    grid-template-columns: var(--po-side-w) minmax(0, 1fr) var(--po-side-w);
    grid-template-areas: "left main right";
    gap: var(--po-gap);
    align-items: start;
}

.po-layout__sidebar--left  { grid-area: left; min-width: 0; }
.po-layout__main           { grid-area: main; min-width: 0; }
.po-layout__sidebar--right { grid-area: right; min-width: 0; }

/* Content never forces the page wider than the screen */
.po-layout__main > * { max-width: 100%; }
.po-layout__main img { max-width: 100%; height: auto; }
.po-layout__main .table-responsive,
.po-layout__main .po-eq-table-wrap,
.po-layout__main .po-monster-list-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Sidebar menus: keep text on one line, no squeezing */
.po-sidebar .sidebar-menu-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Item / monster icons inside tables: never shrink to 0 when the table is tight */
.po-eq-col-icon,
.po-item-list-col-icon,
.po-item-list__icon,
.po-monster-list-col-outfit,
.po-monster-list__outfit {
    width: 48px;
    min-width: 48px;
}

.po-eq-col-icon img,
.po-item-list__icon img,
.po-monster-list__outfit img {
    max-width: none;
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: pixelated;
}

.po-monster-list__outfit img { width: 40px; height: 40px; }

/* Item tabs on /items: flexible grid instead of fixed 4 per row */
.po-eq-tabs {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
    padding: 0;
}
.po-eq-tabs .nav-item,
.po-eq-tabs .nav-item.toptd {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 6px;
}
.po-eq-tabs .nav-item a { width: 100%; min-width: 0; height: 100%; }
.po-eq-tabs .nav-item h3 {
    white-space: normal;
    overflow: visible;
    line-height: 1.25;
    margin-bottom: 0;
}

/* ---------- Header menu button (hidden on desktop) ---------- */
.po-header__menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid #3a3820;
    border-radius: 8px;
    background: #13120a;
    color: #FF9F00;
    font-size: 20px;
    cursor: pointer;
    flex: 0 0 auto;
}
.po-header__menu-btn:hover,
.po-header__menu-btn:focus-visible { color: #fff; border-color: #FF9F00; outline: none; }

.po-nav-backdrop { display: none; }

/* ---------- 992 - 1199 : two columns ---------- */
@media (max-width: 1199.98px) {
    :root { --po-side-w: 230px; --po-gap: 18px; }

    /* same links are in the left menu; avoids a cramped header */
    .po-header__nav { display: none !important; }

    .po-layout__grid {
        grid-template-columns: var(--po-side-w) minmax(0, 1fr);
        grid-template-areas:
            "left main"
            "left right";
    }

    /* right menu under the content: lay its sections side by side */
    .po-layout__sidebar--right .po-sidebar--right {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
    .po-layout__sidebar--right .po-sidebar__section + .po-sidebar__section { border-top: none; }
}

/* ---------- < 992 : one column + drawer ---------- */
@media (max-width: 991.98px) {
    :root { --po-shell-pad: 22px; --po-gap: 16px; }

    .po-layout { padding-top: 14px; }

    .po-layout__grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "main"
            "right";
    }

    .po-header__menu-btn { display: inline-flex; order: -1; }
    .po-header__brand { margin-right: auto; }

    .po-layout__sidebar--left {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1060;
        width: min(300px, 86vw);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #0b0a05;
        box-shadow: 6px 0 24px rgba(0, 0, 0, .6);
        transform: translateX(-105%);
        transition: transform .25s ease;
        margin: 0 !important;
    }
    .po-layout__sidebar--left .po-sidebar { border-radius: 0; min-height: 100%; }

    body.po-nav-open .po-layout__sidebar--left { transform: translateX(0); }
    body.po-nav-open { overflow: hidden; }

    .po-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1055;
        background: rgba(0, 0, 0, .55);
    }
    .po-nav-backdrop[hidden] { display: none; }

    .po-layout__sidebar { margin-bottom: 0 !important; }
}

/* ---------- small phones ---------- */
@media (max-width: 575.98px) {
    .po-header__inner { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
    .po-header__brand { margin-right: auto; }
    .po-header__brand img { max-height: 34px; }
    .po-header__actions {
        width: 100%;
        gap: 8px;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .po-header__cta { justify-content: center; padding: 8px 10px; font-size: 13px; }
    .po-header__social { display: none; }

    .po-layout__sidebar--right .po-sidebar--right { grid-template-columns: minmax(0, 1fr); }

    .po-eq-tabs { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .po-layout__sidebar--left { transition: none; }
}

/* Outfit images (/outfit.php): keep pixel art sharp and proportional.
   Player outfits are 32x32 sprites, so each spot gets an explicit size. */
img[src*="outfit.php"] {
    image-rendering: pixelated;
    object-fit: contain;
}
.imgtop img[src*="outfit.php"] { width: 46px; height: 46px; }            /* home top players */
.po-highscores-outfit { width: 50px; height: 56px; padding: 2px; align-items: center; }
.po-highscores-outfit img[src*="outfit.php"] { width: 42px; height: 42px; }  /* highscores */
.po-account-panel img[src*="outfit.php"] { width: 48px; height: 48px; }   /* account characters */

/* ---------- small-screen table helpers ---------- */
.po-char-link { color: inherit; font-weight: 600; text-decoration: none; }
.po-char-link:hover { color: #FF9F00; }

@media (max-width: 575.98px) {
    .po-hide-sm { display: none !important; }

    /* highscores: drop the status column and tighten cells so the table fits a phone */
    .po-highscores-table__status { display: none !important; }
    .po-highscores-table th,
    .po-highscores-table td { padding-left: 6px !important; padding-right: 6px !important; }
    .po-highscores-outfit { width: 42px; height: 46px; }
    .po-highscores-outfit img[src*="outfit.php"] { width: 36px; height: 36px; }
}
