/* Ruach 홈: 애플식 검정 무대·밝은 갤러리. 움직임은 이름 뜻(숨·바람)에서 나온다 */
@import url("./tokens.css");
@import url("./base.css");

body { background: var(--color-paper); color: var(--color-ink); line-height: 1.5; word-break: keep-all; letter-spacing: -0.01em; --link: var(--color-accent); }
h1, h2, h3 { font-weight: 700; letter-spacing: var(--tracking-display); line-height: 1.08; color: inherit; }
h2 { font-size: clamp(2.25rem, 3.5vw + 1rem, 4rem); }
h3 { font-size: var(--text-xl); line-height: 1.2; }

/* 위쪽 막대: 검정 유리 */
.bar { position: sticky; top: 0; z-index: var(--z-sticky-nav); height: var(--nav-height); background: color-mix(in oklab, var(--color-night) 86%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); color: var(--color-night-ink); --link: var(--color-night-accent); }
.bar-in { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.wordmark { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.02em; color: var(--color-night-ink); text-decoration: none; }
.bar nav { display: flex; align-items: center; gap: var(--space-lg); }
.bar nav a:not(.btn) { color: var(--color-night-muted); text-decoration: none; font-size: var(--text-xs); transition: color var(--dur-short) var(--ease-out); }
.bar nav a:not(.btn):hover { color: var(--color-night-ink); }

/* 버튼: 파란 알약 하나, 테두리 알약 하나 */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--space-lg); border: 1px solid var(--color-accent); border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-md); font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.btn:hover { background: color-mix(in oklab, var(--color-accent) 86%, var(--color-night)); }
.btn:active { transform: scale(0.97); }
.btn-sm { min-height: 28px; padding: 0 var(--space-sm); font-size: var(--text-xs); }
.btn-line { background: transparent; color: var(--color-accent); min-height: 40px; font-size: var(--text-sm); }
.btn-line:hover { background: var(--color-accent); color: var(--color-accent-ink); }
.link { color: var(--link); text-decoration: none; }
.link:hover { text-decoration: underline; }
.btn:focus-visible, .link:focus-visible, .wordmark:focus-visible, .bar nav a:focus-visible, .catalogue:focus-visible, .store-link:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; transition: none; }

/* 첫 화면: 검정 무대 */
.hero { position: relative; isolation: isolate; overflow: clip; background: var(--color-night); color: var(--color-night-ink); --link: var(--color-night-accent); }
.glow { position: absolute; z-index: -1; left: 50%; bottom: -30%; width: min(1100px, 140%); aspect-ratio: 1; translate: -50% 0; border-radius: 50%; background: radial-gradient(closest-side, var(--color-glow), transparent); pointer-events: none; }
.glow::before, .glow::after, .ripple { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(closest-side, transparent 62%, var(--color-ripple) 70%, transparent 78%); opacity: 0; }
.hero-in { min-height: calc(100svh - var(--nav-height)); display: grid; align-content: center; justify-items: center; gap: var(--space-3xl); padding-block: var(--space-3xl); text-align: center; }
.hero-copy { display: grid; justify-items: center; gap: var(--space-lg); }
.hero h1 { font-size: clamp(3.5rem, 8vw + 1rem, 8.5rem); padding-bottom: 0.08em; letter-spacing: -0.035em; background: linear-gradient(180deg, var(--color-night-ink) 30%, var(--color-night-muted)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-lg); width: min(100%, 600px); }
.store-link { display: block; border-radius: 22.5%; transition: transform var(--dur-short) var(--ease-out); }
.store-link:hover { transform: scale(1.06); }
.store-link:active { transform: scale(0.96); }
.icon-link { width: fit-content; }
.shelf img { width: 100%; aspect-ratio: 1; border-radius: 22.5%; box-shadow: 0 10px 30px color-mix(in oklab, var(--color-ink) 16%, transparent); }

