/* Базовые переменные и сброс */
:root {
    --bg: #000000;
    --fg: #7cce99; /* main text color */
    --muted: #4aa86d; /* subdued green */
    --accent: #7cce99; /* primary accent */
    --accent-rgb: 124, 206, 153; /* for rgba() uses */
    --card: #001100;
    --radius: 10px;
}

[data-theme="dark"] {
    --bg: #000000;
    --fg: #7cce99;
    --muted: #4aa86d;
    --accent: #7cce99;
    --accent-rgb: 124, 206, 153;
    --card: #001100;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font-family: 'Fira Mono', monospace;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* Disable text selection site-wide */
html, body, body * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
/* Allow selection inside inputs/textareas if they appear later */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Allow copy for specific elements (e.g., email) */
.copy-allowed, .copy-allowed * {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Matrix-styled mail link */
.copy-allowed{
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--accent-rgb), .55);
    padding-bottom: 2px;
    box-shadow: 0 0 6px rgba(var(--accent-rgb), .18);
    transition: color .2s ease, box-shadow .3s ease, border-color .2s ease, text-shadow .3s ease;
}
.copy-allowed:hover{
    border-bottom-color: rgba(var(--accent-rgb), 1);
    text-shadow: 0 0 8px var(--accent), 0 0 16px var(--accent);
    box-shadow: 0 0 12px rgba(var(--accent-rgb), .32);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem
}

.site-header {
    background: transparent;
    position: sticky;
    top: 0;
    backdrop-filter: saturate(120%) blur(6px);
    z-index: 10
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between
}

.logo {
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    text-shadow: 0 0 5px var(--accent);
}

.nav {
    display: flex;
    gap: 1rem
}

.nav a {
    color: var(--muted);
    text-decoration: none
}

.controls {
    display: flex;
    gap: .5rem;
    align-items: center
}

.nav-toggle {
    display: none;
    padding: .5rem;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px
}

.hero {
    padding: 6rem 0;
    text-align: center
}

.hero h1 {
    font-size: 2rem;
    margin: .2rem 0;
    position: relative;
}

/* Включаем свечение/глитч только после расшифровки */
.hero h1.glitch-after {
    text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 30px var(--accent);
    animation: green-glow 3s ease-in-out infinite alternate, glitch-soft 1.2s ease-in-out infinite;
}

.hero p {
    color: var(--muted)
}

/* 3D tilt scene */
.tilt-scene{ perspective: 800px; }
.tilt-card{
    transform-style: preserve-3d;
    transition: transform .12s ease;
    will-change: transform;
}
.tilt-layer{
    will-change: transform;
    transition: transform .12s ease;
    transform: translateZ(0);
}
.tilt-front{ position: relative; z-index: 10; }

.rabbit-quote {
    font-style: normal; /* убран наклон */
    color: var(--fg);
}

.rabbit-quote.glow-after {
    animation: rabbit-soft 4.5s ease-in-out infinite;
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: #000;
    padding: .6rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 0 10px var(--accent);
    transition: all 0.3s ease;
}

/* Hero actions - pill buttons */
.actions{
    display:grid;
    grid-template-columns: repeat(4, 1fr);
    gap:.75rem;
    justify-items: center;
    margin-top:1rem;
}
.actions .pill-btn{ width:100%; text-align:center; }
.pill-btn{
    position:relative;
    display:inline-block;
    padding:.65rem 1.2rem;
    border-radius:999px;
    border:1px solid var(--accent);
    background: rgba(0,0,0,0.35);
    color: var(--fg);
    text-decoration:none;
    letter-spacing:.02em;
    text-shadow: 0 0 6px rgba(var(--accent-rgb), 0.35);
    box-shadow:
      inset 0 0 10px rgba(var(--accent-rgb), 0.15),
      0 0 10px rgba(var(--accent-rgb), 0.12);
    transition: transform .2s ease, box-shadow .25s ease, background-color .25s ease, color .25s ease, border-color .25s ease;
    cursor:pointer;
    overflow:hidden;
}
/* subtle CRT scanlines */
.pill-btn::before{
    content:"";
    position:absolute; inset:0;
    border-radius:inherit;
    background: repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(124,206,153,0.06) 3px,
      rgba(0,0,0,0) 4px
    );
    opacity:.5; pointer-events:none;
}
/* light sweep */
.pill-btn::after{
    content:""; position:absolute; inset:-1px;
    border-radius:inherit;
    background: linear-gradient(120deg, transparent 35%, rgba(var(--accent-rgb),.18) 50%, transparent 65%);
    transform: translateX(-120%);
    transition: transform .6s ease;
    pointer-events:none;
}
.pill-btn:hover{
    background: rgba(var(--accent-rgb), 0.10);
    box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.35), 0 0 30px rgba(var(--accent-rgb), 0.22);
    transform: translateY(-1px);
}
.pill-btn:hover::after{ transform: translateX(120%); }
.pill-btn:focus-visible{
    outline:none;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.45), 0 0 12px rgba(var(--accent-rgb),.35);
}
.pill-btn[disabled], .pill-btn[aria-disabled="true"], button.pill-btn:disabled{
    opacity:.45;
    border-color: var(--muted);
    color: var(--muted);
    cursor: not-allowed;
    pointer-events:none;
    box-shadow: none;
}

