:root {
  --page: #eee2d4;
  --paper: #fffdf9;
  --ink: #202522;
  --muted: #6e716b;
  --line: rgba(32, 37, 34, .13);
  --chip: rgba(255, 253, 249, .42);
  --radius: 21px;
  --gap: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --hand: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html { background: var(--page); color: var(--ink); }
body { margin: 0; min-width: 280px; background: var(--page); font-family: var(--sans); }
a { color: inherit; }
button { font: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-shell { width: min(1540px, 100%); margin: 0 auto; padding: 38px clamp(16px, 3vw, 48px) 76px; }
.site-header { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr); gap: 34px; align-items: end; padding: 10px 0 30px; border-bottom: 1px solid var(--line); }
.brand-block { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-mark { position: relative; width: 48px; height: 48px; flex: 0 0 auto; }
.brand-mark span { position: absolute; border-radius: 999px; background: var(--ink); }
.brand-mark span:first-child { width: 30px; height: 30px; left: 0; top: 4px; opacity: .9; }
.brand-mark span:last-child { width: 27px; height: 27px; right: 0; bottom: 2px; background: #c97d68; opacity: .78; }
.brand-block h1 { margin: 0; font: 600 clamp(2.1rem, 4.8vw, 4.4rem)/.92 var(--serif); letter-spacing: -.055em; }
.handwritten { font-family: var(--hand); }
.brand-handwriting { margin: 7px 0 0 4px; font-size: clamp(.95rem, 1.6vw, 1.25rem); transform: rotate(-1.5deg); color: #8a5d4f; }
.intro-block { max-width: 540px; justify-self: end; }
.intro-block p { margin: 0 0 14px; font: 500 clamp(1rem, 1.5vw, 1.25rem)/1.5 var(--serif); }
.intro-block span { color: var(--muted); font-size: .68rem; letter-spacing: .17em; }

.controls { display: flex; align-items: center; gap: 18px; padding: 17px 0 21px; position: sticky; top: 0; z-index: 20; background: rgba(238, 226, 212, .91); backdrop-filter: blur(11px); -webkit-backdrop-filter: blur(11px); }
.filter-scroller { display: flex; flex: 1 1 auto; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.filter-scroller::-webkit-scrollbar { display: none; }
.sort-controls { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.sort-controls > span { color: var(--muted); font-size: .75rem; margin-right: 2px; }
.chip, .tag { border: 1px solid var(--line); border-radius: 999px; background: var(--chip); color: #4d504b; white-space: nowrap; }
.chip { padding: 7px 11px; cursor: pointer; font-size: .75rem; transition: background .16s ease, color .16s ease, border-color .16s ease; }
.chip:hover, .chip:focus-visible { background: rgba(255, 255, 255, .72); outline: none; }
.chip:focus-visible { box-shadow: 0 0 0 2px rgba(32, 37, 34, .28); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: white; }

.project-grid { column-width: clamp(168px, 18vw, 244px); column-gap: var(--gap); }
.project-card-wrap { width: 100%; display: inline-block; margin: 0 0 var(--gap); break-inside: avoid; vertical-align: top; perspective: 1200px; }
.project-card-wrap[hidden] { display: none; }
.size-compact { aspect-ratio: 1 / 1.08; }
.size-standard { aspect-ratio: 4 / 5; }
.size-tall { aspect-ratio: 4 / 5.35; }
.project-card { width: 100%; height: 100%; border-radius: var(--radius); transform-style: preserve-3d; transition: transform .22s ease; }
.project-card__inner { position: relative; width: 100%; height: 100%; border-radius: inherit; transform-style: preserve-3d; transition: transform .56s cubic-bezier(.2, .72, .2, 1); }
.project-card.is-flipped .project-card__inner { transform: rotateY(180deg); }
.project-card__face { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid rgba(255, 255, 255, .3); box-shadow: 0 5px 17px rgba(61, 50, 41, .07); transition: box-shadow .22s ease; }
.project-card__front { visibility: visible; transform: rotateY(0deg); background: #777; color: white; pointer-events: auto; }
.project-card__front--type { background: var(--card-bg, #c77c69); color: var(--ink); }
.project-card__image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.002); transition: transform .42s ease; }
.project-card__shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(16, 18, 17, .79) 0%, rgba(16, 18, 17, .22) 49%, rgba(16, 18, 17, .025) 74%); }
.project-card__front--type .project-card__shade { background: linear-gradient(to top, rgba(255, 255, 255, .11), rgba(255, 255, 255, 0)); }
.project-card__front-copy { position: absolute; inset: auto 16px 15px; z-index: 3; }
.project-card__front-copy h2 { margin: 0 0 5px; font: 650 clamp(1.02rem, 1.7vw, 1.48rem)/1.05 var(--serif); letter-spacing: -.025em; }
.project-card__front-copy h2.handwritten-title { font-family: var(--hand); font-weight: 500; line-height: 1.02; letter-spacing: -.04em; }
.project-card__front-copy p { margin: 0 0 11px; max-width: 24ch; font-size: clamp(.82rem, .1vw, .96rem); line-height: 1.35; color: rgba(255, 255, 255, .92); }
.project-card__front--type .project-card__front-copy p { color: rgba(32, 37, 34, .76); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 3px 7px; font-size: .59rem; line-height: 1.15; background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .22); color: inherit; }
.project-card__front--type .tag { background: rgba(255, 255, 255, .28); border-color: rgba(32, 37, 34, .1); }
.handwritten-note { position: absolute; z-index: 3; top: 18px; left: 17px; max-width: 75%; font: 1.18rem/1.06 var(--hand); transform: rotate(-2.5deg); color: currentColor; opacity: .86; }
.handwritten-note::after { content: ""; display: block; width: 34px; height: 8px; margin: 4px 0 0 6px; border-bottom: 1.5px solid currentColor; border-radius: 50%; transform: rotate(-5deg); opacity: .5; }

.fold-cue { position: absolute; z-index: 5; top: 0; right: 0; width: 25px; height: 25px; pointer-events: none; transition: width .2s ease, height .2s ease; filter: drop-shadow(-3px 4px 4px rgba(26, 28, 27, .14)); }
.fold-cue::before { content: ""; position: absolute; inset: 0; clip-path: polygon(100% 0, 0 0, 100% 100%); background: linear-gradient(225deg, rgba(255, 255, 255, .98) 0 43%, rgba(230, 223, 214, .96) 44% 58%, rgba(255, 255, 255, .16) 59%); }
.flip-trigger { position: absolute; z-index: 4; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; cursor: pointer; border-radius: inherit; }
.flip-trigger:focus-visible { outline: 3px solid rgba(32, 37, 34, .55); outline-offset: -4px; }

.flip-trigger::after { content: "tap over"; position: absolute; top: 10px; right: 30px; display: none; padding: 4px 7px; border: 1px solid rgba(32, 37, 34, .12); border-radius: 999px; background: rgba(255, 253, 249, .82); color: rgba(32, 37, 34, .72); font-size: .58rem; line-height: 1; }

.project-card__back { visibility: hidden; transform: rotateY(180deg); background: var(--paper); color: var(--ink); padding: 18px; display: flex; flex-direction: column; pointer-events: none; cursor: pointer; }
.project-card.is-flipped .project-card__front { visibility: hidden; pointer-events: none; transition: box-shadow .22s ease, visibility 0s linear .28s; }
.project-card.is-flipped .project-card__back { visibility: visible; pointer-events: auto; }
.project-card:not(.is-flipped) .project-card__back { transition: box-shadow .22s ease, visibility 0s linear .28s; }
.project-card__back h2 { margin: 28px 0 11px; font: 600 clamp(1rem, 1.55vw, 1.35rem)/1.05 var(--serif); letter-spacing: -.025em; }
.project-card__back-text { flex: 1 1 auto; min-height: 0; margin: 0; overflow-y: auto; font-size: clamp(.82rem, .1vw, .94rem); line-height: 1.5; color: #51544f; }
.back-close { position: absolute; top: 11px; left: 11px; border: 0; border-radius: 999px; background: transparent; color: #6d706a; padding: 6px; cursor: pointer; font-size: 1rem; line-height: 1; }
.back-close:focus-visible, .open-project:focus-visible { outline: 2px solid rgba(32, 37, 34, .45); outline-offset: 3px; }
.project-card__back-bottom { position: relative; margin-top: auto; padding: 14px 0 24px; }
.tag-list--back { margin-bottom: 0; }
.tag-list--back .tag, .tag-list--article .tag { color: #646761; background: #f5f0e9; border-color: #e5ded4; }
.open-project { position: absolute; inset: 0; display: flex; align-items: flex-end; padding-bottom: 2px; font-size: .86rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; text-decoration: underline; text-underline-offset: 3px; }

.project-page { width: min(820px, 100%); margin: 0 auto; padding: 32px clamp(18px, 4vw, 48px) 72px; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 24px; text-decoration: none; color: var(--muted); font-size: .95rem; font-weight: 600; }
.project-article { background: rgba(255, 253, 249, .68); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; }
.project-article__header { padding: clamp(24px, 4.5vw, 48px); }
.eyebrow { margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: .65rem; }
.project-article h1 { margin: 0 0 18px; font: 600 clamp(2.2rem, 5vw, 4.2rem)/.96 var(--serif); letter-spacing: -.055em; }
.project-article__lead { max-width: 56ch; margin: 0 0 22px; font: 500 clamp(1rem, 1.8vw, 1.2rem)/1.55 var(--serif); }
.project-hero { display: block; width: 100%; max-height: 460px; object-fit: cover; }
.project-article__back-link { margin: 14px clamp(24px, 4.5vw, 48px) 0; }
.prose { padding: clamp(24px, 4.5vw, 48px); max-width: 68ch; font: 1rem/1.75 var(--sans); }
.project-article__back-link--bottom { margin-top: 0; margin-bottom: clamp(24px, 4.5vw, 48px); }
.prose h2, .prose h3 { font-family: var(--serif); letter-spacing: -.02em; }
.prose a { text-underline-offset: 3px; }

@media (hover: hover) and (pointer: fine) {
  .project-card-wrap:hover .project-card:not(.is-flipped) { transform: translateY(-4px) rotateX(.8deg) rotateY(-1.1deg); }
  .project-card-wrap:hover .project-card:not(.is-flipped) .project-card__front { box-shadow: 0 12px 28px rgba(62, 50, 40, .12); }
  .project-card-wrap:hover .project-card:not(.is-flipped) .project-card__image { transform: scale(1.025); }
  .project-card-wrap:hover .project-card:not(.is-flipped) .fold-cue { width: 36px; height: 36px; }
}

@media (max-width: 700px) {
  .site-shell { padding-top: 24px; }
  .site-header { grid-template-columns: 1fr; gap: 18px; padding-bottom: 22px; }
  .intro-block { justify-self: start; }
  .controls { align-items: stretch; flex-direction: column; gap: 9px; padding: 12px 0 15px; }
  .sort-controls { overflow-x: auto; padding-bottom: 1px; }
  .project-grid { column-count: 2; column-width: auto; column-gap: 12px; }
  .project-card-wrap { margin-bottom: 12px; }
  .project-card__front-copy { inset: auto 11px 11px; }
  .project-card__front-copy h2 { font-size: clamp(.92rem, 4vw, 1.15rem); }
  .project-card__front-copy p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .82rem; }
  .tag-list--front { gap: 3px; }
  .tag-list--front .tag { padding: 2px 5px; font-size: .52rem; }
  .project-card__back { padding: 12px; }
  .project-card__back h2 { margin-top: 25px; font-size: .98rem; }
  .project-card__back-text { font-size: .76rem; }
  .tag-list--back { gap: 3px; margin-bottom: 0; }
  .tag-list--back .tag { padding: 2px 5px; font-size: .5rem; }
  .open-project { font-size: .78rem; }
  .handwritten-note { font-size: .92rem; top: 13px; left: 12px; }
  .flip-trigger::after { display: block; }
}

@media (max-width: 480px) {
  .project-grid { column-count: 1; }
  .project-card__front-copy p, .project-card__back-text { font-size: .82rem; }
}

@media (max-width: 360px) {
  .site-shell { padding-left: 10px; padding-right: 10px; }
  .project-card-wrap { margin-bottom: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .project-card-wrap:hover .project-card:not(.is-flipped) { transform: none; }
}
