:root {
  --ink: #12110e;
  --paper: #fbfaf5;
  --card-paper: #f7f3e9;
  --display: "Italiana", Georgia, serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
}
button, a { color: inherit; }
button { font: inherit; }
a { text-decoration: none; }

.masthead {
  position: fixed;
  z-index: 5;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 20px 30px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .2em;
}
.masthead h1 {
  margin: 0;
  font: 400 13px var(--display);
  letter-spacing: .05em;
  text-transform: none;
}
.masthead button {
  justify-self: end;
  padding: 0;
  border: 0;
  background: none;
  text-transform: uppercase;
  letter-spacing: .2em;
  cursor: pointer;
}
.masthead .contact-open { justify-self: start; }
.masthead a, .masthead button { border-bottom: 1px solid transparent; }
.masthead a:hover, .masthead button:hover { border-color: currentColor; }

main { min-height: 100svh; display: grid; place-items: center; padding: 64px 24px 30px; }
.viewer { display: grid; justify-items: center; gap: 13px; }
.frame {
  --art-ratio: .706;
  --frame-image: url("frames/portrait-ink-clean.png");
  --frame-middle: url("frames/portrait-middle.png");
  position: relative;
  background: var(--paper);
  transition: width .35s ease;
}
.frame.portrait {
  width: min(62vw, 570px);
  --frame-image: url("frames/portrait-ink-clean.png");
  --frame-middle: url("frames/portrait-middle.png");
}
.frame.landscape {
  width: min(78vw, 820px);
  --frame-image: url("frames/landscape-ink-clean.png");
  --frame-middle: url("frames/landscape-middle-repaired.png");
}
.frame.square {
  width: min(58vw, 540px);
  --frame-image: url("frames/square-ink-clean.png");
  --frame-middle: url("frames/square-middle-clean.png");
}

.frame-top, .frame-bottom {
  position: relative;
  z-index: 3;
  width: 100%;
  background-image: var(--frame-image);
  background-repeat: no-repeat;
  background-size: 100% auto;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.portrait .frame-top { aspect-ratio: 1093 / 285; background-position: top; }
.portrait .frame-bottom { aspect-ratio: 1093 / 235; background-position: bottom; }
.landscape .frame-top { aspect-ratio: 1492 / 110; background-position: top; }
.landscape .frame-bottom { aspect-ratio: 1492 / 250; background-position: bottom; }
.square .frame-top { aspect-ratio: 1254 / 160; background-position: top; }
.square .frame-bottom { aspect-ratio: 1254 / 170; background-position: bottom; }

.frame-body {
  position: relative;
  z-index: 1;
  margin-block: -5px -7px;
  padding: 6px 13.2% 8px;
  background-image: var(--frame-middle);
  background-repeat: repeat-y;
  background-size: 100% 120px;
}
.portrait .frame-body { margin-block: -8px -11px; padding-block: 9px 12px; }
.landscape .frame-body {
  margin-block: 0;
  padding-inline: 7%;
  background-image: none;
}
.square .frame-body { padding-inline: 3.7%; background-image: none; }
.landscape .frame-body::before,
.square .frame-body::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .82;
}
.landscape .frame-body::before {
  background-image: url("frames/landscape-middle-outer-v5.png");
}
.square .frame-body::before {
  background-image: url("frames/square-middle-clean.png");
}

