/* メモリーバース 3章 国のカード（DESIGN.md §100）
   国のページ（html/country/*.html、tools/memoryverse-cards/draw.py が生成）と、あとで地域の記事に
   差し込むカードの両方で使う。部品名はすべて cc- で始め、記事の部品と混ざらないようにしてある。
   図（SVG）の中の色は SVG 自身が持つ（層1〜3の色は §100）。ここはカードの枠・ボタン・注記だけ。 */

.cc-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--gutter) var(--space-16);
}
.cc-card {
    border: 1px solid var(--line, var(--hairline));
    border-radius: var(--radius-lg, 14px);
    padding: 16px;
    background: var(--surface);
}

/* --- 層のボタン（上の段）と、その中身のボタン（下の段） --------------------- */
.cc-ctl { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.cc-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cc-sep { width: 1px; height: 20px; background: var(--line, var(--hairline)); margin: 0 6px; }
.cc-card button {
    font: inherit;
    font-size: 13px;
    color: var(--ink-soft, var(--text-secondary));
    background: transparent;
    border: 1px solid var(--line, var(--hairline));
    border-radius: var(--radius-pill);
    padding: 4px 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.6;
}
.cc-card button[aria-pressed="true"] { color: var(--ink, #fff); border-color: var(--accent); background: rgba(61, 139, 255, .16); }
.cc-card button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-card .cc-lay { font-weight: 700; font-size: 14px; padding: 5px 16px; }
.cc-card .cc-sub { font-size: 12px; padding: 3px 11px; }
.cc-sw { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }
.cc-sw.dash { border-top-style: dashed; }
/* 0のもの：薄く・破線の枠・「なし」。押せない（disabled）。図には何も足さない（§100） */
.cc-card .cc-zero { opacity: .55; cursor: not-allowed; border-style: dashed; }
.cc-zero em { font-style: normal; font-size: 11px; color: #ff9b9b; margin-left: 2px; }
.cc-zeros { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft, var(--text-secondary)); }
.cc-zeros b { color: var(--ink, #fff); }
/* 取得待ち：データはあるが、まだ取れていない（「なし」＝データに無い、とは別。§102.7）。点線の枠・琥珀色の「取得待ち」 */
.cc-card .cc-pending { opacity: .6; cursor: not-allowed; border-style: dotted; }
.cc-pending em { font-style: normal; font-size: 11px; color: #ffb46b; margin-left: 2px; }

/* --- 図：枠だけを先に置き、SVG は country-card.js が取ってきて差し込む ----- */
.cc-maps { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
/* 狭い画面では図を縮めずに横へ送る（§90.1）。枠の縦横比は --w / --h（SVG の寸法）で先に決まる */
.cc-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .28) transparent;
}
.cc-scroll::-webkit-scrollbar { height: 6px; }
.cc-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); border-radius: 99px; }
.cc-fig {
    position: relative;
    width: calc(var(--w) * 1px);
    max-width: 100%;
    aspect-ratio: var(--w) / var(--h);
}
.cc-fig > svg { display: block; width: 100%; height: auto; }
/* 地域のカードの国名は、その国のページへのリンク（region.py の a.cc-cty。DESIGN.md §118）。ふだんは白のまま（地図の形を読みやすく）、
   乗せる・キーボードで選ぶとリンクの色と下線。スマホでは乗せられないので、カードの説明に「国名を押すと、その国のページへ」と書く */
.cc-fig svg a.cc-cty { cursor: pointer; }
.cc-fig svg a.cc-cty:hover text, .cc-fig svg a.cc-cty:focus-visible text { fill: var(--accent, #3d8bff); text-decoration: underline; }
/* 横に送れるときだけ出る1行（country-card.js の setupHint。2-1 §07 の .fig.is-scrollable::before と同じ文言・大きさ） */
.cc-scroll-hint { flex: 0 0 100%; margin: 0 0 -10px; font-size: 11px; letter-spacing: .06em; color: var(--ink-faint, var(--text-tertiary)); }   /* .cc-maps は flex-wrap（間隔18px）。1行で独立させ、図との間を8px に */
.cc-scroll-hint[hidden] { display: none; }
/* 地域のカードが本文の列より広いとき（3-2 南ヨーロッパ 1234px）は縮めずに横へスクロールする（1度44px を守る。DESIGN.md §114） */
.cc-fig.cc-1to1 { max-width: none; }
.cc-status, .cc-fallback {
    position: absolute;
    inset: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-soft, var(--text-secondary));
    border: 1px dashed var(--line, var(--hairline));
    border-radius: var(--radius-md, 10px);
}
.cc-fallback { display: none; }
.cc-fig.is-loaded .cc-status, .cc-fig.is-failed .cc-status { display: none; }
.cc-fig.is-failed .cc-fallback { display: flex; }
@media (max-width: 760px) {
    /* 文字が読める大きさ（図の中の 9px が約8px）を保って横に送る */
    .cc-fig { max-width: none; width: calc(var(--w) * .88px); }
}

/* 注記の欄：段落はサイト共通の p { max-width: 62ch } で折り返す（12.5px で448px）。欄もそれに合わせて上限を付け、
   使わない幅を欄に取らせない（上限が無いと、図が小さい国で欄が739px になり、右の約290px が空いた。DESIGN.md §122） */
.cc-side { flex: 1 1 300px; min-width: 0; max-width: 62ch; font-size: 12.5px; display: flex; flex-direction: column; gap: 14px; }
/* 国のページだけ、図と注記の組を中央に寄せる（余った幅を左右に分ける。縮尺は1度44px のまま変えない）。
   狭い画面（760px 以下）は注記が図の下に回るので、これまでどおり左寄せ */
@media (min-width: 761px) { .cc-page .cc-maps { justify-content: center; } }
.cc-note {
    font-size: 12.5px;
    color: var(--ink-soft, var(--text-secondary));
    border-left: 2px solid var(--line, var(--hairline));
    padding-left: 10px;
    margin: 0;
}
.cc-note b { color: var(--ink, #fff); }

/* --- 出典（ODbL は表示が条件。見える形で置く） ------------------------------ */
.cc-src {
    margin-top: 18px;
    border-top: 1px solid var(--line, var(--hairline));
    padding-top: 12px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--ink-faint, var(--text-tertiary));
}
.cc-src p { margin: 0 0 6px; }
.cc-src b { color: var(--ink-soft, var(--text-secondary)); font-weight: 600; }
.cc-src a { color: inherit; }

/* --- 層と中身の表示（country-card.js がカードに off-* を付け外しする） ------- */
.cc-card.off-L1 .L1, .cc-card.off-L2 .L2, .cc-card.off-L3 .L3,
.cc-card.off-river .k-river, .cc-card.off-lake .k-lake, .cc-card.off-motorway .k-motorway,
.cc-card.off-trunk .k-trunk, .cc-card.off-hsr .k-hsr, .cc-card.off-main .k-main,
.cc-card.off-region .k-region, .cc-card.off-prefname .k-prefname, .cc-card.off-city .k-city { display: none; }

/* --- 画面いっぱいに広げる（国のページだけ。page_tpl.html に .cc-full のボタンがあるときだけ効く。DESIGN.md §107）--------
   カードまるごと（ボタンも）を overlay にする。複製しないので層の切り替えはそのまま効く。
   ★ Fullscreen API は使わない（iPhone の Safari は、ふつうの要素を全画面にできない）。
   ★ 図は画面に収めるだけ。1:1 は置かない（どの国も1度44pxで揃えた縮尺から外れた見え方が混ざるため）。 */
.cc-card .cc-full { margin-left: auto; }
.cc-full-attr { display: none; }
body.cc-full-open { overflow: hidden; }
/* main は position:relative と z-index を持つので、その中の fixed は main の重なりの中に閉じこめられ、サイトの浮いたナビ（z-index 1000）の下になる。
   開いているあいだだけ main をナビより上へ上げる（overlay が画面全体を覆うので、ほかへの影響は無い） */
body.cc-full-open main { z-index: 2001; }
.cc-card.is-full {
    position: fixed;
    inset: 0;
    z-index: 2000;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 12px 12px 8px;
    background: #05080d;
    overflow: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
}
/* 記事の中のカード（地域のカード）は、記事の <style> の .main .cc-card{margin:18px 0} が後から効いて上下に隙間ができる。広げたときは打ち消す */
.main .cc-card.is-full { margin: 0; }
.cc-card.is-full .cc-ctl { margin-bottom: 10px; }
.cc-card.is-full .cc-side, .cc-card.is-full .cc-src { display: none; }
.cc-card.is-full .cc-maps { flex-direction: column; align-items: center; gap: 12px; }
.cc-card.is-full .cc-scroll { overflow: visible; max-width: none; }
/* 枠を画面いっぱいに：幅と、ボタンの段を除いた高さ（--cc-ctl-h は country-card.js が測って入れる）。図の縦横比とは違うので、
   country-card.js が viewBox を枠の縦横比まで広げ、図を真ん中に置く（DESIGN.md §119） */
.cc-card.is-full .cc-fig {
    max-width: none;
    width: calc(100vw - 24px);
    height: calc(100dvh - var(--cc-ctl-h, 140px));
    aspect-ratio: auto;
}
.cc-card.is-full .cc-fig > svg { width: 100%; height: 100%; }
/* 図が2枚以上のカードは1枚ずつ。切り替えのボタンは拡大表示のときだけ（§119） */
.cc-row.cc-tabs { display: none; }
.cc-card.is-full .cc-row.cc-tabs { display: flex; }
.cc-card.is-full .cc-scroll.cc-inactive { display: none; }
.cc-card .cc-tab:disabled { opacity: .45; cursor: not-allowed; border-style: dashed; }
.cc-card.is-full .cc-full-attr {
    display: block;
    margin: 8px 0 0;
    font-size: 11.5px;
    color: var(--ink-faint, var(--text-tertiary));
    text-align: center;
}
.cc-card.is-full .cc-full-attr a { color: inherit; }

/* --- 拡大表示の中の拡大・移動（country-card.js の zoomable。DESIGN.md §108）------------------------ */
.cc-zoombar, .cc-zoomscale { display: none; }
.cc-card.is-full .cc-fig { user-select: none; -webkit-user-select: none; }
.cc-card.is-full .cc-fig > svg { cursor: grab; }
.cc-card.is-full .cc-fig > svg:active { cursor: grabbing; }
.cc-card.is-full .cc-zoombar {
    display: flex; gap: 4px; position: absolute; top: 6px; right: 6px; z-index: 2;
}
.cc-card.is-full .cc-zoombar button { padding: 2px 11px; font-size: 13px; background: rgba(5, 8, 13, .82); }
.cc-card.is-full .cc-zoomscale {
    display: block; position: absolute; left: 6px; bottom: 6px; z-index: 2;
    font-size: 11.5px; padding: 2px 8px; border-radius: 6px;
    color: var(--ink-soft, var(--text-secondary)); background: rgba(5, 8, 13, .82);
}
/* ラベルを逆に縮めて、画面の上の大きさを保つ（--inv = 1/倍率）。縮める中心は text-anchor の端（既定は start） */
.cc-card.is-full svg text { transform-box: fill-box; transform-origin: 0% 70%; transform: scale(var(--inv, 1)); }
.cc-card.is-full svg text[text-anchor="middle"] { transform-origin: 50% 70%; }
.cc-card.is-full svg text[text-anchor="end"] { transform-origin: 100% 70%; }
/* 線の太さと点の大きさも、画面の上で保つ（拡大で道路や鉄道が太い帯に、都市の点が大きな円になるのを防ぐ）。面の塗りは地図と一緒に大きくなる */
.cc-card.is-full svg path, .cc-card.is-full svg line, .cc-card.is-full svg polyline, .cc-card.is-full svg rect { vector-effect: non-scaling-stroke; }
.cc-card.is-full svg circle { transform-box: fill-box; transform-origin: center; transform: scale(var(--inv, 1)); }
.cc-card.is-full .cc-full-omit { max-width: 60em; margin: 8px auto 0; }

