/* Ondra Surfboards
   One paper ground, one ink, one coral accent. Two families: Instrument Serif for the
   things you read from across the room, Hanken Grotesk for the things you read up close.
   Every vertical gap is a whole or half multiple of the tide line (--tl). */

:root {
  --paper: #f3efe7;
  --ink: #10201f;
  --ink-soft: #46524f;
  --coral: #e0532f;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;

  --tl: 28px; /* the tide line: the page's one rhythm */
  --h0: calc(var(--tl) * 0.5);
  --h1: var(--tl);
  --h1h: calc(var(--tl) * 1.5);
  --h2: calc(var(--tl) * 2);
  --h3: calc(var(--tl) * 3);
  --h4: calc(var(--tl) * 4);
  --set: calc(var(--tl) * 6); /* the break between two sets */

  --edge: 11vw; /* main left edge */
  --edge-b: 57vw; /* the second edge */
  --gut: 28px;
  --measure: 25em;

  /* display scale */
  --t-xs: 12px;
  --t-s: 14px;
  --t-m: 18px;
  --t-l: 30px;
  --t-xl: 46px;
  --t-2xl: 72px;
  --t-3xl: 108px;
  --title: clamp(84px, 13vw, 240px);
}

@media (orientation: portrait) {
  :root {
    --title: clamp(72px, 21vw, 220px);
  }
}

@media (max-width: 599px) {
  :root {
    --tl: 26px;
    --set: calc(var(--tl) * 4.5);
    --edge: 20px;
    --gut: 20px;
    --t-l: 26px;
    --t-xl: 36px;
    --t-2xl: 52px;
    --t-3xl: 66px;
    --title: clamp(80px, 27vw, 140px);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --set: calc(var(--tl) * 4);
    --t-2xl: 52px;
    --t-3xl: 72px;
    --title: clamp(64px, 10vw, 140px);
  }
}

@media (min-width: 2200px) {
  :root {
    --tl: 40px;
    --t-xs: 15px;
    --t-s: 18px;
    --t-m: 26px;
    --t-l: 42px;
    --t-xl: 66px;
    --t-2xl: 104px;
    --t-3xl: 156px;
    --gut: 40px;
  }
}

/* ---------- base ---------- */

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-m);
  line-height: var(--tl);
  font-weight: 400;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  overflow-x: clip;
}

h1,
h2,
h3,
p,
dl,
dt,
dd,
figure {
  margin: 0;
  font-weight: 400;
}

h1,
h2 {
  font-family: var(--serif);
  text-wrap: balance;
}

p,
dd {
  text-wrap: pretty;
}

img {
  display: block;
  max-width: none;
  height: auto;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.32em;
}

a:hover {
  text-decoration-color: var(--coral);
}

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

.nb {
  white-space: nowrap;
}

.t-l {
  font-family: var(--serif);
  font-size: var(--t-l);
  line-height: var(--h1h);
}

.t-xl {
  font-family: var(--serif);
  font-size: var(--t-xl);
  line-height: var(--h2);
  letter-spacing: -0.005em;
}

.t-2xl {
  font-size: var(--t-2xl);
  line-height: calc(var(--tl) * 2.5);
  letter-spacing: -0.01em;
}

.t-3xl {
  font-size: var(--t-3xl);
  line-height: calc(var(--tl) * 3.5);
  letter-spacing: -0.015em;
}

.small {
  font-size: var(--t-xs);
  line-height: var(--h0);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- wordmark ---------- */

.mark {
  display: inline-flex;
  align-items: center;
  gap: 0.42em;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.mark svg {
  width: 1.15em;
  height: 0.62em;
  overflow: visible;
}

.mark svg path {
  fill: none;
  stroke: var(--coral);
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* ---------- top: plain words on the bare paper above the scene ---------- */

.top {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--h0) var(--gut) 0 var(--edge);
}

.top a,
.top button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.top nav {
  display: flex;
  column-gap: var(--h1h);
  font-size: var(--t-s);
}

.top nav a {
  text-decoration: none;
}

.top nav a:hover,
.top nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.5em;
}

.top nav a[aria-current="page"] {
  text-decoration-color: var(--coral);
}

.top button {
  display: none;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--t-s);
  cursor: pointer;
}

@media (max-width: 599px) {
  .top nav {
    display: none;
  }

  .top button {
    display: inline-flex;
  }
}

/* the phone menu: the same paper, the words in the serif */
#menu {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

#menu::backdrop {
  background: var(--paper);
}

#menu .top {
  position: relative;
}

#menu .top button {
  display: inline-flex;
}

