/* Moonshine Car Care holding page. Colours, type and motion match the main site (src/app/globals.css). */

@font-face {
  font-family: "Anton";
  src: url("/fonts/anton.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/fonts/montserrat.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --ink: #0f0e0d;
  --cream: #efe3c8;
  --cream-dim: #b5aa94;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  /* the slant of the stripes, from the brand banner */
  --slant: 14deg;
  /* phones: how far the slats carry on past the page's top and bottom, behind the clock and the toolbar */
  --run: 160px;
}

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

html {
  background: var(--ink);
  color: var(--cream);
  /* no rubber-band bounce past the page's edges */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

/*
 * Phones: Safari on iOS 26 shows the page behind the clock and around the toolbar only where the page
 * has been scrolled under them (it fills them with one flat colour otherwise). So the page gets room
 * above and below for the slats to carry on into, and always sits scrolled past the top of it: it snaps
 * there, so a scroll Safari restores on reload or a resize can't leave it too low (the script at the
 * end of index.html also puts it there straight away).
 */
@media (orientation: portrait) {
  html {
    overflow: hidden;
    scroll-snap-type: y mandatory;
  }
  body {
    padding-block: var(--run);
  }
  .page {
    scroll-snap-align: start;
  }
}

img {
  display: block;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
}

ul {
  list-style: none;
  padding: 0;
}

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

::selection {
  background: #f2c230;
  color: var(--ink);
}

/*
 * Portrait (phones, upright tablets): the range as slats, Preload to Bottoms Up above the copy and
 * Black Strap to Versa Clean below it. Landscape: one row of slanted stripes beside the copy (see the
 * media query further down).
 */
.page {
  display: grid;
  height: 100svh;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  /* the slats run on above and below; only the sides are cut off */
  overflow-x: clip;
}

.range-cell,
.range {
  display: contents;
}

.group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(3px, 0.9vw, 6px);
  transform: skewY(calc(var(--slant) * -1));
}

.group:first-child {
  grid-row: 1;
}

.group:last-child {
  grid-row: 3;
}

.stripe {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1 1 0;
  background-color: var(--field);
  /* the icon and badge size themselves to the stripe */
  container-type: size;
  transition: flex-grow 700ms var(--ease-out-expo);
}

/* the open stripe sits above its neighbours, so its badge and shadow overlap the stripes either side */
.stripe {
  z-index: 0;
}

.stripe[data-open] {
  z-index: 1;
  flex-grow: 5;
}

/* the outermost slats run on past the screen edge, so the slant never shows the background there */
.group:first-child .stripe:first-child::before,
.group:last-child .stripe:last-child::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  height: calc(var(--run) + 30vw);
  background-color: inherit;
}

/* each overlaps its slat by 2px, so no hairline shows where the two meet */
.group:first-child .stripe:first-child::before {
  bottom: calc(100% - 2px);
}

.group:last-child .stripe:last-child::after {
  top: calc(100% - 2px);
}

.stripe button {
  position: absolute;
  inset: 0;
  outline: none;
}

.stripe button:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: -6px;
}

/* skewed back upright, so the icon and badge sit straight; centred as a block too, as the badge is bigger than a closed stripe */
.mark {
  pointer-events: none;
  position: absolute;
  /* above the outer stripes' run past the screen edge */
  z-index: 1;
  inset: 0;
  display: grid;
  place-content: center;
  place-items: center;
  transform: skewY(var(--slant));
}

.mark img {
  grid-area: 1 / 1;
}

.icon {
  width: auto;
  height: min(clamp(18px, 6.4vw, 30px), 70cqh);
  transition:
    opacity 500ms var(--ease-out-expo),
    scale 500ms var(--ease-out-expo);
}

.range:has([data-open]) .stripe:not([data-open]) .icon {
  opacity: 0.5;
}

.stripe[data-open] .icon {
  opacity: 0;
  scale: 0.75;
}

/* the label's seal, stamped at the guidelines' -8 to -14 degrees (64px minimum on screen) */
.badge {
  width: min(clamp(84px, 26vw, 130px), 92cqh);
  min-width: 64px;
  height: auto;
  opacity: 0;
  rotate: -30deg;
  scale: 1.25;
  filter: drop-shadow(0 12px 22px rgb(0 0 0 / 0.5));
  transition:
    opacity 200ms ease-out,
    scale 200ms ease-out,
    rotate 200ms ease-out;
}

