/* KxF site — design system v1（仕様: docs/design-system.md） */

/* ---------- 1. Tokens ---------- */
:root {
  --chrome: #2B2E3F; --chrome-2: #3B3F55;
  --teal-900: #1F4F5D; --teal-700: #2C7082; --teal-500: #5EAFC5;
  --tile: #A9C6D4; --tile-shade: #7FA2B3;
  --paper: #FBF6F2; --paper-2: #EEE7E1; --sheet: #F2FAFC;
  --ink: #1E2533; --ink-sub: #5E6A79;
  --cyan: #56C6DA; --cyan-shade: #2C8FA4;
  --gold: #F7C746; --gold-shade: #C48F22;
  --red: #E53935; --army-blue: #2F64D6;
  --title-green: #4FDB97; --title-purple: #C77DFF;
  --r-common: #9AA5B1; --r-green: #36C772; --r-blue: #3B8CF2; --r-purple: #A35CF2; --r-gold: #F5A623;
  --sky-top: #2C86DD; --sky-bottom: #BFE2FF; --snow: #F4F8FB;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-pill: 999px; --r-btn: 12px; --r-tile: 10px; --r-panel: 8px; --r-sheet: 24px;
  --lift: 0 2px 0 rgba(0,0,0,.08), 0 8px 24px rgba(20,30,50,.12);
  --hl: inset 0 2px 0 rgba(255,255,255,.45);

  --f-game: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  --f-body: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Meiryo UI", sans-serif;

  --tabbar-h: 56px;
  --max: 1080px;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--chrome); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--teal-700); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1em; height: 1em; flex-shrink: 0; fill: currentColor; }

/* 縁取り文字（ゲームの白抜き黒縁） */
.outline {
  color: #fff;
  text-shadow: -2px -2px 0 var(--chrome), 2px -2px 0 var(--chrome), -2px 2px 0 var(--chrome), 2px 2px 0 var(--chrome),
               0 -2px 0 var(--chrome), 0 2px 0 var(--chrome), -2px 0 0 var(--chrome), 2px 0 0 var(--chrome),
               0 4px 0 var(--chrome);
}
.outline-thick {
  color: #fff;
  text-shadow: -3px -3px 0 var(--chrome), 3px -3px 0 var(--chrome), -3px 3px 0 var(--chrome), 3px 3px 0 var(--chrome),
               0 -3px 0 var(--chrome), 0 3px 0 var(--chrome), -3px 0 0 var(--chrome), 3px 0 0 var(--chrome),
               0 6px 0 var(--chrome);
}

/* ---------- 3. Layout ---------- */
.page { flex: 1; background: var(--paper); }
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); }
.container--narrow { max-width: 760px; }

/* ---------- 4. App bar / Nav ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--chrome); color: #fff;
  border-bottom: 3px solid #1C1E2B;
}
.appbar-inner { max-width: var(--max); margin: 0 auto; padding: 0 var(--s4); height: 56px; display: flex; align-items: center; gap: var(--s4); }
.brand { display: flex; align-items: center; gap: var(--s2); min-height: 44px; color: #fff; text-decoration: none; font-family: var(--f-game); font-weight: 900; font-size: 18px; letter-spacing: .02em; }
.brand-emblem { width: 32px; height: 38px; }
.brand small { font-weight: 700; font-size: 12px; color: var(--tile); margin-left: var(--s1); }

.navtabs { margin-left: auto; display: flex; gap: var(--s1); align-self: flex-end; }
.navtab {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 96px; padding: 0 var(--s4);
  background: var(--chrome-2); color: #fff; text-decoration: none;
  font-family: var(--f-game); font-weight: 800; font-size: 15px;
  border-radius: var(--r-tile) var(--r-tile) 0 0;
  box-shadow: var(--hl);
}
.navtab .icon { font-size: 20px; }
.navtab:hover { background: #4A4F69; }
.navtab[aria-current="page"] { background: var(--gold); color: var(--chrome); box-shadow: var(--hl), inset 0 -3px 0 var(--gold-shade); }

/* SP: 下部タブバー（HIG Tab bar） */
@media (max-width: 599px) {
  .navtabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; gap: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--chrome); border-top: 3px solid #1C1E2B;
  }
  .navtab { flex: 1; flex-direction: column; gap: 0; min-width: 0; border-radius: 0; font-size: 11px; padding: 0; box-shadow: none; background: transparent; color: var(--tile); }
  .navtab .icon { font-size: 24px; }
  .navtab[aria-current="page"] { background: transparent; color: var(--gold); box-shadow: inset 0 3px 0 var(--gold); }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .brand small { display: none; }
}

