/*
 * Layout primitives that Cargo provided (page/pin model, column grid, media,
 * slideshow, marquee, text effects), rewritten as plain CSS. Site-specific
 * styling lives in site.css (generated) and in each page's inline <style>.
 */

/* ---- Document --------------------------------------------------------- */

* {
  box-sizing: border-box;
}

:focus {
  outline: 0;
}

html {
  --mobile-scale: 1;
  --base-size: 10.8576px;
  --viewport-height: 100vh;
  --min-viewport-height: 100vh;
  font-size: var(--base-size);
  touch-action: manipulation;
  position: relative;
}

html.mobile {
  font-size: calc(var(--base-size) * var(--mobile-scale));
}

html,
body {
  min-height: var(--viewport-height, 100vh);
  margin: 0;
  padding: 0;
}

body {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: none;
  display: flex;
  flex-direction: column;
  width: 100%;
  justify-content: flex-start;
  background-color: #fff;
  position: relative;
  --baseColor-accent: #ff0000;
  font: 14.5px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Cargo hides the page until webfonts settle, then reveals it. */
html:not(.ready) body {
  opacity: 0;
}

customhtml > * {
  position: relative;
  z-index: 10;
}

/* ---- Content / pages / pins ------------------------------------------- */

.content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 100%;
  position: relative;
  flex-grow: 1;
}

.pages {
  width: 100%;
  flex: 1 0 auto;
}

[data-container="set"] {
  display: contents;
}

.page {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  flex-direction: row;
  max-width: 100%;
  width: 100%;
  flex: 0;
}

.mobile .page {
  flex-wrap: wrap;
}

.page.pinned-top,
.page.pinned-bottom {
  flex: 0;
  z-index: 2;
  left: 0;
  right: 0;
}

.page.pinned-top {
  top: 0;
}

.page.pinned-bottom {
  bottom: 0;
}

.page.fixed {
  position: fixed;
  max-height: var(--viewport-height, 100vh);
}

.page.fixed .page-layout {
  max-height: var(--viewport-height, 100vh);
}

.page.overlay {
  position: absolute;
}

.page.overlay,
.page.overlay .page-layout,
.page.fixed,
.page.fixed .page-layout {
  pointer-events: none;
}

.page.fixed .page-content bodycopy :is(a, img, iframe, video, audio, input, button, details, gallery-slideshow, marquee-set, .linked, .zoomable, [uses~="drag"]),
.page.overlay .page-content bodycopy :is(a, img, iframe, video, audio, input, button, details, gallery-slideshow, marquee-set, .linked, .zoomable, [uses~="drag"]) {
  pointer-events: auto;
}

/* Pins limited to one device class (Cargo's "screen visibility"). */
html:not(.mobile) .page[data-visibility="mobile"],
html.mobile .page[data-visibility="desktop"] {
  display: none !important;
}

.page-layout {
  flex-grow: 1;
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  width: 0%;
}

.page-content {
  display: flex;
  flex-direction: row;
  height: 100%;
  align-items: flex-start;
  border-color: transparent;
  border-width: 0;
  width: 100%;
  position: relative;
  isolation: isolate;
}

bodycopy {
  display: block;
  position: relative;
  contain: layout;
  width: 100%;
  min-width: 0;
}

bodycopy * a,
.page a.active {
  text-decoration-color: unset;
}

a {
  color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  contain: layout;
}

hr {
  border: 0;
}

s * {
  text-decoration: line-through;
}

small {
  font-size: 0.75em;
}

strong {
  font-weight: bolder;
}

column-set + *,
gallery-slideshow + *,
media-item + * {
  margin-top: 0;
}

/* ---- Backdrops (legacy video) ------------------------------------------ */

.backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--backdrop-color, transparent);
}

.backdrop.clip {
  clip-path: inset(0);
}

.backdrop-contents {
  position: absolute;
  inset: var(--backdrop-margin, 0);
  overflow: hidden;
}

.backdrop-contents iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 0;
  /* cover: keep 16:9 while filling both axes */
  width: max(100%, calc((var(--viewport-height) - 2 * var(--backdrop-margin, 0px)) * 16 / 9));
  height: max(100%, calc(100vw * 9 / 16));
  min-width: 177.78vh;
  min-height: 56.25vw;
  transform: translate(-50%, -50%);
}

.backdrop-contents.noise::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ---- Column grid -------------------------------------------------------- */
/*
 * build.mjs writes --gutter, --mobile-gutter and --units on each set and
 * --span on each unit. Unit width = span columns plus the gutters between.
 */

column-set {
  --g: var(--gutter, 1rem);
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  position: relative;
  contain: layout;
  clear: both;
}

html.mobile column-set {
  --g: var(--mobile-gutter, var(--gutter, 1rem));
}

column-unit {
  display: block;
  position: relative;
  word-wrap: break-word;
  max-width: 100%;
  min-width: 0;
  flex-grow: 0;
  flex-shrink: 0;
  --column-width: calc((100% - (var(--units) - 1) * var(--g)) / var(--units) * var(--span, 1) + (var(--span, 1) - 1) * var(--g));
  flex-basis: var(--column-width);
  width: var(--column-width);
}

column-unit:not(:last-child) {
  margin-right: var(--g);
}

column-unit:last-child {
  flex-grow: 1;
}

