/* won-space.com 첫 화면 (WebGL 포트폴리오)
   색은 여섯 가지만 쓴다: #080808 · #121212 · #282828 · #FFFFFF · #EF1D2D · #16C75A
   글꼴(모두 SIL Open Font License, Google Fonts): Jost · Cormorant Garamond · IBM Plex Sans KR */

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

:root {
    --black: #080808;
    --surface: #121212;
    --line: #282828;
    --white: #FFFFFF;
    --red: #EF1D2D;
    --green: #16C75A;
    --sans: "Jost", "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    --serif: "Cormorant Garamond", "Times New Roman", serif;
    --gutter: clamp(20px, 4vw, 56px);
    --screen: 100vh;
    color-scheme: dark;
}

@supports (height: 100svh) {
    :root {
        --screen: 100svh;
    }
}

html {
    background: var(--black);
    color: var(--white);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--black);
    color: var(--white);
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

p, h1, h2, h3, dd, li {
    word-break: keep-all;
    overflow-wrap: break-word;
}

a {
    color: inherit;
}

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

:focus-visible {
    outline: 1px solid var(--white);
    outline-offset: 4px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 50;
    padding: 10px 14px;
    background: var(--white);
    color: var(--black);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* ---------- 연락 (오른쪽 위) ---------- */

.contact-bar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px var(--gutter);
}

.contact-mail {
    font-size: 0.74rem;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 3px;
    transition: border-color 0.6s ease;
}

.contact-mail:hover {
    border-bottom-color: var(--white);
}

.contact-github {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    transition: border-color 0.6s ease;
}

.contact-github:hover {
    border-color: var(--white);
}

/* ---------- WebGL 무대 ---------- */

.stage {
    position: relative;
}

.stage-sticky {
    position: sticky;
    top: 0;
    z-index: 0;
    height: var(--screen);
    overflow: hidden;
    background: var(--black);
}

.stage-sticky canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: pan-y;
}

.stage-content {
    position: relative;
    z-index: 1;
    margin-top: calc(var(--screen) * -1);
    pointer-events: none;
}

.stage-content a,
.stage-content button {
    pointer-events: auto;
}

.tile-label {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    display: none;
    min-width: 168px;
    max-width: min(300px, calc(100vw - 32px));
    padding: 14px 16px 15px;
    background: var(--black);
    border: 1px solid var(--line);
    color: var(--white);
    pointer-events: none;
    will-change: transform;
}

.tile-label.is-visible {
    display: block;
}

.tile-label strong {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.tile-label span {
    display: block;
    margin-top: 6px;
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.18em;
}

.tile-label a {
    display: none;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--white);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-decoration: none;
    pointer-events: auto;
}

.tile-label.is-touch a {
    display: block;
}

/* ---------- 이야기 글 ---------- */
/* 장마다 글 한 덩어리(작은 머리 · 큰 숫자 · 한 줄). 문장 없이 영문 이름표와 숫자만. 고급스러움은 글꼴 · 자간 · 크기로. */

.chapter {
    position: relative;
    height: calc(var(--screen) * var(--len, 1));
}

.chapter-text {
    position: sticky;
    top: 92px;
    max-width: 600px;
    padding: 0 var(--gutter);
}

.chapter-kicker {
    margin: 0 0 14px;
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.34em;
    line-height: 1.4;
    text-transform: uppercase;
}

.chapter-title {
    margin: 0;
    font-size: clamp(1.5rem, 2.5vw, 2.15rem);
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.28;
}

/* 큰 숫자: 가는 세리프, 좁은 자간 */
.chapter-num {
    margin-left: -0.04em;
    font-family: var(--serif);
    font-size: clamp(3.6rem, 6.4vw, 6.4rem);
    font-weight: 300;
    font-variant-numeric: lining-nums;
    letter-spacing: -0.02em;
    line-height: 0.84;
}

/* 첫 앱 이름 */
.chapter-name {
    font-family: var(--serif);
    font-size: clamp(2.6rem, 4.6vw, 4.4rem);
    font-weight: 300;
    letter-spacing: 0;
    line-height: 0.96;
}

.chapter-line {
    margin: 16px 0 0;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.26em;
    line-height: 1.6;
}

.chapter-line-sub {
    margin-top: 6px;
    font-weight: 400;
    letter-spacing: 0.14em;
}

/* ---------- 출시 탑의 축 (WebGL 위 HTML, 매 프레임 카메라에 맞춰 옮긴다) ---------- */
/* 가는 축 하나, 작은 달 숫자, 해 이름, 지금 달을 가리키는 가는 빨간 선 하나와 그 위의 이름표. */

.timeline {
    position: absolute;
    inset: 0;
    z-index: 2;
    visibility: hidden;
    pointer-events: none;
}

.story-axis,
.story-tick,
.story-year,
.story-head,
.story-now {
    position: absolute;
    top: 0;
    left: 0;
    will-change: transform;
}

.story-axis {
    height: 1px;
    background: var(--white);
    opacity: 0.3;
    transform-origin: 0 0;
}

