/* Kiwi Micromarts — a like-for-like copy of the Squarespace 7.1 site.
 *
 * Almost every number here was measured from the original, not chosen. The
 * layout reproduces Squarespace's "Fluid Engine" grid exactly (24 columns on
 * desktop, 8 on mobile, rows sized from the container width), and the type
 * sizes use Squarespace's own fluid formula. reference/probe-<width>.json and
 * reference/layout-<width>.json hold the measurements; MIGRATION.md says why.
 * Change a value here and the page stops matching — compare with
 * `npm.cmd run shots -- local` against reference/screenshots/ first.
 *
 * Sections:
 *   0. Fonts
 *   1. Tokens (colours, spacing, type scale)
 *   2. Base
 *   3. Header and mobile menu
 *   4. Sections and the grid
 *   5. Blocks: text, buttons, images, quote
 *   6. Per-section block placement
 *   7. Dividers and highlights
 *   8. Scroll animations
 *   9. 404 page
 */

/* ------------------------------------------------------------ 0. Fonts */

/* Inter is the same file Squarespace served (variable, latin subset). */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
/* Barlow Medium stands in for Loos Normal, the Adobe font the old site used
 * and whose licence stayed with Squarespace. Chosen by rendering the real
 * headings in 26 free fonts and scoring each against the original, then
 * comparing weights by eye; see MIGRATION.md, "Decisions". */
