/* =====================================================================
   KIDBORG.RU — точечные дополнения.
   Основной css/style.css остаётся без изменений.
   ===================================================================== */

/* =================== ГОЛОГРАММЫ =================== */

.sec.active,
.sec.leaving {
  animation: none;
  transform-origin: 50% 50%;
}

.sec.active .sec-head h2 span,
.sec.leaving .sec-head h2 span {
  animation: none;
}

.sec.holo-moving {
  will-change: transform, opacity;
}

.sec.leaving {
  z-index: 20;
  pointer-events: none;
}

.sec.active:not(.leaving) {
  z-index: 21;
}

/*
 * Видимость каждой стороны задаётся явно в main.js.
 * Никакой надежды на скрытие обратной стороны браузером:
 * новая панель до торца имеет visibility:hidden.
 */
.sec.holo-turning {
  opacity: 1;
  filter: none;
  will-change: transform;
  transition: none;
  -webkit-backface-visibility: visible;
  backface-visibility: visible;
  pointer-events: none;
}

/* Неподвижное размытие для открытого раздела. */
#sectionFrost {
  position: fixed;
  top: 84px;
  bottom: 24px;
  left: max(24px, calc((100vw - 1240px) / 2));
  right: max(24px, calc((100vw - 1240px) / 2));
  z-index: 19;
  display: none;
  pointer-events: none;

  background: rgba(8, 18, 38, .12);

  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);

  clip-path: polygon(
    0 0,
    calc(100% - 28px) 0,
    100% 28px,
    100% 100%,
    28px 100%,
    0 calc(100% - 28px)
  );
}

body.in-section #sectionFrost {
  display: block;
}

.sec .sec-panel {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Во время оборота матовый фон следует за панелью. */
body.section-flipping #sectionFrost {
  visibility: hidden;
}

.sec.holo-turning .sec-panel {
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

@supports not (
  (backdrop-filter: blur(1px)) or
  (-webkit-backdrop-filter: blur(1px))
) {
  #sectionFrost {
    background: rgba(8, 18, 38, .88);
  }

  .sec.holo-turning .sec-panel {
    background: rgba(8, 18, 38, .94);
  }
}

/* =================== ОБЩИЕ ЦВЕТА ПЕРЕЛИВА =================== */

:root {
  --frame-sweep-colors:
    rgba(56, 232, 255, .30) 0deg,
    rgba(56, 232, 255, .30) 268deg,
    rgba(56, 232, 255, .85) 294deg,
    #ff9f1c 321deg,
    #ffc14d 340deg,
    #fff0d3 348deg,
    #ff9f1c 355deg,
    rgba(56, 232, 255, .30) 360deg;
}

/* =================== ИЗОБРАЖЕНИЯ: ДОСТИЖЕНИЯ / КУРСЫ =================== */

@property --media-frame-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

#diplomasWrap .diploma-contour {
  display: none;
}

#diplomasWrap .card .thumb::before,
#coursesWrap .card .thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  box-sizing: border-box;
  padding: 1px;
  border: 0;
  pointer-events: none;
  opacity: 0;

  background: conic-gradient(
    from var(--media-frame-angle),
    var(--frame-sweep-colors)
  );

  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;

  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;

  filter: none;
  transform: none;
  transition: none;
  animation: none;
}

#diplomasWrap .card .thumb:hover::before,
#coursesWrap .card .thumb:hover::before {
  animation:
    mediaFrameRotation 1.8s linear 1s 1 both,
    frameSweepVisibility 1.8s ease-in-out 1s 1 both;
}

@keyframes mediaFrameRotation {
  from {
    --media-frame-angle: 0deg;
  }

  to {
    --media-frame-angle: 360deg;
  }
}

#diplomasWrap .diploma-tag {
  text-align: right;
  overflow-wrap: anywhere;
}

/* =================== БОЛЬШАЯ РАМКА ВСЕХ РАЗДЕЛОВ =================== */

