/**
 * ItemMap · Atelier layer
 *
 * The luxury design language for the browsing surfaces (Home, Spaces,
 * Zones, Search): "The Estate Catalog" — a privately printed inventory
 * of a fine residence. Numbered plates, hairline rules, serif display,
 * letterspaced small caps, warm paper, terracotta spent sparingly.
 *
 * Builds ON TOP of design-tokens.css (loaded first). Page-specific
 * styles stay inline in their components per codebase idiom; everything
 * here is shared vocabulary.
 */

:root {
  /* Atelier-specific refinements */
  --at-hairline: rgba(61, 79, 74, 0.14);
  --at-hairline-soft: rgba(61, 79, 74, 0.08);
  --at-plate-mat: #FFFFFF;
  --at-plate-well: #221E19;          /* dark well behind 3D scans */
  --at-ink-display: #2A2723;         /* warm near-black for big serif */
  --at-caption: #8A8378;
  --at-gold: #C9A35E;
  --at-max-width: 1280px;
  --at-gutter: clamp(24px, 5vw, 64px);

  --at-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --at-dur: 0.45s;
}

/* ============================================================
   PAGE SCAFFOLD
   ============================================================ */

.at-page {
  min-height: calc(100vh - var(--nav-height, 60px));
  background:
    radial-gradient(ellipse 90% 40% at 50% 0%, rgba(232, 220, 200, 0.35) 0%, transparent 65%),
    var(--color-bg, #FDFBF8);
  padding-bottom: 120px;
}

.at-container {
  max-width: var(--at-max-width);
  margin: 0 auto;
  padding: 0 var(--at-gutter);
}

/* Subtle paper grain over the whole page (matches the splash) */
.at-grain::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: 1;
}

/* ============================================================
   TYPOGRAPHY VOCABULARY
   ============================================================ */

.at-eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--sage-700, #3D544B);
}

.at-eyebrow--accent { color: var(--terra-700, #B85838); }
.at-eyebrow--muted  { color: var(--at-caption); }

.at-display {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--at-ink-display);
  margin: 0;
}

.at-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--at-ink-display);
  margin: 0;
}

.at-annotation {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--color-text-muted, #6B6560);
}

.at-caption {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  color: var(--at-caption);
}

/* Large serif figure, e.g. "214" in "214 objects" */
.at-figure {
  font-family: var(--font-display);
  font-weight: 500;
  font-variant-numeric: oldstyle-nums;
}

/* ============================================================
   RULES & ORNAMENT
   ============================================================ */

.at-rule {
  border: 0;
  border-top: 1px solid var(--at-hairline);
  margin: 0;
}

/* Hairline with a small centered diamond — section divider */
.at-rule--ornament {
  position: relative;
  overflow: visible;
}
.at-rule--ornament::after {
  content: '◆';
  position: absolute;
  top: -0.62em;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  color: var(--at-gold);
  background: var(--color-bg, #FDFBF8);
  padding: 0 14px;
  font-size: 0.8rem;
}

/* Plate number, e.g. "No. 03" */
.at-plate-no {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--at-caption);
  letter-spacing: 0.04em;
}

/* ============================================================
   SECTION HEADER (eyebrow + title row + hairline)
   ============================================================ */

.at-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--at-hairline);
  margin-bottom: 28px;
}

.at-section-head .at-eyebrow { flex-shrink: 0; }

/* ============================================================
   PLATES (location / zone cards)
   ============================================================ */

.at-plate {
  position: relative;
  display: block;
  background: var(--at-plate-mat);
  border: 1px solid var(--at-hairline-soft);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition:
    transform var(--at-dur) var(--at-ease),
    box-shadow var(--at-dur) var(--at-ease),
    border-color var(--at-dur) var(--at-ease);
}

.at-plate:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 50px rgba(61, 79, 74, 0.14);
  border-color: rgba(61, 79, 74, 0.18);
}

.at-plate:focus-visible {
  outline: 2px solid var(--terra-500, #E07856);
  outline-offset: 3px;
}

/* The image/3D area inside a plate, matted like a print */
.at-plate__media {
  position: relative;
  margin: 10px;
  overflow: hidden;
  background: linear-gradient(160deg, #ECE4D6 0%, #E2D8C6 100%);
}

.at-plate__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--at-ease), filter 1.2s var(--at-ease);
  filter: saturate(0.96);
}

.at-plate:hover .at-plate__media img {
  transform: scale(1.03);
  filter: saturate(1.04);
}

/* Empty-media monogram (no cover yet) */
.at-plate__monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 500;
  color: rgba(61, 79, 74, 0.35);
}

.at-plate__body {
  padding: 18px 22px 22px;
}

.at-plate__toprow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.at-plate__meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-top: 8px;
}

