/* Catalog refinements: native Rails components in the Coss visual language. */
:root {
  --space-page-top: 36px;
  --space-section: 40px;
  --space-grid-inline: 24px;
  --space-grid-block: 32px;
}

/* 1. Page rhythm and information hierarchy. */
.catalog-intro { padding-block: var(--space-page-top) 28px; }
.catalog-intro h1,
.collections-page > h1,
.favorites-heading h1 { font-size: 36px; letter-spacing: -.6px; }
.collections-page, .favorites-page, .about-page { padding-top: var(--space-page-top); }
.collection-grid { margin-top: 28px; }
.favorites-heading { margin-bottom: 24px; }
.favorites-heading p { margin-top: 8px; }
.box-grid { gap: var(--space-grid-block) var(--space-grid-inline); }
.card-copy h3 { font-size: 18px; }
.card-series, .card-meta { font-size: 11px; }
.card-meta { gap: 12px; }
.breadcrumbs { font-size: 12px; padding-block: 24px; }
.photo-credit { font-size: 11px; }
.related-section { margin-top: var(--space-section); padding-top: 32px; }
.related-heading { justify-content: flex-start; align-items: baseline; gap: 10px; }
.related-heading .count-badge { align-self: center; }
.about-page section p { font-size: 16px; }

@media (max-width: 640px) {
  :root { --space-page-top: 28px; --space-grid-inline: 14px; --space-grid-block: 28px; }
  .catalog-intro { padding-bottom: 24px; }
  .catalog-intro h1, .collections-page > h1, .favorites-heading h1 { font-size: 32px; letter-spacing: -.4px; }
  .card-copy h3 { font-size: 16px; }
  .card-series, .card-meta { font-size: 11px; }
  .breadcrumbs { font-size: 11px; padding-block: 20px; }
  .related-section { margin-top: 32px; padding-top: 24px; }
  .about-page section p { font-size: 15px; }
}

/* Nucleo's own filled drawing replaces the outline, rather than filling a stroke icon. */
.ui-icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.icon-filled, .icon-zoom-out { display: none; }
[aria-pressed="true"] .ui-icon-heart .icon-outline,
.header-favorites:has(.nav-favorites-count:not([hidden])) .icon-outline { display: none; }
[aria-pressed="true"] .ui-icon-heart .icon-filled,
.header-favorites:has(.nav-favorites-count:not([hidden])) .icon-filled { display: inline; }
.pswp--zoomed-in .icon-zoom-in { display: none; }
.pswp--zoomed-in .icon-zoom-out { display: inline; }

