/* Wildman Studio — /portfolio: the stage (see ../design-plan.md, "Portfolio").
   One pinned stage; a plate per site, paper and ink alternating; a window on each plate with the
   site itself inside, live. Loaded after style.css and only on /portfolio. */

/* ---------- the head: the list of sites is the picker ---------- */
.plist {
  position: absolute; right: var(--margin); bottom: 8vh; z-index: 2; margin: 0; padding: 0;
  list-style: none; columns: 2; column-gap: 4vw; width: min(52vw, 640px);
}
.plist li { break-inside: avoid; margin: 0 0 .55em; }
.plist a {
  display: inline-block; position: relative; padding-bottom: 3px;
  font-family: var(--serif); font-style: italic; font-weight: 400; font-variation-settings: "opsz" 60;
  font-size: clamp(20px, 1.7vw, 28px); line-height: 1.1; letter-spacing: -.01em; color: var(--paper);
  white-space: nowrap;
}
.plist a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .6s var(--ease-io); }
.plist a:hover::after, .plist a:focus-visible::after { transform: scaleX(1); transform-origin: left; }
.page-dek .plist-open { display: none; }
.page-dek .plist-open a { font-weight: 600; position: relative; padding-bottom: 3px; }
.page-dek .plist-open a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor; }

/* ---------- the stage ---------- */
.portfolio { position: relative; z-index: 1; }
.track--portfolio { position: relative; }
.track--portfolio > .stage {
  position: sticky; top: 0; height: 100vh; height: 100svh;
  overflow: hidden; isolation: isolate;
  --fw: 60vw; --fh: 37.5vw; --iw: 1440px; --ih: 900px; --fs: .5;
}

/* ---------- plates ---------- */
.wplate {
  position: absolute; inset: 0;
  will-change: transform; transform: translate3d(0, 100%, 0); visibility: hidden;
}
.wplate:first-child { transform: none; visibility: visible; }
.wplate[data-tone="paper"] { background: var(--paper); color: var(--ink); --hair: var(--hair-ink); }
.wplate[data-tone="ink"] { background: var(--ink); color: var(--paper); --hair: var(--hair-paper); }
.wplate__inner {
  position: absolute; left: var(--margin); right: var(--margin); top: 12vh; bottom: 12vh;
  display: grid; grid-template-columns: var(--fw) minmax(0, 1fr); gap: 0 4vw; align-items: end;
}

/* ---------- the window: a hairline, and the site ---------- */
.wframe {
  position: relative; width: var(--fw); height: var(--fh);
  border: 1px solid var(--hair); overflow: hidden; background: transparent;
  align-self: end;
  transition: border-color .45s var(--ease-io);
}
.wplate.is-live .wframe { border-color: currentColor; }
.wframe__scale {
  position: absolute; left: 0; top: 0; width: var(--iw); height: var(--ih);
  transform: scale(var(--fs)); transform-origin: 0 0;
}
.wframe__scale iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; pointer-events: none; }
/* only the site on the current plate takes the pointer; one on its way up passes the wheel to the page */
.wplate.is-live .wframe__scale iframe { pointer-events: auto; }

/* ---------- the side column: tools above, the name and a line below ---------- */
.wplate__side {
  display: flex; flex-direction: column; justify-content: space-between;
  height: var(--fh); min-width: 0;
}
.wplate__tools { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 22px; font-size: 13px; letter-spacing: .01em; }
.wplate__tools button, .wplate__tools a {
  appearance: none; -webkit-appearance: none; background: none; border: 0; margin: 0; padding: 0 0 4px;
  font: inherit; color: inherit; cursor: pointer; position: relative; opacity: .55;
  transition: opacity .45s var(--ease-io);
}
.wplate__tools button::after, .wplate__tools a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform .6s var(--ease-io);
}
.wplate__tools button:hover, .wplate__tools a:hover, .wplate__tools button:focus-visible, .wplate__tools a:focus-visible { opacity: 1; }
.wplate__tools button:hover::after, .wplate__tools a:hover::after { transform: scaleX(1); transform-origin: left; }
.wplate__tools button[aria-pressed="true"] { opacity: 1; }
.wplate__tools button[aria-pressed="true"]::after { transform: scaleX(1); transform-origin: left; }
.wplate__mode { display: flex; gap: 14px; }
.wplate__tools .tool-index { opacity: .85; }

.wplate__type {
  margin: 0;
  font-family: var(--serif); font-style: italic; font-weight: 400; font-variation-settings: "opsz" 72;
  font-size: clamp(30px, 3.6vw, 60px); line-height: 1; letter-spacing: -.02em;
}
.wplate__note {
  margin: 14px 0 0; max-width: 30ch;
  font-size: clamp(14px, 1.05vw, 16px); line-height: 1.5; color: var(--ash);
}

