/* ============================================================
 * JP.AI — Future Japan AI Gateway
 * Dark theme / indigo–violet gradient / subtle Japanese motifs
 * ============================================================ */

:root {
  --bg: #070a14;
  --bg-soft: #0c1020;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(255, 255, 255, 0.07);
  --text: #eef1fa;
  --text-dim: #9aa3bd;
  --accent-1: #6366f1;  /* indigo  */
  --accent-2: #a855f7;  /* violet  */
  --accent-3: #22d3ee;  /* cyan    */
  --gold:   #fbbf24;
  --silver: #cbd5e1;
  --bronze: #d97706;
  --radius: 16px;
  --header-h: 64px;
  --tagnav-h: 56px;
  --font: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- ambient background ---------- */
.bg-fx {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 15% -5%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(800px 500px at 85% 5%, rgba(168, 85, 247, 0.16), transparent 60%),
    radial-gradient(700px 600px at 50% 110%, rgba(34, 211, 238, 0.08), transparent 60%),
    var(--bg);
}
/* asanoha-inspired dot grid */
.bg-fx::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), transparent 70%);
}

a { color: inherit; text-decoration: none; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ============================================================
 * Header
 * ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(7, 10, 20, 0.72);
  border-bottom: 1px solid var(--card-border);
}
.header-inner {
  height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.logo {
  display: flex; align-items: baseline; gap: 10px;
  font-weight: 800; font-size: 1.5rem; letter-spacing: 0.02em;
}
.logo .logo-mark {
  background: linear-gradient(120deg, var(--accent-3), var(--accent-1) 45%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.logo .logo-sub {
  font-size: 0.7rem; font-weight: 500; color: var(--text-dim);
  letter-spacing: 0.08em;
}

/* language toggle */
.lang-toggle {
  display: flex; border: 1px solid var(--card-border); border-radius: 999px;
  overflow: hidden; background: var(--card);
}
.lang-toggle button {
  border: 0; background: transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 0.82rem; font-weight: 600;
  padding: 7px 16px; cursor: pointer; transition: all .2s ease;
}
.lang-toggle button.active {
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  color: #fff;
}

/* ============================================================
 * Hero
 * ============================================================ */
.hero { padding: 72px 0 44px; text-align: center; position: relative; }

.hero .torii {
  font-size: 1.6rem; opacity: 0.85; display: inline-block; margin-bottom: 14px;
  filter: drop-shadow(0 0 14px rgba(168, 85, 247, 0.55));
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 800; letter-spacing: 0.01em; line-height: 1.15;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent-3), var(--accent-1) 40%, var(--accent-2) 80%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero .tagline {
  margin-top: 14px; font-size: clamp(1rem, 2.6vw, 1.25rem);
  color: var(--text); font-weight: 600;
}
.hero .subline { margin-top: 6px; color: var(--text-dim); font-size: 0.95rem; }

/* ---------- search ---------- */
.search-wrap { max-width: 640px; margin: 34px auto 0; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px; padding: 6px 6px 6px 22px;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.search-box:focus-within {
  border-color: rgba(139, 122, 246, 0.65);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 0 28px rgba(168, 85, 247, 0.18);
}
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: var(--text); font-family: var(--font); font-size: 1rem; min-width: 0;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box button {
  border: 0; cursor: pointer; border-radius: 999px;
  padding: 11px 24px; font-family: var(--font); font-weight: 700; font-size: 0.92rem;
  color: #fff; background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  transition: transform .15s ease, box-shadow .2s ease; white-space: nowrap;
}
.search-box button:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4); }
.powered { margin-top: 10px; font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.05em; }

/* ---------- MCP gateway promo line ---------- */
.mcp-badge {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 14px auto 0; width: fit-content; max-width: 100%;
  padding: 8px 18px; border-radius: 999px;
  font-size: clamp(0.72rem, 2.6vw, 0.85rem); font-weight: 600;
  white-space: nowrap; overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none;
  color: var(--text-dim);
  border: 1px solid rgba(168, 85, 247, 0.35);
  background: rgba(139, 92, 246, 0.08);
  transition: all .2s ease;
}
.mcp-badge::-webkit-scrollbar { display: none; }
.mcp-badge code {
  font-family: var(--font); font-weight: 700; color: var(--text);
  background: none; padding: 0;
}
.mcp-badge:hover {
  color: #fff; border-color: rgba(139, 122, 246, 0.6);
  background: rgba(99, 102, 241, 0.18);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.25);
  transform: translateY(-1px);
}

/* ---------- keyword chips ---------- */
.keywords {
  margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}
.keywords a {
  font-size: 0.85rem; font-weight: 600; color: var(--text-dim);
  padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--card-border); background: var(--card);
  transition: all .2s ease;
}
.keywords a:hover {
  color: #fff; border-color: rgba(139, 122, 246, 0.6);
  background: rgba(99, 102, 241, 0.18);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.25);
  transform: translateY(-1px);
}

/* ============================================================
 * Latest AI marquee
 * ============================================================ */
.newest { padding: 40px 0 8px; }
.section-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
}
.section-head h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.02em; }
.section-head .bar {
  width: 5px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent-3), var(--accent-2));
}

