/* ──────────────────────────────────────────────
   Language Learning Curve — Japanese Edition
   Dark theme · Crimson accent · Clean modern UI
   ────────────────────────────────────────────── */

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:       #c0392b;
  --red-dark:  #96281b;
  --red-glow:  rgba(192,57,43,0.25);
  --red-faint: rgba(192,57,43,0.08);
  --bg:        #0d0d0f;
  --surface:   #141418;
  --surface2:  #1c1c22;
  --surface3:  #252530;
  --border:    rgba(255,255,255,0.07);
  --text:      #e8e8f0;
  --text-2:    #9999aa;
  --text-3:    #666677;
  --green:     #27ae60;
  --blue:      #2980b9;
  --gold:      #f39c12;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --font:      'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* ─── HEADER ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,13,15,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.logo-sub {
  font-size: 0.75rem;
  color: var(--red);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--red-faint);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(192,57,43,0.2);
}

/* ─── MAIN LAYOUT ─── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ─── INPUT SECTION ─── */
.input-section {
  padding: 60px 0 40px;
}
.section-title-wrap {
  text-align: center;
  margin-bottom: 48px;
}
.section-title-wrap h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.section-title-wrap h1 em {
  font-style: normal;
  color: var(--red);
}
.subtitle {
  color: var(--text-2);
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ─── FORM ─── */
.input-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group > label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-group .icon {
  width: 16px;
  height: 16px;
  stroke: var(--red);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.form-group input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  padding: 12px 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font);
}
.form-group input[type="number"]:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}
.form-group input[type="number"]::placeholder { color: var(--text-3); font-weight: 400; font-size: 1rem; }

.hint {
  font-size: 0.78rem;
  color: var(--text-3);
  line-height: 1.4;
}

/* Sliders */
.slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface3);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--bg);
  box-shadow: 0 0 8px var(--red-glow);
  cursor: pointer;
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--bg);
  cursor: pointer;
}
output {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--red);
  font-family: var(--font);
}

/* Radio cards */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.radio-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 80px;
  user-select: none;
}
.radio-card:hover { border-color: rgba(192,57,43,0.4); background: var(--surface3); }
.radio-card input[type="radio"] { display: none; }
.radio-card:has(input:checked) {
  border-color: var(--red);
  background: var(--red-faint);
  box-shadow: 0 0 0 3px var(--red-glow);
}
.rc-label { font-size: 1rem; font-weight: 700; color: var(--text); }
.rc-sub   { font-size: 0.7rem; color: var(--text-3); }
.radio-card:has(input:checked) .rc-label { color: var(--red); }

/* Submit button */
.form-cta {
  margin-top: 32px;
  display: flex;
  justify-content: center;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 40px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
  font-family: var(--font);
  box-shadow: 0 4px 20px var(--red-glow);
}
.btn-primary svg {
  stroke: #fff;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-primary:hover {
  background: var(--red-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(192,57,43,0.4);
}
.btn-primary:active { transform: translateY(0); }

/* ─── DASHBOARD ─── */
.dashboard { padding: 20px 0 0; }
.dashboard.hidden { display: none; }

.dashboard-header {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 36px;
  padding: 28px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.level-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.level-label { font-size: 0.7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.level-badge {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--red);
  border: 3px solid var(--red);
  border-radius: 10px;
  padding: 4px 20px;
  line-height: 1;
  background: var(--red-faint);
}
.level-hint { font-size: 0.75rem; color: var(--text-2); text-align: center; max-width: 120px; }
.dashboard-headline h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.dashboard-headline p { color: var(--text-2); margin-top: 4px; }

/* ─── STAT CARDS ─── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  border-color: rgba(192,57,43,0.3);
  box-shadow: 0 0 0 1px rgba(192,57,43,0.1);
}
.stat-card.wide { grid-column: 1 / -1; }
.sc-icon {
  width: 32px;
  height: 32px;
  background: var(--red-faint);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.sc-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--red);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sc-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.sc-label {
  font-size: 0.75rem;
  color: var(--text-3);
  line-height: 1.3;
}
.sc-proj-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.sc-proj-row > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ─── CHART BLOCKS ─── */
.chart-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.chart-block-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.chart-icon {
  width: 52px;
  height: 52px;
  background: var(--red-faint);
  border: 1px solid rgba(192,57,43,0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chart-icon svg {
  stroke: var(--red);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-block-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.chart-subtitle { color: var(--text-2); font-size: 0.88rem; }

.chart-container {
  position: relative;
  height: 320px;
  margin-bottom: 20px;
}
.chart-container.tall { height: 400px; }

/* Donut */
.donut-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 340px;
}
.donut-center {
  display: none; /* centre text drawn directly on canvas via afterDraw plugin */
}
#donut-pct {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--text);
  display: block;
}
.donut-label { font-size: 0.75rem; color: var(--text-3); display: block; }

/* SR grid */
.sr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.sr-cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.sr-cell.lapse { border-color: rgba(231,76,60,0.4); background: rgba(231,76,60,0.06); }
.sr-review-num {
  font-size: 0.65rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}
.sr-day {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
}
.sr-day-label { font-size: 0.7rem; color: var(--text-3); margin-top: 2px; }
.sr-stab {
  font-size: 0.75rem;
  color: var(--text-2);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sr-decay-container { height: 200px; margin-top: 8px; }

/* ─── EXPLAINER ─── */
details.explainer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}
details.explainer summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  list-style: none;
  user-select: none;
  transition: color 0.2s;
}
details.explainer summary::-webkit-details-marker { display: none; }
details.explainer summary svg {
  stroke: var(--text-3);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.2s;
}
details.explainer summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--text-3);
  transition: transform 0.25s;
  display: inline-block;
}
details.explainer[open] summary::after { transform: rotate(180deg); }
details.explainer:hover summary { color: var(--text); }
details.explainer:hover summary svg { stroke: var(--red); }

.explainer-body {
  padding: 16px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.explainer-body p { font-size: 0.9rem; color: var(--text-2); line-height: 1.65; }
.explainer-body ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.explainer-body li { font-size: 0.9rem; color: var(--text-2); line-height: 1.5; }
.explainer-body strong { color: var(--text); }
.explainer-body code {
  font-family: var(--mono);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.85rem;
  color: #e2a96c;
}
.explainer-body code sup { font-size: 0.65rem; }

/* ─── FOOTER ─── */
footer {
  text-align: center;
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.78rem;
  line-height: 1.8;
}
footer a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--border); }
footer a:hover { color: var(--red); }

/* ─── ANIMATIONS ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dashboard:not(.hidden) {
  animation: fadeUp 0.5s ease forwards;
}
.chart-block {
  animation: fadeUp 0.4s ease both;
}
.chart-block:nth-child(1) { animation-delay: 0.05s; }
.chart-block:nth-child(2) { animation-delay: 0.1s; }
.chart-block:nth-child(3) { animation-delay: 0.15s; }
.chart-block:nth-child(4) { animation-delay: 0.2s; }
.chart-block:nth-child(5) { animation-delay: 0.25s; }

/* ─── RESPONSIVE ─── */
@media (max-width: 700px) {
  .input-form { padding: 24px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .chart-block { padding: 20px 16px; }
  .dashboard-header { flex-direction: column; gap: 16px; }
  .header-inner { flex-direction: column; gap: 8px; align-items: flex-start; }
  .chart-container { height: 240px; }
  .chart-container.tall { height: 300px; }
  .donut-container { height: 280px; }
  .sr-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .radio-group { gap: 8px; }
  .radio-card { padding: 10px 12px; min-width: 68px; }
}