/* 2. Coss input groups, native selects, segmented links and a bottom Sheet. */
:root { --control-height: 36px; }
.catalog-toolbar { grid-template-columns: minmax(240px, 1fr) auto auto auto; gap: 12px; }
.filter-fields { display: contents; }
.search-field, .sort-control select { height: var(--control-height); border-radius: var(--radius-md); font-size: 12px; }
.search-field { gap: 10px; padding-inline: 12px; }
.search-field input { font-size: 12px; }
.search-field kbd { font: 10px/18px var(--font-ui); color: var(--muted-foreground); background: var(--secondary); border-color: var(--border); }
.sort-control { position: relative; }
.sort-control select { appearance: none; padding-inline: 12px 32px; background: var(--background); }
.sort-control > .ui-icon { position: absolute; inset-inline-end: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--radius-md); color: var(--muted-foreground); background: transparent; flex-shrink: 0; }
.clear-search { width: 26px; height: 26px; }
.mobile-filter-trigger { display: none; }
.view-switch { height: 36px; border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.view-switch a { width: 30px; height: 28px; border-radius: 5px; }
.catalog-meta { min-height: 64px; }
.button { min-height: 36px; border-radius: var(--radius-md); }
.button-primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.button-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted-foreground); }
.filter-sheet { width: min(100%, 480px); max-width: none; max-height: min(88svh, 680px); padding: 0; margin: auto 0 0 auto; inset: auto 0 0; border: 1px solid var(--border); border-radius: 18px 18px 0 0; background: var(--background); color: var(--foreground); box-shadow: 0 -12px 48px rgb(0 0 0 / .08); }
.filter-sheet::backdrop { background: rgb(0 0 0 / .18); }
.filter-sheet-open { overflow: hidden; }
.sheet-header, .sheet-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; }
.sheet-header { border-bottom: 1px solid var(--border); }
.sheet-header h2 { font: 600 16px/1.3 var(--font-ui); }
.sheet-content { padding: 24px 20px; overflow: auto; overscroll-behavior: contain; max-height: calc(88svh - 154px); }
.sheet-footer { border-top: 1px solid var(--border); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.filter-sheet .filter-fields, .filter-sheet .catalog-filters { display: flex; flex-direction: column; gap: 20px; }
.filter-sheet .sort-control { display: flex; flex-direction: column; gap: 8px; }
.filter-sheet .control-label { position: static; width: auto; height: auto; clip: auto; white-space: normal; margin: 0; font-size: 12px; color: var(--muted-foreground); }
.filter-sheet .sort-control select { width: 100%; max-width: none; height: 40px; font-size: 16px; }
.filter-sheet .sort-control > .ui-icon { top: auto; bottom: 13px; transform: none; }

@media (max-width: 1000px) and (min-width: 641px) {
  .catalog-toolbar { grid-template-columns: minmax(0, 1fr) auto auto; }
  .catalog-toolbar .search-field { grid-column: 1 / -1; max-width: none; }
}
@media (max-width: 640px) {
  .catalog-toolbar { grid-template-columns: 1fr auto; gap: 12px; }
  .catalog-toolbar .search-field { grid-column: 1 / -1; height: 42px; max-width: none; }
  .search-field input { font-size: 16px; }
  .search-field kbd { display: none; }
  .catalog-toolbar > .filter-fields { display: none; }
  .mobile-filter-trigger { display: inline-flex; justify-self: start; gap: 8px; min-height: 36px; padding-inline: 11px; }
  .view-switch { justify-self: end; }
  .catalog-meta { min-height: 64px; }
}
@media (hover: hover) and (pointer: fine) {
  .icon-button:hover, .button-ghost:hover { background: var(--secondary); color: var(--foreground); }
  .button-primary:hover { background: var(--secondary-foreground); color: var(--primary-foreground); }
}

/* 3. Objects lead; Coss ghost actions stay available without permanent button chrome. */
:root { --image-surface: #f8f8f8; }
.card-image-wrap, .detail-main-image { border-color: var(--border); border-radius: var(--radius-lg); background: var(--image-surface); }
.card-image-link { padding: 24px; }
.card-image-link img { transition: none; }
.box-card:hover .card-image-link img { transform: none; }
.box-card .favorite-button, .box-card .zoom-button {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-md); background: transparent; box-shadow: none;
  opacity: 1; transition: opacity .15s ease, background-color .15s ease;
}
.box-card .favorite-button { color: var(--favorite); top: 8px; right: 8px; }
.box-card .favorite-button[aria-pressed="true"] { background: transparent; }
.box-card .zoom-button { color: var(--secondary-foreground); bottom: 8px; right: 8px; }
.box-card .favorite-button .ui-icon, .box-card .zoom-button .ui-icon { width: 18px; height: 18px; }
.image-year { top: 12px; left: 12px; border-color: transparent; background: rgb(255 255 255 / .8); }
.card-image-link:active { background: rgb(0 0 0 / .02); }
.detail-main-image { padding: 32px; }
.thumbnails { gap: 8px; padding-top: 12px; }
.thumbnails button { background: var(--image-surface); border-radius: var(--radius-md); }
.specifications { margin-block: 28px; padding: 4px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.specifications > div { align-items: baseline; grid-template-columns: 112px minmax(0, 1fr); padding-block: 12px; font-size: 13px; gap: 12px; }
.specifications > div + div { border-top: 1px solid var(--border); }
.specifications dt { font-size: 12px; }
.specifications dd.mono { font-size: 12px; }
.specifications dd > .text-link { font-size: 13px; line-height: 1.5; }
.item-tags .tag { min-height: 26px; padding: 3px 8px; border-radius: 6px; font-size: 11px; }
.sources-section { padding-top: 0; border-top: 0; margin-top: 24px; }
.sources-section summary { min-height: 40px; align-items: center; gap: 16px; font-size: 12px; color: var(--secondary-foreground); }
.sources-section summary .ui-icon { transition: transform .15s ease; }
.sources-section[open] summary .ui-icon { transform: rotate(180deg); }
.source-row { padding-block: 12px; line-height: 1.6; }
.source-row + .source-row { border-top: 1px solid var(--border); }
.release-row strong { font-size: 13px; }

/* PhotoSwipe keeps its gestures and focus handling; only its icon/visual layer changes. */
.pswp { --pswp-bg: #f8f8f8; }
.pswp__button { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); border-color: var(--border); background: var(--background); color: var(--secondary-foreground); box-shadow: var(--shadow); }
.pswp__button > .ui-icon { position: static; width: 18px; height: 18px; fill: none; transform: none; }
.pswp__button--arrow { position: absolute; }
.pswp__button--arrow > .ui-icon { transform: none; }
.pswp__button:disabled { opacity: .3; }
.pswp__catalog-caption { border-color: var(--border); background: rgb(248 248 248 / .96); border-radius: var(--radius-lg); }
.pswp-original { min-height: 36px; font-size: 11px; }

@media (hover: hover) and (pointer: fine) {
  .box-card .favorite-button, .box-card .zoom-button { opacity: 0; }
  .box-card:hover .favorite-button, .box-card:hover .zoom-button,
  .box-card:focus-within .favorite-button, .box-card:focus-within .zoom-button,
  .box-card .favorite-button[aria-pressed="true"] { opacity: 1; }
  .box-card .favorite-button:hover, .box-card .zoom-button:hover { background: rgb(255 255 255 / .85); }
}
@media (max-width: 640px) {
  .card-image-link { padding: 16px; }
  .box-card .favorite-button, .box-card .zoom-button { opacity: 1; }
  .detail-main-image { padding: 24px; }
  .specifications { padding-inline: 12px; }
  .specifications > div { grid-template-columns: 96px minmax(0, 1fr); gap: 10px; }
}
@media (hover: none), (any-pointer: coarse) {
  .box-card .favorite-button, .box-card .zoom-button { opacity: 1; }
}

/* 4. Quiet navigation and explicit collection types; broad headings remain tags. */
.site-header-inner { min-height: 88px; }
.collection-card { display: flex; flex-direction: column; }
.collection-image { flex-shrink: 0; }
.collection-card .collection-kind { display: inline-flex; width: fit-content; margin-bottom: 10px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; font: 10px/1.4 var(--font-ui); color: var(--muted-foreground); background: var(--secondary); }
.collection-card .collection-copy { display: flex; flex: 1; flex-direction: column; align-items: flex-start; }
.collection-copy h2 { flex: 1; margin-bottom: 12px; }
.collection-copy > span:last-child { width: 100%; }
.footer-wordmark { font-size: 36px; }
.footer-links a { border-radius: 6px; padding-inline: 8px; margin-inline: -8px; }
.footer-collections a { width: calc(100% + 16px); max-width: none; }
.footer-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-block: 0 28px; }
.footer-tags > span { margin-right: 4px; font-size: 11px; color: var(--muted-foreground); }
.footer-tags .tag { font-size: 11px; min-height: 28px; padding: 4px 8px; border-radius: 6px; }
.back-to-top svg { transform: none; }
.pswp-original { display: inline-flex; align-items: center; gap: 7px; }
@media (hover: hover) and (pointer: fine) {
  .footer-links a:hover { background: var(--secondary); text-decoration: none; }
}
@media (max-width: 800px) {
  .site-header-inner { padding-block: 14px; gap: 10px 16px; }
  .site-header .primary-nav a { height: 36px; min-height: 36px; }
}
@media (max-width: 480px) {
  .site-header .wordmark { min-height: 40px; }
  .footer-wordmark { font-size: 32px; }
  .collection-card .collection-kind { font-size: 9px; margin-bottom: 8px; }
  .collection-copy h2 { margin-bottom: 10px; }
}

/* 5. Long captions, small viewports and content extremes. */
.card-image-link { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.card-image-link img { min-width: 0; min-height: 0; }
.collection-image { background: var(--image-surface); }
.collection-image .missing-image { height: 100%; }
.card-copy h3, .detail-info h1, .collection-card h2, .breadcrumbs > span { overflow-wrap: anywhere; }
.pswp__catalog-caption { max-height: 35svh; overflow: auto; overscroll-behavior: contain; }
@media (max-width: 640px) {
  .pswp__button--arrow { bottom: calc(36px + var(--caption-height, 60px)); }
}
