/* ==========================================================================
   FASTDELHIVERY — Media
   The Media page (media.html) and a post's own page (media-post.html).
   Loaded after base.css → layout.css → components.css, by those two pages
   only. Every rule is prefixed `fdm-`, so nothing here can reach another page.
   ========================================================================== */

/* ---- Filter bar ---------------------------------------------------------- */

.fdm-bar { display: grid; gap: 16px; margin-bottom: 18px; }

.fdm-bar__row { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }

.fdm-search {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 5px 5px 14px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.fdm-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.fdm-search__icon { color: var(--muted-2); display: grid; place-items: center; flex: none; }
.fdm-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: .93rem;
}
.fdm-search .btn { flex: none; border-radius: var(--r-pill); }

.fdm-select { flex: 0 1 240px; min-width: 180px; }
.fdm-select select {
  width: 100%;
  height: 100%;
  min-height: 50px;
  padding: 0 40px 0 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  background-color: #fff;
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink-700);
}
.fdm-select select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.fdm-select select[disabled] { opacity: .6; }

.fdm-types {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.fdm-type {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--ink-700);
  font-size: .87rem;
  font-weight: 700;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.fdm-type:hover { border-color: var(--brand); color: var(--brand-600); }
.fdm-type.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.fdm-type:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fdm-type__count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--bg-soft-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  text-align: center;
}
.fdm-type.is-active .fdm-type__count { background: rgba(255, 255, 255, .18); color: #fff; }

.fdm-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 24px;
  margin-bottom: 18px;
  font-size: .87rem;
  color: var(--muted);
}
.fdm-summary b { color: var(--ink); }
.fdm-summary__hint { font-size: .8rem; color: var(--muted-2); }

/* ---- Cards --------------------------------------------------------------- */

.fdm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
.fdm-grid.is-empty { grid-template-columns: minmax(0, 1fr); }

.fdm-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.fdm-card:hover { border-color: var(--brand-100); box-shadow: var(--sh-2); transform: translateY(-4px); }
.fdm-card--skeleton:hover { border-color: var(--line); box-shadow: none; transform: none; }

.fdm-card__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--bg-soft-2);
  overflow: hidden;
  color: var(--navy-500);
}
.fdm-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}
.fdm-card:hover .fdm-card__media img { transform: scale(1.04); }

.fdm-card__blank {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--bg-soft-2), var(--brand-50));
  color: var(--navy-500);
  opacity: .9;
}
.fdm-card__media--video .fdm-card__blank { background: linear-gradient(135deg, var(--navy), var(--navy-500)); color: #fff; }
.fdm-card__media--achievement .fdm-card__blank { background: linear-gradient(135deg, #fff6e6, var(--brand-100)); color: var(--brand-700); }

.fdm-card__type {
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  backdrop-filter: blur(4px);
}
.fdm-card__featured {
  position: absolute;
  right: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: var(--sh-brand);
}
.fdm-card--featured { border-color: var(--brand-100); }

.fdm-card__count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
}
.fdm-card__play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--sh-brand);
  padding-left: 3px;
  transition: transform var(--t-fast);
}
.fdm-card:hover .fdm-card__play { transform: scale(1.08); }

.fdm-card__body { display: flex; flex-direction: column; gap: 9px; padding: 18px 20px 20px; flex: 1 1 auto; min-width: 0; }
.fdm-card--skeleton .fdm-card__body { gap: 12px; }

