/* CropNow: shared tokens, base styles and the site header. */

:root {
  /* Brand palette. Black, green and chalk white lead; the rest stay muted. */
  --black: #000000;
  --green: #42923E;
  --forest: #0D3B09;
  --chalk: #F8FAF7;
  --sage: #C5D1B5;
  --clay: #B96E4C;
  --sun: #F0CF86;

  --ink: var(--black);
  --font-display: "Sofia Sans Extra Condensed", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --font-text: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gutter: clamp(1.25rem, 3.4vw, 4.5rem);
  --header-h: clamp(4rem, 9vh, 6rem);
  --ease: cubic-bezier(.22, .61, .36, 1);

  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 4px;
  border-radius: 2px;
}

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

.skip-link {
  position: absolute;
  top: .75rem;
  left: var(--gutter);
  z-index: 100;
  padding: .6rem 1.1rem;
  border-radius: 999px;
  background: var(--forest);
  color: var(--chalk);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform .2s var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* -- Header ------------------------------------------------------------ */

.site-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: var(--header-h);
  padding-inline: var(--gutter);
}

/* The CropNow wordmark is all black: "Now" takes the same colour as "Crop". */
.brand-now {
  color: inherit;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

/* The CropNow mark (also the favicon) beside the name, in its own green. */
.site-brand__mark {
  width: 1.15em;
  height: 1.15em;
}

.site-nav {
  margin-left: auto;
}

.site-nav__list {
  display: flex;
  gap: clamp(1.5rem, 2.9vw, 3.4rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__link {
  position: relative;
  display: inline-block;
  padding-block: .5rem;
  font-size: clamp(.9rem, .62rem + .4vw, 1.06rem);
  font-weight: 500;
  letter-spacing: .005em;
  text-decoration: none;
}

/* A green line grows under the link on hover. */
.site-nav__link::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: .2rem;
  left: 0;
  height: 1.5px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .35s var(--ease);
}

.site-nav__link:hover::after {
  transform: scaleX(1);
}

/* The current page carries the same green full stop as the title. */
.site-nav__link[aria-current="page"]::before {
  content: "";
  position: absolute;
  bottom: -.3rem;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--green);
}

.site-nav__toggle {
  display: none;
}

@media (max-width: 860px) {
  .js .site-nav__toggle {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: 600 .95rem/1 var(--font-text);
    cursor: pointer;
  }

  .site-nav__toggle-icon {
    position: relative;
    width: 1.35rem;
    height: 10px;
  }

  .site-nav__toggle-icon::before,
  .site-nav__toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 1.5px;
    background: currentColor;
    transition: transform .3s var(--ease), top .3s var(--ease);
  }

  .site-nav__toggle-icon::before {
    top: 0;
  }

  .site-nav__toggle-icon::after {
    top: calc(100% - 1.5px);
  }

  .site-nav[data-open] .site-nav__toggle-icon::before {
    top: calc(50% - .75px);
    transform: rotate(45deg);
  }

  .site-nav[data-open] .site-nav__toggle-icon::after {
    top: calc(50% - .75px);
    transform: rotate(-45deg);
  }

  .js .site-nav__list {
    position: fixed;
    inset: 0;
    z-index: 1;
    flex-direction: column;
    justify-content: center;
    gap: .2rem;
    padding: var(--header-h) var(--gutter) 3rem;
    background: var(--chalk);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s var(--ease), visibility 0s linear .3s;
  }

  .js .site-nav[data-open] .site-nav__list {
    opacity: 1;
    visibility: visible;
    transition: opacity .3s var(--ease);
  }

  .js .site-nav__link {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 13vw, 4.5rem);
    font-weight: 900;
    line-height: 1.05;
    padding-block: .1rem;
  }

  .js .site-nav__link::after {
    bottom: .35rem;
    height: 3px;
  }

  .js .site-nav__link[aria-current="page"]::before {
    top: 50%;
    right: -1.1rem;
    bottom: auto;
    left: auto;
    width: .5rem;
    height: .5rem;
    margin: -.25rem 0 0;
  }

  /* Without JavaScript the menu cannot open, so lay the links out inline. */
  html:not(.js) .site-header {
    height: auto;
    padding-block: 1rem;
  }

  html:not(.js) .site-nav__list {
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
  }
}

html[data-menu-open] {
  overflow: hidden;
}

/* -- Village scenery ------------------------------------------------------
 * A line-drawn Indian farming village, drawn fresh on every page load by
 * village.js into the <canvas> of each [data-village] element.
 */

.village-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Along the outer edges of every page: fixed to the bottom of the window,
 * behind the content, and shown only in the columns either side of it. The
 * centre stays plain. Sections with their own scenery cover it. */
.edge {
  --edge-clear: min(62rem, 100vw - 24rem);
  --edge-fade: 9rem;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: min(58vh, 38vw);
  pointer-events: none;
  opacity: .9;
  -webkit-mask-image: linear-gradient(90deg,
    #000 calc(50% - var(--edge-clear) / 2 - var(--edge-fade)),
    transparent calc(50% - var(--edge-clear) / 2),
    transparent calc(50% + var(--edge-clear) / 2),
    #000 calc(50% + var(--edge-clear) / 2 + var(--edge-fade)));
  mask-image: linear-gradient(90deg,
    #000 calc(50% - var(--edge-clear) / 2 - var(--edge-fade)),
    transparent calc(50% - var(--edge-clear) / 2),
    transparent calc(50% + var(--edge-clear) / 2),
    #000 calc(50% + var(--edge-clear) / 2 + var(--edge-fade)));
}

/* On narrow and portrait screens there are no side columns, so sections
 * show a simpler strip of the same scenery above or below their text. */
.band {
  display: none;
  position: relative;
  height: clamp(10rem, 52vw, 16rem);
  pointer-events: none;
  opacity: .9;
}

@media (max-width: 899px), (max-aspect-ratio: 1/1) {
  .edge {
    display: none;
  }

  .band {
    display: block;
  }
}

/* -- Photographs with distorted edges ----------------------------------------
 * Instead of a frame or a regular shape, a photograph's edge is torn and
 * irregular: masks/photo-edge-N.svg warps a rounded rectangle with noise. The
 * mask stretches to the photograph's own proportions, so give the element
 * those, and only a thin band of the edge is lost.
 */

.photo-edge {
  display: block;
}

.photo-edge > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(.9) sepia(.06);
  -webkit-mask: var(--edge) center / 100% 100% no-repeat;
  mask: var(--edge) center / 100% 100% no-repeat;
}

.photo-edge--1 { --edge: url("../masks/photo-edge-1.svg"); }
.photo-edge--2 { --edge: url("../masks/photo-edge-2.svg"); }
.photo-edge--3 { --edge: url("../masks/photo-edge-3.svg"); }
.photo-edge--4 { --edge: url("../masks/photo-edge-4.svg"); }

/* -- Pages still to be designed ----------------------------------------- */

.page-stub {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--header-h) var(--gutter) 4rem;
}

.band--page {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
}

.page-stub__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(4rem, 14vw, 12rem);
  font-weight: 900;
  line-height: .9;
}
