/* NatureDex Mobile – Zoo-first layout V85
   Smartphone-specific, desktop styles remain unchanged.
   One shared stylesheet instead of stacking fixes in app.css. */
@media (max-width: 680px) {
  /* Discoverable, two-column NatureDex photo grid */
  #anidexView .page-head {
    padding: 16px 14px;
    gap: 8px;
    margin-bottom: 14px;
  }
  #anidexView .page-head h1 { font-size: clamp(24px, 7vw, 32px); }
  #anidexView .page-head p { font-size: 13px; line-height: 1.4; }
  #anidexView .collection-progress { font-size: 15px; padding: 8px 12px; }
  #anidexView .dex-tabs { margin-bottom: 12px; }
  #anidexView .dex-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    margin-bottom: 12px;
  }
  #anidexView .dex-filters #anidexSearch {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }
  #anidexView .dex-filters select { min-width: 0; width: 100%; font-size: 12px; }
  #anidexView .n42-demo-banner { display: none; } /* Move introductory marketing out of the way on mobile. */
  #anidexGrid.animal-grid,
  #anidexGrid .animal-grid.dex-continent-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  #anidexGrid:has(.dex-continent-group) { display: block; }
  #anidexGrid .dex-continent-group { width: 100%; min-width: 0; }
  #anidexGrid .animal-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    border-radius: 15px;
    overflow: hidden;
    margin: 0;
    touch-action: manipulation;
  }
  #anidexGrid .animal-art {
    height: clamp(112px, 34vw, 158px);
    min-height: 0;
    border-radius: 0;
    overflow: hidden;
  }
  #anidexGrid .animal-art .n268-photo,
  #anidexGrid .animal-art .n260-picture,
  #anidexGrid .animal-art img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    border-radius: 0;
  }
  #anidexGrid .animal-art .n268-fallback { font-size: 52px; }
  #anidexGrid .animal-info {
    padding: 10px 9px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
  }
  #anidexGrid .animal-info h3 {
    margin: 0;
    font-size: clamp(13px, 3.7vw, 16px);
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
  #anidexGrid .scientific {
    font-size: 10px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  #anidexGrid .animal-info .badge {
    margin-top: auto;
    width: fit-content;
    max-width: 100%;
    font-size: 10px;
    white-space: normal;
  }
  #anidexGrid .dex-card-status { max-width: 95%; }

  /* The same card treatment applies to EVERY species profile. */
  #animalModal {
    padding: 8px;
    align-items: center;
    justify-items: center;
  }
  #animalModal .modal-card.n42-modal-card {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 18px;
    scrollbar-gutter: auto;
  }
  #animalModal .nd73.n42-profile {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: 16px;
  }
  #animalModal .nd73 .n42-photo-hero,
  #animalModal .nd73 .n42-photo-hero:has(> .nd77-hero-licence) {
    display: grid;
    grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    gap: 9px 12px;
    padding: 16px 13px 8px;
    min-height: 0;
    overflow: visible;
  }
  #animalModal .nd73 .n42-photo-hero > img {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 132px;
    min-height: 0;
    max-height: 132px;
    object-fit: contain !important;
    object-position: center;
    border-radius: 12px;
    box-shadow: none;
    cursor: zoom-in;
  }
  #animalModal .nd73 .n42-photo-hero > .n43-photo-missing {
    grid-column: 1;
    grid-row: 1;
    min-height: 132px;
    height: 132px;
    padding: 8px;
    overflow: hidden;
    font-size: 10px;
  }
  #animalModal .nd73 .n43-photo-missing > span { font-size: 43px; }
  #animalModal .nd73 .n42-photo-hero > .n42-hero-copy,
  #animalModal .nd73 .n42-photo-hero:has(> .nd77-hero-licence) > .n42-hero-copy {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    padding: 0;
    margin: 0;
    text-align: left;
  }
  #animalModal .nd73 .n42-hero-copy h2 {
    margin: 6px 0 4px;
    font-size: clamp(21px, 5.8vw, 27px) !important;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  #animalModal .nd73 .n42-hero-copy > em { margin: 4px 0 9px; font-size: 12px; line-height: 1.3; }
  #animalModal .nd73 .n42-label { font-size: 9px; letter-spacing: 1.1px; }
  #animalModal .nd73 .n42-hero-badges { gap: 5px; }
  #animalModal .nd73 .n42-hero-badges > span { font-size: 10px; padding: 4px 7px; line-height: 1.25; }
  #animalModal .nd73 .n42-photo-hero > .nd77-hero-licence,
  #animalModal .nd73 .n42-photo-hero > .n42-image-credit {
    grid-column: 1 / -1;
    grid-row: auto;
    order: initial;
    padding: 2px 0;
    font-size: 10px;
  }
  #animalModal .nd73 .n42-photo-hero > .nd73-edit-photo {
    top: 19px;
    left: 19px;
    max-width: 33%;
    padding: 4px 6px;
    font-size: 10px;
    line-height: 1.25;
  }
  #animalModal .n42-modal-card > .modal-close {
    top: 8px;
    left: auto;
    right: 8px;
    margin: 10px 10px -52px auto;
    width: 41px;
    height: 41px;
  }

  /* Visitor questions precede specialist facts, maps and taxonomy. */
  #animalModal .nd85-visitor { padding: 12px 14px; background: #0d3022; border-bottom: 1px solid #735f34; }
  #animalModal .nd85-visitor-heading { margin: 0 0 10px; color: #f4e4bc; font-size: 14px; font-weight: 850; }
  #animalModal .nd85-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  #animalModal .nd85-fact {
    min-width: 0;
    padding: 11px;
    background: linear-gradient(140deg, #1a4532, #123827);
    border: 1px solid #887344;
    border-radius: 12px;
  }
  #animalModal .nd85-fact small { display: block; color: #dbc88e; font-size: 11px; font-weight: 800; line-height: 1.3; }
  #animalModal .nd85-fact strong {
    display: block;
    color: #fff4df;
    font-size: 13px;
    line-height: 1.45;
    margin-top: 4px;
    overflow-wrap: anywhere;
    font-weight: 750;
  }
  #animalModal .nd85-recognition {
    margin-top: 10px;
    border-radius: 12px;
    padding: 12px;
    background: #e8f3df;
    color: #254a33;
    border: 1px solid #a4c29b;
  }
  #animalModal .nd85-recognition strong { display: block; font-size: 13px; margin-bottom: 5px; }
  #animalModal .nd85-recognition p { font-size: 12px; line-height: 1.5; margin: 0; color: #2c5639; overflow-wrap: anywhere; }
  #animalModal .nd85-recognition button {
    border: 0;
    margin-top: 9px;
    padding: 0;
    background: transparent;
    color: #185f3c;
    font-weight: 800;
    font-size: 12px;
    text-decoration: underline;
  }
  #animalModal .nd73 .n42-body { padding: 11px 12px 26px; min-width: 0; }
  #animalModal .nd73 .n42-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    gap: 4px;
    padding: 5px;
    background: #0d3022;
    scroll-padding-inline: 12px;
    -webkit-overflow-scrolling: touch;
  }
  #animalModal .nd73 .n42-tabs button { min-height: 42px; font-size: 12px; padding: 9px 12px; }
  #animalModal .nd73 .n42-tab-pane,
  #animalModal .nd73 .n42-overview-grid,
  #animalModal .nd73 .nd71-geo { min-width: 0; max-width: 100%; }
  #animalModal .nd73 .n42-tab-pane { padding: 15px 1px 12px; }
  #animalModal .nd73 .n42-overview-grid { grid-template-columns: minmax(0, 1fr); }
  #animalModal .nd73 .n42-main-specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #animalModal .nd73 .n42-summary-tile { min-width: 0; padding: 10px; }
  #animalModal .nd73 .n42-pane-head h3 { font-size: 22px; }
  #animalModal .nd73 .nd77-map-card,
  #animalModal .nd73 .nd71-mapbox { max-width: 100%; }
}

