/*
  애플 홈페이지 결: 하양→하늘색 그라데이션 바탕 + 강조색 하나(파랑), 큰 타이포가 곧 비주얼.
  모서리 규칙: 조작 요소는 알약(999px), 카드 28px, 달력 칸 20px.
  모션 규칙: transform·opacity만. 스크롤 연동은 CSS animation-timeline, 미지원 브라우저는 정지 화면 그대로.
*/
:root {
  --bg: #f4f9ff;
  /* 바탕: 위는 하양, 오른쪽 위와 왼쪽 아래에 하늘색이 번진다 */
  --backdrop:
    radial-gradient(120vmax 80vmax at 100% -10%, #cfe7ff, transparent 55%),
    radial-gradient(100vmax 70vmax at -10% 110%, #dbeeff, transparent 55%),
    linear-gradient(180deg, #ffffff, #eef6ff);
  --surface: #ffffff;
  /* 무채색 회색 대신 하늘색 기가 도는 중립색. 회색이 섞이면 바탕이 탁해 보인다 */
  --surface-2: #e6f1fc;
  --ink: #1d1d1f;
  --muted: #5d6b7c;
  --line: #d4e4f5;
  --accent: #0066cc;
  --accent-soft: #e3effd;
  --on-accent: #ffffff;
  --card-dark: #0b2a4a;
  --card-dark-muted: #a9c3e0;
  --glow: rgb(120 195 255 / .38); /* 짙은 파랑을 옅게 깔면 회색으로 탁해져서, 밝은 하늘색을 진하게 */
  --ease: cubic-bezier(.16, 1, .3, 1);
  --pad: clamp(20px, 5vw, 64px);
  color-scheme: light dark;
  interpolate-size: allow-keywords; /* details 열림 높이 애니메이션 (지원 브라우저만) */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --backdrop:
      radial-gradient(120vmax 80vmax at 100% -10%, #0f2a47, transparent 55%),
      radial-gradient(100vmax 70vmax at -10% 110%, #0c2138, transparent 55%),
      linear-gradient(180deg, #0d1117, #0b1520);
    --surface: #1c1c1e; --surface-2: #2c2c2e; --ink: #f5f5f7; --muted: #a1a1a6; --line: #38383a;
    --accent: #2997ff; --accent-soft: #10233a; --on-accent: #101012; --card-dark: #2c2c2e; --card-dark-muted: #a1a1a6; --glow: rgb(41 151 255 / .2);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  position: relative;
  font: 17px/1.5 "Pretendard Variable", Pretendard, system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased; word-break: keep-all;
}
/* 그라데이션은 고정된 뒷판에. 스크롤 요소에 두면 모바일에서 매 프레임 다시 그린다 */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--backdrop); pointer-events: none; }
[hidden] { display: none !important; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
a { color: inherit; text-decoration: none; }
ol { list-style: none; margin: 0; padding: 0; }

/* ---- 유리 내비게이션 (웹 근사치. 애플 Liquid Glass 공식 CSS는 없다) ---- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--line) 70%, transparent);
}
@media (prefers-reduced-transparency: reduce) { .nav { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; } }
.nav-in { max-width: 1080px; margin: 0 auto; padding: 0 var(--pad); height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.02em; }
.brand i { color: var(--accent); font-size: 1.35rem; }
@media (max-width: 479px) { .brand span { display: none; } }
.day { display: flex; align-items: center; gap: 2px; }
.day select {
  appearance: none; border: 0; background: none; padding: 6px 8px; font-size: .94rem; font-weight: 600;
  text-align: center; text-align-last: center; cursor: pointer; border-radius: 999px;
}
.day select:hover { background: var(--surface-2); }
.icon {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 999px;
  background: none; font-size: 1.05rem; transition: background .2s, transform .2s var(--ease), opacity .2s;
}
.icon:hover:not(:disabled) { background: var(--surface-2); }
.icon:active:not(:disabled) { transform: scale(.92); }
.icon:disabled { opacity: .3; cursor: default; }

/* ---- 히어로: 그날의 1위가 곧 헤드라인 ---- */
.hero {
  position: relative; isolation: isolate; overflow: clip; display: grid; place-items: center; text-align: center;
  min-height: calc(100dvh - 56px); padding: clamp(40px, 8vh, 88px) var(--pad);
}
.hero::before { /* 뒤에서 은은하게 받쳐 주는 빛. 스크롤에 따라 커진다 */
  content: ""; position: absolute; left: 50%; bottom: 6%; width: min(900px, 120vw); aspect-ratio: 1.6;
  translate: -50% 0; border-radius: 50%; background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none; z-index: -1;
}
.hero-in { width: 100%; max-width: 980px; display: grid; justify-items: center; gap: clamp(14px, 2.4vh, 24px); }
.kicker { color: var(--muted); font-size: clamp(1rem, .9rem + .5vw, 1.3rem); font-weight: 600; letter-spacing: -.01em; }
.headline {
  /* 글자 수가 많으면 작아진다: 한글은 글자 폭이 대략 1em */
  font-size: clamp(2.8rem, min(24vw, calc(84vw / var(--len))), 9rem);
  font-weight: 800; letter-spacing: -.045em; line-height: 1.04; text-wrap: balance; padding-bottom: .06em;
}
.headline .w { display: inline-block; white-space: nowrap; }
.headline .c { display: inline-block; }
.chart { width: min(680px, 100%); color: var(--accent); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .line { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart figcaption { margin-top: 8px; color: var(--muted); font-size: .88rem; }
.big-ratio { font-size: clamp(3rem, 2rem + 5vw, 6rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: clamp(1rem, .95rem + .3vw, 1.2rem); line-height: 1.5; max-width: 36em; text-wrap: balance; }
.cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 12px 22px; border-radius: 999px; white-space: nowrap;
  font-weight: 600; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent);
  transition: transform .25s var(--ease), background .2s, color .2s;
}
.btn:hover { background: var(--accent); color: var(--on-accent); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
.btn.small { padding: 8px 14px; font-size: .9rem; }

.skel { color: transparent; border-radius: 14px; background: var(--surface-2); }
.headline.skel { width: min(520px, 80vw); }
.chart.skel { height: 150px; }

/* ---- 섹션 ---- */
.block { max-width: 1080px; margin: 0 auto; padding: clamp(64px, 12vh, 128px) var(--pad) 0; }
.title { font-size: clamp(2rem, 1.3rem + 3vw, 3.5rem); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; margin-bottom: clamp(28px, 5vh, 48px); text-wrap: balance; }
.subtitle { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); font-weight: 800; letter-spacing: -.03em; margin: clamp(48px, 8vh, 80px) 0 16px; }
.block-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.arrows { display: flex; gap: 8px; margin-bottom: clamp(28px, 5vh, 48px); }
.arrows .icon { width: 44px; height: 44px; background: var(--surface-2); font-size: 1.2rem; }
.arrows .icon:hover:not(:disabled) { background: var(--line); }
@media (max-width: 767px) { .arrows { display: none; } }
.none { padding: 40px 0; color: var(--muted); font-size: 1.05rem; }
.error { max-width: 1080px; margin: 0 auto; padding: 0 var(--pad); color: var(--muted); text-align: center; }

/* ---- 검색어: 1~5위는 크게, 6~25위는 두 단 ---- */
details { border-bottom: 1px solid var(--line); }
summary { display: flex; align-items: center; gap: clamp(12px, 2vw, 20px); padding: 16px 0; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.rank { flex: none; width: 1.6em; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.term { flex: 1; min-width: 0; display: grid; gap: 4px; }
.desc { color: var(--muted); font-size: .9rem; font-weight: 500; line-height: 1.45; letter-spacing: -.01em; }
.lead .big .desc { font-size: clamp(.95rem, .88rem + .25vw, 1.08rem); }
.ai { flex-basis: 100%; min-width: 0; display: grid; gap: 10px; color: var(--muted); font-size: .8rem; }
.ai i { color: var(--accent); margin-right: 4px; }
.suggest { min-width: 0; overflow-x: auto; } /* 구글 칩 줄은 가로로 길다. 칸을 밀어내지 않고 안에서 스크롤 */
.name { flex: 1; min-width: 0; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
summary:hover .name { color: var(--accent); }
.chev { flex: none; color: var(--muted); font-size: 1.1rem; transition: transform .35s var(--ease); }
details[open] .chev { transform: rotate(45deg); }
.badge { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 700; white-space: nowrap; }

.lead .big summary { padding: clamp(18px, 3vh, 28px) 0; }
.lead .big .rank { font-size: clamp(1.2rem, 1rem + 1vw, 1.8rem); }
.lead .big .name { font-size: clamp(1.6rem, 1.1rem + 2.4vw, 3rem); letter-spacing: -.035em; }
.lead li:first-child .rank { color: var(--accent); }
.spark { flex: none; width: clamp(72px, 12vw, 140px); height: auto; overflow: visible; color: var(--accent); }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.rest { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 48px; margin-top: 12px; }
@media (min-width: 768px) { .rest { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rest .name { font-size: 1.1rem; }

.more { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 0 0 22px calc(1.6em + clamp(12px, 2vw, 20px)); }
.stats { display: flex; gap: clamp(20px, 4vw, 40px); }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { font-weight: 700; font-size: 1.05rem; }
details::details-content { block-size: 0; overflow: hidden; transition: block-size .45s var(--ease), content-visibility .45s allow-discrete; }
details[open]::details-content { block-size: auto; }

/* ---- 위키: 가로로 넘기는 카드 ---- */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: clamp(240px, 70vw, 300px); gap: 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
  margin: 0 calc(-1 * var(--pad)); padding: 8px var(--pad) 24px; scroll-padding-inline: var(--pad);
}
.rail::-webkit-scrollbar { display: none; }
.card {
  position: relative; scroll-snap-align: start; display: flex; flex-direction: column; gap: 10px; min-height: 360px; padding: 28px;
  border-radius: 28px; background: var(--surface); box-shadow: 0 0 0 1px var(--line);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease);
}
.card:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 0 0 1px var(--line), 0 24px 48px -24px color-mix(in srgb, var(--ink) 30%, transparent); }
.card:active { transform: scale(.98); }
.card .count { font-size: clamp(3rem, 2.4rem + 2vw, 4.2rem); font-weight: 800; letter-spacing: -.05em; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.card-title { margin-top: auto; font-size: 1.45rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.25; }
.card-title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* 카드 전체가 문서 링크. 접힌 근거만 위로 올린다 */
.card .desc { font-size: .95rem; }
.card .meta { color: var(--muted); font-size: .85rem; }
.card-ai { position: relative; z-index: 1; border: 0; }
.card-ai summary { padding: 6px 0 0; font-size: .8rem; font-weight: 600; color: inherit; opacity: .75; }
.card-ai[open] summary { opacity: 1; }
.card:nth-child(1) { background: var(--accent); box-shadow: none; }
.card:nth-child(1) :is(.count, .card-title, .desc, .meta, .card-ai, .card-ai i) { color: var(--on-accent); }
.card:nth-child(3n + 2) { background: var(--card-dark); box-shadow: none; }
.card:nth-child(3n + 2) .card-title { color: #f5f5f7; }
.card:nth-child(3n + 2) :is(.desc, .meta, .card-ai) { color: var(--card-dark-muted); }
.card:nth-child(3n + 2) .count { color: #2997ff; }
.card:nth-child(3n + 3) { background: linear-gradient(160deg, var(--accent-soft), var(--surface) 70%); }

.views { flex: none; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* ---- 지난 날의 1위 ---- */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 40vw), 1fr)); gap: 12px; }
.dayc {
  position: relative; width: 100%; height: 100%; display: grid; align-content: start; gap: 6px; padding: 16px 16px 18px;
  border: 0; border-radius: 20px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); text-align: left;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), background .2s;
}
.dayc span { color: var(--muted); font-size: .8rem; font-weight: 600; }
.dayc strong { font-size: 1.05rem; letter-spacing: -.02em; line-height: 1.3; overflow-wrap: anywhere; }
.dayc i { position: absolute; top: 14px; right: 14px; color: var(--muted); }
.dayc:hover { transform: translateY(-3px); box-shadow: 0 0 0 1px var(--accent); }
.dayc:active { transform: scale(.97); }
.dayc[aria-current] { background: var(--accent); box-shadow: none; }
.dayc[aria-current] :is(span, strong, i) { color: var(--on-accent); }

.foot { max-width: 1080px; margin: clamp(80px, 14vh, 140px) auto 0; padding: 24px var(--pad) 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; line-height: 1.9; }
.foot a { text-decoration: underline; text-underline-offset: 2px; }

/* ================= 모션 ================= */
@media (prefers-reduced-motion: no-preference) {
  /* 스켈레톤 빛 */
  .skel { background: linear-gradient(90deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }

  /* 히어로 첫 등장: 글자가 하나씩 떠오르고, 차트가 그려진다 */
  .hero-in > .kicker { animation: fade-up .8s var(--ease) both; }
  .headline .c { animation: char-in .9s var(--ease) both; animation-delay: calc(120ms + var(--i) * 40ms); }
  .chart .line { stroke-dasharray: 1; animation: draw 1.6s .45s var(--ease) both; }
  .chart .area, .chart figcaption { animation: fade .9s 1.1s var(--ease) both; }
  .hero-in > :is(.big-ratio, .sub) { animation: fade-up .9s .5s var(--ease) both; }
  .cta { animation: fade-up .9s .7s var(--ease) both; }

  /* 날짜 바꿈: 교차 페이드 */
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .4s; animation-timing-function: var(--ease); }

  @supports (animation-timeline: view()) {
    /* 스크롤하면 히어로가 살짝 멀어지고, 뒤의 빛은 커진다 */
    .hero-in { animation: hero-out linear both; animation-timeline: scroll(root); animation-range: 0 80vh; }
    .hero::before { animation: glow-grow linear both; animation-timeline: scroll(root); animation-range: 0 80vh; }

    /* 제목·목록·칸은 화면에 들어오며 떠오른다 */
    .title, .subtitle, .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 70%; }
    .lead .spark polyline { stroke-dasharray: 1; animation: draw linear both; animation-timeline: view(); animation-range: entry 40% cover 45%; }

    /* 카드는 가로로 들어올 때 커진다 */
    .card { animation: card-in linear both; animation-timeline: view(inline); animation-range: entry 0% entry 90%; }
  }
}

@keyframes shimmer { to { background-position: -150% 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } }
@keyframes char-in { from { opacity: 0; transform: translateY(.45em) scale(.96); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes hero-out { to { opacity: .15; transform: translateY(-6vh) scale(.92); } }
@keyframes glow-grow { to { transform: scale(1.5); opacity: .4; } }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } }
@keyframes card-in { from { scale: .9; } } /* 투명도는 건드리지 않는다: 반투명 남색 카드가 회색 판처럼 보인다 */ /* transform 대신 scale: 호버의 transform 과 겹치지 않게 */
