/* noise-sharpening project styles — extends css/site.css */

/* =========================================================================
 * Gallery
 * ========================================================================= */

.gallery__loading,
.gallery__error,
.gallery__empty {
  color: var(--color-muted);
  margin-top: var(--gap-lg);
}

.gallery__error {
  color: #b54545;
}

.gallery--grid {
  display: grid;
  gap: var(--gap-lg);
  margin-top: var(--gap-xl);
  grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
  .gallery--grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 60rem) {
  .gallery--grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.scenario-card {
  display: flex;
  flex-direction: column;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--color-card-shadow);
  color: inherit;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.scenario-card:hover {
  box-shadow: var(--color-card-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--color-accent);
}

.scenario-card__thumb {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #efefea;
}

.scenario-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scenario-card__body {
  padding: var(--gap-md) var(--gap-md) var(--gap-lg);
}

.scenario-card__title {
  margin: 0 0 0.4em;
  font-size: 1.1rem;
}

.scenario-card__subtitle {
  margin: 0 0 0.6em;
  font-size: 0.9rem;
  color: var(--color-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.scenario-card__meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-accent);
  font-weight: 600;
}

/* =========================================================================
 * Scenario page
 * ========================================================================= */

.scenario-main {
  max-width: 80rem;
}

.scenario__loading,
.scenario__error {
  color: var(--color-muted);
}

.scenario__error {
  color: #b54545;
}

.scenario__breadcrumb {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: var(--gap-md);
}

.scenario__breadcrumb a {
  color: var(--color-muted);
}

.scenario__breadcrumb a:hover {
  color: var(--color-accent);
}

.scenario__breadcrumb span[aria-hidden] {
  margin: 0 0.5em;
}

.scenario__header {
  margin-bottom: var(--gap-xl);
}

/* Optional manifest-authored editorial note. Renders as a callout below
   the lede so a reader sees Peter's commentary on the AI evaluation right
   alongside the scenario description. Cream background + gold left-border
   matches the star colour used in critique blocks. */
.editor-note {
  display: block;
  margin: var(--gap-md) 0 0;
  padding: 0.75rem var(--gap-md);
  background: #faf6e8;
  border-left: 3px solid #c98e1d;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--color-fg);
}

.editor-note strong {
  font-weight: 700;
  margin-right: 0.25em;
}

.scenario__pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--gap-md);
  margin-top: var(--gap-xl);
  padding-top: var(--gap-lg);
  border-top: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.scenario__nav-link {
  font-weight: 600;
}

/* =========================================================================
 * Scenario hero
 *
 * One downscaled "best of" image at the top of the page, sized to fit the
 * content column. It is the LCP element — img tag uses fetchpriority=high
 * and explicit dimensions, the button uses --variant-aspect to reserve
 * layout space before the JPEG decodes.
 * ========================================================================= */

.scenario__hero {
  margin: var(--gap-lg) 0 0;
}

.scenario__hero-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #000;
  cursor: zoom-in;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s ease;
  aspect-ratio: var(--variant-aspect, 4 / 3);
}

.scenario__hero-btn:hover,
.scenario__hero-btn:focus-visible {
  border-color: var(--color-accent);
  outline: none;
}

