/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target);
  padding: 0 var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn-accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-accent:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Series navigation buttons (home page, catalog) — lighter than the
   accent buttons, but still darker than the page background. */
.btn-series {
  background: var(--color-series);
  border-color: var(--color-series);
  color: var(--color-on-accent);
}

.btn-series:hover {
  background: var(--color-series-hover);
  border-color: var(--color-series-hover);
}

/* Header */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 1.125rem;
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
}

.site-header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  font-weight: 700;
}

.site-header__logo img {
  height: 52px;
  width: auto;
}

.site-header__artist-name {
  font-size: 1.2em;
}

.site-header__burger {
  display: inline-flex;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-text);
}

#nav-toggle {
  display: none;
}

.site-header__nav {
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
  padding-bottom: var(--space-sm);
}

#nav-toggle:checked ~ .site-header__nav {
  display: flex;
}

.site-header__nav a,
.site-header__nav button {
  min-height: var(--touch-target);
}

.site-header__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.site-header__links-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.lang-switch {
  display: flex;
  gap: var(--space-xs);
}

.lang-switch button {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  cursor: pointer;
}

.lang-switch button[aria-current="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

@media (min-width: 768px) {
  .site-header__inner {
    flex-wrap: nowrap;
  }

  .site-header__burger {
    display: none;
  }

  .site-header__nav {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    width: auto;
    padding-bottom: 0;
  }

  .site-header__links {
    flex-direction: row;
    gap: var(--space-md);
  }

  /* On mobile "Галерея" + lang switch form their own compact row; on
     desktop that wrapper is unboxed so the lang switch becomes a regular
     nav item again, pushed to the end via order. */
  .site-header__links-row {
    display: contents;
  }

  .lang-switch {
    order: 10;
  }
}

/* Footer */

.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-lg) 0;
  margin-top: var(--space-xl);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.site-footer__contacts {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.site-footer__brand-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.site-footer__brand img {
  height: 46px;
  width: auto;
}

.site-footer__admin-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.875rem;
}

.site-footer__admin-link:hover {
  color: var(--color-accent);
}

.site-footer__logout-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

