/* ==========================================================================
   Elder Salviejo • Weekly Missionary Journal Vault
   Version 2.0 Archival Editorial & Documentary Design System
   Anti-AI Slop • High-Contrast Ink • Natural Paper • Precision Typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;1,6..72,400;1,6..72,600&display=swap');

:root {
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, Cambria, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-hand: 'IBM Plex Mono', monospace; /* Retiring AI-slop cursive */

  --bg-canvas: #fafaf9;
  --bg-card: #ffffff;
  --bg-subtle: #f5f5f4;
  --bg-muted: #e7e5e4;

  --color-ink: #0c0a09;
  --color-ink-secondary: #44403c;
  --color-ink-muted: #78716c;

  --color-crimson: #991b1b;
  --color-crimson-hover: #b91c1c;
  --color-crimson-light: #fef2f2;
  --color-crimson-border: #fecaca;

  --border-archival: #e7e5e4;
  --border-dark: #292524;
}

/* --------------------------------------------------------------------------
   Skeleton Shimmer Loading Animation
   -------------------------------------------------------------------------- */
@keyframes skeleton-sweep {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #e7e5e4 25%,
    #f5f5f4 50%,
    #e7e5e4 75%
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.6s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Global Reset & Layout Safety
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--bg-canvas);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

body {
  font-family: var(--font-sans);
  color: var(--color-ink);
  background-color: var(--bg-canvas);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Global Security & Image Protection
   -------------------------------------------------------------------------- */
img,
svg,
picture,
.protected-image,
.polaroid-frame img,
.polaroid-photo-wrap img,
.lightbox-image {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
  user-drag: none !important;
  pointer-events: auto;
}

input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
}

/* --------------------------------------------------------------------------
   Missionary Nametag Component
   Authentic LDS Missionary name badge style
   -------------------------------------------------------------------------- */
.missionary-nametag {
  background: #09090b;
  color: #ffffff;
  border-radius: 6px;
  padding: clamp(6px, 1.8vw, 10px) clamp(10px, 2.5vw, 18px);
  border: 1px solid #27272a;
  border-top: 2px solid #a1a1aa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-align: center;
  user-select: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  flex-shrink: 1;
}

.missionary-nametag .tag-name {
  font-family: var(--font-sans);
  font-size: clamp(11px, 3.2vw, 14px);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #ffffff;
  text-transform: uppercase;
  line-height: 1.15;
  white-space: nowrap;
}

.missionary-nametag .tag-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
  margin: clamp(3px, 1vw, 5px) auto clamp(2px, 0.8vw, 4px) auto;
  width: 86%;
}

.missionary-nametag .tag-church {
  font-family: var(--font-sans);
  font-size: clamp(6.5px, 1.8vw, 8px);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #d4d4d8;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
}

