:root {
  --paper: #f2efe8;
  --ink: #202321;
  --muted: #62655e;
  --accent: #354795;
  --serif: 'Bodoni Moda', 'Baskerville', serif;
  --sans: 'Space Grotesk', 'Helvetica Neue', sans-serif;
  --gutter: clamp(24px, 5vw, 88px);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
a, button { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, .cv-pages:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}
::selection { background: #ccd1ef; }
[hidden] { display: none !important; }

.hero {
  height: 100svh;
  min-height: 440px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.optical-field {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper);
}
.optical-field::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--paper), transparent 18%),
    linear-gradient(90deg, rgba(242,239,232,.2), transparent 66%),
    linear-gradient(0deg, var(--paper), transparent 27%);
}
#membrane {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.3s;
}
.optical-field.is-ready #membrane { opacity: 1; }
.field-fallback {
  position: absolute;
  width: 48vw;
  height: 48vw;
  max-width: 800px;
  max-height: 800px;
  right: 0;
  top: 7%;
  border-radius: 49% 51% 64% 36% / 62% 34% 66% 38%;
  border: 52px solid #a7b2c2;
  box-shadow: inset 17px -7px 35px #d2afd0, 7px 14px 25px #d4ccc1;
  transform: rotate(-25deg);
  opacity: .7;
}
.optical-field.is-ready .field-fallback { display: none; }
.donut-footer {
  position: absolute;
  inset: auto var(--gutter) max(26px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.donut-footer p { margin: 0; }
.donut-footer a { flex-shrink: 0; color: var(--ink); }
.donut-footer a:hover { text-decoration: underline; text-underline-offset: 5px; }
h1 {
  position: absolute;
  left: var(--gutter);
  bottom: 19%;
  margin: 0;
  font: 500 clamp(110px, 13.8vw, 220px)/.78 var(--serif);
  letter-spacing: -.065em;
}
.controls {
  position: absolute;
  inset: auto var(--gutter) 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.controls a {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  padding: 8px 0;
  background: none;
  border: 0;
  font-size: 12px;
}
.controls a { font-weight: 500; }
.controls a:hover, .cv-actions a:hover { text-decoration: underline; text-underline-offset: 5px; }

/* The document stays out of the composition until requested. */
dialog {
  width: min(940px, calc(100% - 64px));
  height: min(1100px, calc(100svh - 64px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid #c8c9bf;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 100px #20232122;
  overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #f2efe8b8; backdrop-filter: blur(12px); }
.cv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid #c8c9bf;
}
.cv-header h2 { margin: 0; font: 500 14px/1.5 var(--sans); }
.cv-header p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.cv-actions { display: flex; align-items: center; gap: 24px; }
.cv-actions a { font-size: 12px; white-space: nowrap; }
.cv-actions button { width: 44px; height: 44px; padding: 0; border: 0; background: none; font-size: 28px; font-weight: 400; }
.cv-pages {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px;
  scrollbar-color: #999b91 transparent;
}
.cv-pages img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 24px;
  background: white;
  box-shadow: 0 1px 6px #20232112;
}
.cv-pages img:last-child { margin-bottom: 0; }

@media (max-width: 700px) {
  h1 { font-size: clamp(100px, 27vw, 178px); bottom: 22%; }
  .controls { bottom: max(20px, env(safe-area-inset-bottom)); }
  .field-fallback { width: 66vw; height: 66vw; top: 12%; right: -8%; border-width: 28px; }
  dialog { width: 100%; height: 100svh; margin: 0; border: 0; }
  .cv-header { padding: 12px 16px; gap: 12px; }
  .cv-actions { gap: 12px; }
  .cv-pages { padding: 12px 8px; }
}
@media (max-height: 500px) and (min-width: 701px) {
  .hero { min-height: 320px; }
  h1 { font-size: 29vh; bottom: 25%; }
  .controls { bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  #membrane { transition: none; }
}
