/* ================================================================
   top.css — トップページ(index.html)専用スタイル
   ベースは style.css の設計トークンを継承。スマホ幅(360px)を基準に書く。
   ================================================================ */

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

/* ================================================================
   ヒーロー(高さを抑え、検索と入口ボタンを最初の画面に入れる)
   ================================================================ */
.hero {
  /* 検索結果パネルを下にはみ出させるため、切り抜きは背景レイヤー側で行う */
  overflow: visible;
  padding: 1.6rem 1.2rem 2rem;
}

.hero::before,
.hero::after { content: none; }

.hero-bg-grid { overflow: hidden; }

.hero-bg-grid::before {
  content: "";
  position: absolute;
  top: -30%;
  right: -10%;
  width: 60%;
  height: 120%;
  background: radial-gradient(ellipse at center, rgba(245, 158, 11, 0.12) 0%, transparent 65%);
}

.hero-bg-grid::after {
  content: "";
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 50%;
  height: 80%;
  background: radial-gradient(ellipse at center, rgba(14, 165, 233, 0.1) 0%, transparent 65%);
}

.hero-tagline { margin-bottom: 0.6rem; }

.hero-lead {
  margin: 0.6rem 0 1rem;
  line-height: 1.7;
}

/* スマホ・タブレット幅:ロゴだけを、見出しのすぐ上に中央寄せで表示する
   (PCと同じ <img> を使う。回転リング・方位記号・泡の装飾は、高さを取るので出さない) */
.hero-inner { gap: 1rem; }

.hero-visual { display: flex; }

.hero-compass {
  /* 幅は画面の約50%(上限180px)。縦に短い画面では120pxまで小さくして、入口ボタンまで最初の画面に入れる(隠さない) */
  width: clamp(120px, min(50vw, 22vh), 180px);
  max-width: none;
}

.hero-compass > :not(.hero-logo) { display: none; }

.hero-logo {
  width: 100%;
  border-radius: var(--r-md);
  animation: none;
}

@media (min-width: 601px) {
  .hero { padding: 2.6rem 1.5rem 2.8rem; }
}

@media (min-width: 901px) {
  .hero { padding: 3.2rem 1.5rem 3.4rem; }
  .hero-text { max-width: 620px; }
  /* 回転するリングの四隅がページ幅を押し広げないよう、装飾はこの枠で切り抜く */
  .hero-inner { gap: 3.5rem; }
  .hero-visual { display: flex; padding: 60px; overflow: hidden; }
  .hero-compass { width: 230px; max-width: 78vw; }
  .hero-compass > :not(.hero-logo) { display: block; }
  .hero-logo { border-radius: var(--r-lg); animation: float 6s ease-in-out infinite; }
}

/* ---- サイト内検索 ---- */
.site-search {
  position: relative;
  max-width: 560px;
  margin: 0 auto 1rem;
  text-align: left;
}

@media (min-width: 901px) {
  .site-search { margin-left: 0; }
}

.site-search__field { position: relative; }

.site-search__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-muted);
  pointer-events: none;
}

.site-search__input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 1rem 0 2.7rem;
  border: 2px solid transparent;
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--c-text);
  font-family: inherit;
  font-size: 16px; /* iOS の自動ズームを防ぐ */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  -webkit-appearance: none;
  appearance: none;
}

.site-search__input::placeholder { color: #94a3b8; }

.site-search__input:focus {
  outline: none;
  border-color: var(--c-amber);
}

.site-search__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  background: #fff;
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
}

.site-search__status {
  margin: 0;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--c-muted);
}

.site-search__status:empty { display: none; }

.site-search__results {
  list-style: none;
  margin: 0;
  padding: 0 0.4rem 0.4rem;
}

.site-search__results:empty { display: none; }

.site-search__results a {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  align-items: center;
  gap: 0.15rem 0.7rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--r-sm);
}

.site-search__results a:hover,
.site-search__results a:focus-visible {
  background: var(--c-blue-lt);
  outline: none;
}

.search-hit__type {
  grid-row: span 2;
  padding: 0.15rem 0;
  border-radius: var(--r-pill);
  background: var(--c-amber-lt);
  color: #92400e;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.search-hit__title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--c-navy);
  line-height: 1.4;
}

.search-hit__sub {
  grid-column: 2;
  font-size: 0.74rem;
  color: var(--c-muted);
  line-height: 1.4;
}

/* ---- 入口ボタン(中学生 / 高校生 / 大学・社会人) ---- */
.hero-entry { max-width: 560px; margin: 0 auto; }

@media (min-width: 901px) {
  .hero-entry { margin-left: 0; }
}

.hero-entry__label {
  margin: 0 0 0.4rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
}

.hero-entry__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.entry-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 48px;
  padding: 0.3rem 0.4rem;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #ff9f43, #ff6b35);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.entry-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(255, 107, 53, 0.5);
}

.entry-btn:focus-visible,
.hero-sublinks a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 400px) {
  .entry-btn i { display: none; }
}

@media (min-width: 601px) {
  .entry-btn { font-size: 0.95rem; }
}

/* ---- 優先度を下げた既存リンク ---- */
.hero-sublinks {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.45);
}

.hero-sublinks a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.3rem 0.2rem;
}

