/***********************************************************
  MOBILE OVERRIDES (≤ 768px)
  Load after style.css:
  <link rel="stylesheet" href="/models/mobile.css" media="(max-width: 768px)">
************************************************************/

@media (max-width: 768px) {
  /***********************************************************
    ROOT VARS (MOBILE)
  ************************************************************/
  :root { --header-h: 84px; }               /* ↑ mobile anchor offset */

  /***********************************************************
    HEADER (STICKY) + NAV CONTAINER (NO OVERFLOW)
  ************************************************************/
  header.site {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg, #fff);
  }

  /* Key fix: full-width, border-box so padding never exceeds viewport */
  header.site .nav-container {
    position: relative;                      /* dropdown positions under this */
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 12px 16px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  /* Logo size on mobile */
  .logo img { height: 40px; }

  /***********************************************************
    MENU TOGGLE (ACCESSIBLE HIDE, NO OFF-SCREEN SHIFT)
  ************************************************************/
  .menu-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    border: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }

  /***********************************************************
    HAMBURGER
  ************************************************************/
  .menu-icon {
    display: flex;                           /* visible on mobile */
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 22px;
    cursor: pointer;
    margin-left: auto;
  }
  .menu-icon span {
    display: block;
    height: 3px;
    background: #333;
    border-radius: 2px;
  }

  /***********************************************************
    NAV (MOBILE) — PREVENT HORIZONTAL OVERFLOW
  ************************************************************/
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;                               /* directly below header container */
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;                        /* clamp to viewport width */
    box-sizing: border-box;                  /* borders/padding stay inside */
    overflow-x: hidden;                      /* guard against sub-pixel rounding */
    background: var(--bg, #fff);
    border: 1px solid var(--border, #eee);
    border-top: none;
    z-index: 1001;
  }

  /* Reveal nav when checkbox is checked */
  #menu-toggle:checked + .menu-icon + .main-nav { display: block; }

  /* Vertical list on mobile */
  .main-nav ul {
    list-style: none;
    margin: 0;
    padding: 12px 16px;                      /* match header padding */
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
  .main-nav li { width: 100%; }
  .main-nav a {
    display: block;
    width: 100%;
    padding: 12px 0;                         /* larger tap area */
    text-decoration: none;
    color: #333;
    font-weight: 500;
    white-space: normal;                     /* allow wrapping */
    overflow-wrap: anywhere;                 /* break long words/URLs */
    word-break: break-word;                  /* extra safety */
  }

  /* Breadcrumbs can also be long on mobile — allow wrapping safely */
  .breadcrumbs {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /***********************************************************
    GENERAL MOBILE POLISH
  ************************************************************/
  .hero { padding: 1.6rem 0 .6rem; }
  .grid { gap: .9rem; margin: 1.4rem auto; }
  .card h3 { font-size: .98rem; line-height: 1.25; }
  .card p  { font-size: .96rem; }
  footer.site { padding: 1rem 0; }

  /***********************************************************
    SHARE SECTION – STACK BUTTONS ON MOBILE
  ************************************************************/
  .share-buttons {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;                       /* avoid horizontal scroll */
    align-items: stretch;                    /* full-width buttons */
    row-gap: 10px;
    column-gap: 0;
    margin: 12px auto;
    max-width: 100%;
  }
  .share-button {
    width: 100%;
    text-align: center;
    white-space: normal;                     /* allow wrapping if needed */
    margin: 0 !important;
    justify-content: center;
  }
}

/***********************************************************
  SPLIT BLOCKS – MOBILE STACK
************************************************************/
@media (max-width: 768px) {
  .content .split { grid-template-columns: 1fr; }
}

/***********************************************************
  IN-PAGE ANCHOR OFFSET — MOBILE
************************************************************/
@media (max-width: 768px) {
  .content [id] { scroll-margin-top: var(--header-h, 84px); }
}