.portrait .frame-body {
  background-image: none;
}
.portrait .frame-top {
  background-image: url("frames/portrait-top-band.png");
}
.portrait .frame-bottom {
  background-image: url("frames/portrait-bottom-band-v2.png");
}
.portrait-rails {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: url("frames/portrait-middle-verticals-v3.png") center / 100% 100% no-repeat;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .82;
}
.portrait-rails-outer {
  -webkit-mask-image: linear-gradient(to right, #000 0 10%, transparent 10% 90%, #000 90% 100%);
  mask-image: linear-gradient(to right, #000 0 10%, transparent 10% 90%, #000 90% 100%);
}
.portrait-rails-inner-outer {
  bottom: calc(2.35% - 1px);
  height: calc(97.65% + 1px);
  -webkit-mask-image: linear-gradient(to right, transparent 0 10%, #000 10% 13.5%, transparent 13.5% 86.5%, #000 86.5% 90%, transparent 90% 100%);
  mask-image: linear-gradient(to right, transparent 0 10%, #000 10% 13.5%, transparent 13.5% 86.5%, #000 86.5% 90%, transparent 90% 100%);
}
.portrait-rails-inner-inner {
  bottom: calc(2.35% + 2px);
  height: calc(97.65% - 2px);
  -webkit-mask-image: linear-gradient(to right, transparent 0 13.5%, #000 13.5% 17%, transparent 17% 83%, #000 83% 86.5%, transparent 86.5% 100%);
  mask-image: linear-gradient(to right, transparent 0 13.5%, #000 13.5% 17%, transparent 17% 83%, #000 83% 86.5%, transparent 86.5% 100%);
}
.portrait-inner-bottom {
  position: absolute;
  z-index: 2;
  left: 13.42%;
  bottom: 2.35%;
  width: 73.15%;
  aspect-ratio: 793 / 10;
  background: url("frames/portrait-inner-bottom-single.png") center / 100% 100% no-repeat;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .82;
}
.landscape-inner-rails {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: none;
  background: url("frames/landscape-middle-inner-repaired-v2.png") center / 100% 100% no-repeat;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .82;
}
.landscape .landscape-inner-rails { display: block; }
.landscape .portrait-rails,
.square .portrait-rails,
.landscape .portrait-inner-bottom,
.square .portrait-inner-bottom { display: none; }

.frame-top,
.frame-bottom {
  opacity: .82;
}

.art-window {
  position: relative;
  width: 100%;
  aspect-ratio: var(--art-ratio);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--paper);
  transition: aspect-ratio .35s ease;
}
.current-art {
  display: block;
  max-width: 94%;
  max-height: 94%;
  object-fit: contain;
  mix-blend-mode: multiply;
  transition: transform .35s ease;
}
.portrait .current-art { transform: translateY(-2.25%); }
.square .current-art { max-width: 97%; max-height: 97%; }
.inscription {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: var(--cartouche-width, 34%);
  transform: translate(-50%, -50%);
  color: var(--ink);
  text-align: center;
}
.portrait .inscription { top: 45%; --cartouche-width: 32%; }
.landscape .inscription { top: calc(50% + 3px); --cartouche-width: 36%; }
.square .inscription { top: calc(50% - 3px); --cartouche-width: 38%; }
.inscription .number { display: none; }
.inscription h2 { margin: 0; font: 400 clamp(8px, 1.1vw, 12px)/1.05 var(--display); white-space: nowrap; }
.inscription p { display: none; }

.controls { width: min(62vw, 560px); display: flex; justify-content: space-between; align-items: center; }
.controls button {
  padding: 5px 12px;
  border: 0;
  background: none;
  font-size: 17px;
  cursor: pointer;
}
.position { font-size: 9px; letter-spacing: .18em; }
.position b { font-weight: 400; }

.about {
  width: min(520px, calc(100% - 40px));
  padding: 6px;
  border: 1px solid var(--ink);
  border-radius: 30px;
  background: var(--card-paper);
  color: var(--ink);
}
.contact {
  width: min(520px, calc(100% - 40px));
  padding: 6px;
  border: 1px solid var(--ink);
  border-radius: 30px;
  background: var(--card-paper);
  color: var(--ink);
}
.contact-inner {
  position: relative;
  padding: 52px 58px;
  border: 1px solid var(--ink);
  border-radius: 24px;
}
.about-inner {
  position: relative;
  padding: 58px 68px;
  border: 1px solid var(--ink);
  border-radius: 24px;
}
.about::backdrop,
.contact::backdrop { background: rgba(18,17,14,.82); }
.about-close {
  position: absolute;
  top: 13px;
  right: 18px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 29px;
  cursor: pointer;
}
.contact-close {
  position: absolute;
  top: 13px;
  right: 18px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 29px;
  cursor: pointer;
}
.small-title { margin: 0 0 6px; font-size: 9px; text-transform: uppercase; letter-spacing: .22em; }
.about h2 { margin: 0 0 30px; font: 400 36px var(--display); }
.about p { line-height: 1.5; }
.about a { display: inline-block; margin-top: 20px; border-bottom: 1px solid; font-size: 9px; text-transform: uppercase; letter-spacing: .16em; }
.contact h2 { margin: 0 0 28px; font: 400 31px var(--display); }
.contact form { display: grid; gap: 17px; }
.contact label { display: grid; gap: 5px; }
.contact label span { font-size: 8px; text-transform: uppercase; letter-spacing: .18em; }
.contact input,
.contact textarea {
  width: 100%;
  padding: 7px 2px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 16px var(--serif);
  resize: vertical;
}
.contact input:focus,
.contact textarea:focus { border-bottom-width: 2px; }
.contact-submit {
  justify-self: center;
  margin-top: 8px;
  padding: 9px 22px;
  border: 1px solid var(--ink);
  border-radius: 20px;
  background: transparent;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .16em;
  cursor: pointer;
}

@media (max-width: 720px) {
  .masthead { padding: 15px 16px; }
  .masthead > a { font-size: 0; border: 0; }
  .masthead > a::after { content: "Write"; font-size: 8px; }
  .masthead button { font-size: 8px; }
  main { padding: 56px 9px 15px; }
  .frame.portrait { width: min(93vw, 520px); }
  .frame.landscape { width: min(96vw, 650px); max-width: calc(100vw - 18px); }
  .frame.square { width: min(89vw, 500px); }
  .inscription { --cartouche-width: 40%; }
  .inscription h2 { font-size: clamp(8px, 2.35vw, 11px); }
  .controls { width: min(94vw, 520px); }
  .about { border-radius: 24px; }
  .about-inner { border-radius: 18px; }
  .about-inner { padding: 48px 30px; }
  .contact { border-radius: 24px; }
  .contact-inner { padding: 45px 29px; border-radius: 18px; }
}

@media (max-height: 760px) and (min-width: 721px) {
  .frame.portrait { width: min(44vw, 390px); }
  .frame.landscape { width: min(65vw, 650px); }
  .frame.square { width: min(47vw, 460px); }
  .controls { width: min(45vw, 470px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