.fdm-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: .76rem;
  font-weight: 600;
  color: var(--muted);
}
.fdm-card__cat {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fdm-card__title { margin: 0; font-size: 1.08rem; line-height: 1.35; letter-spacing: -.01em; overflow-wrap: anywhere; }
.fdm-card__title a {
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fdm-card__title a:hover { color: var(--brand-600); }

.fdm-card__excerpt {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.fdm-card__more { margin-top: auto; padding-top: 6px; align-self: flex-start; font-size: .86rem; }

.fdm-empty { grid-column: 1 / -1; }

.fdm-pagination__gap { align-self: center; color: var(--muted-2); padding: 0 2px; }

/* ---- A post's own page ---------------------------------------------------- */

.fdm-preview-banner {
  background: var(--warn-bg);
  border-bottom: 1px solid rgba(245, 158, 11, .35);
  color: #8a5a00;
  font-size: .86rem;
  font-weight: 700;
  padding: 10px 0;
}
.fdm-preview-banner .container { display: flex; align-items: center; gap: 9px; }

.fdm-article { max-width: 860px; margin: 0 auto; min-width: 0; }
.fdm-article[aria-busy="true"] { min-height: 320px; }

.fdm-article__tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.fdm-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  color: var(--brand-700);
  font-size: .76rem;
  font-weight: 700;
}
.fdm-tag--type { background: var(--navy); border-color: var(--navy); color: #fff; }
a.fdm-tag:hover { background: var(--brand-100); color: var(--brand-700); }
.fdm-tag--featured { background: var(--brand); border-color: var(--brand); color: #fff; }

.fdm-article__title {
  font-size: clamp(1.65rem, 1.2rem + 2vw, 2.6rem);
  line-height: 1.2;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}
.fdm-article__meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 600;
  margin-bottom: 18px;
}
.fdm-article__meta span { display: inline-flex; align-items: center; gap: 6px; }
.fdm-article__lead {
  font-size: clamp(1rem, .95rem + .35vw, 1.15rem);
  line-height: 1.7;
  color: var(--ink-700);
  white-space: pre-line;
  padding-left: 16px;
  border-left: 4px solid var(--brand);
  margin-bottom: 26px;
  overflow-wrap: anywhere;
}

.fdm-cover { margin: 0 0 28px; border-radius: var(--r-lg); overflow: hidden; background: var(--bg-soft-2); }
.fdm-cover img { width: 100%; max-height: 520px; object-fit: cover; }

.fdm-figure__open { display: block; width: 100%; cursor: zoom-in; }
.fdm-figure__open:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

/* The result card of an Achievement post */
.fdm-result {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
  margin-bottom: 28px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand-50), #fff6e6);
  border: 1px solid var(--brand-100);
}
.fdm-result__icon {
  width: 56px; height: 56px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--sh-brand);
}
.fdm-result__facts { display: flex; gap: 14px 36px; flex-wrap: wrap; margin: 0; min-width: 0; }
.fdm-result__facts dt { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-700); }
.fdm-result__facts dd { margin: 2px 0 0; font-size: 1.1rem; font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }

