/* Jerome Online mobile layout — desktop is intentionally untouched. */
@media screen and (max-width: 768px) {
  html, body { width:100%; min-width:0; max-width:100%; margin:0; overflow-x:hidden; }
  body { -webkit-text-size-adjust:100%; }
  #main { width:100% !important; height:auto !important; min-height:100dvh; }
  #main > tbody > tr > td { vertical-align:top; padding:6px 0; }

  /* Same left-sidebar table, but a fluid frame instead of 700px. */
  #main > tbody > tr > td > table.border {
    width:calc(100% - 12px) !important;
    max-width:700px;
    min-width:0;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    table-layout:fixed;
    margin:0 auto;
  }
  #main > tbody > tr > td > table.border > tbody > tr > td {
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
  }
  #main td.borderright {
    box-sizing:border-box;
    width:97px !important;
    min-width:97px;
    max-width:97px;
    padding:3px;
    vertical-align:top;
  }
  /* Original 90px GIF controls remain legible and identifiable. */
  #main td.borderright img { display:block; max-width:90px; height:auto; }
  #main td.borderright p { margin:0 0 12px; }
  #main td.borderright a { display:inline-flex; align-items:center; min-height:40px; max-width:90px; }

  #main td.spacer {
    width:auto !important;
    min-width:0;
    max-width:none !important;
    box-sizing:border-box;
    padding:8px;
    overflow-wrap:anywhere;
    word-break:normal;
    vertical-align:top;
    font-size:12px;
    line-height:1.5;
  }
  #main td.spacer p { margin-top:7px; }
  #main td.spacer img:not(.recent-image) { max-width:100%; height:auto; }
  #main td.spacer table { max-width:100%; }
  #main td.spacer td { font-size:12px; line-height:1.5; overflow-wrap:anywhere; }

  /* Homepage: original welcome graphic scales within the content cell. */
  #main td.home-content {
    box-sizing:border-box;
    width:auto !important;
    min-width:0;
    max-width:none !important;
    vertical-align:top;
    overflow:hidden;
  }
  #main td.home-content .home-main-image {
    display:block;
    width:100%;
    max-width:598px;
    height:auto;
  }

  /* Clients page: lift the desktop 326px independent-scroll restriction. */
  .portfolio-frame { width:calc(100% - 12px) !important; height:auto !important; min-height:0 !important; max-height:none !important; }
  .portfolio-content-cell { width:auto !important; overflow:visible !important; }
  .portfolio-scroll {
    height:auto !important; max-height:none !important;
    overflow:visible !important; padding-right:0 !important;
  }

  /* Clients introduction and original links become stacked, readable content. */
  .clients-overview { width:100% !important; }
  .clients-overview > tbody > tr:first-child { display:flex; flex-direction:column; }
  .clients-overview > tbody > tr:first-child > td { width:100% !important; display:block; box-sizing:border-box; }
  .clients-overview > tbody > tr:first-child > td:nth-child(2) { display:none; }
  .clients-overview > tbody > tr:first-child > td:nth-child(3) { padding:4px 0 9px; }

  /* Re-pair each of the six historic thumbnails with its caption. */
  .legacy-gallery, .legacy-gallery > tbody { display:block; width:100% !important; }
  .legacy-gallery > tbody { display:grid; grid-template-columns:minmax(0,1fr); row-gap:2px; }
  .legacy-gallery > tbody > tr { display:contents; }
  .legacy-gallery > tbody > tr > td { display:block; width:100% !important; box-sizing:border-box; }
  .legacy-gallery > tbody > tr:nth-child(1) > td:nth-child(1) { order:1; }
  .legacy-gallery > tbody > tr:nth-child(2) > td:nth-child(1) { order:2; margin-bottom:10px; }
  .legacy-gallery > tbody > tr:nth-child(1) > td:nth-child(2) { order:3; }
  .legacy-gallery > tbody > tr:nth-child(2) > td:nth-child(2) { order:4; margin-bottom:10px; }
  .legacy-gallery > tbody > tr:nth-child(1) > td:nth-child(3) { order:5; }
  .legacy-gallery > tbody > tr:nth-child(2) > td:nth-child(3) { order:6; margin-bottom:10px; }
  .legacy-gallery > tbody > tr:nth-child(3) > td { display:none; }
  .legacy-gallery > tbody > tr:nth-child(4) > td:nth-child(1) { order:7; }
  .legacy-gallery > tbody > tr:nth-child(5) > td:nth-child(1) { order:8; margin-bottom:10px; }
  .legacy-gallery > tbody > tr:nth-child(4) > td:nth-child(2) { order:9; }
  .legacy-gallery > tbody > tr:nth-child(5) > td:nth-child(2) { order:10; margin-bottom:10px; }
  .legacy-gallery > tbody > tr:nth-child(4) > td:nth-child(3) { order:11; }
  .legacy-gallery > tbody > tr:nth-child(5) > td:nth-child(3) { order:12; margin-bottom:10px; }
  .legacy-gallery img { max-width:100%; height:auto; }

  /* Recent portfolio: one card per row without touching projects.json. */
  .recent-grid, .recent-grid > tbody, .recent-grid > tbody > tr { display:block; width:100%; }
  .recent-grid { border-spacing:0; }
  .recent-grid td { display:block; box-sizing:border-box; width:100% !important; padding:0 0 13px !important; }
  .recent-card { width:100%; max-width:100%; }
  .recent-thumb { width:150px; max-width:100%; height:74px; }
  .recent-image { max-width:100%; }
  .recent-heading { font-size:12px; }
  .recent-intro { font-size:12px; }
  .recent-name { font-size:12px; }
  .recent-status { font-size:11px; }

  /* Contact form and information stack instead of two cramped columns. */
  .contact-details { width:100% !important; }
  .contact-details > tbody > tr { display:flex; flex-direction:column; }
  .contact-details > tbody > tr > td { display:block; width:100% !important; box-sizing:border-box; }
  .contact-details input:not([type="submit"]),
  .contact-details textarea { max-width:100%; width:100%; }
  .contact-details input[type="submit"] { min-height:40px; padding:5px 14px; }
}

/* Homepage-only correction, 16 Nov 2026.
   Keep the familiar compact 350px retro frame on phones instead of
   stretching the homepage table to the full device height. */
@media screen and (max-width: 768px) {
  #main:has(.home-content) {
    height:auto !important;
    min-height:0 !important;
  }
  #main:has(.home-content) > tbody > tr > td {
    padding:6px 0;
    vertical-align:top;
  }
  #main:has(.home-content) > tbody > tr > td > table.border,
  #main:has(.home-content) > tbody > tr > td > table.border > tbody > tr > td {
    height:350px !important;
    min-height:350px !important;
    max-height:350px !important;
  }
  #main td.home-content {
    height:350px !important;
    vertical-align:middle !important;
    overflow:hidden;
  }
  #main td.home-content .home-main-image {
    display:block;
    width:100%;
    height:auto;
    margin:0 auto;
  }
}
