/* /learn-japanese — static, fast pages in the I Love Kanji look (no framework CSS). */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --line: #e5e5e5;
  --text: #171717;
  --muted: #737373;
  --faint: #737373;
  --accent: #ff5b61;
  --accent-soft: #fff0f1;
  --accent-ink: #d63a41;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --bad: #e11d48;
  --bad-soft: #fff1f2;
  --radius: 22px;
  --jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
[lang="ja"], .jp { font-family: var(--jp); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(250, 250, 250, 0.88); backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid rgba(229, 229, 229, 0.8); }
.site-header .bar { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.site-nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { color: var(--muted); font-size: 0.875rem; font-weight: 600; padding: 6px 10px; border-radius: 12px; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); background: #f0f0f0; text-decoration: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 18px; border-radius: 16px; font-weight: 700; font-size: 0.95rem; border: 1px solid transparent; cursor: pointer; white-space: nowrap; font-family: inherit; }
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px -8px rgba(255, 91, 97, 0.7); }
.btn-outline { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-sm { height: 36px; padding: 0 14px; border-radius: 12px; font-size: 0.85rem; }
@media (max-width: 720px) {
  .site-header .bar { flex-wrap: wrap; height: auto; padding: 10px 0 6px; row-gap: 6px; }
  .site-nav { order: 3; flex-basis: 100%; }
  .site-header .cta-start { margin-left: auto; }
}

/* Breadcrumbs */
.crumbs { font-size: 0.8rem; color: var(--muted); margin: 18px 0 6px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: #a3a3a3; }
.crumbs a { color: var(--muted); }

/* Typography */
main { padding-bottom: 48px; }
.wrap > main:first-child { padding-top: 22px; } /* pages without breadcrumbs */
h1 { font-size: clamp(1.8rem, 4.6vw, 2.6rem); line-height: 1.12; letter-spacing: -0.025em; margin: 8px 0 12px; }
h2 { font-size: 1.35rem; letter-spacing: -0.015em; margin: 36px 0 12px; line-height: 1.25; }
h3 { font-size: 1.05rem; margin: 22px 0 8px; }
p { margin: 0 0 14px; }
.lead { font-size: 1.1rem; color: #404040; }
.answer { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 16px; padding: 16px 18px; margin: 14px 0 22px; }
.answer p:last-child { margin-bottom: 0; }
.kicker { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.75rem; font-weight: 700; }
ul.clean, ol.clean { padding-left: 1.2em; }
li { margin: 4px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.updated { font-size: 0.8rem; color: var(--faint); }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.tile:hover { border-color: #d4d4d4; transform: translateY(-1px); text-decoration: none; }
.tile strong { display: block; font-size: 1rem; }
.tile span { display: block; color: var(--muted); font-size: 0.875rem; margin-top: 2px; }
.tile .emoji { font-family: var(--jp); font-size: 1.6rem; color: var(--accent); line-height: 1; margin-bottom: 8px; }

/* CTA */
.cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; background: linear-gradient(135deg, #fff 0%, var(--accent-soft) 100%); border: 1px solid #ffd6d8; border-radius: var(--radius); padding: 18px 20px; margin: 30px 0; }
.cta strong { display: block; font-size: 1.05rem; }
.cta span { color: var(--muted); font-size: 0.9rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; background: #fcfcfc; }
tr:last-child td, tr:last-child th { border-bottom: 0; }
th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.92rem; font-weight: 600; color: var(--text); background: transparent; }
td .jp, td[lang="ja"] { font-size: 1.05rem; }

/* Entry pages */
.entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 24px; margin: 6px 0 10px; }
.big-jp { font-family: var(--jp); font-size: clamp(3.2rem, 12vw, 5rem); line-height: 1.05; font-weight: 500; }
.reading { font-family: var(--jp); font-size: 1.25rem; color: #404040; }
.romaji { font-family: var(--mono); color: var(--muted); font-size: 0.95rem; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: #f0f0f0; color: #404040; font-size: 0.78rem; font-weight: 600; }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.fact dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); font-weight: 700; }
.fact dd { margin: 2px 0 0; font-weight: 600; }
.senses { padding-left: 1.3em; }
.senses li { margin: 6px 0; }
.example { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 8px 0; }
.example .ja { font-family: var(--jp); font-size: 1.1rem; }
.example .en { color: var(--muted); font-size: 0.92rem; }
.example .src { font-size: 0.7rem; color: var(--faint); }
.word-list { display: flex; flex-wrap: wrap; gap: 8px; }
.word-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 0.9rem; }
.word-chip:hover { border-color: var(--accent); text-decoration: none; }
.word-chip b { font-family: var(--jp); font-weight: 600; font-size: 1.05rem; }
.word-chip i { font-style: normal; color: var(--muted); font-size: 0.8rem; }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.kanji-grid a { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px; font-family: var(--jp); font-size: 1.6rem; color: var(--text); }
.kanji-grid a:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }

/* Stroke order */
.strokes { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.stroke-anim { width: 200px; height: 200px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
.stroke-anim path { fill: none; stroke: var(--text); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.stroke-anim .grid-line { stroke: #eee; stroke-width: 0.6; stroke-dasharray: 2 2; }
/* Hidden until its turn: a zero-length dash would still paint the round line caps as dots */
.stroke-anim.animate path.s { stroke-dasharray: var(--len); animation: draw var(--dur) linear var(--delay) both; }
@keyframes draw { 0% { stroke-dashoffset: var(--len); opacity: 0; } 0.1% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }
.stroke-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.stroke-steps svg { width: 64px; height: 64px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.stroke-steps path { fill: none; stroke: #d4d4d4; stroke-width: 4; stroke-linecap: round; }
.stroke-steps path.on { stroke: var(--text); }
.stroke-steps path.now { stroke: var(--accent); }
.stroke-num { font-size: 7px; fill: var(--accent); font-family: var(--mono); }
@media (prefers-reduced-motion: reduce) { .stroke-anim.animate path.s { animation: none; stroke-dashoffset: 0; } }

/* Tools */
.tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0 22px; }
.field { width: 100%; height: 52px; padding: 0 16px; border-radius: 16px; border: 2px solid #d4d4d4; background: #fff; font: inherit; font-size: 1.05rem; color: var(--text); outline: none; transition: border-color 0.15s; }
.field:focus { border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: #f0f0f0; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 10px; font: inherit; font-size: 0.85rem; font-weight: 600; color: #525252; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.results { margin-top: 12px; display: grid; gap: 6px; }
.result { display: flex; gap: 12px; align-items: baseline; padding: 10px 12px; border-radius: 14px; border: 1px solid #f0f0f0; color: var(--text); }
.result:hover { border-color: var(--accent); text-decoration: none; }
.result b { font-family: var(--jp); font-size: 1.15rem; font-weight: 600; min-width: 4.5em; }
.result .r { font-family: var(--jp); color: var(--muted); font-size: 0.9rem; }
.result .m { color: #404040; font-size: 0.9rem; flex: 1; }
.result .lvl { font-size: 0.7rem; color: var(--faint); font-family: var(--mono); }
.quiz-q { font-family: var(--jp); font-size: clamp(3rem, 14vw, 4.5rem); text-align: center; margin: 10px 0 6px; line-height: 1.2; }
.quiz-sub { text-align: center; color: var(--muted); min-height: 1.6em; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.choice { min-height: 48px; padding: 8px 12px; border-radius: 16px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 0.95rem; color: var(--text); cursor: pointer; text-align: center; }
.choice:hover { border-color: #bdbdbd; }
.choice.right { background: var(--ok-soft); border-color: #6ee7b7; color: #065f46; }
.choice.wrong { background: var(--bad-soft); border-color: #fda4af; color: #9f1239; }
.score { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.flashcard { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 20px; border: 1px solid var(--line); background: #fff; cursor: pointer; padding: 18px; text-align: center; user-select: none; }
.kana-chart { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.kana-chart div { background: #fff; border: 1px solid var(--line); border-radius: 12px; text-align: center; padding: 6px 2px; }
.kana-chart b { display: block; font-family: var(--jp); font-size: 1.5rem; font-weight: 500; }
.kana-chart span { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.kana-chart .empty { visibility: hidden; }
.conj td:first-child { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.feedback-ok { color: var(--ok); font-weight: 700; }
.feedback-bad { color: var(--bad); font-weight: 700; }
noscript .card, .js-note { font-size: 0.85rem; color: var(--muted); }

/* FAQ */
details { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; margin: 8px 0; }
summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: 8px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 28px 0 36px; font-size: 0.875rem; }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
.site-footer h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 0 0 8px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 5px 0; }
.site-footer a { color: #525252; }
.site-footer .legal { margin-top: 22px; color: var(--faint); font-size: 0.78rem; }

/* Links inside running text are underlined, not only coloured (colour-blind readers) */
main p a, main li a, .answer a, .legal a, .crumbs a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