/* Staleness dot */
.at-freshness {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--sage-600, #5C7C6B);
}
.at-freshness--aging   { background: var(--at-gold); }
.at-freshness--stale   { background: var(--terra-700, #B85838); }
.at-freshness--unscanned { background: rgba(61, 79, 74, 0.25); }

/* ============================================================
   THE WELL — dark framed area for 3D scans
   ============================================================ */

.at-well {
  position: relative;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(92, 124, 107, 0.16) 0%, transparent 70%),
    linear-gradient(170deg, #262119 0%, var(--at-plate-well) 55%, #1B1713 100%);
  overflow: hidden;
}

.at-well__hint {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(242, 234, 217, 0.4);
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* ============================================================
   GALLERY WALL (item tiles)
   ============================================================ */

.at-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 26px 22px;
}

.at-tile {
  position: relative;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.at-tile__frame {
  position: relative;
  aspect-ratio: 1;
  background: var(--at-plate-mat);
  border: 1px solid var(--at-hairline-soft);
  box-shadow: 0 1px 6px rgba(46, 36, 26, 0.06);
  padding: 7px;                      /* the mat */
  transition:
    transform var(--at-dur) var(--at-ease),
    box-shadow var(--at-dur) var(--at-ease),
    border-color var(--at-dur) var(--at-ease);
  overflow: hidden;
  /* NOTE: no content-visibility here — combined with the ResizeObserver
     inside each tile and a continuously-rendering canvas above, Chrome
     layout-thrashed the main thread to a standstill. LazyThumb already
     bounds the real cost (thumbnail fetches). */
}

.at-tile:hover .at-tile__frame {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(61, 79, 74, 0.14);
}

.at-tile--selected .at-tile__frame {
  border-color: var(--terra-500, #E07856);
  box-shadow: 0 0 0 1px var(--terra-500, #E07856), 0 10px 28px rgba(184, 88, 56, 0.18);
}

.at-tile__media {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #EFE8DB;
}

.at-tile__label {
  margin-top: 9px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.98rem;
  line-height: 1.25;
  color: var(--at-ink-display);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.at-tile__sublabel {
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--at-caption);
}

/* "Open" affordance on the selected tile */
.at-tile__open {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #FDFBF8;
  background: var(--terra-500, #E07856);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(184, 88, 56, 0.35);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s var(--at-ease), transform 0.3s var(--at-ease);
  z-index: 2;
}

.at-tile--selected .at-tile__open {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   ZONE BAND (sub-location rows on a Space page)
   ============================================================ */

.at-zone-row {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 18px 6px;
  border-bottom: 1px solid var(--at-hairline-soft);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background var(--at-dur) var(--at-ease), padding-left var(--at-dur) var(--at-ease);
}

.at-zone-row:hover {
  background: rgba(232, 220, 200, 0.25);
  padding-left: 14px;
}

.at-zone-row__thumb {
  width: 86px;
  height: 64px;
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(160deg, #ECE4D6 0%, #E2D8C6 100%);
  border: 1px solid var(--at-hairline-soft);
  padding: 3px;
}

.at-zone-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.at-zone-row__arrow {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--at-caption);
  transition: transform var(--at-dur) var(--at-ease), color var(--at-dur) var(--at-ease);
}

.at-zone-row:hover .at-zone-row__arrow {
  transform: translateX(6px);
  color: var(--terra-500, #E07856);
}

/* ============================================================
   BREADCRUMB
   ============================================================ */

.at-crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.at-crumbs a {
  color: var(--at-caption);
  text-decoration: none;
  transition: color 0.25s ease;
}

.at-crumbs a:hover { color: var(--terra-700, #B85838); }

.at-crumbs__sep {
  color: rgba(61, 79, 74, 0.25);
  font-family: var(--font-display);
}

.at-crumbs__here { color: var(--sage-700, #3D544B); }

/* ============================================================
   SEARCH
   ============================================================ */

.at-search-stage {
  padding-top: clamp(48px, 10vh, 110px);
  text-align: center;
}

.at-search-field {
  position: relative;
  max-width: 720px;
  margin: 34px auto 0;
}

.at-search-input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  color: var(--at-ink-display);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--at-hairline);
  padding: 10px 44px 14px 4px;
  text-align: center;
  outline: none;
  transition: border-color 0.4s ease;
}

.at-search-input::placeholder {
  color: rgba(107, 101, 96, 0.45);
  font-style: italic;
}

.at-search-input:focus {
  border-bottom-color: var(--terra-500, #E07856);
}

.at-search-count {
  margin-top: 18px;
  min-height: 1.4em;
}

/* ============================================================
   ENTRANCE CHOREOGRAPHY
   ============================================================ */

@keyframes at-rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.at-rise {
  opacity: 0;
  animation: at-rise 0.7s var(--at-ease) forwards;
}

/* Stagger helpers — apply to siblings */
.at-rise--1 { animation-delay: 0.05s; }
.at-rise--2 { animation-delay: 0.12s; }
.at-rise--3 { animation-delay: 0.19s; }
.at-rise--4 { animation-delay: 0.26s; }
.at-rise--5 { animation-delay: 0.33s; }
.at-rise--6 { animation-delay: 0.40s; }

/* Quiet skeleton shimmer for pending media */
@keyframes at-breathe {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}

.at-pending {
  background: linear-gradient(160deg, #EFE8DB 0%, #E6DCCB 100%);
  animation: at-breathe 2.6s ease-in-out infinite;
}

/* ============================================================
   EMPTY STATES
   ============================================================ */

.at-empty {
  text-align: center;
  padding: 90px 20px;
}

.at-empty .at-annotation {
  display: block;
  margin-top: 10px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 760px) {
  .at-wall {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 20px 14px;
  }
  .at-plate__body { padding: 14px 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .at-rise { animation: none; opacity: 1; }
  .at-pending { animation: none; }
  .at-plate, .at-tile__frame, .at-plate__media img { transition: none; }
}
