/* ***********************************************************************
 *
 *  File:   global_mobile.css
 *
 *  Brief:  Responsive overrides for narrow screens. This is the first
 *          step towards a fully responsive layout: it condenses the
 *          header and main navigation bar into a hamburger menu. Loaded
 *          on every page, after global_desktop.css and any local_*.css
 *          files, so its rules win on specificity ties.
 *
 *  Author: Jomar Hønsi, 2026
 *
 * ************************************************************************/

/* The short title is only ever shown below the extra-narrow breakpoint;
   hidden unconditionally here so it never doubles up with the full
   title regardless of viewport width. */
header#site-header div.header-title h1 .title-short {
  display: none;
}

@media (max-width: 860px) {
  body {
    padding: 0;
  }

  div#container {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border-radius: 0;
  }

  /* Header: hamburger takes the logo's place, logo itself is hidden.
     The title stays on the single icon row but shrinks to fit the
     narrower column so it never wraps onto a second line.
     Selectors are prefixed with header#site-header to match/exceed the
     specificity of the nested rules in global_desktop.css. */
  header#site-header {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    padding: 12px;
    gap: 8px;
  }

  header#site-header div.header-logo {
    display: none;
  }

  header#site-header button.mobile-nav-toggle {
    display: flex;
    grid-column: 1;
    grid-row: 1;
  }

  header#site-header div.header-title {
    grid-column: 2;
    grid-row: 1;
    overflow: hidden;
  }

  header#site-header div.header-title h1 {
    font-size: clamp(0.65em, calc(9.6vw - 21px), 2em);
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  header#site-header button.header-search {
    grid-column: 3;
    grid-row: 1;
  }

  header#site-header div.header-utilities {
    grid-column: 4;
    grid-row: 1;
  }

  /* Main navigation bar: collapsed behind the hamburger toggle */
  div#nav-container {
    display: none;
    flex-direction: column;
    align-items: stretch;
    margin: 0 0 16px;
    gap: 0;
    text-align: left;
  }

  div#nav-container.nav-mobile-open {
    display: flex;
  }

  a.nav-item, div.nav-dropdown {
    width: 100%;
    box-sizing: border-box;
    border-radius: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    text-align: left;
    font-size: 0.95em;
    padding: 10px 12px;
  }

  div.nav-dropdown {
    display: block;
  }

  .nav-dropdown_trigger {
    display: block;
  }

  /* Hover does not exist on touch screens: dropdown groups are always
     expanded inline while the mobile menu is open. */
  div.nav-dropdown_menu {
    display: block;
    position: static;
    box-shadow: none;
    min-width: 0;
    padding: 0 0 0 16px;
  }

  /* Dictionary table-of-content tree: bigger tap targets, less
     indentation, more legible text for touch screens. */
  div.toc-root {
    padding: 8px;
  }

  div.collapse1, div.collapse2 {
    margin-left: 8px;
    margin-right: 8px;
  }

  img.folder {
    width: 24px;
    height: 24px;
  }

  a.toc-root, a.cindex, a.nrindex {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  a.cindex {
    font-size: 0.95em;
  }

  a.nrindex {
    font-size: 0.85em;
  }

  /* Save space: the descriptive label becomes a tooltip (title attr),
     only the entry count stays visible. */
  span.toc-label-text {
    display: none;
  }

  a.toc-root:active, a.cindex:active {
    background-color: #eee;
  }
}

/* Narrow-ish screens: shrink figures */
@media (max-width: 800px) {
  figure {
    max-width: 50%;

    & img {
      max-width: 100%;
    }
  }

  .info-left {
    max-width: 100%;
  }

}

/* Narrow screens adjustments for images */
@media (max-width: 600px) {
  figure, img {
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
  }

  figure.photo {
    border: none;
    float: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
  }

  figure, figure.photo {
    float: none;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  figure img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-left: auto;
    margin-right: auto;
  }

  .info-left {
    max-width: 100%;
  }

}

/*
   Extra-narrow screens: use a short title for the site header.
*/
@media (max-width: 400px) {
  header#site-header div.header-title h1 {
    font-size: 1.3em;
    letter-spacing: 2px;
  }

  header#site-header div.header-title h1 .title-full {
    display: none;
  }

  header#site-header div.header-title h1 .title-short {
    display: inline;
  }

}