.features .cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem
}

/* Matrix inline form under features */
.matrix-inline-form{
    display:flex;
    gap:0;
    align-items:center;
    margin-top:1.25rem;
    opacity: 0;
    transform: translateY(16px);
    transition: all .5s ease;
}
.matrix-inline-form.revealed{ opacity: 1; transform: translateY(0); }
.matrix-input{
    flex:1;
    padding:.7rem .9rem;
    border-radius: var(--radius);
    border:1px solid var(--accent);
        background: rgba(0,0,0,0.35);
        /* move sweep and scanlines inside the input itself */
        background-image:
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0) 0px,
                rgba(0,0,0,0) 2px,
                rgba(124,206,153,0.06) 3px,
                rgba(0,0,0,0) 4px
            ),
            linear-gradient(120deg, transparent 40%, rgba(var(--accent-rgb),.18) 50%, transparent 60%);
        background-size: auto, 220% 100%;
        background-position: 0 0, -150% 0;
    color: var(--fg);
    font-family: 'Fira Mono', monospace;
    font-size: 1rem;
    box-shadow: inset 0 0 10px rgba(var(--accent-rgb), .12);
    transition: all .25s ease;
    width: 100%;
    display: block;
}
.matrix-input:hover{
        background-position: 0 0, 150% 0;
}
.matrix-inline-form .matrix-input{
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}
.matrix-input::placeholder{ color: var(--muted); }
.matrix-input:focus{
    outline:none;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(var(--accent-rgb), .35), inset 0 0 10px rgba(var(--accent-rgb), .18);
    background: rgba(var(--accent-rgb), .06);
}
/* Hover effects on input wrapper similar to pill buttons */
.matrix-input-wrap{ position:relative; flex:1; }
/* Matrix corner brackets effect confined to input area */
.matrix-input-wrap::before{
        content: ""; position:absolute; inset:0; border-radius: var(--radius);
        background:
            linear-gradient(to right, rgba(var(--accent-rgb),.85), rgba(var(--accent-rgb),0)) top left / 32px 2px no-repeat,
            linear-gradient(to bottom, rgba(var(--accent-rgb),.85), rgba(var(--accent-rgb),0)) top left / 2px 32px no-repeat;
        pointer-events:none;
        transition: background-size .35s ease, filter .35s ease;
}
.matrix-input-wrap::after{
        content: ""; position:absolute; inset:0; border-radius: var(--radius);
        background:
            linear-gradient(to left, rgba(var(--accent-rgb),.85), rgba(var(--accent-rgb),0)) bottom right / 32px 2px no-repeat,
            linear-gradient(to top, rgba(var(--accent-rgb),.85), rgba(var(--accent-rgb),0)) bottom right / 2px 32px no-repeat;
        pointer-events:none;
        transition: background-size .35s ease, filter .35s ease;
}
.matrix-input-wrap:hover::before, .matrix-input-wrap:focus-within::before{
        background-size: 64px 2px, 2px 64px;
        filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),.35));
}
.matrix-input-wrap:hover::after, .matrix-input-wrap:focus-within::after{
        background-size: 64px 2px, 2px 64px;
        filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),.35));
}
/* Error state + shake */
.matrix-input.error{
    border-color:#ff5a5a;
    box-shadow: 0 0 12px rgba(255,90,90,.25), inset 0 0 8px rgba(255,90,90,.18);
    color:#ffb3b3;
    caret-color:#ff5a5a;
}
.matrix-input.error::placeholder{ color: rgba(255,90,90,.75); }
@keyframes shake{
  0%{ transform: translateX(0); }
  20%{ transform: translateX(-3px); }
  40%{ transform: translateX(3px); }
  60%{ transform: translateX(-3px); }
  80%{ transform: translateX(3px); }
  100%{ transform: translateX(0); }
}
.matrix-input.shake{ animation: shake 250ms ease; }

