html,
body {
  background: #fff;
  margin: 0;
  padding: 0;
  font-family: "Inter", "Helvetica", sans-serif;
  color: #000;
}

/* subtle, monochrome vignette */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(
    80% 60% at 50% 20%,
    rgba(0, 0, 0, 0.06),
    rgba(0, 0, 0, 0) 60%
  );
  pointer-events: none;
  z-index: 0;
}

header,
footer {
  text-align: center;
  padding: 22px 0;
  border-bottom: 1px solid #000;
  background: #fff;
  position: relative;
  z-index: 1;
}
footer {
  border-bottom: 0;
  border-top: 1px solid #000;
}

h1 {
  font-weight: 500;
  letter-spacing: -0.5px;
  font-size: 32px;
  margin: 0;
}

main {
  min-height: 80vh;
  position: relative;
  z-index: 1;
}

#resources-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 28px 16px 40px;
}

/* smaller, tighter resource tile */
.resource {
  border: 1px solid #000;
  padding: 14px 12px;
  background: #fff;
  width: 120px; /* tighter */
  min-height: 86px; /* compact */
  border-radius: 10px;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.resource:hover {
  box-shadow: var(--shadow-elev-1);
  transform: translateY(-2px);
}

.resource img {
  width: 56px; /* smaller icon */
  height: 56px;
  margin-bottom: 8px;
  filter: grayscale(100%) contrast(130%);
  object-fit: contain;
}

.resource p {
  color: inherit;
  font-size: 12.5px;
  line-height: 1.25;
  text-align: center;
  word-break: break-word;
  max-width: 100%;
  margin: 0;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ---------- Preview Modal ---------- */
.preview-backdrop[hidden] {
  display: none !important;
}
.preview-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 9999;
  animation: fadeIn 0.12s ease-out;
}

.preview-modal {
  position: relative;
  width: min(94vw, 980px);
  height: min(86vh, 820px);
  background: #fff;
  border: 1px solid #000;
  border-radius: 14px;
  box-shadow: var(--shadow-elev-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  border-radius: 10px;
  font-size: 22px;
  line-height: 32px;
  cursor: pointer;
}
.preview-close:hover {
  box-shadow: var(--shadow-button-hover);
  background-color: #ddc3c3;
}

.preview-download {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 8px 12px;
  border: 1px solid #000;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
}
.preview-download:hover {
  box-shadow: var(--shadow-button-hover);
  background-color: #c4ddc3;
}

.preview-content {
  margin-top: 56px; /* leave space for buttons */
  height: calc(100% - 56px);
  overflow: auto;
}

/* embedded viewers */
.preview-content iframe,
.preview-content embed {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* text preview */
.preview-text {
  padding: 18px 20px 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;

  /* Ensure explicit, high-contrast background + text so mobile dark-mode UA renderers don't produce black-on-black */
  background: #ffffff;
  color: #000000;
  border-top: 1px solid #e6e6e6;
  margin: 0;
  height: 100%;
  overflow: auto;
}

/* Dark mode preview-text override */
html.dark .preview-text {
  background: #0b0b0b;
  color: #efefef;
  border-top-color: rgba(255,255,255,0.06);
}

/* tiny animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.preview-share {
  position: absolute;
  top: 10px;
  left: 108px; /* next to Download */
  padding: 8px 12px;
  border: 1px solid #000;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.preview-share:hover {
  box-shadow: var(--shadow-button-hover);
  background-color: #dddbc3;
}

/* New: raw share button (aligned to the right of the "Share" button) */
.preview-share-raw {
  position: absolute;
  top: 10px;
  left: 184px; /* right of the Share button */
  padding: 8px 12px;
  border: 1px solid #000;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.preview-share-raw:hover {
  box-shadow: var(--shadow-button-hover);
  background-color: #c3ddff;
}

/* Theme toggle button */
.theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 8px 12px;
  border: 1px solid #000;
  border-radius: 10px;
  background: #fff;
  color: #000;
  font-size: 13px;
  cursor: pointer;
}
.theme-toggle:hover { box-shadow: var(--shadow-button-hover); }

/* Add shadow variables so we can swap them in dark mode */
:root {
  /* stronger, layered shadows for light mode */
  --shadow-elev-1: 0 10px 30px rgba(0, 0, 0, 0.30), 0 2px 6px rgba(0, 0, 0, 0.12);
  --shadow-elev-2: 0 32px 80px rgba(0, 0, 0, 0.45), 0 8px 20px rgba(0, 0, 0, 0.18);
  --shadow-button-hover: 0 8px 24px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.10);
}

/* Dark mode overrides (applied by adding 'dark' to <html>) */
html.dark,
html.dark body {
  background: #0b0b0b;
  color: #efefef;
}

/* Override shadows in dark mode to be stronger light-glows so they remain visible */
html.dark {
  /* layered light glow + subtle inner soft shadow for depth */
  --shadow-elev-1: 0 10px 30px rgba(255, 255, 255, 0.3), 0 2px 6px rgba(255, 255, 255, 0.12);
  --shadow-elev-2: 0 36px 90px rgba(255, 255, 255, 0.45), 0 10px 28px rgba(255, 255, 255, 0.18);
  --shadow-button-hover: 0 8px 24px rgba(255, 255, 255, 0.32), 0 2px 6px rgba(255, 255, 255, 0.10);
}
html.dark header,
html.dark footer,
html.dark .preview-modal,
html.dark .resource {
  background: #0b0b0b;
  color: #efefef;
  border-color: #efefef;
}
html.dark body::before {
  background: radial-gradient(
    80% 60% at 50% 20%,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0) 60%
  );
}
html.dark .preview-backdrop {
  background: rgba(0, 0, 0, 0.6);
}
html.dark .resource img {
  /* invert icons on dark bg so black/transparent icons become light-on-dark */
  filter: invert(1) grayscale(100%) contrast(130%);
}
html.dark .preview-close,
html.dark .preview-download,
html.dark .preview-share,
html.dark .preview-share-raw,
html.dark .theme-toggle {
  background: #0b0b0b;
  color: #efefef;
  border-color: #efefef;
}
html.dark .preview-close:hover { background-color: #552b2b; }
html.dark .preview-download:hover { background-color: #274227; }
html.dark .preview-share:hover { background-color: #605f2a; }
html.dark .preview-share-raw:hover { background-color: #2a4b76; }