#menu nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: var(--h0);
  padding: var(--h4) var(--gut) 0 var(--edge);
}

#menu nav a {
  font-family: var(--serif);
  font-size: var(--t-xl);
  line-height: var(--h2);
  text-decoration: none;
}

/* ---------- the page: art sits behind type and never takes a tap ---------- */

main {
  position: relative;
  z-index: 0;
  /* paintings bleed off both edges; clip them here so a phone never zooms the page out to fit */
  overflow-x: clip;
}

.art {
  position: relative;
  z-index: -1;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.art img,
.art canvas {
  pointer-events: none;
}

.set {
  margin-top: var(--set);
}

.copy {
  max-width: min(var(--measure), 40vw);
}

.copy > * + * {
  margin-top: var(--h1);
}

.copy > h2 + * {
  margin-top: var(--h0);
}

.copy > .gap {
  margin-top: var(--h2);
}

/* a link alone on its line gets a 44px touch area without moving the lines */
.go {
  display: inline-block;
  padding-block: 8px;
  margin-block: -8px;
}

.go::after {
  content: "\2009\2192";
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.go:hover::after {
  transform: translateX(4px);
}

/* the one button */
.button {
  display: inline-flex;
  align-items: center;
  height: 56px;
  padding: 0 var(--h1);
  border: 1px solid var(--coral);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.3s, color 0.3s;
}

.button:hover {
  background: var(--coral);
  color: var(--paper);
}

/* ---------- the cover: one 3:2 painted scene, the title on its bare paper foot ---------- */

.cover {
  /* the scene starts below the nav words, so they always stand on bare paper */
  --scene-top: calc(var(--h2) + 8px);
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: 1fr auto auto;
  padding: 0 0 var(--h2);
}

.scene {
  position: absolute;
  top: var(--scene-top);
  right: 0;
  aspect-ratio: 3 / 2;
  /* as tall as the screen, but never so wide that the title runs into the painted right side */
  height: min(100svh - var(--scene-top), 66.667vw, max(52vw, (100svh - var(--h4) - var(--title)) / 0.78));
}

.scene img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cover h1 {
  grid-row: 1;
  align-self: end;
  position: relative;
  z-index: 1;
  margin: 0 var(--gut) 0 calc(var(--edge) - 0.06em);
  font-size: var(--title);
  line-height: 0.9;
  letter-spacing: -0.02em;
}

.cover h1.long {
  font-size: min(var(--title), 11vw);
}

.cover .lede {
  position: relative;
  z-index: 1;
  margin: var(--h1) var(--gut) 0 var(--edge);
  max-width: 30em;
}

.cover .clock {
  position: relative;
  z-index: 1;
  margin: var(--h0) var(--gut) 0 var(--edge);
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.cover .clock i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 0 rgba(224, 83, 47, 0.45);
  animation: pulse 2.8s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(224, 83, 47, 0.45);
  }
  70%,
  100% {
    box-shadow: 0 0 0 9px rgba(224, 83, 47, 0);
  }
}

/* the clock means something only when the light moves */
html:not(.tide-live) .cover .clock {
  visibility: hidden;
}

@media (orientation: portrait) {
  .cover {
    display: block;
    min-height: 0;
    padding: var(--h2) 0 0;
    overflow-x: clip;
    --sw: 150vw;
  }

  .scene {
    position: relative;
    top: auto;
    right: auto;
    width: var(--sw);
    height: auto;
    margin-left: calc(100vw - var(--sw) + var(--shift, 0vw));
  }

  .cover h1 {
    margin-top: calc(var(--sw) * -0.17);
  }

  .cover .lede {
    max-width: var(--measure);
  }
}

@media (orientation: portrait) and (max-width: 599px) {
  .cover {
    --sw: 170vw;
  }
}

@media (orientation: portrait) and (min-aspect-ratio: 4 / 5) {
  .cover {
    --sw: 125vw;
  }
}

/* ---------- one sentence, broken by sense ---------- */

.swell {
  padding: 0 var(--gut) 0 var(--edge);
  font-family: var(--serif);
}

.swell span {
  display: block;
}

.swell em {
  font-style: italic;
}

/* ---------- a board planted in sand, its shadow off the right edge ---------- */

.plant {
  position: relative;
  min-height: min(100svh, 70vw);
  padding: var(--h2) 0 var(--h2) var(--edge);
}

.plant .art {
  --pw: min(96svh, 60vw);
  position: absolute;
  top: calc(var(--pw) * 0.02);
  right: 0;
  width: var(--pw);
}

.plant .art img {
  width: 100%;
}

.plant .copy {
  max-width: min(var(--measure), 32vw);
  margin-top: var(--h1);
}

/* ---------- a small object close beside one line ---------- */

.beat {
  display: grid;
  grid-template-columns: calc(47vw - var(--edge)) auto;
  justify-content: start;
  align-items: center;
  padding-left: var(--edge);
}

.beat p {
  padding-right: var(--gut);
  text-wrap: balance;
}

.beat .art {
  width: min(26vw, 340px);
}

.beat .art img {
  width: 100%;
}

/* ---------- art against the left edge, type on the second edge ---------- */

.left-art {
  display: grid;
  grid-template-columns: var(--edge-b) 1fr;
  align-items: center;
}

.left-art .art img {
  width: 100%;
}

.left-art .copy {
  padding-right: var(--gut);
  max-width: calc(var(--measure) + var(--gut));
}

.cliff {
  width: min(40vw, 66svh);
}

/* ---------- the close ---------- */

.close {
  margin-top: var(--set);
  padding: 0 var(--gut) var(--h4) var(--edge);
  display: grid;
  grid-template-columns: calc(var(--edge-b) - var(--edge)) 1fr;
  row-gap: var(--h1);
  align-items: end;
}

.close .mark {
  font-size: var(--t-xl);
}

.close p {
  max-width: var(--measure);
}

.close .small {
  grid-column: 1 / -1;
  margin-top: var(--h2);
}

/* ---------- boards.html ---------- */

.lua .art {
  width: min(84vw, 2000px);
  margin-left: -8vw; /* the nose runs off the left edge */
}

.lua .art img {
  width: 100%;
}

.lua .copy {
  max-width: none;
  margin-top: var(--h1);
  padding: 0 var(--gut) 0 var(--edge);
}

.specs > div + div {
  margin-top: var(--h1h);
}

.specs dt {
  font-size: var(--t-xs);
  line-height: var(--h0);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.specs dd {
  margin-top: var(--h0);
  font-family: var(--serif);
  font-size: var(--t-l);
  line-height: var(--h1h);
}

.specs.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, max-content));
  column-gap: var(--h3);
  row-gap: var(--h1h);
}