/* Inline message */
.inline-msg{
    margin-top:.5rem;
    font-size:.95rem;
    color:#ff5a5a;
    text-shadow: 0 0 8px rgba(255,90,90,.35);
    opacity:0;
    transform: translateY(8px);
    transition: opacity .3s ease, transform .3s ease;
}
.inline-msg.show{ opacity:1; transform: translateY(0); }
/* Inline button merged with input */
.matrix-btn-inline{
    padding:.7rem 1rem;
    border:1px solid var(--accent);
    border-left: 1px solid var(--accent);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    background: rgba(0,0,0,0.35);
    color: var(--fg);
    font-family: 'Fira Mono', monospace;
    font-size: 1rem;
    cursor:pointer;
    box-shadow: inset 0 0 10px rgba(var(--accent-rgb), .12);
    transition: all .25s ease;
}
.matrix-btn-inline.error{
    border-color:#ff5a5a;
    box-shadow: 0 0 12px rgba(255,90,90,.28), inset 0 0 8px rgba(255,90,90,.18);
    color:#ffb3b3;
}
.matrix-btn-inline:hover{
    background: rgba(var(--accent-rgb), .10);
    box-shadow: 0 0 12px rgba(var(--accent-rgb), .30), inset 0 0 10px rgba(var(--accent-rgb), .18);
}
.matrix-btn-inline:active{
    transform: translateY(1px);
}
@media (max-width: 700px){
    .matrix-inline-form{ flex-direction: column; align-items: stretch; }
    .matrix-inline-form .matrix-input{
        border-right: 1px solid var(--accent);
        border-radius: var(--radius);
    }
    .matrix-inline-form .matrix-btn-inline{
        width:100%; text-align:center;
        border-radius: var(--radius);
        margin-top:.5rem;
    }
}

.about p {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.about p.revealed {
    opacity: 1;
}

.about {
    margin-top: 2rem
}

.contact-form {
    display: grid;
    gap: .75rem;
    max-width: 600px
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    padding: .6rem;
    border-radius: 8px;
    border: 1px solid var(--accent);
    background: var(--bg);
    color: var(--fg);
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace
}

/* Скрываем форму до расшифровки заголовка */
.contact-form {
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.5s ease;
    pointer-events: none;
}

.contact-form.revealed {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Скрываем кнопки в секции #password до расшифровки h2 */
#password .actions{
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.5s ease;
    pointer-events: none;
}
#password .actions.revealed{
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.form-msg {
    color: var(--accent);
    margin-top: .5rem
}

.site-footer {
    padding: 2rem 0;
    text-align: center;
    color: var(--muted);
    border-top: 1px solid var(--muted);
    box-shadow: 0 -5px 10px rgba(var(--accent-rgb), 0.2);
}

/* Matrix rain background */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.7;
}

#vignette{
    position: fixed;
    top:0;left:0;width:100%;height:100%;
    pointer-events: none;
    z-index: 6;
    /* мягкая виньетка по краям */
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 58%, rgba(0,0,0,0.42) 100%);
}

/* Subtle film grain overlay */
#grain{
        position: fixed;
        top:0;left:0;width:100%;height:100%;
        pointer-events:none;
        z-index: 7;
        opacity:.03; /* ~3% */
        background-image:
            radial-gradient(circle at 10% 10%, rgba(255,255,255,.08) 0 1px, transparent 1px),
            radial-gradient(circle at 20% 80%, rgba(255,255,255,.06) 0 1px, transparent 1px),
            radial-gradient(circle at 70% 30%, rgba(255,255,255,.07) 0 1px, transparent 1px),
            radial-gradient(circle at 50% 60%, rgba(255,255,255,.05) 0 1px, transparent 1px);
        background-size: 200px 200px, 220px 220px, 180px 180px, 260px 260px;
        animation: grain-move 6s steps(10) infinite;
}
@keyframes grain-move{
    0%{ transform: translate(0,0); }
    25%{ transform: translate(-1%, 1%); }
    50%{ transform: translate(1%, -1%); }
    75%{ transform: translate(-1%, -1%); }
    100%{ transform: translate(0,0); }
}

