html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

.hero-grid {
  background-image:
    linear-gradient(to right, rgba(110, 123, 92, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(110, 123, 92, 0.12) 1px, transparent 1px);
  background-size: 40px 40px;
}

::selection {
  background: #4F5A40;
  color: #FBF8F1;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid #7C4530;
  outline-offset: 2px;
  border-radius: 2px;
}

.lang-flag svg {
  transform-origin: 50% 50%;
  transition: transform 0.25s ease;
}

.lang-flag:hover svg,
.lang-flag:focus-visible svg {
  transform: rotate(-6deg);
}

@media (prefers-reduced-motion: reduce) {
  .lang-flag svg {
    transition: none;
  }
}

/* Pencil-drawn buttons: the outline is always there, the hatching fills in on hover. */
.sketch-btn-hatch {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sketch-btn-filled .sketch-btn-hatch {
  opacity: 0.75;
}

.sketch-btn:hover .sketch-btn-hatch,
.sketch-btn:focus-visible .sketch-btn-hatch {
  opacity: 1;
}

/* Menus: a sheet of paper under the header. */
summary {
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.menu-paper {
  background: #FBF8F1;
  box-shadow: 0 1px 2px rgba(43, 46, 34, 0.12), 3px 8px 14px -5px rgba(43, 46, 34, 0.3);
}

/* Blog board: square post-its and instant photos. */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px 24px;
  align-items: start;
  margin-top: 28px;
}

/* Without this a long photo caption widens its whole column. */
.board > * {
  min-width: 0;
}

.board a {
  color: inherit;
  text-decoration: none;
}

.board .tilt-0 { transform: rotate(-2.4deg); }
.board .tilt-1 { transform: rotate(1.7deg) translateY(5px); }
.board .tilt-2 { transform: rotate(-1.1deg) translateY(-3px); }
.board .tilt-3 { transform: rotate(2.6deg) translateY(3px); }
.board .tilt-4 { transform: rotate(-1.8deg) translateY(4px); }

.board .pi {
  position: relative;
  display: block;
  aspect-ratio: 1;
  filter: drop-shadow(0 1px 1px rgba(43, 46, 34, 0.1)) drop-shadow(2px 6px 6px rgba(43, 46, 34, 0.2));
  transition: transform 0.2s ease;
}

.board .n {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 15px 15px 16px;
  overflow: hidden;
}

.board > :nth-child(3n+1) .n { background: #FBF8F1; --flap: #E9E4D6; }
.board > :nth-child(3n+2) .n { background: #DDE3CC; --flap: #C2CBAB; }
.board > :nth-child(3n+3) .n { background: #D6DEEE; --flap: #B7C3DD; }

.board .d {
  display: block;
  font: 500 12px 'Space Grotesk', sans-serif;
  color: rgba(43, 46, 34, 0.62);
}

.board .t {
  display: -webkit-box;
  flex: none;
  margin: 7px 0 8px;
  overflow: hidden;
  font: 700 26px/1.08 'Caveat', cursive;
  color: #2B2E22;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.board .x {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.3;
  color: rgba(43, 46, 34, 0.75);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* Folded corners: the corner has turned over onto the note. */
.ear-r .n { --e: 30px; clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--e)), calc(100% - var(--e)) 100%, 0 100%); }
.ear-r .n::after { content: ""; position: absolute; right: 0; bottom: 0; width: var(--e); height: var(--e); background: linear-gradient(315deg, transparent 50%, var(--flap) 50%); box-shadow: -2px -2px 4px rgba(43, 46, 34, 0.13); }
.ear-l .n { --e: 24px; clip-path: polygon(0 0, 100% 0, 100% 100%, var(--e) 100%, 0 calc(100% - var(--e))); }
.ear-l .n::after { content: ""; position: absolute; left: 0; bottom: 0; width: var(--e); height: var(--e); background: linear-gradient(45deg, transparent 50%, var(--flap) 50%); box-shadow: 2px -2px 4px rgba(43, 46, 34, 0.13); }
.ear-tr .n { --e: 28px; clip-path: polygon(0 0, calc(100% - var(--e)) 0, 100% var(--e), 100% 100%, 0 100%); }
.ear-tr .n::after { content: ""; position: absolute; right: 0; top: 0; width: var(--e); height: var(--e); background: linear-gradient(225deg, transparent 50%, var(--flap) 50%); box-shadow: -2px 2px 4px rgba(43, 46, 34, 0.13); }
.ear-tl .n { --e: 24px; padding-top: 27px; clip-path: polygon(var(--e) 0, 100% 0, 100% 100%, 0 100%, 0 var(--e)); }
.ear-tl .n::after { content: ""; position: absolute; left: 0; top: 0; width: var(--e); height: var(--e); background: linear-gradient(135deg, transparent 50%, var(--flap) 50%); box-shadow: 2px 2px 4px rgba(43, 46, 34, 0.13); }

/* Lifted corners: the note has come unstuck and curls off the page. */
.lift-r .n { border-bottom-right-radius: 58% 11px; }
.lift-r .n::after { content: ""; position: absolute; right: 0; bottom: 0; width: 62%; height: 36%; background: linear-gradient(340deg, rgba(43, 46, 34, 0.13), transparent 58%); pointer-events: none; }
.lift-r::before { content: ""; position: absolute; right: 7px; bottom: 7px; width: 50%; height: 15px; background: rgba(43, 46, 34, 0.42); filter: blur(6px); transform: rotate(5deg) translateY(9px); }
.lift-l .n { border-bottom-left-radius: 52% 10px; }
.lift-l .n::after { content: ""; position: absolute; left: 0; bottom: 0; width: 56%; height: 34%; background: linear-gradient(20deg, rgba(43, 46, 34, 0.12), transparent 58%); pointer-events: none; }
.lift-l::before { content: ""; position: absolute; left: 7px; bottom: 7px; width: 46%; height: 14px; background: rgba(43, 46, 34, 0.4); filter: blur(6px); transform: rotate(-5deg) translateY(9px); }
.lift-tr .n { border-top-right-radius: 58% 11px; }
.lift-tr .n::after { content: ""; position: absolute; right: 0; top: 0; width: 62%; height: 34%; background: linear-gradient(200deg, rgba(43, 46, 34, 0.12), transparent 58%); pointer-events: none; }
.lift-tr::before { content: ""; position: absolute; right: 7px; top: 7px; width: 50%; height: 14px; background: rgba(43, 46, 34, 0.3); filter: blur(6px); transform: rotate(-5deg) translateY(-8px); }
.lift-tl .n { border-top-left-radius: 52% 10px; }
.lift-tl .n::after { content: ""; position: absolute; left: 0; top: 0; width: 56%; height: 34%; background: linear-gradient(160deg, rgba(43, 46, 34, 0.11), transparent 58%); pointer-events: none; }
.lift-tl::before { content: ""; position: absolute; left: 7px; top: 7px; width: 46%; height: 14px; background: rgba(43, 46, 34, 0.3); filter: blur(6px); transform: rotate(5deg) translateY(-8px); }

/* Instant photo on the board, turning over to show what's written on the back. */
.board .flip {
  display: block;
  outline-offset: 6px;
  perspective: 900px;
  transition: transform 0.3s ease;
}

.turn {
  position: relative;
  display: block;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.1, 0.2, 1);
}

.face {
  display: block;
  background: #FFFEFA;
  box-shadow: 0 1px 2px rgba(43, 46, 34, 0.14), 3px 8px 14px -5px rgba(43, 46, 34, 0.3);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.front {
  padding: 9px 9px 4px;
}

.back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 15px;
  transform: rotateY(180deg);
}

.face .img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(43, 46, 34, 0.08);
}

.face .cap {
  display: block;
  padding: 6px 0 5px;
  overflow: hidden;
  font: 700 20px/1.1 'Caveat', cursive;
  color: #2B2E22;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.face .go {
  margin-top: auto;
  font: 500 12px 'Space Grotesk', sans-serif;
  color: #1B3272;
}

.board .flip:focus-visible { transform: rotate(0); }
.board .flip:focus-visible .turn { transform: rotateY(180deg); }

/* Only with a real pointer: a tap on a phone goes straight to the post. */
@media (hover: hover) {
  .board .pi:hover { transform: rotate(0) translateY(-3px); }
  .board .flip:hover { transform: rotate(0); }
  .board .flip:hover .turn { transform: rotateY(180deg); }
}

@media (prefers-reduced-motion: reduce) {
  .board .pi, .board .flip { transition: none; }
  .turn { transition: none; }
  .face { -webkit-backface-visibility: visible; backface-visibility: visible; }
  .back { opacity: 0; transform: none; transition: opacity 0.2s ease; }
  .board .flip:hover .turn, .board .flip:focus-visible .turn { transform: none; }
  .board .flip:hover .back, .board .flip:focus-visible .back { opacity: 1; }
}

@media (max-width: 639px) {
  .board { grid-template-columns: repeat(2, 1fr); gap: 20px 16px; }
  .board .n { padding: 11px; }
  .board .t { font-size: 22px; }
  .board .x { font-size: 13px; }
}

/* Post and page text. */
.article {
  font-size: 17px;
  line-height: 1.625;
}

.article::after {
  content: "";
  display: block;
  clear: both;
}

.article > * + * { margin-top: 1.25rem; }
.article h2, .article h3 { clear: both; font-family: 'Space Grotesk', sans-serif; font-weight: 600; line-height: 1.3; }
.article h2 { margin-top: 2.5rem; font-size: 1.375rem; }
.article h3 { margin-top: 2rem; font-size: 1.125rem; }
.article a { text-decoration: underline; text-underline-offset: 2px; }
.article a:hover { color: #1B3272; }
.article ul { padding-left: 1.25rem; list-style: disc; }
.article ol { padding-left: 1.25rem; list-style: decimal; }
.article blockquote { padding-left: 0.875rem; border-left: 2px solid #6E7B5C; font: 500 1.625rem/1.2 'Caveat', cursive; color: #4F5A40; }

/* Instant photos in the text. Never alone at full width. */
.photo {
  width: 190px;
  padding: 10px 10px 8px;
  background: #FFFEFA;
  box-shadow: 0 1px 2px rgba(43, 46, 34, 0.14), 3px 8px 14px -5px rgba(43, 46, 34, 0.3);
  transform: rotate(2.2deg);
  transition: transform 0.2s ease;
}

.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.photo figcaption {
  padding-top: 7px;
  font: 700 20px/1.1 'Caveat', cursive;
  color: #2B2E22;
  text-align: center;
}

/* Portrait in the About section: no caption, so the frame keeps its thick bottom edge itself. */
.photo--portrait {
  width: 206px;
  padding-bottom: 34px;
}

@media (min-width: 640px) {
  .photo--portrait { width: 100%; }
}

/* The picture has empty space around the person, so zoom in on the head and shoulders. */
.portrait-crop {
  display: block;
  overflow: hidden;
}

.portrait-crop img {
  transform: scale(1.25);
  transform-origin: 53% 14%;
}

.article > .photo {
  float: right;
  margin: 6px 0 14px 28px;
}

.article > .photo + * { margin-top: 0; }

.photo-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  clear: both;
}

.photo-row .photo:nth-child(odd) { transform: rotate(-1.6deg); }

.diagram {
  clear: both;
}

.diagram img {
  display: block;
  width: 100%;
  height: auto;
}

.diagram figcaption {
  margin-top: 6px;
  font-size: 13px;
  color: #6B6F5C;
}

@media (hover: hover) {
  .photo:hover { transform: rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
  .photo { transition: none; }
}

@media (max-width: 639px) {
  .article > .photo { float: none; width: 220px; margin: 0 auto 1.5rem; }
}