/* ---------- 5. Title bar ---------- */
.titlebar { background: var(--teal-500); border-bottom: 4px solid var(--teal-700); box-shadow: var(--hl); }
.titlebar-inner { max-width: var(--max); margin: 0 auto; padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s3); }
.titlebar h1 { margin: 0; font-family: var(--f-game); font-weight: 900; font-size: 28px; line-height: 1.3; }
.titlebar .sub { font-family: var(--f-game); font-weight: 800; font-size: 13px; color: var(--teal-900); background: rgba(255,255,255,.55); padding: 2px 10px; border-radius: var(--r-pill); }
.titlebar .count { margin-left: auto; font-family: var(--f-game); font-weight: 800; color: #fff; background: var(--chrome); padding: 4px 12px; border-radius: var(--r-pill); font-size: 14px; font-variant-numeric: tabular-nums; }
@media (max-width: 599px) { .titlebar h1 { font-size: 24px; } }

/* ---------- 6. Panel / Info row ---------- */
.panel { background: var(--paper); border-radius: var(--r-panel); box-shadow: var(--lift); padding: var(--s4); }
.info-row { display: flex; justify-content: space-between; gap: var(--s3); background: var(--paper-2); border-radius: 4px; padding: var(--s1) var(--s3); font-size: 15px; }
.info-row + .info-row { margin-top: var(--s1); }
.info-row dt { color: var(--ink-sub); }
.info-row dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 7. Tile ---------- */
.tile {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 64px; padding: var(--s3) var(--s4);
  background: var(--tile); border-radius: var(--r-tile);
  border: 2px solid rgba(255,255,255,.6);
  box-shadow: var(--hl), 0 4px 0 var(--tile-shade);
  color: inherit; text-decoration: none;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.tile:hover { filter: brightness(1.05); }
.tile:active { transform: translateY(3px); box-shadow: var(--hl), 0 1px 0 var(--tile-shade); }
.tile-icon { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-size: 30px; filter: drop-shadow(0 2px 0 var(--tile-shade)); }
.tile-label { font-family: var(--f-game); font-weight: 900; font-size: 19px; line-height: 1.35; }
.tile-desc { display: block; font-family: var(--f-body); font-weight: 500; font-size: 13px; color: var(--teal-900); text-shadow: none; margin-top: 2px; }
.tiles { display: grid; gap: var(--s4) var(--s3); grid-template-columns: 1fr; }
@media (min-width: 600px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- 8. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5);
  background: var(--cyan); border: 0; border-radius: var(--r-btn);
  box-shadow: var(--hl), 0 4px 0 var(--cyan-shade);
  font-family: var(--f-game); font-weight: 900; font-size: 17px; text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: var(--hl), 0 1px 0 var(--cyan-shade); }
.btn--gold { background: var(--gold); box-shadow: var(--hl), 0 4px 0 var(--gold-shade); }
.btn--gold:active { box-shadow: var(--hl), 0 1px 0 var(--gold-shade); }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--paper-2); box-shadow: none; filter: none; cursor: default; color: var(--ink-sub); text-shadow: none; }
.btn-back { width: 48px; min-width: 48px; padding: 0; font-size: 24px; }

/* ---------- 9. Badges ---------- */
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--red); color: #fff; font-family: var(--f-game); font-weight: 900; font-size: 12px; line-height: 1; box-shadow: 0 0 0 2px #fff; }
.badge--new { letter-spacing: .04em; }
.badge[hidden] { display: none; }
.gate { display: inline-grid; place-items: center; min-width: 72px; height: 48px; padding: 0 var(--s3); border-radius: 6px;
  font-family: var(--f-game); font-weight: 900; font-size: 26px; border: 3px solid rgba(255,255,255,.7); }
