/* нормальный бокс-моделинг */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* CSS переменные для двух тем */
:root {
  /* Темная тема */
  --bg-color: #000;
  --text-color: #ffffff;
  --text-secondary: #eeeeee;
  --bg-blur: rgba(255,255,255,0.1);
  --bg-blur-hover: rgba(255,255,255,0.18);
  --bg-blur-strong: rgba(255,255,255,0.25);
  --border-color: rgba(255,255,255,0.15);
  --border-hover: rgba(255,255,255,0.3);
  --bg-image: url('https://i.postimg.cc/L8ZrFW6Z/b5085809d0aa1c6d263d9e3722aed869.jpg');
  --bg-blur-filter: blur(12px) brightness(0.6);
  --theme-transition: 0.3s ease;
  --card-bg: rgba(255,255,255,0.1);
  --card-text: #ffffff;
}

body.light-theme {
  /* Светлая тема */
  --bg-color: #f5f5f5;
  --text-color: #1a1a2e;
  --text-secondary: #2d2d44;
  --bg-blur: rgba(255,255,255,0.7);
  --bg-blur-hover: rgba(255,255,255,0.85);
  --bg-blur-strong: rgba(255,255,255,0.92);
  --border-color: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.15);
  --bg-image: url('https://i.postimg.cc/GhPYmykK/99px-ru-wallpaper-61968-lelush-lelouch-so-znakom-giassa-na.jpg');
  --bg-blur-filter: blur(12px) brightness(1.1);
  --card-bg: rgba(255,255,255,0.92);
  --card-text: #1a1a2e;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  color: var(--text-color);
  overflow-x: hidden;
  position: relative;
  transition: background-color var(--theme-transition), color var(--theme-transition);
}

/* Розмитий фон */
body::before {
  content: '';
  position: fixed;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: var(--bg-blur-filter);
  z-index: -1;
  pointer-events: none;
  transition: filter var(--theme-transition), background-image var(--theme-transition);
}

/* RU-blocked theme removed */

h1 {
  margin-top: clamp(1rem, 4vw, 2rem);
  margin-bottom: 0.8rem;
  font-size: clamp(1.8rem, 6vw, 3rem);
  text-align: center;
  text-shadow: 2px 2px 10px rgba(0,0,0,0.7);
  padding: 0 1rem;
  width: 100%;
  color: var(--text-color);
  transition: color var(--theme-transition);
}

