/* OPENYYC mobile reflow (≤ 768 px). Loads after catalogue.css so its rules
   win when both match. Brutalist intent preserved: hard rules, no rounded
   corners, no soft shadows. */

/* ─── desktop defaults that mobile.css overrides ─────────────── */

/* The mobile "Filter (N)" toggle button and the <dialog> drawer are
   only used on small viewports; hide both on desktop. The inline
   <aside class="openyyc-search__aside--inline"> stays visible. */
.openyyc-filter-toggle {
  display: none;
}

.openyyc-search__drawer {
  display: none;
}

/* The browser shows native <dialog> backdrops when .open is set; we
   keep the brutalist look uniform with this style. */
.openyyc-search__drawer::backdrop {
  background: rgba(14, 14, 16, 0.55);
}

/* ─── 768 px and below ──────────────────────────────────────── */

@media (max-width: 768px) {

  /* ── home ───────────────────────────────────────────────── */

  .openyyc-hero {
    padding: 28px 0 32px;
  }

  .openyyc-hero .row,
  .openyyc-home__publishers-strip .row {
    display: block;
  }

  .openyyc-hero .col-md-8,
  .openyyc-home__publishers-strip .col-md-7,
  .openyyc-home__publishers-strip .col-md-5 {
    width: 100%;
    flex: none;
  }

  .openyyc-home__publishers-strip .col-md-5 {
    margin-top: 32px;
  }

  .openyyc-home .container { padding: 0 16px; }

  .openyyc-hero h1 { font-size: 38px; line-height: 1.05; }
  .openyyc-hero .lede { font-size: 15px; }

  .search-form.search-giant { flex-wrap: wrap; }
  .search-form.search-giant input[type="search"] { font-size: 18px; padding: 12px 14px; }

  .openyyc-stat-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .openyyc-stat-strip .stat {
    padding: 12px 18px;
    flex-shrink: 0;
  }

  .openyyc-home__section { padding: 36px 0; }
  .openyyc-home__section-title { font-size: 28px; }
  .openyyc-home__section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* ── search results ─────────────────────────────────────── */

  .openyyc-sort { flex-wrap: wrap; row-gap: 4px; }
  .openyyc-sort__btn { padding: 4px 8px; font-size: 11px; }

  .openyyc-search__active-inner { padding: 12px 16px; }

  /* Body becomes single column. The inline aside is hidden when JS is
     available (drawer takes over); browsers without JS see the aside
     stacked below the result list as a no-JS fallback. */
  .openyyc-search__body {
    display: block;
  }

  /* Sticky "Filter (N)" toggle button at the top of results. */
  .openyyc-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 12px 16px 0;
    padding: 10px 14px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .openyyc-filter-toggle__count {
    background: var(--gold);
    color: var(--ink);
    padding: 0 6px;
    margin-left: 4px;
    font-weight: 700;
  }

  /* When JS is loaded, the drawer is the canonical filter UI on mobile;
     suppress the inline aside to avoid showing facets twice. */
  .openyyc-ready .openyyc-search__aside--inline {
    display: none;
  }

  /* Mobile inline aside (no-JS fallback): drop the border-right and
     stack below the result list. */
  .openyyc-search__aside--inline {
    border-right: 0;
    border-top: 1px solid var(--ink);
    padding: 16px;
  }

  /* The <dialog> drawer */
  .openyyc-search__drawer[open] {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
  }

  .openyyc-search__drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ink);
    position: sticky;
    top: 0;
    background: var(--paper);
    z-index: 2;
  }

  .openyyc-search__drawer-close {
    background: var(--paper);
    border: 1px solid var(--ink);
    color: var(--ink);
    padding: 4px 10px;
    font-family: var(--mono);
    font-size: 14px;
    cursor: pointer;
  }

  .openyyc-search__drawer-close:hover {
    background: var(--ink);
    color: var(--paper);
  }

  .openyyc-search__drawer-body {
    padding: 12px 16px 96px; /* room for sticky footer */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .openyyc-search__drawer-foot {
    position: sticky;
    bottom: 0;
    padding: 12px 16px;
    background: var(--paper);
    border-top: 1px solid var(--ink);
  }

  .openyyc-search__apply {
    width: 100%;
    justify-content: center;
    padding: 14px;
  }

  /* Single-column result list */
  .openyyc-search__results { padding: 16px 16px 56px; }

  .openyyc-result { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .openyyc-result__main { padding-right: 0; }
  .openyyc-result__title { font-size: 20px; }
  .openyyc-result__notes { font-size: 14px; margin-bottom: 20px; }
  .openyyc-result__stats {
    flex-direction: row;
    gap: 32px;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
    margin-top: 16px;
  }

  .openyyc-pager { flex-direction: column; align-items: stretch; gap: 12px; }
  .openyyc-pager .pagination { flex-wrap: wrap; row-gap: 4px; }

  /* ── dataset detail ─────────────────────────────────────── */

  .openyyc-breadcrumb { padding: 14px 16px 0; flex-wrap: wrap; row-gap: 4px; }

  .openyyc-dataset__header {
    grid-template-columns: 1fr;
    padding: 14px 16px 24px;
    gap: 20px;
  }

  .openyyc-dataset__title { font-size: 32px; line-height: 1.05; max-width: none; }
  .openyyc-dataset__notes { font-size: 14px; }
  .openyyc-dataset__meta { padding: 14px; }

  .openyyc-meta-grid { gap: 10px 14px; }
  .openyyc-meta-grid dd { font-size: 14px; }

  .openyyc-dataset__resources { padding: 24px 16px 40px; }

  .openyyc-resource {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 0;
  }

  .openyyc-resource__badge .openyyc-format { width: auto; display: inline-block; }
  .openyyc-resource__title,
  .module .openyyc-resource__title { font-size: 16px; }
  .openyyc-resource__actions { flex-direction: column; align-items: stretch; }
  .openyyc-resource__actions .openyyc-btn { justify-content: center; }

  /* Embedded preview iframe scales to viewport */
  .openyyc-dataset .dataTables_wrapper { font-size: 11px; }

  /* ── organization profile ───────────────────────────────── */

  .openyyc-org__header-inner {
    grid-template-columns: 80px 1fr;
    gap: 16px;
    padding: 24px 16px 20px;
  }

  .openyyc-org__mark {
    width: 80px;
    height: 80px;
    font-size: 28px;
    border-width: 2px;
  }

  .openyyc-org__title { font-size: 34px; line-height: 1; }
  .openyyc-org__description { font-size: 14px; }

  .openyyc-org__stats { grid-template-columns: 1fr 1fr; }
  .openyyc-org__stat { padding: 12px 16px; }
  .openyyc-org__stat-num { font-size: 24px; }

  .openyyc-org__body { padding: 24px 16px 40px; }

  .openyyc-org-row {
    grid-template-columns: 48px 1fr;
    gap: 14px;
    padding: 14px 0;
  }

  .openyyc-org-row__mark { width: 48px; height: 48px; font-size: 15px; }
  .openyyc-org-row__count { grid-column: 1 / -1; text-align: left; padding-left: 62px; }
  .openyyc-org-row__count-num { display: inline; font-size: 14px; }
  .openyyc-org-row__count-label { display: inline; margin-left: 6px; }
}