@property --section-frame-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.sec .sec-panel {
  --section-frame-cut: 28px;
  --section-frame-inner-cut: 27.4px;
}

.sec.active .sec-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  padding: 0;
  border: 0;

  background: conic-gradient(
    from var(--section-frame-angle),
    var(--frame-sweep-colors)
  );

  background-size: 100% 100%;
  background-position: 0 0;
  background-repeat: no-repeat;

  clip-path: polygon(
    evenodd,

    0 0,
    calc(100% - var(--section-frame-cut)) 0,
    100% var(--section-frame-cut),
    100% 100%,
    var(--section-frame-cut) 100%,
    0 calc(100% - var(--section-frame-cut)),
    0 0,

    1.5px 1.5px,
    calc(100% - var(--section-frame-inner-cut)) 1.5px,
    calc(100% - 1.5px) var(--section-frame-inner-cut),
    calc(100% - 1.5px) calc(100% - 1.5px),
    var(--section-frame-inner-cut) calc(100% - 1.5px),
    1.5px calc(100% - var(--section-frame-inner-cut)),
    1.5px 1.5px,

    0 0
  );

  animation:
    sectionFrameRotation 1.8s linear var(--section-frame-delay, 1.45s) 1 both,
    frameSweepVisibility 1.8s ease-in-out var(--section-frame-delay, 1.45s) 1 both;
}

@keyframes sectionFrameRotation {
  from {
    --section-frame-angle: 0deg;
  }

  to {
    --section-frame-angle: 360deg;
  }
}

@keyframes frameSweepVisibility {
  0% {
    opacity: 0;
  }

  7% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.sec.active.holo-turning .sec-panel::after,
.sec.active.leaving .sec-panel::after {
  animation: none;
  opacity: 0;
}

/* =================== MP3-ПЛЕЕР =================== */

#musicPlayer {
  position: fixed;
  top: 82px;
  right: 62px;
  z-index: 35;
  width: 108px;
  color: var(--text);

  background:
    linear-gradient(
      135deg,
      rgba(56, 232, 255, .045),
      rgba(255, 159, 28, .025)
    ),
    rgba(8, 18, 34, .50);

  -webkit-backdrop-filter: blur(18px) saturate(.75);
  backdrop-filter: blur(18px) saturate(.75);

  border: 1px solid rgba(56, 232, 255, .32);
  border-radius: 4px;

  box-shadow:
    0 4px 18px rgba(0, 0, 0, .16),
    inset 0 1px 0 rgba(255, 255, 255, .035);

  font: 400 10px var(--f-mono);
}

#musicPlayer[hidden],
#musicPlayer [hidden] {
  display: none !important;
}

#musicPlayer.expanded {
  width: min(224px, calc(100vw - 86px));
}

#musicPlayer .mp-top {
  display: flex;
  align-items: stretch;
  min-height: 29px;
}

#musicPlayer button {
  color: var(--cyan);

  transition:
    color .2s ease,
    background .2s ease,
    border-color .2s ease,
    box-shadow .2s ease;
}

#musicPlayer button:hover {
  color: var(--orange);
  background: rgba(255, 159, 28, .07);
}

#musicPlayer button:focus-visible,
#musicPlayer select:focus-visible,
#musicPlayer input:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

#mpToggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 29px;
  padding: 5px 7px;
  font: 700 10px var(--f-head);
  letter-spacing: .09em;
}

.mp-led {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}

#musicPlayer.playing .mp-led {
  background: var(--cyan);
  box-shadow: 0 0 7px var(--cyan);
  animation: mpLedPulse 1.2s ease-in-out infinite alternate;
}

#musicPlayer.playing.muted .mp-led {
  background: var(--orange);
  box-shadow: 0 0 7px var(--orange);
}

@keyframes mpLedPulse {
  from {
    opacity: .45;
  }

  to {
    opacity: 1;
  }
}

.mp-chevron {
  display: inline-block;
  color: var(--orange);
  font: 600 13px var(--f-mono);
  transition: transform .2s ease;
}

