/* Images and Videos: four layouts (justified, masonry, bento, editorial), the layout switcher and
   the preview. Every tile's box is computed in lib/medialayout.js and written inline (left, top,
   width, height, --mh picture height, --tl / --dl text lines); this file only dresses the boxes.
   Chrome uses the design tokens. The two values below are for text set ON a photograph, which
   has to be light on dark in both themes. */
.grid.media{display:block;position:relative;--ink:#fff;--shade:rgba(8,10,12,.82);--shade-0:rgba(8,10,12,0)}
.grid.media>.mt{position:absolute;min-width:0}
.grid.media>.mt:not([data-s]){visibility:hidden}

/* ---------- the tile ---------- */
.mt-media{position:relative;display:block;width:var(--mw,100%);height:var(--mh,100%);border-radius:var(--r-m);overflow:hidden;
  background:var(--surface-2) center/cover no-repeat;color:var(--text-3);cursor:zoom-in;text-decoration:none!important}
.mt-media:focus-visible{border-radius:var(--r-m);outline-offset:2px}
.mt-img{display:block;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .28s ease,transform .4s ease}
.mt-img.in{opacity:1}
@media (hover:hover){.mt:hover .mt-img{transform:scale(1.035)}}
.mt-ph{position:absolute;inset:0;display:grid;place-items:center;color:var(--text-3)}
.mt-ph svg{width:28px;height:28px}
.mt.is-boost .mt-media{box-shadow:0 0 0 2px var(--bg),0 0 0 4px var(--boost)}
.mt.is-bury{opacity:.5}
.mt.is-bury:hover,.mt.is-bury:focus-within{opacity:.9}
.mt-dur{position:absolute;right:6px;bottom:6px;padding:1px 6px;border-radius:var(--r-s);background:var(--shade);color:var(--ink);
  font-size:var(--fs-xs);font-weight:600;font-variant-numeric:tabular-nums;line-height:1.5}
.mt-ico{flex:none;width:14px;height:14px;border-radius:3px;object-fit:contain}

/* the caption under (or beside) the picture */
.mt-cap{height:calc(100% - var(--mh,0px));padding:6px 2px 0;display:flex;flex-direction:column;min-width:0;overflow:hidden}
.mt-title{font-size:var(--fs-s);line-height:var(--tlh,18px);font-weight:500;color:var(--text);max-height:calc(var(--tl,2)*var(--tlh,18px));
  display:-webkit-box;-webkit-line-clamp:var(--tl,2);-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;flex:none}
.mt-desc{font-size:var(--fs-xs);line-height:17px;color:var(--text-2);max-height:calc(var(--dl,0)*17px);
  display:-webkit-box;-webkit-line-clamp:var(--dl,1);-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;flex:none}
.mt-facts{font-size:var(--fs-xs);line-height:17px;height:17px;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:none}
.mt[data-f="0"] .mt-facts{display:none}
.mt-foot{display:flex;align-items:center;gap:6px;height:28px;min-width:0;color:var(--text-3);font-size:var(--fs-xs);flex:none}
.mt-foot .src{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mt-foot .bbb{margin-right:-2px}
@media (pointer:coarse){.mt-foot{height:34px}}
.mt[data-b="0"] .mt-foot{height:24px}
.mt[data-b="0"] .bbb,.mt[data-b="0"] .card-add{display:none}
.mt-foot .card-add{width:24px;height:24px;margin-left:-2px}
/* the up / down / x of a tile stay quiet until the tile is pointed at or focused (always there on touch) */
@media (hover:hover){
  .mt-foot .bbb,.mt-foot .card-add{opacity:0;transition:opacity .12s}
  .mt:hover .bbb,.mt:focus-within .bbb,.mt .bbb[data-tour],.mt .bbb:has([aria-pressed="true"]),.mt:hover .card-add,.mt:focus-within .card-add{opacity:1}
}

/* the overlay on the picture: title and source on a soft shade */
.mt-over{position:absolute;left:0;right:0;bottom:0;padding:34px 10px 8px;display:flex;flex-direction:column;gap:2px;pointer-events:none;
  background:linear-gradient(to top,var(--shade),var(--shade-0));color:var(--ink);opacity:0;transition:opacity .15s}
.mt-over .t{font-size:var(--fs-s);line-height:18px;font-weight:600;display:-webkit-box;-webkit-line-clamp:var(--tl,1);-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}
.mt-over .d{display:none;font-size:var(--fs-s);line-height:19px;opacity:.9;-webkit-line-clamp:var(--dl,2);-webkit-box-orient:vertical;overflow:hidden}
.mt-over .s{display:flex;align-items:center;gap:6px;font-size:var(--fs-xs);line-height:17px;opacity:.9;min-width:0}
.mt-over .s .src{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.mt[data-o="off"] .mt-over{display:none}
.mt[data-o="on"] .mt-over{opacity:1}
.mt[data-o="hover"]:hover .mt-over,.mt[data-o="hover"]:focus-within .mt-over,
.mt[data-o="hov"]:hover .mt-over,.mt[data-o="hov"]:focus-within .mt-over{opacity:1}
@media (hover:none){.mt[data-o="hover"] .mt-over{opacity:1}}                 /* touch: no hover, so it is simply there */
.mt[data-o="hov"] .mt-over .s{display:none}                                   /* the source is already in the caption */
.mt[data-o="hov"] .mt-over{padding-top:22px}
.mt[data-s="over"] .mt-dur{top:6px;left:6px;right:auto;bottom:auto}

/* overlay tiles have no caption: their up / down / x float in the corner */
.mt[data-s="over"] .mt-cap{position:absolute;top:6px;right:6px;height:auto;padding:0;overflow:visible}
.mt[data-s="over"] .mt-cap>:not(.mt-foot),.mt[data-s="over"] .mt-foot>:not(.bbb){display:none}
.mt[data-s="over"] .mt-foot{height:auto}
.mt[data-s="over"] .bbb{margin:0;padding:2px;border-radius:var(--r-m);background:var(--bg);box-shadow:var(--shadow)}
@media (hover:none){.mt[data-s="over"] .mt-cap{display:none}}                 /* on touch they are one tap away, in the preview */

/* a wide video card: the picture beside its text */
.mt[data-s="side"]{display:flex;gap:10px}
.mt[data-s="side"] .mt-media{flex:none}
.mt[data-s="side"] .mt-cap{flex:1;height:100%;padding:0 2px 0 0}
.mt[data-s="side"] .mt-foot{margin-top:auto}
.mt[data-s="side"] .mt-desc{display:none}

/* sizes: a feature tile, a hero */
.mt[data-z="big"] .mt-over{padding:48px 14px 12px}
.mt[data-z="big"] .mt-over .t{font-size:var(--fs-m);line-height:20px}
.mt[data-z="hero"] .mt-media{border-radius:var(--r-l)}
.mt[data-z="hero"] .mt-over{padding:72px 20px 16px;gap:4px}
.mt[data-z="hero"] .mt-over .t{font-size:var(--fs-xl);line-height:1.22;font-weight:600;letter-spacing:-.01em}
.mt[data-z="hero"][data-d="1"] .mt-over .d{display:-webkit-box}
@media (hover:none){.grid.media[data-kind="images"] .mt[data-z=""] .mt-over .t{display:none}}

/* ---------- per layout ---------- */
.grid.media[data-layout="justified"][data-kind="images"] .mt-media{border-radius:var(--r-s)}
.grid.media[data-layout="justified"][data-kind="images"] .mt-cap{padding-top:0}
.grid.media[data-layout="bento"] .mt-media{border-radius:var(--r-m)}
/* editorial: titles are captions, set like a magazine's */
.grid.media[data-layout="editorial"] .mt-title,.grid.media[data-layout="editorial"] .mt-over .t{font-family:ui-serif,"Iowan Old Style","Palatino Linotype",Georgia,serif}
.grid.media[data-layout="editorial"] .mt-title{font-size:var(--fs-m);font-weight:500}
.grid.media[data-layout="editorial"] .mt-media{border-radius:var(--r-s)}
.grid.media[data-layout="editorial"] .mt[data-z="hero"] .mt-media{border-radius:var(--r-m)}
@media (max-width:699px){.mt[data-z="hero"] .mt-over{padding:48px 14px 12px}.mt[data-z="hero"] .mt-over .t{font-size:var(--fs-l)}}

/* ---------- the layout switcher (a filter; the top row and the left rail) ---------- */
.mlay-wrap{display:inline-flex}
.mlay{display:inline-flex;gap:2px;padding:2px;border:1px solid var(--line-strong);border-radius:var(--r-pill);background:var(--bg)}
.mlay button{display:grid;place-items:center;width:36px;height:28px;padding:0;border:0;border-radius:var(--r-pill);background:transparent;color:var(--text-3)}
.mlay button:hover{color:var(--text);background:var(--surface)}
.mlay button[aria-checked="true"]{background:var(--accent-soft);color:var(--accent)}
.mlay svg{width:16px;height:16px;pointer-events:none}
@media (pointer:coarse){.mlay button{height:34px;width:40px}}
.rail .mlay{display:grid;grid-template-columns:repeat(4,1fr);width:100%;border-radius:var(--r-m)}
.rail .mlay button{width:auto;height:34px;border-radius:var(--r-s)}

/* ---------- preview ---------- */
dialog.lightbox{border:0;padding:0;background:var(--bg);color:var(--text);border-radius:var(--r-l);box-shadow:var(--shadow);
  width:min(1180px,calc(100vw - 24px));max-width:none;height:min(780px,calc(100dvh - 24px));max-height:none;overflow:hidden}
dialog.lightbox::backdrop{background:var(--scrim,rgba(10,14,18,.6))}
dialog.lightbox[open]{display:grid;grid-template-columns:minmax(0,1fr) 330px;grid-template-rows:minmax(0,1fr)}
.lb-stage{position:relative;min-width:0;min-height:0;background:var(--surface-2);display:grid}
.lb-pic{min-width:0;min-height:0;display:grid;place-items:center;padding:var(--s4);position:relative}
.lb-img{display:block;position:absolute;inset:var(--s4);margin:auto;width:calc(100% - 2*var(--s4));height:calc(100% - 2*var(--s4));object-fit:contain;border-radius:var(--r-s)}
.lb-video{position:absolute;inset:0;display:block;cursor:pointer}
.lb-play{position:absolute;left:50%;top:50%;width:68px;height:68px;margin:-34px 0 0 -34px;border-radius:50%;display:grid;place-items:center;
  background:var(--shade,rgba(8,10,12,.82));color:#fff;transition:transform .15s}
.lb-play svg{width:28px;height:28px;margin-left:3px;fill:currentColor}
.lb-video:hover .lb-play{transform:scale(1.08)}
.lb-nav{position:absolute;top:50%;margin-top:-20px;width:40px;height:40px;background:var(--bg);color:var(--text);box-shadow:var(--shadow);z-index:1}
.lb-nav:hover{background:var(--surface)}
.lb-nav:disabled{opacity:0;pointer-events:none}
.lb-prev{left:var(--s3)}
.lb-next{right:var(--s3)}
.lb-close{position:absolute;top:var(--s2);right:var(--s2);background:var(--bg);color:var(--text);z-index:2}
.lb-close:hover{background:var(--surface-2)}
.lb-info{min-width:0;min-height:0;overflow:auto;padding:var(--s5) var(--s5) var(--s4);display:flex;flex-direction:column;gap:var(--s3);border-left:1px solid var(--line)}
.lb-src{display:flex;align-items:center;gap:var(--s2);min-width:0;padding-right:36px;font-size:var(--fs-s)}
.lb-src .name{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--text);font-weight:500}
.lb-count{margin-left:auto;flex:none;color:var(--text-3);font-size:var(--fs-xs);font-variant-numeric:tabular-nums}
.lb-title{margin:0;font-size:var(--fs-l);line-height:1.3;font-weight:600;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;overflow:hidden}
.lb-facts{margin:0;display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px var(--s3);font-size:var(--fs-s)}
.lb-facts dt{color:var(--text-3)}
.lb-facts dd{margin:0;color:var(--text);overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
.lb-desc{margin:0;color:var(--text-2);font-size:var(--fs-s);line-height:1.5;overflow-wrap:anywhere}
.lb-actions{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s2);margin-top:var(--s2)}
.lb-actions .btn{text-decoration:none;white-space:nowrap}
.lb-actions .btn svg{width:14px;height:14px;flex:none}
.lb-actions .bbb{margin-left:auto}
.lb-hint{margin:0;color:var(--text-3);font-size:var(--fs-xs)}
@media (max-width:820px){
  dialog.lightbox{height:fit-content;max-height:calc(100dvh - 24px)}
  dialog.lightbox[open]{display:flex;flex-direction:column}
  .lb-stage{flex:none;width:100%;aspect-ratio:var(--ar,1.5);max-height:54dvh}
  .lb-pic{padding:0}
  .lb-img{inset:0;width:100%;height:100%;border-radius:0}
  .lb-info{flex:1 1 auto;border-left:0;padding:var(--s4)}
  .lb-src{padding-right:0}
  .lb-close{box-shadow:var(--shadow)}
  .lb-title{font-size:var(--fs-m);-webkit-line-clamp:3}
  .lb-actions .btn{flex:1;justify-content:center}
  .lb-hint{display:none}
}
