/* =========================================================
   4HE / LAYOUT
   Site frame, header, sidebars and responsive shell
   ========================================================= */

/* =========================
   LAYOUT TOKENS
   ========================= */

:root {
  --layout-max-w: 1260px;
  --layout-left-w: 280px;
  --layout-main-w: 640px;
  --layout-right-w: 280px;
  --layout-gap: 30px;
  --layout-page-gap: 16px;
  --sidebar-top: calc(var(--header-h) + 8px);
}

/* =========================
   WRAPPER
   ========================= */

.wrapper {
  min-height: 100svh;
}

/* =========================
   HEADER
   ========================= */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  box-sizing: border-box;
  padding-right: var(--scrollbar-comp);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.site-header__inner {
  max-width: var(--layout-max-w);
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-header__left,
.site-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__left {
  flex: 1 1 auto;
  min-width: 0;
}

.site-header__right {
  flex: 0 0 auto;
}

.site-header__left-space {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}

.site-header__logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}

.site-header__logo:hover {
  color: var(--text);
  text-decoration: none;
}

.site-header__logo-image {
  width: auto;
  height: 38px;
  max-width: none;
  display: block;
  object-fit: contain;
}

.site-header__logo-mark,
.site-header__logo-text {
  display: none;
}

.site-header__icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    opacity 0.2s ease;
}

.site-header__icon-btn .i-svg {
  width: 23px;
  height: 23px;
}

.site-header__icon-btn:hover {
  background: var(--header-icon-bg-hover);
  color: var(--text);
  text-decoration: none;
}

.site-header__icon-btn:active {
  transform: scale(0.96);
}

.site-header__profile-wrap {
  position: relative;
}

.site-header__profile {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: transparent;
  overflow: hidden;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-header__profile img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 13px;
  object-fit: cover;
  object-position: center;
}

.site-header__profile--guest {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.site-header__profile--guest:hover {
  background: var(--surface-3);
}

.site-header__profile-guest-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
}

.site-header__profile-guest-icon .i-svg {
  width: 22px;
  height: 22px;
}

.site-header__burger {
  display: none;
  position: relative;
}

.site-header__burger span {
  position: absolute;
  left: 50%;
  width: 18px;
  height: 2px;
  margin-left: -9px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition:
    transform 0.22s ease,
    opacity 0.18s ease,
    background 0.18s ease;
}

.site-header__burger span:nth-child(1) {
  transform: translateY(-6px);
}

.site-header__burger span:nth-child(2) {
  transform: translateY(0);
}

.site-header__burger span:nth-child(3) {
  transform: translateY(6px);
}

.site-header__burger.is-active span:nth-child(1) {
  transform: translateY(0) rotate(45deg);
}

.site-header__burger.is-active span:nth-child(2) {
  opacity: 0;
  transform: translateY(0) scaleX(0.6);
}

.site-header__burger.is-active span:nth-child(3) {
  transform: translateY(0) rotate(-45deg);
}

/* =========================
   PROFILE DROPDOWN
   ========================= */

.site-profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 950;
  width: 320px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.16);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease;
}

.site-profile-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.theme-dark .site-profile-dropdown {
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.34);
}

/* =========================
   SEARCH OVERLAY
   ========================= */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.24s ease,
    visibility 0.24s ease;
}

.search-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.search-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-soft);
}

.search-overlay__panel {
  position: relative;
  max-width: var(--layout-max-w);
  margin: 0 auto;
  padding: 14px;
  transform: translateY(-18px);
  transition: transform 0.24s ease;
}

.search-overlay.is-open .search-overlay__panel {
  transform: translateY(0);
}