.specs.row > div + div {
  margin-top: 0;
}

@media (orientation: landscape) and (min-width: 600px) {
  .lua .copy {
    display: grid;
    grid-template-columns: calc(var(--edge-b) - var(--edge)) 1fr;
    grid-template-rows: auto auto 1fr;
    align-items: start;
  }

  .lua .copy > h2,
  .lua .copy > p {
    grid-column: 1;
    max-width: var(--measure);
  }

  .lua .copy .specs {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin-top: var(--h1);
  }
}

/* a board standing whole beside its specs */
.stand {
  position: relative;
  padding: 0 var(--gut) 0 var(--edge);
}

.stand .art {
  position: absolute;
  top: 0;
  height: 100%;
}

.stand .art img {
  height: 100%;
  width: auto;
}

.stand .copy {
  max-width: calc(var(--edge-b) - var(--edge) - var(--gut));
}

.sardinha {
  min-height: min(90svh, 1250px);
}

.sardinha .art {
  left: var(--edge-b);
}

.farol {
  min-height: min(90svh, 1250px);
}

.farol .art {
  left: calc(var(--edge) - 4vw);
}

.farol .copy {
  margin-left: calc(var(--edge-b) - var(--edge));
}

.order {
  padding: 0 var(--gut) 0 var(--edge-b);
}

.order .copy {
  max-width: var(--measure);
}

/* ---------- workshop.html ---------- */

.blank {
  width: 52vw;
}

.steps {
  padding: 0 var(--gut) 0 var(--edge-b);
}

.steps > div + div {
  margin-top: var(--h2);
}

.steps dt {
  display: flex;
  align-items: baseline;
  gap: var(--h0);
  font-family: var(--serif);
  font-size: var(--t-l);
  line-height: var(--h1h);
}

.steps dt span {
  font-family: var(--sans);
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  color: var(--coral);
}

.steps dd {
  margin-top: var(--h0);
  max-width: min(var(--measure), 40vw);
}

@media (orientation: landscape) and (min-width: 600px) {
  .left-art + .steps {
    margin-top: var(--h3);
  }
}

.left-art + .steps {
  margin-top: var(--h3);
}

.glimpse {
  display: grid;
  grid-template-columns: minmax(calc(38vw - var(--edge)), max-content) auto;
  justify-content: start;
  align-items: center;
  padding-left: var(--edge);
}

.glimpse p {
  padding-right: var(--gut);
  text-wrap: balance;
}

.glimpse .art {
  width: min(22vw, 300px);
}

