/* The venetian blind button: a deep petrol pill on a white page, with a small window and its venetian blind in the round
   left end. The slats are elements turned in 3D by script.js; the stripes of light on the pill and the cord with its
   wooden acorn are drawn on two canvases (their colours come from here). */
:root {
  --page: #ffffff;          /* the page */
  --wall: #18302f;          /* the pill, at its top: the wall of the room */
  --wall-deep: #0d1b1c;     /* the pill, at its foot */
  --ink: #f5ecdc;           /* the words */
  --sun: #ffcb7d;           /* the light of the day, in the stripes on the pill */
  --sky-top: #fff1cf;       /* the day behind the slats, at the top of the window */
  --sky: #fbcf8f;           /* the day, in the middle */
  --sky-low: #f1a564;       /* the day, at the sill */
  --leaf: #6f7a4c;          /* the branch outside the window */
  --slat: #ece3d1;          /* the slats */
  --slat-lit: #fffaf0;      /* the slats, along the edge that catches the light */
  --slat-deep: #b9ad96;     /* the slats, along their lower edge */
  --frame: #efe5d2;         /* the frame of the window, the rail and the ladder tapes */
  --cord: #eadfc8;          /* the cord */
  --acorn: #b9834a;         /* the wooden acorn at the end of the cord */
  --focus: #18302f;         /* the ring of the keyboard's focus */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--wall);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 72px 16px;
}

.blind {
  display: grid;
  justify-items: center;
}

/* ---------------------------------------------------------------- the pill */
.blind__btn {
  position: relative;
  display: block;
  /* the script sets the width from the words; this is the width before it does */
  width: 206px;
  max-width: calc(100vw - 32px);
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.blind__btn[aria-disabled='true'] {
  cursor: progress;
}

/* the fill is a layer of its own, so it can swell past the pill with a bounce without moving anything */
.blind__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background:
    radial-gradient(80% 160% at 12% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(180deg, var(--wall), var(--wall-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(13, 27, 28, 0.22),
    0 14px 28px -14px rgba(13, 27, 28, 0.62);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

.blind__btn:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 5px;
}

html[data-using='pointer'] .blind__btn:focus-visible {
  outline: none;
}

/* two clipped layers the size of the pill: under the words the window and the warmth it spills, over them the light
   and the cord */
.blind__under,
.blind__over {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
}

.blind__over {
  z-index: 2;
}

/* the warmth the open window spills on the wall round it */
.blind__glow {
  position: absolute;
  left: -30px;
  top: -40px;
  width: 210px;
  height: 140px;
  background: radial-gradient(closest-side, rgba(255, 203, 125, 0.2), rgba(255, 203, 125, 0.07) 55%, transparent);
  opacity: 0;
}

/* ---------------------------------------------------------------- the window */
.blind__window {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 66px;
  height: 44px;
  border-radius: 22px 7px 7px 22px;
  overflow: hidden;
  /* the slats turn in 3D with this depth, seen from the middle of the window */
  perspective: 200px;
  perspective-origin: 50% 50%;
  background: var(--wall-deep);
}

.blind__sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--sky-top), var(--sky) 52%, var(--sky-low));
}

/* the sun is somewhere up to the left: a broad soft brightness, not a disc */
.blind__sun {
  position: absolute;
  left: -26px;
  top: -30px;
  width: 80px;
  height: 70px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 249, 230, 0.5) 45%, transparent);
}

.blind__branch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: 100% 0%;
}

.blind__branch path {
  fill: var(--leaf);
  opacity: 0.5;
}

.blind__branch > path {
  fill: none;
  stroke: var(--leaf);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.blind__slats {
  position: absolute;
  inset: 0;
}

.blind__slat {
  position: absolute;
  left: -2px;
  right: -2px;
  /* top and height come from the script */
  border-radius: 1px;
  background: linear-gradient(180deg, var(--slat-lit) 0%, var(--slat) 22%, var(--slat) 64%, var(--slat-deep) 100%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  transform-origin: 50% 50%;
  backface-visibility: visible;
  will-change: transform;
}

/* the shade of a slat: the more it turns away from the room, the less light its face catches */
.blind__slat::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #1a1408;
  opacity: var(--shade, 0.2);
}

/* the two ladder tapes the slats hang in, in front of them */
.blind__tapes {
  position: absolute;
  inset: 4px 0 0;
  background:
    linear-gradient(90deg, transparent 0 calc(32% - 0.5px), var(--frame) 0 calc(32% + 0.5px), transparent 0 calc(72% - 0.5px), var(--frame) 0 calc(72% + 0.5px), transparent 0);
  opacity: 0.55;
}

.blind__rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(180deg, #fffaf0, var(--frame) 60%, #bfb39b);
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.35);
}

/* the frame round the opening, and the shadow of its reveal */
.blind__window::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1.5px var(--frame),
    inset 0 0 0 2.5px rgba(0, 0, 0, 0.25),
    inset 2px 3px 5px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the light and the cord */
.blind__light {
  position: absolute;
  left: 0;
  top: 0;
  width: 420px;
  height: 60px;
  mix-blend-mode: screen;
}

.blind__cord {
  position: absolute;
  left: 70px;
  top: 0;
  width: 28px;
  height: 60px;
}

/* ---------------------------------------------------------------- the words */
.blind__label {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 98px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  pointer-events: none;
}

/* the words widen on the typeface's width axis under the pointer; the wide copy, invisible and zero high, holds their
   room, so the pill never changes size */
.blind__word {
  display: inline-grid;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.008em;
  line-height: 1;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.9, 0.45, 1), font-weight 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.blind__word::before {
  content: attr(data-wide);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 116%;
  font-weight: 680;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .blind__btn:not([aria-disabled='true']):hover .blind__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 1px 2px rgba(13, 27, 28, 0.22),
      0 18px 32px -14px rgba(13, 27, 28, 0.68);
  }

  .blind__btn:not([aria-disabled='true']):hover .blind__word {
    font-stretch: 116%;
    font-weight: 680;
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .blind__btn:focus-visible .blind__word {
  font-stretch: 116%;
  font-weight: 680;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no widening */
@media (prefers-reduced-motion: reduce) {
  .blind__fill,
  .blind__word {
    transition: box-shadow 0.3s ease, filter 0.3s ease;
  }

  html[data-using='keys'] .blind__btn:focus-visible .blind__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .blind__btn:not([aria-disabled='true']):hover .blind__fill {
    inset: 0;
    filter: brightness(1.25);
  }

  .blind__btn:not([aria-disabled='true']):hover .blind__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}
