/* =========================
   Archive Overlay
   Link AFTER style.css in <head>
========================= */

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  scrollbar-gutter: stable;
}

/* ── Backdrop ── */
.archive-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  background: rgba(7, 7, 7, 0.85);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--e-smooth);
}
.archive-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Main close (whole overlay) ── */
.archive-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  font-size: 18px;
  z-index: 1100;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}
.archive-close:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.07);
}

/* ── Stage ── */
.archive-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 44px;
  max-width: min(1080px, 94vw);
  width: 100%;
  margin: auto;
  padding: 80px 0 60px;
  /* flex-shrink:0 lets the stage grow beyond viewport → enables scroll */
  flex-shrink: 0;
  transform: translateY(20px);
  transition: transform 0.4s var(--e-smooth);
}
.archive-overlay.open .archive-stage {
  transform: translateY(0);
}

/* ── Card column ── */
.archive-card-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-shrink: 0;
  /* keep card column independent from project stack height */
  align-self: center;
}
.archive-card-col .card {
  transform: rotate(-4deg) !important;
  opacity: 1 !important;
  cursor: pointer;
  transition: transform 0.4s var(--e-smooth) !important;
}
.archive-card-col .card:hover {
  transform: rotate(-2deg) scale(1.04) !important;
}
.archive-flip-hint {
  font-family: var(--font-special);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65); /* ← was 0.3 */
  text-align: center;
  user-select: none;
  animation: hint-pulse 2.6s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.75;
  }
}

/* ══════════════════════════════════════════
   ARCHIVE BOX
   ══════════════════════════════════════════ */

.archive-box {
  flex: 1;
  min-width: 0;
  padding-top: 44px;
  position: relative;
  /* guarantee enough height for card centering even with 0-1 projects */
  min-height: min(420px, 60vh);
}

.archive-box.archive-box--empty {
  min-height: 0;
}

.archive-tray {
  background: #1a1a1a;
  border-top: 10px solid #111;
  border-left: 10px solid #111;
  border-right: 10px solid #111;
  border-radius: 4px 4px 0 0;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.35);
  padding: 0 10px 12px;
  position: relative;
}

.archive-tray-bottom {
  background: #111;
  border-radius: 0 0 8px 8px;
  padding: 28px 20px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6);
}

.archive-tray-label {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  padding: 5px 24px;
  font-family: var(--font-special);
  font-size: 15px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  user-select: none;
}

/* Stack wrapper — height set by JS */
.archive-stack {
  position: relative;
  width: 100%;
}

/* ── Individual file card ── */
.archive-file-card {
  position: absolute;
  left: 0;
  right: 0;
  cursor: pointer;
  padding-top: 30px;
  margin-top: -30px;
  overflow: visible;
  transition: transform 0.22s var(--e-smooth);
}
.archive-file-card:hover {
  transform: translateY(-13px) !important;
}

.archive-file-paper {
  background: #f0ece4;
  border: 1px solid #c8c0b0;
  border-radius: 4px 4px 2px 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  position: relative;
  min-height: 34px;
  transition: box-shadow 0.22s ease;
}
.archive-file-card:hover .archive-file-paper {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
}

.archive-file-tab {
  position: absolute;
  top: -26px;
  height: 28px;
  min-width: 90px;
  max-width: 200px;
  padding: 0 14px;
  background: #f0ece4;
  border: 1px solid #c8c0b0;
  border-bottom: none;
  border-top: 3px solid var(--nub-stripe, #c8c0b0);
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  font-family: var(--font-special);
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: #3a3028;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.archive-file-card:nth-child(4n + 1) .archive-file-tab {
  left: 4%;
}
.archive-file-card:nth-child(4n + 2) .archive-file-tab {
  left: 26%;
}
.archive-file-card:nth-child(4n + 3) .archive-file-tab {
  left: 50%;
}
.archive-file-card:nth-child(4n + 0) .archive-file-tab {
  left: 70%;
}

/* ══════════════════════════════════════════
   FULL-PAGE FILE OVERLAY
   ══════════════════════════════════════════ */

.archive-file-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--e-smooth);
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 60px 24px 40px;
}
.archive-file-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.archive-image-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.archive-image-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.archive-image-preview {
  max-width: min(1200px, 92vw);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #111;
}

