/* ============================================================
   MyMembership — Themes gallery page
   Editorial rows layout with a Light/Dark preview toggle and
   brand-styled browser frames around drag-droppable
   <image-slot> screenshots.
   ============================================================ */

/* ---------- Page shell ---------- */
.th-page { background: var(--paper); }

/* This page is light from the top, so pin the nav to its dark treatment
   (the brand logo + links are cream, built to sit on obsidian). */
.th-page .nav {
  background: rgba(14, 14, 12, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(176, 141, 87, 0.12);
}

.th-hero {
  padding: clamp(11rem, 16vw, 13.5rem) 0 clamp(2rem, 4vw, 3.25rem);
  text-align: center;
}
.th-hero .lead {
  max-width: 46ch;
  margin: 1.1rem auto 0;
  color: var(--muted);
}

/* ---------- Control bar (light/dark preview toggle) ---------- */
.th-controls {
  position: sticky;
  /* tuck just under the fixed nav so it never hides behind it on scroll
     (--th-pin is set from the nav's measured height by themes.js) */
  top: var(--th-pin, 150px);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 1.6rem;
  padding: 1.1rem 0 1.2rem;
  margin-top: clamp(1.5rem, 3vw, 2.4rem);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline-light);
}

.th-controls__label {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted-light);
}

.th-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-light);
  font-weight: 600;
}
.th-mode__track {
  position: relative;
  width: 60px; height: 30px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: linear-gradient(120deg, #fff, var(--cream-soft));
  transition: background 0.3s ease, border-color 0.3s ease;
}
.th-mode__track::after {
  content: '';
  position: absolute; top: 50%; left: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gold);
  transform: translateY(-50%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
  box-shadow: 0 2px 6px rgba(14, 14, 12, 0.2);
}
.th-page.is-dark .th-mode__track { background: linear-gradient(120deg, var(--charcoal), var(--obsidian)); border-color: var(--gold); }
.th-page.is-dark .th-mode__track::after { transform: translateY(-50%) translateX(30px); background: var(--gold-bright); }
.th-mode__label { transition: color 0.25s ease; }
.th-mode__label--dark { color: var(--muted-light); }
.th-page.is-dark .th-mode__label--light { color: var(--muted-light); }
.th-page.is-dark .th-mode__label--dark { color: var(--obsidian); }
.th-mode__label--light { color: var(--obsidian); }

/* Ghost button reads on the light page; stays cream inside the dark lightbox */
.th-ghost-dark { color: var(--obsidian); border: 1px solid var(--hairline-light); }
.th-ghost-dark:hover { color: var(--gold-deep); border-color: var(--gold); }
.btn__arrow svg { width: 14px; height: 14px; display: block; }

/* ---------- Browser frame ---------- */
.bframe {
  border-radius: 14px;
  overflow: hidden;
  background: var(--charcoal);
  border: 1px solid var(--hairline);
  box-shadow: 0 30px 60px -28px rgba(14, 14, 12, 0.55), 0 4px 14px -8px rgba(14, 14, 12, 0.3);
}
.bframe__bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.95rem;
  height: 40px;
  background: var(--obsidian);
  border-bottom: 1px solid var(--hairline);
}
.bframe__dots { display: flex; gap: 0.42rem; }
.bframe__dots span {
  width: 11px; height: 11px; border-radius: 50%;
  background: rgba(244, 237, 224, 0.18);
}
.bframe__dots span:first-child { background: rgba(176, 141, 87, 0.55); }
.bframe__url {
  flex: 1;
  margin: 0 0.4rem;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.8rem;
  border-radius: 999px;
  background: var(--charcoal-2);
  color: rgba(244, 237, 224, 0.62);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bframe__url svg { width: 11px; height: 11px; flex: none; opacity: 0.7; }
.bframe__url a { color: inherit; text-decoration: none; }
.bframe__url a:hover { color: var(--gold, #b08d57); text-decoration: underline; }
.bframe__live {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--obsidian);
  background: var(--gold);
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  transition: background 0.2s ease, transform 0.2s ease;
}
.bframe__live:hover { background: var(--gold-bright); transform: translateY(-1px); }
.bframe__screen {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--charcoal-2);
}

/* image-slot screenshots stacked for light/dark crossfade */
.th-shot {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  transition: opacity 0.5s ease;
}
.th-shot--dark { opacity: 0; pointer-events: none; }
.th-page.is-dark .th-shot--light { opacity: 0; pointer-events: none; }
.th-page.is-dark .th-shot--dark { opacity: 1; pointer-events: auto; }
.th-shot::part(frame) { background: var(--charcoal-2); border-radius: 0; }
.th-shot::part(empty) { color: rgba(244, 237, 224, 0.55); }
.th-shot::part(ring) { border-color: rgba(176, 141, 87, 0.3); }

/* ---------- Meta block (shared) ---------- */
.th-meta__cat {
  font-size: 0.8rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.85rem;
}
.th-meta__name { margin-bottom: 1rem; }
.th-meta__name em { font-style: italic; color: var(--gold); }
.th-meta__desc { color: var(--muted); max-width: 42ch; margin-bottom: 1.6rem; }
.th-meta__actions { display: flex; flex-wrap: wrap; gap: 0.7rem 1.1rem; align-items: center; }

/* ============================================================
   Editorial rows
   ============================================================ */
.rows { display: flex; flex-direction: column; gap: clamp(4rem, 8vw, 7rem); padding: clamp(2.5rem, 5vw, 4rem) 0 2rem; }
.trow {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
}
/* Reveal-on-scroll only once JS arms it — static / print / no-JS shows content. */
.rows.js-reveal .trow {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.rows.js-reveal .trow.is-in { opacity: 1; transform: none; }
.trow:nth-child(even) .trow__frame { order: 1; }
.trow__num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.78rem; color: var(--gold); letter-spacing: 0.12em; margin-bottom: 1rem;
}

/* ---------- CTA strip ---------- */
.th-cta {
  text-align: center;
  padding: clamp(3.5rem, 7vw, 6rem) 0;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  border-top: 1px solid var(--hairline-light);
}
.th-cta p { color: var(--muted); max-width: 44ch; margin: 1rem auto 1.8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .trow,
  .trow:nth-child(even) { grid-template-columns: 1fr; }
  .trow:nth-child(even) .trow__frame { order: 0; }
}

@media (max-width: 560px) {
  /* Hero: trim the wide editorial measure so lines don't run short */
  .th-hero .lead { max-width: 32ch; }

  /* Control bar: keep the label + toggle on one tidy row */
  .th-controls { gap: 0.75rem 1.1rem; padding: 0.95rem 0 1rem; }

  /* Browser frame: lighten chrome so the URL + Live pill still fit */
  .bframe__bar { gap: 0.4rem; padding: 0 0.7rem; height: 36px; }
  .bframe__url { font-size: 0.66rem; padding: 0 0.6rem; }
  .bframe__live { font-size: 0.6rem; padding: 0.3rem 0.55rem; }

  /* Meta: tighten the measure and stack the actions full-width for tapping */
  .th-meta__desc { max-width: none; margin-bottom: 1.4rem; }
  .th-meta__actions { gap: 0.7rem; }
  .th-meta__actions .btn {
    width: 100%;
    justify-content: center;
    padding-left: 1.2rem;
    padding-right: 1.2rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .rows.js-reveal .trow, .th-shot { animation: none !important; transition: none !important; }
  .rows.js-reveal .trow { opacity: 1 !important; transform: none !important; }
}
@media print {
  .rows.js-reveal .trow { opacity: 1 !important; transform: none !important; }
}
