/* ============================================================
   MORGUE DRAWER GRID — Personal Portfolio
   ============================================================ */

/* --- Reset & Base --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: #0B0F12;
  color: #A8B2B6;
  font-family: 'Newsreader', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Scrollbar --- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0B0F12;
}

::-webkit-scrollbar-thumb {
  background: #2A353B;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3A454B;
}

/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: #2A353B #0B0F12;
}

/* --- Selection --- */

::selection {
  background: rgba(0, 229, 255, 0.12);
  color: #e0e5e8;
}

::-moz-selection {
  background: rgba(0, 229, 255, 0.12);
  color: #e0e5e8;
}

/* --- Focus --- */

:focus-visible {
  outline: 2px solid #AEB7BA;
  outline-offset: 2px;
}

/* --- Links --- */

a {
  color: #A98C5A;
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover {
  text-decoration: underline;
  color: #c4a46e;
}

/* ============================================================
   SKIP LINK (Accessibility)
   ============================================================ */

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 2000;
  padding: 8px 16px;
  background: #0B0F12;
  color: #D8DED9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  border: 1px solid #AEB7BA;
  border-radius: 2px;
  text-decoration: none;
  transition: top 150ms ease;
}

.skip-link:focus {
  top: 8px;
}

/* ============================================================
   CASE-FILE HEADER (Above-fold identity)
   ============================================================ */

