/* =======================================
   KUMIAI — Design System
   Dark mode premium, Japanese aesthetics
   ======================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Serif+JP:wght@300;400;700&family=Space+Mono:wght@400;700&display=swap');

/* ── CSS Variables ───────────────────── */
:root {
  --red:       #e8432d;
  --red-soft:  #ff6b52;
  --orange:    #f0924a;
  --gold:      #f5c842;

  --bg:        #0d0d12;
  --bg-card:   #16161f;
  --bg-glass:  rgba(22, 22, 31, 0.7);
  --border:    rgba(255, 255, 255, 0.07);
  --border-accent: rgba(232, 67, 45, 0.35);

  --text:      #e8e8f0;
  --text-muted:#8888a8;
  --text-dim:  #555570;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;

  --shadow:    0 4px 32px rgba(0,0,0,0.45);
  --shadow-card: 0 2px 20px rgba(0,0,0,0.4);

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  margin: 0;
  /* Subtle grid pattern */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(232,67,45,0.08) 0%, transparent 70%),
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: auto, 60px 60px, 60px 60px;
}

/* ── Bootstrap overrides ─────────────── */
.container, .container-fluid {
  --bs-gutter-x: 2rem;
}

/* ── Typography ──────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Space Mono', monospace;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  background: linear-gradient(135deg, var(--red-soft) 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

h2 {
  color: var(--orange);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  margin-bottom: 0.5rem;
}

h3 {
  color: var(--red-soft);
  font-size: 1.1rem;
}

p { color: var(--text-muted); line-height: 1.75; }

a {
  color: var(--red-soft);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--orange); }

strong { color: var(--text); }

/* ── Header / Nav ────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(13, 13, 18, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header .logo img {
  height: 44px;
  width: auto;
  transition: transform var(--transition), filter var(--transition);
}
.site-header .logo:hover img {
  transform: scale(1.06);
  filter: drop-shadow(0 0 10px rgba(232,67,45,0.6));
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, var(--red), var(--orange));
  border-radius: 2px;
  transition: transform var(--transition);
}
.site-nav a:hover, .site-nav a.active {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.site-nav a:hover::after, .site-nav a.active::after {
  transform: translateX(-50%) scaleX(1);
}

.site-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ── Buttons ─────────────────────────── */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.1rem;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red) 0%, var(--orange) 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(232,67,45,0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(232,67,45,0.5);
  color: #fff;
  background: linear-gradient(135deg, var(--red-soft) 0%, var(--gold) 100%);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--red-soft);
  border: 1.5px solid var(--border-accent);
}
.btn-outline:hover {
  background: rgba(232,67,45,0.12);
  border-color: var(--red-soft);
  color: var(--red-soft);
  transform: translateY(-1px);
}

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-w-full { width: 100%; }

/* Bootstrap compat shim */
.btn-outline-primary { composes: btn-outline; }
.btn-outline-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  transition: all var(--transition);
  cursor: pointer;
}
.btn-outline-secondary:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

/* ── Cards ───────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-card);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  border-color: var(--border-accent);
}

.card-kanji-symbol {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a26 0%, #12121c 100%);
  font-family: 'Noto Serif JP', serif;
  font-size: 5rem;
  color: #fff;
  text-shadow: 0 0 40px rgba(232,67,45,0.5);
  position: relative;
  overflow: hidden;
}
.card-kanji-symbol::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(232,67,45,0.12) 0%, transparent 70%);
}

.card-body {
  padding: 1rem 1.1rem 1.1rem;
}
.card-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  min-height: 2.5em;
}
.card-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.card-jlpt-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(232,67,45,0.15);
  color: var(--red-soft);
  border: 1px solid var(--border-accent);
  letter-spacing: 0.05em;
}

/* ── Sidebar / Filters ───────────────── */
.filters-sidebar {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: 85px;
}
.filters-sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

/* ── Form Controls ───────────────────── */
.form-control, .form-select {
  background: rgba(255,255,255,0.04);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  transition: all var(--transition);
  width: 100%;
}
.form-control:focus, .form-select:focus {
  background: rgba(255,255,255,0.07);
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px rgba(232,67,45,0.12);
  color: var(--text);
  outline: none;
}
.form-control::placeholder { color: var(--text-dim); }
.form-select option {
  background: var(--bg-card);
  color: var(--text);
}

label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.4rem;
  display: block;
}

.filter-group {
  margin-bottom: 1rem;
}