/* The article body */
.fdm-prose { font-size: 1.02rem; line-height: 1.85; color: var(--ink-700); overflow-wrap: anywhere; }
.fdm-prose > * + * { margin-top: 1.15em; }
.fdm-prose h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); margin: 1.7em 0 0; }
.fdm-prose h3 { font-size: clamp(1.1rem, 1rem + .4vw, 1.3rem); margin: 1.5em 0 0; }
.fdm-prose > h2:first-child, .fdm-prose > h3:first-child { margin-top: 0; }
.fdm-prose p { margin: 1.15em 0 0; }
.fdm-prose > p:first-child { margin-top: 0; }
.fdm-prose ul, .fdm-prose ol { padding-left: 24px; display: grid; gap: 8px; }
.fdm-prose ul { list-style: disc; }
.fdm-prose ol { list-style: decimal; }
.fdm-prose li { display: list-item; }
.fdm-prose a { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.fdm-figure { margin: 1.6em 0 0; }
.fdm-figure img { width: 100%; border-radius: var(--r); background: var(--bg-soft-2); }
.fdm-figure figcaption,
.fdm-gallery__item figcaption {
  margin-top: 8px;
  font-size: .84rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* Video */
.fdm-video { margin: 1.6em 0 0; }
.fdm-article > .fdm-video { margin: 0 0 28px; }
.fdm-video__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--sh-2);
}
.fdm-video--portrait .fdm-video__frame { aspect-ratio: 9 / 16; max-width: 380px; margin: 0 auto; }
.fdm-video--instagram .fdm-video__frame { aspect-ratio: 4 / 5; max-width: 480px; margin: 0 auto; background: #fff; border: 1px solid var(--line); }
.fdm-video__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.fdm-video__link { margin: 10px 0 0; text-align: center; font-size: .86rem; }
.fdm-video__link a { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.fdm-video--link { padding: 18px; border: 1px dashed var(--line); border-radius: var(--r); }
.fdm-video--link .fdm-video__link { margin: 0; }

/* Gallery */
.fdm-gallery { margin-top: 36px; }
.fdm-gallery__title { display: flex; align-items: center; gap: 9px; font-size: 1.25rem; margin-bottom: 16px; }
.fdm-gallery__title span { color: var(--muted); font-weight: 600; font-size: .95rem; }
.fdm-gallery__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fdm-gallery__grid--single { grid-template-columns: minmax(0, 1fr); }
.fdm-gallery__item { margin: 0; min-width: 0; }
.fdm-gallery__item button {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg-soft-2);
  cursor: zoom-in;
}
.fdm-gallery__grid--single .fdm-gallery__item button { aspect-ratio: auto; }
.fdm-gallery__item button:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.fdm-gallery__item img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow); }
.fdm-gallery__grid--single .fdm-gallery__item img { height: auto; }
.fdm-gallery__item button:hover img { transform: scale(1.05); }

.fdm-article__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.fdm-share { display: flex; align-items: center; gap: 8px; }
.fdm-share__label { font-size: .8rem; font-weight: 700; color: var(--muted); margin-right: 2px; }

/* Lightbox */
.fdm-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 56px 64px;
  background: rgba(0, 0, 0, .93);
}
.fdm-lightbox[hidden] { display: none; }
.fdm-lightbox__stage { margin: 0; max-width: 100%; max-height: 100%; display: grid; justify-items: center; gap: 12px; min-height: 0; }
.fdm-lightbox__stage img { max-width: 100%; max-height: calc(100dvh - 160px); object-fit: contain; border-radius: var(--r-sm); }
.fdm-lightbox__stage figcaption { color: #e0e0e0; font-size: .9rem; text-align: center; max-width: 720px; }
.fdm-lightbox__btn {
  position: absolute;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  transition: background var(--t-fast);
}
.fdm-lightbox__btn:hover { background: rgba(255, 255, 255, .26); }
.fdm-lightbox__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fdm-lightbox__btn[hidden] { display: none; }
.fdm-lightbox__close { top: 14px; right: 14px; }
.fdm-lightbox__prev { left: 12px; top: 50%; margin-top: -23px; }
.fdm-lightbox__next { right: 12px; top: 50%; margin-top: -23px; }
.fdm-lightbox__count { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; color: #b3b3b3; font-size: .82rem; font-weight: 700; }

/* ---- Smaller screens ------------------------------------------------------ */

@media (max-width: 980px) {
  .fdm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .fdm-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .fdm-select { flex: 1 1 100%; }
  .fdm-search .btn { padding-left: 14px; padding-right: 14px; }
  .fdm-gallery__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fdm-result { flex-direction: column; align-items: flex-start; padding: 18px; }
  .fdm-lightbox { padding: 60px 10px 46px; }
  .fdm-lightbox__prev { left: 6px; }
  .fdm-lightbox__next { right: 6px; }
  .fdm-article__foot { flex-direction: column; align-items: stretch; }
  .fdm-article__foot .btn { justify-content: center; }
  .fdm-share { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .fdm-card, .fdm-card__media img, .fdm-gallery__item img, .fdm-card__play { transition: none; }
  .fdm-card:hover { transform: none; }
}
