/* Portfolio: a masonry of every kept piece, after dannpetty.com. Rounded cards on a soft ground;
   each piece plays in its card on its brand's own mat; opening one flies it into a viewer that
   gives its placement, size and loop. Light by default, with a dark mode the switch (top right)
   or the system can choose. */

:root {
  --ground: #f2f2f0;
  --card: #ffffff;
  --ink: #141414;
  --ink-2: #3c3c3a;
  --muted: #74746f;
  --line: rgba(20, 20, 18, 0.08);
  --chip: rgba(255, 255, 255, 0.92);
  --backdrop: rgba(242, 242, 240, 0.9);
  --lift: 0 1px 1px rgba(20, 18, 14, 0.04), 0 4px 8px -2px rgba(20, 18, 14, 0.06), 0 14px 26px -10px rgba(20, 18, 14, 0.16), 0 34px 60px -28px rgba(20, 18, 14, 0.3);
  --radius: 24px;
  --media-radius: 12px;
  --gap: 16px;
  --pad: 14px;
  --ui: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ground: #0f0f0e;
  --card: #1b1b1a;
  --ink: #f3f3f0;
  --ink-2: #cfcfca;
  --muted: #8f8f89;
  --line: rgba(255, 255, 255, 0.08);
  --chip: rgba(30, 30, 29, 0.92);
  --backdrop: rgba(12, 12, 11, 0.9);
  --lift: 0 1px 1px rgba(0, 0, 0, 0.3), 0 6px 12px -4px rgba(0, 0, 0, 0.4), 0 18px 34px -12px rgba(0, 0, 0, 0.55), 0 40px 70px -30px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 300ms ease, color 300ms ease;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

/* In the Studio the page scrolls inside .stage, so the panel can inset it; on its own it is a
   normal page with the document scrolling. */
html.framed, html.framed body { height: 100%; }
html.framed .stage { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; }
.page { max-width: 1760px; margin: 0 auto; padding: 20px 20px 64px; }

/* ---- the masonry ---- */
.grid { display: flex; align-items: flex-start; gap: var(--gap); }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.card {
  position: relative;
  border-radius: var(--radius);
  background: var(--card);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease), box-shadow 450ms var(--ease), background-color 300ms ease;
}
.card.in { opacity: 1; transform: none; }

/* a piece: the card is its brand's mat, the piece inset on it */
.work { background: var(--mat, #ebebe9); }
:root[data-theme="dark"] .work { background: color-mix(in srgb, var(--mat, #ebebe9) 9%, #1b1b1a); }
.work .open {
  display: block;
  width: 100%;
  padding: var(--pad) var(--pad) 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: zoom-in;
  border-radius: var(--radius);
}
.work .open:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.work .media {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--media-radius);
  background: rgba(0, 0, 0, 0.04);
  transform: translateZ(0);
}
.work .media video, .work .media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 700ms var(--ease);
}
.work .label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 4px 13px;
  font-size: 13px;
  line-height: 1.3;
}
.work .label b { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.work .label span { color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.no-labels .work .label { display: none; }
body.no-labels .work .open { padding-bottom: var(--pad); }
/* hover: the card lifts off the page and casts a soft, layered shadow */
@media (hover: hover) {
  .work.in:hover { transform: translateY(-4px); box-shadow: var(--lift); }
  .work:hover .media video, .work:hover .media img { transform: scale(1.015); }
}

/* the intro */
.intro { padding: 26px 28px 24px; }
.intro h1 { margin: 0; font-size: 25px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
.intro .role { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.intro .role a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 40px 4px 0; color: var(--muted); font-size: 13px; }

/* the light and dark switch */
.theme {
  position: fixed; top: 16px; right: 16px; z-index: 40;
  width: 40px; height: 40px; border: 0; border-radius: 50%; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--chip); color: var(--ink);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 8px 24px -10px rgba(0, 0, 0, 0.3);
}
.theme svg { width: 18px; height: 18px; }
.theme .moon { display: none; }
:root[data-theme="dark"] .theme .sun { display: none; }
:root[data-theme="dark"] .theme .moon { display: block; }
.theme:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
html.viewing .theme { opacity: 0; pointer-events: none; }

/* ---- the viewer ---- */
.viewer { position: fixed; inset: 0; z-index: 50; }
.viewer[hidden] { display: none; }
.v-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(22px) saturate(1.05);
  backdrop-filter: blur(22px) saturate(1.05);
}
.v-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 96px 40px 40px; }
.v-stage.scroll { display: block; overflow-y: auto; overscroll-behavior: contain; padding: 96px 40px 80px; }
.v-media { position: relative; overflow: hidden; border-radius: 14px; background: #000; box-shadow: var(--lift); }
.v-media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.v-mail { position: relative; margin: 0 auto; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: var(--lift); }
.v-mail iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: transparent; }
.v-set { display: flex; justify-content: center; align-items: flex-start; gap: 24px; margin: 0 auto; }
.v-set img, .v-sheet img { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: var(--lift); }
.v-set figure, .v-sheet { margin: 0; }
.v-set figure { flex: 1 1 0; min-width: 0; }
.v-sheet { margin: 0 auto; }

/* the caption: placement, size and loop */
.v-cap {
  position: absolute; left: 20px; top: 16px; z-index: 3; margin: 0;
  display: flex; gap: 26px; flex-wrap: wrap; max-width: calc(100% - 100px);
  padding: 12px 20px 13px; border-radius: 18px;
  background: var(--chip); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 30px -14px rgba(0, 0, 0, 0.3);
}
.v-cap div { min-width: 0; }
.v-cap dt { font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.v-cap dd { margin: 2px 0 0; font-size: 14px; line-height: 1.35; font-weight: 500; color: var(--ink); }
.v-close {
  position: absolute; top: 20px; right: 20px; z-index: 3; width: 42px; height: 42px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
  background: var(--chip); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 30px -14px rgba(0, 0, 0, 0.3);
}
.v-close svg { width: 14px; height: 14px; }
.v-close:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* the flying copy of a piece, between its card and the viewer */
.flyer { position: fixed; z-index: 60; overflow: hidden; pointer-events: none; border-radius: 12px; will-change: left, top, width, height; }
.flyer canvas, .flyer img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }

/* ---- smaller screens ---- */
@media (max-width: 860px) {
  .viewer { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .v-backdrop { position: fixed; }
  :root .v-backdrop { background: color-mix(in srgb, var(--ground) 97%, transparent); }
  .v-stage, .v-stage.scroll { position: relative; inset: auto; display: block; overflow: visible; padding: 72px 16px 16px; }
  .v-stage .v-media { margin: 0 auto; }
  .v-cap { position: relative; left: auto; top: auto; max-width: none; margin: 0 16px 28px; flex-direction: column; gap: 10px; }
  .v-close { position: fixed; top: 14px; right: 14px; }
  .v-set { flex-direction: column; gap: 16px; }
  .v-set figure { width: 100%; }
}
@media (max-width: 520px) {
  :root { --radius: 20px; --gap: 12px; --pad: 12px; }
  .page { padding: 12px 12px 48px; }
  .intro { padding: 22px 22px 20px; }
  .theme { top: 12px; right: 12px; }
}

/* the Studio's First frame: everything still */
body.still .work video { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .card { transform: none; transition: opacity 300ms ease; }
  .work .media video, .work .media img { transition: none; }
  .work.in:hover { transform: none; }
}
