/* Keep gallery listings in three even columns on desktop too. */
.gallery-index {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}
.gallery-index .gallery-card {
  box-sizing: border-box;
  float: none;
  width: auto;
  min-width: 0;
  margin: 0;
}
.gallery-index .gallery-card h3 { line-height: 1.25; }
.gallery-index .gallery-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.gallery-index .gallery-card a { overflow-wrap: anywhere; }

/*
 * KingSize responsive layer — tablet/mobile only.
 * Keep kingsize.css as the historical desktop baseline.
 * The selectors below intentionally override its fixed widths and hover menus.
 */
.mobile-site-title,
#mobile-menu-toggle,
.mobile-menu-name {
  display: none;
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 1024px) {
  html {
    scroll-padding-top: 84px;
  }
  body {
    height: auto;
    min-height: 100dvh;
  }
  #wrapper {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    height: auto;
  }

  /* Compact dark top bar; the menu floats over content when opened. */
  #menu_wrap {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 500;
    display: block;
    background: #0b0b0b;
    border-bottom: 1px solid #323232;
  }
  #menu {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: 72px;
    padding: 10px clamp(14px, 4vw, 30px);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 14px;
    background: rgba(10, 10, 10, .98);
  }
  #logo, #logo h1 {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    padding: 0;
    margin: 0;
  }
  #logo h1 a {
    display: block;
    width: 52px;
    height: 52px;
    border-radius: 4px;
    background-size: cover !important;
    background-position: center center !important;
    text-indent: 0;
  }
  .mobile-site-title {
    display: block;
    min-width: 0;
    font: bold 21px 'PT Sans Narrow', 'PT Sans', Arial, sans-serif;
    letter-spacing: .025em;
    color: #f2f2f2;
  }
  html.has-js #mobile-menu-toggle {
    display: inline-flex;
  }
  #mobile-menu-toggle {
    margin-left: auto;
    min-width: 96px;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 11px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #191919;
    color: #fff;
    padding: 10px 14px;
    cursor: pointer;
    font: bold 15px 'PT Sans', Arial, sans-serif;
    touch-action: manipulation;
  }
  #mobile-menu-toggle:hover,
  #mobile-menu-toggle[aria-expanded="true"] {
    background: #292929;
    border-color: #bbb;
  }
  #mobile-menu-toggle:focus-visible {
    outline: 3px solid white;
    outline-offset: 3px;
  }
  .mobile-menu-glyph {
    display: inline-block;
    width: 18px;
    height: 2px;
    flex: 0 0 18px;
    background: currentColor;
    position: relative;
  }
  .mobile-menu-glyph::before,
  .mobile-menu-glyph::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: currentColor;
  }
  .mobile-menu-glyph::before { top: -6px; }
  .mobile-menu-glyph::after { top: 6px; }

  #site-navigation {
    box-sizing: border-box;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 510;
    width: 100%;
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px clamp(14px, 4vw, 30px) 20px;
    background: rgba(8, 8, 8, .98);
    border-bottom: 1px solid #505050;
    box-shadow: 0 12px 22px rgba(0, 0, 0, .55);
  }
  /* The unenhanced (no JS) navigation stays available. */
  html.has-js #site-navigation:not(.is-open) {
    display: none;
  }
  #navbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
    list-style: none;
  }
  #navbar li,
  #navbar li ul li {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    box-sizing: border-box;
    float: none;
    position: static;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
  }
  #navbar li.menu-item:hover,
  #navbar .sub-menu li.menu-item:hover {
    background: none;
  }
  #navbar li a,
  #navbar li ul li a {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    height: auto;
    margin: 0;
    padding: 12px 14px;
    background: none;
    border-bottom: 1px solid #303030;
    color: #d5d5d5;
    font-size: 16px;
    line-height: 22px;
    text-transform: none;
    outline-offset: -3px;
    touch-action: manipulation;
  }
  #navbar li a strong {
    font-size: 17px;
  }
  #navbar li a span {
    position: static;
    display: inline;
    top: auto;
    left: auto;
    margin-left: 10px;
    font-size: 12px;
    color: #aaa;
  }
  #navbar li a:hover,
  #navbar li a:focus-visible {
    color: #fff;
    background: #202020;
  }
  #navbar li a:focus-visible {
    outline: 2px solid white;
  }
  #navbar .desktop-menu-name { display: none; }
  #navbar .mobile-menu-name { display: inline; }
  #navbar li ul,
  #navbar li:hover > ul,
  #navbar li:hover > ul li ul {
    display: block;
    position: static;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }
  #navbar li ul li a {
    min-height: 46px;
    padding-left: 32px;
    font-size: 15px;
    color: #c6c6c6;
  }
  #hide_menu { display: none; }
  /* Without JavaScript, keep navigation permanently visible and in flow. */
  html:not(.has-js) #menu {
    height: auto;
    flex-wrap: wrap;
  }
  html:not(.has-js) #site-navigation {
    position: static;
    flex-basis: 100%;
    max-height: none;
    box-shadow: none;
    padding: 0 0 8px;
  }

  /* The desktop fixed sidebar and 680px content window cannot fit tablets. */
  #main_wrap {
    width: 100%;
    min-height: calc(100dvh - 72px);
    margin: 0;
    background: rgba(8, 8, 8, .83);
  }
  #main {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 20px clamp(16px, 4vw, 32px) 32px;
  }
  #main h2.section_title {
    margin: 8px 0 30px;
    font-size: clamp(25px, 4.4vw, 31px);
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  #main h3 {
    overflow-wrap: anywhere;
  }
  #content,
  #content_gallery_top,
  #content_gallery_top.content_full_width,
  .content_two_thirds,
  .content_full_width {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #content {
    float: none;
    margin: 0 0 30px;
  }
  #content_gallery_top {
    margin: 0 0 22px;
  }
  #content img,
  #main img {
    max-width: 100%;
    height: auto;
  }
  #content p, #main p {
    overflow-wrap: break-word;
  }
  #content pre,
  #main pre,
  #main table {
    max-width: 100%;
    overflow-x: auto;
  }
  .post-list .post {
    padding-bottom: 10px;
  }
  .post a.read_more {
    display: inline-block;
    position: static;
    min-height: 44px;
    box-sizing: border-box;
    padding: 12px 0;
    margin-top: 2px;
  }
  .post .metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    height: auto;
    min-height: 28px;
    box-sizing: border-box;
  }
  .post .metadata p {
    margin: 0;
  }
  .post .metadata a {
    position: static;
    margin-left: auto;
  }
  #sidebar {
    float: none;
    box-sizing: border-box;
    clear: both;
    width: 100%;
    margin: 24px 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 24px;
  }
  #sidebar > .sidebar_item {
    min-width: 0;
  }
  #sidebar ul li a {
    box-sizing: border-box;
    min-height: 44px;
    padding-top: 11px;
    padding-bottom: 11px;
    overflow-wrap: anywhere;
  }
  #sidebar h3 {
    padding: 0 0 12px;
  }

  /* Reflow all legacy photo grids and variants. */
  .gallery_3columns,
  .gallery_2columns,
  .gallery_4columns,
  .gallery_grid {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    list-style: none;
  }
  .gallery_3columns li,
  .gallery_2columns li,
  .gallery_4columns li,
  .gallery_grid li {
    display: block;
    float: none;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    aspect-ratio: 220 / 140;
    overflow: hidden;
  }
  .gallery_3columns li a,
  .gallery_2columns li a,
  .gallery_4columns li a,
  .gallery_grid li a {
    display: block;
    width: 100%;
    height: 100%;
  }
  .gallery_3columns li a img,
  .gallery_2columns li a img,
  .gallery_4columns li a img,
  .gallery_grid li a img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: cover;
  }
  .gallery-index {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    margin: 0 0 24px;
    padding: 0;
  }
  .gallery-index .gallery-card {
    display: block;
    float: none;
    box-sizing: border-box;
    min-width: 0;
    width: auto;
    margin: 0;
  }
  .gallery-index .gallery-card h3 {
    line-height: 1.25;
    padding: 0 0 12px;
  }
  .gallery-index .gallery-card img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }
  .gallery-index .gallery-card a {
    overflow-wrap: anywhere;
  }
  #pagination,
  #pagination-full {
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
  }
  #footer, #footer_info, #footer_columns {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
  }
  #footer {
    padding: 20px 0 0;
  }
  #footer_columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    padding: 22px 0;
  }
  #footer_columns > div {
    box-sizing: border-box;
    float: none;
    width: 100%;
    min-width: 0;
    margin: 0;
  }
  #footer_columns > div:nth-child(2) { display: none; }
  #footer_columns div li a {
    box-sizing: border-box;
    min-height: 44px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  #contact_form, #contact_form input, #contact_form textarea {
    box-sizing: border-box;
    max-width: 100%;
  }
  #contact_form input:not([type="submit"]),
  #contact_form textarea {
    width: 100%;
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  #menu { height: 68px; }
  #site-navigation { max-height: calc(100dvh - 68px); }
  #main { padding: 18px 16px 24px; }
  #main_wrap { min-height: calc(100dvh - 68px); }
  #main h2.section_title { margin-bottom: 24px; }
  #sidebar { grid-template-columns: 1fr; gap: 4px; }
  #sidebar > .sidebar_item { margin-bottom: 16px; }
  .gallery_3columns,
  .gallery_2columns,
  .gallery_4columns,
  .gallery_grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gallery-index { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  #footer_columns { grid-template-columns: 1fr; gap: 0; }
  #main h2, #main h3 { overflow-wrap: anywhere; }
  #content .img_floated_left, #content .img_floated_right,
  #content img.alignleft, #content img.alignright {
    float: none;
    display: block;
    max-width: 100%;
    margin: 10px 0 16px;
  }
}

@media (max-width: 360px) {
  #menu { gap: 8px; }
  .mobile-site-title { font-size: 19px; }
  #mobile-menu-toggle { min-width: 84px; padding: 10px; }
  .gallery-index { grid-template-columns: 1fr; }
}

@media (hover: none) and (pointer: coarse) {
  .gallery .image_hover { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  #mobile-menu-toggle { transition: none; }
}
