*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-toggle,
.menu-toggle:focus,
.menu-toggle:focus-visible,
.nav-link {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.page {
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--page-pad-y) var(--page-pad-x);
  padding-bottom: calc(var(--page-pad-y) + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
}

/* Header */

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  position: relative;
  z-index: 2;
}

.logo {
  font-size: var(--type-wordmark-size);
  font-weight: var(--type-wordmark-weight);
  letter-spacing: var(--type-wordmark-tracking);
  line-height: 1;
}

.menu-toggle {
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: calc(28px - 4pt);
  height: calc(28px - 4pt);
  flex-shrink: 0;
  position: relative;
}

.menu-dot {
  display: block;
  width: calc(4px - 1pt);
  height: calc(4px - 1pt);
  border-radius: 50%;
  background: var(--color-text);
}

.menu-toggle[aria-expanded="true"] .menu-dot {
  display: none;
}

.menu-toggle[aria-expanded="true"]::before {
  content: "×";
  font-size: 18pt;
  font-weight: var(--weight-regular);
  line-height: 1;
  color: var(--color-text);
}

.nav {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link,
.credit {
  font-size: var(--type-nav-size);
  font-weight: var(--type-nav-weight);
  letter-spacing: var(--type-nav-tracking);
  line-height: 1;
}

.date {
  font-size: var(--type-nav-size);
  font-weight: var(--type-nav-weight);
  letter-spacing: var(--type-date-tracking);
  line-height: 1;
}

/* Main — desktop / tablet side-by-side until stack breakpoint */

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: 0;
  column-gap: var(--layout-cta-well-inset);
  position: relative;
}

.cta {
  grid-column: 1;
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  max-width: 100%;
  position: relative;
  z-index: 2;
  /* Keep clear of the centered well with an aesthetic inset */
  padding-right: var(--layout-cta-well-inset);
}

.tagline {
  font-size: var(--type-tagline-size);
  font-weight: var(--type-tagline-weight);
  letter-spacing: var(--type-tagline-tracking);
  line-height: 1.05;
  white-space: nowrap;
}

.store-badge {
  display: inline-block;
  line-height: 0;
  cursor: default;
}

.store-badge img {
  display: block;
  height: var(--store-badge-height);
  width: auto;
}

.main-spacer {
  grid-column: 3;
}

/* Artifact — well (front) + strip (back), Y-flip */

.artifact-wrap {
  --well-scale-effective: var(--well-scale);
  --well-display-w: calc(var(--well-design-w) * var(--well-scale-effective));
  --well-display-h: calc(var(--well-design-h) * var(--well-scale-effective));

  grid-column: 2;
  width: var(--well-display-w);
  height: var(--well-display-h);
  position: relative;
  z-index: 1;
  justify-self: center;
  align-self: center;
  perspective: 1400px;
  perspective-origin: 50% 50%;
}

.artifact-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateY(0deg);
  transform-style: preserve-3d;
  transition: transform var(--artifact-flip-ms) cubic-bezier(0.4, 0.0, 0.2, 1);
}

.artifact-wrap.reduce-motion .artifact-flip {
  transition: none;
}

.artifact-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.artifact-face--front {
  transform: rotateY(0deg) translateZ(1px);
}

.artifact-face--back {
  transform: rotateY(180deg) translateZ(1px);
}

/* Well — shell holds radius/overflow so the 3D face isn’t flattened */

.well-shell {
  --well-r: calc(var(--well-radius) * var(--well-scale-effective));
  position: absolute;
  inset: 0;
  border-radius: var(--well-r);
  overflow: hidden;
  /* Transparent (not dark) so radius AA doesn’t fringe black on white page */
  background: transparent;
  color: var(--color-well-text);
  isolation: isolate;
  -webkit-mask-image: -webkit-radial-gradient(#fff, #000);
  clip-path: inset(0 round var(--well-r));
}

.well-media {
  position: absolute;
  /* Overscan seals the rounded clip — no shell color peeking at edges */
  inset: -2px;
  z-index: 0;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  user-select: none;
  background: transparent;
  border-radius: 0;
}

.well-media[hidden] {
  display: none !important;
}

.well-media.is-active {
  z-index: 1;
}

.well-video {
  background: transparent;
}

.well-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: #0a0a0a;
  transition: opacity 0.3s ease;
}

