/*
  Public site: home, download, auth utilities, theme catalog and theme detail.
*/

/* ============================================================
   Page shells
   ============================================================ */

/* Centered single-block pages (home hero, auth card). Height comes from the
   flex body in base.css, so no magic footer offset here. */
.public-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-5);
  min-height: calc(100vh - var(--topbar-height) - var(--space-9));
}

.public-narrow,
.public-page {
  width: 100%;
  max-width: var(--content-narrow);
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) var(--space-8);
}

.public-catalog {
  width: 100%;
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) var(--space-8);
}

/* ---- Page header block: title + lede, one rhythm everywhere ---- */

.public-narrow h1,
.public-page h1,
.catalog-header h1 {
  margin-bottom: var(--space-3);
}

.public-narrow .lede,
.public-page .lede,
.catalog-header .lede,
.page-hero .lede {
  color: var(--color-text-secondary);
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body-lg);
  max-width: var(--measure);
}

.public-narrow .lede,
.public-page .lede {
  margin-bottom: var(--space-6);
}

.catalog-header {
  margin-bottom: var(--space-6);
}

/* ============================================================
   Home hero
   ============================================================ */

.page-hero {
  max-width: 620px;
  text-align: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  margin: 0 0 var(--space-5);
  padding: 0 var(--space-3);
  border: var(--border-hairline-width) solid rgba(242, 118, 46, 0.28);
  border-radius: var(--radius-full);
  background: var(--color-brand-orange-soft);
  color: var(--color-brand-orange);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: var(--ls-caption);
  text-transform: uppercase;
}

.page-hero h1 {
  font-size: var(--fs-display-md);
  line-height: var(--lh-display-md);
  letter-spacing: var(--ls-display-md);
  margin-bottom: var(--space-4);
}

.page-hero .lede {
  margin: 0 auto var(--space-6);
}

.page-hero .actions {
  justify-content: center;
}

.page-hero .note {
  margin-top: var(--space-6);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
}

/* The holding page carries a single statement, so the hero title steps up to
   display-lg once there is room for it. Other public h1 stay at display-md. */
@media (min-width: 900px) {
  .page-hero h1 {
    font-size: var(--fs-display-lg);
    line-height: var(--lh-display-lg);
    letter-spacing: var(--ls-display-lg);
  }
}

/* ============================================================
   Download page
   ============================================================ */

/* The version card leads the page: it carries the actual download. */
.download-primary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.download-build-info {
  flex: 1 1 200px;
  min-width: 0;
}

.download-build-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.download-version {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-display-sm);
  line-height: var(--lh-display-sm);
  letter-spacing: var(--ls-display-sm);
}

.download-subversion {
  margin: 0 0 var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
}

.download-meta {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
}

.download-disclaimer {
  margin: var(--space-3) 0 0;
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
}

.download-card-early {
  margin-top: var(--space-4);
}

.download-primary .btn {
  flex-shrink: 0;
}

/* ============================================================
   Theme catalog
   ============================================================ */

/* Browse controls: one row on desktop, wrapping on a phone. A plain GET form, so there is
   nothing here to style around a script. */
.catalog-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.catalog-filters .field {
  margin: 0;
}

.catalog-filter-search {
  flex: 1 1 240px;
  min-width: 180px;
}

.catalog-count {
  margin-top: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  font-variant-numeric: tabular-nums;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
}

/* Statement card: sharp corners (design system §5). The render is the product,
   so the preview leads and the status/price ride on top of it. */
.theme-card {
  display: flex;
  flex-direction: column;
  border: var(--border-hairline-width) solid var(--color-border-hairline);
  border-radius: var(--radius-sharp);
  background: var(--color-surface-raised);
  overflow: hidden;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast),
    transform var(--transition-fast);
}

.theme-card:hover {
  border-color: var(--color-brand-orange);
  background: var(--color-surface-overlay);
  color: var(--color-text-primary);
  transform: translateY(-2px);
}

