/* =====================================================================
   Anarchy Live - phone layout
   The desktop board is the 2006 IPB skin and stays exactly as it is:
   every rule below lives inside the breakpoint.
   ===================================================================== */

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

  /* ---------------------------------------------------------------
     Shell: unlock the 990px desktop width
     --------------------------------------------------------------- */
  html, body { overflow-x: hidden; }
  body { text-align: left; }
  #container { min-width: 0; font-size: 15px; }
  .wrapper {
    width: auto; min-width: 0; max-width: none;
    padding: 0 10px; box-sizing: border-box;
  }
  #content { padding: 8px 0 14px; overflow: visible; }
  #content .wrapper { padding: 0 8px; }
  table { font-size: 14px; }
  .smalltext { font-size: 12px; }
  img { max-width: 100%; }

  /* tables that hold the forum and thread lists must stop being tables,
     otherwise a grid row inside them shrink-wraps to its content */
  table.tborder:has(tbody[id^="cat_"]),
  table.tborder:has(tr.inline_row),
  table.tborder:has(tr.post_table),
  table.post_table { display: block; width: 100%; box-sizing: border-box; }
  table.tborder:has(tbody[id^="cat_"]) > tbody,
  table.tborder:has(tr.inline_row) > tbody { display: block; }

  /* ---------------------------------------------------------------
     Header: banner, then a wrapping nav
     --------------------------------------------------------------- */
  #logostrip { line-height: 0; }
  #logostrip img { width: 100%; height: auto; }

  #submenu { padding: 0 8px 4px; }
  #submenu p {
    float: none !important;
    text-align: left;
    font-size: 12px;
    padding: 0 !important;
  }
  #submenu p.home { margin: 0 0 2px !important; }
  #submenu p.home a { font-size: 15px; padding: 8px 0; display: inline-block; }
  #submenu p a {
    display: inline-block;
    padding: 10px 9px;
    font-size: 12px;
    letter-spacing: 0.5px;
  }

  /* ---------------------------------------------------------------
     Welcome / search bar
     --------------------------------------------------------------- */
  #panel { margin: 4px 0; padding: 6px 8px; }
  #panel .upper { padding: 0; }
  #panel .upper .wrapper {
    width: auto; max-width: none;
    padding: 0;
    display: flex; flex-direction: column; gap: 6px;
  }
  #search { float: none; display: flex; gap: 6px; width: 100%; }
  #search input { margin: 0 !important; }
  #search input.textbox { flex: 1 1 auto; width: auto; font-size: 16px; padding: 6px; }
  #search input.button { flex: 0 0 auto; padding: 6px 14px; font-size: 14px; }
  #panel .welcome { display: block; font-size: 13px; line-height: 1.8; }
  #panel .welcome a.login,
  #panel .welcome a.register { display: inline-block; padding: 6px 0; font-size: 14px; }

  /* ---------------------------------------------------------------
     Forum index: each category becomes a card, each forum a row
     --------------------------------------------------------------- */
  table.tborder > thead > tr > td.thead { padding: 8px; font-size: 13px; }

  tbody[id^="cat_"] > tr { display: grid; }
  /* the Forum / Threads / Posts / Last Post header row has no meaning stacked */
  tbody[id^="cat_"] > tr:first-child { display: block; }
  tbody[id^="cat_"] > tr:first-child > td { display: none; }

  tbody[id^="cat_"] > tr:not(:first-child) {
    grid-template-columns: 20px max-content max-content 1fr;
    align-items: start;
    padding: 7px 0 8px;
    border-bottom: 1px solid #C9D6E5;
  }
  tbody[id^="cat_"] > tr > td { width: auto !important; border: 0; padding: 0; }

  tbody[id^="cat_"] > tr > td:nth-child(1) { grid-area: 1 / 1; padding-top: 4px; }
  tbody[id^="cat_"] > tr > td:nth-child(2) { grid-area: 1 / 2 / 2 / 5; padding-right: 4px; }
  tbody[id^="cat_"] > tr > td:nth-child(3) {
    grid-area: 2 / 2; justify-self: start;
    font-size: 12px; color: #4A5A70; padding-top: 3px;
  }
  tbody[id^="cat_"] > tr > td:nth-child(3)::after { content: " threads"; }
  tbody[id^="cat_"] > tr > td:nth-child(4) {
    grid-area: 2 / 3; justify-self: start;
    font-size: 12px; color: #4A5A70; padding: 3px 0 0 10px;
  }
  tbody[id^="cat_"] > tr > td:nth-child(4)::after { content: " posts"; }
  tbody[id^="cat_"] > tr > td:nth-child(5) {
    grid-area: 3 / 1 / 4 / 5;
    text-align: left !important;
    font-size: 12px;
    color: #4A5A70;
    padding: 4px 0 0 20px;
    line-height: 1.5;
  }
  /* last post reads as two lines, not three */
  tbody[id^="cat_"] > tr > td:nth-child(5) br ~ br { display: none; }
  tbody[id^="cat_"] > tr > td:nth-child(5) .smalltext > span[title] { margin-right: 5px; }
  tbody[id^="cat_"] > tr > td:nth-child(5) .smalltext { text-align: left; font-size: 12px; }

  tbody[id^="cat_"] > tr > td:nth-child(2) strong a { font-size: 15px; }
  tbody[id^="cat_"] > tr > td:nth-child(2) .smalltext {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.45;
  }

  /* ---------------------------------------------------------------
     Thread list
     --------------------------------------------------------------- */
  tr.inline_row {
    display: grid;
    width: 100%;
    grid-template-columns: 16px 18px 1fr auto;
    align-items: baseline;
    padding: 6px 0 7px;
    border-bottom: 1px solid #C9D6E5;
  }
  tr.inline_row > td { width: auto !important; border: 0; padding: 0; }
  tr.inline_row > td:nth-child(1) { grid-area: 1 / 1; }
  tr.inline_row > td:nth-child(2) { grid-area: 1 / 2; }
  tr.inline_row > td:nth-child(3) { grid-area: 1 / 3 / 2 / 5; padding: 0 4px 0 4px; }
  tr.inline_row > td:nth-child(4) {
    grid-area: 2 / 3; justify-self: start;
    font-size: 12px; color: #4A5A70; padding-top: 3px;
  }
  tr.inline_row > td:nth-child(4)::after { content: " replies"; }
  tr.inline_row > td:nth-child(5) {
    grid-area: 2 / 4; justify-self: end;
    font-size: 12px; color: #4A5A70; padding-top: 3px;
  }
  tr.inline_row > td:nth-child(5)::after { content: " views"; }
  tr.inline_row > td:nth-child(6) {
    grid-area: 3 / 1 / 4 / 5;
    text-align: left !important;
    font-size: 11.5px; color: #4A5A70;
    padding-top: 3px; line-height: 1.45;
  }
  /* one line: "1 hour ago  Last Post: Nari" */
  tr.inline_row > td:nth-child(6) br { display: none; }
  tr.inline_row > td:nth-child(6) a::before { content: " "; }
  tr.inline_row .smalltext { font-size: 11.5px; line-height: 1.45; }
  tr.inline_row td:nth-child(3) a { font-size: 14px; }

  /* ---------------------------------------------------------------
     Posts: author above the message, not beside it
     --------------------------------------------------------------- */
  table.post_table { display: block; border-collapse: collapse; }
  table.post_table > tbody,
  table.post_table > tbody > tr { display: flex; flex-wrap: wrap; align-items: center; }
  table.post_table td { width: auto !important; border: 0; }

  /* name / date / post number bar */
  table.post_table > tbody > tr:nth-child(1) {
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
  }
  table.post_table > tbody > tr:nth-child(1) td { padding: 0; }
  table.post_table > tbody > tr:nth-child(1) td:nth-child(1) { flex: 0 1 auto; min-width: 0; }
  table.post_table > tbody > tr:nth-child(1) td:nth-child(2) { flex: 0 0 auto; }
  table.post_table > tbody > tr:nth-child(1) .normalname a { font-size: 15px; }
  table.post_table > tbody > tr:nth-child(1) .postdetails { font-size: 12px; }

  /* author strip */
  table.post_table > tbody > tr:nth-child(2) { flex-direction: column; align-items: stretch; }
  table.post_table td.post_author {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px;
  }
  table.post_table td.post_author .author_avatar { margin: 0; flex: 0 0 auto; }
  table.post_table td.post_author .author_avatar img {
    width: 44px; height: 44px; border: 1px solid #B9C8DC;
  }
  table.post_table td.post_author .postdetails {
    font-size: 11.5px; line-height: 1.5; display: block; min-width: 0;
  }
  /* the stat block reads as one flowing line instead of six stacked ones */
  table.post_table td.post_author .postdetails br { display: none; }
  table.post_table td.post_author .postdetails img { vertical-align: middle; }

  /* the message */
  table.post_table td.post1 { flex: 1 0 100%; padding: 0 10px 10px; }
  table.post_table .postcolor.post_body {
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  table.post_table .post_body img { height: auto !important; }
  table.post_table .post_body pre,
  table.post_table .post_body code { white-space: pre-wrap; word-wrap: break-word; }

  /* buttons */
  table.post_table > tbody > tr:nth-child(3) { justify-content: space-between; padding: 0 8px 8px; }
  table.post_table td.post_controls { float: none !important; padding: 0; }
  table.post_table .postbit_buttons { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  table.post_table .postbit_buttons a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 32px; min-width: 32px; padding: 0 5px;
  }
  table.post_table .postbit_buttons a span { font-size: 12px; }
  table.post_table td.catend { display: none; }

  /* ---------------------------------------------------------------
     Portal: three columns become one
     --------------------------------------------------------------- */
  table.portal_table { display: block; }
  table.portal_table > tbody { display: flex; flex-direction: column; }
  table.portal_table td { display: block; width: auto !important; }
  table.portal_table td.portal_gap { display: none; }
  table.portal_table td.portal_main { order: 1; }
  table.portal_table td.portal_col:nth-of-type(1) { order: 2; }
  table.portal_table td.portal_col:last-child { order: 3; }
  .maintitle, .maintitlecollapse { padding: 8px; font-size: 13px; }

  /* ---------------------------------------------------------------
     Member list: alphabet bar wraps, each member becomes a row
     --------------------------------------------------------------- */
  #content table.tborder > tbody > tr > td.thead .float_right {
    float: none; display: flex; flex-wrap: wrap; padding-top: 4px;
  }
  #content table.tborder > tbody > tr > td.thead .float_right a { padding: 7px 7px; }
  #content table.tborder > tbody > tr > td.thead { overflow: hidden; }

  /* the member rows are the only 7-cell rows on the board (rating is off) */
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    padding: 7px 0;
    border-bottom: 1px solid #C9D6E5;
  }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td {
    border: 0; padding: 0; width: auto !important;
  }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(1) { flex: 0 0 40px; }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(1) img {
    width: 40px; height: 40px; object-fit: cover;
  }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(2) {
    flex: 1 1 0; min-width: 0;
  }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(3),
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(4),
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(5),
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(6),
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(7) {
    flex: 0 0 auto;
    margin-right: 12px;
    font-size: 11.5px;
    color: #4A5A70;
    line-height: 1.5;
  }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(3)::before { content: "Joined "; }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(4)::before { content: "Last visit "; }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(5)::before { content: "Posts: "; }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(6)::before { content: "Threads: "; }
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td:nth-of-type(7)::before { content: "Referrals: "; }
  /* its Avatar / Username / ... header row */
  #content table.tborder > tbody > tr:has(> td:nth-of-type(7)) > td.tcat { display: none; }

  /* ---------------------------------------------------------------
     Search: the keyword / username columns stack
     --------------------------------------------------------------- */
  #content table.tborder:has(td.tcat[width="50%"]) { display: block; }
  #content table.tborder:has(td.tcat[width="50%"]) > tbody { display: block; }
  #content table.tborder:has(td.tcat[width="50%"]) td { display: block; width: auto !important; }

  input.textbox, select, textarea { max-width: 100%; box-sizing: border-box; }

  /* ---------------------------------------------------------------
     Generic tables, forms, footer
     --------------------------------------------------------------- */
  td.formbit,
  td.formbit2 { display: block; width: auto !important; }
  input.textbox, textarea, select { font-size: 16px; max-width: 100%; box-sizing: border-box; }
  input.button { min-height: 36px; }

  #footer ul.menu { display: flex; flex-wrap: wrap; gap: 2px 12px; padding: 6px 0; }
  #footer ul.menu li { display: inline-block; padding: 8px 0; }
  #footer .lower { text-align: left; font-size: 12px; padding: 6px 0; }
  #footer .upper .wrapper, #footer .lower .wrapper { padding: 0 10px; }

  /* editor */
  .sceditor-container { max-width: 100% !important; }
}