.scenario__hero-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scenario__hero-hint {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.scenario__hero-btn:hover .scenario__hero-hint,
.scenario__hero-btn:focus-visible .scenario__hero-hint {
  opacity: 1;
}

/* Display-only hero (manifest's hero_image_file) — no button wrapper, no
   click-to-lightbox. Mirrors the .scenario__hero-btn frame but without
   the hover affordances. The image's intrinsic aspect-ratio is used
   here (rather than the variant aspect) since the source is typically
   the full uncropped scene with its own dimensions. */
.scenario__hero--display {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}

.scenario__hero--display img {
  display: block;
  width: 100%;
  height: auto;
}

/* =========================================================================
 * Variants list
 * ========================================================================= */

.variants {
  display: flex;
  flex-direction: column;
  gap: var(--gap-xl);
  margin-top: var(--gap-lg);
}

.variant {
  display: grid;
  grid-template-areas:
    "open"
    "meta";
  gap: var(--gap-md);
  padding-bottom: var(--gap-xl);
  border-bottom: 1px solid var(--color-border);
}

.variant:last-child {
  border-bottom: none;
}

@media (min-width: 64rem) {
  .variant {
    grid-template-columns: minmax(0, var(--crop-width, 1fr)) minmax(0, 1fr);
    grid-template-areas: "open meta";
    gap: var(--gap-lg);
    align-items: start;
  }
}

.variant__open-btn {
  grid-area: open;
  display: block;
  /* The crop image is intrinsically var(--crop-width) wide. Cap the button
     at that size so it doesn't stretch past native; on narrow viewports the
     max-width clamp lets the figure shrink to fit. */
  width: var(--crop-width, 100%);
  max-width: 100%;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #000;
  cursor: zoom-in;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s ease;
}

.variant__open-btn:hover,
.variant__open-btn:focus-visible {
  border-color: var(--color-accent);
  outline: none;
}

.variant__zoom-hint {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.variant__open-btn:hover .variant__zoom-hint,
.variant__open-btn:focus-visible .variant__zoom-hint {
  opacity: 1;
}

.variant__meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.variant__title {
  margin: 0;
  font-size: 1.4rem;
}

.variant__caption {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.variant__no-critique {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-muted);
  font-style: italic;
}

/* Critique block */

.critique {
  background: #f4f3ee;
  border-left: 3px solid var(--color-accent);
  border-radius: 4px;
  padding: var(--gap-md);
}

.critique__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.critique__score {
  color: #c98e1d;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
}

.critique__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.critique__model {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.critique__details {
  font-size: 0.92rem;
}

.critique__summary {
  cursor: pointer;
  color: var(--color-accent);
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
}

.critique__summary::-webkit-details-marker {
  display: none;
}

.critique__details[open] .critique__summary {
  display: none;
}

.critique__text {
  margin: 0;
  line-height: 1.55;
}

/* Crop figure (sits inside .variant__open-btn). */

.variant__crop {
  margin: 0;
  background: #000;
  /* Border, radius, and overflow live on the parent .variant__open-btn so
     hover/focus styles can target the click affordance directly. The figure
     is just a layout grouping for the image and its caption. */
}

.variant__crop > img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--crop-aspect, 3 / 2);
  /* The 200% crop is a centered half of the source region nearest-neighbor
     upscaled. Keep pixel boundaries crisp on any incidental scaling so the
     doubled pixels stay visible as 2x2 blocks (the photo-app "200% zoom"
     look). */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.variant__crop figcaption {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  padding: 0.4rem 0.6rem;
  background: var(--color-card-bg);
  font-weight: 700;
}

/* =========================================================================
 * Lightbox (full-resolution OpenSeadragon viewer)
 * ========================================================================= */

.body--lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.96);
  display: flex;
  flex-direction: column;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: var(--gap-md);
  padding: 0.5rem 0.75rem 0.5rem 1.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.9rem;
}

.lightbox__pickers {
  /* `flex: 0 1 auto` (was 1 1) — pickers take their natural width on the
     left so the EXIF strip can grow into the middle of the bar. Pickers
     can still shrink when controls + exif crowd them on narrow widths. */
  flex: 0 1 auto;
  align-self: center;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.lightbox__exif {
  /* Sits between the pickers and the zoom controls, fills the middle.
     Single-line; the JS sets the same string in title= for hover-reveal
     when text-overflow ellipsis kicks in on narrow viewports. Hidden
     entirely below the breakpoint where there's no room for it. */
  flex: 1 1 auto;
  align-self: center;
  min-width: 0;
  text-align: center;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.75);
  padding: 0 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .lightbox__exif { display: none; }
}

.lightbox__pick {
  /* Strip default <select> chrome so it reads as bold inline text. */
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0.25rem 1.5rem 0.25rem 0.5rem;
  /* Custom chevron — drawn as a CSS background image. */
  background-image: linear-gradient(
      45deg,
      transparent 50%,
      rgba(255, 255, 255, 0.7) 50%
    ),
    linear-gradient(135deg, rgba(255, 255, 255, 0.7) 50%, transparent 50%);
  background-position:
    calc(100% - 0.85rem) calc(50% + 1px),
    calc(100% - 0.5rem) calc(50% + 1px);
  background-size:
    0.35rem 0.35rem,
    0.35rem 0.35rem;
  background-repeat: no-repeat;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  max-width: 14em;
  text-overflow: ellipsis;
}