.stripe[data-open] .badge {
  opacity: 1;
  rotate: -11deg;
  scale: 1;
  transition-duration: 700ms;
  transition-delay: 150ms;
  transition-timing-function: var(--ease-out-expo);
}

/* clear of the slanted slat edges above and below (tan 14deg of half the width, plus a little air) */
.content {
  grid-row: 2;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(11vw + 6px) 16px;
  text-align: center;
}

.lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo {
  width: clamp(220px, 42vw, 420px);
  height: auto;
}

h1 {
  margin-top: clamp(16px, 3vh, 40px);
  font-family: "Anton", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(44px, 8vw, 80px);
  line-height: 0.9;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}

.line {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.625;
  text-wrap: balance;
  color: var(--cream-dim);
}

.line span {
  display: block;
}

.footer {
  margin-top: 18px;
  font-family: "Montserrat", Arial, sans-serif;
  font-weight: 600;
  font-size: 9px;
  line-height: 2;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgb(239 227 200 / 0.45);
}

.footer span {
  display: block;
}

.footer .sep {
  display: none;
}

.footer a {
  transition: color 150ms;
}

.footer a:hover {
  color: var(--cream);
}

/* short phones: a tighter middle leaves the slats room to breathe */
@media (orientation: portrait) and (max-height: 720px) {
  .content {
    padding-block: calc(9vw + 4px);
  }
  .logo {
    width: 190px;
  }
  h1 {
    margin-top: 12px;
    font-size: 38px;
  }
  .line {
    margin-top: 10px;
  }
  .footer {
    margin-top: 12px;
  }
}

@media (min-width: 40rem) {
  .line {
    font-size: 13px;
  }
}

@media (min-width: 80rem) {
  .line {
    font-size: 14px;
  }
  .footer span,
  .footer .sep {
    display: inline;
  }
}

@media (orientation: landscape) {
  .page {
    overflow: hidden;
    grid-template-columns: 52fr 48fr;
    grid-template-rows: minmax(0, 1fr);
  }
  .range-cell {
    display: block;
    position: relative;
    grid-row: 1;
    grid-column: 1;
  }
  /* the stripes, slanted as one block and run past the top and bottom */
  .range {
    position: absolute;
    inset: -12% 0;
    display: flex;
    gap: clamp(3px, 0.42vw, 9px);
    transform: skewX(calc(var(--slant) * -1));
  }
  .group {
    display: contents;
  }
  .group:first-child .stripe:first-child::before {
    inset-inline: auto;
    inset-block: 0;
    right: calc(100% - 2px);
    width: 60vh;
    height: auto;
  }
  .group:last-child .stripe:last-child::after {
    content: none;
  }
  .mark {
    transform: skewX(var(--slant));
  }
  .icon {
    width: min(clamp(18px, 2.3vw, 46px), 72cqw);
    height: auto;
  }
  .badge {
    width: clamp(84px, 12vw, 250px);
  }
  .content {
    grid-row: 1;
    grid-column: 2;
    padding: 48px 40px;
  }
  .logo {
    width: clamp(220px, 30vw, 600px);
  }
  h1 {
    margin-top: clamp(24px, 5vh, 64px);
    font-size: clamp(44px, 5.2vw, 104px);
  }
  .line {
    margin-top: 16px;
  }
  .footer {
    position: absolute;
    inset-inline: 0;
    bottom: calc(24px + env(safe-area-inset-bottom));
    margin-top: 0;
  }
}

/* each stripe slides in along its own length (in from the sides on portrait screens), then the copy rises in */
.group:first-child .stripe {
  --from: -101% 0;
}

.group:last-child .stripe {
  --from: 101% 0;
}

@media (orientation: landscape) {
  .group:first-child .stripe,
  .group:last-child .stripe {
    --from: 0 115%;
  }
}

@keyframes stripe-in {
  from {
    translate: var(--from);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 14px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .stripe {
    animation: stripe-in 1.2s var(--ease-out-expo) both;
    animation-delay: calc(120ms + var(--i) * 55ms);
  }
  .lockup {
    animation: rise 1s var(--ease-out-expo) 0.6s both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stripe {
    transition: none;
  }
  .badge {
    transition-property: opacity;
  }
}
