/* Obras Residencies — Artist Archive */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f9f8f6;
  --surface: #ffffff;
  --border: #e8e4df;
  --text: #1a1a1a;
  --text-muted: #6b6560;
  --accent: #2d2926;
  --tag-bg: #f0ede8;
  --radius: 4px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.05);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.13), 0 12px 40px rgba(0,0,0,0.08);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 40px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.filter-bar input { min-width: 200px; }
.filter-bar select { min-width: 140px; cursor: pointer; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--accent); }

.filter-bar .count {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-clear {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-family: var(--font);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-clear:hover { border-color: var(--accent); color: var(--accent); }

/* ── Grid ── */
.gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 28px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 1200px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .gallery { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px)  {
  .gallery { grid-template-columns: 1fr; padding: 16px; }
  .filter-bar { padding: 12px 16px; }
  .site-header { padding: 16px; }
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow);
  will-change: transform;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.card:hover .card-photo { transform: scale(1.03); }

.card-photo-wrap {
  overflow: hidden;
}

.card-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: var(--tag-bg);
  transition: transform 0.4s ease;
}

.card-photo-placeholder {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--tag-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2rem;
}

.card-body {
  padding: 14px 16px 16px;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-discipline {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 2px 7px;
  background: var(--tag-bg);
  border-radius: 2px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Empty / Loading states ── */
.state-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.65);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* backdrop blur for a premium feel */
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-overlay.open { display: flex; }

/* ── Modal panel ── */
.modal {
  background: var(--surface);
  border-radius: 6px;
  width: 100%;
  max-width: 940px;
  max-height: 88vh;
  overflow: hidden;
  position: relative;
  box-shadow: 0 32px 100px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  /* JS controls transform for the FLIP animation */
  will-change: transform, opacity;
}

/* ── Two-column layout ── */
.modal-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left column: portrait + links */
.modal-left {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.modal-portrait {
  width: 100%;
  flex: 1;
  object-fit: cover;
  display: block;
  min-height: 0;
  background: var(--tag-bg);
}

.modal-portrait-placeholder {
  width: 100%;
  flex: 1;
  min-height: 200px;
  background: var(--tag-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-muted);
}

.modal-left-footer {
  flex-shrink: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.modal-left-footer a {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.modal-left-footer a:hover { opacity: 1; }
.modal-left-footer a::before { content: '↗'; font-size: 0.7rem; }

/* Right column: scrollable content */
.modal-right {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-right::-webkit-scrollbar { width: 5px; }
.modal-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.modal-right-inner {
  padding: 32px 36px 40px;
}

/* Close button */
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,0.92);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 1px 5px rgba(0,0,0,0.15);
  transition: background 0.15s, transform 0.15s;
}
.modal-close:hover { background: #fff; transform: scale(1.1); }

/* Modal content typography */
.modal-name {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  align-items: center;
  margin-bottom: 6px;
}

.modal-subtitle .sep { color: var(--border); }

.modal-subtitle span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-subtitle .pill {
  background: var(--tag-bg);
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}

.modal-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.modal-text {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

/* Residency info grid */
.modal-residency-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 20px;
}

.modal-residency-item label {
  display: block;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.modal-residency-item span {
  font-size: 0.87rem;
  color: var(--text);
}

/* Documentation image grid */
.modal-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.modal-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.modal-images img:hover { opacity: 0.88; }

/* Mobile modal: stack vertically */
@media (max-width: 700px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92vh; border-radius: 12px 12px 0 0; flex-direction: column; }
  .modal-layout { flex-direction: column; overflow-y: auto; }
  .modal-left { width: 100%; flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .modal-portrait { width: 160px; flex: none; height: 220px; }
  .modal-portrait-placeholder { width: 160px; flex: none; height: 220px; min-height: unset; }
  .modal-left-footer { flex: 1; border-top: none; border-left: 1px solid var(--border); justify-content: flex-end; }
  .modal-right { overflow-y: visible; }
  .modal-right-inner { padding: 20px; }
  .modal-name { font-size: 1.3rem; }
  .modal-residency-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-images { grid-template-columns: repeat(2, 1fr); }
}
