/* Minimalist Gallery Void — Content-First Archival Design */

:root {
  color-scheme: dark;
  --bg-void: #09090b;
  --bg-surface: #111114;
  --bg-hover: #1a1a1f;
  --border: #222228;
  --border-strong: #32323b;
  --ink: #f2f2ef;
  --muted: #8b8b93;
  --accent: #d9381e;
  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-void);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* Gallery Shell */
.gallery-shell {
  display: flex;
  flex-direction: column;
  block-size: 100dvh;
  overflow: hidden;
}

/* Single Compact Top Bar (48px) */
.topbar {
  flex: none;
  block-size: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-inline: 16px;
  background: var(--bg-surface);
  border-block-end: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-inline-size: 0;
}

.wordmark {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}

.sep {
  color: var(--border-strong);
  flex: none;
}

.active-title {
  margin: 0;
  font-size: 13px;
  font-weight: 450;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-inline-size: 42vw;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* Quiet View Tabs */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-end: 4px;
}

.view-tabs [role="tab"] {
  position: relative;
  padding: 13px 10px;
  background: transparent;
  border: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.14s ease;
}

.view-tabs [role="tab"]:hover:not(:disabled) {
  color: var(--ink);
}

.view-tabs [role="tab"]:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.view-tabs [role="tab"][aria-selected="true"] {
  color: var(--ink);
}

.view-tabs [role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 8px 0;
  border-block-end: 1.5px solid var(--ink);
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.step-count {
  padding-inline: 6px;
  font-size: 12px;
  color: var(--muted);
}

.icon-btn,
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.icon-btn {
  padding: 5px 6px;
}

.icon-btn:hover:not(:disabled),
.text-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.primary-btn {
  background: var(--ink);
  color: var(--bg-void);
  border-color: var(--ink);
}

.primary-btn:hover:not(:disabled) {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--bg-void);
}

@media (max-width: 780px) {
  .active-title,
  .sep,
  .repo-link {
    display: none;
  }
}

/* Main Stage (Full Bleed) */
.stage-main {
  flex: 1;
  min-block-size: 0;
  display: grid;
  background: var(--bg-void);
}

.panel {
  grid-area: 1 / 1;
  min-block-size: 0;
  display: flex;
  flex-direction: column;
}

.panel[hidden] {
  display: none;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-block-size: 0;
  background: var(--bg-void);
}

.frame-slot,
.frame-slot iframe {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  border: 0;
  display: block;
}

.stage-empty,
.stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  background: var(--bg-void);
  z-index: 2;
}

.stage-empty[hidden],
.stage-loading[hidden] {
  display: none;
}