#musicPlayer.expanded .mp-chevron {
  transform: rotate(180deg);
}

#mpMute {
  display: grid;
  place-items: center;
  flex: 0 0 29px;
  min-height: 29px;
  border-left: 1px solid var(--line);
}

#mpMute svg {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#mpMute .mp-sound-off {
  display: none;
}

#musicPlayer.muted #mpMute {
  color: var(--orange);
}

#musicPlayer.muted .mp-sound-waves {
  display: none;
}

#musicPlayer.muted .mp-sound-off {
  display: block;
}

/* =================== ОКНО АУДИОВИЗУАЛИЗАТОРА =================== */

#musicPlayer .mp-visualizer {
  position: relative;
  height: 34px;
  margin: 0 6px 5px;
  overflow: hidden;
  border: 1px solid rgba(56, 232, 255, .16);
  border-radius: 2px;

  background:
    linear-gradient(
      180deg,
      rgba(56, 232, 255, .025),
      rgba(255, 159, 28, .035)
    ),
    rgba(3, 9, 19, .22);

  box-shadow: inset 0 0 9px rgba(0, 0, 0, .18);
  pointer-events: none;
}

#musicPlayer.expanded .mp-visualizer {
  height: 42px;
  margin-left: 8px;
  margin-right: 8px;
}

#mpSpectrum {
  display: block;
  width: 100%;
  height: 100%;
}

/* =================== УПРАВЛЕНИЕ ПЛЕЕРОМ =================== */

#mpBody {
  border-top: 1px solid rgba(56, 232, 255, .18);
  padding: 8px;
  max-height: calc(100dvh - 176px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) transparent;
}

.mp-demos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

#musicPlayer .mp-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 25px;
  padding: 4px;
  border: 1px solid rgba(56, 232, 255, .22);
  border-radius: 2px;
  text-align: center;
  background: rgba(56, 232, 255, .025);
}

.mp-demo span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 9px var(--f-mono);
}

#musicPlayer .mp-demo.selected {
  border-color: rgba(255, 159, 28, .75);
  box-shadow: inset 0 0 9px rgba(255, 159, 28, .07);
}

#musicPlayer .mp-demo[aria-pressed="true"] {
  background: rgba(56, 232, 255, .09);
}

#mpPlaylist {
  display: block;
  width: 100%;
  min-width: 0;
  height: 26px;
  padding: 3px 5px;
  border: 1px solid rgba(56, 232, 255, .22);
  border-radius: 2px;
  color: var(--text);
  background: rgba(5, 12, 25, .34);
  font: 400 10px var(--f-mono);
  color-scheme: dark;
}

#mpPlaylist option {
  color: var(--text);
  background: #0a1428;
}

.mp-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0 3px;
}

#musicPlayer .mp-controls button {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(56, 232, 255, .22);
  border-radius: 2px;
  font: 600 18px var(--f-mono);
}

#musicPlayer #mpPlay {
  border-color: rgba(255, 159, 28, .45);
  color: var(--orange);
  font-size: 12px;
}

#mpTime {
  margin-left: auto;
  color: var(--muted);
  white-space: nowrap;
  font: 400 9px var(--f-mono);
}

#musicPlayer input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 14px;
  padding: 0;
  accent-color: var(--cyan);
  cursor: pointer;
}

#musicPlayer input[type="range"]:disabled {
  opacity: .4;
}

.mp-volume {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0 5px;
}

.mp-volume label {
  flex: 0 0 auto;
  color: var(--orange);
  font-size: 9px;
  letter-spacing: .06em;
}

#musicPlayer #mpVolume {
  accent-color: var(--orange);
}

#mpUpload {
  width: 100%;
  min-height: 25px;
  padding: 4px 6px;
  border: 1px solid rgba(56, 232, 255, .22);
  border-radius: 2px;
  font: 600 9px var(--f-mono);
  letter-spacing: .04em;
}

#musicPlayer .mp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* =================== АДАПТИВНОСТЬ =================== */

