:root {
  --blue: #002159;
  --white: #ffffff;
  --line: rgba(0, 33, 89, 0.15);
  --soft: rgba(0, 33, 89, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--white);
  color: var(--blue);
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { opacity: 0.6; }

/* ---------- header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: var(--white);
}
.logo { display: block; }
.logo img { display: block; height: 44px; width: auto; }
nav { display: flex; gap: 24px; }
nav a.active { text-decoration: underline; text-underline-offset: 4px; }

main { padding: 24px 24px 80px; min-height: calc(100vh - 120px); }

footer {
  padding: 24px;
  text-align: center;
}
footer .social { display: flex; justify-content: center; gap: 24px; margin-bottom: 12px; }
footer .copy { opacity: 0.5; }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 48px 24px;
  max-width: 1400px;
  margin: 40px auto 0;
}
.item { display: block; cursor: pointer; }
.item .frame,
.detail .frame {
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.item .caption { margin-top: 12px; text-align: center; line-height: 1.7; }
.item .caption span { opacity: 0.5; }

.placeholder {
  width: 100%;
  height: 100%;
  background: var(--soft);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

/* ---------- painting detail ---------- */
.detail {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 64px;
  max-width: 1200px;
  margin: 40px auto 0;
  align-items: center;
}
.detail .frame { width: min(100%, 70vh); margin: 0 auto; }
.detail .media { min-width: 0; }
.thumbs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.thumbs button {
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  opacity: 0.5;
}
.thumbs button.on { border-color: var(--blue); opacity: 1; }
.thumbs button:hover { opacity: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail .meta { line-height: 2; max-width: 360px; }
.detail .meta .btn { margin-top: 24px; }
.detail h1 { font-size: 13px; font-weight: 700; letter-spacing: 0.15em; margin-bottom: 16px; }
.detail .info { margin: 24px 0 8px; text-transform: none; line-height: 1.8; }
.back { display: inline-block; margin-bottom: 8px; opacity: 0.5; }

.btn {
  display: inline-block;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: var(--white);
  font: inherit;
  text-align: center;
  letter-spacing: 0.15em;
  cursor: pointer;
}
.btn:hover { background: var(--white); color: var(--blue); opacity: 1; }
.btn.sold,
.btn.sold:hover { background: var(--white); color: var(--blue); opacity: 0.4; cursor: default; }

/* ---------- code page ---------- */
.code-box {
  max-width: 320px;
  margin: 18vh auto 0;
  text-align: center;
  line-height: 2;
}
.code-box input {
  width: 100%;
  margin: 24px 0 12px;
  padding: 16px;
  border: 1px solid var(--blue);
  background: var(--white);
  color: var(--blue);
  font: inherit;
  text-align: center;
  letter-spacing: 0.3em;
  outline: none;
}
.code-box input::placeholder { color: var(--blue); opacity: 0.35; }
.msg { min-height: 2em; margin-top: 12px; }

.empty { text-align: center; margin-top: 18vh; line-height: 2; }

/* ---------- certificate (private page) ---------- */
.cert { max-width: 595px; margin: 24px auto 0; }
.thanks { text-align: center; margin-bottom: 48px; }
.thanks h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.3em; margin-bottom: 16px; }
.thanks p { text-transform: none; line-height: 1.8; font-size: 12px; }
/* the card has A4 proportions (210 × 297); the painting shrinks to fit the space left */
.cert-card {
  aspect-ratio: 210 / 297;
  display: flex;
  flex-direction: column;
  padding: 40px 44px;
  border: 1px solid var(--blue);
  box-shadow: inset 0 0 0 6px var(--white), inset 0 0 0 7px var(--blue);
}
.cert-head { text-align: center; font-weight: 700; letter-spacing: 0.25em; margin-bottom: 24px; }
.cert-card .frame {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  justify-content: center;
}
.cert-card .frame img { width: auto; max-width: 100%; height: 100%; aspect-ratio: 1 / 1; }
.cert .rows { margin-top: 24px; }
.cert .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.cert .row span:first-child { opacity: 0.5; }
.cert .row span:last-child { text-align: right; }
.cert-text { text-transform: none; line-height: 1.8; margin-top: 20px; text-align: center; }
.sign { margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sign img { height: 48px; width: auto; }
.sign span { border-top: 1px solid var(--blue); padding-top: 8px; width: 180px; text-align: center; opacity: 0.6; }
.cert-photos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 64px;
}
.cert-photos .frame:last-child:nth-child(odd) { grid-column: span 2; }


/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  header { padding: 16px; }
  .logo img { height: 36px; }
  main { padding: 16px 16px 60px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 32px 16px; margin-top: 16px; }
  .detail { grid-template-columns: 1fr; gap: 24px; margin-top: 8px; }
  .detail .frame { width: 100%; }
  .thumbs button { width: 44px; height: 44px; }
  .detail .meta { max-width: none; }
}
/* phones: too narrow for an A4-shaped card on screen, so it just grows to fit */
@media screen and (max-width: 720px) {
  .cert-card { aspect-ratio: auto; padding: 28px 22px; }
  .cert-card .frame { flex: none; }
  .cert-card .frame img { width: 100%; height: auto; }
}
