/*
  Keramapke, for now: a home page with Mapke's studio sign on it, her work,
  an about page, and a shop that is coming soon. Click the sign, or tab to it
  and press Enter, and it turns over. On the shop it starts on its back,
  which says "Coming soon!". js/sign.js does the turning; without JavaScript
  the sign is just a picture.

  The Content-Security-Policy only allows this file, so: no style=""
  attributes or <style> blocks in the HTML. Put all styling here.
*/

:root {
  --sky: #bcd6f2; /* the glaze of her periwinkle cup */
  --ink: #2b2341;
  --cobalt: #2c4fb8;
  --violet: #4a2d7c; /* the cut side of the letters in the header */
  --lemon: #fdd919;
  --font-display: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;

  /* The header: the cup on the left (home), the words on the right. */
  --edge: clamp(0.9rem, 2.5vw, 1.75rem);
  --cup: clamp(3.75rem, 9vw, 5.5rem);
  --word: clamp(2.2rem, 5.5vw, 3.1rem); /* height of the word pictures */
  --bar: calc(var(--edge) + max(var(--word), var(--cup) * 0.6)); /* the room the header takes */
}

html {
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font-display);
  line-height: 1.5;
}

body {
  position: relative;
  margin: 0;
}

/* Header, on every page */

.site-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: var(--edge) var(--edge) 0;
  /* only the links take clicks: the space between them belongs to the page */
  pointer-events: none;
}

.site-header a {
  position: relative;
  z-index: 0;
  display: block;
  border-radius: 0.75rem;
  pointer-events: auto;
}

.site-header img {
  display: block;
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.site-nav a:hover img {
  transform: translateY(-2px) rotate(-3deg);
}

.home img {
  width: var(--cup);
  height: auto;
}

/* Hover the cup and someone bumps into it: it tips over and its coffee
   flies over the edge. That is a second picture, images/mug-spill.svg, laid
   over the first so the cups line up. Its viewBox (441 612 449 267) reaches
   past mug.svg's (560 654 384 229), hence: left (441 - 560) / 384, top
   (612 - 654) / 229, width 449 / 384. */
.home .spill {
  position: absolute;
  top: -18.341%;
  left: -30.99%;
  width: 116.927%;
  visibility: hidden;
}

/* only with a mouse or trackpad: on a touch screen a tap would knock the cup
   over and leave it lying there */
@media (hover: hover) {
  .home:hover img {
    visibility: hidden;
  }

  .home:hover .spill {
    visibility: visible;
  }
}

.site-nav ul {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 3vw, 1.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav img {
  width: auto;
  height: var(--word);
}

/* The page you are on: a lemon swash behind the bottom of its word. (The
   word pictures put the baseline at 68% of their height.) */
.site-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 47%;
  right: 7%;
  left: 1%;
  height: 25%;
  border-radius: 1rem;
  background: var(--lemon);
  transform: rotate(-2deg);
}

/* Home and shop: one thing in the middle of the screen */

.stage {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  /* the turning sign may reach past the edges of a small screen: cut it
     off there instead of letting the page scroll sideways */
  overflow: clip;
}

/* The studio sign, on the home page and the shop. js/sign.js makes it a
   button that turns the sign over, in 3D on a canvas when it can and in CSS
   (flat) when it can't. It keeps clear of the header and footer, above and
   below. */

.sign {
  position: relative;
  width: min(88vw, (100vh - 2 * var(--bar) - 2rem) * 1.42, 58rem);
  width: min(88vw, (100svh - 2 * var(--bar) - 2rem) * 1.42, 58rem);
  aspect-ratio: 1398 / 983;
  transform: rotate(-2deg);
}

.sign-faces {
  position: relative;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.3, 1.35, 0.5, 1);
}

.sign-faces img {
  display: block;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.sign-faces .sign-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

.sign-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  perspective: 1800px;
}

.sign-button:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 0.5rem;
}

.sign-button[aria-pressed="true"] .sign-faces {
  transform: rotateY(180deg);
}

/* The shop's sign starts on its back ("Coming soon!"), and turns on the same
   way to its front. */
.sign[data-start="back"] .sign-faces {
  transform: rotateY(180deg);
}

.sign[data-start="back"] .sign-button[aria-pressed="true"] .sign-faces {
  transform: rotateY(360deg);
}

/* The 3D version reaches 8% of the sign's width past it on every side
   (MARGIN in js/sign.js), for the corners that swing out as it turns. It is
   ready a moment after the page, and fades in over the pictures, which look
   just the same, with its shadow. */
