/* artempochemy — базовая тема: монохром, японский минимализм (間 · суми), двоичный слой */
:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --fg: #f5f5f5;
  --fg-muted: rgba(245, 245, 245, 0.68);
  --line: rgba(255, 255, 255, 0.18);
  --line-strong: rgba(255, 255, 255, 0.42);
  --binary: rgba(255, 255, 255, 0.09);
  --binary-bright: rgba(255, 255, 255, 0.16);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: "Geist Variable", "Geist", "Noto Sans JP", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-jp: "Noto Sans JP", "Geist Variable", sans-serif;
  --container: 1120px;
  --gutter: 24px;
  --ma-section: 5rem;
  --intro-total: 6400ms;
  --reveal-duration: 1.15s;
  --reveal-header-delay: 0.08s;
  --reveal-main-delay: 0.22s;
  /* Тема: слои поверх фона */
  --precision-scrim: linear-gradient(to bottom, rgba(10, 10, 10, 0.65), rgba(10, 10, 10, 0.88));
  --precision-scan: rgba(255, 255, 255, 0.02);
  --page-grid-line: rgba(255, 255, 255, 0.02);
  --noise-fine: rgba(255, 255, 255, 0.03);
  --noise-grid: rgba(255, 255, 255, 0.02);
  --noise-grid-md: rgba(255, 255, 255, 0.018);
  --noise-radial: rgba(255, 255, 255, 0.04);
  --noise-blend: screen;
  --noise-opacity: 0.35;
  --card-fill: rgba(255, 255, 255, 0.02);
  --card-shine: rgba(255, 255, 255, 0.04);
  --card-shadow: rgba(255, 255, 255, 0.06);
  --surface-panel: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  /* Подсветка в слое лепестков (тёмный фон) */
  --decor-petal-glow-a: rgba(255, 255, 255, 0.14);
  --decor-petal-glow-b: rgba(255, 255, 255, 0.12);
  --decor-petal-glow-c: rgba(255, 255, 255, 0.1);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ddd9d3;
  --bg-elevated: #e8e5e0;
  --fg: #10100f;
  --fg-muted: rgba(16, 16, 15, 0.76);
  --line: rgba(16, 16, 15, 0.16);
  --line-strong: rgba(16, 16, 15, 0.34);
  --binary: rgba(16, 16, 15, 0.11);
  --binary-bright: rgba(16, 16, 15, 0.2);
  --precision-scrim: linear-gradient(to bottom, rgba(221, 217, 211, 0.45), rgba(221, 217, 211, 0.82));
  --precision-scan: rgba(16, 16, 15, 0.055);
  --page-grid-line: rgba(16, 16, 15, 0.07);
  --noise-fine: rgba(0, 0, 0, 0.045);
  --noise-grid: rgba(0, 0, 0, 0.038);
  --noise-grid-md: rgba(0, 0, 0, 0.034);
  --noise-radial: rgba(0, 0, 0, 0.07);
  --noise-blend: multiply;
  --noise-opacity: 0.26;
  --card-fill: rgba(0, 0, 0, 0.055);
  --card-shine: rgba(0, 0, 0, 0.08);
  --card-shadow: rgba(0, 0, 0, 0.12);
  --surface-panel: rgba(0, 0, 0, 0.06);
  --surface-hover: rgba(0, 0, 0, 0.09);
  --decor-petal-glow-a: rgba(42, 40, 38, 0.14);
  --decor-petal-glow-b: rgba(38, 36, 34, 0.11);
  --decor-petal-glow-c: rgba(34, 32, 30, 0.09);
}

/* Токены сетки по ширине экрана: ноутбук / планшет / телефон */
@media (max-width: 1024px) {
  :root {
    --gutter: 20px;
    --ma-section: 4.25rem;
  }
}

@media (max-width: 560px) {
  :root {
    --gutter: 16px;
    --ma-section: 3rem;
  }
}

