/* Case gallery: the original layout, refined for reading (shared tokens live in ../style.css). */
.gallery-hero {
  text-align: center;
  padding: 72px 24px 48px;
  position: relative;
}
.gallery-hero::before {
  content: "";
  position: absolute;
  inset: -30% 15% auto;
  height: 520px;
  background: radial-gradient(closest-side, rgb(255 222 102 / 14%), rgb(255 222 102 / 0%));
  pointer-events: none;
  z-index: -1;
}
.gallery-hero h1 {
  font-size: clamp(48px, 6vw, 80px);
  font-weight: 750;
  letter-spacing: -0.05em;
  line-height: 1;
}
.gallery-title > img {
  width: 1.9em;
  height: auto;
  aspect-ratio: 1.5;
  transform: rotate(-4deg);
}
.gallery-hero > p:not(.eyebrow) {
  color: var(--body);
  font-size: 19px;
  line-height: 1.65;
  margin-top: 22px;
}
.gallery-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 30px;
}
.gallery-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 15px;
}
.gallery-stats span + span {
  border-left: 1px solid var(--line-strong);
  padding-left: 24px;
}
.gallery-stats b {
  color: var(--ink);
  font-weight: 650;
  margin-right: 4px;
}

/* Explorer */
.gallery-explorer {
  max-width: calc(1290px + 2 * var(--gutter));
  margin: auto;
  padding: 0 var(--gutter) 64px;
  scroll-margin-top: 76px;
}
.suite-tabs {
  display: flex;
  gap: 32px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.suite-tabs button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: 16px;
  font-weight: 550;
  color: var(--muted);
}
.suite-tabs button:hover {
  color: var(--ink);
}
.suite-tabs button[aria-selected="true"] {
  border-color: var(--ink);
  color: var(--ink);
}
.suite-tabs button span {
  font-size: 13px;
  font-weight: 600;
  background: var(--soft);
  padding: 1px 8px;
  border-radius: 999px;
  color: var(--body);
}
.suite-tabs button[aria-selected="true"] span {
  background: var(--ink);
  color: var(--white);
}
.explorer-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin: 28px 0 18px;
}
.gallery-search {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  background: var(--white);
  border-radius: 14px;
  width: 600px;
  max-width: 65%;
  box-shadow: 0 1px 2px rgb(20 24 38 / 4%);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.gallery-search:focus-within {
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 4px rgb(193 164 84 / 18%);
}
.gallery-search svg {
  color: var(--muted);
  width: 20px;
  height: 20px;
}
.gallery-search input {
  background: transparent;
  border: 0;
  outline: none;
  font-size: 17px;
  min-width: 0;
  flex: 1;
  color: var(--ink);
}
.gallery-search input::placeholder {
  color: var(--muted);
}
.gallery-search input:focus-visible {
  outline: 0;
}
.result-count {
  font-size: 15px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.result-count b {
  color: var(--ink);
  font-weight: 650;
}
.result-count button {
  min-height: 44px;
  margin-left: 10px;
  font-size: 15px;
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 32px;
}
.category-filters button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 55%);
  border-radius: 999px;
  font-size: 15px;
  line-height: 1.3;
  color: var(--body);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.category-filters button b {
  font-weight: 650;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.category-filters button:hover {
  background: var(--white);
  border-color: #aaa59e;
}
.category-filters button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #e7e8ee;
}
.category-filters button[aria-pressed="true"] b {
  color: var(--white);
}

/* Case cards */
.case-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}
.case-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  min-width: 0;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
}
.case-card:hover,
.case-card:focus-within {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow:
    0 1px 2px rgb(20 24 38 / 5%),
    0 24px 44px -24px rgb(20 24 38 / 30%);
}
.card-open {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  text-align: left;
}
.card-open:focus-visible {
  outline-offset: -3px;
  border-radius: var(--radius);
}
.card-visual {
  position: relative;
  width: 100%;
  background: var(--soft);
  aspect-ratio: 1.5;
  overflow: hidden;
}
.card-visual > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}
.case-card:hover .card-visual > img {
  transform: scale(1.03);
}
.card-ref-count {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgb(255 255 255 / 94%);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 0 2px 8px rgb(20 24 38 / 12%);
}
.card-ref-count svg {
  width: 14px;
  height: 14px;
}
.card-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  padding: 22px 24px 18px;
}
.card-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--muted);
}
.category-code {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.05em;
  color: var(--accent-ink);
  background: var(--accent-wash);
  border-radius: 6px;
  padding: 2px 8px;
}
.card-copy h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.25;
}
.card-id {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 550;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.card-prompt {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.65;
  color: var(--body);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  font-weight: 550;
  color: var(--ink);
}
.card-prompt + .card-bottom {
  margin-top: 18px;
}
.card-bottom > span:last-child {
  font-size: 18px;
  color: var(--muted);
  transition: transform 0.18s;
}
.case-card:hover .card-bottom > span:last-child {
  color: var(--ink);
  transform: translate(2px, -2px);
}
.load-more-wrap {
  text-align: center;
  margin: 44px 0 0;
}
.load-more-wrap p {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 14px;
}
.load-more-wrap button {
  min-width: 190px;
}
.gallery-status {
  border: 1px dashed var(--line-strong);
  padding: 64px 20px;
  text-align: center;
  border-radius: var(--radius);
  color: var(--body);
  font-size: 17px;
}
.gallery-status strong {
  display: block;
  font-size: 24px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 8px;
}
.gallery-status button {
  margin-top: 24px;
}
.gallery-help {
  max-width: calc(1290px + 2 * var(--gutter));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  margin: 0 auto;
  padding: 72px var(--gutter) 96px;
}
.gallery-help > div:first-child {
  border-top: 1px solid var(--line);
  padding-top: 64px;
}
.gallery-help > div:last-child {
  border-top: 1px solid var(--line);
  padding-top: 90px;
}
.gallery-help h2 {
  font-size: clamp(30px, 3vw, 40px);
}
.gallery-help p:not(.eyebrow) {
  font-size: 18px;
  color: var(--body);
  line-height: 1.7;
}
.gallery-help a {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  margin-top: 16px;
  font-size: 16px;
  font-weight: 550;
  border-bottom: 1px solid var(--line-strong);
}
.gallery-help a:hover {
  border-color: var(--ink);
}

/* Case dialog */
.case-dialog {
  width: min(1240px, calc(100vw - 64px));
  max-width: none;
  max-height: calc(100dvh - 56px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: contain;
  box-shadow: 0 30px 100px rgb(16 19 27 / 30%);
}
.case-dialog::backdrop {
  background: rgb(20 24 36 / 60%);
  backdrop-filter: blur(6px);
}
body:has(.case-dialog[open]) {
  overflow: hidden;
}
.case-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgb(247 245 242 / 94%);
  backdrop-filter: blur(12px);
}
.case-header > div:first-child > p {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--muted);
}
.case-header h2 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}
.case-header .case-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 550;
  letter-spacing: 0.03em;
  color: var(--body);
}
.case-checks {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--muted);
}
.case-checks::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.modal-controls,
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.modal-controls button,
.viewer-controls button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--white);
  font-size: 18px;
  transition: background 0.15s;
}
.modal-controls button:hover,
.viewer-controls button:hover {
  background: var(--soft);
}
.modal-controls span {
  min-width: 64px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.modal-controls .close-dialog,
.viewer-controls [data-close-target] {
  margin-left: 8px;
  font-size: 24px;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}
.modal-controls .close-dialog:hover,
.viewer-controls [data-close-target]:hover {
  background: #2b3040;
}
.case-body {
  padding: 32px;
}
.case-overview {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 28px;
  align-items: start;
}
.target-panel {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  overflow: hidden;
  text-align: left;
  box-shadow: var(--shadow-card);
}
.target-panel img {
  width: 100%;
  max-height: 440px;
  min-height: 200px;
  object-fit: contain;
  background: var(--soft);
}
.target-panel span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  font-size: 15px;
  color: var(--muted);
}
.target-panel b {
  margin-right: auto;
  font-weight: 650;
  color: var(--ink);
}
.target-panel i {
  font-style: normal;
}
.target-panel:hover span {
  color: var(--ink);
}
.instruction-panel {
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow-card);
}
.instruction-panel .eyebrow {
  margin-bottom: 14px;
}
.instruction-content {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 12px;
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}
.reference-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  margin: 40px 0 18px;
}
.reference-heading h3 {
  font-size: 24px;
}
.reference-heading h3 span {
  margin-left: 8px;
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
}
.reference-heading p {
  font-size: 15px;
  color: var(--muted);
}
.reference-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
}
.reference-item {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  overflow: hidden;
  transition:
    transform 0.18s,
    border-color 0.18s,
    box-shadow 0.18s;
}
.reference-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 12px 22px -14px rgb(20 24 38 / 35%);
}
.reference-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: 6px;
}
.reference-item span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--body);
  font-variant-numeric: tabular-nums;
}
.case-footnote {
  margin-top: 20px;
  font-size: 15px;
  color: var(--muted);
}