.archive-image-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.archive-image-close:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.58);
}

.archive-file-page {
  --archive-file-shift: 0px;
  --archive-file-y-shift: 0px;
  background: #f5f1e8;
  border: 1px solid #bdb5a5;
  border-radius: 6px 6px 3px 3px;
  width: min(800px, 92vw);
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  transform: translate(
    var(--archive-file-shift),
    calc(16px + var(--archive-file-y-shift))
  );
  transition: transform 0.32s var(--e-smooth);
  margin: auto;
}
.archive-file-overlay.visible .archive-file-page {
  transform: translate(var(--archive-file-shift), var(--archive-file-y-shift));
}

.archive-file-page-tab {
  position: absolute;
  top: -28px;
  left: 6%;
  height: 30px;
  min-width: 100px;
  max-width: 220px;
  padding: 0 16px;
  background: #f5f1e8;
  border: 1px solid #bdb5a5;
  border-bottom: none;
  border-top: 3px solid var(--nub-stripe, #bdb5a5);
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  font-family: var(--font-special);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #1a1510;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.archive-file-page-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 1;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}
.archive-file-page-close:hover {
  background: rgba(255, 255, 255, 1);
  color: rgba(0, 0, 0, 0.9);
  border-color: rgba(0, 0, 0, 0.3);
}

/* ── Two-column body ── */
.archive-file-page-body {
  display: flex;
  overflow: hidden;
  min-height: 220px;
  max-height: 58vh;
}

/* Left column — text */
.archive-file-page-body-inner {
  flex: 1;
  min-width: 0;
  padding: 18px 20px 24px;
  /*overflow-y: auto;*/
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  animation: body-in 0.28s var(--e-smooth) both;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}
.archive-file-page-body-inner::-webkit-scrollbar {
  width: 4px;
}
.archive-file-page-body-inner::-webkit-scrollbar-track {
  background: transparent;
}
.archive-file-page-body-inner::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* Right column — images */
.archive-file-images-col {
  width: 45%;
  flex-shrink: 0;
  padding: 18px 16px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}
.archive-file-images-col::-webkit-scrollbar {
  width: 4px;
}
.archive-file-images-col::-webkit-scrollbar-track {
  background: transparent;
}
.archive-file-images-col::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

@keyframes body-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Image layout ──
   JS groups images into .archive-img-row divs:
   - wide images get their own row (full width)
   - two consecutive verticals share a row side by side
   - a lone vertical centers itself
*/
.archive-images {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.archive-img-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

/* Wide image — fills the row */
.archive-img-row img.archive-img--wide {
  width: 100%;
  margin: 0;
}

/* Lone vertical — natural width, centered */
.archive-img-row:not(.archive-img-row--pair) img:not(.archive-img--wide) {
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

/* Paired verticals — split the row equally */
.archive-img-row--pair img {
  width: calc(50% - 3px);
  flex-shrink: 0;
}

/* All images share these */
.archive-img-row img {
  min-height: 120px;
  max-height: 320px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: block;
  cursor: zoom-in;
}

.archive-no-img {
  background: rgba(0, 0, 0, 0.04);
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-special);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: rgba(40, 30, 20, 0.35);
  text-transform: uppercase;
}

/* ── Text content ── */
.archive-description {
  font-family: var(--font-base);
  font-size: 13.5px;
  line-height: 1.65;
  color: #2a2018;
  margin: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.archive-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.archive-meta-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 11.5px;
}
.archive-meta-label {
  font-family: var(--font-special);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(40, 30, 20, 0.45);
  min-width: 68px;
  flex-shrink: 0;
}
.archive-meta-value {
  font-family: var(--font-base);
  color: #3a2c1e;
}

.archive-meta-section {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.archive-type-badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 2px;
  border: 1.5px solid;
  font-family: var(--font-special);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  transform: rotate(-1.5deg);
}

.archive-status-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 13px;
  border-radius: 3px;
  border: 2px solid;
  font-family: var(--font-special);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 700;
  transform: rotate(-3deg);
  opacity: 0.85;
  position: relative;
}
.archive-status-stamp::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid currentColor;
  opacity: 0.25;
  border-radius: 1px;
}
.archive-status-stamp--done {
  border-color: #1a7820;
  color: #1a7820;
}
.archive-status-stamp--progress {
  border-color: #a06000;
  color: #b87800;
}
.archive-status-stamp--archived {
  border-color: #888;
  color: #888;
}

.archive-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.archive-tag {
  display: inline-block;
  padding: 3px 9px;
  background: transparent;
  border: 1px solid rgba(80, 60, 40, 0.3);
  border-radius: 20px;
  font-family: var(--font-special);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(40, 30, 20, 0.6);
  position: relative;
}
.archive-tag::before {
  content: "#";
  margin-right: 1px;
  opacity: 0.5;
}

.archive-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.archive-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border: 1px solid rgba(80, 60, 40, 0.2);
  border-radius: 3px;
  font-family: var(--font-special);
  font-size: 11px;
  letter-spacing: 0.3px;
  color: #2a2018;
  text-decoration: none;
  background: transparent;
  transition:
    background var(--t-med) ease,
    border-color var(--t-med) ease;
}
.archive-link svg {
  flex-shrink: 0;
  opacity: 0.35;
  transition: opacity var(--t-med) ease;
}
.archive-link:hover {
  background: rgba(80, 60, 40, 0.06);
  border-color: rgba(80, 60, 40, 0.45);
}
.archive-link:hover svg {
  opacity: 0.7;
}