/* ---------- the rail: a hairline of ticks, one a site; it inverts on every plate ---------- */
.rail {
  position: absolute; left: var(--margin); right: var(--margin); bottom: 4.6vh; z-index: 5;
  display: flex; gap: 6px; height: 18px;
  mix-blend-mode: difference; color: var(--paper);
}
.rail button {
  flex: 1 1 0; position: relative; appearance: none; -webkit-appearance: none;
  background: none; border: 0; margin: 0; padding: 0; cursor: pointer;
}
.rail button::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor; opacity: .5;
}
.rail button::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1px; width: calc(var(--p, 0) * 100%); background: currentColor;
}
.rail button[aria-current="true"]::before { opacity: .55; }
.rail button[aria-current="true"]::after { height: 2px; }
.rail button:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }
/* the name of a tick, on hover or focus */
.rail__tag {
  position: absolute; left: 0; bottom: 10px; white-space: nowrap;
  font-size: 11px; letter-spacing: .01em; opacity: 0; transform: translateY(4px);
  transition: opacity .35s var(--ease-io), transform .35s var(--ease-io); pointer-events: none;
}
.rail button:last-child .rail__tag, .rail button:nth-last-child(2) .rail__tag, .rail button:nth-last-child(3) .rail__tag { left: auto; right: 0; }
.rail button:hover .rail__tag, .rail button:focus-visible .rail__tag { opacity: 1; transform: none; }
@media (pointer: coarse) { .rail__tag { display: none; } }

/* ---------- the index: an ink plate that rises over the page, like the menu ---------- */
html.index-open { overflow: hidden; }
.pindex {
  position: fixed; inset: 0; z-index: 45;
  background: var(--ink); color: var(--paper);
  transform: translateY(100%); visibility: hidden;
  transition: transform .9s var(--ease-io), visibility 0s linear .9s;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.pindex.is-open { transform: none; visibility: visible; transition: transform .9s var(--ease-io), visibility 0s; }
.pindex__inner { min-height: 100%; padding: 16vh var(--margin) 10vh; display: flex; flex-direction: column; justify-content: flex-end; gap: 6vh; }
.pindex__list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 6vw; }
.pindex__list li { break-inside: avoid; margin: 0 0 .18em; }
.pindex__list a {
  display: inline-block; position: relative; padding-bottom: .06em;
  font-family: var(--serif); font-weight: 500; font-variation-settings: "opsz" 96;
  font-size: clamp(28px, 4.2vw, 68px); line-height: 1.05; letter-spacing: -.02em;
  color: var(--paper); opacity: .48; transition: opacity .5s var(--ease-io); white-space: nowrap;
}
.pindex__list a:hover, .pindex__list a:focus-visible, .pindex__list a[aria-current="true"] { opacity: 1; }
.pindex__list a[aria-current="true"]::after { content: ""; position: absolute; left: .02em; right: .02em; bottom: 0; height: 1px; background: currentColor; }
.pindex__close {
  align-self: flex-start; appearance: none; -webkit-appearance: none; background: none; border: 0; margin: 0; padding: 0 0 4px;
  font: inherit; font-size: 13px; letter-spacing: .01em; color: var(--paper); cursor: pointer; position: relative;
}
.pindex__close::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor; }
.pindex__close .esc { color: var(--ash); }

/* ---------- a phone window on a desktop screen: the frame goes portrait, the column widens ---------- */
.stage[data-mode="phone"] .wplate__inner { grid-template-columns: var(--fw) minmax(0, 1fr); }

/* ---------- narrow screens: the name above the window, the tools beneath it ---------- */
@media (max-width: 1024px) {
  .plist { display: none; }
  .page-dek .plist-open { display: block; margin-top: 12px; }
}
@media (max-width: 899px) {
  .wplate__inner {
    top: 11vh; bottom: 10vh;
    grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 14px 0; align-items: start; align-content: start;
  }
  .stage[data-mode="phone"] .wplate__inner { grid-template-columns: 1fr; }
  /* the name, then the window, then the tools */
  .wplate__side { display: contents; }
  .wplate__side > div { order: 0; }
  .wframe { order: 1; align-self: start; justify-self: start; }
  .wplate__side > .wplate__tools { order: 2; }
  .wplate__type { font-size: clamp(26px, 6.4vw, 40px); }
  .wplate__note { display: none; }
  .rail { bottom: 3.6vh; height: 14px; gap: 4px; }
  .pindex__inner { padding: 14vh var(--margin) 8vh; }
  .pindex__list { columns: 1; }
  .pindex__list a { font-size: clamp(26px, 7.5vw, 44px); white-space: normal; }
}

/* ---------- reduced motion: plates fade instead of rising; the index fades ---------- */
@media (prefers-reduced-motion: reduce) {
  .wplate { transform: none !important; opacity: 0; }
  .wplate:first-child { opacity: 1; }
  .pindex { transform: none; opacity: 0; transition: opacity .4s ease, visibility 0s linear .4s; }
  .pindex.is-open { opacity: 1; transition: opacity .4s ease, visibility 0s; }
}