.gate--x { background: color-mix(in srgb, var(--army-blue) 75%, #8fd0ff); box-shadow: 0 0 16px rgba(80,170,255,.7), var(--hl); }
.gate--minus { background: color-mix(in srgb, var(--red) 85%, #ff9a9a); box-shadow: 0 0 16px rgba(255,90,90,.6), var(--hl); }

/* ---------- 10. Tags / Segment ---------- */
.tag { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill);
  background: var(--tile); color: var(--teal-900); font-family: var(--f-game); font-weight: 800; font-size: 13px; text-decoration: none;
  box-shadow: var(--hl), 0 2px 0 var(--tile-shade); }
.tag:hover { filter: brightness(1.05); }
.tag--title { background: var(--chrome); color: var(--title-green); box-shadow: none; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s2); }

.segment { display: flex; gap: var(--s1); overflow-x: auto; scrollbar-width: none; background: var(--sheet); border-bottom: 1px solid var(--paper-2);
  margin: 0 calc(var(--s4) * -1) var(--s5); padding: 0 var(--s4); -webkit-overflow-scrolling: touch; }
.segment::-webkit-scrollbar { display: none; }
.segment button { flex-shrink: 0; min-height: 48px; padding: 0 var(--s4); background: none; border: 0; border-bottom: 3px solid transparent;
  font-family: var(--f-game); font-weight: 800; font-size: 15px; color: var(--ink-sub); cursor: pointer; }
.segment button span { font-size: 12px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.segment button:hover { color: var(--ink); }
.segment button[aria-pressed="true"] { color: var(--teal-700); border-bottom-color: var(--teal-700); }

/* ---------- 11. Cards（記事カード = 商店カード型） ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card { position: relative; display: flex; flex-direction: column; background: #C3D7E1; border-radius: var(--r-tile);
  border: 2px solid rgba(255,255,255,.7); box-shadow: 0 4px 0 var(--tile-shade); overflow: hidden; transition: transform .08s, box-shadow .08s; }
.card[hidden] { display: none; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--tile-shade); }
.card-head { display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s3); background: #D6E4EB; color: #46525F;
  font-family: var(--f-game); font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.card-head .badge { margin-left: auto; }
.card-link { display: flex; gap: var(--s3); padding: var(--s3); color: var(--ink); text-decoration: none; flex: 1; }
.card-link::after { content: ""; position: absolute; inset: 0; } /* カード全体をタップ領域に */
.card-thumb { width: 88px; height: 88px; flex-shrink: 0; border-radius: var(--r-tile); overflow: hidden; display: grid; place-items: center;
  background: var(--r-blue); border: 3px solid rgba(255,255,255,.8); box-shadow: 0 2px 0 rgba(0,0,0,.15); color: #fff; font-size: 40px; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb--gold { background: var(--r-gold); } .card-thumb--purple { background: var(--r-purple); }
.card-thumb--green { background: var(--r-green); } .card-thumb--common { background: var(--r-common); }
.card-title { margin: 0; font-family: var(--f-game); font-weight: 800; font-size: 16px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { position: relative; z-index: 1; padding: 0 var(--s3) var(--s3); }
.card-tags .tag { min-height: 28px; font-size: 12px; }
@media (min-width: 600px) {
  .card-link { flex-direction: column; }
  .card-thumb { width: 100%; height: 160px; }
}
.empty { grid-column: 1 / -1; text-align: center; color: var(--ink-sub); padding: var(--s7) 0; }

/* ---------- 12. Sheet（記事本文 = 同盟通達シート） ---------- */
.sheet { position: relative; background: var(--sheet); border-radius: var(--r-sheet) var(--r-sheet) var(--r-panel) var(--r-panel);
  box-shadow: var(--lift); padding: var(--s6) var(--s5) var(--s5); }
.sheet::before { content: ""; position: absolute; top: 12px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: #C9D3DA; }
.sheet-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); font-family: var(--f-game); font-weight: 800; font-size: 14px; color: var(--ink-sub); font-variant-numeric: tabular-nums; }
.sheet-title { margin: var(--s3) 0 var(--s4); font-family: var(--f-game); font-weight: 900; font-size: 26px; line-height: 1.45; color: var(--ink); }
.sheet-body { background: #fff; border: 1px solid #E1E8EC; border-radius: var(--r-tile); padding: var(--s4); font-size: 17px; word-break: break-word; }
.sheet-body p { margin: 0 0 1em; } .sheet-body p:last-child { margin-bottom: 0; }
.sheet-images { display: grid; gap: var(--s3); margin-top: var(--s4); }
.sheet-images figure { margin: 0; }
.sheet-images img { border-radius: var(--r-tile); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(20,30,50,.15); }
.sheet-images-label { font-family: var(--f-game); font-weight: 800; font-size: 14px; margin: var(--s4) 0 0; }
@media (max-width: 599px) { .sheet { padding: var(--s6) var(--s4) var(--s4); } .sheet-title { font-size: 22px; } .sheet-body { font-size: 16px; } }

.breadcrumb { font-size: 13px; color: var(--ink-sub); margin-bottom: var(--s4); }
.breadcrumb a { color: var(--ink-sub); }

/* ---------- 13. Pager ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s5); }
.pager .tile { flex-direction: column; align-items: flex-start; gap: 2px; }
.pager .next { align-items: flex-end; text-align: right; }
.pager-label { font-family: var(--f-game); font-weight: 900; font-size: 14px; }
.pager-title { font-size: 13px; color: var(--teal-900); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pager .is-empty { visibility: hidden; }
.backrow { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s5); }

/* ---------- 14. Hero（本拠地） ---------- */
.hero { position: relative; overflow: hidden; color: #fff; text-align: center;
  background: linear-gradient(180deg, var(--sky-top) 0%, #6FB5EE 45%, var(--sky-bottom) 72%, var(--snow) 72.2%, #E3EDF4 100%);
  padding: var(--s7) var(--s4) 0; }
.hero-cloud { position: absolute; background: #fff; border-radius: 999px; opacity: .9; filter: drop-shadow(0 6px 0 rgba(160,200,235,.6)); }
.hero-cloud::before, .hero-cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.hero-cloud::before { width: 55%; height: 160%; left: 15%; bottom: 20%; }
.hero-cloud::after { width: 40%; height: 120%; right: 12%; bottom: 25%; }
.hero-cloud.c1 { width: 160px; height: 40px; top: 48px; left: -20px; animation: drift 40s linear infinite alternate; }
.hero-cloud.c2 { width: 120px; height: 32px; top: 120px; right: 6%; animation: drift 32s linear infinite alternate-reverse; }
.hero-cloud.c3 { width: 90px; height: 24px; top: 30px; right: 30%; opacity: .7; }
@keyframes drift { to { transform: translateX(40px); } }
.hero-kicker { position: relative; display: inline-block; font-family: var(--f-game); font-weight: 900; font-size: 14px; color: var(--chrome);
  background: var(--gold); padding: 4px 14px; border-radius: var(--r-pill); box-shadow: 0 3px 0 var(--gold-shade); }
.hero-title { position: relative; margin: var(--s4) 0 var(--s2); font-family: var(--f-game); font-weight: 900; font-size: 44px; line-height: 1.2; }
.hero-lead { position: relative; margin: 0 auto; max-width: 30em; font-family: var(--f-game); font-weight: 800; font-size: 15px; }
.hero-gates { position: relative; display: flex; justify-content: center; gap: var(--s4); margin: var(--s5) 0 var(--s4); }
.hero-castle { position: relative; display: block; width: min(520px, 100%); height: auto; margin: 0 auto -2px; }
@media (max-width: 599px) { .hero-title { font-size: 32px; } .hero { padding-top: var(--s6); } }

.section-title { display: flex; align-items: center; gap: var(--s2); margin: var(--s6) 0 var(--s4); font-family: var(--f-game); font-weight: 900; font-size: 20px; color: var(--teal-900); }
.section-title::before { content: ""; width: 6px; height: 22px; border-radius: 3px; background: var(--gold); box-shadow: 0 2px 0 var(--gold-shade); }

/* ---------- 15. Footer ---------- */
.site-footer { background: var(--chrome); color: var(--tile); text-align: center; font-family: var(--f-game); font-weight: 800; font-size: 13px; padding: var(--s5) var(--s4); }

/* ---------- 16. Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.titlebar-label { margin: 0; font-family: var(--f-game); font-weight: 900; font-size: 22px; line-height: 1.3; }

/* ---------- 17. Large button / Gold frame / Dialog（ぬるぽチェンジャーで追加） ---------- */
.btn--lg { min-height: 64px; font-size: 24px; border-radius: 16px; box-shadow: var(--hl), 0 6px 0 var(--cyan-shade); }
.btn--lg:active { transform: translateY(5px); box-shadow: var(--hl), 0 1px 0 var(--cyan-shade); }
.btn--lg.btn--gold { box-shadow: var(--hl), 0 6px 0 var(--gold-shade); }
.btn--lg.btn--gold:active { box-shadow: var(--hl), 0 1px 0 var(--gold-shade); }

/* 金枠タイル（入力欄などを囲む。ゲームの UR 枠） */
.frame-gold { padding: var(--s2); border-radius: 16px; background: linear-gradient(180deg, #FFD96A, var(--r-gold));
  border: 3px solid var(--gold-shade); box-shadow: 0 4px 0 #A8741A; }
.frame-gold.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.03); } }

/* ダイアログ（ゲームのポップアップ: 水色の枠＋縁取りタイトル＋生成りの本体） */
.dialog { width: min(360px, calc(100vw - 48px)); padding: 0; border: 4px solid var(--teal-500); border-radius: 16px;
  background: var(--paper); color: var(--ink); box-shadow: 0 6px 0 var(--teal-700), 0 16px 32px rgba(0,0,0,.35); }
.dialog::backdrop { background: rgba(43, 46, 63, .6); }
.dialog[open] { animation: dialog-in .2s ease; }
@keyframes dialog-in { from { transform: scale(.9); opacity: 0; } }
.dialog-head { background: var(--teal-500); padding: var(--s3) var(--s4); text-align: center; font-family: var(--f-game); font-weight: 900; font-size: 20px; }
.dialog-body { padding: var(--s5) var(--s5) var(--s6); text-align: center; }
.dialog-message { margin: 0 0 var(--s5); font-family: var(--f-game); font-weight: 800; font-size: 22px; line-height: 1.5; }
.dialog-body .btn { min-width: 160px; }

/* ---------- 18. Search（同盟通達の検索窓） ---------- */
.search { position: relative; display: flex; align-items: center; margin-bottom: var(--s2); }
.search-icon { position: absolute; left: 16px; font-size: 20px; color: var(--teal-700); pointer-events: none; }
.search-input {
  width: 100%; min-height: 48px; padding: 0 48px 0 48px;
  border: 2px solid var(--tile); border-radius: var(--r-pill); background: #fff; color: var(--ink);
  font-family: var(--f-body); font-size: 16px; /* 16px 未満だと iOS が拡大する */
  box-shadow: inset 0 2px 3px rgba(20,30,50,.08); -webkit-appearance: none; appearance: none;
}
.search-input::placeholder { color: #6E7987; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-input:focus { outline: none; border-color: var(--teal-700); box-shadow: 0 0 0 3px rgba(44,112,130,.25); }
.search-clear { position: absolute; right: 2px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-sub); font-size: 18px; cursor: pointer; }
.search-clear:hover { color: var(--ink); background: var(--paper-2); }
.search-clear[hidden] { display: none; }
.search-status { min-height: 1.5em; margin: 0 0 var(--s2); padding-left: var(--s4); font-size: 13px; color: var(--ink-sub); }
#no-hit[hidden] { display: none; }