.archive-empty {
  font-family: var(--font-special);
  font-size: 13px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  padding: 40px 0;
}

/* ── Mobile ── */
@media (max-width: 700px) {
  .archive-overlay {
    padding-top: 80px;
  }

  .archive-stage {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 24px 12px 60px;
    margin: 0 auto;
  }
  .archive-card-col {
    flex-direction: column;
    gap: 14px;
    align-items: center;
    justify-content: flex-start;
    align-self: auto;
  }
  .archive-card-col .card {
    width: var(--card-w-mobile) !important;
    height: var(--card-h-mobile) !important;
  }
  .archive-box {
    width: 100%;
    flex: 1;
    min-width: 0;
    padding-top: 44px;
    position: relative;
  }

  .archive-box.archive-box--empty {
    min-height: 0;
  }

  .archive-file-overlay {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 56px 20px 40px;
    justify-content: flex-start;
  }

  .archive-file-page {
    --archive-file-shift: 0px;
    --archive-file-y-shift: 0px;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    height: auto !important;
    margin: auto 0;
    /*margin-top: 14px;*/
    margin-top: auto;
    margin-bottom: auto;
  }

  .archive-file-page-body {
    flex-direction: column;
    max-height: none !important;
    overflow: visible !important;
    height: auto !important;
  }

  .archive-file-page-body-inner {
    overflow-y: visible !important;
    max-height: none !important;
    height: auto !important;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 14px 14px 16px;
  }

  .archive-file-images-col {
    width: 100%;
    overflow-y: visible !important;
    max-height: none !important;
    height: auto !important;
    padding: 14px 14px 18px;
  }

  .archive-file-card:nth-child(4n + 1) .archive-file-tab {
    left: 4%;
  }
  .archive-file-card:nth-child(4n + 2) .archive-file-tab {
    left: 20%;
  }
  .archive-file-card:nth-child(4n + 3) .archive-file-tab {
    left: 38%;
  }
  .archive-file-card:nth-child(4n + 0) .archive-file-tab {
    left: 30%;
  }
}