.case-file {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: #070A0D;
  border-bottom: 1px solid #1A2025;
  padding: 10px 24px;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.case-file__id {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.case-file__name {
  font-size: 13px;
  font-weight: 700;
  color: #D8DED9;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.case-file__role {
  font-size: 10px;
  color: #7E8A95;
  letter-spacing: 0.03em;
}

.case-file__divider {
  width: 1px;
  height: 28px;
  background: #1E272C;
  flex-shrink: 0;
}

.case-file__thesis {
  font-size: 11px;
  color: #A8B2B6;
  font-style: italic;
  font-family: 'Newsreader', serif;
  flex: 1;
  min-width: 200px;
}

.case-file__stats {
  font-size: 10px;
  color: #7E8A95;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.case-file__stats strong {
  color: #D8DED9;
  font-weight: 600;
}

.case-file__links {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.case-file__links a {
  font-size: 10px;
  color: #A98C5A;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 2px 6px;
  border: 1px solid rgba(169, 140, 90, 0.25);
  border-radius: 2px;
  transition: border-color 150ms ease, color 150ms ease;
}

.case-file__links a:hover {
  border-color: #A98C5A;
  color: #c4a46e;
  text-decoration: none;
}

/* ============================================================
   AUTOPSY RAIL (Fixed Filter Header)
   ============================================================ */

.autopsy-rail {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #090D10;
  border-bottom: 1px solid #1E272C;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Scroll affordance fade on right edge */
.autopsy-rail::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, #090D10);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

.autopsy-rail.has-overflow::after {
  opacity: 1;
}

.autopsy-rail__filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #1E272C;
  border-radius: 3px;
  background: transparent;
  color: #A8B2B6;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
  white-space: nowrap;
}

.autopsy-rail__filter:hover {
  border-color: #AEB7BA;
  color: #D8DED9;
}

.autopsy-rail__filter.is-active {
  border-color: #AEB7BA;
  background: #1A2329;
  color: #D8DED9;
}

.autopsy-rail__filter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.autopsy-rail__filter-dot--dead { background: #B84A4A; }
.autopsy-rail__filter-dot--alive { background: #8A9B8F; }
.autopsy-rail__filter-dot--attack { background: #D6A84F; }
.autopsy-rail__filter-dot--papers { background: #AEB7BA; }
.autopsy-rail__filter-dot--systems { background: #7E8FA8; }
.autopsy-rail__filter-dot--ghosts { background: #9A8BB3; }

.autopsy-rail__count {
  color: #8A969B;
  margin-left: 2px;
}

/* ============================================================
   ARIA-LIVE ANNOUNCER (visually hidden)
   ============================================================ */

.filter-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   MAIN GRID
   ============================================================ */

.morgue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 130px 40px 40px 40px;
  max-width: 960px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .morgue-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 130px 20px 20px 20px;
  }

  .drawer--wide {
    grid-column: span 2;
  }
}

@media (max-width: 480px) {
  .morgue-grid {
    grid-template-columns: 1fr;
  }

  .drawer--wide {
    grid-column: span 1;
  }
}

/* ============================================================
   DRAWER BASE
   ============================================================ */

.drawer {
  background: #161D21;
  border: 1px solid #1E272C;
  border-radius: 2px;
  position: relative;
  min-width: 0;
  transition: border-color 300ms ease, box-shadow 300ms ease;
}

/* Metallic top highlight */
.drawer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, #2A353B 30%, #3A454B 50%, #2A353B 70%, transparent 100%);
  border-radius: 2px 2px 0 0;
  pointer-events: none;
}

/* --- Wide Drawer --- */

.drawer--wide {
  grid-column: span 2;
}

/* --- Hidden (filtered out) --- */

.drawer--hidden {
  display: none;
}

/* ============================================================
   DRAWER HANDLE (Closed State Button)
   ============================================================ */

.drawer__handle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 18px;
  border: none;
  background: transparent;
  color: #D8DED9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background-color 150ms ease;
}

.drawer__handle:hover {
  background: #1A2329;
}

.drawer__handle:focus-visible {
  outline: 2px solid #D6A84F;
  outline-offset: -2px;
}

/* Pull indicator bar */
.drawer__handle::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: #2A353B;
  border-radius: 2px;
  transition: background-color 150ms ease;
}

.drawer__handle:hover::after {
  background: #AEB7BA;
}

.drawer.is-open .drawer__handle::after {
  background: #AEB7BA;
}

/* --- Drawer ID --- */

.drawer__id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #8A969B;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* --- Drawer Title --- */

.drawer__title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: #D8DED9;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Status LED --- */

.drawer__led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.drawer__led--dead {
  background: #B84A4A;
  box-shadow: 0 0 4px #B84A4A;
}

.drawer__led--alive {
  background: #8A9B8F;
  box-shadow: 0 0 4px #8A9B8F;
}

.drawer__led--attack {
  background: #D6A84F;
  box-shadow: 0 0 4px #D6A84F;
}

.drawer__led--papers {
  background: #AEB7BA;
  box-shadow: 0 0 4px #AEB7BA;
}

.drawer__led--systems {
  background: #7E8FA8;
  box-shadow: 0 0 4px #7E8FA8;
}

.drawer__led--ghosts {
  background: #9A8BB3;
  box-shadow: 0 0 4px #9A8BB3;
}

.drawer__led--changelog {
  background: #8F9A9C;
  box-shadow: 0 0 4px #8F9A9C;
}

.drawer__led--links {
  background: #AEB7BA;
  box-shadow: 0 0 4px #AEB7BA;
}

.drawer__led--vacant {
  background: #8F9A9C;
}

/* --- Verified Date --- */

.drawer__date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #8A969B;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ============================================================
   DRAWER CONTENT (Open State)
   ============================================================ */

.drawer__content {
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height 300ms ease, padding 300ms ease, opacity 300ms ease, visibility 300ms ease;
  opacity: 0;
  padding: 0 18px;
  font-family: 'Newsreader', sans-serif;
  font-size: 14px;
  line-height: 1.65;
  color: #A8B2B6;
}

.drawer.is-open .drawer__content {
  max-height: 600px;
  visibility: visible;
  opacity: 1;
  padding: 12px 18px 20px 18px;
}

.drawer.is-opening .drawer__content {
  will-change: max-height;
}

.drawer.is-open {
  border-color: #2A353B;
  box-shadow: 0 0 12px rgba(174, 183, 186, 0.04);
}

/* Content typography */

.drawer__content h3,
.drawer__content h4 {
  font-family: 'JetBrains Mono', monospace;
  color: #D8DED9;
  margin: 12px 0 6px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.drawer__content h3:first-child,
.drawer__content h4:first-child {
  margin-top: 0;
}

.drawer__content p {
  margin: 0 0 10px 0;
  color: #A8B2B6;
}

.drawer__content ul,
.drawer__content ol {
  margin: 0 0 10px 0;
  padding-left: 18px;
}

.drawer__content li {
  margin-bottom: 4px;
}

.drawer__content a {
  color: #A98C5A;
  text-decoration: none;
}

.drawer__content a:hover {
  text-decoration: underline;
  color: #c4a46e;
}

.drawer__content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: #0E1418;
  padding: 2px 5px;
  border-radius: 2px;
  color: #AEB7BA;
}

.drawer__content strong {
  color: #D8DED9;
  font-weight: 600;
}

/* --- Stats / Numbers --- */

.drawer__stat {
  color: #D8DED9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   CONTENT TYPE: PAPERS
   ============================================================ */

.drawer__verdict {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
  margin-top: 4px;
}

.drawer__verdict--confirmed {
  background: rgba(138, 155, 143, 0.15);
  color: #8A9B8F;
  border: 1px solid rgba(138, 155, 143, 0.3);
}

.drawer__verdict--plausible {
  background: rgba(214, 168, 79, 0.12);
  color: #D6A84F;
  border: 1px solid rgba(214, 168, 79, 0.25);
}

.drawer__verdict--refuted {
  background: rgba(184, 74, 74, 0.15);
  color: #B84A4A;
  border: 1px solid rgba(184, 74, 74, 0.3);
}

.drawer__verdict--inconclusive {
  background: rgba(143, 154, 156, 0.12);
  color: #A8B2B6;
  border: 1px solid rgba(143, 154, 156, 0.25);
}

.drawer__arxiv {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #6B7578;
  letter-spacing: 0.02em;
}

/* ============================================================
   CONTENT TYPE: SYSTEMS
   ============================================================ */

.drawer__stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.drawer__stack-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 2px;
  background: rgba(126, 143, 168, 0.12);
  color: #7E8FA8;
  border: 1px solid rgba(126, 143, 168, 0.2);
}

/* ============================================================
   CONTENT TYPE: COLD CASES (formerly ghosts)
   ============================================================ */

.drawer--ghost {
  border-color: rgba(154, 139, 179, 0.15);
}

.drawer--ghost .drawer__title {
  color: #c4b8d9;
}

.drawer--ghost .drawer__content {
  color: #9A8BB3;
}

.drawer--ghost .drawer__content a {
  color: #b8a3d4;
}

.drawer--ghost .drawer__content a:hover {
  color: #d4c5ec;
}

.drawer--ghost.is-open {
  border-color: rgba(154, 139, 179, 0.25);
  box-shadow: 0 0 16px rgba(154, 139, 179, 0.06);
}

/* ============================================================
   CONTENT TYPE: VACANT
   ============================================================ */

.drawer--vacant {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

.drawer--vacant::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 8px,
    rgba(143, 154, 156, 0.04) 8px,
    rgba(143, 154, 156, 0.04) 9px
  );
  pointer-events: none;
}

.drawer--vacant .drawer__handle {
  cursor: not-allowed;
}

/* ============================================================
   STALENESS CLASSES
   ============================================================ */

/* .fresh — no modifications, clean default */

.drawer.aging {
  opacity: 0.85;
}

.drawer.stale {
  opacity: 0.7;
  border-color: rgba(169, 140, 90, 0.15);
}

.drawer.stale::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(169, 140, 90, 0.03);
  pointer-events: none;
  border-radius: 2px;
}

.drawer.expired {
  opacity: 0.55;
  border-color: rgba(214, 168, 79, 0.2);
}

.drawer.expired::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(214, 168, 79, 0.05);
  pointer-events: none;
  border-radius: 2px;
}

/* REVERIFY badge for expired drawers */
.drawer.expired .drawer__handle::before {
  content: 'REVERIFY';
  position: absolute;
  top: 6px;
  right: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #D6A84F;
  background: rgba(214, 168, 79, 0.1);
  border: 1px solid rgba(214, 168, 79, 0.25);
  padding: 1px 5px;
  border-radius: 2px;
}

/* ============================================================
   RESPONSIVE — Tablet (<=1024px)
   ============================================================ */

@media (max-width: 1024px) {
  .morgue-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 126px 16px 32px 16px;
  }

  .drawer--wide {
    grid-column: span 2;
  }

  .autopsy-rail {
    padding: 10px 16px;
    gap: 6px;
  }

  .autopsy-rail__filter {
    font-size: 10px;
    padding: 4px 8px;
  }

  .case-file {
    padding: 8px 16px;
    gap: 12px;
  }

  .case-file__thesis {
    display: none;
  }
}