/* Stacked on mobile (default) unless mobile-stack="false". */
html.mobile column-set:not([mobile-stack="false"]) {
  flex-direction: column;
  align-items: flex-start;
}

html.mobile column-set:not([mobile-stack="false"]) > column-unit {
  flex-basis: auto;
  width: 100%;
  margin-right: 0;
}

html.mobile column-set:not([mobile-stack="false"]) > column-unit:not(:last-child) {
  margin-bottom: var(--g);
}

html.mobile column-set:not([mobile-stack="false"]) > column-unit[data-empty] {
  display: none;
}

/* ---- Media -------------------------------------------------------------- */

media-item {
  display: inline-flex;
  flex-direction: column;
  vertical-align: bottom;
  position: relative;
  width: var(--scale, 100%);
  max-width: 100%;
  transform: rotate(var(--media-rotation, 0deg));
}

media-item .media-figure {
  margin: 0;
  width: 100%;
}

media-item .media-link {
  display: block;
}

media-item .sizing-frame {
  display: block;
  width: 100%;
  height: 0;
  padding-bottom: var(--frame-padding, 56.25%);
  position: relative;
}

media-item [part="media"] {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  object-fit: cover;
  object-position: center;
}

media-item .caption {
  margin-top: 0.5em;
  text-align: left;
}

/* ---- Galleries ---------------------------------------------------------- */

gallery-grid,
gallery-justify,
gallery-columnized {
  --gg: var(--gallery-gutter, 1rem);
  display: block;
  width: 100%;
  position: relative;
}

html.mobile :is(gallery-grid, gallery-justify, gallery-columnized) {
  --gg: var(--gallery-mobile-gutter, var(--gallery-gutter, 1rem));
}

gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr));
  gap: calc(2 * var(--gg));
  align-items: start;
}

html.mobile gallery-grid {
  grid-template-columns: repeat(var(--mobile-columns, var(--columns, 3)), minmax(0, 1fr));
}

gallery-grid > media-item {
  grid-column: span min(var(--grid-span, 1), var(--columns, 3));
  width: 100%;
}

gallery-columnized {
  display: flex;
  align-items: flex-start;
  gap: calc(2 * var(--gg));
}

gallery-columnized > .gallery-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(2 * var(--gg));
}

gallery-columnized > .gallery-column > media-item {
  width: 100%;
}

html.mobile gallery-columnized[data-mobile-flow] {
  flex-direction: column;
}

gallery-justify {
  display: flex;
  flex-direction: column;
  gap: var(--gg);
}

gallery-justify > .gallery-row {
  display: flex;
  gap: var(--gg);
  align-items: stretch;
}

/* Items share the row height; rounding differences are cropped. */
gallery-justify > .gallery-row > media-item {
  flex: var(--item-ratio, 1) 1 0;
  min-width: 0;
  width: auto;
}

gallery-justify > .gallery-row > media-item .media-figure {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

gallery-justify > .gallery-row > media-item .sizing-frame {
  flex: 1 1 auto;
}

/* ---- Slideshow ---------------------------------------------------------- */

gallery-slideshow {
  display: block;
  position: relative;
  width: 100%;
}

gallery-slideshow > media-item {
  display: none;
  width: 100%;
}

gallery-slideshow > media-item.active,
gallery-slideshow:not(.ready) > media-item:first-of-type {
  display: flex;
}

/* ---- Marquee ------------------------------------------------------------ */

marquee-set {
  display: block;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  contain: layout;
  min-height: 0.5em;
  touch-action: pan-y;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

marquee-set .marquee-track {
  display: block;
  white-space: nowrap;
  will-change: transform;
  backface-visibility: hidden;
}

marquee-set .marquee-positioner {
  display: inline-block;
  white-space: nowrap;
  min-width: 100%;
  vertical-align: top;
}

marquee-set .marquee-positioner.clone {
  position: absolute;
  top: 0;
  left: var(--clone-offset, 100%);
}

marquee-inner {
  display: inline-block;
  white-space: nowrap;
  pointer-events: auto;
}

/* ---- Text icons --------------------------------------------------------- */

text-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  line-height: 1;
}

text-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- "uses" text effects (eye-roll, rotation, drag, fit-text) ---------- */
/*
 * Cargo applies these as shadow-host styles, which lose to any page CSS, so
 * they are wrapped in :where() (zero specificity) to keep that priority.
 */

:where([uses]) {
  transform-origin: center center;
}

:where(span[uses], [uses~="drag"]) {
  display: inline-block;
}

:where([uses~="rotation"], [uses~="eye-roll"], [uses~="drag"]) {
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px)) rotate(var(--rotation, 0deg));
}

:where([uses~="drag"]) {
  pointer-events: auto !important;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

:where([uses~="drag"].dragging) {
  cursor: grabbing;
  transition: none !important;
}

:where([uses~="fit-text"]) {
  white-space: nowrap !important;
  display: inline-block !important;
  min-width: 1px;
}

@keyframes yab-rotate {
  from {
    transform: rotate(var(--rotation, 0deg));
  }
  to {
    transform: rotate(calc(var(--rotation, 0deg) + 360deg));
  }
}

:where([uses~="rotation"][data-spin]) {
  animation: yab-rotate var(--spin-duration, 10s) linear infinite;
  animation-direction: var(--spin-direction, normal);
  will-change: transform;
}
