/* style.css */

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

html, body {
  height: 100%;
  background: #0a1f0a;
  color: #00ff41;
  font-family: 'VT323', monospace;
  font-size: 1rem;
  line-height: 1.45;
  overflow-x: hidden;
}

body {
  position: relative;
  background: radial-gradient(circle at 50% 50%, #0f2e0f, #000);
}

.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 50%,
    rgba(0, 255, 65, 0.06) 50%,
    rgba(0, 255, 65, 0.06) 51%,
    transparent 51%
  );
  background-size: 100% 4px;
  animation: scan 8s linear infinite;
  z-index: 9999;
  opacity: 0.5;
}

@keyframes scan {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

@keyframes heal-flash {
  0%, 100% { text-shadow: 0 0 20px #00ffff; }
  50%      { text-shadow: 0 0 40px #00ffff, 0 0 60px #00aaff; }
}

#health.critical {
  animation: critical-pulse 1.2s infinite alternate;
}

@keyframes critical-pulse {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0.75; transform: scale(1.04); }
}

.pipboy-header {
  text-align: center;
  padding: 1.2rem 1rem 0.8rem;
  border-bottom: 2px solid #00cc33;
  box-shadow: 0 4px 12px #00ff4133;
  position: relative;
  z-index: 10;
  background: rgba(0, 15, 0, 0.7);
}

.status-bar {
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  max-width: 640px;
  margin: 0 auto 0.4rem;
  opacity: 0.8;
}

.status-bar span {
  transition: opacity 0.2s linear;
}

h1 {
  font-size: 4.8rem;
  letter-spacing: 0.25em;
  text-shadow: 0 0 20px #00ff41, 0 0 40px #00cc33;
  margin: 0.2rem 0;
}

h1 span {
  color: #00cc33;
  text-shadow: 0 0 30px #00cc33;
}

.subtitle {
  font-size: 1.6rem;
  letter-spacing: 0.4em;
  opacity: 0.85;
  margin-bottom: 0.8rem;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.terminal {
  background: rgba(0,0,0,0.4);
  border: 1px solid #00aa22;
  padding: 1.4rem;
  margin: 1.5rem auto;
  max-width: 720px;
  box-shadow: inset 0 0 30px #001100;
}

h2 {
  text-align: center;
  font-size: 2.6rem;
  margin: 2rem 0 1.5rem;
  text-shadow: 0 0 15px #00ff41;
  letter-spacing: 0.15em;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.8rem;
  margin: 2rem 0;
}

.project-card {
  background: rgba(0, 20, 0, 0.65);
  border: 1px solid #008822;
  padding: 1.1rem;
  transition: all 0.13s ease;
  position: relative;
  overflow: hidden;
}

.project-card:hover {
  border-color: #00ff41;
  box-shadow: 0 0 25px #00ff4150;
  transform: translateY(-6px);
}

.screenshot-placeholder {
  height: 180px;
  background: #000;
  border: 1px dashed #004411;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #003300;
  background: repeating-linear-gradient(
    45deg,
    #000 0,
    #000 10px,
    #001100 10px,
    #001100 20px
  );
}

/* Контейнер — используем аппаратное ускорение */
.screenshot-slider {
  position: relative;
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #000;
  border: 2px solid #003300;
  margin-bottom: 1rem;
  border-radius: 3px;
  /* Заменяем тяжелый box-shadow на более простой */
  box-shadow: inset 0 0 20px #001100;
  /* Force GPU rendering */
  transform: translateZ(0);
}

/* Обертка для слайдов */
.screenshot-slider .slides-wrapper {
  position: absolute;
  inset: 0;
  /* Анимируем только transform — это дешево */
  animation: crt-damage 12s infinite linear; 
  will-change: transform;
}

.screenshot-slider img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  /* Убираем sepia/contrast отсюда и переносим на родителя */
}

.screenshot-slider img.active {
  opacity: 1;
}

/* ОПТИМИЗАЦИЯ: Сканирующие линии и мерцание в одном слое */
.screenshot-slider::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Вместо mix-blend-mode используем полупрозрачный градиент */
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 255, 65, 0.15) 2px,
    rgba(0, 255, 65, 0.15) 3px
  );
  background-size: 100% 4px;
  z-index: 10;
  /* Снижаем частоту мерцания для экономии ресурсов */
  animation: scan-flicker 2s infinite;
  will-change: opacity;
}

/* ОПТИМИЗАЦИЯ: Статичный шум вместо SVG-турбулентности */
.screenshot-slider .crt-noise {
  position: absolute;
  inset: -50%; /* Запас для анимации смещения */
  pointer-events: none;
  /* Используем Base64 очень легкого шума (около 1kb) */
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAAAAAC0m76nAAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQflChYSEiInN8daAAAAPklEQVQ4y2P4v4mBgcH/f8R4A8P/f8RgA8P/f8RgA8P/f8RgA8P/f8RgA8P/f8RgA8P/f8RgA8P/f8RgA8P/f8R4AwB6Xkz79T69pAAAAABJRU5ErkJggg==');
  background-size: 100px 100px;
  opacity: 0.8;
  z-index: 11;
  animation: noise-move 0.2s steps(2) infinite;
}

/* Упрощенная виньетка */
.screenshot-slider::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle,
    transparent 40%,
    rgba(0, 0, 0, 0.8) 100%
  );
  z-index: 9;
}

/* Эффект старого экрана через фильтры на весь контейнер */
.screenshot-slider {
  filter: brightness(0.9) contrast(1.1) sepia(0.5) hue-rotate(10deg);
}

/* --- ОПТИМИЗИРОВАННЫЕ АНИМАЦИИ --- */