@media (max-width: 980px) {
  #musicPlayer {
    right: 18px;
  }

  #musicPlayer.expanded {
    width: min(224px, calc(100vw - 36px));
  }
}

@media (max-width: 768px) {
  #sectionFrost {
    top: 70px;
    bottom: 8px;
    left: 8px;
    right: 8px;

    clip-path: polygon(
      0 0,
      calc(100% - 16px) 0,
      100% 16px,
      100% 100%,
      16px 100%,
      0 calc(100% - 16px)
    );
  }

  .sec .sec-panel {
    --section-frame-cut: 16px;
    --section-frame-inner-cut: 15.4px;
  }

  #musicPlayer {
    top: 72px;
    right: 12px;
    width: 108px;
  }

  #musicPlayer.expanded {
    width: min(224px, calc(100vw - 24px));
  }

  #mpBody {
    max-height: calc(100dvh - 160px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #musicPlayer.playing .mp-led {
    animation: none;
  }

  #diplomasWrap .card .thumb:hover::before,
  #coursesWrap .card .thumb:hover::before,
  .sec.active .sec-panel::after {
    animation: none;
    opacity: 0;
  }
}

/* =================== AI-ЧАТ =================== */

#sec-ai .ai-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ai-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: min(960px, 100%);
  margin: 0 auto;
  transform: translateX(30px);

  border: 1px solid var(--line);
  background: rgba(3, 10, 22, .64);
  box-shadow: inset 0 0 40px rgba(56, 232, 255, .025);
}

.ai-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(56, 232, 255, .035);
}

.ai-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-brand b {
  display: block;
  color: var(--cyan);
  font: 700 12px var(--f-head);
  letter-spacing: .12em;
}

.ai-brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font: 400 10px var(--f-mono);
}

.ai-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px rgba(255, 159, 28, .65);
}

#aiClear {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--cyan);
  font: 600 10px var(--f-mono);
  transition: .2s;
}

#aiClear:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.ai-messages {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) transparent;
}

.ai-message {
  flex: 0 0 auto;
  width: fit-content;
  max-width: 88%;
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: rgba(11, 28, 49, .75);
}

.ai-message-assistant {
  align-self: flex-start;
  border-radius: 2px 12px 12px 12px;
}

.ai-message-user {
  align-self: flex-end;
  border-color: rgba(255, 159, 28, .32);
  border-radius: 12px 2px 12px 12px;
  background: rgba(255, 159, 28, .065);
}

.ai-message-author {
  margin-bottom: 7px;
  color: var(--cyan);
  font: 700 10px var(--f-mono);
  letter-spacing: .14em;
}

.ai-message-user .ai-message-author {
  color: var(--orange);
}

.ai-message-text {
  color: var(--text);
  font: 400 15px/1.65 var(--f-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

.ai-pending .ai-message-text {
  color: var(--muted);
}

.ai-message-failed {
  border-style: dashed;
}

.ai-status {
  padding: 0 20px 10px;
  color: var(--muted);
  font: 400 10px var(--f-mono);
}

.ai-input {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(3, 10, 22, .8);
}

.ai-input textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(56, 232, 255, .02);
  color: var(--text);
  font: 400 15px var(--f-body);
  resize: none;
  transition: .2s;
}

.ai-input textarea:focus {
  border-color: var(--cyan);
  outline: none;
  background: rgba(56, 232, 255, .05);
}

.ai-input button {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  background: rgba(56, 232, 255, .08);
  color: var(--cyan);
  font: 700 12px var(--f-head);
  letter-spacing: .08em;
  transition: .2s;
}

.ai-input button:hover:not(:disabled) {
  background: var(--cyan);
  color: #030a16;
}

.ai-input button:disabled {
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
  cursor: not-allowed;
}

@keyframes aiBlink {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px rgba(56, 232, 255, .65); }
  50% { opacity: .4; box-shadow: none; }
}

.ai-thinking .ai-indicator {
  background: var(--cyan);
  animation: aiBlink 1s infinite ease-in-out;
}