/**
 * jsm-mobile.css
 *
 * Mobile breakpoint layer for the "jsm-demo" theme. Loaded AFTER jsm-home.css
 * so these rules win the cascade normally — only one !important is used
 * below, and only because it overrides an inline style="" in indexJournal.tpl.
 *
 * Targets the real selectors already in your 4 templates (top-bar, main-nav,
 * nav-list, hero, search-form, content-grid, card, features-strip,
 * about-section, indexing-section, site-footer, ...). No template markup
 * needs to change for this file alone to work — see jsm-mobile.js for the
 * handful of elements (backdrop, dropdown state) that script adds at runtime.
 *
 * Adjust the 860px breakpoint if your desktop layout already collapses
 * somewhere else.
 */

@media (max-width: 860px) {
  .container {
    padding: 0;
  }

  /* ============ Header / top bar ============ */
  .top-bar-inner {
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand {
    gap: 9px;
  }
  .brand-mark,
  .brand-mark img {
    width: 56px;
    height: 56px;
  }
  .brand-mark img {
    object-fit: contain;
  }
  .brand > span:not(.brand-mark) {
    display: none;
  }
  .utility-nav .utility-link,
  .utility-nav .divider-v {
    display: none; /* moved into the nav drawer instead, see main-nav below */
  }
  .utility-nav .btn-primary.btn-sm {
    display: inline-flex;
    padding: 6px 8px;
  }
  .btn-sm {
    padding: 9px 16px;
    font-size: 12px;
}
  .submit-label-desktop {
    display: none;
  }
  .submit-label-mobile {
    display: inline;
  }
  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  /* ============ Main nav -> slide-in drawer ============ */
  .main-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 86%;
    max-width: 340px;
    background: #fff;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    z-index: 200;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.15);
    padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
    display: block;
  }
  .main-nav.is-open {
    transform: translateX(0);
  }
  .main-nav-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 60px 16px 24px;
  }
  .nav-list {
    flex-direction: column;
    align-items: stretch;
  }
  .nav-item {
    width: 100%;
  }
  .nav-link {
    display: block;
    padding: 12px 6px;
    color: var(--color-primary);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.07);
  }
  .nav-item.active .nav-link {
    color: var(--color-primary);
    border-bottom-color: var(--color-gold);
  }
  /* Dropdowns become tap-to-expand instead of hover (see jsm-mobile.js) */
  .nav-item.has-dropdown .nav-dropdown {
    position: static;
    display: none;
    box-shadow: none;
    width: 100%;
    padding-left: 14px;
    opacity: 1;
    visibility: visible;
  }
  .nav-item.has-dropdown.is-open .nav-dropdown {
    display: block;
  }
  .nav-dropdown-2col {
    columns: 1;
  }

  /* Backdrop element, inserted by jsm-mobile.js */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 8, 0.45);
    z-index: 150;
    display: none;
  }
  .nav-backdrop.is-open {
    display: block;
  }

  /* Utility links + submit CTA repeated at the bottom of the drawer */
  .main-nav-inner::after {
    content: "";
  }

  /* ============ Hero ============ */
  .hero-inner {
    flex-direction: column;
    text-align: center;
  }
  .hero-visual {
    order: -1;
    margin-bottom: 20px;
    width: 100%;
  }
  .hero-visual img {
    width: 100%;
    height: auto;
  }
  .hero-features {
    grid-template-columns: 1fr 1fr;
  }
  .hero-cta {
    flex-direction: column;
  }
  .hero-cta .btn {
    width: 100%;
    justify-content: center;
  }

  /* ============ Search ============ */
  .search-form {
    flex-direction: column;
    align-items: stretch;
  }
  /* Overrides the inline style="flex: 0 0 150px" etc. set directly in
     indexJournal.tpl on .select-wrap — only an inline style can force this,
     hence the one !important in this file. */
  .search-form .select-wrap {
    flex: 1 1 100% !important;
    width: 100%;
  }
  .search-input {
    flex: 1 1 44px;
    width: 100%;
    height: 10px;
  }
  .search-submit {
    width: 100%;
    justify-content: center;
  }

  /* ============ Content grid (Current Issue / Latest Articles / Editor's Choice / Announcements) ============ */
  .content-grid {
    grid-template-columns: 1fr;
  }
  .card-header {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .article-stats {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .article-footer {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* ============ Features strip ============ */
  .features-inner {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .feature-item {
    flex-direction: row;
  }

  /* ============ About publisher ============ */
  .about-grid {
    grid-template-columns: 1fr;
  }
  .about-stats {
    grid-template-columns: 1fr 1fr;
  }

  /* ============ Indexing & footer ============ */
  .indexing-row {
    flex-wrap: wrap;
  }
  .footer-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