.story-tick {
    font-size: 0.56rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    line-height: 1;
    white-space: nowrap;
    opacity: 0.66;
}

.story-year {
    padding-right: 4px;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.26em;
    line-height: 1;
    white-space: nowrap;
}

.story-head {
    width: 1px;
    background: var(--red);
    transform-origin: 0 0;
}

.story-now {
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    line-height: 1;
    white-space: nowrap;
}

/* 첫 화면 바닥의 빨간 점 하나(정확한 색 원) */
.stage-dot {
    position: absolute;
    top: -4px;
    left: -4px;
    z-index: 2;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    visibility: hidden;
    pointer-events: none;
    will-change: transform;
}

/* ---------- 첫 화면 ---------- */

.hero {
    position: relative;
    min-height: var(--screen);
}

.hero-text {
    position: absolute;
    left: 0;
    bottom: clamp(88px, 14vh, 140px);
    top: auto;
}

/* 첫 화면의 주인공은 앱 하나가 아니라 숫자다. */
.hero-text .chapter-num {
    margin: 6px 0 14px;
    font-size: clamp(7rem, 14vw, 13rem);
    line-height: 0.8;
}

.js .hero-text > * {
    animation: rise 1.6s cubic-bezier(0.22, 1, 0.36, 1) 1.1s both;
}

.js .hero-text > :nth-child(2) {
    animation-delay: 1.25s;
}

.js .hero-text > :nth-child(3) {
    animation-delay: 1.4s;
}

@keyframes rise {
    0% {
        opacity: 0;
        transform: translateY(14px);
    }

    100% {
        opacity: 1;
        transform: none;
    }
}

.hero-cue {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 1px;
    height: clamp(40px, 7vh, 64px);
    background: var(--line);
    overflow: hidden;
}

.hero-cue::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 40%;
    background: var(--white);
    animation: cue 3.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes cue {
    0% {
        transform: translateY(-100%);
    }

    100% {
        transform: translateY(260%);
    }
}

/* ---------- 숫자 ---------- */

.numbers {
    position: relative;
    height: calc(var(--screen) * 2);
}

.numbers-pin {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: var(--screen);
    padding: 88px var(--gutter) clamp(28px, 6vh, 64px);
}

.numbers-big {
    display: none;
}

.numbers-caption {
    margin: 0 0 18px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.2em;
}

.stats {
    display: flex;
    justify-content: center;
    margin: 0;
}

.stats div {
    padding: 0 clamp(18px, 3.4vw, 44px);
    text-align: center;
}

.stats div:not(:last-child) {
    border-right: 1px solid var(--line);
}

.stats dt {
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    white-space: nowrap;
}

.stats dd {
    margin: 6px 0 0;
    font-family: var(--serif);
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    font-weight: 300;
    line-height: 1;
}

/* ---------- 갤러리 벽 ---------- */

.wall {
    position: relative;
    min-height: calc(var(--screen) * 1.5);
}

/* 벽 아래 바닥 쪽에 머문다. */
.wall-text {
    top: calc(var(--screen) - 132px);
}

/* ---------- 유튜브 채널 ---------- */
/* WebGL에서는 채널마다 둥근 3D 프로필 판이 서고, 아래 목록의 링크가 그 판 밑 이름표가 된다.
   WebGL이 없으면 같은 목록이 둥근 프로필 + 이름 + 주제의 가운데 맞춤 격자로 남는다(데스크톱 4 + 3, 휴대폰 2열). */

.channels {
    position: relative;
    height: calc(var(--screen) * 1.5);
}

.channels[hidden] {
    display: none;
}

.channel-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 44px 24px;
    max-width: 980px;
    margin: 0 auto;
    padding: 48px var(--gutter) 0;
    list-style: none;
}

.channel-item {
    flex: 0 0 196px;
    min-width: 0;
}

.channel-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    pointer-events: auto;
}

.channel-link img {
    width: 128px;
    height: 128px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
}

