:root {
  --ma-ink: #211a14;
  --ma-paper: #efe1c3;
  --ma-paper-edge: #d0b984;
  --ma-gold: #d4b66f;
  --ma-night: #020a11;
}

html.ma-page {
  background: var(--ma-night);
}

body.ma-body {
  min-width: 320px;
  margin: 0;
  background: var(--ma-night);
  color: #f4eee2;
}

body.ma-body:not(.ma-document-open) {
  overflow: hidden;
}

.ma-back {
  position: fixed;
  z-index: 96;
  top: 136px;
  left: max(18px, calc((100vw - 680px) / 2));
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid rgba(235, 213, 163, .34);
  border-radius: 999px;
  background: rgba(2, 12, 20, .68);
  color: #f6eddc;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font: 650 10px/1 var(--sans, Inter, sans-serif);
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: transform .28s ease, border-color .28s ease, background-color .28s ease, opacity .25s ease;
}

.ma-back span {
  color: var(--ma-gold);
  font-size: 16px;
  transition: transform .28s ease;
}

.ma-back:hover,
.ma-back:focus-visible {
  border-color: rgba(235, 213, 163, .72);
  background: rgba(15, 33, 47, .9);
  transform: translateX(-3px);
}

.ma-back:hover span,
.ma-back:focus-visible span {
  transform: translateX(-2px);
}

.site-header.scrolled + .ma-back {
  top: 86px;
}

@media (min-width: 981px) {
  body.ma-body .site-header {
    width: min(680px, calc(100% - 40px));
    height: 64px;
    grid-template-columns: 1fr auto;
    gap: 14px;
    padding-inline: 14px;
    border-radius: 20px 0 20px 0;
  }

  body.ma-body .site-header .navbar-medallion {
    width: 38px;
    height: 38px;
  }

  body.ma-body .site-header .brand-copy small {
    display: none;
  }

  body.ma-body .desktop-nav {
    display: none;
  }

}

.ma-experience {
  position: relative;
  min-height: calc(100svh - 34px);
  isolation: isolate;
  background: #020a11;
}

.ma-scene {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(100svh - 34px);
  min-height: 620px;
  overflow: hidden;
  background: #020a11;
}

.ma-scene::before {
  content: "";
  position: absolute;
  inset: -1%;
  background: url("../images/historical/marie-antoinette/hamilton-1600.webp") center 48% / cover no-repeat;
  filter: saturate(.94) brightness(.92);
  transform: scale(1.02);
  transition: filter 1.25s cubic-bezier(.22, 1, .36, 1), transform 1.25s cubic-bezier(.22, 1, .36, 1);
}

.ma-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(2, 8, 13, .04), transparent 48%, rgba(2, 8, 13, .08) 63%, rgba(2, 8, 13, .58));
  transition: background 1.1s ease, opacity 1.1s ease;
}

.ma-painting {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 0;
  transform-origin: 50% 48%;
  transition: transform 1.35s cubic-bezier(.16, 1, .3, 1), filter 1.1s ease, opacity 1.1s ease;
}

.ma-painting img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center 48%;
  box-shadow: none;
}

.ma-intro {
  position: absolute;
  inset: auto 0 clamp(34px, 6vh, 72px);
  z-index: 4;
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  text-align: center;
  text-shadow: 0 3px 22px rgba(0, 0, 0, .9);
  transition: opacity .7s ease, transform .9s cubic-bezier(.22, 1, .36, 1);
}

.ma-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
  color: #ead39b;
  font: 600 10px/1 var(--sans, Inter, sans-serif);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.ma-eyebrow::before,
.ma-eyebrow::after {
  content: "";
  width: 30px;
  height: 1px;
  background: currentColor;
  opacity: .6;
}

.ma-intro h1 {
  max-width: 800px;
  margin: 0 auto 12px;
  color: #fffaf0;
  font: 500 clamp(44px, 7vw, 92px)/.9 var(--serif, Georgia, serif);
  letter-spacing: -.035em;
}

.ma-intro p {
  max-width: 640px;
  margin: 0 auto 25px;
  color: #e2ddd4;
  font: 400 clamp(14px, 1.5vw, 17px)/1.65 var(--sans, Inter, sans-serif);
}

.ma-open,
.ma-close {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--sans, Inter, sans-serif);
}

