/* ==========================================================
   Pixel — extras v4: transição entre páginas, cor no substrato,
   comparador arquivo × objeto físico
   ========================================================== */

/* ---------- Transição entre páginas (View Transitions API) ---------- */
@view-transition { navigation: auto; }

::view-transition-old(root) { animation: px-page-out .26s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: px-page-in .42s cubic-bezier(.2, .75, .25, 1) both; }

@keyframes px-page-out { to { opacity: 0; } }
@keyframes px-page-in { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

/* ---------- Cor no substrato ---------- */
.substrate-demo {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: clamp(46px, 7vw, 110px);
  align-items: center;
}

.substrate-copy h2 {
  margin: 15px 0 22px;
  font: 500 clamp(2.5rem, 4.3vw, 5.4rem)/.95 Manrope, sans-serif;
  letter-spacing: -.06em;
}

.substrate-copy > p { color: var(--muted, #a3a6aa); line-height: 1.75; max-width: 520px; }

.substrate-controls { display: grid; gap: 22px; margin-top: 38px; }

.substrate-group > span {
  display: block;
  margin-bottom: 10px;
  color: #a3a6aa;
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.substrate-options { display: flex; flex-wrap: wrap; gap: 8px; }

.substrate-btn {
  min-height: 42px;
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: transparent;
  color: #d6d8db;
  cursor: pointer;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: border-color .25s ease, background .25s ease, color .25s ease;
}

.substrate-btn:hover { border-color: rgba(255, 255, 255, .42); }

.substrate-btn[aria-pressed="true"] {
  border-color: #f3f3f3;
  background: #f3f3f3;
  color: #111;
}

.substrate-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.substrate-chip i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--chip);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25);
}

.substrate-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  padding: 0;
  background: none;
  color: #d6d8db;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
}

.substrate-toggle b {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .16);
  transition: background .25s ease;
}

.substrate-toggle b::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f3f3f3;
  transition: transform .3s cubic-bezier(.2, .75, .25, 1);
}

.substrate-toggle[aria-pressed="true"] b { background: #d91b2b; }
.substrate-toggle[aria-pressed="true"] b::after { transform: translateX(18px); }
.substrate-toggle:disabled { opacity: .35; cursor: not-allowed; }

/* palco */
.substrate-stage {
  position: relative;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #f2f0eb;
  --ink: #c8102e;
  --sheen-x: 35%;
}

.substrate-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .7s cubic-bezier(.2, .75, .25, 1);
}

.substrate-stage[data-substrate="papel"] .substrate-layer--papel,
.substrate-stage[data-substrate="transparente"] .substrate-layer--transparente,
.substrate-stage[data-substrate="metalizado"] .substrate-layer--metalizado { opacity: 1; }

.substrate-layer--papel {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #faf9f6, #ebe8e2);
}

/* o que está atrás do filme transparente: produto/líquido */
.substrate-layer--transparente {
  background:
    radial-gradient(120% 80% at 30% 20%, rgba(255, 214, 150, .55), transparent 60%),
    linear-gradient(165deg, #6b4220 0%, #a8682c 38%, #3a2210 78%, #1e1208 100%);
}

.substrate-layer--transparente::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .28) 47%, transparent 54%);
}

.substrate-layer--metalizado {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 1px, rgba(0, 0, 0, .04) 1px 3px),
    linear-gradient(115deg, #7c8085 0%, #c9ccd0 calc(var(--sheen-x) - 22%), #ffffff var(--sheen-x), #b5b9be calc(var(--sheen-x) + 18%), #6e7277 100%);
}

/* rótulo impresso */
.substrate-label {
  position: absolute;
  inset: 17% 14% 21% 14%;
}

/* reflexo do metalizado atravessando a tinta */
.substrate-label::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(115deg, transparent calc(var(--sheen-x) - 26%), rgba(255, 255, 255, .55) var(--sheen-x), transparent calc(var(--sheen-x) + 22%));
  mix-blend-mode: soft-light;
  pointer-events: none;
  transition: opacity .6s ease;
}

.substrate-stage[data-substrate="metalizado"][data-white="off"] .substrate-label::after { opacity: 1; }

.substrate-white,
.substrate-ink {
  position: absolute;
  inset: 0;
  transition: opacity .6s cubic-bezier(.2, .75, .25, 1), background-color .6s ease, mix-blend-mode .6s ease;
}