@font-face {
  font-family: "Barlow";
  src: url("/assets/fonts/barlow-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ----------------------------------------------------------- 1. Tokens */

:root {
  --black: #121211;
  --white: #fff;
  --accent: #aedf1a;        /* lime: header button, highlight underlines */
  --light-accent: #d291f1;  /* lavender: "Contact Us", wavy dividers */

  --max-width: 1657px;
  --gutter: 1.5vw;          /* page padding */
  --mobile-gutter: 6vw;

  --heading-font: "Barlow", "Inter", sans-serif;
  --body-font: "Inter", sans-serif;

  /* Barlow is drawn 5% bigger than Loos Normal was and tracked a touch
   * tighter, so letters are the same height and every heading breaks onto
   * the same lines as the original at 1920, 1440, 1280, 1024 and 768 wide
   * (found by sweeping both values; phones get their own pair below). Line
   * heights stay tied to the ORIGINAL size (see .h1/.h2), so nothing moves. */
  --heading-scale: 1.05;
  --heading-tracking: -0.075em;

  /* Squarespace's fluid type: for a size value v,
   *   min((v-1)·1.2vw + 1rem, max((v-1)·0.012·1657px + 1rem, v·1rem))
   * and on portrait phones (v-1)·0.012·min(100vh, 900px) + 1rem.
   * v: h1 6.2, h2 2.8, large 1.2, small 0.8, header button 0.9, button 0.8. */
  --fs-h1: min(calc(6.24vw + 1rem), max(calc(103.3968px + 1rem), 6.2rem));
  --fs-h2: min(calc(2.16vw + 1rem), max(calc(35.7912px + 1rem), 2.8rem));
  --fs-large: min(calc(0.24vw + 1rem), max(calc(3.9768px + 1rem), 1.2rem));
  --fs-small: min(calc(1rem - 0.24vw), max(calc(1rem - 3.9768px), 0.8rem));
  --fs-btn-header: min(calc(1rem - 0.12vw), max(calc(1rem - 1.9884px), 0.9rem));
  --fs-btn: var(--fs-small);
}
@media (max-width: 767px) and (orientation: portrait) {
  :root {
    /* Matches the original's line breaks at 360, 375, 390 and 414 wide in
     * 27 of 28 headings (the quote wraps one line differently at 390). */
    --heading-scale: 1.06;
    --heading-tracking: -0.065em;
    --fs-h1: calc(5.2 * min(1.2vh, 10.8px) + 1rem);
    --fs-h2: calc(1.8 * min(1.2vh, 10.8px) + 1rem);
    --fs-large: calc(0.2 * min(1.2vh, 10.8px) + 1rem);
    --fs-small: calc(1rem - 0.2 * min(1.2vh, 10.8px));
    --fs-btn-header: calc(1rem - 0.1 * min(1.2vh, 10.8px));
  }
}

/* ------------------------------------------------------------- 2. Base */

html {
  font-size: 22px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (max-width: 991px) {
  html { font-size: 16px; }
}

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

body {
  margin: 0;
  background: var(--white);
  color: var(--black);
  font-family: var(--body-font);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.2em;
  /* Declared in em here and inherited as a length, exactly as Squarespace
   * did: every Inter paragraph gets the body's -0.01em, whatever its size. */
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }

a { color: inherit; }

strong { font-weight: 700; }

/* The hero's <h1> wraps two grid blocks (the two headline lines sit in
 * separately placed blocks, as in the original). display: contents lets its
 * children be grid items while the heading stays one heading. */
.contents { display: contents; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 1rem; left: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--black);
  font-size: 0.8rem;
  text-decoration: none;
  border-radius: 30px;
  transform: translateY(-300%);
}
.skip-link:focus { transform: none; }

/* ----------------------------------------- 3. Header and mobile menu */

/* In the original the header floats over the first section, which is padded
 * down by exactly the header's height. Keeping it in the flow gives the same
 * result without measuring it. */
.header {
  position: relative;
  z-index: 20;
}
.header-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2vw var(--gutter);
}
.header-logo img {
  width: auto;
  height: 193px;
}

.btn {
  display: inline-block;
  font-family: var(--body-font);
  font-weight: 400;
  line-height: normal;
  letter-spacing: normal;
  text-align: center;
  text-decoration: none;
  color: var(--black);
  border: 1px solid var(--black);
  border-radius: 30px;
  padding: 1.2rem 2.004rem;
  transition: opacity 0.1s linear;
}
.btn:hover { opacity: 0.8; }
.btn--header {
  background: var(--accent);
  font-size: var(--fs-btn-header);
  text-transform: uppercase;
}

.burger {
  display: none;
  width: 47px;
  height: 37px;
  padding: 1px 6px;
  margin: 0;
  background: none;
  border: 0;
  color: var(--black);
  cursor: pointer;
}
.burger-box {
  position: relative;
  display: block;
  width: 35px;
  height: 35px;
}
.burger-bun {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 100%;
  height: 1px;
  margin: auto;
  background: currentColor;
  transition: transform 250ms cubic-bezier(.2, .6, .3, 1), width 250ms cubic-bezier(.2, .6, .3, 1);
}
.burger-bun--top { transform: translateY(-5.5px); }
.burger-bun--bottom { transform: translateY(5.5px); }
.menu-open .burger-bun--top { transform: translateX(3.5px) rotate(-135deg); width: 28px; }
.menu-open .burger-bun--bottom { transform: translateX(3.5px) rotate(135deg); width: 28px; }

.menu {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--white);
  opacity: 0;
  visibility: hidden;
  transition: visibility 0.6s cubic-bezier(.4, 0, .2, 1), opacity 0.4s cubic-bezier(.4, 0, .2, 1);
}
.menu-open .menu {
  opacity: 1;
  visibility: visible;
}
.menu-cta {
  padding: 15.6px 0 var(--mobile-gutter);
  text-align: center;
}
.btn--menu {
  min-width: 210px;
  background: #000;
  border-color: #000;
  color: var(--white);
  font-size: 1.2rem;
  text-transform: uppercase;
}
html.menu-open { overflow: hidden; }

/* Squarespace's mobile header: phones and narrow windows, and touch screens
 * up to 1024px wide (tablets in landscape). */
@media (pointer: coarse) and (max-width: 1024px), (max-width: 799px) {
  .header-bar { padding: var(--mobile-gutter); }
  .header-bar .btn--header { display: none; }
  .burger { display: block; }
}
@media (max-width: 767px) {
  .header-logo img { height: 84px; }
}

/* ------------------------------------------- 4. Sections and the grid */

.sec {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 33vh;           /* "small" section height */
}
.sec-content {
  position: relative;
  z-index: 1;
  padding: 3.3vmax 0;
}