.ma-open {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 50px;
  padding: 0 25px;
  border: 1px solid rgba(234, 211, 155, .72);
  border-radius: 999px;
  background: rgba(2, 12, 20, .72);
  color: #fff6df;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .3);
  backdrop-filter: blur(12px);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  transition: transform .3s ease, background-color .3s ease, color .3s ease;
}

.ma-open::after {
  content: "→";
  color: var(--ma-gold);
  font-size: 16px;
  transition: transform .3s ease;
}

.ma-open:hover,
.ma-open:focus-visible {
  background: #d8bc79;
  color: #07131c;
  transform: translateY(-2px);
}

.ma-open:hover::after,
.ma-open:focus-visible::after {
  color: #07131c;
  transform: translateX(4px);
}

.ma-credit {
  position: absolute;
  right: max(18px, 3vw);
  bottom: 18px;
  z-index: 4;
  color: rgba(239, 232, 220, .63);
  font: 500 9px/1.45 var(--sans, Inter, sans-serif);
  letter-spacing: .06em;
  text-align: right;
  text-transform: uppercase;
  transition: opacity .7s ease;
}

.ma-scroll-hint {
  display: none;
}

body.ma-document-open .ma-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  height: 100svh;
  min-height: 0;
}

body.ma-document-open .ma-scene::before {
  filter: saturate(.78) brightness(.62);
  transform: scale(1.04);
}

body.ma-document-open .ma-scene::after {
  background: rgba(1, 7, 12, .4);
}

body.ma-document-open .ma-painting {
  filter: brightness(.78) saturate(.86);
  opacity: .96;
  transform: scale(.94) translateY(-1vh);
}

body.ma-document-open .ma-intro,
body.ma-document-open .ma-credit {
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
}

.ma-document {
  position: relative;
  z-index: 5;
  display: none;
  width: 100%;
  min-height: 100svh;
  padding: clamp(132px, 16vh, 190px) 20px 90px;
}

body.ma-document-open .ma-document {
  display: block;
  animation: ma-document-reveal 1.05s .32s both cubic-bezier(.16, 1, .3, 1);
}

@keyframes ma-document-reveal {
  from { opacity: 0; transform: translateY(44px); }
  to { opacity: 1; transform: translateY(0); }
}

.ma-close {
  position: fixed;
  z-index: 115;
  top: clamp(86px, 10vh, 112px);
  right: max(18px, 3vw);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(235, 213, 163, .32);
  border-radius: 999px;
  background: rgba(2, 12, 20, .76);
  color: #efe5d4;
  backdrop-filter: blur(12px);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: background-color .25s ease, border-color .25s ease;
}

.ma-close:hover,
.ma-close:focus-visible {
  border-color: rgba(235, 213, 163, .68);
  background: rgba(23, 38, 50, .92);
}

.ma-letter-wrap {
  width: min(820px, 100%);
  margin: 0 auto;
}

.ma-context {
  width: min(700px, calc(100% - 24px));
  margin: 0 auto 28px;
  color: #d8d2c7;
  text-align: center;
}

.ma-context .ma-eyebrow {
  margin-bottom: 16px;
}

.ma-context h2 {
  margin: 0 0 15px;
  color: #fff8e9;
  font: 500 clamp(38px, 6vw, 66px)/.94 var(--serif, Georgia, serif);
  letter-spacing: -.025em;
}

.ma-context p {
  margin: 0 auto;
  max-width: 610px;
  font: 400 14px/1.75 var(--sans, Inter, sans-serif);
}

.ma-letter {
  position: relative;
  padding: clamp(42px, 7vw, 78px) clamp(28px, 8vw, 86px) clamp(54px, 8vw, 92px);
  border: 1px solid rgba(99, 68, 30, .28);
  background:
    radial-gradient(circle at 18% 9%, rgba(255, 255, 255, .28), transparent 25%),
    radial-gradient(circle at 88% 82%, rgba(117, 75, 28, .07), transparent 30%),
    repeating-linear-gradient(0deg, rgba(82, 50, 19, .025) 0 1px, transparent 1px 4px),
    var(--ma-paper);
  color: var(--ma-ink);
  box-shadow: 0 42px 130px rgba(0, 0, 0, .45), inset 0 0 70px rgba(109, 72, 29, .08);
}

.ma-letter::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(96, 67, 31, .18);
  pointer-events: none;
}

.ma-letter-heading {
  position: relative;
  z-index: 1;
  margin-bottom: 38px;
  text-align: center;
}