.glimpse .art img {
  width: 100%;
}

.visit {
  --w: min(64vw, 140svh, 1900px, (100vw - var(--edge) - 18em) / 0.86);
  position: relative;
  min-height: calc(var(--w) * 0.6667 + var(--h1h));
  padding-left: var(--edge);
}

.visit .art {
  position: absolute;
  top: var(--h1h);
  right: 0;
  width: var(--w);
}

.visit .art img {
  width: 100%;
}

.visit .copy {
  max-width: min(var(--measure), 100vw - var(--edge) - var(--w) * 0.86);
}

/* ---------- a phone on its side ---------- */

@media (orientation: landscape) and (max-height: 500px) {
  .copy,
  .steps dd,
  .plant .copy {
    max-width: min(var(--measure), 48vw - var(--gut));
  }

  .beat {
    grid-template-columns: calc(56vw - var(--edge)) auto;
  }
}

/* ---------- upright screens and phones: one column, picture first ---------- */

@media (orientation: portrait), (max-width: 599px) {
  .copy,
  .plant .copy,
  .visit .copy,
  .steps dd {
    max-width: var(--measure);
    padding-right: var(--gut);
  }

  .swell {
    max-width: calc(var(--edge) + 20em);
  }

  .plant {
    min-height: 0;
    padding: 0;
  }

  .plant .art {
    position: relative;
    top: 0;
    width: min(86%, max(56svh, 320px));
    margin-left: auto;
  }

  .plant .copy {
    padding-left: var(--edge);
    margin-top: var(--h1);
  }

  .plant > h2 {
    margin: var(--h1) 0 0 var(--edge);
  }

  /* a two-word title wraps onto the paper instead of shrinking onto the painting */
  .cover h1.long {
    font-size: min(var(--title), 25vw);
    margin-top: calc(var(--sw) * -0.06);
  }

  .beat,
  .glimpse {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
  }

  .beat .art,
  .glimpse .art {
    width: min(52vw, 300px);
    margin-left: 34vw;
  }

  .beat p,
  .glimpse p {
    margin-top: var(--h1h);
  }

  .left-art {
    display: block;
  }

  .cliff {
    width: min(76vw, 62svh);
  }

  .blank {
    width: 96vw;
    margin-left: -6vw;
  }

  .left-art .copy {
    margin-top: var(--h1h);
    padding-left: var(--edge);
    max-width: calc(var(--edge) + var(--measure));
  }

  .steps {
    padding-left: var(--edge);
  }

  .order {
    padding-left: var(--edge);
  }

  .visit {
    --w: 130vw;
    min-height: 0;
    padding-left: 0;
  }

  .visit .art {
    position: relative;
    top: 0;
    margin-left: calc(100vw - var(--w));
  }

  .visit .copy {
    position: relative;
    margin-top: var(--h1);
    padding-left: var(--edge);
    max-width: calc(var(--edge) + var(--measure));
  }

  .close {
    display: block;
  }

  .close p {
    margin-top: var(--h1);
  }

  .lua .art {
    width: 128vw;
    margin-left: -22vw;
  }

  .lua .copy {
    margin-top: var(--h1h);
  }
}

@media (max-width: 599px), (max-width: 820px) and (orientation: portrait) {
  .stand {
    min-height: 0;
  }

  .stand .art {
    position: relative;
    height: min(max(70svh, 440px), 620px);
  }

  .sardinha .art {
    left: 0;
    margin-left: 46vw;
  }

  .farol .art {
    left: 0;
    margin-left: 4vw;
  }

  .stand .copy,
  .farol .copy {
    max-width: none;
    margin-left: 0;
    margin-top: var(--h1h);
  }

  .specs.row {
    grid-template-columns: repeat(2, minmax(0, max-content));
    column-gap: var(--h2);
  }
}

/* ---------- arrival: things surface as they come into view ---------- */

html.js .rise {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition:
    opacity 1.1s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: var(--delay, 0s);
}

html.js .rise.in {
  opacity: 1;
  transform: none;
}

/* paintings arrive like a wet wash: from paper to colour */
html.js .wash {
  opacity: 0;
  transition: opacity 1.6s cubic-bezier(0.3, 0.6, 0.2, 1);
  transition-delay: var(--delay, 0s);
}

html.js .wash.in {
  opacity: 1;
}

.drift {
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  html.js .rise,
  html.js .wash {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .drift {
    transform: none !important;
  }

  .cover .clock i {
    animation: none;
  }
}

/* the light canvas, laid exactly over its picture */
.tide-canvas {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.tide-canvas.on {
  opacity: 1;
}