@media (min-width: 768px) {
  .site-footer__inner {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}

/* Painting cards / grid */

.painting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.painting-card {
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
}

.painting-card__image {
  aspect-ratio: 4 / 5;
  object-fit: cover;
  width: 100%;
}

.painting-card__body {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.painting-card__title {
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  align-self: flex-start;
}

.badge-sold {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Stars / rating */

.stars {
  display: inline-flex;
  gap: 0.15rem;
}

.stars button,
.stars .star {
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
}

.stars .star.is-filled {
  color: var(--color-accent);
}

/* Filters (accordion on mobile) */

.filters {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  max-width: 480px;
  font-size: 0.875rem;
}

.filters__toggle {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 0 var(--space-sm);
  cursor: pointer;
  font-size: 0.875rem;
}

.filters__body {
  display: none;
  padding: 0 var(--space-sm) var(--space-sm);
  flex-direction: column;
  gap: 0.4rem;
}

.filters.is-open .filters__body {
  display: flex;
}

.filters .form-field {
  margin-bottom: 0;
  gap: 0.15rem;
}

.filters label {
  font-size: 0.8rem;
}

.filters select,
.filters input {
  min-height: 36px;
  width: 100%;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .filters__toggle {
    display: none;
  }

  .filters__body {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    padding: var(--space-sm);
  }

  .filters select,
  .filters input {
    width: auto;
  }
}

/* Forms */

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: var(--space-md);
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field select,
.form-field textarea {
  min-height: var(--touch-target);
  width: 100%;
  padding: var(--space-xs);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: inherit;
  font-size: 1rem;
}

/* Bottom row of the catalog page: search on the left, series buttons
   on the right (wraps to a stacked column on narrow screens). */
.catalog-bottom-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

@media (min-width: 768px) {
  .catalog-bottom-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

.catalog-bottom-row__series {
  justify-content: flex-end;
}

/* Compact search (низ каталогу) */

.search-compact {
  display: flex;
  gap: var(--space-xs);
  max-width: 320px;
}

.search-compact input[type="text"] {
  min-height: 36px;
  padding: 0.35rem var(--space-xs);
  font-size: 0.875rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
}

.search-compact button {
  min-height: 36px;
  padding: 0 var(--space-sm);
  font-size: 0.875rem;
}

.btn-compact {
  min-height: 36px;
  padding: 0 var(--space-sm);
  font-size: 0.875rem;
}

/* Painting detail: image + album navigation sidebar */

.painting-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.painting-detail__main {
  min-width: 0;
}

.painting-detail__image {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.album-nav {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
}

.album-nav__title {
  margin: 0 0 var(--space-xs);
  font-size: 0.875rem;
}

/* Ctrl+Left/Right hint buttons only make sense with a keyboard —
   hidden on mobile/tablet, where the main image is swiped instead. */
.album-nav__controls {
  display: none;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.album-nav__controls .btn {
  flex: 1 1 auto;
}

/* Mobile/tablet: horizontal scrollable strip — scales to any number of
   paintings without growing the page, you just scroll sideways. */
.album-nav__grid {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
}

.album-nav__thumb {
  flex: 0 0 72px;
  width: 72px;
  aspect-ratio: 1 / 1;
  min-width: var(--touch-target);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  display: block;
}

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

.album-nav__thumb.is-active {
  border-color: var(--color-accent);
}

@media (min-width: 1024px) {
  .painting-detail {
    flex-direction: row;
    align-items: flex-start;
  }

  .painting-detail__main {
    flex: 1 1 auto;
  }

  /* Wider sidebar with a multi-column grid instead of one long column —
     with many paintings in the series it fills a fixed viewport-height
     box and scrolls internally, instead of stretching the whole page.
     Grid (not flex) rows here on purpose: a flex column only shrinks its
     children when the *whole column* is over max-height, and an auto/
     max-height-only flex container never hands flex-grow children extra
     room since it has no definite size to grow into — the thumbnail grid
     either overflowed past the sidebar or (if shrunk) had its rows
     squeezed. A minmax(0, 1fr) grid row gets a real, definite,
     smaller-than-content height, so the thumbnail grid inside it overflows
     for real and its own overflow-y: auto actually scrolls. */
  .album-nav {
    flex: 0 0 320px;
    position: sticky;
    top: calc(var(--space-lg) + 60px);
    max-height: calc(100vh - var(--space-lg) - 80px);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .album-nav__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    grid-auto-rows: min-content;
    align-content: start;
    column-gap: var(--space-xs);
    row-gap: calc(var(--space-xs) / 3);
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding-bottom: 0;
    padding-right: 2px;
  }

  .album-nav__thumb {
    flex: initial;
    width: auto;
    min-width: 0;
  }

  .album-nav__controls {
    display: flex;
  }
}

/* Lightbox: full-size image over a darkened, smoky blurred backdrop */

.painting-detail__image {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: rgba(20, 17, 13, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lightbox[hidden] {
  display: none;
}

.lightbox__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Upload dropzone */

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  min-height: var(--touch-target);
}

.dropzone.is-dragover {
  border-color: var(--color-accent);
}

.dropzone input[type="file"] {
  display: none;
}

/* Chat widget */

.chat-bubble {
  position: fixed;
  right: var(--space-lg);
  bottom: var(--space-lg);
  z-index: 90;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: var(--color-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.chat-bubble:hover {
  background: var(--color-accent-hover);
}

.chat-panel {
  position: fixed;
  right: var(--space-lg);
  bottom: calc(var(--space-lg) * 2 + 60px);
  z-index: 90;
  width: min(320px, calc(100vw - 2 * var(--space-lg)));
  max-height: min(480px, calc(100vh - 120px));
  overflow-y: auto;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.chat-panel[hidden] {
  display: none;
}

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-weight: 700;
}

.chat-panel__close {
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.chat-panel__form {
  padding: var(--space-md);
}

.chat-panel__status {
  margin: var(--space-xs) 0 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.chat-panel__status.is-error {
  color: #b3402a;
}

.chat-panel__status a {
  color: inherit;
}

.chat-widget__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 480px) {
  .chat-panel {
    right: var(--space-sm);
    bottom: calc(var(--space-md) * 2 + 60px);
  }

  .chat-bubble {
    right: var(--space-sm);
    bottom: var(--space-sm);
  }
}