/* ── Page Layout ─────────────────────── */
.page-wrapper {
  max-width: 1380px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.layout-sidebar {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 768px) {
  .layout-sidebar {
    grid-template-columns: 1fr;
  }
  .filters-sidebar {
    position: static;
  }
}

/* ── Hero (index) ────────────────────── */
.hero {
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '学';
  position: absolute;
  font-family: 'Noto Serif JP', serif;
  font-size: 40vw;
  color: rgba(255,255,255,0.012);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.hero-eyebrow {
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--orange);
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 4rem);
  margin-bottom: 1rem;
}

.hero p.lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 2.5rem;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 3.5rem;
}

.hero-stats {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}
.hero-stat {
  text-align: center;
}
.hero-stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--red-soft), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}
.hero-stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.25rem;
}

/* ── Section Heading ─────────────────── */
.section-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.section-heading-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-heading h2 {
  margin: 0;
  white-space: nowrap;
}

/* ── Grid Cards ──────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

/* ── Detail Page ─────────────────────── */
.detail-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem 2rem;
  text-align: center;
}
.detail-kanji-display {
  font-family: 'Noto Serif JP', serif;
  font-size: clamp(5rem, 18vw, 11rem);
  line-height: 1;
  color: var(--text);
  margin: 1rem 0;
  text-shadow: 0 0 80px rgba(232,67,45,0.3);
  position: relative;
}
.detail-kanji-display::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--orange));
  border-radius: 2px;
}

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  margin-bottom: 1.25rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.detail-section h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.detail-section p {
  color: var(--text);
  font-size: 1rem;
  margin: 0;
}
.detail-section ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
}
.detail-section ul li {
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
}

/* ── Reading pills ───────────────────── */
.reading-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.reading-pill {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.3rem 0.85rem;
  font-family: 'Noto Serif JP', serif;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.reading-pill.kun { border-color: rgba(240,146,74,0.3); color: var(--orange); }
.reading-pill.on  { border-color: rgba(232,67,45,0.3);  color: var(--red-soft); }

/* ── Accordion (getstarted) ──────────── */
.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.accordion-button {
  background: var(--bg-card);
  color: var(--text);
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 1.1rem 1.25rem;
  border: none;
  box-shadow: none;
}
.accordion-button:not(.collapsed) {
  background: rgba(232,67,45,0.08);
  color: var(--red-soft);
  box-shadow: none;
}
.accordion-button::after {
  filter: invert(1) brightness(0.7);
}
.accordion-body {
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 0.25rem 1.5rem 1.25rem;
}
.accordion-body ol, .accordion-body ul {
  padding-left: 1.3rem;
  color: var(--text-muted);
}
.accordion-body li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

/* ── Footer ──────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  margin-top: 4rem;
  background: rgba(13,13,18,0.8);
}
.site-footer-nav {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  list-style: none;
  padding: 0;
}
.site-footer-nav a {
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: color var(--transition);
}
.site-footer-nav a:hover { color: var(--text-muted); }
.site-footer-copy {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.site-footer-copy span {
  background: linear-gradient(90deg, var(--red-soft), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* ── Animations ──────────────────────── */
.fade-in {
  animation: fadeUp 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fade-in-delay-1 { animation-delay: 0.1s; }
.fade-in-delay-2 { animation-delay: 0.2s; }
.fade-in-delay-3 { animation-delay: 0.3s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── User greeting ───────────────────── */
.user-greeting {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Vocab detail links ───────────────── */
.kanji-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.kanji-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Noto Serif JP', serif;
  font-size: 1.4rem;
  color: var(--text);
  transition: all var(--transition);
}
.kanji-link-btn:hover {
  border-color: var(--border-accent);
  background: rgba(232,67,45,0.1);
  color: var(--red-soft);
  transform: scale(1.08);
}

/* ── Tip boxes ───────────────────────── */
.tip-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}
.tip-box strong { color: var(--orange); }

/* ── Login / Register forms ──────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  text-align: center;
  margin-bottom: 0.25rem;
}
.auth-card p.subtitle {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}
.form-field {
  margin-bottom: 1rem;
}

/* ── Responsive tweaks ───────────────── */
@media (max-width: 640px) {
  .site-header { padding: 0.65rem 1rem; }
  .page-wrapper { padding: 1.5rem 1rem; }
  .hero { min-height: 80vh; padding: 3rem 1rem; }
  .hero-stats { gap: 2rem; }
}