.well.is-ready .well-shell::before {
  opacity: 0;
}

.well:not(.is-ready) .well-media {
  opacity: 0;
}

/* Chrome stays at design size, then scales — keeps type locked */
.well-chrome-scale {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: var(--well-design-w);
  height: var(--well-design-h);
  transform: scale(var(--well-scale-effective));
  transform-origin: top left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.well.is-ready .well-chrome-scale {
  opacity: 1;
  visibility: visible;
}

.well-chrome {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--well-top-inset) var(--well-side-inset) var(--well-bottom-inset);
}

.well-location {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: var(--well-location-nudge);
  font-size: var(--well-type-size);
  font-weight: var(--well-type-weight);
  letter-spacing: var(--well-type-tracking);
  line-height: 1.2;
  text-shadow: var(--well-text-shadow);
}

.well-location-label {
  position: relative;
  display: inline-block;
  text-align: center;
}

.pin {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 4pt;
  flex-shrink: 0;
  width: 0.75em;
  height: auto;
  display: block;
  filter: drop-shadow(0 0.5px 1px rgba(0, 0, 0, 0.28));
}

.well-caption-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--well-caption-time-gap);
  padding-bottom: 12px;
}

.well-caption,
.well-time {
  font-size: var(--well-type-size);
  line-height: 1.2;
  letter-spacing: var(--well-type-tracking);
  text-shadow: var(--well-text-shadow);
}

.well-caption {
  font-weight: var(--well-type-weight);
}

.well-time {
  font-weight: var(--well-type-time-weight);
}

/* Strip — shell holds fill/overflow; face stays 3D-clean */

.strip-shell {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--strip-fill);
  color: var(--strip-ink);
  border-radius: 0;
  overflow: hidden;
  /* Travels with the strip face through the flip */
  box-shadow: var(--strip-shadow);
}

.strip-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: calc(var(--strip-slot-gap) * var(--well-scale-effective));
  padding: calc(var(--strip-grid-inset) * var(--well-scale-effective));
}

.strip-slot {
  --strip-slot-r: calc(var(--strip-cell-radius) * var(--well-scale-effective));
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: var(--strip-slot-r);
  /* Match strip cream so AA fringes don’t read as a black frame */
  background: var(--strip-fill);
  overflow: hidden;
  isolation: isolate;
  -webkit-mask-image: -webkit-radial-gradient(#fff, #000);
  clip-path: inset(0 round var(--strip-slot-r));
}

.strip-slot-video {
  position: absolute;
  /* Overscan so cover media fully seals the rounded clip */
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  background: transparent;
  border-radius: inherit;
}

.strip-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--strip-title-to-date) * var(--well-scale-effective));
  padding: calc(var(--strip-grid-to-title) * var(--well-scale-effective))
    calc(var(--strip-footer-inset-x) * var(--well-scale-effective))
    calc(var(--strip-date-to-bottom) * var(--well-scale-effective));
}

.strip-title {
  font-size: calc(var(--strip-title-size) * var(--well-scale-effective));
  font-weight: var(--strip-title-weight);
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--strip-ink);
}

.strip-title:empty {
  display: none;
}

.strip-date {
  font-size: calc(var(--strip-date-size) * var(--well-scale-effective));
  font-weight: var(--strip-date-weight);
  letter-spacing: 0;
  line-height: 1.2;
  color: var(--strip-ink);
  opacity: var(--strip-date-opacity);
}

/* Footer */

.footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  position: relative;
  z-index: 2;
}

.footer-left,
.footer-right {
  display: flex;
  flex-direction: column;
  gap: var(--footer-row-gap);
}

.footer-right {
  text-align: right;
  align-items: flex-end;
}

.meta {
  font-size: var(--type-meta-size);
  font-weight: var(--type-meta-weight);
  letter-spacing: var(--type-meta-tracking);
  color: var(--type-meta-color);
  line-height: 1.2;
}

/* Stack only when there isn’t room for side CTA + inset + well */

