:root {
    --bg: #ffffff;
    --bg2: #f8fafc;
    --bg3: #eef2f7;
    --border: rgba(0, 0, 0, 0.09);
    --border-hover: rgba(0, 0, 0, 0.18);
    --text: #334155;
    --heading: #0f172a;
    --muted: #94a3b8;
    --bg-op-4: rgba(0, 0, 0, 0.03);
    --bg-op-5: rgba(0, 0, 0, 0.05);
    --bg-op-9: rgba(0, 0, 0, 0.08);
    --dot-color: rgba(0, 0, 0, 0.06);

    --bec: #F7931A;
    --ete: #627EEA;
    --sle: #00FFA3;
    --mono: 'Space Mono', monospace;
    --sans: 'Noto Sans KR', sans-serif;
}

[data-theme="dark"] {
    --bg: #080b11;
    --bg2: #0e1219;
    --bg3: #151b26;
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.16);
    --text: #cbd5e1;
    --heading: #f1f5f9;
    --muted: #475569;
    --bg-op-4: rgba(255, 255, 255, 0.03);
    --bg-op-5: rgba(255, 255, 255, 0.05);
    --bg-op-9: rgba(255, 255, 255, 0.08);
    --dot-color: rgba(255, 255, 255, 0.035);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
    /* 배경 dot grid */
    background-image: radial-gradient(var(--dot-color) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* ── HEADER ── */
.header {
    text-align: center;
    padding: 72px 20px 20px;
    position: relative;
}


/* ── CONTROLS CONTAINER (THEME + LANG) ── */
.header-controls {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 10;
}

.theme-toggle-btn,
.lang-toggle-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle-btn {
    padding: 9px;
    border-radius: 50%;
}

.lang-toggle-btn {
    padding: 8px 12px;
    border-radius: 20px;
    font-family: var(--mono);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.theme-toggle-btn:hover,
.lang-toggle-btn:hover {
    background: var(--bg3);
    border-color: var(--border-hover);
    color: var(--heading);
    transform: translateY(-1px);
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* ── LOGO ── */
.logo-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 18px;
}

.logo-dots {
    display: flex;
    gap: 7px;
    align-items: center;
}

.logo-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: dotpulse 3s ease-in-out infinite;
}

.logo-dot:nth-child(1) {
    background: var(--bec);
    box-shadow: 0 0 0 0 rgba(247, 147, 26, 0.5);
    animation-delay: 0s;
}

.logo-dot:nth-child(2) {
    background: var(--ete);
    box-shadow: 0 0 0 0 rgba(98, 126, 234, 0.5);
    animation-delay: 0.5s;
}

.logo-dot:nth-child(3) {
    background: var(--sle);
    box-shadow: 0 0 0 0 rgba(0, 255, 163, 0.5);
    animation-delay: 1s;
}

@keyframes dotpulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.25);
        opacity: 0.85;
    }
}

h1 {
    font-family: var(--mono);
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--heading);
}

.tagline {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.loading-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    font-size: 0.76rem;
    color: var(--muted);
    background: var(--bg2);
    border: 1px solid var(--border);
    padding: 5px 13px;
    border-radius: 20px;
    font-family: var(--mono);
}

.loading-note::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}

/* ── CHAIN SECTION ── */
.section {
    max-width: 900px;
    /* BEC 티커 밀림 현상 방지를 위해 가로 폭 900px로 상향 */
    margin: 0 auto;
    padding: 32px 20px 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* 데스크톱(PC) Grid View - 카드 동적 정렬 순서 제어 */
.section> :nth-child(1) {
    order: 1;
}

/* BitEver L1 */
.section> :nth-child(2) {
    order: 3;
}

/* LightningEver L2 */
.section> :nth-child(3) {
    order: 2;
}

/* EtherEver L1 */
.section> :nth-child(4) {
    order: 4;
}

/* ArbiEver L2 */
.section> :nth-child(5) {
    order: 5;
}

/* SolaEver L1 */

.chain-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: border-color 0.25s, transform 0.2s, background 0.2s, box-shadow 0.25s;
    position: relative;
    overflow: hidden;
}

/* 왼쪽 컬러 바 */
.chain-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 14px 0 0 14px;
    transition: width 0.2s;
}

.chain-card.bec::before {
    background: var(--bec);
}

.chain-card.ete::before {
    background: var(--ete);
}

.chain-card.sle::before {
    background: var(--sle);
}

/* 솔라에버 2열 전체 차지 */
.chain-card.sle {
    grid-column: span 2;
}

/* 서브 체인 (L2) 카드 스타일 */
.sub-chain-card {
    margin-left: 0;
    /* 가로 Grid 배치 시 마진 제거 */
    padding: 16px 20px;
}