/* Backgrounds inset from the page edges by the gutter. */
.sec--inset {
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* Fluid Engine: gutter column, 8 (mobile) or 24 columns capped at the max
 * page width, gutter column. Rows have a floor and grow to fit their content.
 * --rows-m / --rows-d are the row counts the original section declared. */
.grid {
  --gc: 11px;                 /* column gap */
  --side: calc(var(--mobile-gutter) - var(--gc));
  display: grid;
  column-gap: var(--gc);
  row-gap: 11px;
  grid-template-columns:
    minmax(var(--side), 1fr)
    repeat(8, minmax(0, calc((var(--max-width) - var(--gc) * 7) / 8)))
    minmax(var(--side), 1fr);
  grid-template-rows: repeat(var(--rows-m), minmax(24px, auto));
}
@media (min-width: 768px) {
  .grid {
    --side: calc(var(--gutter) - var(--gc));
    --inset: 0px;
    --container: min(var(--max-width), calc(100vw - var(--gutter) * 2 - var(--inset)));
    grid-template-columns:
      minmax(var(--side), 1fr)
      repeat(24, minmax(0, calc((var(--max-width) - var(--gc) * 23) / 24)))
      minmax(var(--side), 1fr);
    grid-template-rows: repeat(var(--rows-d), minmax(calc(var(--container) * 0.0215), auto));
  }
  .sec--inset .grid { --inset: calc(var(--gutter) * 2); }
}

/* ------------------------------ 5. Blocks: text, buttons, images, quote */

.blk {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
}
.blk--center { justify-content: center; }

/* Paragraph spacing as Squarespace had it: 1rem between paragraphs, 2rem
 * around headings. Written as margin-top only, because blocks are flex
 * containers and margins inside them don't collapse. */
.text > * { margin: 0; }
.text > * + * { margin-top: 1rem; }
.text > * + .h1, .text > * + .h2,
.text > .h1 + *, .text > .h2 + * { margin-top: 2rem; }

.h1, .h2, .quote {
  font-family: var(--heading-font);
  font-weight: 500;
  letter-spacing: var(--heading-tracking);
  white-space: pre-wrap;
}
.h1 {
  font-size: calc(var(--fs-h1) * var(--heading-scale));
  line-height: calc(var(--fs-h1) * 0.792);     /* 1 + (1 - 6.2) / 25 */
}
.h2 {
  font-size: calc(var(--fs-h2) * var(--heading-scale));
  line-height: calc(var(--fs-h2) * 0.928);     /* 1 + (1 - 2.8) / 25 */
}
.t-large { font-size: var(--fs-large); line-height: 1.2; }
.t-small { font-size: var(--fs-small); line-height: 1.2; }
.text p { white-space: pre-wrap; }

/* Text that Squarespace scaled to fill its block ("B arista Quality Coffee",
 * "& Satisfying Snacks"): a fixed fraction of the block's width. */
.scaled {
  container-type: inline-size;
}
.scaled-text {
  display: block;
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 500;
  letter-spacing: var(--heading-tracking);
  line-height: 1;
  white-space: nowrap;
  color: #181817;
}

.btn-wrap {
  display: flex;
  justify-content: center;
}
.btn--secondary {
  background: var(--light-accent);
  font-size: var(--fs-btn);
  letter-spacing: 0.02em;
}

/* Images sit absolutely inside their block so a tall photo can't push the
 * grid rows apart; the block's grid area decides the size. */
.img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 40px;
}
.img--contain {
  object-fit: contain;
  border-radius: 0;
}

/* The hero coffee machine had Squarespace's "parallax" image effect on
 * (angle 45°, intensity 20): the picture is drawn 1.12× larger than its box,
 * clipped to it, and drifts right and up as the page scrolls. The box is the
 * image's own shape, centred in the block, as Squarespace sized it. site.js
 * moves it; this is the resting (half-way) position. */
.b-hero-5 { container-type: size; }
.parallax {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100cqw, 100cqh * 591 / 592);
  height: min(100cqh, 100cqw * 592 / 591);
  overflow: hidden;
  border-radius: 100px;
}
.parallax img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.12);
  will-change: transform;
}

.quote-card {
  margin: 0;
  flex: 1;
  padding: 6%;
  background: rgba(255, 255, 255, 0.53);
  border-radius: 40px;
}
.quote {
  margin: 1rem 0;
  font-size: calc(var(--fs-h2) * var(--heading-scale));
  line-height: var(--fs-h2);
  color: var(--black);
}
@media (max-width: 767px) and (orientation: portrait) {
  /* The one heading that needed its own tracking to wrap like the original
   * at 360-414 wide. */
  .quote { letter-spacing: -0.07em; }
}

/* ------------------------------------ 6. Per-section block placement */

/* Grid areas are row-start / column-start / row-end / column-end, copied
 * from the original. Column 1 is the left gutter column. */

