/* ============================================================
   COSMIC PLATE · SCREEN VIEW
   ------------------------------------------------------------
   Responsive gallery-style layout optimized for viewing on
   screens. Images and content adapt to viewport size.

   Debug mode (?debug on localhost) uses plate.css directly.
   ============================================================ */

/* ── Intro Section ── */
.intro {
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px 24px 64px;
}

.intro-header {
  margin-bottom: 24px;
}

.intro-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(42px, 8vw, 64px);
  font-weight: 400;
  color: var(--paper);
  margin: 0;
  letter-spacing: -0.02em;
}

.intro-tagline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 12px;
}

.intro-subtitle {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.intro-license {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s;
}

.intro-license:hover {
  color: var(--paper);
}

.intro-license-hint {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.intro-content {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 48px;
  align-items: start;
  border-top: 1px solid var(--rule);
  padding-top: 24px;
}

.intro-desc {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.75;
  color: var(--paper);
  max-width: 70ch;
}

.intro-desc p {
  margin: 0 0 1.2em;
}

.intro-desc p:first-child,
.intro-desc p:nth-child(2) {
  font-size: 19px;
  line-height: 1.6;
  opacity: 0.9;
}

.intro-desc p:first-child::first-letter {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 3.2em;
  float: left;
  line-height: 0.8;
  margin-right: 0.18em;
  margin-top: 0.1em;
  color: var(--paper);
}

.intro-desc p:last-child {
  margin-bottom: 0;
}

.intro-footnote {
  font-size: 12px !important;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  margin-top: 1.5em !important;
  padding-top: 1em;
  border-top: 1px solid var(--rule);
}

.intro-footnote a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

.intro-footnote a:hover {
  color: var(--paper);
}

/* ── Intro specs (right column) ── */
.intro-specs-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 24px;
  font-weight: 400;
  color: var(--paper);
  margin: 0 0 16px;
}

.intro-specs {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 16px;
  row-gap: 8px;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  min-width: 200px;
  max-width: 340px;
}

.intro-specs dt {
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.intro-specs dd {
  margin: 0;
  color: var(--paper);
  opacity: 0.85;
}

/* ── Mission Navigation (sticky) ── */
.mission-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(31, 29, 26, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(196, 189, 169, 0.15);
}

.mission-nav-inner {
  display: flex;
  align-items: center;
  gap: 34px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 0 16px 24px;
}

.mission-nav-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.3;
  transition: opacity 0.2s ease;
}

.mission-nav.is-sticky .mission-nav-title {
  opacity: 1;
}

.mission-nav-list {
  display: flex;
  gap: 24px;
  transform: translateY(1.5px);
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.mission-nav-list::-webkit-scrollbar {
  display: none;
}

.mission-nav-item {
  flex-shrink: 0;
}

.mission-nav-link {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 4px;
  transition: color 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.mission-nav-link:hover {
  color: var(--paper);
}

.mission-nav-link.active {
  color: var(--accent);
}

/* ── PDF Selection Bar (bottom) ── */
.pdf-hierarchy {
  --bar-content-height: 80px;
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(31, 29, 26, 0.85);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(196, 189, 169, 0.15);
  padding: 12px 24px;
  z-index: 1001;
  align-items: stretch;
  gap: 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
body.has-selection .pdf-hierarchy {
  transform: translateY(0);
}
.pdf-hierarchy-header {
  display: none;
}
.pdf-hierarchy-scroll {
  flex: 1;
  height: var(--bar-content-height);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.pdf-hierarchy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  gap: 8px;
  height: 100%;
}
.pdf-hierarchy-item {
  cursor: pointer;
  flex-shrink: 0;
  height: 100%;
  transform: scale(1);
  opacity: 1;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}
.pdf-hierarchy-item.entering {
  transform: scale(0);
  opacity: 0;
}
.pdf-hierarchy-item.leaving {
  transform: scale(0);
  opacity: 0;
}
.pdf-hierarchy-item img {
  width: auto;
  height: 100%;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.pdf-hierarchy-item:hover img,
.pdf-hierarchy-item.active img {
  opacity: 1;
}

/* ── Download PDF button ── */
.download-pdf-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--bar-content-height);
  padding: 0 28px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--paper);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.download-pdf-btn:hover {
  background: transparent;
  color: var(--accent);
}
.download-pdf-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.download-pdf-btn .btn-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.download-pdf-btn .btn-count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* ── Responsive adjustments ── */
@media (max-width: 768px) {
  .intro-content {
    grid-template-columns: 1fr;
    row-gap: 32px;
  }

  .intro-specs {
    max-width: none;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 600px) {
  .intro {
    padding: 48px 20px 40px;
  }

  .intro-desc {
    font-size: 16px;
  }

  .mission-nav-inner {
    padding: 12px 0 12px 25px;
    gap: 18px;
  }
  .mission-nav-title {
    font-size: 14px;
    transform: translateY(-1px);
  }

  .mission-nav-list {
    transform: translateY(0.5px);
    gap: 9px;
  }

  .mission-nav-link {
    font-size: 10px;
    padding: 6px 10px;
  }

  .pdf-hierarchy {
    --bar-content-height: 56px;
    padding: 10px 16px;
    gap: 12px;
  }

  .download-pdf-btn {
    padding: 0 16px;
  }

  .download-pdf-btn .btn-label {
    font-size: 14px;
  }

  .download-pdf-btn .btn-count {
    font-size: 9px;
  }
}

/* ── Lightbox Preview (above selection bar) ── */
.hover-preview {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--selection-bar-height, 104px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: auto;
  z-index: 1000;
  padding: 24px;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hover-preview-container {
  position: relative;
  max-width: 100%;
  max-height: calc(100% - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hover-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.8);
  cursor: default;
  transition: opacity 0.2s ease;
}
.hover-preview img.fading-out {
  position: absolute;
  opacity: 0;
}
.hover-preview-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.hover-preview.visible {
  opacity: 1;
  visibility: visible;
}

/* ── Cursor Label ── */
.cursor-label {
  display: none;
  position: fixed;
  pointer-events: none;
  z-index: 2001;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--accent);
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
}
.cursor-label.visible {
  display: block;
}
@media (max-width: 768px) {
  .cursor-label {
    display: none !important;
  }
}

/* ── Hide preview images in normal view ── */
.plate-preview {
  display: none;
}

/* ── Debug button (localhost only) ── */
.debug-btn {
  position: fixed;
  bottom: 16px;
  left: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 1px solid var(--ink-soft);
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink-soft);
  border-radius: 4px;
  text-decoration: none;
  opacity: 0.5;
  transition:
    opacity 0.15s,
    border-color 0.15s,
    color 0.15s;
  z-index: 100;
}
.debug-btn:hover {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   CARD VIEW (default, excludes debug mode)
   ============================================================ */
body:not([data-view="debug"]):not([data-view="pdf"]) .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-template-rows: masonry;
  gap: 32px;
  padding: 32px 24px 120px;
  max-width: 1400px;
  margin: 0 auto;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .plate {
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 24px;
  border-radius: 8px;
  grid-template-rows: auto auto auto;
  row-gap: 16px;
  page-break-after: auto;
  break-after: auto;
  cursor: pointer;
  transition:
    box-shadow 0.15s ease,
    outline 0.15s ease;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .plate:hover {
  box-shadow: 0 0 0 2px var(--ink-soft);
}

body:not([data-view="debug"]):not([data-view="pdf"]) .plate.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .plate.selected::before {
  content: "Added";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
}

@media (max-width: 768px) {
  body:not([data-view="debug"]):not([data-view="pdf"]) .plate.selected::before {
    content: "Added · Tap to remove";
  }
}

body:not([data-view="debug"]):not([data-view="pdf"]) .crop {
  display: none;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .rail {
  font-size: 10px;
  padding-bottom: 12px;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .well {
  padding: 0;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .well img {
  border-radius: 4px;
  border: none;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .caption {
  grid-template-columns: 1fr;
  grid-template-areas:
    "title"
    "subtitle"
    "desc"
    "specs";
  row-gap: 12px;
  padding-top: 16px;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .caption h1 {
  font-size: clamp(24px, 5vw, 42px);
}

body:not([data-view="debug"]):not([data-view="pdf"]) .caption .subtitle {
  font-size: 10px;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .caption .desc {
  font-size: 14px;
  line-height: 1.6;
  max-width: none;
}

body:not([data-view="debug"]):not([data-view="pdf"]) .specs {
  grid-template-columns: 100px 1fr;
  font-size: 11px;
  row-gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  min-width: 0;
}

/* ============================================================
   DEBUG MODE (localhost only, uses plate.css directly)
   ============================================================ */
[data-view="debug"] .gallery {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 48px 24px;
  max-width: none;
}

[data-view="debug"] .stage {
  width: var(--paper-w);
}

[data-view="debug"] .plate {
  cursor: default;
}

[data-view="debug"] .pdf-hierarchy,
[data-view="debug"] .intro,
[data-view="debug"] .mission-nav,
[data-view="debug"] .debug-btn {
  display: none;
}

/* ============================================================
   PDF GENERATION MODE
   ============================================================ */
[data-view="pdf"] .plate {
  display: grid;
}
[data-view="pdf"] .plate-preview {
  display: none;
}

/* ============================================================
   PRINT OUTPUT
   ============================================================ */
@media print {
  html,
  body {
    background: white;
  }

  .intro,
  .mission-nav,
  .download-pdf-btn,
  .pdf-hierarchy,
  .hover-preview {
    display: none !important;
  }

  .plate-preview {
    display: none !important;
  }
  .plate {
    display: grid !important;
  }

  .gallery {
    background: white;
    padding-top: 24px;
  }
  .plate.selected::before {
    display: none;
  }
}
