* { box-sizing: border-box; }

body { margin: 0; }
[hidden] { display: none !important; }
button { cursor: pointer; }
button:disabled { cursor: wait; }
img { display: block; max-width: 100%; }

.wrap {
  width: min(1280px, calc(100% - 112px));
  margin-inline: auto;
}

.masthead { border-bottom: 1px solid var(--color-line); }
.masthead-inner {
  display: flex;
  min-height: 84px;
  align-items: center;
}
.brand { width: 152px; height: auto; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.94fr);
  gap: clamp(28px, 3.65vw, 56px);
  align-items: start;
  padding-block: 48px 72px;
}

.intro {
  container-type: inline-size;
  padding-block: 2px 22px;
}
.stages {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 332px;
  margin: 0 0 38px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--color-muted);
}

.stages li {
  border-top: 3px solid var(--color-line);
  padding-top: 10px;
}
.stages .stage-current {
  color: var(--color-accent);
  border-color: var(--color-accent);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 13.5cqw, 3.9rem);
  line-height: 1.015;
  letter-spacing: -0.05em;
  text-wrap: initial;
}

.questionnaire {
  min-width: 0;
  border-inline-start: 1px solid var(--color-line);
  padding-inline-start: clamp(28px, 3.65vw, 56px);
}

fieldset {
  min-inline-size: 0;
  padding: 0;
  border: 0;
  margin: 0;
}

label {
  display: block;
  color: var(--color-text);
  line-height: 1.35;
}

.name-field {
  max-width: 456px;
  margin-bottom: 32px;
}

.name-field label,
.written-answers label,
.other-field label {
  margin-bottom: 8px;
  font-weight: 700;
}

input[type="text"],
textarea {
  display: block;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--color-line);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.5;
}

input[type="text"] { min-height: 46px; }
textarea { min-height: 108px; resize: vertical; }
input[type="text"]:focus,
textarea:focus {
  background: var(--color-bg);
  border-color: var(--color-accent);
  outline: 2px solid var(--color-accent);
  outline-offset: 0;
}

.proposition legend {
  padding: 0;
  color: var(--color-text);
  font: var(--weight-heading) clamp(1.65rem, 2.55vw, 2.375rem)/1.1 var(--font-heading);
  letter-spacing: -0.045em;
}

.hint {
  color: var(--color-muted);
  font-size: 1rem;
  margin: 5px 0 17px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.gallery-item { position: relative; min-width: 0; }
.photo-choice, .other-choice {
  position: relative;
  cursor: pointer;
  border: 1px solid var(--color-line);
  border-radius: 4px;
}

.photo-choice {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.photo-choice input, .other-choice input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  clip-path: inset(50%);
}

.photo-choice:hover, .other-choice:hover { border-color: var(--color-accent); }
.photo-choice:has(input:focus-visible), .other-choice:has(input:focus-visible) {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}
.photo-choice:has(input:checked), .other-choice:has(input:checked) {
  background: var(--color-surface);
  border-color: var(--color-accent);
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

.photo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1.61;
  background: var(--color-surface);
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.photo-frame img { width: 100%; height: 100%; object-fit: contain; }
.photo-frame .cheese-photo { object-fit: cover; object-position: right center; }
.gallery-item:nth-child(2) .photo-frame { background: #faf4d5; }
.gallery-item:nth-child(3) .photo-frame { background: #f4f5f4; }

.option-caption, .other-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 9px 10px;
  font-size: 0.9375rem;
  line-height: 1.25;
}
.option-caption { flex: 1; }

.radio-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 17px;
  height: 17px;
  border: 1px solid var(--color-muted);
  border-radius: 50%;
  background: var(--color-bg);
}
input:checked ~ .radio-mark, input:checked ~ .option-caption .radio-mark { border-color: var(--color-accent); }
input:checked ~ .radio-mark::after, input:checked ~ .option-caption .radio-mark::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
}

.preview {
  display: grid;
  place-items: center;
  position: absolute;
  top: 5px;
  right: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-accent);
  border: 1px solid var(--color-line);
  border-radius: 4px;
}
.preview:hover { border-color: var(--color-accent); }
.preview span {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transform: translate(-1.5px, -1.5px);
}
.preview span::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1.5px;
  top: 9px;
  left: 9px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

