/* Adaptive layout layer: phones, tablets, desktops, and ultrawide displays. */
html,
body {
  overflow-x: clip;
}

.gallery-more {
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.load-more-button {
  min-height: 46px;
  padding-right: 22px;
  padding-left: 22px;
}

@media (min-width: 1800px) {
  .site-header {
    max-width: 2200px;
  }

  .site-header .search-control {
    max-width: 640px;
  }

  main {
    padding-right: clamp(48px, 3.5vw, 88px);
    padding-left: clamp(48px, 3.5vw, 88px);
  }

  .category-browse,
  body[data-page="home"] .archive-panel,
  body[data-page="archive"] .category-hero,
  body[data-page="archive"] .archive-panel {
    max-width: 1760px;
  }

  .mosaic {
    column-count: 5;
    column-gap: 18px;
    max-width: 2100px;
    margin-right: auto;
    margin-left: auto;
  }

  .art-card {
    margin-bottom: 18px;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .site-header {
    grid-template-columns: auto minmax(240px, 1fr) auto;
    gap: 12px;
  }

  .top-brand {
    width: 112px;
  }

  .top-nav-pills {
    display: flex;
    min-height: 42px;
  }

  .top-nav-pills button {
    min-height: 34px;
    padding-right: 12px;
    padding-left: 12px;
    font-size: 0.78rem;
  }

  .top-nav-action:first-child {
    display: none;
  }

  .top-nav-action {
    min-height: 42px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .site-header .search-control input {
    height: 46px;
  }
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 12px;
  }

  body {
    min-width: 0;
  }

  .site-header {
    position: relative;
    top: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    width: calc(100% - 16px);
    min-height: 0;
    margin: 8px auto 0;
    padding: 10px;
    border-radius: 20px;
  }

  .top-nav-left {
    display: flex;
    min-width: 0;
    gap: 8px;
  }

  .top-brand {
    flex: 0 0 auto;
    width: 104px;
  }

  .top-nav-pills {
    display: flex;
    flex: 0 0 auto;
    min-height: 36px;
    gap: 2px;
    padding: 3px;
  }

  .top-nav-pills button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 0.7rem;
  }

  .top-nav-actions {
    align-self: center;
  }

  .top-nav-action:first-child {
    display: none;
  }

  .top-nav-action {
    min-height: 38px;
    padding: 0 12px;
    font-size: 0.74rem;
    white-space: nowrap;
  }

  .site-header .search-control {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .site-header .search-control input {
    height: 46px;
    padding-right: 50px;
    padding-left: 44px;
    font-size: 0.84rem;
  }

  .search-command-key {
    display: none;
  }

  .search-suggestions {
    top: calc(100% + 8px);
    width: calc(100vw - 32px);
    max-height: min(420px, 62dvh);
    overflow-y: auto;
    padding: 12px;
    border-radius: 18px;
  }

  .search-suggestion-list {
    gap: 7px;
  }

  .search-suggestion-list button {
    min-height: 36px;
    padding-right: 12px;
    font-size: 0.75rem;
  }

  main {
    width: 100%;
    padding-right: 14px;
    padding-bottom: 48px;
    padding-left: 14px;
  }

  body[data-page="home"] .cosmos-hero {
    min-height: min(570px, calc(100svh - 120px));
    margin-right: -14px;
    margin-left: -14px;
    padding: 64px 18px 58px;
    overflow: hidden;
  }

  .cosmos-hero-copy {
    width: min(100%, 520px);
  }

  .cosmos-hero-copy h1 {
    max-width: 350px;
    font-size: clamp(2.65rem, 12.4vw, 3.8rem);
    letter-spacing: -0.07em;
    line-height: 0.88;
  }

  .cosmos-hero-copy > p:not(.kicker) {
    max-width: 330px;
    margin-top: 20px;
    font-size: 0.86rem;
    line-height: 1.45;
  }

  .cosmos-hero-actions {
    gap: 8px;
    margin-top: 22px;
  }

  .hero-action {
    min-height: 44px;
    padding-right: 16px;
    padding-left: 16px;
    font-size: 0.8rem;
  }

  .floating-art-field .feature-frame:nth-child(1) {
    top: 8%;
    left: -4%;
    width: 102px;
  }

  .floating-art-field .feature-frame:nth-child(2) {
    top: 11%;
    right: -5%;
    width: 86px;
  }

  .floating-art-field .feature-frame:nth-child(3) {
    right: -7%;
    bottom: 2%;
    width: 104px;
  }

  .floating-art-field .feature-frame:nth-child(4) {
    right: auto;
    bottom: 1%;
    left: -7%;
    display: block;
    width: 94px;
  }

  .floating-art-field .feature-frame:nth-child(n + 5) {
    display: none;
  }

  body[data-page="home"] .category-browse,
  body[data-page="explore"] .category-browse {
    margin-bottom: 36px;
    padding-top: 42px;
  }

  .section-heading {
    text-align: center;
  }

  .section-heading h2 {
    font-size: clamp(2.25rem, 11vw, 3.3rem);
  }

  .section-heading p:not(.kicker) {
    max-width: 340px;
    margin-right: auto;
    margin-left: auto;
    font-size: 0.88rem;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .category-card,
  .category-card:nth-child(1),
  .category-card:nth-child(4),
  .category-card:nth-child(5) {
    grid-column: auto;
    min-height: 276px;
    border-radius: 18px;
  }

  .category-card-content {
    padding: 20px;
  }

  .category-card-title {
    font-size: 1.5rem;
  }

  body[data-page="home"] .archive-panel {
    gap: 9px;
    padding-top: 20px;
  }

  body[data-page="home"] .archive-header {
    align-items: flex-end;
    gap: 8px;
  }

  body[data-page="home"] .archive-header h2 {
    max-width: 11ch;
    font-size: clamp(2.25rem, 10vw, 3.1rem);
    line-height: 0.94;
  }

  body[data-page="home"] .toolbar-status {
    margin-left: auto;
  }

  .archive-section-copy {
    font-size: 0.86rem;
  }

  body[data-page="archive"] .category-hero {
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
    padding: 28px 0 16px;
  }

  body[data-page="archive"] .category-back {
    min-height: 40px;
    margin-bottom: 10px;
    padding: 0;
  }

  body[data-page="archive"] .category-hero h1 {
    font-size: clamp(3rem, 15vw, 4.8rem);
    line-height: 0.9;
  }

  body[data-page="archive"] .category-hero p:not(.category-hero-count) {
    max-width: 34ch;
    margin-top: 14px;
    font-size: 0.92rem;
  }

  .category-hero-visuals {
    min-height: 142px;
  }

  .category-hero-visual:nth-child(1) {
    top: 0;
    right: 8%;
    width: 138px;
    aspect-ratio: 1.16;
  }

  .category-hero-visual:nth-child(2) {
    top: 20px;
    right: auto;
    left: 7%;
    width: 108px;
  }

  .category-hero-visual:nth-child(3) {
    display: none;
  }

  body[data-page="archive"] .archive-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 0 8px;
  }

  body[data-page="archive"] .category-switcher summary,
  body[data-page="archive"] .sort-control {
    min-height: 42px;
  }

  body[data-page="archive"] .category-menu {
    width: min(240px, calc(100vw - 28px));
    max-height: min(430px, 66dvh);
    overflow-y: auto;
  }

  body[data-page="archive"] .category-menu .filter-button {
    min-height: 40px;
  }

  body[data-page="archive"] .artist-filter-group {
    width: auto;
    margin-right: -14px;
    margin-left: -14px;
    padding: 1px 14px 6px;
    scroll-padding-left: 14px;
    scrollbar-width: none;
  }

  body[data-page="archive"] .artist-filter-group::-webkit-scrollbar {
    display: none;
  }

  body[data-page="archive"] .artist-filter-button {
    min-height: 38px;
    padding-right: 13px;
    padding-left: 13px;
  }

  .mosaic {
    column-count: 2;
    column-gap: 10px;
  }

  .art-card {
    margin-bottom: 10px;
    border-radius: 12px;
  }

  .art-overlay {
    gap: 0;
    padding: 42px 10px 10px;
    background: linear-gradient(
      180deg,
      transparent 44%,
      rgba(0, 0, 0, 0.08) 60%,
      rgba(0, 0, 0, 0.72) 100%
    );
    opacity: 1;
    transform: none;
  }

  .art-overlay > * {
    opacity: 1;
    transform: none;
  }

  .art-title {
    font-size: 0.82rem;
    line-height: 1.08;
  }

  .art-subtitle,
  .card-actions {
    display: none;
  }

  .gallery-more {
    margin-top: 18px;
  }

  .load-more-button {
    width: min(100%, 260px);
    min-height: 48px;
  }

  .art-dialog,
  .art-dialog[open] {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    grid-template-columns: 1fr;
    margin: auto;
    overflow: auto;
    border-radius: 20px;
  }

  .dialog-media img,
  .art-dialog[data-orientation="portrait"] .dialog-media img,
  .art-dialog[data-orientation="wide"] .dialog-media img {
    width: 100%;
    max-width: 100%;
    max-height: 58dvh;
  }

  .dialog-details {
    width: auto;
    max-height: none;
    gap: 10px;
    padding: 18px 18px max(20px, env(safe-area-inset-bottom));
    overflow: visible;
  }

  .dialog-close {
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
  }

  .utility-dialog,
  .submission-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 20px;
  }

  .utility-dialog-inner,
  .submission-form {
    gap: 15px;
    padding: 24px 18px max(22px, env(safe-area-inset-bottom));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-field input,
  .form-field select,
  .form-field textarea,
  .file-control {
    min-height: 48px;
  }

  .utility-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .utility-actions .intro-button {
    min-height: 46px;
  }

  .share-popover {
    right: 10px !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    left: 10px !important;
    width: auto;
    border-radius: 18px;
  }
}

@media (max-width: 360px) {
  .site-header {
    padding: 9px;
  }

  .top-brand {
    width: 90px;
  }

  .top-nav-pills button {
    padding-right: 7px;
    padding-left: 7px;
  }

  .top-nav-action {
    padding-right: 9px;
    padding-left: 9px;
    font-size: 0.69rem;
  }

  .cosmos-hero-copy h1 {
    font-size: clamp(2.45rem, 12.2vw, 3.15rem);
  }

  .category-card {
    min-height: 250px;
  }
}

@media (max-width: 340px) {
  .site-header {
    grid-template-rows: auto auto auto;
  }

  .top-nav-left {
    display: contents;
  }

  .top-brand {
    grid-column: 1;
    grid-row: 1;
    width: 96px;
  }

  .top-nav-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .top-nav-pills {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .top-nav-pills button {
    flex: 1 1 50%;
  }

  .site-header .search-control {
    grid-row: 3;
  }
}
