/* ============================================================
   KaraS Typing — style.css
   ダークテーマ / カラス(KaraS)モチーフ
   ============================================================ */

/* Stenodisplay フォント（キー図表示用・SIL OFL 1.1 / Kaoffie作） */
@font-face {
  font-family: 'Stenodisplay';
  src: url('/fonts/Stenodisplay-Classic.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg: #0f1014;
  --bg-soft: #14161c;
  --panel: #191b23;
  --panel-2: #1f2230;
  --border: #2a2d3a;
  --text: #e9e9ef;
  --text-dim: #9a9cae;
  --text-faint: #5f6172;
  --accent: #8c7bff;
  --accent-soft: #8c7bff33;
  --ok: #58d68d;
  --err: #f26d6d;
  --warn: #f2c94c;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}
.logo-accent { color: var(--accent); margin-left: 6px; }

.top-nav { display: flex; gap: 4px; flex: 1; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-btn:hover { color: var(--text); background: var(--panel); }

.auth-area { display: flex; align-items: center; gap: 10px; }

#user-badge {
  font-size: 13px;
  color: var(--accent);
  font-family: var(--mono);
}
#user-badge::before { content: "@"; opacity: 0.6; }

/* ---------- buttons ---------- */

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: filter .15s, background .15s;
}
.btn-primary {
  background: var(--accent);
  color: #12101f;
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- layout ---------- */

main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; }

.view { display: none; }
.view.active { display: block; }

.section-title {
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 1px;
  margin: 28px 0 12px;
}

.hidden { display: none !important; }

/* ---------- home ---------- */

.hero { padding: 18px 0 6px; }
.hero h1 {
  font-family: var(--mono);
  font-size: 34px;
  margin: 0 0 8px;
  letter-spacing: 1px;
}
.hero-sub { color: var(--text-dim); margin: 0; font-size: 14px; }
.hero-sub b { color: var(--accent); }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.lesson-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.lesson-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.lesson-card-random {
  border-color: #4a4270;
  background: linear-gradient(160deg, #191b23 0%, #201c33 100%);
}
.lesson-card-random:hover { border-color: var(--accent); }
.lesson-card h3 { margin: 0 0 6px; font-size: 15px; }
.lesson-card .lesson-meta { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }
.lesson-card .lesson-sample {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- practice ---------- */

.practice-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}
.p-lesson { font-weight: 700; }
.p-progress { color: var(--text-faint); font-family: var(--mono); margin-left: 10px; font-size: 14px; }
.timer { font-family: var(--mono); color: var(--text-dim); }

.problem-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 26px 30px;
  text-align: center;
  min-height: 190px;
}

.strokes {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  min-height: 24px;
}
.stroke-unit {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-faint);
  padding: 5px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.stroke-fig {
  font-family: 'Stenodisplay', var(--mono);
  font-size: 60px;
  line-height: 1;
  color: #c9cbd8;
}
.stroke-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.stroke-unit.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.stroke-unit.current .stroke-fig { color: #b9aaff; }
.stroke-unit.current .stroke-name { color: var(--accent); }
.stroke-unit.done {
  border-color: rgba(88, 214, 141, 0.35);
  background: rgba(88, 214, 141, 0.07);
}
.stroke-unit.done .stroke-fig { color: var(--ok); opacity: .85; }
.stroke-unit.done .stroke-name { color: var(--ok); opacity: .7; }

.kana-line {
  font-size: 40px;
  letter-spacing: 4px;
  margin-bottom: 10px;
  min-height: 52px;
}
.kana-unit { color: var(--text); }
.kana-unit.todo { color: var(--text-dim); }
.kana-unit.current { color: #fff; border-bottom: 3px solid var(--accent); }
.kana-unit.done { color: var(--ok); }
.kana-unit.err { color: var(--err); border-bottom: 3px solid var(--err); }

.practice-right { display: flex; align-items: center; gap: 12px; }

.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.mode-tab {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.mode-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.stats-row {
  display: flex;
  gap: 28px;
  justify-content: center;
  margin: 20px 0 16px;
}
.stat { display: flex; align-items: baseline; gap: 7px; }
.stat-label { font-size: 12px; color: var(--text-faint); }
.stat-val { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.stat-unit { font-size: 11px; color: var(--text-faint); }

/* input catcher */
.type-catcher {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  cursor: text;
}
.type-catcher.focused { border-color: var(--accent); border-style: solid; }
.type-catcher.error-flash { animation: flash-err .25s; }
@keyframes flash-err {
  0% { background: #f26d6d22; }
  100% { background: transparent; }
}
#type-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: text;
  font-size: 20px;
  border: none;
  background: transparent;
  color: transparent;
}
.type-hint { color: var(--text-faint); font-size: 13px; user-select: none; }

.practice-bottom {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}

/* ---------- result ---------- */

.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
}
.result-lesson { font-weight: 700; font-size: 17px; margin-bottom: 20px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.result-item { text-align: center; background: var(--panel-2); border-radius: 10px; padding: 12px 6px; }
.result-val { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--accent); }
.result-label { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.result-items { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; }
.result-items .ri { display: flex; justify-content: space-between; padding: 5px 4px; border-bottom: 1px solid var(--border); font-family: var(--mono); }
.result-items .ri .ri-text { opacity: .9; }
.result-items .ri.miss .ri-text { color: var(--err); }
.result-items .ri .ri-note { color: var(--text-faint); font-size: 12px; }

.result-actions { display: flex; align-items: center; gap: 12px; }
.save-state { font-size: 12px; color: var(--text-faint); }

/* ---------- records ---------- */

.records-note { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }

.records-wrap { overflow-x: auto; }
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.records-table th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.records-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  white-space: nowrap;
}
.records-table td.lesson-cell { font-family: inherit; }
.records-empty { color: var(--text-faint); padding: 30px 10px; text-align: center; }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #000000aa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-narrow { max-width: 380px; }
.modal h3 { margin: 0 0 6px; }
.modal-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 18px; }

/* ---------- help page ---------- */

.help-intro h3 { margin: 0 0 12px; font-size: 15px; color: var(--accent); }
.help-example-row {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 22px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.help-example-text p { margin: 0 0 6px; font-size: 14px; }
.help-example-text .dim { font-size: 13px; margin-bottom: 0; }

.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.key-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px 8px;
  text-align: center;
}
.key-fig {
  font-family: 'Stenodisplay', var(--mono);
  font-size: 40px;
  line-height: 1.1;
  color: #c9cbd8;
  display: block;
}
.key-fig-lg {
  font-family: 'Stenodisplay', var(--mono);
  font-size: 56px;
  line-height: 1.1;
  color: #c9cbd8;
  display: block;
}
.key-label { display: block; font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.help-h { font-size: 15px; color: var(--accent); margin: 28px 0 12px; }

.help-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; margin-bottom: 8px; }
.help-table th { text-align: left; color: var(--text-faint); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.help-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.help-table td:nth-child(2) { color: var(--accent); }
.help-table td:nth-child(3) { color: var(--text-dim); font-family: inherit; font-size: 12px; }
.help-note { font-size: 12px; color: var(--text-dim); margin: 8px 0 0; line-height: 1.7; }
.dim { color: var(--text-dim); }

/* ---------- landing ---------- */

.landing-hero { padding: 26px 0 30px; }
.landing-title {
  font-size: 54px;
  margin: 0 0 10px;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #fff 35%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-sub { font-size: 17px; font-weight: 600; margin: 0 0 14px; }
.landing-desc { font-size: 14px; color: var(--text-dim); line-height: 1.8; max-width: 660px; margin: 0 0 22px; }
.landing-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.landing-cta-note { font-size: 12px; color: var(--text-faint); margin: 0; }

.landing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.landing-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.landing-card h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
.landing-card p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.landing-card b { color: var(--text); font-family: var(--mono); font-size: 12px; }

.landing-steps { margin: 0 0 14px; padding-left: 22px; }
.landing-steps li { margin-bottom: 10px; font-size: 14px; line-height: 1.6; }
.landing-steps .dim { font-size: 13px; }
.landing-steps a, .landing-hero a { color: var(--accent); }

/* ---------- qwerty experience ---------- */

.qwerty-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.qwerty-keys { display: flex; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.qwerty-pressed { font-size: 13px; color: var(--text-dim); }
.qwerty-pressed b { color: var(--accent); font-family: var(--mono); }

body.qwerty-mode .type-catcher { display: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  animation: toast-in .2s;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .site-header { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .top-nav { order: 3; flex-basis: 100%; }
  main { padding: 18px 14px 50px; }
  .hero h1 { font-size: 26px; }
  .kana-line { font-size: 30px; }
  .problem-card { padding: 24px 14px; }
  .result-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-row { gap: 16px; }
}