.search-overlay__top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.search-overlay__form {
  min-width: 0;
  height: 56px;
  padding: 0 12px 0 16px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.search-overlay__input {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
}

.search-overlay__input::placeholder {
  color: var(--text-fade);
}

.search-overlay__submit,
.search-overlay__close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.search-overlay__submit .i-svg,
.search-overlay__close .i-svg {
  width: 22px;
  height: 22px;
}

.search-overlay__submit:hover,
.search-overlay__close:hover {
  background: var(--surface-2);
  color: var(--accent-main);
}

.search-overlay__submit:active,
.search-overlay__close:active {
  transform: scale(0.96);
}

.search-overlay__close {
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.search-overlay__body {
  margin-top: 12px;
}

.search-overlay__block {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.search-overlay__title {
  margin-bottom: 12px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.search-overlay__recent {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-overlay__recent a {
  min-height: 34px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.search-overlay__recent a:hover {
  background: var(--accent-main-soft);
  color: var(--accent-main);
  text-decoration: none;
}

/* =========================
   MAIN LAYOUT
   ========================= */

.cols {
  max-width: var(--layout-max-w);
  margin: calc(var(--header-h) + var(--layout-page-gap)) auto 0;
  padding: var(--layout-page-gap) 0;
  display: grid;
  grid-template-columns: var(--layout-left-w) minmax(0, var(--layout-main-w)) var(--layout-right-w);
  gap: var(--layout-gap);
  justify-content: center;
}

.col_left {
  position: sticky;
  top: var(--sidebar-top);
  height: calc(100vh - var(--header-h) - 32px);
}

.col_main,
.col_right {
  min-width: 0;
}

.content,
.entry-item {
  display: grid;
  grid-template-columns: minmax(0, 100%);
  gap: 15px;
}

/* =========================
   MENU OVERLAY
   ========================= */

#menuOverlay {
  position: fixed;
  top: var(--header-h);
  left: 0;
  z-index: 700;
  width: 100%;
  height: calc(100vh - var(--header-h));
  padding: 0;
  border: 0;
  background: var(--overlay-soft);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

#menuOverlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* =========================
   LEFT SIDEBAR
   ========================= */

.sidebar {
  max-height: 100%;
  margin-left: 10px;
  margin-right: 16px;
  display: grid;
  row-gap: 16px;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.side_menu {
  padding: 10px;
  display: grid;
  row-gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.sidebar__title {
  padding: 4px 8px 8px;
  color: var(--text-fade);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side_menu_item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  text-decoration: none;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.side_menu_item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.side_menu_item:active {
  transform: scale(0.99);
}

.side_menu_active,
.side_menu_active:hover {
  background: var(--accent-main-soft);
  color: var(--accent-main);
}

.side_menu_icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition:
    color 0.16s ease,
    opacity 0.16s ease,
    transform 0.18s ease;
}

.side_menu_icon .i-svg,
.side_menu_icon .icon,
.side_menu_icon .ui-icon {
  width: 23px;
  height: 23px;
}

.side_menu_item:hover .side_menu_icon {
  color: var(--text);
}

.side_menu_active .side_menu_icon {
  color: var(--accent-main);
}

.side_menu_photo {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 10px;
}

.side_menu_photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.side_menu_category,
.side_menu_item > span:last-child {
  min-width: 0;
  color: inherit;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side_menu_more {
  margin-top: 2px;
}

.side_menu_more__hidden {
  display: none;
}

.side_menu_more.is-open .side_menu_more__hidden {
  display: grid;
  row-gap: 3px;
}

.side_menu_toggle {
  min-height: 32px;
  padding: 0 8px 0 6px;
  border-radius: 10px;
  justify-content: flex-start;
  gap: 8px;
  background: transparent !important;
  color: var(--text-soft);
}

.side_menu_toggle:hover {
  background: transparent !important;
  color: var(--accent-main);
}

.side_menu_toggle .side_menu_icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.side_menu_toggle .side_menu_icon .i-svg {
  width: 21px;
  height: 21px;
}

.side_menu_toggle .side_menu_category,
.side_menu_toggle > span:last-child {
  font-size: 13px;
  font-weight: 400;
}

.side_menu_toggle .i-svg {
  transition: transform 0.18s ease;
}

.side_menu_more.is-open .js-side-menu-toggle,
.side_menu_more.is-open .js-side-menu-toggle .side_menu_icon {
  color: var(--accent-main);
}

.side_menu_more.is-open .side_menu_toggle .i-svg {
  transform: rotate(180deg);
}

/* =========================
   RIGHT SIDEBAR
   ========================= */

.col_right_bg,
.col_right_bg_comm {
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}

.col_right_bg {
  padding: 14px 16px;
}

.col_right_bg_comm {
  padding: 14px 10px;
}

.col_right_bg_title {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.col_right_bg_title span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
}

.ads {
  position: sticky;
  top: var(--sidebar-top);
  width: 100%;
  max-height: 450px;
  padding: 0 10px;
  object-fit: contain;
}

/* =========================
   RESPONSIVE
   ========================= */

@media screen and (max-width: 1240px) {
  :root {
    --layout-left-w: 220px;
    --layout-gap: 24px;
  }

  .cols {
    max-width: 884px;
    grid-template-columns: var(--layout-left-w) minmax(0, var(--layout-main-w));
  }

  .col_right {
    display: none;
  }
}

@media screen and (max-width: 925px) {
  .site-header__burger {
    display: inline-flex;
  }

  .site-header__inner {
    padding: 0 12px;
    gap: 8px;
  }

  .site-header__left,
  .site-header__right {
    gap: 6px;
  }

  .cols {
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 16px 0;
  }

  .col_main {
    min-width: 0;
    margin-bottom: 0;
  }

  .col_right {
    display: none !important;
  }

  .col_left {
    position: fixed;
    top: var(--header-h);
    left: -320px;
    z-index: 800;
    width: 320px;
    max-width: 88vw;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
    background: var(--bg);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    transition: left 0.25s ease;
  }

  .col_left.open {
    left: 0;
  }

  .sidebar {
    max-height: none;
    margin: 0;
    padding-bottom: 18px;
    row-gap: 14px;
    overflow: visible;
  }

  .side_menu {
    padding: 10px;
    border-radius: 18px;
  }

  #menuOverlay {
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
  }
}

@media screen and (max-width: 768px) {
  .site-profile-dropdown {
    right: 0;
    width: min(320px, calc(100vw - 24px));
  }

  .search-overlay__top {
    gap: 8px;
  }

  .search-overlay__form {
    height: 54px;
    border-radius: 16px;
  }

  .search-overlay__block {
    border-radius: 16px;
  }
}

@media screen and (max-width: 640px) {
  .site-header__icon-btn,
  .site-header__profile {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .site-header__icon-btn .i-svg {
    width: 22px;
    height: 22px;
  }

  .site-header__profile img {
    border-radius: 12px;
  }

  .site-header__logo-image {
    height: 34px;
    max-width: 150px;
  }

  .site-profile-dropdown {
    right: -8px;
    width: min(320px, calc(100vw - 16px));
  }

  .cols {
    padding: 0 0 10px 0;
  }

  .col_left {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .sidebar {
    margin: 0;
    padding-bottom: 22px;
    row-gap: 12px;
  }

  .side_menu {
    padding: 9px;
    border-radius: 16px;
  }

  .sidebar__title {
    padding: 4px 8px 7px;
    font-size: 10px;
  }

  .side_menu_item {
    min-height: 40px;
    padding: 0 11px;
    gap: 10px;
    border-radius: 11px;
  }

  .side_menu_icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .side_menu_icon .i-svg,
  .side_menu_icon .icon,
  .side_menu_icon .ui-icon {
    width: 23px;
    height: 23px;
  }

  .side_menu_category,
  .side_menu_item > span:last-child {
    font-size: 13px;
  }

  .side_menu_photo {
    width: 26px;
    height: 26px;
    border-radius: 9px;
  }

  .search-overlay__panel {
    padding: 12px;
  }

  .search-overlay__form {
    height: 54px;
    padding: 0 12px 0 16px;
    border-radius: 16px;
  }

  .search-overlay__input {
    font-size: 16px;
  }

  .search-overlay__block {
    padding: 14px;
    border-radius: 16px;
  }

  .search-overlay__recent a {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* =========================
   REDUCED MOTION
   ========================= */

@media (prefers-reduced-motion: reduce) {
  .site-header__icon-btn,
  .site-header__burger span,
  .site-profile-dropdown,
  .search-overlay,
  .search-overlay__panel,
  .search-overlay__submit,
  .search-overlay__close,
  #menuOverlay,
  .col_left,
  .side_menu_item,
  .side_menu_icon,
  .side_menu_toggle .i-svg {
    transition: none !important;
  }
}