/* ============================================================
   RESPONSIVE — Mobile (<=600px)
   ============================================================ */

@media (max-width: 600px) {
  .morgue-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 120px 12px 24px 12px;
  }

  .drawer--wide {
    grid-column: span 1;
  }

  .autopsy-rail {
    top: 32px;
    padding: 8px 12px;
    gap: 5px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .autopsy-rail__filter {
    font-size: 9px;
    padding: 8px 12px;
    min-height: 44px;
    flex-shrink: 0;
  }

  .case-file {
    padding: 6px 12px;
    gap: 8px;
  }

  .case-file__name {
    font-size: 11px;
  }

  .case-file__role {
    display: none;
  }

  .case-file__thesis {
    display: none;
  }

  .case-file__stats {
    font-size: 9px;
  }

  .case-file__links {
    display: none;
  }

  .drawer__handle {
    padding: 14px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .drawer__title {
    font-size: 12px;
  }

  .drawer__id {
    font-size: 9px;
  }

  .drawer__date {
    font-size: 9px;
  }

  .drawer.is-open .drawer__content {
    padding: 10px 14px 16px 14px;
  }

  .drawer__content {
    font-size: 13px;
  }
}

/* ============================================================
   PRINT STYLESHEET
   ============================================================ */

@media print {
  body {
    background: #fff;
    color: #1a1a1a;
  }

  .case-file,
  .autopsy-rail,
  .morgue-contact,
  .morgue-footer,
  .skip-link {
    display: none;
  }

  .morgue-grid {
    display: block;
    padding: 0;
    max-width: none;
  }

  .drawer {
    background: #fff;
    border: 1px solid #ccc;
    margin-bottom: 12px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .drawer::before {
    display: none;
  }

  .drawer--hidden {
    display: block;
  }

  .drawer__content {
    max-height: none !important;
    opacity: 1 !important;
    padding: 12px 18px 20px 18px !important;
    overflow: visible;
    color: #333;
  }

  .drawer__led { box-shadow: none; }
  .drawer--ghost { opacity: 1; border-color: #ccc; }
  .drawer--ghost .drawer__title { color: #333; }
  .drawer--ghost .drawer__content { color: #555; }
  .drawer--ghost .drawer__content a { color: #666; }
  .drawer--ghost .drawer__content a:hover { color: #888; }
  .drawer--ghost.is-open { border-color: #ddd; box-shadow: none; }

  .drawer__handle {
    color: #1a1a1a;
  }

  .drawer__title {
    color: #1a1a1a;
  }

  .drawer__content h3,
  .drawer__content h4 {
    color: #1a1a1a;
  }

  .drawer__content p {
    color: #333;
  }

  .drawer__content a::after {
    content: ' (' attr(href) ')';
    font-size: 10px;
    color: #666;
  }

  .drawer__led {
    box-shadow: none;
  }

  .drawer--vacant {
    display: none;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.morgue-contact {
  text-align: center;
  padding: 20px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #7E8A95;
  letter-spacing: 0.03em;
}

.morgue-contact a {
  color: #9B6B6B;
  text-decoration: none;
}

.morgue-contact a:hover {
  color: #B84A4A;
}

.morgue-footer {
  text-align: center;
  padding: 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #6B7578;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