.hero-sublinks a:hover { color: #fcd34d; }

/* ================================================================
   新規セクション共通
   ================================================================ */
.top-section { padding: 3rem 1.2rem; }

.top-section__inner {
  max-width: 1200px;
  margin: 0 auto;
}

.top-section .section-lead { margin-bottom: 1.4rem; }

.top-section--periodic {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.top-section--popular { background: var(--c-bg); }

@media (min-width: 769px) {
  .top-section { padding: 4.5rem 1.5rem; }
}

.section-more {
  margin: 1.6rem 0 0;
  text-align: center;
}

.section-more a,
.journey-more a {
  display: inline-block;
  padding: 0.5rem 0.4rem;
  color: var(--c-blue);
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  transition: border-color 0.18s ease;
}

.section-more a:hover,
.journey-more a:hover { border-bottom-color: var(--c-blue); }

/* ================================================================
   周期表(配色は atoms.html と同じ:背景=常温での状態、枠線=分類)
   ================================================================ */
.pt-solid   { background: linear-gradient(135deg, #e3f2fd, #bbdefb); }
.pt-liquid  { background: linear-gradient(135deg, #fff9c4, #ffe082); }
.pt-gas     { background: linear-gradient(135deg, #ffccbc, #ffab91); }
.pt-unknown { background: linear-gradient(135deg, #e0e0e0, #bdbdbd); }

.pt-metal     { border: 2px solid #1e88e5; }
.pt-nonmetal  { border: 2px solid #e53935; }
.pt-metalloid { border: 2px dashed #ffb300; }

.pt-legend {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.9rem;
  font-size: 0.78rem;
  color: var(--c-muted);
}

.pt-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pt-legend__swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.pt-legend__swatch--border { background: #fff; }

.pt-scroll-hint {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: 0.76rem;
  color: var(--c-muted);
}

@media (min-width: 1240px) {
  .pt-scroll-hint { display: none; }
}

.pt-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.8rem;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

.pt-scroll:focus-visible {
  outline: 3px solid var(--c-blue);
  outline-offset: 2px;
}

.pt-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(18, minmax(58px, 1fr));
  /* 8行目はランタノイド・アクチノイドとの間の余白 */
  grid-template-rows: repeat(7, auto) 0.5rem repeat(2, auto);
  gap: 4px;
  min-width: 1112px;
}

.pt-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-height: 62px;
  padding: 2px 2px 4px;
  border-radius: 8px;
  color: var(--c-navy);
  text-align: center;
  line-height: 1.15;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pt-num {
  align-self: flex-start;
  padding-left: 2px;
  font-size: 0.62rem;
  font-weight: 600;
}

.pt-sym {
  font-size: 1.1rem;
  font-weight: 800;
}

.pt-name {
  margin-top: 1px;
  font-size: 0.64rem;
}

a.pt-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

a.pt-cell:focus-visible {
  outline: 3px solid var(--c-navy);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}

/* 元素ページがまだ無い元素:薄く表示し、リンクにしない */
.pt-missing {
  opacity: 0.35;
  cursor: default;
}

/* ================================================================
   よく読まれている単元
   ================================================================ */
.unit-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

@media (min-width: 640px) {
  .unit-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1000px) {
  .unit-grid { grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
}

.unit-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  height: 100%;
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.unit-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-blue);
}

.unit-card:focus-visible,
.section-more a:focus-visible,
.journey-more a:focus-visible,
.academy-strip__link:focus-visible {
  outline: 3px solid var(--c-blue);
  outline-offset: 2px;
}

.unit-card__level {
  padding: 0.12rem 0.7rem;
  border-radius: var(--r-pill);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* 色は subject.html のレベル別カードに合わせる(白文字が読める濃さの側を使用) */
.unit-card__level--jh   { background: #047857; }
.unit-card__level--hs   { background: #b45309; }
.unit-card__level--univ { background: #5b21b6; }

.unit-card__title {
  font-size: 1.02rem;
  color: var(--c-navy);
  line-height: 1.45;
}

.unit-card__desc {
  font-size: 0.83rem;
  color: var(--c-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* ================================================================
   地図帳一覧(主要4枚)
   ================================================================ */
.featured-card--terms {
  background: linear-gradient(145deg, #fef3c7, #fde68a);
  border-color: #fcd34d;
}

@media (min-width: 961px) {
  .featured-grid--four { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1100px) {
  .featured-grid--four { grid-template-columns: repeat(4, 1fr); gap: 1.1rem; }
  .featured-grid--four .featured-card { padding: 1.6rem 1.3rem 2.6rem; }
}

.featured-maps { padding-bottom: 4rem; }

.all-maps { padding: 2.5rem 1.5rem 3.5rem; }

.map-list--single {
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
}

/* ================================================================
   Chem Atlasとは?(縮小版)
   ================================================================ */
.journey--compact { padding: 3.5rem 1.5rem; }

.journey-more { margin: 0; }

@media (max-width: 860px) {
  .journey-more { text-align: center; }
}

/* ================================================================
   Chem Atlas Academy(小さな帯)
   ================================================================ */
.academy-strip {
  padding: 1rem 1.2rem;
  background: var(--c-navy);
  color: #fff;
}

.academy-strip__inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
}

.academy-strip__text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
}

.academy-strip__text strong {
  display: block;
  font-size: 0.9rem;
  color: #fcd34d;
}

.academy-strip__link {
  flex-shrink: 0;
  padding: 0.35rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--r-pill);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.academy-strip__link:hover { background: rgba(255, 255, 255, 0.14); }
.academy-strip__link:focus-visible { outline-color: #fff; }

@media (min-width: 769px) {
  .academy-strip__inner {
    flex-direction: row;
    justify-content: space-between;
    gap: 1.5rem;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-btn, .unit-card, .pt-cell { transition: none; }
}