.spinner {
  inline-size: 20px;
  block-size: 20px;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.floating-fs-btn {
  position: absolute;
  inset-block-end: 14px;
  inset-inline-end: 14px;
  z-index: 3;
  display: grid;
  place-items: center;
  inline-size: 32px;
  block-size: 32px;
  background: rgba(17, 17, 20, 0.72);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  opacity: 0.45;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.floating-fs-btn:hover {
  opacity: 1;
  border-color: var(--border-strong);
}

.floating-fs-btn[hidden] {
  display: none;
}

/* Stills Gallery */
.panel-gallery {
  padding: 20px 24px 16px;
  gap: 14px;
  justify-content: space-between;
}

.gallery-stage {
  flex: 1;
  min-block-size: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.hero-zoom-btn {
  max-inline-size: 100%;
  max-block-size: calc(100dvh - 200px);
  background: transparent;
  border: 0;
  padding: 0;
  display: flex;
}

.hero-zoom-btn img {
  max-inline-size: 100%;
  max-block-size: calc(100dvh - 200px);
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.gallery-caption {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.thumb-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-block: 4px;
  justify-content: center;
}

.strip-btn {
  flex: none;
  inline-size: 96px;
  block-size: 60px;
  padding: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  opacity: 0.55;
  transition: opacity 0.14s ease, border-color 0.14s ease;
}

.strip-btn:hover {
  opacity: 0.9;
}

.strip-btn[aria-current="true"] {
  opacity: 1;
  border-color: var(--ink);
}

.strip-btn img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

/* Code Panel */
.panel-code {
  padding: 20px 24px;
}

.code-split {
  flex: 1;
  min-block-size: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 760px) {
  .code-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

.code-files {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  padding: 6px;
}

.code-file-btn {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  text-align: start;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.code-file-btn:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

.code-file-btn[aria-current="true"] {
  background: var(--bg-hover);
  color: var(--ink);
}

.code-file-btn span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-pane {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  min-block-size: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
}

.code-head {
  display: flex;
  justify-content: space-between;
  padding: 9px 14px;
  border-block-end: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.code-body {
  margin: 0;
  padding: 14px;
  flex: 1;
  min-block-size: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
}

/* Native Scroll-Snap Slide-Out Drawer */
.Drawer {
  --drawer-width: min(27rem, 86dvw, 100dvw - 24px);
  --drawer-backdrop: 0;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  overflow: visible;
}

.Drawer::backdrop {
  background: #000;
  opacity: calc(var(--drawer-backdrop) * 0.68);
}

.Drawer-scroller {
  position: relative;
  display: grid;
  grid-template-columns: var(--drawer-width) 100%;
  overflow-x: scroll;
  overscroll-behavior: none;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

@media (prefers-reduced-motion: no-preference) {
  .Drawer-scroller {
    scroll-behavior: smooth;
  }
}

.Drawer-scroller::after {
  content: "";
  scroll-snap-align: end;
  scroll-initial-target: nearest;
}

.Drawer-sheet {
  display: flex;
  flex-direction: column;
  height: 100svh;
  background: var(--bg-surface);
  color: var(--ink);
  border-inline-end: 1px solid var(--border);
  scroll-snap-align: start;
  overflow: hidden;
}

@supports (animation-timeline: scroll()) {
  .Drawer {
    timeline-scope: --drawer-fade;
    animation: fade-drawer-backdrop linear both;
    animation-timeline: --drawer-fade;
  }
  .Drawer-scroller {
    scroll-timeline: --drawer-fade x;
  }
  @property --drawer-backdrop {
    syntax: "<number>";
    inherits: true;
    initial-value: 0;
  }
  @keyframes fade-drawer-backdrop {
    0% { --drawer-backdrop: 1; }
    100% { --drawer-backdrop: 0; }
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-block-end: 1px solid var(--border);
}

.drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.drawer-controls {
  padding: 12px 16px;
  border-block-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-search {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-void);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink);
}

.drawer-search:focus {
  border-color: var(--border-strong);
  outline: none;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-btn {
  padding: 4px 9px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}

.filter-btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

.filter-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg-void);
  border-color: var(--ink);
}

.catalog-grid {
  flex: 1;
  min-block-size: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 12px 16px 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.tile-btn {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tile-thumb {
  inline-size: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-void);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: border-color 0.14s ease;
}

.tile-btn:hover .tile-thumb {
  border-color: var(--border-strong);
}

.tile-btn[aria-current="true"] .tile-thumb {
  border-color: var(--ink);
}

.tile-thumb img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

.tile-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.tile-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Native Light-Dismiss Modals */
.modal-dialog {
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--ink);
  inline-size: min(92vw, 560px);
  max-block-size: 86vh;
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.lightbox-dialog {
  inline-size: min(92vw, 1180px);
  max-block-size: 90vh;
}

.modal-box {
  display: flex;
  flex-direction: column;
  max-block-size: 86vh;
}

.lightbox-box {
  max-block-size: 90vh;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-block-end: 1px solid var(--border);
}

.modal-head form {
  margin: 0;
}

.modal-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-wrap: balance;
}

.modal-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-note {
  margin: 0;
  max-inline-size: 65ch;
  text-wrap: pretty;
  color: var(--ink);
}

.info-kv {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 12.5px;
}

.info-kv dt {
  color: var(--muted);
}

.info-kv dd {
  margin: 0;
  color: var(--ink);
}

.info-kv a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prompt-details {
  border-block-start: 1px solid var(--border);
  padding-block-start: 12px;
}

.prompt-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.prompt-details summary:hover {
  color: var(--ink);
}

.prompt-pre {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--bg-void);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-block-size: 240px;
  overflow-y: auto;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lightbox-media {
  padding: 14px;
  display: flex;
  justify-content: center;
  overflow: auto;
  background: var(--bg-void);
}

.lightbox-media img {
  max-inline-size: 100%;
  max-block-size: calc(90vh - 90px);
  object-fit: contain;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
