@font-face {
  font-family: "InstaCard Script";
  src: url("assets/segoesc.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: #f7fbf4;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.top-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
}

.top-bar h1 {
  margin: 0;
  text-align: center;
  font-family: "Courier New", Consolas, "Liberation Mono", monospace;
  font-size: clamp(3.5rem, 10vw, 8rem);
  font-weight: 700;
  color: #1d4f31;
  line-height: 1;
}

.instacard-logo {
  display: block;
  width: min(220px, 42vw);
  height: auto;
}

.asset-gallery {
  width: 100%;
  margin-top: 20px;
}

body.card-view-active .asset-gallery {
  display: none;
}

.card-picker {
  display: grid;
  gap: 12px;
}

.asset-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.asset-thumb {
  display: block;
  padding: 0;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.asset-thumb:hover,
.asset-thumb:focus-visible,
.asset-thumb.is-selected {
  border-color: #1d4f31;
}

.asset-thumb img {
  display: block;
  width: min(22vw, 180px);
  height: auto;
}

.preview-page {
  display: none;
  width: min(1100px, 100%);
  margin: 8px auto 0;
}

body.card-view-active .preview-page {
  display: block;
}

.preview-sheet {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  container-type: inline-size;
  aspect-ratio: 11 / 8.5;
  width: min(100%, calc((100vh - 190px) * 11 / 8.5));
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #d3d3d3;
  box-shadow: 0 12px 28px rgba(29, 79, 49, 0.14);
}

.preview-sheet::before,
.preview-sheet::after {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.preview-sheet::before {
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px dashed #696969;
}

.preview-sheet::after {
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px dashed #696969;
}

.preview-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.preview-panel:nth-child(1),
.preview-panel:nth-child(3) {
  border-right: 1px solid #d3d3d3;
}

.preview-panel:nth-child(1),
.preview-panel:nth-child(2) {
  border-bottom: 1px solid #d3d3d3;
}

.selected-card-image {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-panel:nth-child(1) > *,
.preview-panel:nth-child(2) > * {
  transform: rotate(180deg);
}

.brand-panel img {
  width: 60%;
  height: 45%;
  object-fit: contain;
}

.placeholder-panel,
.message-panel {
  text-align: center;
  color: #000000;
}

.message-panel {
  font-family: "InstaCard Script", "Segoe Script", "Lucida Handwriting", Arial, sans-serif;
  font-size: 3.03cqw;
  line-height: normal;
  font-weight: 400;
  white-space: pre-wrap;
}

.placeholder-panel p,
.message-panel p {
  margin: 0;
  max-width: calc(100% - 72px);
}

.message-panel h2 {
  margin: 0;
  max-width: calc(100% - 72px);
  font: inherit;
}

.message-panel p {
  display: none;
}

.message-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.message-controls label {
  display: grid;
  gap: 4px;
  color: #1d4f31;
  font-size: 0.9rem;
  text-align: left;
}

.message-controls input {
  width: 160px;
  padding: 8px 10px;
  border: 1px solid #9fb5a5;
  border-radius: 6px;
  font: inherit;
}

.preview-action,
.choose-card {
  display: inline-block;
  margin: 14px 6px 0;
  padding: 10px 14px;
  color: #1d4f31;
  background: #ffffff;
  border: 1px solid #9fb5a5;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.preview-page {
  text-align: center;
}

.preview-action:hover,
.preview-action:focus-visible,
.choose-card:hover,
.choose-card:focus-visible {
  background: #eef7ea;
}

@media (max-width: 640px) {
  .top-bar {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .instacard-logo {
    width: min(180px, 60vw);
  }

  .asset-row {
    flex-wrap: wrap;
  }

  .message-controls {
    flex-direction: column;
    align-items: center;
  }

  .asset-thumb img {
    width: min(38vw, 160px);
  }

  .preview-panel {
    padding: 10px;
  }
}