.ma-letter-heading span {
  color: #755326;
  font: 700 9px/1 var(--sans, Inter, sans-serif);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.ma-letter-heading h3 {
  margin: 13px 0 4px;
  font: 600 clamp(31px, 5vw, 48px)/1 var(--serif, Georgia, serif);
}

.ma-letter-heading p {
  margin: 0;
  color: #6f5739;
  font: italic 17px/1.5 var(--serif, Georgia, serif);
}

.ma-letter-text {
  position: relative;
  z-index: 1;
  font: 500 clamp(18px, 2.1vw, 22px)/1.82 var(--serif, Georgia, serif);
  hanging-punctuation: first last;
}

.ma-letter-text p {
  margin: 0 0 1.35em;
}

.ma-letter-text p:first-child::first-letter {
  float: left;
  margin: .08em .12em 0 0;
  color: #8b642c;
  font-size: 4.1em;
  font-weight: 600;
  line-height: .72;
}

.ma-letter-signoff {
  margin-top: 32px;
  padding-top: 23px;
  border-top: 1px solid rgba(91, 60, 24, .25);
  color: #6e4d24;
  font: italic 600 17px/1.6 var(--serif, Georgia, serif);
  text-align: right;
}

.ma-notes {
  width: min(820px, 100%);
  margin: 30px auto 0;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 1px;
  border: 1px solid rgba(214, 182, 111, .18);
  background: rgba(214, 182, 111, .16);
}

.ma-note {
  padding: 26px;
  background: rgba(3, 19, 31, .87);
  backdrop-filter: blur(14px);
}

.ma-note span {
  color: #d8b966;
  font: 700 9px/1 var(--sans, Inter, sans-serif);
  letter-spacing: .16em;
  text-transform: uppercase;
}

.ma-note h3 {
  margin: 12px 0 9px;
  color: #fff4df;
  font: 600 27px/1.05 var(--serif, Georgia, serif);
}

.ma-note p,
.ma-note li {
  color: #c9c5be;
  font: 400 12px/1.7 var(--sans, Inter, sans-serif);
}

.ma-note ul {
  margin: 12px 0 0;
  padding-left: 17px;
}

.ma-note a {
  color: #f0dca8;
  text-decoration: underline;
  text-decoration-color: rgba(240, 220, 168, .35);
  text-underline-offset: 3px;
}

.ma-return {
  display: flex;
  justify-content: center;
  margin-top: 34px;
}

.ma-return a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 18px;
  border: 1px solid rgba(235, 213, 163, .27);
  border-radius: 999px;
  color: #ede2cd;
  font: 600 10px/1 var(--sans, Inter, sans-serif);
  letter-spacing: .08em;
  text-transform: uppercase;
}

html[data-theme="night"] .ma-letter {
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 255, 255, .04), transparent 27%),
    repeating-linear-gradient(0deg, rgba(229, 205, 157, .018) 0 1px, transparent 1px 4px),
    #13202a;
  border-color: rgba(212, 182, 111, .24);
  color: #eee4d3;
  box-shadow: 0 42px 130px rgba(0, 0, 0, .62), inset 0 0 80px rgba(0, 0, 0, .16);
}

html[data-theme="night"] .ma-letter::before {
  border-color: rgba(212, 182, 111, .18);
}

html[data-theme="night"] .ma-letter-heading span,
html[data-theme="night"] .ma-letter-heading p,
html[data-theme="night"] .ma-letter-signoff,
html[data-theme="night"] .ma-letter-text p:first-child::first-letter {
  color: #d7ba74;
}