/* Полупрозрачная фоновая картинка, цифры остаются яркими */
#matrix-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('../bg-0.png');
    background-size: cover;
    background-position: center calc(50% + var(--bg-shift-y, 0px));
    background-repeat: no-repeat;
    background-attachment: fixed;
    opacity: 0.3; /* регулируй прозрачность фона тут */
}

#matrix-bg span {
    position: absolute;
    color: var(--accent);
    font-size: 14px;
    font-family: 'Fira Mono', monospace;
    animation: fall 2s linear infinite;
    opacity: 0.6
}
#matrix-bg span.leader{
    color: #baf7d3; /* brighter accent */
    text-shadow: 0 0 8px rgba(var(--accent-rgb), .7);
    font-size: 16px;
    opacity: .9;
}

@keyframes fall {
    0% {
        top: -20px;
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
    85% {
        opacity: 0.5;
        transform: scale(0.9);
    }
    95% {
        opacity: 0;
        transform: scale(0.7);
    }
    100% {
        top: 100vh;
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Local fall from current Y (for cursor spawns) */
@keyframes fall-local {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(100vh); opacity: 0; }
}

@keyframes rabbit-glow {
    from {
        text-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff;
    }
    to {
        text-shadow: 0 0 20px #ffffff, 0 0 30px #ffffff, 0 0 40px #ffffff;
    }
}

/* Более мягкое приятное свечение для цитаты */
@keyframes rabbit-soft {
    0% {
        text-shadow: 0 0 2px rgba(var(--accent-rgb), 0.25), 0 0 6px rgba(var(--accent-rgb), 0.18);
        filter: brightness(1);
    }
    50% {
        text-shadow: 0 0 6px rgba(var(--accent-rgb), 0.35), 0 0 16px rgba(var(--accent-rgb), 0.25);
        filter: brightness(1.05);
    }
    100% {
        text-shadow: 0 0 3px rgba(var(--accent-rgb), 0.28), 0 0 10px rgba(var(--accent-rgb), 0.2);
        filter: brightness(1);
    }
}

/* Зелёное свечение для заголовка */
@keyframes green-glow {
    from {
        text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 30px var(--accent);
    }
    to {
        text-shadow: 0 0 20px var(--accent), 0 0 30px var(--accent), 0 0 40px var(--accent);
    }
}

/* Более мягкий глитч для главного заголовка */
@keyframes glitch-soft {
    0%, 100% {
        text-shadow: 0 0 8px var(--accent), 0 0 18px var(--accent);
        filter: none;
    }
    25% {
        text-shadow: 1px -1px 0 rgba(255,0,0,0.12), -1px 1px 0 rgba(0,128,255,0.12), 0 0 12px var(--accent);
        filter: brightness(1.03);
    }
    50% {
        text-shadow: -1px 1px 0 rgba(255,0,0,0.12), 1px -1px 0 rgba(0,128,255,0.12), 0 0 14px var(--accent);
        filter: none;
    }
    75% {
        text-shadow: .5px .5px 0 rgba(255,0,0,0.10), -.5px -.5px 0 rgba(0,128,255,0.10), 0 0 12px var(--accent);
        filter: brightness(1.02);
    }
}

/* Quick text glitch pulse */
.glitch-pulse{
        animation: glitch-pulse 200ms ease-out 1;
}
@keyframes glitch-pulse{
    0%  { text-shadow: 0 0 2px rgba(255,0,0,.18), 0 0 2px rgba(0,128,255,.18), 0 0 10px var(--accent); filter: contrast(1.04) brightness(1.06); }
    50% { text-shadow: 0 0 4px rgba(255,0,0,.22), 0 0 4px rgba(0,128,255,.22), 0 0 12px var(--accent); filter: contrast(1.03) brightness(1.04); }
    100%{ text-shadow: 0 0 8px var(--accent); filter: none; }
}

/* Global burst state */
body.glitch-burst #matrix-bg::before{
    filter: hue-rotate(2deg) saturate(1.08) brightness(1.05);
    /* no positional jump to avoid jerk */
}
body.glitch-burst .tilt-card{
    /* no movement; just a soft glow */
    box-shadow: 0 0 18px rgba(var(--accent-rgb), .25);
}

/* Scanline flash during burst */
#scanline{
        position: fixed; left:0; right:0; top:0; height:2px;
        background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb),.9), transparent);
        opacity: 0; pointer-events: none; z-index: 7;
}
body.glitch-burst #scanline{
        animation: scan-flash 160ms linear 1;
}
@keyframes scan-flash{
    0%{ opacity: 0; transform: translateY(0); }
    50%{ opacity:.9; transform: translateY(45vh); }
    100%{ opacity:0; transform: translateY(90vh); }
}