/* Image viewer */
.target-dialog {
  width: min(1180px, calc(100vw - 40px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 18px 20px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: contain;
}
.target-dialog::backdrop {
  background: rgb(14 17 26 / 82%);
}
.target-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.target-preview-header p {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  font-size: 16px;
  color: var(--body);
}
.target-preview-header p b {
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.viewer-stage {
  display: grid;
  place-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.viewer-stage img {
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 190px);
  object-fit: contain;
}
.viewer-note {
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 1080px) {
  .case-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
  .reference-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .case-dialog {
    width: calc(100vw - 36px);
  }
  .case-header {
    padding: 20px 24px;
  }
  .case-body {
    padding: 24px;
  }
  .gallery-help {
    gap: 40px;
  }
}
@media (max-width: 760px) {
  .gallery-hero {
    padding: 52px 20px 36px;
  }
  .gallery-hero h1.gallery-title {
    font-size: clamp(40px, 11vw, 56px);
    gap: 12px;
  }
  .gallery-hero > p:not(.eyebrow) {
    font-size: 17px;
  }
  .gallery-hero > p br {
    display: none;
  }
  .gallery-stats {
    gap: 4px 18px;
  }
  .gallery-stats span + span {
    border-left: 0;
    padding-left: 0;
  }
  .suite-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
  }
  .suite-tabs button {
    justify-content: space-between;
    min-height: 52px;
    font-size: 15px;
    text-align: left;
    line-height: 1.3;
  }
  .explorer-tools {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 20px;
  }
  .gallery-search {
    width: 100%;
    max-width: 100%;
  }
  .gallery-search input {
    font-size: 16px;
  }
  .category-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 calc(-1 * var(--gutter)) 24px;
    padding: 2px var(--gutter) 6px;
    scrollbar-width: none;
  }
  .category-filters::-webkit-scrollbar {
    display: none;
  }
  .category-filters button {
    flex-shrink: 0;
  }
  .case-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card-copy {
    padding: 20px 20px 16px;
  }
  .gallery-help {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 var(--gutter) 64px;
  }
  .gallery-help > div:first-child {
    padding-top: 52px;
  }
  .gallery-help > div:last-child {
    border: 0;
    padding-top: 18px;
  }
  .gallery-help br {
    display: none;
  }
  .case-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 16px;
  }
  /* Compact sticky header: title and close on top, case id and case navigation below. */
  .case-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "meta meta meta close"
      "title title title close"
      "id prev count next";
    align-items: center;
    gap: 2px 6px;
    padding: 12px 14px 10px 16px;
  }
  .case-header > div:first-child,
  .modal-controls {
    display: contents;
  }
  .case-header > div:first-child > p {
    grid-area: meta;
    margin: 0;
  }
  .case-header h2 {
    grid-area: title;
    font-size: 21px;
  }
  .case-header .case-id {
    grid-area: id;
    margin-top: 2px;
    font-size: 14px;
  }
  .modal-controls button {
    width: 40px;
    height: 40px;
  }
  .modal-controls [data-move="-1"] {
    grid-area: prev;
  }
  .modal-controls span {
    grid-area: count;
    min-width: 0;
    padding-inline: 2px;
    font-size: 14px;
  }
  .modal-controls [data-move="1"] {
    grid-area: next;
  }
  .modal-controls .close-dialog {
    grid-area: close;
    align-self: start;
    margin-left: 0;
  }
  .case-body {
    padding: 16px;
  }
  .case-overview {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .target-panel img {
    max-height: 340px;
    min-height: 0;
  }
  .instruction-panel {
    padding: 20px;
  }
  .instruction-content {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .reference-heading {
    display: block;
    margin: 28px 0 14px;
  }
  .reference-heading h3 {
    font-size: 21px;
  }
  .reference-heading p {
    margin-top: 4px;
  }
  .reference-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  .reference-item span {
    left: 4px;
    bottom: 4px;
    padding: 0 5px;
  }
  .target-dialog {
    width: calc(100vw - 12px);
    padding: 12px;
  }
  .target-preview-header {
    align-items: flex-start;
  }
  .target-preview-header p {
    flex-direction: column;
    gap: 0;
  }
  .viewer-controls {
    gap: 6px;
  }
  .viewer-controls [data-close-target] {
    margin-left: 4px;
  }
}
@media (max-width: 360px) {
  .reference-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .case-card,
  .card-visual > img,
  .reference-item {
    transition: none;
  }
  .case-card:hover {
    transform: none;
  }
}