.sign-canvas {
  position: absolute;
  top: calc(-8% * 1398 / 983);
  left: -8%;
  width: 116%;
  height: calc(100% + 16% * 1398 / 983);
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 0.8rem 1rem rgb(31 50 120 / 20%));
  transition: opacity 0.4s;
}

.sign.is-3d .sign-canvas {
  opacity: 1;
}

.sign.is-3d .sign-faces {
  visibility: hidden;
  transition: visibility 0s 0.4s;
}

/* Footer on the home page: Instagram */

.site-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  padding: 0 var(--edge) var(--edge);
  pointer-events: none;
}

.instagram {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem 0.35rem 0.6rem;
  border-radius: 999px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  pointer-events: auto;
  transition: background-color 0.2s, color 0.2s;
}

.instagram svg {
  width: 1.6rem;
  height: 1.6rem;
}

.instagram:hover {
  background: rgb(255 255 255 / 35%);
  color: var(--violet);
}

.site-header a:focus-visible,
.instagram:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 0.3rem;
}

/* About and work */

.about,
.work {
  max-width: 60rem;
  margin: 0 auto;
  padding: calc(var(--bar) + 2rem) var(--edge) 4rem;
}

/* Page titles (about, work), with a lemon swash under one word, like the
   one under the word of the page you are on */
.title {
  margin: 0 0 clamp(1.5rem, 4vw, 2.5rem);
  color: var(--violet);
  font-size: clamp(1.6rem, 5.4vw, 2.9rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}

.swash {
  position: relative;
  z-index: 0;
  white-space: nowrap;
}

.swash::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 48%;
  right: -0.1em;
  bottom: 10%;
  left: -0.1em;
  border-radius: 1rem;
  background: var(--lemon);
  transform: rotate(-2deg);
}

.photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(0.75rem, 3vw, 2rem);
}

.photos img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: clamp(0.6rem, 1.5vw, 1.1rem);
  box-shadow: 0 0.8rem 1.6rem rgb(31 50 120 / 18%);
}

/* a little wobbly, like the rest of her work */
.photos img:first-child {
  transform: rotate(-1.5deg);
}

.photos img:last-child {
  transform: rotate(1.25deg);
}

.prose {
  max-width: 34rem;
  margin: clamp(2rem, 6vw, 3.25rem) auto 0;
  font-size: clamp(1.05rem, 2.4vw, 1.2rem);
  line-height: 1.6;
}

.prose p {
  margin: 0 0 1em;
}

.prose a {
  color: var(--cobalt);
  font-weight: 700;
  text-underline-offset: 0.2em;
}

/* Work: her cups in a row, then a pair: a stack of them in the sun, and in
   a drawing of hers, which has a white border like a print */

.work-hero,
.pair img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: clamp(0.6rem, 1.5vw, 1.1rem);
  box-shadow: 0 0.8rem 1.6rem rgb(31 50 120 / 18%);
}

.work-hero {
  transform: rotate(-0.75deg);
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: clamp(0.75rem, 3vw, 2rem);
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
}

.pair figure {
  margin: 0;
}

.pair img {
  transform: rotate(1.25deg);
}

.pair .drawing img {
  box-sizing: border-box;
  padding: clamp(0.35rem, 1.3vw, 0.85rem);
  border-radius: 0.25rem;
  background: #fffdf4;
  transform: rotate(-1.5deg);
}

.pair figcaption {
  margin-top: 0.9rem;
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  font-weight: 700;
  text-align: center;
}

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

/* The smallest phones: a smaller cup and words, so the header fits */

@media (max-width: 22rem) {
  :root {
    --cup: 3.25rem;
    --word: 1.9rem;
  }
}

/* Page not found */

.lost {
  align-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}

.lost img {
  width: min(60vw, 16rem);
  height: auto;
}

.lost h1 {
  margin: 1.5rem 0 0.25rem;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  line-height: 1.1;
}

.lost a {
  color: var(--cobalt);
  font-size: 1.15rem;
  font-weight: 700;
  text-underline-offset: 0.2em;
}

/* A gentle sway, only for people who don't mind motion */

@media (prefers-reduced-motion: no-preference) {
  .sign {
    animation: sway 7s ease-in-out infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-2deg);
  }

  50% {
    transform: rotate(1.5deg) translateY(-6px);
  }
}