.theme-card-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--color-surface-overlay);
  border-bottom: var(--border-hairline-width) solid var(--color-border-hairline);
  overflow: hidden;
}

.theme-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sharp);
  transition: transform var(--transition-base);
}

.theme-card:hover .theme-card-preview img {
  transform: scale(1.04);
}

.theme-card-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  font-size: var(--fs-display-md);
}

/* Tags sit over an arbitrary render, so each one carries its own dark plate
   instead of relying on the image behind it. */
.theme-card-tags {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  right: var(--space-3);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.theme-card-tags .badge {
  background: rgba(11, 13, 18, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-color: rgba(244, 245, 247, 0.18);
}

.theme-card-tags .badge-preorder {
  margin-right: auto;
  color: var(--color-brand-orange);
}

.badge-price {
  color: var(--color-text-primary);
}

.badge-free {
  color: var(--color-brand-green);
}

.theme-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  flex: 1;
}

.theme-card-body h2 {
  font-size: var(--fs-body-lg);
  line-height: 1.3;
  margin: 0;
}

.theme-card-author {
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
  color: var(--color-text-secondary);
}

.theme-card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: var(--border-hairline-width) solid var(--color-border-hairline);
  color: var(--color-text-secondary);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  font-variant-numeric: tabular-nums;
}

.theme-card-facts span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.theme-card-facts i {
  color: var(--color-text-faint);
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  border: var(--border-hairline-width) solid var(--color-border-strong);
  background: var(--color-surface-overlay);
  font-size: var(--fs-caption);
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--color-text-secondary);
}

.badge-preorder {
  color: var(--color-brand-orange);
  background: var(--color-brand-orange-soft);
  border-color: rgba(242, 118, 46, 0.28);
}

.badge-owned {
  color: var(--color-brand-green);
  background: var(--color-brand-green-soft);
  border-color: rgba(46, 212, 122, 0.28);
}

.badge-new {
  color: var(--color-brand-green);
  background: var(--color-brand-green-soft);
  border-color: rgba(46, 212, 122, 0.28);
}

/* Orange is the CTA colour, so a sale badge borrows it deliberately: a discount is the one
   catalog fact that is meant to read as an offer. */
.badge-sale {
  color: var(--color-brand-orange);
  background: var(--color-brand-orange-soft);
  border-color: rgba(242, 118, 46, 0.28);
}

/* The struck-through list price rides inside the price plate, one step down in size and colour
   so the amount that is actually charged stays the loud one. */
.price-was {
  color: var(--color-text-faint);
  font-weight: 500;
  text-decoration-thickness: 1px;
}

/* ============================================================
   Theme page — header
   ============================================================ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-md);
}

.back-link:hover {
  color: var(--color-text-primary);
}

/* The detail page runs at the wide catalog width: the gallery needs the room
   next to a fixed-width buy panel. */
.theme-page-wrap {
  padding-bottom: var(--space-9);
}

.theme-page-head {
  margin-bottom: var(--space-6);
}

.theme-detail-meta {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.theme-page-head h1 {
  margin: 0;
}

.theme-page-author {
  margin-top: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-lg);
}

/* ============================================================
   Theme page — layout
   ============================================================ */

.theme-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas:
    "gallery buy"
    "content buy";
  gap: var(--space-7) var(--space-6);
  align-items: start;
}

.theme-gallery {
  grid-area: gallery;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.theme-gallery-empty {
  grid-column: 1 / -1;
}

.theme-page-content {
  grid-area: content;
  display: grid;
  gap: var(--space-6);
  align-content: start;
}

.theme-buybox {
  grid-area: buy;
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  align-self: start;
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface-raised);
  border: var(--border-hairline-width) solid var(--color-border-hairline);
  border-radius: var(--radius-md);
}

/* ============================================================
   Theme page — gallery
   ============================================================ */

/* Preview frames are statement pieces: sharp, hairline, no rounding. The first
   shot runs full width because it is what sells the theme. */
