/* ============================================================
   FreeAppsStudio — Design tokens
   ============================================================ */
:root {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --text: #111114;
  --sub: #63666d;
  --border: #eaeaec;
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --danger: #dc2626;
  --shadow: 0 10px 30px -12px rgba(17, 17, 20, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --max-w: 860px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0f;
    --bg-elevated: #111318;
    --card: #15171d;
    --text: #f5f5f7;
    --sub: #9a9da6;
    --border: #24262e;
    --accent: #818cf8;
    --accent-2: #22d3ee;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

/* Manual override (data-theme set by script.js), takes priority over system */
:root[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --text: #111114;
  --sub: #63666d;
  --border: #eaeaec;
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --shadow: 0 10px 30px -12px rgba(17, 17, 20, 0.12);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0c0f;
  --bg-elevated: #111318;
  --card: #15171d;
  --text: #f5f5f7;
  --sub: #9a9da6;
  --border: #24262e;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ============================================================
   i18n visibility (toggled via html.lang-ja / html.lang-en, set
   synchronously in <head> to avoid a flash of both languages)
   ============================================================ */
.lang-ja [lang="en"] { display: none; }
.lang-en [lang="ja"] { display: none; }

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", Meiryo, Inter, Roboto, Arial, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { padding-left: 1.2em; }
h1, h2, h3, p { overflow-wrap: anywhere; }

/* ============================================================
   Top bar (lang + theme switch)
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand .logo-mark { width: 22px; height: 22px; }

.controls { display: flex; gap: 8px; }

.pill-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.pill-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.pill-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ============================================================
   Layout
   ============================================================ */
main, .page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* Hero */
.hero {
  position: relative;
  padding: 168px 24px 96px;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 640px;
  z-index: -1;
  background:
    radial-gradient(closest-side, color-mix(in srgb, var(--accent) 32%, transparent), transparent),
    radial-gradient(closest-side, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent);
  background-position: 15% 20%, 85% 10%;
  background-repeat: no-repeat;
  background-size: 55% 55%, 50% 50%;
  filter: blur(60px);
  opacity: .55;
}
.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(40px, 8vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
  font-weight: 800;
}
.hero-sub {
  font-size: clamp(17px, 2.4vw, 21px);
  color: var(--sub);
  max-width: 560px;
  margin: 0 auto;
}
.scroll-hint {
  margin-top: 56px;
  font-size: 13px;
  color: var(--sub);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(6px);} }

/* Sections */
section.block {
  padding: 88px 0;
  border-top: 1px solid var(--border);
}
section.block:first-of-type { border-top: none; }
.eyebrow-sm {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
h2 {
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: -0.02em;
  margin: 0 0 20px;
  font-weight: 800;
}
.lede {
  font-size: 17px;
  color: var(--sub);
  max-width: 640px;
  margin: 0 0 8px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: transform .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

.apps-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin-top: 28px;
}
.app-card { display: flex; flex-direction: column; gap: 14px; }
.app-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-card h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.app-card .status {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--sub);
  text-transform: uppercase;
}
.app-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.app-links a {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--sub);
}
.app-links a:hover { color: var(--text); border-color: var(--accent); }

/* Contact */
.contact-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.contact-email {
  font-size: clamp(19px, 3vw, 24px);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  transition: opacity .2s ease;
}
.btn:hover { opacity: .85; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px 60px;
  text-align: center;
  color: var(--sub);
  font-size: 13px;
}
footer .foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
}
footer .foot-links a:hover { color: var(--text); }

/* Reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ============================================================
   Legal / static content pages
   ============================================================ */
.doc {
  padding: 140px 0 90px;
}
.doc h1 { font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.02em; margin-bottom: 6px; }
.doc .updated { color: var(--sub); font-size: 13px; margin-bottom: 40px; }
.doc h2 { font-size: 20px; margin-top: 40px; }
.doc p, .doc li { color: var(--sub); font-size: 15.5px; }
.doc a { color: var(--accent); font-weight: 600; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--sub);
  margin-bottom: 26px;
}
.back-link:hover { color: var(--text); }

/* 404 */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.error-page .code {
  font-size: clamp(64px, 14vw, 120px);
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .hero { padding-top: 132px; }
  section.block { padding: 64px 0; }
  .contact-card { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { transition: none; opacity: 1; transform: none; }
  .scroll-hint { animation: none; }
}