/* 앱: 밝은 갤러리 */
.apps { background: var(--color-paper); padding-block: var(--section-gap-s); }
.apps-pin { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); container-type: inline-size; }
.catalogue { --pad: max(var(--gutter), calc((100cqw - var(--container)) / 2 + var(--gutter))); list-style: none; margin: 0; display: flex; gap: var(--space-lg); padding: var(--space-md) var(--pad) var(--space-lg); scroll-padding-inline: var(--pad); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.app { flex: 0 0 clamp(280px, 28vw, 380px); scroll-snap-align: start; display: grid; grid-template-rows: auto 1fr auto; gap: var(--space-lg); padding: var(--space-xl) var(--space-xl) var(--space-lg); min-height: 440px; background: var(--color-paper-2); border-radius: var(--radius-card); transition: transform var(--dur-long) var(--ease-out); }
.app:hover { transform: scale(1.015); }
.icon { width: 120px; height: 120px; border-radius: 22.5%; box-shadow: 0 10px 30px color-mix(in oklab, var(--color-ink) 14%, transparent); }
.app-text { display: grid; align-content: start; gap: var(--space-xs); min-width: 0; }
.app-text p:not(.docs) { color: var(--color-ink-2); }
.docs { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-md); margin-top: var(--space-xs); font-size: var(--text-sm); }
.stores { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

/* 맺음 */
.close { background: var(--color-paper); padding-block: var(--space-xl); }
.close-in { display: grid; gap: var(--space-md); border-top: 1px solid var(--color-rule); padding-top: var(--space-lg); }
.legal { display: grid; gap: var(--space-xs); font-size: var(--text-xs); line-height: 1.6; }
.facts { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-lg); }
.facts > div { display: flex; gap: var(--space-xs); }
.facts dt { color: var(--color-muted); }
.facts dd { margin: 0; color: var(--color-ink-2); }
.sign { font-weight: 600; color: var(--color-ink); }
.meta { color: var(--color-muted); }

/* ── 움직임 ── 모두 끝 모습이 기본값이라 줄이기 설정·미지원 브라우저는 완성된 페이지를 본다 */
@media (prefers-reduced-motion: no-preference) {
  /* 불러올 때: 제목이 올라오고, 빛이 숨 쉬며 물결이 번진다 */
  .hero-copy > * { animation: rise 1s var(--ease-out) both; }
  .glow { animation: breathe 5s var(--ease-in-out) infinite alternate both; }
  .glow::before, .glow::after { animation: ripple 9s var(--ease-out) infinite; }
  .glow::after { animation-delay: 3s; }
  .glow .ripple { animation: ripple 9s var(--ease-out) 6s infinite; }
}
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes ripple { 0% { opacity: 0; scale: 0.25; } 15% { opacity: 0.9; } 100% { opacity: 0; scale: 1.25; } }
@keyframes breathe { from { opacity: 0.55; scale: 0.88; } to { opacity: 1; scale: 1.04; } }

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* 첫 화면을 떠날 때: 제목이 작아지며 흐려진다 */
    .hero-copy { animation: hero-out linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    /* 앱 구간에 들어설 때: 아이콘이 각자 다른 거리에서 바람에 실려 올라온다 */
    .shelf li { animation: drift-in linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  }
  /* 넓은 화면: 앱 구간을 붙잡고 카드를 가로로 흘린다(아이콘 줄은 위에 머문다) */
  @media (prefers-reduced-motion: no-preference) and (min-width: 60rem) {
    .apps { height: 420svh; padding: 0; view-timeline: --apps block; }
    .apps-pin { position: sticky; top: 0; height: 100svh; align-content: center; overflow: clip; padding-top: var(--nav-height); }
    .catalogue { width: max-content; overflow: visible; scroll-snap-type: none; animation: slide linear both; animation-timeline: --apps; animation-range: contain 4% contain 96%; }
    .app { min-height: min(460px, 52svh); }
  }
}
@keyframes hero-out { to { opacity: 0; scale: 0.9; translate: 0 -60px; } }
@keyframes drift-in { from { opacity: 0; translate: 0 calc(var(--lift) * -1); rotate: calc(var(--n) * 2deg - 5deg); } to { opacity: 1; translate: 0 0; rotate: 0deg; } }
@keyframes slide { to { transform: translateX(calc(-100% + 100cqw)); } }

@media (max-width: 40rem) {
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 280px); }
  .app { flex-basis: 84%; padding: var(--space-lg); min-height: 400px; }
  .bar nav { gap: var(--space-md); }
}
