/* ==========================================================================
   Y.H. Securities — Files
   Cards + grid for the shared Files API module (files.js). Reusable across
   pages: relies on the site's CSS variables (--navy, --gold, --gold-d,
   --gray/--gd, --border, --bg-gray, --text-*) with safe fallbacks so it works
   on index.html's in-page theme, the components.css theme, and styles.css.
   ========================================================================== */

/* ── Section ── */
#files-section {
  padding: 5rem 0;
  background: #fff;
}

/* ── Grid: 2 → 3 → 4+ columns ── */
.files-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
@media (min-width: 640px) { .files-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .files-grid { grid-template-columns: repeat(4, 1fr); } }

/* ── Card ── */
.file-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e6eaf0);
  border-radius: .5rem;
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.file-card:hover {
  border-color: var(--gold, #C9A84C);
  transform: translateY(-4px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .1);
}

/* media area */
.file-card-media {
  position: relative;
  background: #fff;
  border-bottom: 1px solid var(--border, #e6eaf0);
}
.file-card-thumb-link,
.file-card-icon-link {
  display: block;
  text-decoration: none;
}
.file-card-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  padding: .625rem;
  box-sizing: border-box;
  display: block;
}
.file-card-thumb-link:hover .file-card-thumb {
  opacity: .9;
}
.file-card-icon {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, var(--navy, #101722), var(--navy-l, hsl(220, 30%, 18%)));
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-card-icon svg {
  color: var(--gold, #C9A84C);
  opacity: .85;
}

/* video player cards (rendered by files.js for mime video/*) */
.file-card-video {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, var(--navy, #101722), var(--navy-l, hsl(220, 30%, 18%)));
  overflow: hidden;
}
.file-card-video-player {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.file-card-play {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* native <video> controls stay clickable underneath */
  color: var(--gold, #C9A84C);
  opacity: 1;
  transition: opacity .2s ease, visibility .2s ease;
}
.file-card-play svg {
  width: 3rem;
  height: 3rem;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .45));
}
.file-card-play.is-hidden {
  opacity: 0;
  visibility: hidden;
}
.file-card-video.is-error {
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-card-error {
  margin: 0;
  padding: 0 1rem;
  color: var(--gold, #C9A84C);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: center;
}

/* body */
.file-card-body {
  padding: .875rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  align-items: flex-start;
  flex: 1;
}
.file-card-name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--navy, #101722);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.file-card-meta {
  font-size: .7rem;
  color: var(--text-secondary, var(--gd, hsl(220, 10%, 40%)));
}
.file-card-badge {
  margin-top: .25rem;
  display: inline-flex;
  align-items: center;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .2rem .55rem;
  background: var(--navy, #101722);
  color: var(--gold, #C9A84C);
  text-transform: uppercase;
  width: fit-content;
  border-radius: .1875rem;
}

/* download control (added to every card body by files.js) */
.file-card-download {
  margin-top: .5rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1;
  padding: .45rem .8rem;
  color: var(--gold, #C9A84C);
  background: var(--navy, #101722);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.file-card-download:hover,
.file-card-download:focus-visible {
  color: var(--navy, #101722);
  background: var(--gold, #C9A84C);
  border-color: var(--gold, #C9A84C);
}
.file-card-download:focus-visible {
  outline: 2px solid var(--gold, #C9A84C);
  outline-offset: 2px;
}
.file-card-download .file-card-download-icon {
  flex-shrink: 0;
}
.file-card-download[disabled].downloading {
  opacity: .65;
  cursor: default;
  color: var(--gold, #C9A84C);
  background: var(--navy, #101722);
}
.file-card-download[disabled].downloading:hover,
.file-card-download[disabled].downloading:focus-visible {
  color: var(--gold, #C9A84C);
  background: var(--navy, #101722);
  border-color: transparent;
}

/* ── Loading / empty / error states ── */
.files-state {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--text-secondary, var(--gd, hsl(220, 10%, 40%)));
  font-size: .875rem;
  text-align: center;
}
.files-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border, #e6eaf0);
  border-top-color: var(--gold, #C9A84C);
  border-radius: 50%;
  animation: files-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes files-spin {
  to { transform: rotate(360deg); }
}

/* ── Lightbox (self-contained, built by files.js) ── */
.files-lb {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 14, 31, .9);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.files-lb.open {
  display: flex;
  animation: files-lb-in .18s ease-out;
}
.files-lb-box {
  position: relative;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: .5rem;
  overflow: hidden;
}
.files-lb-img {
  width: 100%;
  height: auto;
  max-height: 78vh;
  object-fit: contain;
  background: #fff;
  display: block;
}
.files-lb-meta {
  padding: .75rem 1.25rem;
  font-size: .78rem;
  color: var(--gd, hsl(220, 10%, 40%));
  border-top: 1px solid var(--border, #e6eaf0);
  font-family: 'Inter', sans-serif;
}
.files-lb-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 1.1rem;
  border: none;
  cursor: pointer;
  transition: background .2s, color .2s;
  z-index: 10000;
  font-family: 'Inter', sans-serif;
}
.files-lb-close:hover {
  background: var(--gold, #C9A84C);
  color: var(--navy, #101722);
}
body.files-lb-lock {
  overflow: hidden;
}

@keyframes files-lb-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Reduced motion: drop the hover lift + lightbox fade ── */
@media (prefers-reduced-motion: reduce) {
  .file-card {
    transition: border-color .2s ease;
  }
  .file-card:hover {
    transform: none;
    box-shadow: none;
  }
  .files-lb.open {
    animation: none;
  }
  .file-card-play {
    transition: none;
  }
}
