/* Mulmit Ocean Canon — detail surfaces: /stock, /asset, /crypto coin pages.
 *
 * Loaded last on the three detail pages, after ocean.css. The direction is
 * "요약 갑판 · 두 층" (.impeccable/surfaces/app-static-stock-html.md): the first
 * layer is one glance — the price pair, the chart, four tiles, one paragraph —
 * and the second layer is four tabs. Every data section stays; what changes is
 * that each section is one panel with the heading on its column, the long
 * method notes fold into a details, and the four page kinds share one grammar.
 *
 * Rules that live here and nowhere else:
 *  - a section is a panel: padding on all sides (the old sections had none, so
 *    headings and tables sat on the panel's edge — operator, 2026-09-16 "글자랑
 *    카드 겹치고");
 *  - the heading carries the 3px state rule in the panel's gutter, so the
 *    heading text, the note and the table start on one column;
 *  - a deck tile is a door: label, value, one note, a chevron; hover lifts it.
 */

.world { --detail-pad: clamp(16px, 3vw, 24px); --detail-rule: 3px; }

/* ── Head ──────────────────────────────────────────────────────────── */
.world :is(.stock-head, .asset-head, .coin-head) {
  position: relative;
  padding-right: 116px;
  border-bottom: 0;
  padding-bottom: var(--sp-2);
}
.world :is(.stock-head, .asset-head, .coin-head) h1 {
  font-size: clamp(26px, 3.2vw, 34px);
  line-height: 1.15;
  letter-spacing: -.03em;
}
.world :is(.stock-head, .asset-head, .coin-head) .market-tag {
  border-color: var(--line);
  color: var(--ink-3);
}
.world :is(.stock-head, .asset-head, .coin-head) .pin-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 0 10px;
  border-color: var(--line);
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}
.world :is(.stock-head, .asset-head, .coin-head) .pin-toggle::after {
  content: "";
  position: absolute;
  inset: -4px;
}
.world :is(.stock-head, .asset-head, .coin-head) .pin-toggle .ico {
  width: 15px;
  height: 15px;
}
.world :is(.stock-head, .asset-head, .coin-head) .pin-toggle .pin-toggle-text {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
}
.world :is(.stock-head, .asset-head, .coin-head) .pin-toggle:hover {
  border-color: var(--line-strong);
  background: var(--panel);
}