.theme-shot {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-surface-overlay);
  border: var(--border-hairline-width) solid var(--color-border-hairline);
  border-radius: var(--radius-sharp);
  transition: border-color var(--transition-fast);
}

/* The lead shot shows the whole render — a theme is judged on the full frame,
   so it must not be cropped. The smaller shots stay a uniform 16:9 grid. */
.theme-shot.is-lead {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  background: var(--color-surface-canvas);
}

.theme-shot.is-lead img {
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.theme-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-base);
}

.theme-shot:hover {
  border-color: var(--color-brand-orange);
}

.theme-shot:hover img {
  transform: scale(1.02);
}

.theme-shot-zoom {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(11, 13, 18, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--color-text-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.theme-shot:hover .theme-shot-zoom,
.theme-shot:focus-visible .theme-shot-zoom {
  opacity: 1;
}

/* ============================================================
   Theme page — buy box
   ============================================================ */

.theme-price-block {
  display: grid;
  gap: var(--space-1);
}

/* The one place a display numeral is allowed outside a page title: a short,
   loud price with no body copy at the same size next to it. */
.theme-price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-display-md);
  line-height: 1.05;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.theme-price-was {
  font-family: var(--font-body);
  font-size: var(--fs-body-lg);
  font-weight: 500;
  color: var(--color-text-faint);
  margin-left: var(--space-2);
  vertical-align: middle;
}

.theme-price .badge-sale {
  vertical-align: middle;
  margin-left: var(--space-2);
}

.theme-sale-ends {
  color: var(--color-brand-orange);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
}

.theme-buybox-sub {
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
  font-variant-numeric: tabular-nums;
}

.theme-buybox-actions {
  display: grid;
  gap: var(--space-3);
}

.theme-buybox-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: calc(var(--space-2) * -1);
}

.theme-buybox-note i {
  color: var(--color-brand-green);
  line-height: var(--lh-body-sm);
}

/* Order created: the code and the payment links belong to the same moment. */
.theme-order {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-brand-orange-soft);
  border: var(--border-hairline-width) solid rgba(242, 118, 46, 0.3);
}

.theme-order-code {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-display-sm);
  line-height: var(--lh-display-sm);
  letter-spacing: 0.08em;
  color: var(--color-text-primary);
  word-break: break-all;
}

.theme-order .hint {
  margin-top: var(--space-1);
}

.theme-order-links {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: var(--border-hairline-width) solid rgba(242, 118, 46, 0.3);
}

.theme-buybox-block,
.theme-buybox-facts {
  padding-top: var(--space-4);
  border-top: var(--border-hairline-width) solid var(--color-border-hairline);
}

.theme-buybox-block {
  display: grid;
  gap: var(--space-2);
}

/* In a narrow panel the facts read better as label-left / value-right rows
   than as the two fixed columns .meta-list uses in a wide card. */
.theme-buybox-facts > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  grid-template-columns: none;
  padding: var(--space-2) 0;
}

.theme-buybox-facts dt {
  font-size: var(--fs-body-sm);
  white-space: nowrap;
}

.theme-buybox-facts dd {
  font-size: var(--fs-body-sm);
  text-align: right;
  min-width: 0;
}

/* ============================================================
   Theme page — content sections
   ============================================================ */

.theme-section {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

.theme-section h2 {
  padding-bottom: var(--space-3);
  border-bottom: var(--border-hairline-width) solid var(--color-border-hairline);
}

.theme-prose {
  max-width: var(--measure);
  color: var(--color-text-secondary);
  white-space: pre-line;
}

.theme-notes {
  margin: 0;
  padding: var(--space-4);
  border-left: 2px solid var(--color-brand-orange);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  max-width: var(--measure);
  white-space: pre-line;
}

.theme-changelog {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: var(--measure);
}

.theme-changelog-entry {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border-left: 2px solid var(--color-border-hairline);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--color-surface-raised);
}

/* The shipped version wears the same orange rule as the author's note, so the eye lands first
   on what you would actually download right now. */
