:root {
  /* lvh = «большой» вьюпорт: не прыгает при появлении/скрытии UI браузера */
  --app-h: 100lvh;
  --scene-height: 140lvh;
  --char-size: calc(var(--app-h) * 0.34);
  --char-bottom: calc(var(--app-h) * 0.025 + 10px);
  --sky: #6ec4e8;

  /* Medusmo palette */
  --med-bg: #f3f3f1;
  --med-ink: #1c1c1a;
  --med-soft: #b7b7b2;
  --med-muted: #6f6f6a;
  --med-line: #e0e0dc;
  --med-card: #fafaf8;
  --med-lime: #dafb71;
  --med-lime-hot: #e6ff27;
  --med-charcoal: #31312f;

  --font: "Onest", sans-serif;
  --radius: 1rem;
  --radius-pill: 999px;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  min-height: 100lvh;
  background: var(--sky);
  overflow-x: hidden;
}

html.is-site,
body.is-site {
  overflow: hidden;
  height: 100%;
  background: var(--med-bg);
}

.city-strip {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  background: var(--sky);
}

body.is-site .city-strip {
  visibility: hidden;
}

.city-segment {
  position: absolute;
  left: 0;
  bottom: 0;
  top: auto;
  width: 100vw;
  height: var(--app-h);
  background-image: url("Image.png");
  background-repeat: no-repeat;
  background-size: auto 100%;
  background-position: left bottom;
  will-change: transform;
}

.welcome-tip {
  position: absolute;
  top: clamp(4.5rem, 18vh, 9rem);
  left: 50vw;
  transform: translateX(-50%);
  z-index: 2;
  width: max-content;
  max-width: calc(100vw - 1.5rem);
  padding: 1.15rem 1.75rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--med-line);
  background: var(--med-card);
  font-family: var(--font);
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.45s ease;
}

.welcome-tip.is-hiding {
  opacity: 0;
}

.welcome-title {
  margin: 0;
  font-size: clamp(1.25rem, 3.4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  white-space: nowrap;
  color: var(--med-ink);
}

.welcome-sub {
  margin: 0.45rem 0 0;
  font-size: clamp(0.92rem, 1.7vw, 1.05rem);
  font-weight: 500;
  color: var(--med-muted);
}

.speech-tip {
  position: fixed;
  left: 50%;
  bottom: calc(var(--char-bottom) + var(--char-size) * 1.02);
  transform: translateX(-50%) translateY(8px);
  z-index: 25;
  width: max-content;
  max-width: calc(100vw - 1.5rem);
  padding: 1rem 1.5rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--med-line);
  background: var(--med-card);
  font-family: var(--font);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    visibility 0.28s;
}

.speech-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.45rem;
  width: 0.75rem;
  height: 0.75rem;
  border-right: 1px solid var(--med-line);
  border-bottom: 1px solid var(--med-line);
  background: var(--med-card);
  transform: translateX(-50%) rotate(45deg);
}

.speech-tip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.speech-tip p {
  margin: 0;
  font-size: clamp(0.9rem, 1.25vw, 1.05rem);
  line-height: 1.45;
  font-weight: 500;
  color: var(--med-ink);
  hyphens: none;
  -webkit-hyphens: none;
}

.speech-line {
  display: block;
  white-space: nowrap;
}

body.is-site .speech-tip {
  opacity: 0;
  visibility: hidden;
}

.walk-track {
  position: relative;
  z-index: 1;
}

.scene {
  height: var(--scene-height);
}

.character {
  position: fixed;
  left: 50%;
  bottom: var(--char-bottom);
  top: auto;
  width: var(--char-size);
  aspect-ratio: 1 / 1;
  transform: translateX(-50%);
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  image-rendering: auto;
  pointer-events: none;
  user-select: none;
  z-index: 20;
  transition: opacity 0.15s linear;
}

.character.idle {
  background-image: url("assets/character.png");
}

.character.walk-right {
  background-image: url("assets/right.png");
}

.character.walk-left {
  background-image: url("assets/left.png");
}

.character.is-moving {
  animation: toy-bob 0.26s ease-in-out infinite;
}

@keyframes toy-bob {
  0%,
  100% {
    transform: translateX(-50%);
  }
  50% {
    transform: translateX(-50%) translateY(-6px);
  }
}

.cover-spacer {
  height: 120lvh;
  pointer-events: none;
}

.cover-panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  width: 100%;
  height: var(--app-h, 100lvh);
  min-height: var(--app-h, 100lvh);
  background: var(--med-bg);
  color: var(--med-ink);
  transform: translateX(100%);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  pointer-events: none;
  visibility: visible;
  padding: 0;
  box-sizing: border-box;
}

.cover-panel .med-frame {
  min-height: 100%;
  height: 100%;
}

.cover-panel.is-in {
  transform: translateX(0);
  pointer-events: auto;
}

