/* Photos and name tiles (server/images/render.js, public/js/images.js), and the admin's Images page. Its own
   stylesheet beside site.css, linked by the pages that draw image blocks (render.js IMAGE_STYLES): site.css is
   pinned block by block (test/home-business.test.js). Uses site.css's tokens. */

/* A column of the photo and, in a narrow slot, its credit under it (see the container query below). The figure is a
   size container for its width only: every slot gives it a width (or the full width of its card). It clips its
   corners with overflow: clip (hidden where clip is unknown), which, unlike hidden, lets the box grow past its
   ratio when a credit sits under the photo. */
.tx-img { position: relative; overflow: hidden; overflow: clip; margin: 0; border-radius: var(--radius); background: var(--sky-50); aspect-ratio: 16 / 10; display: flex; flex-direction: column; container-type: inline-size; }
.tx-img--16x10 { aspect-ratio: 16 / 10; }
.tx-img--16x9 { aspect-ratio: 16 / 9; }
.tx-img--4x3 { aspect-ratio: 4 / 3; }
.tx-img--1x1 { aspect-ratio: 1 / 1; }
.tx-img img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: 50% 50%; }

/* "Photo of Las Vegas": the photo is of the place, not of the item on the card. Wrapped, never cut: the place's
   name is always read whole. */
.tx-img-label { position: absolute; top: 10px; left: 10px; max-width: calc(100% - 20px); padding: 4px 10px; border-radius: 999px; background: rgba(7, 26, 51, .78); color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; }

/* The photographer's credit, small, over the photo's bottom right corner. Unsplash asks for the photographer and
   Unsplash to be credited where they can be seen, so it wraps rather than being cut. */
.tx-img-credit { position: absolute; right: 0; bottom: 0; max-width: 100%; padding: 3px 8px; border-top-left-radius: 8px; background: rgba(7, 26, 51, .62); color: rgba(255, 255, 255, .92); font-size: 11px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
.tx-img-credit a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.tx-img-credit a:hover { text-decoration-thickness: 2px; }

/* A slot under 200px wide (a thumbnail beside a trip or a hotel): the credit moves under the photo, across the
   figure's whole width, wrapped, and the figure grows by its height (the photo keeps the slot's ratio), so both
   links are whole and nothing is cut. */
@container (width < 200px) {
  .tx-img > img { flex: 1 0 auto; height: auto; aspect-ratio: inherit; }
  .tx-img .tx-img-credit { position: static; flex: none; max-width: none; padding: 2px 6px 3px; border-radius: 0; background: var(--navy-800); color: #fff; font-size: 10px; line-height: 1.3; }
  /* A destination card (the homepage strip, /destinations) has its name over the photo's foot and its credit at
     the top: there the credit, then the label, sit in one band above the photo, so the name below stays clear.
     (Each has a z-index: an ordered flex item would paint under the photo, and the card's link covers the rest.) */
  .home .dest-card .tx-img .tx-img-credit, .tb-dest .tx-img .tx-img-credit { position: relative; z-index: 2; order: -2; border-radius: 0; }
  .home .dest-card .tx-img .tx-img-label, .tb-dest .tx-img .tx-img-label { position: relative; z-index: 1; order: -1; top: auto; left: auto; flex: none; max-width: none; margin: 0; padding: 0 6px 4px; border-radius: 0; background: var(--navy-800); font-size: 11px; }
}

/* The name tile: no photo is known (or none loaded), so the place's name on the brand gradient. */
.tx-img--tile { display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: clamp(14px, 4%, 24px); background: linear-gradient(135deg, var(--navy-800) 0%, var(--navy-700) 55%, var(--blue-600) 100%); color: #fff; }
.tx-img-tile-title { font-size: clamp(18px, 1.2rem + .6vw, 26px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.tx-img-tile-sub { font-size: 14px; font-weight: 500; color: rgba(226, 236, 246, .86); line-height: 1.35; }

@media (forced-colors: active) {
  .tx-img--tile { border: 1px solid CanvasText; }
  .tx-img-label, .tx-img-credit { border: 1px solid CanvasText; }
}

/* ---------- The homepage's destinations strip (server/views/destinationsStrip.js) ----------
   site.css styles the card (.home .dest-card, pinned there); the card's link covers it without wrapping the picture,
   so a photo's credit links are never inside another link. The caption names the place, so a tile shows only its
   gradient. (The Travel by Budget slots are in trips.css.) */
.home .dest-card .tx-img { border-radius: 0; }
/* The picture fills its card, as tall as its row (see the narrow slots above). */
.home .dest-card { display: flex; flex-direction: column; }
.home .dest-card > .tx-img { flex: 1 0 auto; }
.home .dest-link { color: inherit; text-decoration: none; }
.home .dest-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.home .dest-link:focus-visible { outline: none; }
.home .dest-link:focus-visible::after { outline: 3px solid var(--blue-400); outline-offset: -3px; border-radius: inherit; }
.home .dest-card .tx-img-credit { z-index: 2; top: 0; bottom: auto; border-radius: 0 0 0 8px; }
.home .dest-card .tx-img-label { top: 30px; }
.home .dest-card .tx-img--tile > span { visibility: hidden; }

/* ---------- The admin's Images page (server/views/imagesAdmin.js) ---------- */
.tx-imgadm-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; list-style: none; padding: 0; margin: 0 0 20px; }
.tx-imgadm-thumb { width: 96px; height: 60px; border-radius: 6px; object-fit: cover; background: var(--sky-50); }
.tx-imgadm-table td { vertical-align: middle; }
.tx-imgadm-table form { display: inline; }
.tx-imgadm-region { margin-top: 26px; }
.tx-imgadm-search { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; margin-bottom: 18px; }
.tx-imgadm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; list-style: none; padding: 0; margin: 0; }
.tx-imgadm-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.tx-imgadm-card .field { margin: 0; }
.tx-imgadm-card .tx-img-cand { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; background: var(--sky-50); }
.tx-imgadm-card p { font-size: 14px; }
@media (max-width: 640px) {
  .tx-imgadm-search { grid-template-columns: 1fr; }
}

/* ---------- A destination page's hero (views/pages.js pageHero, photo given) ----------
   The place's own photo fills the hero behind the copy, in place of the shared coast picture, under the same navy
   wash on the copy's side. The figure makes no layer of its own: the photo goes under the wash (z-index -2, the
   wash is -1) and the credit above everything at the hero's foot, so it stays readable and clickable. */
.page-hero--photo::before { background: linear-gradient(90deg, rgba(8, 33, 64, .95) 0%, rgba(10, 40, 76, .86) 35%, rgba(12, 52, 96, .5) 65%, rgba(12, 52, 96, .2) 100%); }
.page-hero .page-hero-photo { position: absolute; inset: 0; width: auto; height: auto; aspect-ratio: auto; border-radius: 0; background: none; overflow: visible; container-type: normal; }
.page-hero .page-hero-photo img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: center 55%; }
.page-hero .page-hero-photo .tx-img-credit { z-index: 1; }
.page-hero .page-hero-photo.tx-img--tile { display: none; }