.theme-changelog-entry.is-current {
  border-left-color: var(--color-brand-orange);
}

.theme-changelog-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.theme-changelog-version {
  font-size: var(--fs-body-md);
  font-weight: 600;
  color: var(--color-text-primary);
}

.theme-changelog-date {
  font-size: var(--fs-body-sm);
  color: var(--color-text-secondary);
}

.theme-changelog-notes {
  margin: 0;
  max-width: var(--measure);
  color: var(--color-text-secondary);
  white-space: pre-line;
}

.theme-changelog-empty {
  margin: 0;
  font-size: var(--fs-body-sm);
}

.theme-changelog-more {
  margin: 0;
}

.theme-changelog-more > summary {
  cursor: pointer;
  padding: var(--space-3) 0;
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
}

.theme-changelog-more > summary:hover {
  color: var(--color-text-primary);
}

.theme-changelog-more[open] > summary {
  margin-bottom: var(--space-3);
}

/* A version whose archive retention has already pruned: still in the history, no longer
   downloadable. */
.badge-muted {
  opacity: 0.7;
}

.theme-layout-groups {
  display: grid;
  max-width: var(--measure);
}

.theme-layout-group {
  margin: 0;
  border-bottom: var(--border-hairline-width) solid var(--color-border-hairline);
}

.theme-layout-group:last-child {
  border-bottom: 0;
}

.theme-layout-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-3) 0;
  color: var(--color-text-primary);
  font-size: var(--fs-body-md);
  font-weight: 600;
  list-style: none;
}

.theme-layout-group > summary::-webkit-details-marker {
  display: none;
}

.theme-layout-group > summary:hover {
  color: var(--color-text-primary);
}

.theme-layout-group[open] > summary {
  margin-bottom: var(--space-2);
}

.theme-layout-group-type {
  min-width: 0;
}

.theme-layout-group-count {
  flex-shrink: 0;
  font-size: var(--fs-body-sm);
  font-weight: 400;
  color: var(--color-text-secondary);
}

.theme-layout-group .theme-layout-list {
  margin-bottom: var(--space-3);
}

.theme-layout-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: var(--measure);
}

.theme-layout-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: var(--border-hairline-width) solid var(--color-border-hairline);
  font-size: var(--fs-body-md);
}

.theme-layout-list li:last-child {
  border-bottom: 0;
}

.theme-layout-list i {
  color: var(--color-text-faint);
}

.theme-layout-name {
  flex: 1;
  min-width: 0;
}

.theme-chip-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Payment / contact link lists. */
.link-list-plain {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list-plain a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-body-md);
  word-break: break-word;
}

.link-list-plain i {
  font-size: var(--fs-body-sm);
  flex-shrink: 0;
}

.text-link {
  color: var(--color-brand-orange);
}

/* ============================================================
   Buy flow — /themes/{id}/buy, /buy/payment, /buy/confirm, /order
   ============================================================ */

/* Wider than the 640px .public-page default: the explainer needs room for two
   columns, while the prose inside it stays capped at --measure. */
.theme-buy-page {
  max-width: 780px;
  display: grid;
  gap: var(--space-6);
  align-content: start;
}

.theme-buy-page .back-link {
  margin-bottom: 0;
}

.theme-buy-head {
  display: grid;
  gap: var(--space-3);
}

.theme-buy-head h1 {
  margin: 0;
}

.theme-buy-subject {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--fs-body-md);
}

.theme-buy-subject-name {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* ---- Step indicator ---- */

.theme-buy-steps ol {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.theme-buy-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-faint);
  font-size: var(--fs-body-sm);
}

.theme-buy-step + .theme-buy-step::before {
  content: "";
  width: var(--space-5);
  height: 1px;
  margin-right: var(--space-1);
  background: var(--color-border-hairline);
}

.theme-buy-step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  border: var(--border-hairline-width) solid var(--color-border-strong);
  font-size: var(--fs-caption);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.theme-buy-step.is-current {
  color: var(--color-text-primary);
  font-weight: 600;
}

