/* ===========================================================================
   Shared components for every design variant.

   Loaded before the design stylesheet, so a design only has to define its
   colour tokens and may override anything here. Uses the tokens that every
   design declares: --accent, --accent-strong, --accent-soft, --mint, --page,
   --surface, --surface-2, --text, --muted, --line, --radius, --radius-sm.
   =========================================================================== */

/* ------------------------------------------------------------ theme toggle */
.pv-theme-toggle {
  display: inline-flex; align-items: center; gap: .3rem; cursor: pointer;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: .22rem .3rem; font: inherit; font-size: .8rem;
}
.pv-theme-toggle:hover { border-color: var(--accent); }
.pv-theme-toggle__pair {
  display: inline-flex; align-items: center; gap: .28rem;
  padding: .16rem .55rem; border-radius: 999px; line-height: 1;
}
.pv-theme-toggle__pair .pv-icon { width: .95rem; height: .95rem; display: block; }
html[data-theme="light"] .pv-theme-toggle__pair[data-pair="light"],
html[data-theme="dark"] .pv-theme-toggle__pair[data-pair="dark"] {
  background: var(--surface); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
html[data-theme="light"] .pv-theme-toggle__pair[data-pair="light"] .pv-icon--sun { color: #d99a20; }
html[data-theme="dark"] .pv-theme-toggle__pair[data-pair="dark"] .pv-icon--moon { color: #ffd166; }

/* ------------------------------------------------------------ layout shell */
.pv-layout { display: block; }
.pv-layout--sidebar {
  display: grid; grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1.75rem; align-items: start;
}
.pv-content { min-width: 0; }

.pv-sidebar { display: grid; gap: 1rem; position: sticky; top: 1rem; }
.pv-sidebar__card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem;
}
.pv-sidebar__title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 0 0 .6rem;
}
.pv-sidebar__nav { display: grid; gap: .12rem; }
.pv-sidebar__item {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .38rem .5rem; border-radius: var(--radius-sm);
  color: var(--text); font-size: .92rem; text-decoration: none;
}
.pv-sidebar__item:hover { background: var(--accent-soft); color: var(--accent-strong); }
.pv-sidebar__item.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.pv-sidebar__count {
  font: 600 .78rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.pv-sidebar__label {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 0 0 .4rem;
}
.pv-sidebar__card > .pv-sidebar__label + .pv-switch { margin-bottom: 1rem; }

/* ------------------------------------------------------------ hero */
.pv-hero__tagline { margin: .1rem 0 .5rem; font-size: 1.02rem; color: var(--muted); }
.pv-hero__note { margin: 0; font-size: .88rem; color: var(--muted); }

/* ------------------------------------------------------------ toolbar */
.pv-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 1.25rem; margin: 0 0 1.4rem; padding: .6rem .85rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pv-toolbar--sidebar { justify-content: flex-start; }
.pv-toolbar__summary { margin: 0; font-size: .95rem; }
.pv-toolbar__scope { color: var(--muted); }
.pv-toolbar__controls { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.1rem; }

.pv-switch {
  display: inline-flex; padding: .15rem; gap: .15rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.pv-switch__option {
  padding: .3rem .8rem; border-radius: 999px; font-size: .85rem;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.pv-switch__option:hover { color: var(--accent-strong); }
.pv-switch__option.is-active {
  background: var(--accent); color: #fff; font-weight: 600;
}
html[data-theme="dark"] .pv-switch__option.is-active { color: #06110f; }

.pv-toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--text); text-decoration: none; cursor: pointer;
}
.pv-toggle:hover { color: var(--accent-strong); }
.pv-toggle__track {
  width: 2.1rem; height: 1.15rem; border-radius: 999px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
  display: inline-flex; align-items: center; padding: 1px;
  transition: background .15s ease, border-color .15s ease;
}
.pv-toggle__knob {
  width: .85rem; height: .85rem; border-radius: 50%; background: var(--muted);
  transition: transform .15s ease, background .15s ease;
}
.pv-toggle.is-on .pv-toggle__track { background: var(--accent); border-color: var(--accent); }
.pv-toggle.is-on .pv-toggle__knob { background: #fff; transform: translateX(.95rem); }
.pv-toggle__hint { color: var(--muted); }

.pv-empty { padding: 1.5rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ------------------------------------------------------------ article cards
   One DOM, three layouts, switched by a body class:
     .pv--mode-tiles    big picture grid
     .pv--mode-list     larger row with picture
     .pv--mode-compact  dense single-line rows
   Every picture box has a fixed aspect ratio and the photo is letterboxed
   inside it (object-fit: contain), so mixed portrait/landscape photos never
   stretch and never change the height of the row they sit in.
   ------------------------------------------------------------------------ */
.pv-list { list-style: none; margin: 0; padding: 0; }

.pv-card__media { display: block; overflow: hidden; background: var(--media-mat); }
.pv-card__media img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pv-card__media .pv-placeholder {
  display: grid; place-items: center; width: 100%; height: 100%;
  background: var(--surface-2); color: var(--muted); font-size: .8rem;
  border: 1px dashed var(--line); border-radius: 0;
}
/* A sold article is dimmed, but the badge must stay legible — it is the whole
   point of showing it. Only the surrounding card fades, not the red tag. */
.pv-card.is-sold { opacity: .62; }
.pv-card.is-sold .pv-badge--sold { opacity: 1; }
.pv-card.is-sold .pv-card__title a { color: var(--muted); }

/* A sold article keeps its photo on the detail page, just dimmed like the card
   in the overview. Only the stage fades: the arrow buttons and the counter sit
   outside it and must stay at full contrast. */
.pv-detail.is-sold .pv-slider__slide img { opacity: .62; }
.pv-card__title a { text-decoration: none; }
.pv-card__title a:hover { text-decoration: underline; }

/* --- tiles --- */
body.pv--mode-tiles .pv-list {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}
body.pv--mode-tiles .pv-card { display: flex; flex-direction: column; }
body.pv--mode-tiles .pv-card__media {
  aspect-ratio: 4 / 3; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--media-mat);
}
body.pv--mode-tiles .pv-card__body { padding-top: .7rem; }
body.pv--mode-tiles .pv-card__title { font-size: 1.05rem; margin: .2rem 0 .25rem; }
body.pv--mode-tiles .pv-card__sub { margin: 0 0 .5rem; }

/* --- list --- */
body.pv--mode-list .pv-list { display: grid; gap: .9rem; }
body.pv--mode-list .pv-card {
  display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: 1rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .85rem;
}
body.pv--mode-list .pv-card__media {
  aspect-ratio: 4 / 3; border-radius: var(--radius-sm); background: var(--media-mat);
}
body.pv--mode-list .pv-card__title { font-size: 1.02rem; margin: .15rem 0 .25rem; }
body.pv--mode-list .pv-card__sub { margin: 0 0 .5rem; }

/* --- compact --- */
body.pv--mode-compact .pv-list { display: grid; }
body.pv--mode-compact .pv-card {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: .85rem;
  align-items: center; padding: .45rem .5rem;
  border-bottom: 1px solid var(--line);
}
body.pv--mode-compact .pv-card__media {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm); background: var(--media-mat);
}
body.pv--mode-compact .pv-card__body {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "id price" "title price" "sub price";
  align-items: center; column-gap: 1rem; row-gap: .05rem; min-width: 0;
}
body.pv--mode-compact .pv-card__body > .pv-id { grid-area: id; justify-self: start; }
body.pv--mode-compact .pv-card__body > .pv-card__title { grid-area: title; }
body.pv--mode-compact .pv-card__body > .pv-card__sub { grid-area: sub; }
body.pv--mode-compact .pv-card__body > .pv-price { grid-area: price; text-align: right; white-space: nowrap; }
body.pv--mode-compact .pv-card__title { font-size: .95rem; margin: 0; }
body.pv--mode-compact .pv-card__sub {
  margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------------------ slider
   Fixed 4:3 stage: the box keeps its size no matter which photo is shown, and
   object-fit: contain letterboxes the picture inside it. */
.pv-slider {
  display: flex; flex-direction: column; gap: .6rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .6rem;
}
.pv-slider__stage {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--media-mat); border-radius: var(--radius-sm);
}
.pv-slider__slide { position: absolute; inset: 0; display: none; margin: 0; }
.pv-slider__slide.is-active { display: block; }
.pv-slider__slide img {
  display: block; width: 100%; height: 100%;
  object-fit: contain; background: var(--media-mat);
}
.pv-slider__controls { display: flex; align-items: center; justify-content: center; gap: .8rem; }
.pv-slider__arrow {
  width: 2.4rem; height: 2.4rem; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 1rem; line-height: 1;
}
.pv-slider__arrow:hover { border-color: var(--accent); color: var(--accent-strong); }
.pv-slider__counter {
  font: 600 .82rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: center;
}

/* ------------------------------------------------------------ lightbox */
.pv-lightbox {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(6, 10, 12, .92); padding: 1.25rem;
}
.pv-lightbox[hidden] { display: none; }
.pv-lightbox__inner { display: flex; flex-direction: column; align-items: center; gap: .7rem; max-height: 94vh; }
.pv-lightbox img {
  display: block; max-width: min(100%, 70rem); max-height: 74vh; width: auto;
  background: var(--media-mat); border-radius: var(--radius-sm);
}
.pv-lightbox__bar { display: flex; align-items: center; gap: 1.1rem; }
.pv-lightbox__arrow {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .4); background: rgba(0, 0, 0, .45);
  color: #fff; font-size: 1.1rem; line-height: 1;
}
.pv-lightbox__arrow:hover { border-color: #fff; background: rgba(0, 0, 0, .7); }
.pv-lightbox__counter {
  font: 600 .85rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #dbe6ea; font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: center;
}
.pv-lightbox__links { display: flex; gap: 1rem; align-items: center; margin: 0; font-size: .85rem; }
.pv-lightbox__links a { color: #cfe4f2; }
.pv-lightbox__close {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .4); background: rgba(0, 0, 0, .4);
  color: #fff; font-size: 1.2rem; line-height: 1;
}

/* ------------------------------------------------------------ mobile menu */
.pv-burger {
  display: none; cursor: pointer; padding: .4rem .45rem; gap: .25rem;
  flex-direction: column; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.pv-burger:hover { border-color: var(--accent); }
.pv-burger__bar { display: block; width: 1.05rem; height: 2px; background: var(--text); border-radius: 2px; }

.pv-drawer {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(6, 10, 12, .6); padding: 1rem;
}
.pv-drawer[hidden] { display: none; }
.pv-drawer__inner {
  width: min(22rem, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}
.pv-drawer__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.pv-drawer__head strong { font-size: 1.05rem; }
.pv-drawer__close {
  width: 2rem; height: 2rem; border-radius: 50%; cursor: pointer; font-size: 1.15rem; line-height: 1;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
.pv-drawer__options { margin-top: 1.1rem; border-top: 1px solid var(--line); padding-top: .9rem; }

/* ------------------------------------------------------------ detail media */
.pv-slider .pv-placeholder--large, .pv-placeholder--large {
  background: var(--surface-2); color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2rem 1rem; text-align: center; margin: 0;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .pv-layout--sidebar { grid-template-columns: 1fr; }
  .pv-sidebar { position: static; }
  .pv-sidebar__nav { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
}

@media (max-width: 700px) {
  body.pv--mode-list .pv-card { grid-template-columns: 7rem minmax(0, 1fr); gap: .7rem; }
  body.pv--mode-compact .pv-card { grid-template-columns: 3.25rem minmax(0, 1fr); }
  body.pv--mode-compact .pv-card__body {
    grid-template-columns: 1fr; grid-template-areas: "id" "title" "sub" "price"; row-gap: .1rem;
  }
  body.pv--mode-compact .pv-card__body > .pv-price { text-align: left; }
  body.pv--mode-compact .pv-card__sub { white-space: normal; }
  .pv-toolbar { align-items: flex-start; }
  .pv-theme-toggle__label-word { display: none; }
}