/* Photo fullscreen: accessible dialog, close by X, Esc or tapping the backdrop. */
.nd85-photo-dialog {
  box-sizing: border-box;
  width: min(96vw, 980px);
  max-width: 96vw;
  max-height: 95dvh;
  padding: 12px;
  margin: auto;
  border: 1px solid #b7a069;
  border-radius: 18px;
  color: #f7edcf;
  background: #0b251c;
  box-shadow: 0 25px 80px #000b;
}
.nd85-photo-dialog::backdrop { background: #03130ed9; }
.nd85-photo-dialog img { display: block; width: 100%; max-height: 80dvh; object-fit: contain; }
.nd85-photo-dialog figcaption { margin: 7px 44px 3px 2px; font: 700 13px/1.4 system-ui,sans-serif; }
.nd85-photo-dialog .nd85-photo-close {
  float: right; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: #f9f3e3; color: #153725; font-size: 26px; cursor: pointer;
}

@media (max-width: 680px) {
  #animalModal .nd85-similar {
    margin-top: 9px;
    padding: 9px 12px;
    border: 1px solid #6f865b;
    border-radius: 12px;
    background: #173d2c;
    color: #f0ebd2;
  }
  #animalModal .nd85-similar summary { font-size: 12px; font-weight: 800; cursor: pointer; }
  #animalModal .nd85-similar p { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: #d9e8d0; }
}