.theme-buy-step.is-current .theme-buy-step-num {
  background: var(--color-brand-orange);
  border-color: var(--color-brand-orange);
  color: var(--color-text-on-accent);
}

.theme-buy-step.is-done {
  color: var(--color-text-secondary);
}

.theme-buy-step.is-done .theme-buy-step-num {
  background: var(--color-brand-green-soft);
  border-color: rgba(46, 212, 122, 0.32);
  color: var(--color-brand-green);
}

/* ---- Numbered "how it works" ---- */

.theme-flow {
  display: grid;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: var(--measure);
}

.theme-flow-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.theme-flow-num {
  flex-shrink: 0;
  width: 2ch;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-display-sm);
  line-height: 1.1;
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
}

.theme-flow-item h3 {
  margin-bottom: var(--space-1);
}

.theme-flow-item p {
  color: var(--color-text-secondary);
}

/* ---- Payment links on the order page ----
   Only here, once the order code exists: each link opens in a new tab or copies,
   with its host shown so the buyer can see where it goes before following it. */

.theme-pay-links {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.theme-pay-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-hairline-width) solid var(--color-border-hairline);
  background: var(--color-surface-sunken);
}

.theme-pay-link-name {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 0;
}

.theme-pay-link-name i {
  color: var(--color-text-faint);
}

.theme-pay-link-label {
  font-weight: 600;
}

.theme-pay-link-host {
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  word-break: break-all;
}

.theme-pay-link-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ---- Step footers ---- */

.theme-buy-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.theme-buy-form {
  display: grid;
  gap: var(--space-5);
}

.theme-buy-form .field {
  margin-bottom: 0;
}

/* ---- Order page ---- */

.theme-buy-page .theme-order {
  justify-items: start;
}

.theme-order-expiry {
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-sm);
}

@media (max-width: 640px) {
  .theme-pay-link-actions,
  .theme-pay-link-actions .btn {
    flex: 1;
  }

  .theme-buy-steps ol {
    gap: var(--space-2);
  }

  .theme-buy-step + .theme-buy-step::before {
    display: none;
  }

  .theme-buy-step-label {
    display: none;
  }

  .theme-buy-step.is-current .theme-buy-step-label {
    display: inline;
  }

  .theme-buy-actions .btn {
    flex: 1;
  }
}

/* ============================================================
   Full-size preview — :target only, no scripting
   ============================================================ */

.lightbox {
  display: none;
}

.lightbox:target {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: rgba(5, 6, 9, 0.88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
}

.lightbox-figure {
  position: relative;
  z-index: 1;
  margin: 0;
  display: grid;
  gap: var(--space-3);
  justify-items: center;
  max-width: min(1280px, 100%);
}

.lightbox-figure img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  object-fit: contain;
  background: var(--color-surface-canvas);
  border: var(--border-hairline-width) solid var(--color-border-strong);
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
}

.lightbox-nav {
  display: flex;
  gap: var(--space-2);
}

/* ============================================================
   Narrow viewports
   ============================================================ */

@media (max-width: 1000px) {
  /* The buy box follows the gallery, before the long-form sections. */
  .theme-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "gallery"
      "buy"
      "content";
    gap: var(--space-6);
  }

  .theme-buybox {
    position: static;
  }
}

@media (max-width: 640px) {
  .public-main {
    padding: var(--space-7) var(--space-4);
    min-height: 0;
  }

  .public-narrow,
  .public-page,
  .public-catalog {
    padding: var(--space-6) var(--space-4) var(--space-7);
  }

  .theme-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .theme-gallery {
    grid-template-columns: minmax(0, 1fr);
  }

  .theme-buybox {
    padding: var(--space-4);
  }

  .theme-price {
    font-size: var(--fs-display-sm);
  }

  .lightbox:target {
    padding: var(--space-3);
  }

  .lightbox-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .lightbox-nav {
    justify-content: space-between;
  }
}