/* ── Hero: the price pair on one surface ───────────────────────────── */
.world .quote {
  margin: var(--sp-3) 0 var(--sp-3);
  padding: 22px var(--detail-pad) 20px;
}
.world .quote-live-label { font-weight: 650; }
.world .quote-rail {
  gap: var(--sp-3) var(--sp-5);
  border-top-color: var(--water-line);
}
.world .quote-rail dt { color: var(--ink-3); letter-spacing: .02em; text-transform: none; }
.world .quote.has-live .quote-official { border-top-color: var(--water-line); }
/* The asset and coin pages open with the same surface. */
.world :is(.asset-price, .coin-price) {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px var(--sp-3);
  margin: var(--sp-3) 0;
  padding: 22px var(--detail-pad) 20px;
  border: 1px solid var(--water-line);
  border-radius: 20px;
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(39, 115, 248, .13), transparent 56%),
    linear-gradient(180deg, var(--water-1) 0%, var(--water-3) 100%);
  box-shadow: 0 12px 34px rgba(var(--shadow-ink), .07);
}
.world :is(.asset-price, .coin-price) > strong {
  margin: 0;
  color: var(--ink);
  font: 700 var(--fs-hero)/1 var(--num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}
.world :is(.asset-price, .coin-price) > em {
  margin: 0;
  font: 700 var(--fs-xl)/1.1 var(--num);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.world :is(.asset-price, .coin-price) > small {
  flex: 0 0 100%;
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  letter-spacing: -.01em;
}
.world .perp-quote {
  max-width: none;
  margin: var(--sp-3) 0;
  padding: 20px var(--detail-pad) 18px;
  border: 1px solid var(--water-line);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--water-1) 0%, var(--water-3) 100%);
  box-shadow: 0 12px 34px rgba(var(--shadow-ink), .07);
}
.world :is(.state-line, #head-loading .state-line) { font-size: var(--fs-sm); }
.world #head-loading { margin: 0; }

/* ── 개요 탭의 한눈 — 차트 아래 타일 넷 ─────────────────────────────── */
.world .deck-tiles,
.world :is(.stock-kpis, .asset-kpis, .coin-kpis) {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
  margin: 0;
}
.world :is(.stock-kpis, .asset-kpis, .coin-kpis) { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.world .deck-tile,
.world :is(.stock-kpi, .asset-kpi, .coin-kpi) {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  min-height: 98px;
  margin: 0;
  padding: var(--sp-4);
  border: 0;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--surface-shadow);
  color: var(--ink);
  text-align: left;
}
.world .deck-tile {
  appearance: none;
  padding-right: 34px;
  cursor: pointer;
  font: inherit;
  transition: box-shadow .18s ease, transform .18s ease;
}
.world .deck-tile:hover { box-shadow: var(--surface-shadow-lift); transform: translateY(-2px); }
.world .deck-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.world .deck-tile-label,
.world :is(.stock-kpi, .asset-kpi, .coin-kpi) > small {
  display: block;
  margin: 0;
  color: var(--ink-3);
  font: 650 var(--fs-xs)/1.3 var(--sans);
  letter-spacing: 0;
  text-transform: none;
}
.world .deck-tile-value,
.world :is(.stock-kpi, .asset-kpi, .coin-kpi) > strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font: 750 22px/1.1 var(--num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  word-break: normal;
}
.world .deck-tile-value > b { font-weight: inherit; }
.world .deck-tile-value > b.up { color: var(--up); }
.world .deck-tile-value > b.down { color: var(--down); }
.world .deck-tile-note,
.world :is(.stock-kpi, .asset-kpi, .coin-kpi) > span {
  display: block;
  margin: 0;
  color: var(--ink-2);
  font: 500 var(--fs-xs)/1.45 var(--sans);
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.world .deck-tile-go {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 18px;
  height: 18px;
  color: var(--ink-3);
  transition: color .18s ease, transform .18s ease;
}
.world .deck-tile:hover .deck-tile-go { color: var(--accent); transform: translateX(2px); }
/* 타일 줄은 이제 개요 탭 **안**에 산다 — 차트와 한 문단 사이에서 숨 쉴 자리. */
.world .stock-tab-panel > .deck-tiles { margin: var(--sp-4) 0; }

/* ── Tabs: the second layer ────────────────────────────────────────── */
/* 탭 줄은 시세 바로 아래다 — 갈래를 고르려고 한 화면을 내리지 않는다
 * (운영자 2026-09-17). 선택 표시는 중첩 카드가 아니라 아래 괘선이다. */
.world .stock-tabs-wrap {
  margin: var(--sp-3) 0 0;
  border-bottom: 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
}
.world .stock-tabs {
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  min-width: 0;
}
.world .stock-tab {
  color: var(--ink-3);
  font: 650 var(--fs-md)/1 var(--sans);
  letter-spacing: -.01em;
  transition: color .16s ease;
}
.world .stock-tab::after { left: 10px; right: 10px; border-radius: 2px 2px 0 0; }
.world .stock-tab:hover { color: var(--ink); background: transparent; }
.world .stock-tab[aria-selected="true"] { color: var(--ink); font-weight: 750; }
/* A tab with nothing under it says so before it is pressed. */
.world .stock-tab.is-empty:not([aria-selected="true"]) { color: var(--ink-4, var(--ink-3)); opacity: .55; }
.world .stock-tab.active { color: var(--ink); }
.world .stock-tab-panel { padding-top: var(--sp-2); }
.world .stock-subnav {
  gap: var(--sp-2);
  margin: var(--sp-3) 0 0;
  padding: 0 2px var(--sp-1);
}
.world .stock-subnav a {
  min-height: var(--tap-min);
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel);
  color: var(--ink-2);
  font: 650 var(--fs-xs)/1 var(--sans);
  transition: color .16s ease, border-color .16s ease;
}
.world .stock-subnav a:hover,
.world .stock-subnav a:focus-visible { color: var(--accent); border-color: var(--accent); }
.world .stock-tab-empty {
  margin: var(--sp-4) 0;
  padding: 18px var(--detail-pad);
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

/* ── Sections are panels ───────────────────────────────────────────── */
.world :is(.stock-section, .asset-section, .coin-section, .ssr-neighbors) {
  margin: var(--sp-4) 0;
  padding: 20px var(--detail-pad) 18px;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--surface-shadow);
}
.world .ssr-neighbors { margin-top: var(--sp-4); }
.world :is(.stock-section, .asset-section, .coin-section, .ssr-neighbors) > h2,
.world :is(.stock-section, .coin-section) > .chart-heading > h2,
.world .asset-section > .asset-chart-head > h2 {
  position: relative;
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: -.02em;
}
.world :is(.stock-section, .asset-section, .coin-section, .ssr-neighbors) > h2::before,
.world :is(.stock-section, .coin-section) > .chart-heading > h2::before,
.world .asset-section > .asset-chart-head > h2::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: calc(-1 * var(--detail-pad) + 6px);
  width: var(--detail-rule);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--chart), var(--current-2));
}
.world :is(.stock-section, .asset-section, .coin-section) > .sub,
.world :is(.stock-section, .coin-section) > .chart-heading > .sub,
.world .asset-section > .asset-chart-head > .sub,
.world .stock-section > .qtr-what,
.world .stock-section .krop-ladder-title {
  margin: 0 0 var(--sp-3);
  max-width: 72ch;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.world .stock-section .krop-ladder-title { margin-top: var(--sp-4); color: var(--ink); font-weight: 700; }
.world .stock-section .co-h3 { margin-top: var(--sp-4); }
.world :is(.stock-section, .asset-section, .coin-section) > h2 + .sub { margin-top: 2px; }
/* Explanations read after the figures: quieter, one measure, never a wall. */
.world .stock-section .krop-why,
.world .stock-section .easy-only.krop-why,
.world .stock-section .ksi-help {
  max-width: 72ch;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  line-height: 1.55;
}
.world .stock-section > .krop-why { margin: var(--sp-2) 0 0; }
.world .stock-section .brief-text { max-width: 68ch; font-size: var(--fs-md); line-height: 1.75; }

/* Stat cells: label, figure, tag, note — the figure leads. */
.world .stock-section .krop-stats,
.world .stock-section .stock-kpis {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--sp-4) var(--sp-4);
  margin: var(--sp-3) 0 var(--sp-2);
}
.world .stock-section .krop-stat { gap: 3px; }
.world .stock-section .krop-stat small { color: var(--ink-3); font-weight: 600; }
.world .stock-section .krop-stat strong { font-size: 22px; letter-spacing: -.02em; }
/* 꼬리표는 알약이고 색이 없다 — 굵기만으로 경계 밖을 말한다(stock.html 참조). */
.world .stock-section .krop-stat .tech-tag { color: var(--ink-3); }
.world .stock-section .krop-stat .tech-tag.is-edge { color: var(--ink); }
.world .stock-section .krop-stat .krop-why { margin-top: 2px; }
.world .stock-section .stock-kpis .stock-kpi { min-height: 0; padding: 0; box-shadow: none; background: transparent; border-radius: 0; }
.world .stock-section .grade-hero { margin: var(--sp-3) 0 var(--sp-4); }
.world .stock-section .grade-grid { gap: var(--sp-4); }
.world .stock-section .band-now { margin: var(--sp-2) 0 var(--sp-3); }
.world .stock-section .band-now strong { font-size: 24px; }