.sub-chain-card .chain-name {
    font-size: 0.98rem;
}

.sub-chain-card::before {
    width: 2px;
}

.sub-chain-card:hover::before {
    width: 3px;
}

.arrow-icon {
    font-family: var(--mono);
    color: var(--muted);
    margin-right: 6px;
    font-weight: 400;
}

/* hover */
.chain-card:hover {
    transform: translateY(-3px);
    background: var(--bg3);
}

.chain-card:hover::before {
    width: 4px;
}

.chain-card.bec:hover {
    border-color: rgba(247, 147, 26, 0.35);
    box-shadow: 0 8px 32px rgba(247, 147, 26, 0.12), 0 2px 8px rgba(247, 147, 26, 0.08);
}

.chain-card.ete:hover {
    border-color: rgba(98, 126, 234, 0.35);
    box-shadow: 0 8px 32px rgba(98, 126, 234, 0.14), 0 2px 8px rgba(98, 126, 234, 0.08);
}

.chain-card.sle:hover {
    border-color: rgba(0, 255, 163, 0.3);
    box-shadow: 0 8px 32px rgba(0, 255, 163, 0.1), 0 2px 8px rgba(0, 255, 163, 0.06);
}

.chain-left {
    flex: 1;
    min-width: 0;
}

.chain-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    flex-wrap: wrap;
}

.chain-name {
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--heading);
}

.chain-ticker {
    font-family: var(--mono);
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.bec .chain-ticker {
    background: rgba(247, 147, 26, 0.13);
    color: var(--bec);
    border: 1px solid rgba(247, 147, 26, 0.2);
}

.ever .chain-ticker {
    background: rgba(247, 147, 26, 0.08);
    color: var(--bec);
    border: 1px solid rgba(247, 147, 26, 0.15);
}

/* ever ticker */
.ete .chain-ticker {
    background: rgba(98, 126, 234, 0.13);
    color: var(--ete);
    border: 1px solid rgba(98, 126, 234, 0.2);
}

.sle .chain-ticker {
    background: rgba(0, 255, 163, 0.1);
    color: var(--sle);
    border: 1px solid rgba(0, 255, 163, 0.2);
}

.dev-badge {
    font-size: 0.7rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 4px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}

.status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: #ef4444;
}

.status-text {
    font-family: var(--mono);
    font-size: 0.73rem;
    color: var(--muted);
}

.status-text.online {
    color: #22c55e;
}

.status-text.offline {
    color: #ef4444;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(34, 197, 94, 0);
    }
}

.chain-btns {
    display: flex;
    gap: 7px;
    flex-shrink: 0;
}

.btn {
    text-decoration: none;
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-op-4);
    color: var(--text);
    transition: all 0.15s;
    white-space: nowrap;
    font-family: var(--sans);
}

.btn:hover {
    background: var(--bg-op-9);
    border-color: var(--border-hover);
    color: var(--heading);
    transform: translateY(-1px);
}

/* ── DIVIDER ── */
.divider {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 2.5px;
    text-transform: uppercase;
}

/* ── BUILT BY ── */
.built-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px 0;
}

/* Docker 카드 데스크톱 뷰 3열 전체 커버 확장 */
.stack-item.lang-docker {
    grid-column: span 3;
}

.built-title {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 20px;
}

.stack-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.stack-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 12px;
    text-align: center;
    transition: border-color 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}

.stack-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

/* 언어별 상단 컬러 바 */
.stack-item.lang-cpp::before {
    background: #00599C;
}

.stack-item.lang-rust::before {
    background: #CE422B;
}

.stack-item.lang-go::before {
    background: #00ACD7;
}

.stack-item.lang-py::before {
    background: #F7C948;
}

.stack-item.lang-ts::before {
    background: #3178C6;
}

.stack-item.lang-ex::before {
    background: #6E4FA3;
}

.stack-item.lang-scala::before {
    background: #DC322F;
}

.stack-item.lang-kotlin::before {
    background: #7F52FF;
}

.stack-item.lang-sol::before {
    background: #363636;
}

.stack-item.lang-docker::before {
    background: #2496ED;
}

/* Docker Blue */

.stack-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stack-lang {
    font-family: var(--mono);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--heading);
    margin-bottom: 5px;
}

.stack-desc {
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.5;
}

.what-block {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 10px;
}

.what-block-title {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 14px;
    letter-spacing: 0.5px;
}

.what-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.what-list li {
    font-size: 0.87rem;
    color: var(--text);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    line-height: 1.55;
}

.what-list li::before {
    content: '→';
    font-family: var(--mono);
    color: var(--muted);
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 0.8rem;
}

.hl-bec {
    color: var(--bec);
    font-weight: 700;
}