@media (max-width: 760px) {
  .ma-back {
    top: 116px;
    left: 12px;
    min-height: 38px;
    padding-inline: 13px;
    font-size: 9px;
  }

  .site-header.scrolled + .ma-back {
    top: 80px;
  }

  .ma-experience,
  .ma-scene {
    min-height: calc(100svh - 32px);
    height: calc(100svh - 32px);
  }

  .ma-painting {
    padding: 0;
  }

  .ma-painting img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: 64% center;
    box-shadow: none;
  }

  .ma-scene::before {
    display: none;
  }

  .ma-scene::after {
    background: linear-gradient(180deg, rgba(2, 8, 13, .06), transparent 38%, rgba(2, 8, 13, .66) 84%);
  }

  .ma-intro {
    bottom: 27px;
  }

  .ma-intro h1 {
    font-size: clamp(43px, 13vw, 63px);
  }

  .ma-intro p {
    max-width: 430px;
    font-size: 13px;
  }

  .ma-credit {
    display: none;
  }

  body.ma-document-open .ma-painting {
    filter: brightness(.74) saturate(.82);
    opacity: .92;
    transform: scale(.95) translateY(-1vh);
  }

  .ma-document {
    padding: 126px 12px 62px;
  }

  .ma-close {
    top: 86px;
    right: 12px;
    min-height: 38px;
    padding-inline: 13px;
  }

  .ma-context {
    width: calc(100% - 20px);
  }

  .ma-context p {
    font-size: 13px;
  }

  .ma-letter {
    padding: 43px 25px 54px;
  }

  .ma-letter::before {
    inset: 8px;
  }

  .ma-letter-text {
    font-size: 18px;
    line-height: 1.72;
  }

  .ma-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .ma-painting {
    padding: 0;
  }

  .ma-intro {
    bottom: 24px;
  }

  .ma-intro h1 {
    font-size: clamp(42px, 6vw, 66px);
  }

  .ma-intro p {
    margin-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ma-scene::before,
  .ma-painting,
  .ma-intro,
  .ma-credit,
  .ma-open,
  .ma-open::after,
  .ma-close {
    transition: none !important;
  }

  body.ma-document-open .ma-document {
    animation: none;
  }
}

/* Responsive repairs: keep the immersive cover, but make the open letter a
   normal scrollable page on phones and tablets. */
body.ma-body main {
  overflow: visible;
}

body.ma-document-open {
  overflow-x: hidden;
  overflow-y: auto;
}

body.ma-document-open .ma-experience {
  display: flow-root;
  height: auto;
  min-height: 0;
  overflow: visible;
}

body.ma-document-open .ma-document {
  min-height: auto;
}

body.ma-document-open .ma-site-footer {
  position: relative;
  z-index: 8;
}

@media (max-width: 1100px) {
  body.ma-body .site-header {
    grid-template-columns: 1fr auto;
  }

  body.ma-body .site-header .brand-copy {
    min-width: 0;
  }

  body.ma-body .site-header .brand-copy small {
    display: none;
  }

  body.ma-body .header-actions {
    gap: 4px;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .ma-scene {
    height: calc(100svh - 34px);
    min-height: 720px;
  }

  .ma-intro {
    bottom: max(38px, env(safe-area-inset-bottom));
    width: min(780px, calc(100% - 40px));
  }

  .ma-intro h1 {
    font-size: clamp(54px, 8vw, 78px);
    line-height: .95;
  }

  .ma-back {
    left: max(18px, calc((100vw - 780px) / 2));
  }
}

@media (max-width: 760px) {
  body.ma-body .site-header,
  body.ma-body .site-header.scrolled {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body.ma-body .site-header .brand {
    min-width: 0;
  }

  body.ma-body .site-header .brand-copy {
    width: auto;
    min-width: 0;
  }

  .ma-experience,
  .ma-scene {
    height: calc(100svh - 32px);
    min-height: 680px;
  }

  .ma-intro {
    bottom: max(20px, env(safe-area-inset-bottom));
    width: calc(100% - 40px);
  }

  .ma-eyebrow {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 8px;
    letter-spacing: .14em;
  }

  .ma-eyebrow::before,
  .ma-eyebrow::after {
    width: 22px;
  }

  .ma-intro h1 {
    font-size: clamp(38px, 11.5vw, 54px);
    line-height: .98;
  }

  .ma-open {
    max-width: 100%;
    min-height: 48px;
    padding-inline: 19px;
    text-align: center;
  }

  .ma-document {
    padding-top: 158px;
  }

  .ma-context {
    width: 100%;
  }

  .ma-context h2 {
    font-size: clamp(31px, 9vw, 42px);
  }

  .ma-letter {
    padding: 38px 20px 48px;
  }

  .ma-letter-heading h3 {
    font-size: clamp(29px, 9vw, 38px);
  }

  .ma-letter-text {
    font-size: clamp(16px, 4.7vw, 18px);
    line-height: 1.76;
  }

  .ma-letter-text p:first-child::first-letter {
    font-size: 3.45em;
  }

  .ma-note {
    padding: 22px 20px;
  }
}

@media (max-width: 380px) {
  .ma-back {
    max-width: calc(100vw - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ma-letter {
    padding-inline: 17px;
  }

  .ma-letter-text {
    line-height: 1.72;
  }
}