/* Hero */
.sec--hero {
  padding-bottom: calc(var(--gutter) + 6vw);   /* inset gutter + divider */
}
.grid--hero { --rows-m: 23; --rows-d: 20; }
.b-hero-1 { grid-area: 1 / 2 / 4 / 10; z-index: 1; }
.b-hero-2 { grid-area: 3 / 2 / 6 / 10; z-index: 2; }
.b-hero-3 { grid-area: 6 / 2 / 10 / 10; z-index: 3; }
.b-hero-4 { grid-area: 10 / 2 / 12 / 6; z-index: 4; }
.b-hero-5 { grid-area: 13 / 2 / 23 / 10; z-index: 2; }
.b-hero-1 .scaled-text { font-size: 12.87cqw; }   /* ink width = the original's */
.b-hero-2 .scaled-text { font-size: 13.85cqw; }
.b-hero-1 .scaled-text { color: #181817; }
.b-hero-2 .scaled-text { color: var(--black); }
@media (min-width: 768px) {
  .b-hero-1 { grid-area: 2 / 1 / 6 / 15; z-index: 2; }
  .b-hero-2 { grid-area: 6 / 1 / 9 / 14; z-index: 3; }
  .b-hero-3 { grid-area: 11 / 3 / 14 / 12; z-index: 3; justify-content: center; }
  .b-hero-4 { grid-area: 15 / 3 / 17 / 7; z-index: 4; }
  .b-hero-5 { grid-area: 1 / 13 / 19 / 27; z-index: 1; }
}

/* Intro statement */
.sec--intro .h2 { color: #000; }
.grid--intro { --rows-m: 11; --rows-d: 11; }
.b-intro { grid-area: 1 / 2 / 12 / 10; }
@media (min-width: 768px) {
  .b-intro { grid-area: 3 / 5 / 12 / 23; }
}

/* Four steps */
.grid--steps { --gc: 15px; --rows-m: 49; --rows-d: 14; }
.b-step-1-img { grid-area: 1 / 2 / 9 / 8; z-index: 4; }
.b-step-1-title { grid-area: 9 / 2 / 10 / 8; z-index: 2; }
.b-step-1-text { grid-area: 10 / 2 / 12 / 8; z-index: 3; }
.b-step-2-img { grid-area: 13 / 4 / 21 / 10; z-index: 3; }
.b-step-2-title { grid-area: 21 / 4 / 22 / 10; z-index: 1; }
.b-step-2-text { grid-area: 22 / 4 / 24 / 10; z-index: 2; }
.b-step-3-img { grid-area: 25 / 2 / 33 / 8; z-index: 4; }
.b-step-3-title { grid-area: 33 / 2 / 34 / 8; z-index: 2; }
.b-step-3-text { grid-area: 34 / 2 / 36 / 8; z-index: 3; }
.b-step-4-img { grid-area: 37 / 4 / 45 / 10; z-index: 5; }
.b-step-4-title { grid-area: 45 / 4 / 46 / 10; z-index: 3; }
.b-step-4-text { grid-area: 46 / 4 / 48 / 10; z-index: 4; }
@media (min-width: 768px) {
  .b-step-1-img { grid-area: 3 / 3 / 11 / 7; z-index: 11; }
  .b-step-1-title { grid-area: 11 / 3 / 12 / 8; z-index: 5; }
  .b-step-1-text { grid-area: 12 / 3 / 15 / 7; z-index: 8; }
  .b-step-2-img { grid-area: 1 / 9 / 8 / 13; z-index: 2; }
  .b-step-2-title { grid-area: 8 / 9 / 9 / 13; z-index: 3; }
  .b-step-2-text { grid-area: 9 / 9 / 13 / 13; z-index: 6; }
  .b-step-3-img { grid-area: 3 / 15 / 11 / 19; z-index: 12; }
  .b-step-3-title { grid-area: 11 / 15 / 12 / 19; z-index: 7; }
  .b-step-3-text { grid-area: 12 / 15 / 14 / 19; z-index: 9; }
  .b-step-4-img { grid-area: 1 / 21 / 8 / 25; z-index: 14; }
  .b-step-4-title { grid-area: 8 / 21 / 9 / 26; z-index: 10; }
  .b-step-4-text { grid-area: 9 / 21 / 12 / 25; z-index: 13; }
}
.img--clean { object-position: 50.611% 68.8086%; }
.img--enjoy { object-position: 45.8091% 100%; }

/* Coffee and snacks */
.sec--coffee { padding-bottom: 6vw; }        /* divider */
.sec--coffee .h2 { color: #000; }
.grid--coffee { --rows-m: 11; --rows-d: 20; }
.b-coffee { grid-area: 1 / 2 / 12 / 10; }
@media (min-width: 768px) {
  .b-coffee { grid-area: 3 / 5 / 21 / 23; }
}

/* Empty spacer section, as in the original */
.sec--spacer { min-height: 1vh; }
.sec--spacer .sec-content { padding: 0.1vmax 0; }
.grid--spacer { --rows-m: 2; --rows-d: 2; }

/* Testimonial */
.sec--quote {
  min-height: 40vh;
  padding-top: var(--gutter);
  padding-bottom: var(--gutter);
}
.sec--quote .sec-content { padding: 4vmax 0; }
.sec-bg {
  position: absolute;
  inset: var(--gutter);
  overflow: hidden;
}
.sec-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}
.sec-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--white);
  opacity: 0.15;
}
.grid--quote { --rows-m: 6; --rows-d: 10; }
.b-quote { grid-area: 1 / 2 / 7 / 10; z-index: 1; }
@media (min-width: 768px) {
  .b-quote { grid-area: 2 / 5 / 11 / 23; }
}