.other-choice {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
}
.other-field { margin-top: 15px; }

.written-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 18px;
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid var(--color-line);
}

.written-answers label span {
  color: var(--color-muted);
  font-weight: 400;
}

.form-actions { margin-top: 30px; }
.button {
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}
.primary {
  color: var(--color-on-accent);
  background: var(--color-accent);
}
.primary:hover { background: #1b4d3e; }
.primary:disabled { opacity: 0.7; }
.secondary {
  background: var(--color-bg);
  border-color: var(--color-line);
  color: var(--color-accent);
}
.secondary:hover { border-color: var(--color-accent); }
.form-error { color: #8e2e29; margin: 10px 0 0; font-size: 1rem; }

.receipt {
  padding: 32px;
  background: var(--color-surface);
  border-top: 3px solid var(--color-accent);
}
.receipt-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  color: var(--color-accent);
  margin-bottom: 24px;
}
.receipt-mark::before {
  content: "";
  width: 15px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  transform: translateY(-2px) rotate(-45deg);
}
.receipt h2 { margin: 0; }
.receipt h2:focus { outline: none; }
.receipt p { color: var(--color-muted); margin: 8px 0 0; }

.image-dialog {
  width: min(1140px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-text);
}
.image-dialog[open] { display: flex; flex-direction: column; }
.image-dialog::backdrop { background: rgb(22 42 35 / 0.72); }
.dialog-toolbar, .dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 12px 16px;
}
.dialog-toolbar h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  letter-spacing: -0.025em;
  text-wrap: initial;
}
.close {
  position: relative;
  display: block;
  width: 46px;
  padding: 0;
}
.close span::before, .close span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  content: "";
  width: 17px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}
.close span::after { transform: translate(-50%, -50%) rotate(-45deg); }
.dialog-image {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--color-surface);
}
.dialog-image img {
  width: 100%;
  max-height: calc(100dvh - 192px);
  object-fit: contain;
}
.dialog-image.is-zoomed img {
  width: max(1280px, 150%);
  max-width: none;
  max-height: none;
}
.dialog-actions { justify-content: flex-end; }

@media (max-width: 1050px) {
  .wrap { width: calc(100% - 72px); }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr); }
}

@media (max-width: 840px) {
  .wrap { width: calc(100% - 40px); }
  .masthead-inner { min-height: 64px; }
  .brand { width: 130px; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding-block: 28px 48px;
  }
  .intro { padding: 0 0 24px; border-bottom: 1px solid var(--color-line); }
  .stages { margin-bottom: 22px; }
  h1 { max-width: 590px; font-size: clamp(2.125rem, 5.8vw, 3.35rem); }
  .questionnaire { padding: 0; border: none; }
  .name-field { margin-bottom: 26px; }
}

@media (max-width: 560px) {
  .gallery { gap: 6px; }
  .photo-frame { aspect-ratio: 1.3; }
  .option-caption { padding: 8px 5px; gap: 5px; font-size: 0.875rem; min-height: 52px; }
  .option-caption .radio-mark { width: 14px; height: 14px; }
  input:checked ~ .option-caption .radio-mark::after { width: 8px; height: 8px; }
  .preview { top: 3px; right: 3px; width: 32px; height: 32px; }
  .written-answers { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .form-actions .button { width: 100%; }
  .receipt { padding: 24px; }
  .dialog-toolbar, .dialog-actions { padding: 10px; }
  .zoom { padding-inline: 8px; }
}

@media (max-width: 360px) {
  .wrap { width: calc(100% - 32px); }
  .option-caption { flex-wrap: wrap; align-content: start; align-items: center; }
  .dialog-toolbar { gap: 5px; }
}