/* Кнопка смены тем в правом верхнем углу */
.theme-toggle-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  background: var(--bg-blur-strong);
  color: var(--text-color);
  font-size: 1.4rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all var(--theme-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.theme-toggle-btn:hover {
  transform: scale(1.1) rotate(20deg);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  background: var(--bg-blur-hover);
}

.theme-toggle-btn:active {
  transform: scale(0.95) rotate(20deg);
}

@media (max-width: 640px) {
  .theme-toggle-btn {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}

/* Пошук */
.search-container {
  margin: 0 auto 1.2rem auto;
  width: 90%;
  max-width: 700px;
  padding: 0 1rem;
  order: 2;
}

#search,
.search-input {
  width: 100%;
  padding: 0.8rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-blur);
  color: var(--text-color);
  font-size: 1rem;
  backdrop-filter: blur(10px);
  transition: all var(--theme-transition);
}

#search:focus,
.search-input:focus {
  outline: none;
  background: var(--bg-blur-hover);
  border-color: var(--border-hover);
}

#search::placeholder,
.search-input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

body.light-theme #search::placeholder,
body.light-theme .search-input::placeholder {
  color: rgba(0, 0, 0, 0.5);
}

/* Вкладки */
.nav {
  margin-top: 0;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  padding: 0 1rem;
  order: 3;
}

.nav-btn {
  border: 1px solid var(--border-color);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  background: var(--bg-blur);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all var(--theme-transition);
}

.nav-btn:hover {
  background: var(--bg-blur-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.3);
}

.nav-btn.active {
  background: var(--bg-blur-strong);
  border-color: var(--border-hover);
  color: var(--text-color);
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(0,0,0,0.3);
}

.nav-btn.theme-btn {
  font-size: 1.1rem;
  padding: 0.5rem 0.9rem;
  min-width: 40px;
}

.page {
  width: 100%;
  display: none;
  order: 4;
}
.page.active { display: block; }

/* ===== УРОКИ ===== */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  width: 90%;
  max-width: 1200px;
  margin: 0 auto 3rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: 1.8rem;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 180px;
  transition: all 0.3s ease;
  position: relative;
  cursor: pointer;
  border: 2px solid var(--border-color);
  perspective: 1000px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 35px rgba(0,0,0,0.25);
  border-color: var(--border-hover);
}
.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  color: var(--card-text);
  line-height: 1.3;
}
.card-button {
  background: var(--bg-blur-hover);
  border: 1px solid var(--border-hover);
  color: var(--card-text);
  padding: 0.6rem 1rem;
  border-radius: 1rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  backdrop-filter: blur(5px);
  transition: all var(--theme-transition);
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
}
.card-button:hover {
  background: var(--bg-blur-strong);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===== ПАМ’ЯТКА / ШПОРИ / НОВИНИ ===== */
.info-container {
  width: 90%;
  max-width: 900px;
  margin: 2.5rem auto 3rem auto;
}

.memo-card {
  background: var(--bg-blur);
  backdrop-filter: blur(12px);
  border-radius: 1.8rem;
  padding: 1.4rem 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: 0.4rem;
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

.info-badge {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-bottom: 0.4rem;
}

.info-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.info-text {
  font-size: 0.95rem;
  line-height: 1.5;
}

.info-text strong { font-weight: 600; }

/* шпори */
.shpora-container {
  max-width: 1000px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

/* пасхалка */
.easter-egg {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 2rem 0 2.5rem 0;
}
.easter-egg img {
  max-width: 140px;
  opacity: 0.9;
  filter: drop-shadow(0 0 12px rgba(0,0,0,0.7));
}

/* Оверлей для блокування удален */

/* ===== УРОКИ (карточки улучшены) ===== */
@media (max-width: 768px) {
  body { align-items: stretch; }
  body::before { filter: blur(8px) brightness(0.6); }

  .nav {
    margin-top: 0.8rem;
    padding: 0 0.8rem;
    gap: 0.4rem;
  }
  .nav-btn {
    flex: 1 1 30%;
    text-align: center;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
  }

  .search-container {
    width: 100%;
    max-width: none;
    padding: 0 1rem;
    margin: 1rem auto 0.8rem auto;
  }

  #search, .search-input {
    padding: 0.6rem 0.9rem;
    font-size: 0.95rem;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    width: 100%;
    max-width: none;
    padding: 0 1rem 1.8rem 1rem;
    margin-bottom: 1.5rem;
  }

  .card {
    height: auto;
    padding: 0.8rem 0.9rem;
    border-radius: 1.2rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
  }

  .card-title {
    font-size: 1.05rem;
    text-align: left;
    flex: 1;
  }

  .card-button {
    font-size: 0.92rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    white-space: nowrap;
  }

  .info-container {
    width: 100%;
    max-width: none;
    padding: 0 1rem 2rem 1rem;
    margin: 1.8rem auto 2rem auto;
  }
  .memo-card {
    border-radius: 1.4rem;
    padding: 1.2rem 1.3rem;
  }
  .info-title { font-size: 1.1rem; }
  .info-text { font-size: 0.9rem; }

  .shpora-container {
    grid-template-columns: 1fr;
    gap: 1.2rem;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.4rem;
    padding: 0 0.8rem;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display:none; }

  .nav-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
  }

  .card {
    flex-direction: column;
    align-items: stretch;
  }
  .card-title { text-align: center; }
  .card-button { width: 100%; }
}


/* ===== КОМЕНТАРІ ===== */
.comments-container .comment-form-card {
  margin-bottom: 1.2rem;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.comment-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border-color);
  background: var(--bg-blur);
  color: var(--text-color);
  font-size: 1rem;
  outline: none;
}
.comment-input:focus {
  border-color: var(--border-hover);
  background: var(--bg-blur-hover);
}

.comments-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.6rem 0 1rem 0;
  padding: 0 0.2rem;
}

.comments-count {
  opacity: 0.8;
  font-size: 0.95rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comment-meta {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.comment-delete {
  margin-top: 0.6rem;
  cursor: pointer;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
  align-self: flex-end;
  transition: transform 0.15s ease, color 0.15s ease;
}
.comment-delete:hover {
  color: #fff;
  transform: scale(1.08);
}

.comment-hint {
  font-size: 0.85rem;
  opacity: 0.7;
  min-height: 1em;
}

/* Policy screen styles removed */

.policy-note {
  display: none; /* Policy screen deleted */
}

/* плавное появление карточек после загрузки */
.page.active .card,
.page.active .memo-card {
  opacity: 1;
  transform: translateY(0);
  animation: none;
}

body.site-loaded .page.active .card,
body.site-loaded .page.active .memo-card {
  animation: cardIn 0.45s ease forwards;
}

body.site-loaded .page.active .card:nth-child(2),
body.site-loaded .page.active .memo-card:nth-child(2) {
  animation-delay: 0.05s;
}
body.site-loaded .page.active .card:nth-child(3),
body.site-loaded .page.active .memo-card:nth-child(3) {
  animation-delay: 0.09s;
}
body.site-loaded .page.active .card:nth-child(4),
body.site-loaded .page.active .memo-card:nth-child(4) {
  animation-delay: 0.13s;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .theme-toggle-btn {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}
