/* UX fixes layered over style.css (loaded last in templates/header.tpl).
   Desktop changes are small (readability, contrast, focus); the phone layout is under the media query. */

/* Keyboard focus: visible only when navigating with the keyboard. */
a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #f5c542 !important;
    outline-offset: 2px;
}

/* Side menus: 11px grey was hard to read in Persian. */
#menu_content ul li a {
    font-size: 13px !important;
    line-height: 1.6;
}

/* Items the template highlights (missions, unread mail, phone check) used a grey image that made them
   look disabled; show them as bright with a red marker instead. */
#menu_content ul li a[style*="bbgg"] {
    background-image: none !important;
    color: #ffffff !important;
    font-weight: bold;
    box-shadow: inset -3px 0 0 #e53935;
}

/* The page you are on. Set by js/ux.js. */
#menu_content ul li a.is-current, #navbar_mid li a.is-current {
    color: #ffffff !important;
    background: url(../images/menu_li_a.png) repeat;
}

/* Collapsible menu groups (js/ux.js). */
#menu_head.is-toggle {
    cursor: pointer;
    user-select: none;
}
#menu_head.is-toggle .fa {
    transition: transform .15s;
    transform: rotate(-90deg);
}
#menu_head.is-collapsed .fa {
    transform: none;
}
#menu_content.is-collapsed {
    display: none;
}

/* Contrast: dark red text (#9c0706, #840000) on black was about 2:1. */
td.start {
    color: #e53935;
}
a.tab {
    color: #e53935 !important;
}
.input::placeholder {
    color: #e6bcbc;
}

/* Rows with a single radio button can be picked by clicking anywhere on the row (js/ux.js). */
tr.row-pick {
    cursor: pointer;
}
tr.row-pick:hover > td {
    background-color: rgba(255, 255, 255, 0.04);
}

/* Shop: keep the buy button in reach while scrolling the long list. */
.sticky-action {
    position: sticky;
    bottom: 0;
    padding: 10px 0;
    background: rgba(0, 0, 0, 0.85);
    text-align: center;
    z-index: 5;
}

#ranktext {
    text-shadow: 0 0 3px #000, 0 0 3px #000;
}

/* Counts in the menus (new mail, people in jail, cars in the garage). */
.menu-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e53935;
    color: #ffffff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    vertical-align: middle;
}
.menu-badge-muted {
    background: #555555;
}