.marquee {
  overflow: hidden; position: relative;
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}
.marquee-track {
  display: flex; gap: 14px; width: max-content;
  padding: 12px 0 6px;   /* room for the NEW badge that sticks out above cards */
  animation: marquee 36s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

.new-card {
  display: flex; align-items: center; gap: 12px;
  min-width: 250px; padding: 14px 18px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius);
  transition: all .2s ease; position: relative;
}
.new-card:hover {
  background: var(--card-hover); border-color: rgba(139, 122, 246, 0.5);
  transform: translateY(-2px);
}
.new-card .new-badge {
  position: absolute; top: -8px; right: 10px;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.08em;
  padding: 2px 8px; border-radius: 999px; color: #fff;
  background: linear-gradient(120deg, #f43f5e, var(--accent-2));
}
.new-card .t-name { font-weight: 700; font-size: 0.95rem; }
.new-card .t-tag { font-size: 0.74rem; color: var(--text-dim); }

/* ---------- tool icon (favicon w/ letter fallback) ---------- */
.t-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  overflow: hidden; position: relative;
}
.t-icon img {
  width: 100%; height: 100%; object-fit: contain;
  padding: 7px; background: #fff; position: absolute; inset: 0;
}

/* ============================================================
 * Sticky tag nav
 * ============================================================ */
/* wrapping tag cloud — all categories visible, sticky below the header */
.tag-nav {
  position: sticky; top: var(--header-h); z-index: 90;
  margin-top: 34px;
  background: rgba(7, 10, 20, 0.82);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}
.tag-nav-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
}
.tag-nav-inner {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  flex: 1;
}
.tag-nav-all { display: none; } /* only shown on mobile, see media query below */
.tag-nav a {
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-dim); padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--card-border); background: var(--card);
  transition: all .2s ease;
}
.tag-nav a:hover {
  color: #fff; border-color: rgba(139, 122, 246, 0.6);
  background: rgba(99, 102, 241, 0.18);
  transform: translateY(-1px);
}
.tag-nav a.active {
  color: #fff; background: rgba(99, 102, 241, 0.22);
  border-color: rgba(139, 122, 246, 0.55);
}

/* ============================================================
 * Ranking sections
 * ============================================================ */
.rankings { padding: 40px 0 30px; }
.rank-section { padding-top: 26px; margin-bottom: 40px; }
.rank-section .section-head h2 .icon { margin-right: 8px; }

.rank-list { display: flex; flex-direction: column; gap: 12px; }

.rank-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius);
  transition: all .2s ease;
}
.rank-item:hover {
  background: var(--card-hover);
  border-color: rgba(139, 122, 246, 0.45);
  transform: translateX(4px);
}

/* rank number */
.rank-no {
  width: 44px; flex-shrink: 0; text-align: center;
  font-weight: 800; font-size: 1.35rem; font-style: italic;
  color: var(--text-dim);
}
.rank-item[data-rank="1"] .rank-no { color: var(--gold);   text-shadow: 0 0 18px rgba(251, 191, 36, .5); font-size: 1.6rem; }
.rank-item[data-rank="2"] .rank-no { color: var(--silver); text-shadow: 0 0 14px rgba(203, 213, 225, .4); font-size: 1.5rem; }
.rank-item[data-rank="3"] .rank-no { color: var(--bronze); text-shadow: 0 0 14px rgba(217, 119, 6, .45); font-size: 1.45rem; }
.rank-item[data-rank="1"] { border-color: rgba(251, 191, 36, 0.35); background: linear-gradient(90deg, rgba(251,191,36,0.06), var(--card) 45%); }

.rank-body { flex: 1; min-width: 0; }
.rank-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rank-name { font-weight: 700; font-size: 1.05rem; }
.rank-badge {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  color: #cdb4ff; background: rgba(168, 85, 247, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.35);
}
.rank-desc { margin-top: 3px; font-size: 0.85rem; color: var(--text-dim); }

.rank-visit {
  flex-shrink: 0; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
  padding: 9px 18px; border-radius: 999px;
  color: var(--text); border: 1px solid var(--card-border);
  transition: all .2s ease;
}
.rank-visit:hover {
  color: #fff; border-color: transparent;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.35);
}

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ============================================================
 * Footer
 * ============================================================ */
.site-footer {
  border-top: 1px solid var(--card-border);
  padding: 34px 0 44px; text-align: center;
  color: var(--text-dim); font-size: 0.8rem;
}
.site-footer .foot-logo {
  font-weight: 800; font-size: 1.1rem; margin-bottom: 8px;
  background: linear-gradient(120deg, var(--accent-3), var(--accent-1) 45%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.site-footer .foot-note { max-width: 620px; margin: 0 auto 10px; }

/* ============================================================
 * Responsive
 * ============================================================ */
@media (max-width: 640px) {
  .hero { padding: 48px 0 34px; }
  .search-box button { padding: 10px 16px; }
  .rank-item { padding: 13px 14px; gap: 10px; }
  .rank-no { width: 30px; font-size: 1.15rem; }
  .rank-visit { display: none; }           /* whole row is clickable on mobile */
  .rank-desc { font-size: 0.78rem; }
  .t-icon { width: 34px; height: 34px; }
  .new-card { min-width: 210px; }

  /* collapse the category chips to the first 2 + a "全て" toggle,
     so a long category list doesn't eat the whole screen (and the
     first couple chips don't get squeezed/wrapped) */
  .tag-nav-inner {
    flex: 1; min-width: 0;
    flex-wrap: nowrap; overflow: hidden;
    justify-content: flex-start;
  }
  .tag-nav-inner a:nth-child(n+3) { display: none; }
  .tag-nav-inner.expanded {
    flex-wrap: wrap; overflow: visible;
  }
  .tag-nav-inner.expanded a:nth-child(n+3) { display: inline-flex; }

  .tag-nav-all {
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-family: var(--font);
    font-size: 0.8rem; font-weight: 700;
    padding: 7px 14px; border-radius: 999px; cursor: pointer;
    color: var(--text-dim); border: 1px solid var(--card-border);
    background: var(--card);
    transition: all .2s ease;
  }
  .tag-nav-all.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(139, 122, 246, 0.55);
  }
}
