.rest {
  display: grid;
  place-items: center;
  background: var(--soot-deep);
  opacity: 0;
  animation: rest-in 1.4s var(--ease) forwards;
  transition: opacity 0.4s;
}

.rest--leaving {
  opacity: 0 !important;
  animation: none;
}

@keyframes rest-in {
  to {
    opacity: 1;
  }
}

/* ---------- картина во весь экран, медленный наезд камеры ---------- */

.rest__gallery {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.rest__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform-origin: var(--origin, 50% 50%);
  animation: approach 80s ease-in-out infinite alternate;
  transition: opacity 2.2s ease;
}

.rest__art--shown {
  opacity: 1;
}

@keyframes approach {
  from {
    transform: scale(1.02);
  }
  to {
    transform: scale(1.12);
  }
}

/* Тень сгущается к центру, где текст, а края оставляют картину видной */
.rest__shade {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse min(46vw, 900px) 72vh at 50% 52%, rgb(10 7 5 / 0.8), rgb(10 7 5 / 0.55) 55%, rgb(10 7 5 / 0.08) 100%),
    linear-gradient(180deg, rgb(8 6 4 / 0.6), transparent 22%, transparent 72%, rgb(8 6 4 / 0.8));
}

.rest__shade::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grain);
  opacity: 0.35;
  mix-blend-mode: overlay;
}

.rest__embers {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- сцена ---------- */

.rest__stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(700px, calc(100vw - 48px));
  text-align: center;
}

.rest__eyebrow {
  margin: 0 0 min(18px, 2vh);
  color: var(--gold);
  font-size: clamp(17px, 1.6vh, 22px);
  font-style: italic;
  opacity: 0;
  animation: fade-in 1.2s 0.2s forwards;
}

.rest__title {
  margin: 0;
  color: var(--parchment);
  font: 400 clamp(42px, 7vh, 100px) / 1.05 var(--font-display);
  text-shadow: 0 2px 28px rgb(0 0 0 / 0.75);
  text-wrap: balance;
}

.rest__word {
  display: inline-block;
  white-space: nowrap;
}

/* Глашатай: буквы проступают по одной, как чернила на пергаменте */
.rest__letter {
  display: inline-block;
  opacity: 0;
  filter: blur(10px);
  transform: translateY(12px);
  animation: letter-in 1s var(--ease) forwards;
  animation-delay: calc(var(--i) * 34ms + 350ms);
}

.rest__letter--rubric {
  color: var(--vermilion-light);
  font-size: 1.22em;
  line-height: 0.8;
  text-shadow: 0 0 26px rgb(217 71 60 / 0.5), 0 2px 18px rgb(0 0 0 / 0.7);
}

@keyframes letter-in {
  to {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

.rest__lede {
  max-width: 32em;
  margin: 14px 0 0;
  color: var(--parchment-dim);
  font-size: clamp(18px, 2.2vh, 24px);
  font-style: italic;
  text-shadow: 0 1px 12px rgb(0 0 0 / 0.8);
  opacity: 0;
  animation: fade-in 1.4s 1.3s forwards;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

.rest__session,
.rest__done {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  opacity: 0;
  animation: fade-in 1.4s 1.8s forwards;
}

.rest__session {
  margin-top: min(30px, 3vh);
}

.rest__dial {
  --dial-size: min(380px, 34vh);
}

.rest__activity {
  margin-top: min(28px, 2.8vh);
}

.rest__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: min(26px, 2.6vh);
}

.rest__skip {
  --hold-duration: 3s;
}

.rest__streak {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--parchment-faint);
  font-size: 15px;
  font-style: italic;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.8);
}

.rest__streak b {
  color: var(--gold-light);
  font-style: normal;
}

.rest__done {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: min(44px, 4.5vh);
}

/* Подпись к картине, как табличка в музее: мелко, в углу, не спорит с часами */
.rest__credit {
  position: fixed;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: grid;
  gap: 2px;
  max-width: min(440px, 36vw);
  margin: 0;
  padding-left: 12px;
  border-left: 1px solid var(--gold-line);
  color: var(--parchment-dim);
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.9);
  opacity: 0;
  animation: fade-in 1.6s 2.6s forwards;
}

.rest__credit-artist {
  color: var(--gold-light);
  font: 16px/1.2 var(--font-display);
}

.rest__credit-work {
  font-style: italic;
}

/* На узком экране угла не хватает: подпись встаёт под содержимым по центру */
@media (max-width: 760px) {
  .rest__credit {
    position: static;
    max-width: none;
    margin-top: 22px;
    padding: 8px 0 0;
    border-left: 0;
    border-top: 1px solid var(--gold-hair);
    font-size: 13px;
    text-align: center;
  }
}

/* На второстепенных мониторах только картина, глашатай и часы: кнопки живут на основном экране */
.rest--secondary .rest__activity,
.rest--secondary .rest__actions,
.rest--secondary .rest__oath,
.rest--secondary .rest__streak,
.rest--secondary .rest__done {
  display: none;
}

/* ---------- activity (занятие на привал, пергаментный лист) ---------- */

.activity {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 16px 14px 16px 16px;
  text-align: left;
}

/* Буквица на финифти в золотой рамке, как в часослове */
.activity__initial {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 2px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, var(--c1), var(--c2) 75%);
  box-shadow: inset 0 0 0 3px rgb(255 240 200 / 0.18), 0 2px 6px rgb(60 30 10 / 0.45);
  color: var(--gold-light);
  font: 44px/1 var(--font-display);
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.55);
}

.activity__title {
  margin: 0 0 3px;
  color: var(--ink);
  font: 400 24px/1.15 var(--font-display);
}

.activity__text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16.5px;
  line-height: 1.45;
}

.activity--swap {
  animation: swap 0.45s var(--ease);
}

@keyframes swap {
  from {
    opacity: 0.3;
    transform: translateX(10px);
  }
}

/* ---------- oath (клятва для выхода в строгом режиме) ---------- */

.oath {
  width: min(540px, 100%);
  margin-top: 16px;
}

.oath__label {
  display: block;
  margin-bottom: 8px;
  color: var(--parchment-dim);
  font-style: italic;
}

.oath__input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  background: rgb(10 7 5 / 0.75);
  font: 20px var(--font-display);
  text-align: center;
  user-select: text;
}

.oath__input:focus {
  border-color: var(--gold);
  outline: none;
}

.oath__error {
  min-height: 20px;
  margin-top: 6px;
  color: var(--vermilion-light);
  font-size: 14px;
}

.oath--shake {
  animation: shake 0.4s;
}

@keyframes shake {
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}
