/* sci.wadai.me 公開サイト（1 本だけ。外のフォントは読まない） */

:root {
  /* 水色（ブランド）。--sky は塗り・ロゴ・枠、--sky-ink は白地の文字とリンク */
  --sky: #22a6e0;
  --sky-ink: #0b77b0;
  --sky-tint: #e6f5fc;

  --bg: #ffffff;
  --surface: #f6f7f8;
  --card: #ffffff;
  --text: #1a1c1e;
  --muted: #5d6368;
  --line: #e2e5e8;
  --line-strong: #c9ced3;
  --focus: #22a6e0;

  /* テスト版の帯（本公開とはっきり分ける色） */
  --test-bg: #ffb020;
  --test-text: #1f1400;
  --test-stripe: rgba(0, 0, 0, 0.08);

  --radius: 12px;
  --band-h: 48px;
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Noto Sans JP",
    "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sky-ink: #6cc9f0;
    --sky-tint: #10303f;
    --bg: #141618;
    --surface: #1b1e21;
    --card: #1d2023;
    --text: #e8eaec;
    --muted: #a3a9ae;
    --line: #2d3136;
    --line-strong: #41474d;
    --test-bg: #f2a516;
    --test-text: #1a1100;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--sky-ink);
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

img,
svg {
  display: block;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ───────── ヘッダー・フッター ───────── */

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  min-height: 60px;
}

.home-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 0;
  min-height: 44px;
}

.logo {
  height: 30px;
  width: auto;
}

.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.site-footer .wrap {
  padding-top: 20px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
}

/* ───────── ボタン ───────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: var(--sky);
}

/* ───────── トップ ───────── */

.hero {
  padding: 32px 0 8px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(26px, 6.4vw, 38px);
  line-height: 1.3;
  letter-spacing: 0.02em;
  font-weight: 800;
}

.hero h1::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin-bottom: 16px;
  border-radius: 2px;
  background: var(--sky);
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 3.8vw, 17px);
}

.intro {
  margin-top: 16px;
  max-width: 44em;
}

.intro p {
  margin: 0 0 0.8em;
}

.tools {
  margin-top: 24px;
}

.finder {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px;
  padding: 12px 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.search {
  position: relative;
  display: block;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: 46px;
  padding: 8px 14px 8px 42px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* iOS で拡大されない大きさ */
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sky) 30%, transparent);
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* 横に流せる。はみ出しはこの行の中だけ */
  margin-left: -16px;
  margin-right: -16px;
  padding: 0 16px;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip-label {
  flex: none;
  min-width: 2.6em;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.chip {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--sky);
}

.chip[aria-pressed="true"] {
  border-color: var(--sky-ink);
  background: var(--sky-ink);
  color: var(--bg);
  font-weight: 700;
}

.count {
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 600px) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
  }
}

.card {
  display: flex;
}

.card-link {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 16px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card-link:hover {
  border-color: var(--sky);
  box-shadow: 0 6px 20px -12px color-mix(in srgb, var(--sky) 60%, transparent);
  transform: translateY(-1px);
}

.card-link:active {
  transform: translateY(0);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.badge-subject {
  border-color: transparent;
  background: var(--sky-tint);
  color: var(--sky-ink);
}

.card-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 700;
}

.card-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.card-go {
  margin-top: auto;
  padding-top: 12px;
  color: var(--sky-ink);
  font-size: 13px;
  font-weight: 700;
}

.no-match,
.empty {
  padding: 40px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.no-match p,
.empty p {
  margin: 0 0 12px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  fill: none;
  stroke: var(--sky);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

/* ───────── 404 ───────── */

.not-found {
  padding-top: 48px;
  padding-bottom: 24px;
}

.not-found .nf-code {
  margin: 0;
  color: var(--sky);
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
}

.not-found h1 {
  margin: 16px 0 8px;
  font-size: 22px;
  line-height: 1.4;
}

.not-found p {
  color: var(--muted);
}

/* ───────── 枠つきのページ（細い帯＋iframe） ───────── */

.page-frame {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.band {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--band-h);
  padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.band-home {
  flex: none;
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 6px;
  border-radius: 8px;
}

.band-logo {
  height: 26px;
  width: auto;
}

.band-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fs-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* 押せる広さは 44px にする（見た目は 36px） */
.fs-button {
  position: relative;
}

.fs-button::after {
  content: "";
  position: absolute;
  inset: -4px;
}

.fs-button:hover {
  border-color: var(--sky);
}

.fs-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-frame {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 0;
  height: calc(100dvh - var(--band-h));
  border: 0;
  background: #fff;
}

/* テスト版: 帯を黄色の斜線にして、本公開とすぐ見分けられるようにする */
.band-test {
  border-bottom-color: transparent;
  background: var(--test-bg)
    repeating-linear-gradient(-45deg, transparent 0 12px, var(--test-stripe) 12px 24px);
  color: var(--test-text);
}

.band-test .band-home {
  /* 黄色の地では水色が沈むので、白い台にのせる */
  height: 34px;
  padding: 0 6px;
  background: #ffffff;
}

.band-test .band-logo {
  height: 22px;
}

.test-badge {
  flex: none;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--test-text);
  color: var(--test-bg);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.test-note {
  flex: none;
  font-size: 12px;
  font-weight: 600;
}

.band-test .fs-button {
  border-color: rgba(0, 0, 0, 0.35);
  background: rgba(255, 255, 255, 0.85);
  color: #1a1c1e;
}

@media (max-width: 720px) {
  .test-note {
    display: none;
  }
}

@media (max-width: 560px) {
  .band-home {
    padding: 0 4px;
  }

  .band {
    gap: 8px;
  }
}

@media (max-width: 360px) {
  .fs-button span {
    display: none;
  }

  .fs-button {
    padding: 0 10px;
  }
}

/* ───────── 動きを止める ───────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .card-link:hover {
    transform: none;
  }
}
