/*
Description: Responsive layout for mobile devices
Created by: Allen, Erfa
For: Mugglarportalen
*/

/* PC */

/* Hide the mobile leftmenu */
#hamburgerMenu,
#mobileLeftMenu,
.side-nav,
.hamburger-icon {
    display: none;
}

/* MOBILE */

@media only screen and (max-width: 768px) {

    /* Hide the PC leftmenu */
    #leftMenu {
        display: none;
    }

    #hamburgerMenu {
        display: block;
        position: fixed;
        top: 13px;
        left: 17px;
        background-color: rgba(0, 0, 0, 0.5);
        padding: 5px 0px;
        border-radius: 5px;
        z-index: 1000;
    }

    #hamburgerMenu:hover {
        background-color: rgba(0, 0, 0, 0.7);
        border-color: #333;
    }

    /* The copied leftmenu for mobile containing all icons */
    #mobileLeftMenu {
        display: block;
        padding: 0px 0px;
    }

    /* Overlay-effect for sidenavigation leftmenu */
    #overlay {
        position: fixed;
        display: none;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        background-color: rgba(0,0,0,0.5);
        z-index: 1500;
    }

    /* Fill whole screen with margin for borders */
    #main {
        width: calc(100% - 14px);
        margin-left: 7px;
        margin-right: 7px;
        min-height: auto;
    }

    #leftBorder,
    #rightBorder {
        position: absolute;
        top: -1px;
        bottom: -1px;
        width: 7px;
        height: calc (100% + 2px);
    }

    #leftBorder {
        left: -8px;
    }

    #rightBorder {
        right: -8px;
    }

    #topBorder {
        display: block;
        position: relative;
        left: 0px;
    }

    #logo {
        display: block;
        width: 100%;
        height: 100%;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: 0px;
    }

    #topMenu {
        display: block;
        position: absolute;
        left: 0px;
        right: 0px;
        top: 100px;
        height: 26px;
    }

    #contentContainer {
        position: static;
        margin: 0;
        padding: 5px;
        width: 100%;
        margin-top: 25px; /* Give space to topmenu */
    }

    #content {
        width: 100%;
    }

    #usersOnline {
        font-size: small;
    }

    #numUsersOnline {
        font-size: small;
    }

    /* Allow horisontal scrolling */
    #board {
        overflow-y: hidden;
        overflow-x: auto;
    }

    /* Shrink the design color rectangles */
    #designer td {
        width: 30px;
        font-size: 0.5em;
        text-align: center;
    }

    /* Make the ratings score table take up less space*/
    [id^="ratings"] table tr td:nth-child(2) {
        width: 60px;
        text-align: center;
    }

    /* Fit the canvas better */
    #snapeGame {
        width: 100%;
        height: auto;
    }

    #animalshopInfo {
        max-width: 100%;
    }

    #speechBalloonText p {
        color: #000000 !important;
    }

    #content img[alt="Knut"] {
        width: 35%;
        margin-right: 5%;
    }

    #speechBalloon {
        display: inline-block;
        width: 60%;
    }

    /* Prevent textfields in Settings to overflow */
    input[type="file"],
    input[type="text"],
    input[type="password"],
    textarea[name="forum_signature"],
    #text {
        max-width: 100%;
        overflow-x: auto;
        white-space: break-word;
    }

    .hamburger-icon {
        display: inline;
        cursor: pointer;
        font-size: 30px;
        padding: 13px;
        color: #ffffff;
    }

    .topMenuIcon {
        height: 25px;
    }

    /* Side navigation including leftmenu */
    .side-nav {
        display: block;
        height: 100%;
        width: 0; /* Close it */
        position: fixed;
        top: 0;
        left: 0;
        background-color: #312b27;
        overflow-x: hidden;
        transition: 0.3s;
        z-index: 2000;
        border: none transparent; /* Hide the borders when it's closed */
    }

    /* Leftmenu icons */
    .side-nav a {
        padding: 0px 12px;
        text-decoration: none;
        font-size: 18px;
        display: block;
        transition: 0.2s;
    }

    .side-nav.open {
        left: 0; /* Bring it forth */
        background-color: #312b27;
        border: 1px solid rgba(0, 0, 0, 0.4); /* Show borders when it's opened */
    }

    .menuItem a {
        display: inline-block;
        height: 60px; /* Only Index menuItems are 64px for some reason, so we force height here */
    }

    .mobile-only {
        display: initial;
    }

    .pc-only {
        display: none;
    }

    li.menuItem {
        display: block;
        background-color: inherit;
    }

    li.menuItem:hover {
        background-color: transparent;
    }

    .forum_header {
        font-size: 12px;
    }

    .forum_row {
        font-size: 12px;
    }

    .forum_row img,
    .forum_row iframe {
        max-width: 100% !important;
        height: auto !important;
    }

    .forum_post_user_header {
        width: 80px;
    }

    .forum_avatar {
        width: 46px;
    }

    .forum_post_santa_hat {
        top: 8px;
        right: -4px;
        width: 31px;
        height: 25px;
    }

    .boardPaperContainer {
        transform: scale(0.9);
    }

    /* Allow scrolling when the text overflows */
    .boardPaper {
        overflow: auto;
    }

    .profile-santa-hat {
        top: 125px;
    }

    .card_small {
        zoom: 0.45; /* Pedestrian hack to forcefully make cards fit in Market */
    }

    /* Apply box-sizing on all elements and their pseudo-elements */
    *, *::before, *::after {
        box-sizing: border-box;
    }

    html {
        scroll-behavior: smooth;
    }

    body {
        touch-action: auto;
    }

    /* Adjust title fonts */
    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 16px;
    }

    h3 {
        font-size: 14px;
    }

    /* Adjust so that body and html content starts from top-left corner */
    body,
    html {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }

    table {
        width: 100%;
        table-layout: fixed; /* Prevent column growing with content */
        overflow-wrap: break-word; /* Break when words do not fit the cell */
    }

    table img {
        max-width: 100%;
    }

    td, th, p {
        white-space: normal; /* Allow text breaking over multiple rows in the cell */
        overflow: hidden;
        overflow-wrap: break-word; /* Prevent words from overflowing */

    }

    td, th {
        font-size: 12px;
    }
    
    td {
        word-break: break-word;
    }

    div[id^="ratings"] {
        position: absolute;
        right: 5px;
        max-width: 50%;
    }

    iframe {
        max-width: 100%;
        height: auto;
    }
}
