/*
Theme Name: Gallery
Theme URI: https://forshow.avetasatour.org
Description: Lightweight gallery theme for artworks. Media attachments as content, native categories and tags.
Version: 1.0
Author: Vache Asatryan
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: gallery
*/

/* Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --header-height: 4.5rem;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #f5f5f5;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

/* Single artwork: no page scroll, only text area scrolls */
html:has(.single-artwork),
body:has(.single-artwork) {
  overflow: hidden;
  height: 100svh;
}

a {
  color: #ccc;
  text-decoration: none;
}

a:hover {
  color: #fff;
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Layout */
.site-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
}

.site-header__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

@media (min-width: 769px) {
  .header-collapsible {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    margin-left: auto;
    max-width: 100%;
    text-align: right;
  }

  .primary-nav ul,
  .secondary-nav ul {
    justify-content: flex-end;
  }

  .secondary-nav {
    padding-top: 0;
    margin-top: 0;
    border-top: none;
  }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #f5f5f5;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.site-title a {
  color: #f5f5f5;
}

.site-title a:hover {
  text-decoration: none;
}

.primary-nav ul,
.secondary-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav a,
.secondary-nav a {
  color: #ccc;
}

.primary-nav a:hover,
.secondary-nav a:hover {
  color: #fff;
  text-decoration: underline;
}

/* Main */
.site-main {
  flex: 1;
  min-height: 0;
}

.site-main:has(.single-artwork) {
  flex: 0 0 auto;
  height: calc(100svh - var(--header-height));
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Front page / page content */
.content-area {
  max-width: 65ch;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.content-area .entry-content {
  margin-top: 1rem;
}

.content-area .entry-content p {
  margin: 0 0 1rem;
}

/* Archive grid */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  padding: 2rem 1.5rem;
}

.archive-item {
  margin: 0;
}

.archive-item a {
  display: block;
}

.archive-item img {
  width: 100%;
}

.archive-header {
  padding: 2rem 1.5rem 0;
}

.archive-header-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.archive-item .archive-title {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Single artwork */
.single-artwork {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.artwork-media {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100%;
  width: 100%;
  padding: 1.5rem;
  background-color: #0a0a0a;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.artwork-content {
  padding: 2rem 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.artwork-content .entry-title {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.artwork-description {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: #bbb;
  line-height: 1.6;
}

.artwork-meta {
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: #999;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.artwork-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.artwork-meta-label {
  font-weight: 500;
  color: #888;
  min-width: 4.5rem;
}

.artwork-meta a {
  color: #999;
}

.artwork-meta a:hover {
  color: #fff;
}

/* Selected toggle */
.selected-toggle {
  margin-bottom: 2rem;
}

.selected-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #999;
}

.selected-toggle-label:hover {
  color: #fff;
}

.selected-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.selected-toggle-switch {
  display: inline-block;
  width: 2.5rem;
  height: 1.25rem;
  background: #333;
  border-radius: 1.25rem;
  position: relative;
  transition: background 0.2s;
}

.selected-toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  background: #666;
  border-radius: 50%;
  transition: transform 0.2s;
}

.selected-toggle-input:checked + .selected-toggle-switch {
  background: #444;
}

.selected-toggle-input:checked + .selected-toggle-switch::after {
  transform: translateX(1.25rem);
  background: #fff;
}

.selected-toggle-text {
  font-weight: 500;
}

/* Artwork nav (category strip) */
.artwork-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid #222;
}

.artwork-nav-link {
  display: block;
  text-decoration: none;
  flex-shrink: 0;
  color: #999;
  transition: opacity 0.2s;
}

.artwork-nav-link:hover {
  text-decoration: none;
}

.artwork-nav-link img {
  max-width: 112px;
  max-height: 112px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  opacity: 1;
  transition: opacity 0.2s;
}

.artwork-nav-link.artwork-nav-current img {
  opacity: 0.7;
}

.artwork-nav-link:hover img {
  opacity: 1;
}

.artwork-nav-link.artwork-nav-current:hover img {
  opacity: 0.85;
}

/* Components */
.comments-area {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #333;
}

.comments-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.comment-list {
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
}

.comment {
  margin-bottom: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comment:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.comment-body {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  font-size: 0.8rem;
}

.comment-body .comment-author {
  font-weight: 600;
  flex-shrink: 0;
}

.comment-body .comment-metadata {
  font-size: 0.7rem;
  color: #999;
  flex-shrink: 0;
}

.comment-body .comment-metadata::before {
  content: "· ";
}

.comment-body .comment-content {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.comment-body .comment-content p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline;
}

.comment-reply-link,
.comment-edit-link {
  display: none;
}

.comments-login-required {
  color: #999;
  font-size: 0.9rem;
  font-style: italic;
}

/* Comment form - compact */
.comment-respond {
  margin-top: 0.5rem;
  padding: 0.6rem;
  background: #0a0a0a;
  border-radius: 4px;
  border: 1px solid #222;
}

.comment-form {
  margin-top: 0;
}

.comment-form p {
  margin-bottom: 0.4rem;
}

.comment-form label {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #bbb;
}

.comment-form-comment {
  margin-bottom: 0.4rem;
}

.comment-form textarea {
  width: 100%;
  min-height: 36px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.3;
  color: #f5f5f5;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-form textarea:focus {
  outline: none;
  border-color: #555;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.comment-form textarea::placeholder {
  color: #666;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: #f5f5f5;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  transition: border-color 0.2s;
}

.comment-form input[type="text"]:focus,
.comment-form input[type="email"]:focus,
.comment-form input[type="url"]:focus {
  outline: none;
  border-color: #555;
}

.comment-form .form-submit {
  margin: 0.35rem 0 0;
}

.comment-form input[type="submit"] {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #000;
  background: #f5f5f5;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.comment-form input[type="submit"]:hover {
  background: #fff;
}

.comment-form input[type="submit"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .header-collapsible {
    display: block;
    flex-basis: 100%;
    order: 3;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s, opacity 0.2s;
  }

  .header-collapsible.is-open {
    max-height: 70vh;
    opacity: 1;
    overflow-y: auto;
  }

  .primary-nav,
  .secondary-nav {
    padding: 0.75rem 0 0;
    background: transparent;
  }

  .secondary-nav {
    border-top: 1px solid #222;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
  }

  .primary-nav ul,
  .secondary-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .primary-nav li,
  .secondary-nav li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #222;
  }

  .primary-nav li:last-child,
  .secondary-nav li:last-child {
    border-bottom: none;
  }

  .site-header__top {
    position: relative;
    z-index: 100;
  }

  .site-header {
    position: relative;
    z-index: 100;
  }

  html:has(.single-artwork),
  body:has(.single-artwork) {
    overflow: auto;
    height: auto;
    min-height: 100svh;
  }

  .site-main:has(.single-artwork) {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .single-artwork {
    grid-template-columns: 1fr;
  }

  .artwork-media {
    min-height: 60vh;
    position: relative;
  }

  .artwork-content {
    padding: 1.5rem;
    overflow: visible;
  }
}