.card p, .about p {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease;
}

.card p.revealed, .about p.revealed {
    opacity: 1;
    transform: translateY(0);
}

@keyframes glitch {
    0%, 100% {
        transform: translate(0);
        text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00, 0 0 30px #00ff00;
    }
    20% {
        transform: translate(-2px, 2px);
        text-shadow: -2px 2px 0 #ff0000, 2px -2px 0 #0000ff;
    }
    40% {
        transform: translate(-2px, -2px);
        text-shadow: 2px 2px 0 #ff0000, -2px -2px 0 #0000ff;
    }
    60% {
        transform: translate(2px, 2px);
        text-shadow: -2px -2px 0 #ff0000, 2px 2px 0 #0000ff;
    }
    80% {
        transform: translate(2px, -2px);
        text-shadow: 2px -2px 0 #ff0000, -2px 2px 0 #0000ff;
    }
}

/* Responsive */
@media (max-width:800px) {
    .features .cards {
        grid-template-columns: 1fr
    }

    .nav {
        display: none;
        position: absolute;
        right: 1rem;
        top: 64px;
        background: var(--card);
        padding: 1rem;
        border-radius: 8px;
        box-shadow: 0 10px 30px rgba(var(--accent-rgb), 0.2)
    }

    .nav-toggle {
        display: inline-block
    }
}

/* Две колонки по 2 кнопки, когда ряд из 4 не влазит */
@media (max-width: 760px){
    .actions{ grid-template-columns: repeat(2, 1fr); }
}

/* Subtle cursor trail (non-intrusive) */
.cursor-dot{
        position: fixed;
        top:0; left:0;
        width: 6px; height: 6px;
        border-radius: 50%;
        background: rgba(var(--accent-rgb), .5);
        box-shadow: 0 0 10px rgba(var(--accent-rgb), .4);
        pointer-events: none;
        z-index: 8;
        transform: translate3d(0,0,0);
        animation: cursor-fade 480ms ease-out forwards;
}

/* Text cursor trail bits */
.cursor-bit{
        position: fixed;
        top:0; left:0;
        color: var(--accent);
        font-family: 'Fira Mono', monospace;
        font-size: 12px;
        text-shadow: 0 0 8px rgba(var(--accent-rgb), .5);
        pointer-events:none;
        z-index:8;
        transform: translate3d(0,0,0);
        animation: bit-fade 700ms ease-out forwards;
}
@keyframes bit-fade{
    0%   { opacity:.7; transform: translate3d(var(--x,0), var(--y,0),0) scale(1); }
    60%  { opacity:.35; transform: translate3d(calc(var(--x,0) + 4px), calc(var(--y,0) + 4px),0) scale(.95); }
    100% { opacity:0;   transform: translate3d(calc(var(--x,0) + 10px), calc(var(--y,0) + 10px),0) scale(.9); }
}
@keyframes cursor-fade{
    0%   { opacity:.5; transform: translate3d(var(--x,0), var(--y,0),0) scale(1); }
    50%  { opacity:.3; transform: translate3d(calc(var(--x,0) + 2px), calc(var(--y,0) + 2px),0) scale(.9); }
    100% { opacity:0;   transform: translate3d(calc(var(--x,0) + 6px), calc(var(--y,0) + 6px),0) scale(.75); }
}
