/* SWISS projects. Two parts: the overview grid, and the reader that leafs through every photo
   of one project like a book. Without JavaScript the page is a plain list of projects with all
   their photos, which is what search engines read. */

.pgrid,
.preader {
  --pr-bg: var(--bg, #151515);
  --pr-surface: var(--surface-1, #1b1b1b);
  --pr-line: var(--line, #2a2a2a);
  --pr-text: var(--text, #f2f2f0);
  --pr-muted: var(--text-muted, #a3a3a3);
  --pr-subtle: var(--text-subtle, #8a8a8a);
  --pr-hot: var(--brand, #c2272b);
  --pr-hot-soft: var(--brand-text, #dd585c);
  --pr-cold: #7fb3d5;
  --pr-ease: cubic-bezier(0.22, 0.68, 0.24, 1);
}

/* ---------- overview ---------- */

.pgrid {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.pgrid__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pcard {
  position: relative;
  height: 100%;
  border: 1px solid var(--pr-line);
  border-radius: 8px;
  background: var(--pr-surface);
  overflow: hidden;
  transition: border-color 0.25s var(--pr-ease), transform 0.25s var(--pr-ease);
}

.pcard:hover { border-color: var(--pr-hot); transform: translateY(-3px); }

/* the title carries the link, and the link covers the whole card */
.pcard__open {
  color: inherit;
  text-decoration: none;
}

.pcard__open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.pcard__cover {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--pr-bg);
}

.pcard__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--pr-ease);
}

.pcard:hover .pcard__cover img { transform: scale(1.04); }

.pcard__count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(21, 21, 21, 0.82);
  color: var(--pr-text);
  font-size: 0.75rem;
  font-weight: 600;
}

.pcard__body { display: grid; align-content: start; gap: 8px; padding: 20px; }
.pcard__title { margin: 0; color: var(--pr-text); font-size: 1.1875rem; font-weight: 600; line-height: 1.3; }
.pcard__meta { margin: 0; color: var(--pr-hot-soft); font-size: 0.875rem; font-weight: 600; }
.pcard__text { margin: 0; color: var(--pr-muted); font-size: 0.9375rem; line-height: 1.6; }

.pcard__cue {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--pr-text);
  font-size: 0.875rem;
  font-weight: 600;
}

.pcard__cue::after {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--pr-hot);
  transition: width 0.25s var(--pr-ease);
}

.pcard:hover .pcard__cue::after { width: 34px; }

.pcard__open:focus-visible { outline: 2px solid var(--focus, #f2f2f0); outline-offset: 3px; }

.pgrid__closing {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 56px 0 0;
  text-align: center;
}

.pgrid__closing p { margin: 0; color: var(--pr-text); font-size: 1.125rem; }

.pgrid__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 32px;
  border-radius: 4px;
  background: var(--pr-hot);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.pgrid__cta:hover { background: var(--brand-hover, #b33f2e); }
.pgrid__cta:focus-visible { outline: 2px solid var(--focus, #f2f2f0); outline-offset: 2px; }

/* every photo lives in the page; the reader only borrows them */
.pcard__shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0 20px 20px;
  list-style: none;
}

.pcard__shots img { display: block; width: 100%; height: auto; border-radius: 4px; }
.pcard__shots figure { margin: 0; }
.pcard__shots figcaption { margin-top: 4px; color: var(--pr-subtle); font-size: 0.8125rem; }
.pgrid.is-enhanced .pcard__shots { display: none; }

/* ---------- the reader ---------- */

.preader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: rgba(10, 10, 10, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--pr-ease), visibility 0.3s;
}

.preader.is-open { opacity: 1; visibility: visible; }

.preader__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(242, 242, 240, 0.08);
}

.preader__heading { display: grid; gap: 2px; min-width: 0; margin: 0; }
.preader__title { margin: 0; color: var(--pr-text); font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.preader__meta { margin: 0; color: var(--pr-muted); font-size: 0.8125rem; }

.preader__count {
  margin: 0 0 0 auto;
  color: var(--pr-subtle);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.preader__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--pr-line);
  border-radius: 4px;
  background: transparent;
  color: var(--pr-text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s var(--pr-ease), color 0.2s var(--pr-ease);
}

.preader__close:hover { border-color: var(--pr-hot); color: var(--pr-hot-soft); }

/* the book itself */
.preader__stage {
  position: relative;
  display: grid;
  min-height: 0;
  padding: 20px;
  perspective: 2400px;
}

.pbook {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-self: center;
  width: min(100%, 1180px);
  height: 100%;
  min-height: 0;
  transform-style: preserve-3d;
}

.ppage {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #121212;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
}

.ppage--left { border-radius: 6px 0 0 6px; }
.ppage--right { border-radius: 0 6px 6px 0; }

/* every photo sits in the same frame, so portrait and landscape look equally tidy */
.ppage,
.pflip__face { padding: clamp(16px, 2.4vw, 40px); }

.ppage img,
.pflip__face img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 1px solid rgba(242, 242, 240, 0.16);
  border-radius: 2px;
  background: #0d0d0d;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.55);
}

/* the spine */
.pbook::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 26px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55));
  transform: translateX(-13px);
  pointer-events: none;
}

/* the sheet that turns */
.pflip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  visibility: hidden;
  pointer-events: none;
}

.pflip.is-turning { visibility: visible; }
.pflip.is-animated { transition: transform 0.72s var(--pr-ease); }

.pflip__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #121212;
  backface-visibility: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
}

.pflip__face--back { transform: rotateY(180deg); }

/* controls */
.preader__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 20px 10px;
  border-top: 1px solid rgba(242, 242, 240, 0.08);
}

.pbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--pr-line);
  border-radius: 4px;
  background: transparent;
  color: var(--pr-text);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--pr-ease), background-color 0.2s var(--pr-ease), color 0.2s var(--pr-ease);
}

/* back is the cold side, forward is the warm side */
.pbtn--prev:hover:not([disabled]),
.pbtn--prev:focus-visible { border-color: var(--pr-cold); color: var(--pr-cold); }
.pbtn--prev:active:not([disabled]) { background: rgba(127, 179, 213, 0.14); }

.pbtn--next:hover:not([disabled]),
.pbtn--next:focus-visible { border-color: var(--pr-hot); color: var(--pr-hot-soft); }
.pbtn--next:active:not([disabled]) { background: rgba(194, 39, 43, 0.18); }

.pbtn[disabled] { opacity: 0.35; cursor: default; }
.pbtn:focus-visible,
.preader__close:focus-visible { outline: 2px solid var(--focus, #f2f2f0); outline-offset: 2px; }

/* the strip of thumbnails */
.preader__strip {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  max-width: 100%;
  padding: 0 20px calc(14px + env(safe-area-inset-bottom, 0px));
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.pthumb {
  flex: none;
  width: 68px;
  height: 50px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s var(--pr-ease), border-color 0.2s var(--pr-ease);
}

.pthumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.pthumb:hover { opacity: 0.9; }
.pthumb.is-current { opacity: 1; border-color: var(--pr-hot); }
.pthumb:focus-visible { outline: 2px solid var(--focus, #f2f2f0); outline-offset: 2px; }

html.has-open-reader,
html.has-open-reader body { overflow: hidden; }
html.has-open-reader body { position: fixed; right: 0; left: 0; width: 100%; }

/* ---------- phones: one page at a time ---------- */

@media (max-width: 899px) {
  .pgrid { padding: 0 16px 56px; }
  .pbook { grid-template-columns: 1fr; }
  .ppage--left { display: none; }
  .ppage--right { border-radius: 6px; }
  .pbook::after { display: none; }
  .pflip { left: 0; width: 100%; }
  .preader__stage { padding: 12px; }
  .ppage, .pflip__face { padding: 12px; }
  .preader__bar { padding: 12px 14px; }
  .preader__title { font-size: 0.9375rem; }
  .preader__nav { gap: 10px; padding: 10px 14px 8px; }
  .pbtn { flex: 1 1 0; padding: 0 12px; }
  .preader__strip { padding: 0 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .pthumb { width: 56px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .pflip.is-animated { transition: none; }
  .pcard,
  .pcard__cover img,
  .pbtn,
  .preader { transition: none; }
}