.site-rest {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: 100%;
  height: var(--app-h, 100lvh);
  min-height: var(--app-h, 100lvh);
  background: var(--med-bg);
  visibility: hidden;
  pointer-events: none;
  box-sizing: border-box;
}

.site-rest.is-revealed {
  visibility: visible;
  pointer-events: auto;
}

.site-scroller {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
}

.site-scroller::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.site-block {
  box-sizing: border-box;
  width: 100%;
  flex: 0 0 100%;
  height: 100%;
  min-height: 100%;
  background: var(--med-bg);
  color: var(--med-ink);
  padding: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Medusmo-like: soft light, lime accent, big caps, quiet cards */
.med-frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  padding: clamp(1.25rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 1.8vh, 1.35rem);
  background: var(--med-bg);
  font-family: var(--font);
}

.med-eyebrow {
  font-size: clamp(0.78rem, 1.3vw, 0.9rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--med-muted);
  flex: 0 0 auto;
}

.med-title {
  display: flex;
  flex-direction: column;
  gap: 0.05em;
  font-weight: 800;
  font-size: clamp(2.1rem, 6.8vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  max-width: 16ch;
  flex: 0 1 auto;
  min-height: 0;
}

.med-title-strong {
  color: var(--med-ink);
}

.med-title-soft {
  color: var(--med-soft);
}

.med-lead {
  max-width: 36rem;
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.5;
  font-weight: 400;
  color: var(--med-muted);
  flex: 0 0 auto;
}

.med-lead-wide {
  max-width: 28rem;
}

.med-grid {
  list-style: none;
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border: 1px solid var(--med-line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--med-line);
  min-height: 0;
  flex: 1 1 auto;
}

.med-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.med-grid-skills {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.med-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.65rem;
  padding: clamp(0.95rem, 2vw, 1.45rem);
  border: none;
  background: var(--med-card);
  min-height: 0;
}

.med-card h3 {
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--med-ink);
  flex: 0 0 auto;
}

.med-card p {
  font-size: clamp(0.9rem, 1.35vw, 1.02rem);
  line-height: 1.45;
  color: var(--med-muted);
}

.med-frame-contact {
  justify-content: center;
  gap: 1.25rem;
}

.med-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.med-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.med-btn-lime {
  background: var(--med-lime);
  color: var(--med-charcoal);
}

.med-btn-lime:hover {
  background: var(--med-lime-hot);
}

.med-btn-dark {
  background: var(--med-charcoal);
  color: #ffffff;
}

.med-place {
  font-size: 0.95rem;
  color: var(--med-muted);
}

@media (max-width: 900px) {
  .med-grid,
  .med-grid-3,
  .med-grid-skills {
    grid-template-columns: 1fr 1fr;
  }

  .med-grid-skills {
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
}

/* Низкие экраны: чуть меньше только заголовок, карточки остаются читаемыми */
@media (max-height: 820px) {
  .med-frame {
    padding-top: 1.1rem;
    padding-bottom: 1.1rem;
    gap: 0.65rem;
  }

  .med-title {
    font-size: clamp(1.85rem, 5.8vh, 3.2rem);
  }
}

@media (max-width: 640px) {
  .speech-tip {
    width: max-content;
    max-width: calc(100vw - 1.25rem);
    padding: 0.75rem 0.85rem 0.85rem;
    bottom: calc(var(--char-bottom) + var(--char-size) * 0.95);
  }

  .speech-tip p {
    /* Длинные строки реплик — чуть мельче, чтобы nowrap влезал */
    font-size: clamp(0.68rem, 3.35vw, 0.82rem);
    line-height: 1.38;
    text-align: center;
  }

  .speech-line {
    display: block;
    white-space: nowrap;
  }

  .med-frame {
    overflow: hidden;
    padding: 1.2rem 0.85rem calc(1rem + env(safe-area-inset-bottom, 0px));
    gap: 0.75rem;
  }

  .med-title {
    font-size: clamp(1.55rem, 9vw, 2.1rem);
    max-width: none;
    margin-bottom: 0.15rem;
  }

  .med-lead {
    font-size: 0.84rem;
    line-height: 1.35;
    max-width: none;
    margin-bottom: 0.2rem;
  }

  .med-grid,
  .med-grid-3 {
    grid-template-columns: 1fr;
  }

  /* 6 карточек в 2 колонки, полный текст */
  .med-grid-skills {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, minmax(0, 1fr));
    flex: 1 1 auto;
    min-height: 0;
  }

  .med-grid-skills .med-card {
    padding: 0.6rem 0.65rem;
    gap: 0.35rem;
    justify-content: flex-start;
  }

  .med-grid-skills .med-card h3 {
    font-size: 0.88rem;
    line-height: 1.2;
  }

  .med-grid-skills .med-card p {
    font-size: 0.7rem;
    line-height: 1.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cover-panel {
    transition: none;
  }
}