/* Method notes fold. A section's basis and arithmetic are one click away,
 * never gone (PRODUCT.md: 긴 계산법·방법론·원문 근거만 details에 접는다). */
.world .stock-fold { margin: var(--sp-3) 0 0; }
.world .stock-fold > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0;
  border: 0;
  color: var(--ink-3);
  font: 600 var(--fs-xs)/1 var(--sans);
  list-style: none;
  cursor: pointer;
}
.world .stock-fold > summary::-webkit-details-marker { display: none; }
.world .stock-fold > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-1px) rotate(-45deg);
  transition: transform .18s ease;
}
.world .stock-fold[open] > summary::before { transform: translateY(-2px) rotate(45deg); }
.world .stock-fold > summary:hover,
.world .stock-fold[open] > summary { color: var(--accent); }
.world .stock-fold > .stock-note {
  margin: var(--sp-2) 0 0;
  max-width: 68ch;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  line-height: 1.6;
}
.world .stock-fold:has(> .stock-note:empty) { display: none; }
.world :is(.asset-note, .coin-note) {
  max-width: 68ch;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  line-height: 1.6;
}

/* Tables sit on the panel's column. */
.world :is(.stock-section, .asset-section, .coin-section) .table-scroll { margin: var(--sp-2) 0 0; }
.world :is(.stock-table, .asset-table, .coin-table) { font-size: var(--fs-sm); }
/* 공통 표 여백과 같은 값(ocean.css의 한 벌 규칙) — 9/10px이던 자리다. */
.world :is(.stock-table, .asset-table, .coin-table) th,
.world :is(.stock-table, .asset-table, .coin-table) td { padding: var(--sp-2) var(--sp-3); }
.world :is(.stock-table, .asset-table, .coin-table) thead th {
  font: 650 var(--fs-xs)/1.4 var(--sans);
  letter-spacing: 0;
  text-transform: none;
}
.world .stock-table td.up { color: var(--up); }
.world .stock-table td.down { color: var(--down); }
.world .stock-news li { padding: var(--sp-2) 0; }
.world .stock-news a { font-size: var(--fs-sm); }
.world .stock-links { margin: 0; }
.world .stock-links a { padding: 8px 12px; border-color: var(--line); border-radius: 999px; color: var(--ink-2); }
.world .stock-links a:hover { color: var(--accent); border-color: var(--accent); }