/* ---------- Phones and small tablets ---------- */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
    }
    #bodybg {
        display: none;
    }
    #container {
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    #container > * {
        order: 3;
    }
    #header, #navbar_end_left, #navbar_mid, #navbar_end_right {
        order: 0;
    }
    #content_container {
        order: 1;
    }
    #column_right {
        order: 2;
    }

    /* Header: a 64px logo strip from header.jpg. */
    #header {
        width: 100%;
        height: auto;
        min-height: 0;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 70px, #111 70px),
                    url(../images/header.jpg) no-repeat #111;
        background-size: 100% 100%, 700px auto;
        background-position: 0 0, calc(50vw - 304px) -18px;
        padding-top: 70px;
        box-sizing: border-box;
        position: relative;
    }
    #countdown {
        display: none;
    }

    /* Logged in: rank and player stats become one compact bar under the logo. */
    #header.header-ingame {
        display: flex;
        flex-direction: column;
    }
    #header.header-ingame #status {
        order: 1;
    }
    #header.header-ingame #rankbar {
        order: 2;
        position: static;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 3px 8px;
        box-sizing: border-box;
        opacity: 1;
        background: #1b1b1b;
        display: flex;
        justify-content: center;
        gap: 12px;
    }
    #header.header-ingame #rankbar2, #header.header-ingame #ranktext {
        display: none;
    }
    #header.header-ingame #ranktext2, #header.header-ingame #rankbar_text {
        position: static;
        font-size: 12px;
        color: #cfcfcf;
        font-weight: normal;
    }
    #header.header-ingame #status {
        position: static;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 6px 8px;
        box-sizing: border-box;
        background: #1b1b1b;
        border-top: 1px solid #5a0a0a;
        border-bottom: 1px solid #5a0a0a;
    }
    #header.header-ingame #in_status > center {
        display: none;
    }
    #header.header-ingame #status table {
        width: 100% !important;
        float: none;
    }
    #header.header-ingame #status table tbody {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px 14px;
        direction: rtl;
    }
    #header.header-ingame #status table tr {
        display: flex;
        align-items: center;
        gap: 4px;
        direction: ltr;
    }
    #header.header-ingame #status table td {
        display: block;
        width: auto !important;
        padding: 0;
    }
    #header.header-ingame #status a {
        color: #eeeeee !important;
        font-size: 12px;
        white-space: nowrap;
    }
    #header.header-ingame #status img[src*="barra"] {
        height: 7px;
    }

    /* Logged out: the login card sits under the logo. */
    #header:not(.header-ingame) #status {
        position: static;
        margin: 0 auto;
    }

    /* Top navigation: one row that scrolls sideways. */
    #navbar_mid {
        width: 100%;
        height: auto;
        display: flex;
        flex-direction: row-reverse;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        background-size: auto 100%;
    }
    #navbar_mid::-webkit-scrollbar {
        display: none;
    }
    #navbar_mid li {
        flex: 0 0 auto;
    }
    #navbar_mid li a {
        float: none;
        font-size: 13px;
        padding: 12px 12px;
        height: auto;
        white-space: nowrap;
    }
    #navbar_mid li.menu-jump {
        position: sticky;
        right: 0;
        background: #3a0505;
        z-index: 2;
    }
    #navbar_mid li.menu-jump a {
        color: #ffffff;
        font-weight: bold;
    }
    #navbar_end_left, #navbar_end_right {
        display: none;
    }

    /* Side menus: a drawer opened from the ☰ button (js/ux.js moves the columns into it). */
    #menu-drawer {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 86%;
        max-width: 340px;
        overflow-y: auto;
        background: #0b0b0b;
        z-index: 1000;
        transform: translateX(105%);
        transition: transform .2s ease;
        box-shadow: -4px 0 16px rgba(0, 0, 0, .7);
        text-align: right;
    }
    #menu-drawer .drawer-top {
        position: sticky;
        top: 0;
        z-index: 3;
        display: flex;
        gap: 8px;
        padding: 10px;
        background: #3a0505;
    }
    #menu-drawer .drawer-search {
        flex: 1;
        min-width: 0;
        padding: 8px 10px;
        border: 1px solid #6b1010;
        border-radius: 6px;
        background: #1b1b1b;
        color: #ffffff;
        font: 15px BYekan, 'BYekan', Tahoma;
        direction: rtl;
    }
    #menu-drawer .drawer-close {
        flex: 0 0 40px;
        border: 0;
        border-radius: 6px;
        background: #1b1b1b;
        color: #ffffff;
        font-size: 18px;
        cursor: pointer;
    }
    #menu-drawer .drawer-quick {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 10px;
        border-bottom: 1px solid #2a2a2a;
    }
    #menu-drawer .drawer-quick[hidden] {
        display: none;
    }
    #menu-drawer .drawer-quick a {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 10px 2px;
        border-radius: 8px;
        background: #1b1b1b;
        color: #e0e0e0;
        font: 12px BYekan, 'BYekan', Tahoma;
        text-align: center;
    }
    #menu-drawer .drawer-quick a .fa {
        font-size: 20px;
        color: #e53935;
    }
    #menu-drawer .drawer-quick a.is-current {
        background: #3a0505;
        color: #ffffff;
    }
    #menu-drawer .drawer-quick .menu-badge {
        position: absolute;
        top: 4px;
        left: 4px;
    }
    #menu-drawer .drawer-empty {
        padding: 16px;
        color: #aaaaaa;
        text-align: center;
        font: 14px BYekan, 'BYekan', Tahoma;
    }
    /* Group titles in the drawer: slim rows instead of the tall red banners. */
    #menu-drawer #menu_head {
        background: #141414 !important;
        border-bottom: 1px solid #2a2a2a;
        border-right: 3px solid #b71c1c;
        padding: 12px 14px;
        font-size: 15px;
        text-align: right !important;
        display: flex;
        justify-content: space-between;
        flex-direction: row-reverse;
    }
    #menu-drawer #menu_content {
        background: #0b0b0b !important;
        padding: 0;
    }
    #menu-drawer #menu_content a.is-current {
        background: #3a0505;
    }
    #menu-drawer #column_dark_content, #menu-drawer #column_dark_content_top {
        background: none;
    }
    .menu-dot {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #ff5252;
        vertical-align: top;
    }
    #menu-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .6);
        z-index: 999;
    }
    html.menu-open #menu-drawer {
        transform: none;
    }
    html.menu-open #menu-backdrop {
        display: block;
    }
    html.menu-open, html.menu-open body {
        overflow: hidden;
    }

    /* Menu columns: full width (inside the drawer, or below the page if the script did not run). */
    #column_container, #column_right, #content_container {
        float: none !important;
        width: 100% !important;
    }
    #column_container > *, #column_right > * {
        width: 100%;
    }
    #menu_head, #menu_content, #column_dark_content_bottom {
        width: 100% !important;
        background-size: 100% 100%;
        box-sizing: border-box;
    }
    #column_dark_content_bottom {
        display: none;
    }
    #menu_head {
        height: auto;
        padding: 10px 0;
        font-size: 16px;
    }
    #menu_content ul li a {
        font-size: 15px !important;
        padding: 10px 14px !important;
    }

    #content {
        width: auto;
        float: none;
        padding: 16px 12px;
        background-size: 100% auto;
        overflow-x: auto;
        box-sizing: border-box;
    }
    #content img {
        max-width: 100%;
        height: auto;
    }
    #content table {
        max-width: 100%;
    }
    h1.titel {
        margin-left: 0;
        background-size: 100% 100%;
    }
    div.dark, div.warningbar {
        width: auto;
        max-width: 100%;
        margin-left: 0;
        box-sizing: border-box;
        background-size: 100% 100%;
        height: auto;
        padding-bottom: 12px;
    }
    input.input, input.login_input, select.input, textarea {
        max-width: 100%;
        font-size: 16px;
    }
    div.footer {
        margin-bottom: 20px;
    }
}
