/* Reset */
* {
  margin: 0;
  padding: 0;
  border: 0;
  box-sizing: border-box;
}
html, body {
  height: 100%;
}

/* Fonts */
@font-face {
  font-family: 'PixeloidSans';
  src: url('../fonts/PixeloidSans.woff2') format('woff2'),
       url('../fonts/PixeloidSans.woff') format('woff');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'PixeloidSans';
  src: url('../fonts/PixeloidSans-Bold.woff2') format('woff2'),
       url('../fonts/PixeloidSans-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: 'PixeloidMono';
  src: url('../fonts/PixeloidMono.woff2') format('woff2'),
       url('../fonts/PixeloidMono.woff') format('woff');
  font-weight: 400;
  font-style: normal;
}

/* Base */
body {
  font-family: 'PixeloidSans';
  background-color: rgb(130, 81, 20);
  color: #F5DEB3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background-color: rgb(168, 106, 29);
  margin: 10px 10px 0;
  border: 2px solid #5D3A1A;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  min-height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
  width: 100%;
}

.h1 {
  font-family: 'PixeloidMono';
  font-size: clamp(18px, 4vw, 22px);
}

.ava {
  width: clamp(40px, 12vw, 48px);
  height: clamp(40px, 12vw, 48px);
}
.ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.main_container {
  flex: 1;
  display: flex;
  position: relative;
  border: 2px solid #5D3A1A;
  margin: 10px;
  min-height: 0;
}

/* Navigation */
.nav_section {
  border-right: 2px solid #5D3A1A;
  padding: 15px;
  width: clamp(160px, 18vw, 200px);
  background-color: rgb(155, 97, 27);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
}

.nav-button {
  background-color: #45a049;
  border: 2px solid #5D3A1A;
  color: #F5DEB3;
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
  font-size: clamp(12px, 2.5vw, 16px);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 180px;
  margin: 0 auto;
  border-radius: 0;
}
.nav-button.active {
  background-color: #2d662f;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.nav-button:hover {
  background-color: #3a8a3d;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0,0,0,0.3);
}
.nav-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Main content */
.main_section {
  flex: 1;
  display: flex;
  min-height: 0;
  background-color: #715432;
  padding: 115px 15px 15px;
  overflow: hidden;
  position: relative;
}
.main_section::before {
  content:'';
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.5);
  z-index:1;
  transition:opacity .5s ease;
  pointer-events:none;
}
.main_section.light-on::before {
  opacity:0;
}

.content {
  position: absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  padding: 0 15px 15px;
  opacity:0;
  transform: translateX(-110%);
  transition: all .7s ease;
  display:none;
  overflow-y:auto;
}
.content.active {
  display:block;
  opacity:1;
  transform:translateX(0);
}
.content.leaving {
  transform: translateX(110%);
  opacity:0;
}

/* Gallery */
.gallery {
  display:flex;
  flex-direction:column;
  gap:15px;
  margin-top:15px;
}
.gallery img {
  border:2px solid #5D3A1A;
  transition: transform .3s ease;
  max-width:100%;
}

/* Lamp */
.lamp-container {
  position:absolute;
  top:0;
  left:50%;
  transform:translateX(-50%);
  z-index:3;
}
.lamp-bulb {
  width:100px;
  height:100px;
  background:url('../imgs/lamp-sprite.png') no-repeat;
  background-size:200px 100px;
  background-position:0 0;
}
.lamp-bulb.on {
  background-position:-100px 0;
  filter: drop-shadow(0 0 10px yellow);
}

/* Right panel */
.right_section {
  border-left: 2px solid #5D3A1A;
  width: clamp(160px, 18vw, 200px);
  background-color: rgb(155, 97, 27);
  padding:15px;
  display:flex;
  flex-direction:column;
  align-items:center;
  /* чтобы блок с тумблером не схлапывался */
  flex-shrink: 0;
  min-height: 140px;
}

/* Tumbler */
.tumbler-wrapper {
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  margin-bottom:20px;
}
.tumbler {
  width: clamp(120px, 20vw, 180px);
  height: clamp(120px, 20vw, 180px);
  background-image: url('../imgs/tumbler.png');
  background-size: 720px 180px;
  background-position: -540px 0;
  cursor:pointer;
  transition: background-position .3s steps(3);
  margin:5px 0;
}
.tumbler.on {
  background-position:0 0;
}
.tumbler-plate {
  background:silver;
  color:#333;
  padding:5px;
  font-family:'PixeloidMono';
  font-size:14px;
  border:2px solid #5D3A1A;
  text-align:center;
  width:100px;
  box-shadow:0 2px 4px rgba(0,0,0,.2);
}
.tumbler-plate.active {
  background:#c0c0c0;
  font-weight:bold;
}
.tumbler-plate.on-label { order:1; }
.tumbler { order:2; }
.tumbler-plate.off-label { order:3; }