/* Chart: the panel holds it, the widget draws in a soft well. */
.world :is(.stock-section, .asset-section, .coin-section) .chart-wrap {
  border: 0;
  border-radius: 14px;
  background: var(--water-1);
}
.world #sec-chart .chart-tabs { border-bottom-color: var(--line); }
.world #sec-chart .chart-range button { background: var(--panel); border-color: var(--line); color: var(--ink-2); }
.world #sec-chart .chart-range button.active { color: var(--accent); border-color: var(--accent); }
.world .asset-section > #chart-wrap { border-radius: 14px; }

/* Sticky band under the masthead keeps the value while a tab is read. */
.world .quote-stuck {
  border-bottom-color: var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

/* ── Phone ─────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .world { --detail-pad: 16px; }
  .world .deck-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .world :is(.stock-kpis, .asset-kpis, .coin-kpis) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .world .deck-tile,
  .world :is(.stock-kpi, .asset-kpi, .coin-kpi) { min-height: 92px; padding: 12px 14px 12px; }
  .world .deck-tile { padding-right: 30px; }
  .world .deck-tile-value,
  .world :is(.stock-kpi, .asset-kpi, .coin-kpi) > strong { font-size: 20px; }
  .world .deck-tile-go { top: 12px; right: 10px; }
  .world :is(.stock-section, .asset-section, .coin-section, .ssr-neighbors) {
    margin: var(--sp-3) 0;
    padding: 16px var(--detail-pad) 16px;
    border-radius: 16px;
  }
  .world :is(.stock-section, .asset-section, .coin-section, .ssr-neighbors) > h2,
  .world :is(.stock-section, .coin-section) > .chart-heading > h2,
  .world .asset-section > .asset-chart-head > h2 { font-size: 17px; }
  .world .stock-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .world .stock-tab { padding: 0 2px; font-size: var(--fs-sm); }
  .world .stock-tab::after { left: 6px; right: 6px; }
  .world .stock-section .krop-stats,
  .world .stock-section .stock-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-3); }
  .world .stock-section .krop-stat strong { font-size: 20px; }
  .world .quote { padding: 18px var(--detail-pad) 16px; }
  .world :is(.asset-price, .coin-price) { padding: 18px var(--detail-pad) 16px; }
  .world :is(.asset-price, .coin-price) > strong { font-size: clamp(32px, 10vw, 44px); }
  .world .perp-quote { padding: 16px var(--detail-pad) 16px; }
}
@media (max-width: 400px) {
  .world .deck-tile-value,
  .world :is(.stock-kpi, .asset-kpi, .coin-kpi) > strong { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .world .deck-tile, .world .deck-tile-go, .world .stock-fold > summary::before { transition: none; }
  .world .deck-tile:hover { transform: none; }
}

/* ── 첫 화면은 값이 도착해도 움직이지 않는다 ─────────────────────────────
 * 실측(2026-09-17, 브라우저 layout-shift): `/stock/000660`의 CLS 1.53 가운데
 * 0.76이 **시세 블록 한 장** 때문이었다. `#quote`가 `hidden`으로 시작해 값이
 * 도착할 때 나타나면서 아래의 갑판을 507px 밀어 내린다.
 *
 * 값을 지어내지 않는다는 규칙은 그대로다 — 자리만 미리 잡는다. 숨은 동안
 * 그 자리를 차지하는 것은 `.quote`가 아니라 앵커의 최소 높이다. 값이 오면
 * 그 안을 채우므로 화면이 한 번도 안 밀린다. 첫 라운드가 끝나면 놓아 준다. */
/* 자리는 **시세 블록이 실제로 오는 페이지에서만** 잡는다. 국내 종목이 그렇고,
 * 미국 종목은 재배포 권리가 없어 이 블록이 끝내 안 선다 — 거기서 자리를 잡으면
 * 360px짜리 빈 구멍이 영원히 남는다. `html.stock-kr`은 인라인 스크립트가 첫
 * 페인트 전에 붙인다. 높이는 실측값이다: 1440에서 360px, 390에서 545px.
 * (불러오는 줄로 문을 열어 봤더니 시세가 서는 순간과 창이 어긋나 오히려
 * 밀림이 늘었다 — 실측 CLS 0.76 → 0.91.) */
html.stock-kr .world main.shell:has(#quote[hidden]) #quote-reserve { display: block; }
#quote-reserve { display: none; min-height: 360px; }
/* 폰에서는 여섯 지표가 개요 탭으로 내려가므로 카드가 그만큼 낮다(실측 2026-09-17:
   ko 330 · en 373). 자리는 **큰 쪽**을 잡는다 — 모자라면 그만큼 밀린다. */
@media (max-width: 760px) { #quote-reserve { min-height: 375px; } }

/* 표의 첫 칸은 판의 글 열에서 시작한다. 공통 표 규칙이 모든 칸에 좌우 여백을
 * 주면서 이 페이지들만 표 글자가 제목보다 12px 오른쪽에 섰다(실측 2026-09-17:
 * `sec-company` · `sec-peers` · `sec-fund` · 코인 두 섹션 gap −12).
 * 대시보드의 표는 판이 여백을 안 주므로 첫 칸이 레일을 지지만, 여기서는
 * 섹션이 이미 여백을 갖는다 — 그래서 첫 칸은 0이다. */
.world :is(.stock-section, .asset-section, .coin-section)
  :is(.stock-table, .asset-table, .coin-table) :is(th, td):first-child { padding-left: 0; }

/* 개요 탭으로 내려온 여섯 지표(폰). 시세 카드 안에 있을 때의 윗선은 필요 없다 —
 * 이제 탭 줄이 그 경계를 긋는다. */
.world .stock-tab-panel > .quote-rail {
  margin: var(--sp-3) 0 0;
  padding: 0;
  border-top: 0;
}