.lightbox__pick:hover,
.lightbox__pick:focus-visible {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

.lightbox__pick option {
  /* Force a dark drop-down panel — without this, some systems render the
     option list with default light-mode colours that clash with the bar. */
  background: #1a1a1a;
  color: #fff;
}

.lightbox__sep {
  opacity: 0.65;
  flex: 0 0 auto;
}

.lightbox__controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lightbox__zoom {
  /* Tabular-nums + a fixed min-width keep the readout from jittering as the
     percentage digit count changes. Yellow makes it visually distinct from
     the (white) preset buttons so it reads as a status, not a control. */
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
  color: #f4c542;
  min-width: 7rem;
  text-align: right;
  padding: 0 0.25rem;
  white-space: nowrap;
}

.lightbox__btn,
.lightbox__close {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lightbox__btn:hover,
.lightbox__btn:focus-visible,
.lightbox__close:hover,
.lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
  outline: none;
}

.lightbox__close {
  font-size: 1.2rem;
  padding: 0.2rem 0.6rem;
}

/* Stage holds the two viewer layers + divider + side badges. */
.lightbox__stage {
  flex: 1 1 auto;
  position: relative;
  background: #000;
  overflow: hidden;
  user-select: none;
}

/* Layers are absolutely-positioned shells stacked inside the stage. The actual
   OSD viewer sits inside, filling the layer at 100%/100%. We need this shell
   because OSD imposes position: relative inline on its host element, which
   would otherwise collapse it to 0 height. */
.lightbox__layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #000;
}

/* In compare mode the top layer is clipped via inline clip-path that the
   divider drag updates (clip-path: inset(0 0 0 X%)). */
.lightbox__layer--top {
  z-index: 2;
}

.lightbox__viewer {
  width: 100%;
  height: 100%;
  background: #000;
}

/* OpenSeadragon's zoom / home controls sit at top-left by default. Nudge them
   in slightly so they're not flush against the viewport edge. */
.lightbox__viewer .openseadragon-container > div:first-of-type {
  margin: 0.6rem;
}

/* Side badges — clickable buttons in the bottom corners. The title sits at the
   outer corner; the "i" icon sits toward the centre so the user can always
   reach it without crossing the image. Clicking opens the critique panel. */
.lightbox__badge {
  position: absolute;
  bottom: 0.75rem;
  z-index: 5;
  padding: 0.3rem 0.6rem;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lightbox__badge:hover:not([disabled]),
.lightbox__badge:focus-visible:not([disabled]) {
  background: rgba(0, 0, 0, 0.85);
  border-color: rgba(255, 255, 255, 0.35);
  outline: none;
}

.lightbox__badge[disabled] {
  cursor: default;
}

.lightbox__badge[aria-expanded="true"] {
  background: rgba(20, 20, 20, 0.95);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox__badge--left {
  left: 0.75rem;
}

.lightbox__badge--right {
  right: 0.75rem;
}

.lightbox__badge[hidden] {
  display: none;
}

.lightbox__info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 1;
}

.lightbox__info-icon[hidden] {
  display: none;
}

/* Critique panel — anchored to the bottom corner, sized to fit the text up to
   half the stage width. height:auto so it stays as shallow as the content
   allows; max-height clamps and scrolls if a critique ever runs long. */
.lightbox__critique {
  position: absolute;
  bottom: 3.25rem; /* sits just above the badge */
  z-index: 6;
  width: calc(50% - 1.5rem);
  max-width: 30rem;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.7rem 0.85rem;
  background: rgba(15, 15, 15, 0.94);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
  line-height: 1.5;
}

.lightbox__critique--left {
  left: 0.75rem;
}

.lightbox__critique--right {
  right: 0.75rem;
}

.lightbox__critique[hidden] {
  display: none;
}

.lightbox__critique-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.lightbox__critique-stars {
  color: #d39d2c;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.lightbox__critique-stars:empty {
  display: none;
}

.lightbox__critique-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.lightbox__critique-model {
  font-size: 0.7rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  opacity: 0.65;
}

.lightbox__critique-model:empty {
  display: none;
}

.lightbox__critique-close {
  margin-left: auto;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lightbox__critique-close:hover,
.lightbox__critique-close:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  outline: none;
}

/* Per-variant description (from the JPEG's dc:description) sits between the
   header and the AI critique. Visually softer so the AI text remains the focal
   content. Hidden when the caption is empty. */
.lightbox__critique-caption {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  font-style: italic;
}

.lightbox__critique-caption:empty {
  display: none;
}

.lightbox__critique-text {
  margin: 0;
}

/* Divider — vertical line spanning full stage height, with a circular drag
   handle in the middle. The line is decorative (pointer-events: none); only
   the handle catches drag events so OSD pan still works elsewhere. */
.lightbox__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  transform: translateX(-1px);
  z-index: 4;
  pointer-events: none;
}

.lightbox__divider[hidden] {
  display: none;
}

.lightbox__divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  color: #1a1a1a;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: none;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s ease;
}

.lightbox__divider-handle:hover,
.lightbox__divider-handle:focus-visible {
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
}