.substrate-white { background: #fbfbf8; opacity: 0; }

.substrate-ink {
  background-color: var(--ink);
  mix-blend-mode: multiply;
  opacity: .97;
}

.substrate-name {
  position: absolute;
  z-index: 2;
  left: 22px;
  bottom: 18px;
  color: rgba(255, 255, 255, .92);
  font: 600 .7rem/1 Inter, sans-serif;
  letter-spacing: .14em;
}

.substrate-stage[data-substrate="transparente"] .substrate-ink { opacity: .82; }
.substrate-stage[data-substrate="metalizado"] .substrate-ink { opacity: .8; }
.substrate-stage[data-white="on"]:not([data-substrate="papel"]) .substrate-white { opacity: .96; }
.substrate-stage[data-white="on"][data-substrate="transparente"] .substrate-ink,
.substrate-stage[data-white="on"][data-substrate="metalizado"] .substrate-ink { opacity: .97; }

/* referência de tela */
.substrate-ref {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  background: rgba(9, 9, 9, .78);
  backdrop-filter: blur(6px);
  color: #e4e5e7;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.substrate-ref i { width: 26px; height: 26px; background: var(--ink); transition: background .6s ease; }

.substrate-caption {
  min-height: 3.6em;
  margin: 20px 0 0;
  color: #c9cbcf;
  font-size: .92rem;
  line-height: 1.6;
}

.substrate-note {
  margin: 10px 0 0;
  color: #6f7378;
  font-size: .72rem;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .substrate-demo { grid-template-columns: 1fr; }
  .substrate-stage { aspect-ratio: 4 / 3.4; }
}

/* Cor × substrato sobre fundo claro (mesmo tom de "Possibilidade essencial") */
.section.cream + .section.cream#cor-no-substrato { padding-top: 0; }
.section.cream#cor-no-substrato .substrate-demo { padding-top: clamp(70px, 8vw, 110px); border-top: 1px solid var(--line-dark, rgba(18, 16, 13, .16)); }
.section.cream .substrate-copy h2 { color: #151515; }
.section.cream .substrate-copy > p { color: #5d6065; }
.section.cream .substrate-group > span { color: #5f646b; }
.section.cream .substrate-btn { border-color: rgba(21, 21, 21, .18); color: #2b2d30; }
.section.cream .substrate-btn:hover { border-color: rgba(21, 21, 21, .45); }
.section.cream .substrate-btn[aria-pressed="true"] { border-color: #151515; background: #151515; color: #f3f3f3; }
.section.cream .substrate-chip i { box-shadow: 0 0 0 1px rgba(21, 21, 21, .2); }
.section.cream .substrate-toggle { color: #2b2d30; }
.section.cream .substrate-toggle b { background: rgba(21, 21, 21, .18); }
.section.cream .substrate-toggle b::after { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.section.cream .substrate-toggle[aria-pressed="true"] b { background: #d91b2b; }
.section.cream .substrate-stage { border-color: rgba(21, 21, 21, .14); box-shadow: 0 24px 60px rgba(30, 32, 36, .16); }
.section.cream .substrate-caption { color: #3f4246; }
.section.cream .substrate-note { color: #7a7e84; }

/* ---------- Comparador arquivo × objeto físico ---------- */
@property --pos { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
.compare.is-hinting { transition: --pos .42s cubic-bezier(.45, 0, .2, 1); }
.compare-section[hidden] { display: none; }

.compare {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #111;
  touch-action: pan-y;
  user-select: none;
  --pos: 50%;
}

.compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.compare-after { clip-path: inset(0 0 0 var(--pos)); }

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 1px;
  background: rgba(255, 255, 255, .85);
  transform: translateX(-.5px);
}

.compare-handle::after {
  content: "‹ ›";
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #f3f3f3;
  color: #111;
  font: 600 .9rem/1 Inter, sans-serif;
  letter-spacing: .1em;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.compare-tag {
  position: absolute;
  bottom: 18px;
  padding: 7px 11px;
  background: rgba(9, 9, 9, .72);
  color: #e4e5e7;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.compare-tag--before { left: 18px; }
.compare-tag--after { right: 18px; }

.compare-range:focus-visible + .compare-handle::after { outline: 2px solid #d91b2b; outline-offset: 3px; }
