/* Paper and ink: mockup #1 (docs/mockups/mockup-1-paper-ink.png). */
:root {
  --paper: #FAF6EE;
  --ink: #1E1E1E;
  --umber: #5A554C;
  --vermilion: #C0392B;
  --card: #FFFDF8;
  --tint: rgba(192, 57, 43, 0.13);
  --mincho: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --serif: 'Lora', Baskerville, Georgia, serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--mincho);
  /* A faint fibre grain, so it reads as paper rather than a flat fill. */
  background:
    radial-gradient(circle at 20% 30%, rgba(90, 85, 76, 0.035) 0 1px, transparent 2px) 0 0 / 23px 29px,
    radial-gradient(circle at 70% 60%, rgba(90, 85, 76, 0.03) 0 1px, transparent 2px) 0 0 / 31px 17px,
    var(--paper);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 2.5rem) 1.5rem calc(env(safe-area-inset-bottom, 0px) + 4rem);
}

header h1 {
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}

#sub {
  font-family: var(--serif);
  color: var(--umber);
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
}

#lesson {
  margin-top: 2.5rem;
  font-size: 1.75rem;
  /* Room for the ruby line is reserved, so revealing it doesn't move text. */
  line-height: 2.5;
}

#lesson p, #task-text p { margin: 0 0 0.6em; }

.w {
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.15s;
}
.w.on { background: var(--tint); }
.w.open { background: var(--tint); box-shadow: 0 2px 0 var(--vermilion); }

ruby { ruby-position: over; }
rt {
  font-size: 0.42em;
  color: var(--vermilion);
  visibility: hidden;
  letter-spacing: 0.04em;
}
.w.on rt { visibility: visible; }

#task {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(90, 85, 76, 0.25);
}
#task h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--umber);
  font-size: 0.95rem;
  margin: 0 0 0.3rem;
}
#task-text { font-size: 1.35rem; line-height: 2.4; }

#error { font-family: var(--serif); color: var(--vermilion); }

/* The meaning card: a sheet of rice paper laid over the page. */
#card {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  max-width: 32rem;
  margin: 0 auto;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 4px;
  padding: 1.1rem 1.25rem 1.2rem;
  box-shadow: 0 1px 0 rgba(90, 85, 76, 0.18), 0 12px 32px rgba(30, 30, 30, 0.16);
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.kana { font-size: 1.6rem; }
#card-say {
  border: 1px solid rgba(90, 85, 76, 0.3);
  background: transparent;
  border-radius: 999px;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.1rem;
  cursor: pointer;
}
#card-say[hidden] { display: none; }
.base { margin: 0.1rem 0 0; color: var(--umber); font-size: 1rem; }
.base:empty { display: none; }
.pos {
  font-family: var(--serif);
  font-style: italic;
  color: var(--umber);
  font-size: 0.85rem;
  margin: 0.3rem 0 0;
}
.senses {
  font-family: var(--serif);
  margin: 0.5rem 0 0;
  padding-left: 1.3rem;
  font-size: 1rem;
  line-height: 1.5;
}
.senses:has(> li:only-child) { list-style: none; padding-left: 0; }

.kanji:not(:empty) {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px dashed rgba(90, 85, 76, 0.3);
  display: grid;
  gap: 0.9rem;
}
.kj { display: grid; grid-template-columns: 3rem 1fr; column-gap: 0.8rem; align-items: start; }
.kj-char { font-size: 2.4rem; line-height: 1; color: var(--ink); }
.kj-body { font-family: var(--serif); font-size: 0.92rem; line-height: 1.45; }
.kj-mean { font-weight: 600; }
.kj-read { font-family: var(--mincho); color: var(--umber); }
.kj-parts { color: var(--umber); }
.kj-parts b { font-family: var(--mincho); font-weight: 400; color: var(--ink); font-size: 1.1em; }
.kj-hook { font-style: italic; margin-top: 0.15rem; }

/* Stats: calm counts, no streaks. */
header { position: relative; }
.nav {
  position: absolute;
  right: 0;
  top: 0.4rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--umber);
  text-decoration: none;
  font-size: 0.95rem;
}
#stats .nav { position: static; display: inline-block; margin-bottom: 1rem; }
.nav a { color: inherit; text-decoration: none; }
nav.nav { display: flex; gap: 1rem; }
.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--vermilion);
  cursor: pointer;
}
.push-row { font-family: var(--serif); color: var(--umber); margin: 0; }
#stats-body { font-family: var(--serif); margin-top: 1.5rem; }
.stats-line { font-size: 1.1rem; }
.quiet { color: var(--umber); font-style: italic; }
#stats h3 { font-weight: 400; font-style: italic; color: var(--umber); font-size: 0.95rem; margin: 1.8rem 0 0.6rem; }
.kanji-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  background: var(--card);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  box-shadow: 0 1px 0 rgba(90, 85, 76, 0.18);
}
.chip-k { font-family: var(--mincho); font-size: 1.6rem; }
.chip-n { color: var(--vermilion); font-size: 0.85rem; }
.word-list { list-style: none; padding: 0; margin: 0; }
.word-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed rgba(90, 85, 76, 0.25);
}
.wl-word { font-family: var(--mincho); font-size: 1.35rem; }
.wl-what { color: var(--umber); font-size: 0.9rem; font-style: italic; }

/* Replying to the task: the learner's answer, then the tutor's note. */
#reply { margin-top: 1rem; }
#replies { list-style: none; padding: 0; margin: 0; }
#replies li { margin-bottom: 1rem; }
.mine { font-size: 1.15rem; line-height: 1.8; }
.note {
  white-space: pre-wrap;
  background: var(--card);
  border-left: 3px solid var(--vermilion);
  padding: 0.6rem 0.8rem;
  margin-top: 0.4rem;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.6;
}
#reply-text {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1.6;
  background: var(--card);
  color: var(--ink);
  border: 1px solid rgba(90, 85, 76, 0.3);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  resize: vertical;
}
.reply-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4rem; gap: 1rem; }
#reply-status { font-family: var(--serif); font-style: italic; color: var(--umber); font-size: 0.9rem; }
#reply-send {
  font-family: var(--serif);
  font-size: 1rem;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
}
#reply-send:disabled { opacity: 0.5; }
