﻿/* ============================================================
   TEMPLATE STUDIO
   The gallery is a shelf of printed strips, not a card grid.
   Every preview is a real rendered photostrip (see preview.js),
   given a paper shadow, a slight lift on hover, and an editorial
   rhythm that varies strip height per template.
   ============================================================ */

.templates-page {
  padding-top: clamp(var(--space-5), 4vw, var(--space-8));
}

.templates-page::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: 220px;
  background: radial-gradient(ellipse at 15% 0%, rgba(151, 139, 255, 0.18), transparent 58%);
  pointer-events: none;
  z-index: -1;
}

/* ------------------------------ Page head ------------------------------- */

.studio-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-5);
}

.studio-head h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 10px;
}

.studio-head .muted-text {
  max-width: 54ch;
  font-size: var(--fs-md);
  line-height: 1.65;
}

.studio-head-note {
  flex: 0 0 auto;
  max-width: 260px;
  padding: var(--space-4);
  border: 1px solid rgba(106, 90, 249, 0.14);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.6;
  box-shadow: 0 8px 20px rgba(35, 28, 80, 0.04);
}

.studio-head-note strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 600;
}

/* --------------------------- Category navigation ------------------------- */

/* A creative-app style rail: hairline underlined tabs, not pill chips. */
.category-rail {
  position: sticky;
  top: 78px;
  z-index: calc(var(--z-sticky) - 1);
  margin-bottom: var(--space-6);
  padding-top: 8px;
  background: rgba(246, 244, 255, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.category-row {
  gap: 8px;
}

.category-tab {
  position: relative;
  padding: 10px 14px;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.category-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
}

.category-tab[aria-selected='true'] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* category rail and .strip-thumb are shared primitives - see components.css */

/* --------------------------- Editorial mosaic ---------------------------- */

/*
 * Rows of different lengths rather than a uniform grid, so the library
 * reads like a laid-out contact sheet. Templates keep their true strip
 * proportions, which means some tiles are visibly taller than others.
 */
.strip-gallery {
  display: flex;
  flex-direction: column;
  gap: clamp(var(--space-5), 5vw, var(--space-7));
  padding-bottom: var(--space-6);
}

.gallery-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(var(--space-5), 5vw, var(--space-8));
  flex-wrap: wrap;
}

.gallery-row--offset {
  justify-content: flex-start;
  padding-left: clamp(0px, 6vw, 120px);
}

.gallery-row--wide {
  gap: clamp(var(--space-6), 7vw, 110px);
}

/* -------------------------------- Tile ---------------------------------- */

.strip-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  flex: 0 0 auto;
  padding: 10px 8px 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: center;
  transition: transform var(--dur-base) var(--ease-print);
  border-radius: 18px;
}

.strip-tile:hover,
.strip-tile:focus-visible {
  transform: translateY(-8px);
}

.strip-tile:hover,
.strip-tile:focus-visible,
.strip-tile.is-selected {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 12px 30px rgba(35, 28, 80, 0.06);
}

.strip-tile:focus-visible {
  outline: none;
}

/* the paper itself */
.strip-tile-brand {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(18, 14, 28, 0.84);
  color: #fff;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-settle);
  pointer-events: none;
}

.strip-tile-paper {
  position: relative;
  display: block;
  width: var(--tile-width, 190px);
  aspect-ratio: var(--strip-ratio, 3 / 4);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-paper);
  transition: box-shadow var(--dur-base) var(--ease-print), transform var(--dur-base) var(--ease-print);
  overflow: visible;
}

.strip-tile:hover .strip-tile-brand,
.strip-tile:focus-visible .strip-tile-brand,
.strip-tile.is-selected .strip-tile-brand {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.strip-tile:hover .strip-tile-paper,
.strip-tile:focus-visible .strip-tile-paper {
  box-shadow: var(--shadow-paper-lg), 0 10px 24px rgba(106, 90, 249, 0.12);
}

/* a thin edge highlight sells the "sheet of paper" read */
.strip-tile-paper::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  pointer-events: none;
}

/* .strip-thumb is a shared primitive - see components.css */

.strip-tile-paper[data-ready='true'] .strip-thumb {
  opacity: 1;
}

/* while a tile renders, reserve the space so nothing jumps */
.strip-tile-paper:not([data-ready='true']) {
  background: linear-gradient(100deg, var(--surface-sunken) 30%, var(--surface-alt) 50%, var(--surface-sunken) 70%);
  background-size: 220% 100%;
  animation: paper-shimmer 1.4s var(--ease) infinite;
}

@keyframes paper-shimmer {
  to {
    background-position: -220% 0;
  }
}

.strip-tile-paper.is-preview-failed {
  background: var(--surface-sunken);
}

/* selection: lift + check, never a glow */
.strip-tile.is-selected .strip-tile-paper {
  transform: scale(1.055);
  box-shadow: var(--shadow-paper-lg), 0 0 0 2px rgba(106, 90, 249, 0.4), 0 18px 38px rgba(106, 90, 249, 0.18);
}

.strip-tile-check {
  position: absolute;
  top: -10px;
  right: -10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 3px 10px rgba(43, 34, 25, 0.28);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease-settle);
  pointer-events: none;
  z-index: 2;
}

