@font-face {
    font-family: "Story Script";
    src: url("/assets/fonts/StoryScript-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Press Start 2P';
    src: url('/assets/fonts/press_start2p_cyrillic.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Press Start 2P';
    src: url('/assets/fonts/press_start2p_latin.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("/assets/fonts/JetBrainsMono_latin.woff2") format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("/assets/fonts/JetBrainsMono_latin-ext.woff2") format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("/assets/fonts/JetBrainsMono_cyrillic.woff2") format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("/assets/fonts/JetBrainsMono_cyrillic-ext.woff2") format('woff2');
}

/* Нормализация и сброс стилей */
*, *::before, *::after {
    box-sizing: border-box;
}

:where(ul, ol):where([class]) {
    padding-left: 0;
    list-style-type: none;
}

body, :where(blockquote, figure):where([class]) {
    margin: 0;
}

:where(h1,h2,h3, h4, h5, h6, p, ul, ol, dl):where([class]) {
    margin-block: 0;
}

:where(dd[class]) {
    margin-left: 0;
}

img {
    display: block;
    max-width: 100%;
}

input, textarea, select, button {
    font: inherit;
}

/*----------------- Глобальные правила и переменные ----------------*/
:root {
    --color-white: white;
    --color-black: #080808;
    --color-yellow: #E8F104;
    --color-yellow-dark: #747802;
    --color-dark-blue: #02247B;
    --color-gray: #404142;

    --text-dim: #9aa0a6;
    --bg-card: #1e2327;

    --logo-f: "Story Script", sans-serif;
    --title-f: "Press Start 2P", system-ui;
    --main-f: "JetBrains Mono", monospace;

    --container-max-width: 1200px;
    --container-padding-x: 15px;
    --border-radius: 8px;
    --border: 1px solid #2a2f34;
    --margin-bottom: 35px;

    height: 100%;
    scroll-behavior: smooth;

    --bg: #14171a; /* основной фон, тёмный */
    --text: #e6e6e6; /* основной текст */
    --accent: #ffe347;
    --accent-dim: #7a6a25;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background: var(--color-black);
    color: var(--color-white);
    font-family: var(--main-f);
    font-size: 16px;
    min-height: 100%;
    line-height: 1.6;
}

h2 {
    font-size: 32px;
    font-weight: 700;
}

.container {
    max-width: calc(max(var(--container-max-width), 60%) + var(--container-padding-x) * 2);
    margin-inline: auto;
    padding-inline: var(--container-padding-x);
}

.highlight-text {
    font-weight: 800;

    display: inline-flex;
    align-items: center;

    background-color: var(--color-yellow);
    border-radius: 50%;
    line-height: 0.8;
    text-indent: 0;
}

::selection {
    color: var(--color-black);
    background-color: var(--color-white);
}

.link {
    color: var(--color-white);
}

@media (hover: hover) {
    .link:hover {
        color: var(--color-yellow);
    }
}

@media (hover: none) {
    .link:active {
        color: var(--color-yellow);
    }
}

/*---------------------------- Header ----------------------------*/
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    column-gap: 20px;
    font-size: 40px;
    padding-block: 10px;
    padding-inline: 32px;

    position: sticky;
    top: 0;
    z-index: 100;
    background-image: radial-gradient(var(--color-dark-blue), var(--color-black) 85%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;

    font-family: var(--logo-f);
    line-height: 1;

    text-decoration: none;
}

.logo::before {
    content: "";
    height: 2em;
    aspect-ratio: 512 / 548;
    background-color: var(--color-white);

    -webkit-mask: url("/assets/logo_svg.svg") center / contain no-repeat;
    mask: url("/assets/logo_svg.svg") center / contain no-repeat;
}

.logo-github {
    width: 1.25em;
    aspect-ratio: 1;
    background-color: var(--color-white);
    margin-block: 0.375em;

    -webkit-mask: url("/assets/icons/akar-icons--github-outline-fill.svg") center / contain no-repeat;
    mask: url("/assets/icons/akar-icons--github-outline-fill.svg") center / contain no-repeat;
}

@media (hover: hover) {
    .logo:hover::before, .logo-github:hover {
        background-color: var(--color-yellow);
    }

    .logo-github:hover {
        cursor: alias;
    }
}

@media (hover: none) {
    .logo:active::before, .logo-github:active {
        background-color: var(--color-yellow);
    }
}

/*----------------------- Title -----------------------*/
.title-block {
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: 10px;
    margin-bottom: var(--margin-bottom);
}

.title__text-block {
    padding: var(--container-padding-x);
}

.title__text-block h1 {
    font-family: var(--title-f);
    font-size: 56px;
    user-select: none;
}

.title__text-subtitle {
    color: var(--text-dim);
    font-size: 40px;
}

.title__img-block {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    flex-direction: column;
    padding: var(--container-padding-x);
}

.title__img {
    border-radius: var(--border-radius);
    margin-bottom: var(--margin-bottom);
}

.btn {
    width: 180px;
    height: 60px;
    border-radius: var(--border-radius);
    font-size: 24px;
    font-weight: bold;
    user-select: none;
}

.btn--yellow {
    border: 3px solid var(--color-yellow);
    background: none;
    color: var(--color-yellow);

    transition: 150ms 50ms;
}

@media (hover: hover) {
    .btn--yellow:hover {
        box-shadow: 0 4px 8px 0 rgb(222 224 126), 0 6px 20px 0 rgb(230 238 53);
        transform: scale(1.05);
    }

    .btn--yellow:active {
        transform: scale(1);
    }
}

@media (hover: none) {
    .btn--yellow {
        transition: 50ms;
    }

    .btn--yellow:active {
        transform: scale(1.05);
        box-shadow: 0 4px 8px 0 rgb(222 224 126), 0 6px 20px 0 rgb(230 238 53);
    }
}

.title__video {
    display: block;
    max-width: 100%;
    border-radius: var(--border-radius);
    border: var(--border);
    margin-bottom: 50px;
    margin-inline: auto;
}

/*---------------------------- Components ---------------------------*/

.components {
    background-color: var(--color-yellow);
    color: var(--color-black);
    padding-block: var(--container-padding-x);
}

.components-grid {
    --gap: 20px;
    --cols: 6;

    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: var(--gap);
}

.components-item {
    flex: 0 0 calc((100% - var(--gap) * (var(--cols) - 1)) / var(--cols));
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;

    font-size: 18px;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-align: center;

    overflow-wrap: anywhere;
}

.components-item__svg {
    width: 100%;
    height: 140px;
    object-fit: contain;
}

/*-------------------------- Assembly -------------------------*/

.assembly {
    color: var(--color-black);
    background-color: var(--color-white);
    padding-block: var(--container-padding-x);
    font-size: 20px;
}

.assembly p, .firmware p {
    text-indent: 3em;
}

.assembly p::selection {
    color: var(--color-black);
    background-color: var(--color-yellow);
}

.direction {
    display: flex;
    flex-direction: column;
}

.direction-item {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;

    scroll-margin-top: calc(var(--header-height, 0px) + 30px);
}

.direction-item--right-img {
    flex-direction: row-reverse;
}

.direction-item__img {
    max-width: 60%;
    max-height: 500px;
    margin: var(--container-padding-x);
    border-radius: var(--border-radius);
    flex-shrink: 0;
}

.direction-item__text {
    padding: var(--container-padding-x);
}

/*--------------------------- Firmware --------------------------*/
.firmware {
    font-size: 20px;
}

.firmware-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 50px;
}

.firmware p code {
    background-color: rgb(55 59 64 / 0.69);
    border-radius: 4px;
    border: 1px solid var(--color-gray);
}

.firmware-content__code {
    position: sticky;
    top: calc(var(--header-height, 0px) + 10px);
    align-self: start;
}

.accordion-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.accordion-card__title {
    border: 3px solid var(--color-yellow-dark);
    border-radius: 100px;
    padding-block: 20px;
    padding-right: 40px;
    padding-left: 60px;
    display: flex;
    justify-content: space-between;
    gap: 20px;

    scroll-margin-top: calc(var(--header-height, 0px) + 10px);

    transition: background-color 0.8s, border-color 150ms;
}

.accordion-card__title-arrow {
    width: 2em;
    aspect-ratio: 1;
    background-color: var(--color-yellow-dark);

    -webkit-mask: url("assets/icons/pixelarticons--arrow-big-down-dash.svg") center / contain no-repeat;
    mask: url("assets/icons/pixelarticons--arrow-big-down-dash.svg") center / contain no-repeat;

    transition: transform 0.8s, background-color 150ms;
    flex: 0 0 2em;
}

.accordion-card__title-text {
    p {
        text-indent: 0;
        color: var(--text-dim);
    }
}

.accordion-card__title-text h3 {
    font-size: 24px;
}


.accordion-card__title.active {
    background-color: rgb(232 241 4 / 0.11);
    border-color: var(--color-yellow);

    .accordion-card__title-arrow {
        background-color: var(--color-yellow);
        transform: rotate(-180deg);
    }
}

.accordion-card__title:hover {
    border-color: var(--color-yellow);

    .accordion-card__title-arrow {
        background-color: var(--color-yellow);
    }
}

.accordion-card__title h3, .accordion-card__title p {
    margin: 0;
}

.accordion-card__open, .firmware-intro {
    margin-bottom: 50px;
}

.all-leds-grid {
    display: grid;
    align-items: baseline;
    grid-template-columns: 1fr auto;
    grid-template-areas:
            "text1 code"
            "text2 code";

    column-gap: 20px;
}

.all-leds-block {display: contents;}

.firmware-content__code {
    grid-area: code;
    max-width: 100%;
}

.all-leds-text__first {grid-area: text1;}

.all-leds-text__second {grid-area: text2;}

/* footer */
.footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85em;
    border-top: 1px solid #2a2f34;
    padding-block: 20px;
}

.footer a {
    color: var(--color-yellow);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/*-------------------------- Code Style ----------------------------------*/

.code-block {
    border: 1px solid var(--color-yellow);
    padding: 10px;
    overflow-x: auto;
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    margin-top: 0;

    display: block;
    flex-shrink: 0;
}

.ref:after {
    content: attr(data-n);
    justify-content: center;
    align-items: center;
    width: 1.4em;
    height: 1.4em;

    border-radius: 50%;
    border: 2px solid var(--color-gray);
    background: var(--color-black);
    color: var(--color-yellow);
    font-weight: bold;
    line-height: 1;
    user-select: none;
}

.ref-code {
    position: relative;
}

.ref-code::after {
    position: absolute;
    right: 0.6em;
    top: 0;

    display: flex;
}

.ref-text::after {
    display: inline-flex;

    margin-left: 0.6em;
    vertical-align: middle;
    text-indent: 0;
}

.kw {color: #ff9e56}

.type {color: #E8F104}

.mac {color: #1647c9}

.num {color: #79C0FF}

.fn {color: #D2A8FF}

.com {color: #a5da92}

/*----------------------------- Adaptive --------------------------------*/

@media (min-width: 2500px) {
    h2 {
        font-size: clamp(32px, 1.28vw, 40px);
    }

    .header {
        font-size: 50px;
    }

    .title__text-block h1 {
        font-size: clamp(56px, 2.24vw, 80px);
    }

    .title__text-subtitle {
        font-size: clamp(40px, 1.6vw, 65px);
    }

    .components-item {
        font-size: clamp(18px, 0.72vw, 30px);
    }

    .assembly, .firmware {
        font-size: clamp(20px, 0.8vw, 36px);
    }

    .accordion-card__title-text h3 {
        font-size: clamp(24px, 0.96vw, 40px);
    }

    .accordion-card__title {
        padding-block: clamp(20px, 0.8vw, 30px);
        padding-right: clamp(40px, 1.6vw, 60px);
        padding-left: clamp(60px, 2.4vw, 90px);
    }
}

@media (max-width: 1200px) {
    .title__text-block h1 {
        font-size: clamp(28px, 4.67vw, 56px);
    }

    .title__text-subtitle {
        font-size: clamp(20px, 3.3vw, 40px);
    }

    .firmware-content {
        flex-wrap: wrap;
        gap: 20px;
        align-items: baseline;
    }

    .firmware-content__code--extra-large {
        flex: 1 0 100%;
    }

    .firmware-text-shrink {
        flex: 1;
    }
}

@media (max-width: 1150px) {
    .components-grid {
        --cols: 4;
    }
}

@media (max-width: 1050px) {
    .direction-item__img {
        max-height: clamp(200px, 47.6vw, 500px);
    }

    .assembly, .firmware {
        font-size: clamp(18px, 1.9vw, 20px);
    }

    .firmware-content__text {
        display: contents;
    }

    .firmware-content-text__first {
        flex: 0 0 100%;
    }

    .firmware-content__code--large {
        flex: 1 0 100%;
    }

    .all-leds-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "block"
            "text2";
    }

    .all-leds-block {
        display: flex;
        gap: 20px;
        grid-area: block;
    }

}

@media (max-width: 800px) {
    .components-grid {
        --cols: 3;
    }

    .direction-item {
        flex-direction: column;
    }

    .direction-item__img {
        max-height: 500px;
        max-width: 100%;
    }

    .firmware-content__text-second {
        flex: 0 0 100%;
    }

    .firmware-content__code--middle {
        flex: 1 0 100%;
    }
}

@media (max-width: 600px) {
    .title__text-block h1 {
        font-size: clamp(20px, 6.7vw, 40px);
    }

    .title__text-subtitle {
        font-size: clamp(15px, 5vw, 30px);
    }

    .header {
        font-size: 30px;
        padding-inline: var(--container-padding-x);
    }

    .title-block {
        grid-template-columns: 1fr;
    }

    .title__img-block {
        order: 1;
    }

    h2 {
        font-size: 24px;
    }

    .components-item, .firmware-content__code {
        font-size: clamp(16px, 3vw, 18px);
    }

    .accordion-card__title-text h3 {
        font-size: clamp(20px, 4vw, 24px);
    }

    .firmware-content__code--small {
        flex: 1 0 100%;
        align-self: stretch;
    }

    .all-leds-block {
        flex-direction: column;
        flex-wrap: wrap;
    }
}

@media (max-width: 510px) {
    .components-grid {
        --cols: 2;
    }

    .components-item {
        font-size: clamp(16px, 4.5vw, 18px);
    }

    .accordion-card__title-text h3 {
        font-size: clamp(18px, 3.9vw, 20px);
    }

    .accordion-card__title-text p {
        font-size: clamp(16px, 3.5vw, 18px);
    }

    .accordion-card__title {
        padding-left: 50px;
        padding-right: 20px;
    }
}

@media (max-width: 400px) {
    .accordion-card__title-text h3 {
        font-size: clamp(16px, 4.5vw, 18px);
    }

    .accordion-card__title {
        gap: 10px;
    }
}