.missionary-nametag .tag-christ {
  font-family: var(--font-sans);
  font-size: clamp(8px, 2.3vw, 10px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #ffffff;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Elder Salviejo Profile Picture Avatars
   -------------------------------------------------------------------------- */
.profile-avatar-nav {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid #d6d3d1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  background-color: #1c1917;
  flex-shrink: 0;
}

.profile-avatar-nav img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

.profile-avatar-hero {
  position: relative;
  width: clamp(64px, 15vw, 100px);
  height: clamp(64px, 15vw, 100px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #d6d3d1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  background-color: #1c1917;
  flex-shrink: 0;
}

.profile-avatar-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

/* --------------------------------------------------------------------------
   Translucent Archival Header
   -------------------------------------------------------------------------- */
.archival-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(250, 250, 249, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-archival);
  transition: all 0.2s ease;
}

/* --------------------------------------------------------------------------
   Editorial Ledger Row (Timeline Feed)
   -------------------------------------------------------------------------- */
.ledger-row {
  display: block;
  text-decoration: none;
  color: inherit;
  background-color: #ffffff;
  border: 1px solid var(--border-archival);
  border-radius: 8px;
  margin-bottom: 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  position: relative;
}

.ledger-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.18s ease;
  border-radius: 8px 0 0 8px;
}

.ledger-row:hover {
  border-color: #c5c0bb;
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.08), 0 1px 4px -1px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.ledger-row:hover::before {
  background: var(--color-crimson);
}

.ledger-row-active {
  border-left-color: var(--color-crimson);
}

.ledger-row-active::before {
  background: var(--color-crimson);
}

/* --------------------------------------------------------------------------
   Refined Modern Polaroid Component
   -------------------------------------------------------------------------- */
.polaroid-frame {
  background: #ffffff;
  padding: 10px 10px 14px 10px;
  border-radius: 4px;
  border: 1px solid #e7e5e4;
  box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.polaroid-frame:hover {
  box-shadow: 0 16px 32px -4px rgba(0, 0, 0, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   Aspect Ratio & Containment Utilities (Anti-Cropping / Natural Ratios)
   -------------------------------------------------------------------------- */
.aspect-4-3 { aspect-ratio: 4 / 3; }
.aspect-3-4 { aspect-ratio: 3 / 4; }
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-letter { aspect-ratio: 8.5 / 11; }

.polaroid-photo-wrap {
  position: relative;
  overflow: hidden;
  background-color: transparent;
  border-radius: 1px;
  width: 100%;
  display: block;
}

.polaroid-photo-wrap img {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

/* Snug Polaroid: Frame hugs the natural dimensions of the photo */
.polaroid-snug { display: flex; flex-direction: column; }
.polaroid-snug .polaroid-photo-wrap { background-color: transparent; min-height: 0; width: 100%; }
.polaroid-snug .polaroid-photo-wrap img { width: 100%; height: auto; object-fit: contain; }


/* Polaroid pin dot — the red/orange tack */
.polaroid-pin {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f87171, #991b1b 80%);
  box-shadow: 0 2px 8px rgba(153, 27, 27, 0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  z-index: 2;
  flex-shrink: 0;
}

.polaroid-stamp {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #57534e;
  text-align: center;
  text-transform: uppercase;
  margin-top: 10px;
  padding: 0 2px;
  line-height: 1.35;
}


/* --------------------------------------------------------------------------
   Universal Archival Lightbox & Ratio-Preserving Zoom Canvas
   -------------------------------------------------------------------------- */
.universal-lightbox-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.universal-lightbox-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
}

.universal-lightbox-img {
  max-width: min(92vw, 1100px);
  max-height: min(74dvh, 76vh);
  width: auto;
  height: auto;
  object-fit: contain;
  aspect-ratio: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
  border-radius: 2px;
  transform-origin: center center;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  will-change: transform;
}

.universal-lightbox-img.zoomed {
  cursor: grab;
}

.universal-lightbox-img.zoomed:active,
.universal-lightbox-img.cursor-grabbing {
  cursor: grabbing !important;
}

.universal-lightbox-img:not(.zoomed) {
  cursor: zoom-in;
}

/* --------------------------------------------------------------------------
   Dynamic Orientation Row-by-Row Layout for Book Print PDF Appendix
   (Full-Height 8.80 in Canvas, Proportional Widths, Zero Dead Space)
   -------------------------------------------------------------------------- */
.appendix-rows-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  gap: 10px;
  box-sizing: border-box;
}

.appendix-row {
  display: flex;
  flex-direction: row;
  width: 100%;
  flex: 1 1 0%;
  gap: 10px;
  min-height: 0;
  box-sizing: border-box;
}

/* Individual Row Tile (Proportional Width, Object-Fit Cover) */
.appendix-row-tile,
.appendix-grid-tile {
  position: relative;
  height: 100%;
  min-width: 0;
  border-radius: 4px;
  overflow: hidden;
  background-color: #18181b;
  border: 1px solid #e7e5e4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  box-sizing: border-box;
}

.appendix-row-tile img,
.appendix-grid-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.2s ease;
}

.appendix-row-tile:hover img,
.appendix-grid-tile:hover img {
  transform: scale(1.02);
}

/* Official Archival Colophon Seal Card */
.appendix-colophon-seal {
  width: 100%;
  min-height: 0;
  border-radius: 4px;
  background-color: #fafaf9;
  border: 1.5px solid #d6d3d1;
  padding: 14px 18px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Compact Editorial Overlay Badges */
.appendix-tile-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(24, 24, 27, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #ffffff;
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.appendix-tile-date {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(24, 24, 27, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #d4d4d8;
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.sheet-header {
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  min-height: 0.65in !important;
  height: auto !important;
  flex-shrink: 0 !important;
  border-bottom: 1px solid #d6d3d1 !important;
  padding-bottom: 0.35rem !important;
  margin-bottom: 0.4rem !important;
  display: flex !important;
  align-items: baseline !important;
  justify-content: space-between !important;
  gap: 1rem !important;
  box-sizing: border-box !important;
  z-index: 10;
}

.sheet-footer {
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  height: 0.35in !important;
  flex-shrink: 0 !important;
  border-top: 1px solid #d6d3d1 !important;
  padding-top: 0.35rem !important;
  margin-top: 0.4rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  box-sizing: border-box !important;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: #57534e;
  z-index: 10;
}

.sheet-content {
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* Missing utility classes not in precompiled Tailwind build */
.text-\[9px\] { font-size: 9px !important; }
.text-\[9\.5px\] { font-size: 9.5px !important; }
.text-\[10px\] { font-size: 10px !important; }
.text-\[11px\] { font-size: 11px !important; }
.tracking-\[0\.25em\] { letter-spacing: 0.25em !important; }
.max-h-\[195px\] { max-height: 195px !important; }
.max-h-\[220px\] { max-height: 220px !important; }

.weekly-plate-card {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 8px 8px 10px 8px;
  box-sizing: border-box;
}

.weekly-snug-wrap {
  overflow: hidden;
  border-radius: 2px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: auto;
  max-width: 100%;
}

.weekly-snug-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

@media print {
  .appendix-masonry-3col {
    column-count: 3 !important;
    column-gap: 4mm !important;
    width: 100% !important;
  }

  .appendix-card,
  .weekly-plate-card {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    box-shadow: none !important;
    border: 1px solid #e7e5e4 !important;
    background: #ffffff !important;
  }

  .appendix-card .polaroid-photo-wrap img,
  .weekly-snug-wrap img {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    object-fit: contain !important;
  }
}

/* --------------------------------------------------------------------------
   Slide-Over Reading Docket Panel
   -------------------------------------------------------------------------- */
.docket-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 9, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.docket-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.docket-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 720px;
  background: #fafaf9;
  z-index: 60;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-archival);
}

.docket-panel.active {
  transform: translateX(0);
}

.docket-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-archival);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.docket-body {
  padding: 32px 28px;
  overflow-y: auto;
  flex: 1;
}

.docket-body p {
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-ink-secondary);
  margin-bottom: 20px;
}

.docket-dropcap::first-letter {
  font-family: var(--font-serif);
  font-size: 3.4em;
  line-height: 0.8;
  float: left;
  margin: 0.08em 0.15em 0 0;
  font-weight: 700;
  color: var(--color-ink);
}

/* --------------------------------------------------------------------------
   Typography Helpers
   -------------------------------------------------------------------------- */
.font-sans { font-family: var(--font-sans); }
.font-serif { font-family: var(--font-serif); }
.font-mono { font-family: var(--font-mono); }
.font-hand { font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   Selection & Scrollbar
   -------------------------------------------------------------------------- */
::selection {
  background-color: #fee2e2;
  color: var(--color-crimson);
}

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

::-webkit-scrollbar-track {
  background: #fafaf9;
}

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

::-webkit-scrollbar-thumb:hover {
  background: #a8a29e;
}