@media (max-width: 940px) {
  .nav {
    gap: 1rem 1.25rem;
  }

  .page {
    --tablet-edge-x: var(--page-pad-x);
    --tablet-edge-bottom: clamp(20px, 3vh, 36px);
    padding-bottom: calc(
      72px + var(--tablet-edge-bottom) + env(safe-area-inset-bottom, 0px)
    );
  }

  .main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 36px;
    padding: 28px 0 48px;
    position: relative;
    z-index: 3; /* sit above fixed footer so App Store isn’t covered */
  }

  .main-spacer {
    display: none;
  }

  .artifact-wrap {
    order: 1;
    flex-shrink: 0;
  }

  .cta {
    order: 2;
    align-items: center;
    text-align: center;
    padding-right: 0;
  }

  .tagline {
    white-space: normal;
  }

  .store-badge {
    position: relative;
    z-index: 3;
  }

  .footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1; /* under main / App Store */
    padding: 16px var(--tablet-edge-x)
      calc(var(--tablet-edge-bottom) + env(safe-area-inset-bottom, 0px));
    /* No opaque bar — footer text stays, content can overlap */
    background: transparent;
    pointer-events: none;
  }

  .footer .credit,
  .footer .meta,
  .footer .date,
  .footer .contact {
    pointer-events: auto;
  }
}

/* Phone — Phone_Ver layout; safe area above browser chrome */

@media (max-width: 720px) {
  .page {
    --phone-edge-x: 20px;
    --phone-edge-top: calc(20px - 3pt);
    --phone-edge-bottom: calc(20px - 3pt);
    padding: calc(var(--phone-edge-top) + env(safe-area-inset-top, 0px))
      var(--phone-edge-x)
      calc(88px + var(--phone-edge-bottom) + env(safe-area-inset-bottom, 0px));
    /* bottom pad clears fixed footer */
  }

  .header {
    display: block;
    text-align: center;
    min-height: calc(28px - 4pt);
    position: relative;
    z-index: 4;
  }

  .menu-toggle {
    display: flex;
    position: fixed;
    top: calc(var(--phone-edge-top) + env(safe-area-inset-top, 0px));
    right: var(--phone-edge-x);
    z-index: 5;
  }

  .logo {
    display: block;
    width: fit-content;
    /* prior offsets, then −3pt all, −4pt stack, −4pt again */
    margin: calc(36px + 2pt + 20pt - 3pt - 4pt - 4pt) auto 0;
    font-size: 28pt;
  }

  .nav {
    display: flex;
    position: fixed;
    top: calc(var(--phone-edge-top) + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 6px 40px;
    background: var(--color-bg);
    z-index: 4;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(16px);
    transition:
      opacity 0.28s ease,
      transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0.32s;
  }

  .nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  @media (prefers-reduced-motion: reduce) {
    .nav {
      transition: none;
      transform: none;
    }
  }

  .nav-link,
  .credit,
  .date {
    font-size: calc(var(--type-nav-size) - 1pt); /* 10pt → 9pt */
  }

  .meta {
    font-size: calc(var(--type-nav-size) - 2pt); /* nav/credit/date − 1pt → 8pt */
  }

  .main {
    gap: 0;
    /* content stack lift; booth↔tagline gap set on .tagline */
    padding: 0 0 28px;
  }

  .cta {
    display: contents;
  }

  .tagline {
    order: 1;
    display: block;
    width: 100%;
    text-align: center;
    font-size: 11pt;
    font-weight: var(--weight-bold); /* phone keeps bold; desktop uses black */
    margin: 2pt 0 28px; /* explicit booth ↔ tagline +2pt */
  }

  .artifact-wrap {
    --well-scale-effective: min(
      calc(var(--well-scale) * 0.9),
      calc(78vw / 395px)
    );
    order: 2;
  }

  .store-badge {
    order: 3;
    margin-top: calc(28px - 3pt - 4pt - 4pt + 2pt); /* +2pt above App Store */
  }

  .store-badge img {
    height: calc(40px + 8pt - 2pt); /* −2pt */
  }

  .footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    align-items: flex-start;
    gap: 1rem;
    padding: 12px var(--phone-edge-x)
      calc(var(--phone-edge-bottom) + env(safe-area-inset-bottom, 0px));
    background: var(--color-bg);
    pointer-events: auto;
  }
}