/* Footer */
.footer {
  margin:0 10px 10px;
  height:60px;
  background:rgb(155,97,27);
  border:2px solid #5D3A1A;
  display:flex;
  justify-content:center;
  align-items:center;
}
.footer p {
  text-align:center;
  width:100%;
}
.footer a {
  text-decoration:none;
  color:#e4c38b;
  transition: color .3s ease;
}
.footer a:hover {
  color:#f5decb;
}
.footer a:visited {
  color:#e4c38b;
}

/* Socials */
.social-list {
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:20px;
  align-items:flex-start;
}
.social-block {
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:10px;
  text-decoration:none;
}
.social-label {
  font-family:'PixeloidMono';
  font-size:14px;
  color:#F5DEB3;
  text-align:left;
}

.icon{
  width:40px;
  height:40px;
  min-width:40px;
  min-height:40px;
  flex:0 0 40px;          /* <– не даём иконке сжиматься */
  image-rendering:pixelated;
  background-size:40px 40px;
  display:inline-block;
}
.vk {
  background-image:url('../imgs/vk.png');
}
.youtube {
  background-image:url('../imgs/yt.png');
}
.telegram {
  background-image:url('../imgs/tel.png');
}

/* Content container scroll */
#contentContainer {
  flex:1;
  display:flex;
  flex-direction:column;
  overflow-y:auto;
  position:relative;
  z-index:2;
  line-height:1.5;
  color:#F5DEB3;
  transition: filter .5s ease;
}
.main_section:not(.light-on) #contentContainer {
  filter: brightness(.5);
}

/* Custom scrollbar */
#contentContainer::-webkit-scrollbar {
  width:12px;
}
#contentContainer::-webkit-scrollbar-track {
  background:rgb(155,97,27);
  border-left:2px solid #5D3A1A;
}
#contentContainer::-webkit-scrollbar-thumb {
  background:#45a049;
  border:2px solid #5D3A1A;
  border-radius:0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.3);
}
#contentContainer {
  scrollbar-width: thin;
  scrollbar-color: #45a049 rgb(155,97,27);
}

/* Burger */
.burger {
  display:none;
  flex-direction:column;
  justify-content:space-between;
  width:clamp(28px,8vw,32px);
  height:clamp(20px,6vw,24px);
  cursor:pointer;
}
.burger-line {
  display:block;
  height:clamp(2px,.6vw,3px);
  width:100%;
  background:#F5DEB3;
  transition: transform .3s ease-in-out, opacity .3s ease-in-out;
  border-radius:2px;
}
.burger.active .burger-line:nth-child(1) {
  transform: translateY(clamp(9px,2.8vw,11px)) rotate(45deg);
}
.burger.active .burger-line:nth-child(2) {
  opacity:0;
  transform: scaleX(0);
}
.burger.active .burger-line:nth-child(3) {
  transform: translateY(clamp(-9px,-2.8vw,-11px)) rotate(-45deg);
}

/* Responsive nav */
@media (max-width: 768px) {
  .burger {
    display:flex;
  }

  .main_container {
    flex-direction:column;
    position:relative;
  }

  .nav_section {
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background:rgb(155,97,27);
    transform: translateY(-100%);
    opacity:0;
    pointer-events:none;
    transition: transform 1.2s cubic-bezier(0.77,0,0.175,1), opacity 1.2s ease;
    z-index:10;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
  }
  .nav_section.active {
    transform: translateY(0);
    opacity:1;
    pointer-events:auto;
  }

  .nav_section,
  .right_section {
    width:100%;
    border:none;
    border-bottom:2px solid #5D3A1A;
  }

  .nav-list {
    gap:30px;
  }

  .nav-button {
    transform: translateY(20px);
    opacity:0;
    transition: transform .8s ease, opacity .8s ease;
  }

  .nav_section.active .nav-button {
    transform: translateY(0);
    opacity:1;
  }
}

/* Контакты / тайлы */
.tile-row {
  display:flex;
  flex-direction:row;
  align-items:flex-start;
  gap:40px;
  margin-top:30px;
  padding-left:15px;
}
.tile-wrapper {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  margin-top:30px;
}
.tile-hint {
  font-family:'PixeloidMono';
  font-size:13px;
  color:#F5DEB3;
  text-shadow:1px 1px 2px #000;
  text-align:center;
  width:128px;
  line-height:1.1;
  word-break:break-word;
}