@media (min-width: 1440px) {
  :root {
    --container: 1200px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  color: var(--fg);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  /* Иначе fixed с z-index: -1 уходит под canvas/html и декор «пропадает» */
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
select,
[contenteditable="true"],
.allow-copy {
  -webkit-user-select: text;
  user-select: text;
}

/* Фон: дома + сакура + самурай строго позади контента (z-index: -1) */
.scene-depth {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.scene-depth__houses {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("../assets/decor/jp-skyline.svg");
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: 100% auto;
  opacity: 0.2;
  filter: grayscale(1);
  -webkit-mask-image: linear-gradient(
    to top,
    black 0%,
    black min(52%, 380px),
    rgba(0, 0, 0, 0.78) 68%,
    transparent 92%
  );
  mask-image: linear-gradient(
    to top,
    black 0%,
    black min(52%, 380px),
    rgba(0, 0, 0, 0.78) 68%,
    transparent 92%
  );
}

.scene-depth__houses::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../assets/decor/jp-skyline.svg");
  background-repeat: no-repeat;
  background-position: center 72%;
  background-size: 135% auto;
  opacity: 0.45;
  filter: grayscale(1);
  -webkit-mask-image: radial-gradient(ellipse 85% 55% at 50% 58%, black 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 85% 55% at 50% 58%, black 0%, transparent 72%);
}

.scene-depth__petals {
  position: absolute;
  inset: -6%;
  z-index: 1;
  opacity: 0.22;
  background-image:
    url("../assets/decor/sakura-petals-drift.svg"),
    url("../assets/decor/sakura-petals-drift.svg"),
    url("../assets/decor/sakura-petals-drift.svg"),
    url("../assets/decor/sakura-petals-drift.svg"),
    radial-gradient(ellipse 100px 52px at 18% 38%, var(--decor-petal-glow-a), transparent 70%),
    radial-gradient(ellipse 80px 44px at 88% 22%, var(--decor-petal-glow-b), transparent 68%),
    radial-gradient(ellipse 70px 36px at 55% 82%, var(--decor-petal-glow-c), transparent 65%);
  background-repeat: no-repeat;
  background-position:
    6% 14%,
    78% 28%,
    42% 56%,
    92% 72%,
    0 0,
    0 0,
    0 0;
  background-size:
    min(340px, 42vw) auto,
    min(300px, 38vw) auto,
    min(320px, 40vw) auto,
    min(280px, 36vw) auto,
    100% 100%,
    100% 100%,
    100% 100%;
  filter: grayscale(1);
}

.scene-depth__sakura {
  position: absolute;
  inset: -10%;
  z-index: 2;
  opacity: 0.28;
  background-image:
    url("../assets/decor/sakura-tr.svg"),
    url("../assets/decor/sakura-bl.svg"),
    url("../assets/decor/sakura-tl.svg"),
    url("../assets/decor/sakura-br.svg"),
    url("../assets/decor/sakura-mid.svg"),
    url("../assets/decor/sakura-tr.svg"),
    url("../assets/decor/sakura-bl.svg"),
    url("../assets/decor/sakura-mid.svg");
  background-repeat: no-repeat;
  background-position:
    calc(100% + 8px) -4%,
    -8% calc(100% + 4%),
    -6% -4%,
    calc(100% + 4%) calc(100% + 2%),
    50% -4%,
    92% 48%,
    12% 42%,
    48% 88%;
  background-size:
    min(52vw, 500px) auto,
    min(48vw, 460px) auto,
    min(44vw, 420px) auto,
    min(46vw, 440px) auto,
    min(118vw, 1180px) auto,
    min(38vw, 360px) auto,
    min(36vw, 340px) auto,
    min(95vw, 920px) auto;
  filter: grayscale(1);
}

.scene-depth__samurai {
  position: absolute;
  bottom: -6%;
  right: clamp(24px, 7vw, 88px);
  z-index: 3;
  width: min(220px, 24vw);
  height: min(460px, 52vh);
  opacity: 0.24;
  background: url("../assets/decor/samurai-full.svg") center bottom / contain no-repeat;
  filter: grayscale(1);
}

/* Светлая тема: приглушённый фон + сакура/силуэты заметны, как «тушь» на бумаге */
html[data-theme="light"] .scene-depth__sakura {
  opacity: 0.36;
  filter: grayscale(1) brightness(0.4) contrast(1.18);
}

html[data-theme="light"] .scene-depth__petals {
  opacity: 0.3;
  filter: grayscale(1) brightness(0.46) contrast(1.12);
}

html[data-theme="light"] .scene-depth__houses {
  opacity: 0.24;
  filter: grayscale(1) brightness(0.52) contrast(1.06);
}

html[data-theme="light"] .scene-depth__houses::after {
  opacity: 0.5;
  filter: grayscale(1) brightness(0.52) contrast(1.06);
}

html[data-theme="light"] .scene-depth__samurai {
  opacity: 0.28;
  filter: grayscale(1) brightness(0.44) contrast(1.1);
}

@media (max-width: 640px) {
  .scene-depth__houses {
    opacity: 0.16;
    background-size: 140% auto;
  }

  .scene-depth__houses::after {
    opacity: 0.35;
    background-size: 180% auto;
  }

  .scene-depth__petals {
    opacity: 0.17;
    background-size:
      min(280px, 72vw) auto,
      min(260px, 68vw) auto,
      min(270px, 70vw) auto,
      min(240px, 62vw) auto,
      100% 100%,
      100% 100%,
      100% 100%;
  }

  .scene-depth__sakura {
    opacity: 0.2;
    inset: -6%;
    background-size:
      min(85vw, 380px) auto,
      min(82vw, 360px) auto,
      min(78vw, 340px) auto,
      min(80vw, 350px) auto,
      min(145vw, 920px) auto,
      min(72vw, 300px) auto,
      min(70vw, 290px) auto,
      min(130vw, 880px) auto;
  }

  .scene-depth__samurai {
    opacity: 0.19;
    width: min(140px, 36vw);
    height: min(300px, 38vh);
    right: 8px;
    bottom: -4%;
  }

  html[data-theme="light"] .scene-depth__houses {
    opacity: 0.2;
  }

  html[data-theme="light"] .scene-depth__houses::after {
    opacity: 0.44;
  }

  html[data-theme="light"] .scene-depth__petals {
    opacity: 0.26;
  }

  html[data-theme="light"] .scene-depth__sakura {
    opacity: 0.34;
  }

  html[data-theme="light"] .scene-depth__samurai {
    opacity: 0.24;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene-depth__houses {
    opacity: 0.17;
  }

  .scene-depth__petals {
    opacity: 0.18;
  }

  .scene-depth__sakura {
    opacity: 0.22;
  }

  .scene-depth__samurai {
    opacity: 0.2;
  }
}

/* Сетка + шум: над сакурой/самураем (z-index 1), под текстом */
.binary-noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      var(--noise-fine) 2px,
      var(--noise-fine) 3px
    ),
    linear-gradient(var(--noise-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--noise-grid) 1px, transparent 1px);
  background-size:
    auto,
    100% 48px,
    48px 100%;
  mix-blend-mode: var(--noise-blend);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 20%, transparent 70%);
}