.strip-tile-check .lucide {
  width: 14px;
  height: 14px;
}

.strip-tile.is-selected .strip-tile-check {
  opacity: 1;
  transform: scale(1);
}

.strip-tile-name {
  color: var(--ink);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color var(--dur-fast) var(--ease);
}

.strip-tile.is-selected .strip-tile-name {
  font-weight: 700;
}

.strip-tile-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-light);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.strip-tile-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

/* the selected caption turns into a state label */
.strip-tile-state {
  display: inline-flex;
  align-items: center;
  height: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}

.strip-tile-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-settle);
}

.strip-tile:hover .strip-tile-action,
.strip-tile:focus-visible .strip-tile-action {
  opacity: 1;
  transform: translateY(0);
}

.strip-tile.is-selected .strip-tile-state {
  height: auto;
  opacity: 1;
}

/* --------------------------- Featured showcase -------------------------- */

.showcase {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(var(--space-6), 5vw, 80px);
  margin-bottom: var(--space-7);
  padding: clamp(var(--space-5), 4vw, 64px);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(243, 239, 255, 0.72));
  border: 1px solid rgba(124, 111, 191, 0.14);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.showcase::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 18% 20%, rgba(214, 190, 150, 0.16), transparent 70%),
    radial-gradient(ellipse 50% 60% at 85% 85%, rgba(160, 175, 190, 0.12), transparent 70%);
  pointer-events: none;
}

.showcase-intro {
  position: absolute;
  top: var(--space-4);
  left: var(--space-5);
}

.showcase-intro::after {
  content: 'Featured';
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.showcase-intro h3 {
  margin: 6px 0 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  letter-spacing: -0.025em;
}

.showcase-kicker {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid rgba(106, 90, 249, 0.18);
  border-radius: var(--radius-pill);
  color: #6254c6;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.showcase-strips {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.showcase-strip {
  width: 168px;
  aspect-ratio: var(--strip-ratio, 3 / 4);
  background: var(--surface);
  border-radius: 2px;
  box-shadow: var(--shadow-paper-lg);
  transition: transform var(--dur-base) var(--ease-print);
}

.showcase-strip .strip-thumb {
  opacity: 0;
}

.showcase-strip[data-ready='true'] .strip-thumb {
  opacity: 1;
}

.showcase-strip--back {
  width: 146px;
  transform: rotate(-9deg) translateX(26%);
  z-index: 1;
  opacity: 0.92;
}

.showcase-strip--front {
  width: 178px;
  transform: rotate(3.5deg);
  z-index: 2;
}

.showcase-strip--side {
  width: 132px;
  transform: rotate(11deg) translateX(-26%);
  z-index: 1;
  opacity: 0.88;
}

.showcase-copy {
  position: relative;
  padding-top: var(--space-6);
}

.showcase-copy h3 {
  margin-bottom: var(--space-3);
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.showcase-copy .preview-drawer-actions {
  margin-top: var(--space-4);
}

.showcase-copy p {
  max-width: 42ch;
  margin-bottom: var(--space-4);
  font-size: var(--fs-md);
  line-height: 1.7;
}

.showcase-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: var(--space-5);
}

.showcase-tag {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
}

/* --------------------------- Preview panel ------------------------------- */

.preview-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: end center;
  background: rgba(30, 25, 20, 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-base) var(--ease), visibility var(--dur-base) var(--ease);
}

.preview-drawer.open {
  opacity: 1;
  visibility: visible;
}

.preview-drawer-panel {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(var(--space-5), 4vw, 56px);
  align-items: center;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  padding: clamp(var(--space-5), 3vw, 40px);
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-xl);
  transform: translateY(24px);
  transition: transform var(--dur-base) var(--ease-print);
}

.preview-drawer.open .preview-drawer-panel {
  transform: translateY(0);
}

.preview-drawer-stage {
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: linear-gradient(160deg, var(--surface-alt), var(--surface-sunken));
  border-radius: var(--radius-md);
}

.preview-drawer-strip {
  width: 232px;
  max-height: 56vh;
  aspect-ratio: var(--strip-ratio, 3 / 4);
  object-fit: contain;
  background: var(--surface);
  border-radius: 2px;
  box-shadow: var(--shadow-paper-lg);
}

.preview-drawer-copy {
  min-width: 0;
}

.preview-drawer-title {
  margin-bottom: 6px;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.preview-drawer-desc {
  max-width: 44ch;
  margin-bottom: var(--space-4);
  font-size: var(--fs-base);
  line-height: 1.7;
}

.preview-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  max-width: 420px;
}

.preview-spec {
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
}

.preview-spec dt {
  margin-bottom: 2px;
  color: var(--muted-light);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.preview-spec dd {
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.preview-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.preview-drawer-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}

/* ------------------------- Selection summary bar ------------------------- */

.selection-bar {
  position: sticky;
  bottom: var(--space-3);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
}

.selection-summary {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.selection-label {
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.selection-summary strong {
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-meta {
  color: var(--muted);
  font-size: var(--fs-xs);
}

/* ------------------------------ Empty state ------------------------------ */

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-5);
  text-align: center;
}