.tile-button {
  width:128px;
  height:128px;
  background-image:url('../imgs/tile.png');
  background-size:cover;
  background-repeat:no-repeat;
  filter: brightness(0.4);
  transition: filter .3s ease, transform .3s ease;
  border:none;
  outline:none;
  cursor:pointer;
  display:block;
  margin:0 auto;
}
.tile-button:hover {
  filter: brightness(1.2);
  transform: scale(1.1);
}

/* Состояние «включено» у тайла — остаётся подсвеченным */
.tile-button.selected {
  filter: brightness(1.2);
  transform: scale(1.1);
}

.tile-button-second {
  background-image:url('../imgs/tile2.png');
}

/* Темы от тайлов */
body.tile-theme header,
body.tile-theme .footer {
  background-image:url('../imgs/tile.png');
  background-repeat:repeat;
  background-size:128px 128px;
  background-color:transparent;
}
body.tile-theme header *,
body.tile-theme .footer * {
  text-shadow:1px 1px 2px #000;
  color:#fffde0;
}

body.tile-theme-side .nav_section,
body.tile-theme-side .right_section {
  background-image:url('../imgs/tile2.png');
  background-repeat:repeat;
  background-size:128px 128px;
  background-color:transparent;
}
body.tile-theme-side .nav_section *,
body.tile-theme-side .right_section * {
  color:#fffde0;
  text-shadow:1px 1px 2px #000;
}

/* Sprite guy */
.sprite-container {
  position:fixed;
  right:15px;
  bottom:120px;
  width:180px;
  height:180px;
  z-index:1000;
  pointer-events:none;
}
.sprite-animation.hidden {
  opacity:0;
  pointer-events:none;
}
.sprite-animation {
  width:256px;
  height:256px;
  background-image:url('../imgs/1_sprite_map.png');
  background-repeat:no-repeat;
  background-position:0 0;
  image-rendering:pixelated;
  animation-name: playSpriteLoop;
  animation-duration:1s;
  animation-timing-function: steps(9);
  animation-fill-mode:forwards;
  animation-play-state: paused;
}

/* Sprite anims */
@keyframes playSpriteLoop {
  from { background-position:-2304px 0; }
  to   { background-position:0 0; }
}
@keyframes moveRight {
  0%   { transform:translateX(0); }
  100% { transform:translateX(15px); }
}
.sprite-animation.playing {
  animation: playSpriteLoop 1s steps(9) forwards;
}
.sprite-container.moving {
  animation: moveRight 1s linear forwards;
}

@keyframes playSpriteReverse {
  from { background-position:0 0; }
  to   { background-position:-2304px 0; }
}
@keyframes moveLeft {
  0%   { transform:translateX(15px); }
  100% { transform:translateX(0); }
}
.sprite-animation.reverse {
  animation: playSpriteReverse 1s steps(9) forwards;
}
.sprite-container.returning {
  animation: moveLeft 1s linear forwards;
}

/* Mobile tumbler */
@media (max-width: 768px) {
  .right_section {
    width:100%;
    flex-direction:row;
    justify-content:center;
    gap:20px;
    padding:10px;
    border-top:2px solid #5D3A1A;
    border-left:none;
    min-height: 120px;
  }
  .tumbler-wrapper {
    flex-direction:row;
    align-items:center;
    justify-content:center;
    gap:15px;
    margin-bottom:0;
  }
  .tumbler {
    transform:rotate(-90deg);
    transform-origin:center;
    width:120px;
    height:120px;
    background-size:480px 120px;
    background-position:-360px 0;
  }
  .tumbler.on {
    background-position:0 0;
  }
  .tumbler-plate {
    width:auto;
    padding:4px 8px;
    font-size:12px;
    white-space:nowrap;
  }
  .tumbler-plate.on-label { order:0; }
  .tumbler { order:1; }
  .tumbler-plate.off-label { order:2; }
}

/* Portrait lock */
@media screen and (orientation: landscape) and (max-width: 1024px) {
  body::before {
    content:"Пожалуйста, поверните устройство вертикально 🙃";
    position:fixed;
    inset:0;
    background:#000;
    color:#fffde0;
    font-family:'PixeloidMono';
    font-size:16px;
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:999999;
    text-align:center;
    padding:20px;
    line-height:1.5;
  }
  body > * {
    display:none !important;
  }
}