@media (min-width: 900px) {
  .binary-noise {
    background-image:
      repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        var(--noise-fine) 2px,
        var(--noise-fine) 3px
      ),
      linear-gradient(var(--noise-grid-md) 1px, transparent 1px),
      linear-gradient(90deg, var(--noise-grid-md) 1px, transparent 1px),
      radial-gradient(ellipse 80% 50% at 50% -20%, var(--noise-radial), transparent 55%);
    background-size:
      auto,
      100% 48px,
      48px 100%,
      100% 100%;
  }
}

/* Вертикальная полоса с двоичным кодом (японская вертикальная ось) */
.jp-binary-rail {
  position: fixed;
  top: 0;
  bottom: 0;
  right: clamp(8px, 2vw, 20px);
  width: 1.15rem;
  z-index: 1;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.55;
  letter-spacing: 0.35em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: var(--binary-bright);
  opacity: 0.55;
  user-select: none;
  white-space: pre;
}

@media (max-width: 640px) {
  .jp-binary-rail {
    opacity: 0.28;
    font-size: 8px;
  }
}

/* Обёртка контента (без z-index — чтобы fixed #hero-title оставался над #intro-backdrop) */
.shell {
  position: relative;
}

.subpage .shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

@keyframes reveal-soft {
  0% {
    opacity: 0;
    transform: translateY(28px);
    filter: blur(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes reveal-nav {
  0% {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes reveal-bg {
  0% {
    opacity: 0;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .theme-toggle::before {
    transition: none;
  }
}

/* Переключатель темы */
.site-header__end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: calc(8px * 2);
}

.theme-toggle {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.theme-toggle:hover {
  border-color: var(--fg-muted);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fg);
  transform: translate(0, -50%);
  transition: transform 0.28s var(--ease-smooth);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .theme-toggle::before {
  transform: translate(18px, -50%);
}

.theme-toggle__hint {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  user-select: none;
  white-space: nowrap;
  line-height: 1;
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  .theme-toggle__hint {
    font-size: 8px;
    letter-spacing: 0.08em;
    max-width: 5.5rem;
  }
}

/* Согласие на cookie — всплывающая панель */
body.cookie-consent-open {
  overflow: hidden;
}

.cookie-consent {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: max(calc(8px * 2), env(safe-area-inset-top, 0px));
  padding-inline: max(calc(8px * 2), env(safe-area-inset-left, 0px)) max(calc(8px * 2), env(safe-area-inset-right, 0px));
  padding-bottom: max(calc(8px * 2), env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.cookie-consent:not([hidden]):not(.cookie-consent--closed) {
  pointer-events: auto;
}

.cookie-consent[hidden],
.cookie-consent.cookie-consent--closed {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.cookie-consent__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

html[data-theme="light"] .cookie-consent__backdrop {
  background: rgba(20, 20, 18, 0.35);
}

.cookie-consent__panel {
  position: relative;
  width: min(100%, 32rem);
  max-height: min(88vh, 28rem);
  overflow: auto;
  margin-bottom: calc(8px * 2);
  padding: calc(8px * 4);
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}

.cookie-consent__eyebrow {
  margin: 0 0 calc(8px * 1);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--binary-bright);
}

.cookie-consent__title {
  margin: 0 0 calc(8px * 2);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.cookie-consent__text {
  margin: 0 0 calc(8px * 2);
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg-muted);
}

.cookie-consent__text--muted {
  margin-bottom: calc(8px * 3);
  font-size: 13px;
}

.cookie-consent__link {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cookie-consent__link:hover {
  opacity: 0.88;
}

.cookie-consent__link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.cookie-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(8px * 2);
  align-items: center;
}

.cookie-consent__btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: calc(8px * 2) calc(8px * 3);
  border-radius: 0;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  transition:
    opacity 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.cookie-consent__btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.cookie-consent__btn--primary {
  color: var(--bg);
  background: var(--fg);
  border-color: var(--fg);
}

.cookie-consent__btn--primary:hover {
  opacity: 0.92;
}

.cookie-consent__btn--ghost {
  color: var(--fg);
  background: transparent;
}

.cookie-consent__btn--ghost:hover {
  background: var(--surface-panel);
  border-color: var(--fg-muted);
}

@media (prefers-reduced-motion: reduce) {
  .cookie-consent__backdrop {
    backdrop-filter: none;
  }

  .scroll-to-top {
    transition: none;
  }
}

/* Шапка: соцсети рядом с переключателем темы */
.site-header__social {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(8px * 1.25);
}

.site-header__social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  color: var(--fg-muted);
  border: 1px solid var(--line);
  background: transparent;
  text-decoration: none;
  transition:
    color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.site-header__social-link:hover {
  color: var(--fg);
  border-color: var(--line-strong);
  background: var(--surface-panel);
}

.site-header__social-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.site-header__social-link svg {
  display: block;
}

/* Кнопка «наверх» */
.scroll-to-top {
  position: fixed;
  z-index: 90;
  right: max(12px, calc(env(safe-area-inset-right, 0px) + 8px));
  bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--bg-elevated);
  color: var(--fg-muted);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity 0.28s var(--ease),
    visibility 0.28s var(--ease),
    transform 0.28s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.scroll-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-to-top:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
  background: var(--surface-panel);
}

.scroll-to-top:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.scroll-to-top svg {
  display: block;
}