@keyframes crt-damage {
  0%, 100% { transform: scale(1.01) translate(0,0); }
  33% { transform: scale(1.02) translate(0.5%, 0.5%) rotate(0.1deg); }
  66% { transform: scale(1.015) translate(-0.5%, -0.2%) rotate(-0.1deg); }
}

@keyframes scan-flicker {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

@keyframes noise-move {
  0% { transform: translate(0,0); }
  100% { transform: translate(10px, 10px); }
}

/* Остановка всех анимаций внутри слайдера, если он не виден */
.screenshot-slider.is-paused *,
.screenshot-slider.is-paused::before,
.screenshot-slider.is-paused::after {
    animation-play-state: paused !important;
}

.no-screenshots {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #004411;
  font-size: 1.1rem;
  background: repeating-linear-gradient(
    45deg,
    #000 0,
    #000 10px,
    #001100 10px,
    #001100 20px
  );
}

.project-card h3 {
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
  color: #33ff77;
}

.links {
  margin-top: 1rem;
  display: flex;
  gap: 1.2rem;
  justify-content: center;
}

.links a, .links-big a {
  color: #00ff41;
  text-decoration: none;
  border: 1px solid #006600;
  padding: 0.5rem 1.1rem;
  transition: all 0.15s;
}

.links a:hover, .links-big a:hover {
  background: #00ff4122;
  border-color: #00ff41;
  box-shadow: 0 0 15px #00ff4166;
}

.links-big {
  text-align: center;
  margin: 2.5rem 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 2.5rem;
}

.links-big a {
  font-size: 1.7rem;
  padding: 0.7rem 1.6rem;
}

footer {
  text-align: center;
  padding: 2.5rem 1rem 4rem;
  color: #006600;
  font-size: 1.2rem;
}

.radiation-symbol {
  font-size: 4rem;
  opacity: 0.15;
  margin-bottom: 0.8rem;
  transition: opacity 0.05s linear;
  text-shadow: 0 0 3px rgba(0,255,0,0.4);
}

@keyframes glitch {
  0%   { transform: translate(0); }
  20%  { transform: translate(-1px, 1px); }
  40%  { transform: translate(1px, -1px); }
  60%  { transform: translate(-1px, -1px); }
  80%  { transform: translate(1px, 1px); }
  100% { transform: translate(0); }
}

.glitch {
  animation: glitch 0.12s steps(2) infinite;
  text-shadow:
    2px 0 rgba(0,255,65,0.6),
   -2px 0 rgba(0,200,51,0.6);
}

.boot-screen {
  position: fixed;
  inset: 0;
  background: #020a04;
  color: #00ff41;
  font-family: monospace;
  font-size: 1rem;
  padding: 2rem;
  z-index: 9999;
}

.boot-screen pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.4;
}

.hidden {
  display: none;
}

/* .boot-cursor::after {
  content: '';
  animation: blink 1s steps(1) infinite;
} */

@keyframes blink {
  50% { opacity: 0; }
}

.reboot-button {
  margin-left: 12px;
  padding: 2px 8px;
  background: #0f0;
  color: #000;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  cursor: pointer;
  border: 2px solid #0f0;
  border-radius: 0;
  user-select: none;
  transition: all 0.12s;
}

.reboot-button:hover {
  background: #0c0;
  box-shadow: 0 0 10px #0f0;
}

.reboot-button:active {
  background: #080;
  transform: scale(0.97);
}

#ai-terminal {
  display: flex;
  flex-direction: column;
  height: 20em;                /* начальная высота */
  max-height: 85vh;            /* не выше экрана */
  background: rgba(0,0,0,0.4);
  border: 1px solid #00aa22;
  padding: 1.4rem;
  margin: 1.5rem auto;
  max-width: 720px;
  box-shadow: inset 0 0 30px #001100;
  position: relative;
  overflow: hidden;
}

#ai-terminal.expanded {
  height: 50em;
  max-height: 85vh;
}

#term-output {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 0.5rem;       /* место под возможный скроллбар */
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: #00aa22 #001100;
}

#term-output::-webkit-scrollbar {
  width: 6px;
}

#term-output::-webkit-scrollbar-track {
  background: #001100;
}

#term-output::-webkit-scrollbar-thumb {
  background: #00aa22;
  border-radius: 3px;
}

.term-input {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding-top: 0.6rem;
  border-top: 1px solid #004411;
  flex-shrink: 0;
}

.term-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: #00ff41;
  outline: none;
  font-family: inherit;
  font-size: 1.1rem;
}

.term-input input::placeholder {
  color: hsl(135, 79%, 17%);
  font-family: inherit;
  font-style: italic;
}

#term-expand {
  position: absolute;
  right: 8px;
  top: 8px;
  background: #003300;
  color: #00ff41;
  border: 1px solid #00aa22;
  padding: 0.3rem 0.3em;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 5;
}

#term-output p.user {
  color: #aaffaa;
}

#term-output p.ai-response {
  color: #88ff88;
  margin-left: 1.4em;
}

#term-output p.error {
  color: #ff4444;
  font-weight: bold;
}

/* #term-output p.cursor::after {
  content: '▮';
  animation: blink 1s steps(1) infinite;
} */


/* Адаптивность */

@media (max-width: 680px) {
  h1 { font-size: 2.8rem; letter-spacing: 0.18em; }
  .subtitle { font-size: 1rem; letter-spacing: 0.3em; }
  .project-grid { grid-template-columns: 1fr; }
  .status-bar { font-size: 0.8rem; flex-direction: row; gap: 0.4rem; }
  h2 {font-size: 1.6rem;}
  .links-big a {font-size: 1rem; padding: 0.4rem 0.4rem;}
}

.boot-screen {font-size: 0.7rem; padding: 1.2rem;}