.channel-link strong {
    display: block;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.channel-link span {
    display: block;
    min-width: 0;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    line-height: 1.5;
    text-transform: uppercase;
}

.channel-link:hover strong,
.channel-link:focus-visible strong {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* 무대 위 이름표 */
.channel-list.is-stage {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.channel-list.is-stage .channel-item {
    position: absolute;
    top: 0;
    left: 0;
    visibility: hidden;
    text-align: center;
    will-change: transform;
}

.channel-list.is-stage .channel-link {
    display: block;
    padding: 4px 0;
    border: 0;
}

.channel-list.is-stage img {
    display: none;
}

.channel-list.is-stage strong {
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}

.channel-list.is-stage span {
    margin-top: 4px;
    font-size: 0.56rem;
    letter-spacing: 0.22em;
}

/* ---------- 끝: 비어 있는 다음 자리 ---------- */

.next {
    position: relative;
    height: var(--screen);
}

.next-text {
    position: absolute;
    top: calc(49% + 44px);
    left: 0;
    right: 0;
    margin: 0 auto;
    text-align: center;
}

.next-mail {
    font-size: 0.86rem;
    letter-spacing: 0.1em;
    text-decoration: none;
    border-bottom: 1px solid var(--white);
    padding-bottom: 3px;
}

.wall-fallback {
    display: none;
}

/* WebGL을 쓸 수 없을 때: 글은 위에서 아래로 이어서 읽고, 같은 아이콘을 HTML 격자로 */
.no-webgl .stage-sticky,
.no-webgl .hero-cue {
    display: none;
}

.no-webgl .hero,
.no-webgl .chapter,
.no-webgl .channels,
.no-webgl .next {
    height: auto;
    min-height: 0;
    padding: 56px 0 0;
}

.no-webgl .hero {
    padding-top: 120px;
}

.no-webgl .chapter-text,
.no-webgl .hero-text,
.no-webgl .next-text {
    position: static;
    text-align: left;
}

.no-webgl .hero-text > * {
    animation: none;
}

.no-webgl .next {
    padding-bottom: 96px;
}

.no-webgl .stage-content {
    margin-top: 0;
    pointer-events: auto;
}

.no-webgl .numbers {
    height: auto;
}

.no-webgl .numbers-pin {
    position: relative;
    height: auto;
    padding-top: 120px;
    gap: 28px;
}

.no-webgl .numbers-big {
    display: block;
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(7rem, 30vw, 16rem);
    font-weight: 300;
    line-height: 0.9;
}

.no-webgl .wall {
    min-height: 0;
    padding: 56px var(--gutter) 24px;
}

.no-webgl .wall-text {
    padding: 0 0 32px;
}

.no-webgl .wall-fallback {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 18px;
    max-width: 1100px;
    margin: 0 auto;
}

.wall-fallback a {
    display: block;
}

.wall-fallback img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 22%;
}

/* ---------- 앱 목록 (HTML) : 검색 · 화면 낭독기용, 키보드로 들어오면 보인다 ---------- */

.apps:not(:focus-within) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.apps {
    position: relative;
    z-index: 2;
    padding: 96px var(--gutter) 80px;
    background: var(--black);
    border-top: 1px solid var(--line);
}

.apps-title {
    margin: 0 0 32px;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.app-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 32px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-item {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 4px 14px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.app-main {
    display: contents;
    text-decoration: none;
}

.app-main img {
    grid-row: span 2;
    width: 48px;
    height: 48px;
    border-radius: 11px;
    background: var(--surface);
}

.app-name {
    display: block;
    min-width: 0;
    font-weight: 500;
    line-height: 1.3;
}

.app-main:hover .app-name,
.app-main:focus-visible .app-name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.app-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    min-width: 0;
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.app-meta a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- 폭별 조정 ---------- */

@media (max-width: 1100px) {
    .app-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .chapter-text {
        top: 76px;
    }

    .chapter-kicker {
        margin-bottom: 10px;
        letter-spacing: 0.3em;
    }

    .chapter-num {
        font-size: clamp(3.2rem, 15vw, 4.2rem);
    }

    .chapter-name {
        font-size: clamp(2.4rem, 11vw, 3.2rem);
    }

    .chapter-line {
        margin-top: 12px;
        font-size: 0.66rem;
        letter-spacing: 0.22em;
    }

    .chapter-line-sub {
        margin-top: 4px;
        letter-spacing: 0.1em;
    }

    .channel-list {
        gap: 36px 16px;
        padding-top: 40px;
    }

    .channel-item {
        flex-basis: calc(50% - 8px);
    }

    .channel-link img {
        width: 104px;
        height: 104px;
        margin-bottom: 14px;
    }

    .channel-list.is-stage strong {
        font-size: 0.8rem;
    }

    .channel-list.is-stage span {
        font-size: 0.52rem;
        letter-spacing: 0.16em;
    }

    .wall-text {
        top: calc(var(--screen) - 104px);
    }

    /* 휴대폰 첫 화면: 글은 위, 앱들은 그 아래 수면 위에 줄지어. */
    .hero-text {
        top: 76px;
        bottom: auto;
    }

    .hero-text .chapter-num {
        margin: 4px 0 10px;
        font-size: clamp(5.6rem, 30vw, 7.6rem);
    }

    .next-text {
        top: calc(40% + 17vw + 40px);
    }

    .stage-dot {
        top: -3px;
        left: -3px;
        width: 6px;
        height: 6px;
    }

    .contact-bar {
        gap: 12px;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .contact-mail {
        font-size: 0.68rem;
        letter-spacing: 0.08em;
    }

    .stats div {
        padding: 0 14px;
    }

    .stats dt {
        font-size: 0.56rem;
        letter-spacing: 0.18em;
    }

    .app-list {
        grid-template-columns: minmax(0, 1fr);
    }
}

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

    .hero-cue::after {
        animation: none;
        transform: translateY(60%);
    }

    .js .hero-text > * {
        animation: none;
    }
}
