:root {
  --burgundy: #471e24;
  --burgundy-deep: #36161b;
  --ivory: #f6efe6;
  --ivory-soft: rgba(246, 239, 230, 0.72);
  --gold: #d4a866;
  --gold-light: #e2be85;
  --gold-muted: rgba(212, 168, 102, 0.55);
  --black: #140e10;
  --line: rgba(212, 168, 102, 0.32);
  --card: rgba(20, 8, 10, 0.18);

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --radius-card: 1.25rem;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--burgundy);
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--burgundy) 0%, var(--burgundy) 55%, var(--burgundy-deep) 100%);
  background-attachment: fixed;
  color: var(--ivory);
  font-family: "Cormorant Garamond", Palatino, "Palatino Linotype", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  width: min(28rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.45rem 0 var(--space-4);
}

/* Шапка */

.brand {
  width: min(100%, 20rem);
  margin: 0 auto;
}

.brand img {
  display: block;
  width: 100%;
  height: auto;
}

.subtitle {
  margin: var(--space-2) 0 0;
  text-align: center;
  text-wrap: balance;
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.3;
  color: var(--gold);
}

/* Шаги */

.progress {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.progress li {
  width: 1.6rem;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.35s var(--ease), width 0.35s var(--ease);
}

body[data-step="photo"] .progress li:nth-child(-n + 1),
body[data-step="shape"] .progress li:nth-child(-n + 2),
body[data-step="group"] .progress li:nth-child(-n + 2),
body[data-step="style"] .progress li:nth-child(-n + 2),
body[data-step="base"] .progress li:nth-child(-n + 3),
body[data-step="accent"] .progress li:nth-child(-n + 3),
body[data-step="result"] .progress li {
  background: var(--gold);
}

body[data-step="photo"] .progress li:nth-child(1),
body[data-step="shape"] .progress li:nth-child(2),
body[data-step="group"] .progress li:nth-child(2),
body[data-step="style"] .progress li:nth-child(2),
body[data-step="base"] .progress li:nth-child(3),
body[data-step="accent"] .progress li:nth-child(3),
body[data-step="result"] .progress li:nth-child(4) {
  width: 2.6rem;
}

section:not([hidden]) {
  animation: rise 0.45s var(--ease);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

h2 {
  margin: var(--space-3) 0 var(--space-3);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-align: center;
  text-wrap: balance;
}

h2 em {
  font-style: italic;
  color: var(--gold);
}

.step-note {
  margin: calc(-1 * var(--space-2)) 0 var(--space-3);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--ivory-soft);
  text-align: center;
  line-height: 1.4;
  text-wrap: balance;
}

#style-group-name {
  font-style: normal;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Примеры кадра */

figure {
  margin: 0;
}

.examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.examples figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: var(--space-2) 0.5rem var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
}

.examples img {
  display: block;
  width: 100%;
  height: 8.5rem;
  object-fit: contain;
}

.examples figcaption {
  position: relative;
  width: 100%;
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: none;
  font-size: clamp(0.9rem, 4.4vw, 1.05rem);
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: none;
  white-space: nowrap;
  color: var(--ivory);
}

.examples figcaption::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 5.25rem;
  border-top: 1px solid var(--line);
  transform: translateX(-50%);
}

figcaption {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ivory-soft);
}

/* Кнопки */

.actions {
  display: grid;
  gap: 0.75rem;
  margin-top: var(--space-3);
}

button {
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--gold);
  color: var(--black);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 0.5rem 1.4rem -0.8rem rgba(0, 0, 0, 0.55);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

button:active {
  transform: scale(0.98);
}

@media (hover: hover) {
  button:hover {
    background: var(--gold-light);
    border-color: var(--gold-light);
  }
}

button:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

.actions__secondary {
  background: transparent;
  border-color: var(--gold-muted);
  color: var(--ivory);
  font-size: 1.12rem;
  font-weight: 500;
  box-shadow: none;
}

@media (hover: hover) {
  .actions__secondary:hover {
    background: rgba(212, 168, 102, 0.1);
    border-color: var(--gold);
  }
}

#to-next,
#generate-base,
#generate-accent,
#open-frame,
#pay-pack,
#pay-check,
#start-pay-check,
#copy-referral {
  width: 100%;
  margin-top: var(--space-3);
}

.referral {
  margin: var(--space-3) 0 0;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  color: var(--gold);
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
}

button.back {
  display: block;
  width: auto;
  min-width: 9rem;
  margin: var(--space-4) auto 0;
  padding: 0.6rem 1.75rem;
  background: var(--gold);
  border-color: var(--gold);
  color: var(--black);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

#back-to-result {
  width: 100%;
  margin-top: var(--space-2);
}

/* Направления и стили */

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.choices button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.6rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-color: var(--line);
  color: var(--ivory);
  font-size: 1.2rem;
  font-weight: 500;
  text-align: center;
  box-shadow: none;
}

#group-choices button {
  min-height: 4.6rem;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.choices button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

@media (hover: hover) {
  .choices button:hover {
    background: rgba(212, 168, 102, 0.1);
    border-color: var(--gold);
  }
}

.choices button.is-selected {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--black);
}

/* Цвета */

.color-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-flow: dense;
  gap: 0.75rem;
  align-items: start;
}

.color-groups > div:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.color-groups > div {
  display: grid;
  gap: 0.6rem;
}

.color-groups > div:has(.shades:not([hidden])) {
  grid-column: 1 / -1;
}

.color-groups button {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-color: rgba(246, 239, 230, 0.22);
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
}

.color-groups > div:has(.shades:not([hidden])) > button {
  border-color: var(--gold);
}

.shades {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
}

.shades[hidden] {
  display: none;
}

.shades button {
  min-height: 3rem;
  padding: 0.55rem 0.6rem;
  font-size: 1rem;
  line-height: 1.15;
}

.color-groups button.is-selected {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Фото и кадр */

.preview {
  margin-top: var(--space-3);
}

.preview img,
#result-image {
  display: block;
  width: 100%;
  max-height: 22rem;
  object-fit: contain;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.preview figcaption {
  text-transform: none;
  letter-spacing: 0.04em;
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--gold);
}

#result-image {
  height: auto;
  max-height: 70vh;
  padding: 0.35rem;
  border-color: var(--gold-muted);
  box-shadow: 0 1.5rem 3rem -1.5rem rgba(0, 0, 0, 0.7);
}

#result-image[hidden] {
  display: none;
}

.status {
  margin: calc(-1 * var(--space-1)) 0 var(--space-3);
  color: var(--ivory-soft);
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
}

.status.is-busy::before {
  content: "";
  display: block;
  width: 3.25rem;
  height: 3.25rem;
  margin: var(--space-2) auto var(--space-3);
  border: 1px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1.4s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.result-actions[hidden] {
  display: none;
}

.result-actions #again {
  margin-bottom: 0.25rem;
}

@media (prefers-reduced-motion: reduce) {
  section:not([hidden]),
  .status.is-busy::before {
    animation: none;
  }
}