/* Get in Touch — the site footer, on every page */
.grid--contact { --rows-m: 4; --rows-d: 8; }
.b-contact { grid-area: 1 / 2 / 3 / 10; z-index: 2; text-align: center; }
@media (min-width: 768px) {
  .b-contact { grid-area: 1 / 8 / 9 / 20; }
}
.b-contact .h1 { color: var(--black); }
.b-contact a {
  color: #000;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

/* --------------------------------------- 7. Dividers and highlights */

/* The wavy lavender line along the bottom of the hero and of the coffee
 * section. Squarespace's setting: one wave per 100vw, 6vw tall, shifted
 * 1000px (which it halves). The SVG is three waves wide and slid 500px left,
 * so the phase matches at any width without JavaScript. */
.has-divider { overflow: hidden; overflow: clip; }
.divider {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 300%;
  height: 6vw;
  transform: translateX(-500px);
  overflow: visible;
  pointer-events: none;
}
.divider path {
  fill: none;
  stroke: var(--light-accent);
  stroke-width: 2px;
  stroke-linecap: square;
}

/* Highlighted phrases get a hand-drawn lime underline, drawn by site.js
 * (the curve has to follow each line the phrase wraps onto). */
.has-hl {
  position: relative;
  isolation: isolate;         /* so the underline can sit behind the text */
}
.hl-layer {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.hl-layer svg {
  position: absolute;
  overflow: visible;
}
.hl-layer path {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: square;
  stroke-linejoin: bevel;
}

/* ------------------------------------------------ 8. Scroll animations */

/* Only with JavaScript: without it, everything is simply visible. Text fades
 * in; images, the quote card and the contact block wipe in from the left.
 * site.js staggers the delays exactly as Squarespace did (i / 38 s). */
.js [data-anim="fade"] {
  opacity: 0;
  transition: opacity 0.65s ease var(--delay, 0s);
}
.js [data-anim="fade"].is-in { opacity: 1; }
.js [data-anim="clip"] {
  clip-path: ellipse(0 100% at 0 0);
}
.js [data-anim="clip"].is-in {
  animation: clip-in 0.65s ease var(--delay, 0s) forwards;
}
@keyframes clip-in {
  from { clip-path: polygon(0 0, 10% 0, 0 100%, 0 100%); }
  to { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
}
@media (prefers-reduced-motion: reduce) {
  .js [data-anim="fade"] { opacity: 1; transition: none; }
  .js [data-anim="clip"] { clip-path: none; }
  .js [data-anim="clip"].is-in { animation: none; }
}

/* ----------------------------------------------------------- 9. 404 page */

/* Squarespace's system 404: plain Inter text, gutter-padded, then the same
 * "Get in Touch" footer as every page. */
.notfound {
  padding: 0 var(--gutter) var(--gutter);
}
.notfound p,
.notfound ul { margin: 1rem 0; }
.notfound p:first-of-type { padding-top: var(--gutter); }
.notfound ul { padding-left: 40px; }
.notfound a { color: #000; text-decoration: none; }