.hl-ete {
    color: var(--ete);
    font-weight: 700;
}

.hl-sle {
    color: var(--sle);
    font-weight: 700;
}

/* ── CONTACT & SOCIAL FALLBACK ── */
.social-section,
.contact-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px 28px 20px;
}

.social-row,
.contact-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
}

.social-btn,
.contact-btn {
    display: flex;
    align-items: center;
    justify-content: center; /* 텍스트와 아이콘 정중앙 정렬 */
    gap: 8px;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text);
    transition: all 0.2s;
    width: 140px; /* 모든 소셜 버튼의 가로 길이를 140px로 일관되게 고정 */
    box-sizing: border-box; /* 패딩이 크기에 영향을 주지 않도록 보장 */
}

.social-btn:hover,
.contact-btn:hover {
    background: var(--bg3);
    border-color: var(--border-hover);
    color: var(--heading);
    transform: translateY(-2px);
}

.social-btn svg,
.contact-btn svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
    flex-shrink: 0;
}

.yt-btn:hover {
    color: #FF0000;
    border-color: rgba(255, 0, 0, 0.25);
}

.dc-btn:hover {
    color: #5865F2;
    border-color: rgba(88, 101, 242, 0.25);
}

.email-btn:hover {
    color: #EA4335;
    border-color: rgba(234, 67, 53, 0.25);
}

.visitor-row {
    text-align: center;
    font-family: var(--mono);
    font-size: 0.76rem;
    color: var(--muted);
}

.visitor-val {
    color: var(--text);
    font-weight: 700;
}

.footer {
    text-align: center;
    padding: 0 20px;
    font-size: 0.75rem;
    color: var(--muted);
    font-family: var(--mono);
    opacity: 0.7;
}

/* ── 페이지 진입 애니메이션 ── */
.header,
.section,
.built-section,
.social-section,
.contact-section {
    animation: fadein 0.5s ease both;
}

.section {
    animation-delay: 0.08s;
}

.built-section {
    animation-delay: 0.14s;
}

.social-section,
.contact-section {
    animation-delay: 0.2s;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 720px) {
    .section {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Specificity(우선순위) 버그 예방을 위해 의사 클래스로 명시적 order 리셋 */
    .section> :nth-child(1) {
        order: 0;
    }

    .section> :nth-child(2) {
        order: 0;
    }

    .section> :nth-child(3) {
        order: 0;
    }

    .section> :nth-child(4) {
        order: 0;
    }

    .section> :nth-child(5) {
        order: 0;
    }

    .chain-card.sle {
        grid-column: span 1;
    }

    .sub-chain-card {
        margin-left: 18px;
    }

    /* 모바일 아코디언 접기/펼치기 */
    .collapsible-divider {
        cursor: pointer;
    }
    .collapsible-divider:hover .divider-label {
        color: var(--heading);
    }
    .collapsible-divider .toggle-icon {
        display: inline-block;
        margin-left: 6px;
        font-size: 0.65rem;
        vertical-align: middle;
        transition: transform 0.2s ease;
        transform: rotate(-90deg); /* 기본적으로 접힌 상태 (우향 화살표) */
    }
    .collapsible-divider.expanded .toggle-icon {
        transform: rotate(0deg); /* 펼쳐졌을 때 (하향 화살표) */
    }
    .section:not(.expanded),
    .demo-section:not(.expanded) {
        display: none !important;
    }
}

/* ── COLLAPSIBLE TOGGLE ── */
.toggle-icon {
    display: none;
}

@media (max-width: 480px) {
    .stack-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 모바일 2열 그리드 밸런싱을 위해 Docker 카드를 1칸 크기로 리셋 */
    .stack-item.lang-docker {
        grid-column: span 1;
    }

    .chain-card {
        flex-wrap: wrap;
    }

    .chain-btns {
        width: 100%;
        justify-content: flex-end;
    }

    h1 {
        font-size: 1.45rem;
    }
}

/* ── DEMO VIDEOS CAROUSEL ── */
.demo-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    animation: fadein 0.5s ease both;
    animation-delay: 0.11s;
}

.demo-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for webkit */
.demo-grid::-webkit-scrollbar {
    height: 6px;
}

.demo-grid::-webkit-scrollbar-track {
    background: transparent;
}

.demo-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.demo-grid::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

.demo-item {
    flex: 0 0 220px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.25s, transform 0.2s, background 0.2s, box-shadow 0.25s;
}

.demo-item:hover {
    transform: translateY(-3px);
    background: var(--bg3);
    border-color: var(--border-hover);
    box-shadow: 0 8px 24px var(--bg-op-9);
}

.demo-label {
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--heading);
    text-align: center;
}

.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}