/* jlptn5 — there is deliberately no shared stylesheet, since each app is its
   own Docker build context. Keep --paper/--paper-2/--card/--ink/--ink-soft/
   --line in sync with apps/main/site/index.html. */

:root {
  color-scheme: light;

  --paper: #faf7f2;
  --paper-2: #f2ede4;
  --card: #ffffff;
  --ink: #24211c;
  --ink-soft: #6b6459;
  --line: #e6ddd0;

  /* Crimson is the app accent; indigo belongs to kana. */
  --crimson: #c0392b;  --crimson-dark: #8e2a20;
  --indigo: #5b57d9;   --indigo-dark: #3f3bb3;
  --teal: #12a594;     --teal-dark: #0b7d70;
  --amber: #e08b2f;    --amber-dark: #b8651a;
  --plum: #8e44ad;     --plum-dark: #6b2d85;

  --ok: #6aaa64;
  --bad: #d64545;

  /* Accents as *text* need more lift on a dark surface than accents as *fill*
     do, so the two are separate. The input borders keep using --ok / --bad. */
  --crimson-text: var(--crimson-dark);
  --ok-text: #4a8a44;
  --bad-text: var(--bad);

  /* Translucent tints take a bare triplet so rgba() can follow the theme —
     hardcoding the RGB inline is what leaves a tint stuck at light values. */
  --crimson-rgb: 192, 57, 43;
  --ok-rgb: 106, 170, 100;
  --bad-rgb: 214, 69, 69;
  --shadow-rgb: 36, 33, 28;

  --card-ring: 0 0 #0000;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: #16130f;
  --paper-2: #262119;
  --card: #1e1a15;
  --ink: #f2ede4;
  --ink-soft: #a79d8e;
  --line: #38312a;

  --crimson-text: #f08b7e;
  --ok-text: #8bc784;
  --bad-text: #e86a6a;

  --crimson-rgb: 240, 139, 126;
  --ok-rgb: 139, 199, 132;
  --bad-rgb: 232, 106, 106;
  --shadow-rgb: 0, 0, 0;

  /* A hairline keeps every tile readable against the dark page. */
  --card-ring: 0 0 0 1px var(--line);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over the display rules below — screens are
   switched by toggling it, and an author `display` otherwise beats the UA
   default (the same lesson as in the amr, rordle and kana apps). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* Japanese needs its own stack, and the sans-serif fallback would otherwise
   pick a Chinese font on some systems. No web font — nothing here may make an
   external request. */
.jp, .prompt, .choice, [lang="ja"] {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium",
    "Yu Gothic", "Noto Sans JP", Meiryo, "MS PGothic", sans-serif;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.4rem 1.25rem 1.5rem;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.brand { text-decoration: none; color: inherit; }
.brand h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
.brand p { margin: 0.1rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.theme-btn {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  display: grid; place-items: center;
  cursor: pointer;
}
.theme-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: block; }

main { flex: 1; }
h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em;
     color: var(--ink-soft); margin: 1.8rem 0 0.7rem; font-weight: 600; }
h2:first-child { margin-top: 0; }

/* ---------- tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.8rem;
}

.tile {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 108px;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(155deg, var(--crimson), var(--crimson-dark));
  --glow: rgba(192, 57, 43, 0.45);
  box-shadow: var(--card-ring), 0 1px 2px rgba(var(--shadow-rgb), 0.08);
  transition: transform 0.15s, box-shadow 0.15s;
}
.tile:hover { transform: translateY(-4px);
              box-shadow: var(--card-ring), 0 16px 32px -12px var(--glow); }
.tile .name { font-weight: 600; font-size: 1.05rem; }
.tile .desc { font-size: 0.8rem; opacity: 0.9; margin-top: 0.15rem; }
.tile .meta { margin-top: auto; font-size: 0.72rem; opacity: 0.85;
              padding-top: 0.5rem; }
.tile .glyph {
  position: absolute; right: 0.5rem; bottom: -0.9rem;
  font-size: 3.6rem; opacity: 0.17; line-height: 1; pointer-events: none;
}
.tile.kata  { background: linear-gradient(155deg, var(--indigo), var(--indigo-dark));
              --glow: rgba(91, 87, 217, 0.45); }
.tile.kanji { background: linear-gradient(155deg, var(--crimson), var(--crimson-dark)); }
.tile.gram  { background: linear-gradient(155deg, var(--teal), var(--teal-dark));
              --glow: rgba(18, 165, 148, 0.45); }
.tile.vocab { background: linear-gradient(155deg, var(--amber), var(--amber-dark));
              --glow: rgba(224, 139, 47, 0.45); }
.tile.adj   { background: linear-gradient(155deg, var(--plum), var(--plum-dark));
              --glow: rgba(142, 68, 173, 0.45); }
.tile.exam  { background: linear-gradient(155deg, #445, #223);
              --glow: rgba(68, 68, 85, 0.5); }

/* ---------- drill ---------- */

.drill-bar {
  display: flex; align-items: center; gap: 0.8rem;
  margin-bottom: 1.4rem; min-height: 26px;
}
.back { color: var(--ink-soft); text-decoration: none; font-size: 0.85rem; }
.back:hover { color: var(--ink); }
.drill-name { font-size: 0.85rem; color: var(--ink-soft); margin-left: auto; }
.score { font-variant-numeric: tabular-nums; font-size: 0.85rem;
         color: var(--ink-soft); }
.score .streak { color: var(--crimson-text); font-weight: 600; }

.prompt {
  text-align: center;
  font-size: clamp(2.8rem, 13vw, 4.4rem);
  line-height: 1.25;
  margin: 1.2rem 0 0.4rem;
  word-break: break-word;
}
.prompt.kana { font-size: clamp(3.4rem, 17vw, 5.4rem); }
.prompt.sentence { font-size: clamp(1.3rem, 5.5vw, 1.9rem); line-height: 1.7; }
.prompt .blank { color: var(--crimson-text); border-bottom: 3px solid currentColor;
                 padding: 0 0.5em; }
.prompt-sub { text-align: center; color: var(--ink-soft); font-size: 0.95rem;
              margin-bottom: 0.6rem; }

.answer {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.15rem;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-align: center;
}
.answer:focus { outline: none; border-color: var(--ink-soft); }
.answer.ok  { border-color: var(--ok);  background: rgba(var(--ok-rgb), 0.12); }
.answer.bad { border-color: var(--bad); background: rgba(var(--bad-rgb), 0.1);
              animation: shake 0.3s; }

.choices { display: grid; gap: 0.6rem; grid-template-columns: 1fr 1fr; }
.choice {
  padding: 0.9rem 0.7rem;
  font-size: 1.4rem;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.choice:hover:not([disabled]) { border-color: var(--ink-soft); }
.choice.ok  { border-color: var(--ok);  background: rgba(var(--ok-rgb), 0.14); }
.choice.bad { border-color: var(--bad); background: rgba(var(--bad-rgb), 0.12);
              animation: shake 0.3s; }
.choice[disabled] { cursor: default; opacity: 0.75; }
.choice.ok[disabled], .choice.bad[disabled] { opacity: 1; }

.feedback {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(var(--bad-rgb), 0.4);
  background: rgba(var(--bad-rgb), 0.06);
  animation: rise 0.18s ease-out;
}
.feedback.correct { border-color: rgba(var(--ok-rgb), 0.5);
                    background: rgba(var(--ok-rgb), 0.07); }
.feedback .romaji { font-size: 1.15rem; font-weight: 600; }
.feedback .kana { color: var(--ink-soft); }
.feedback .meaning { color: var(--ink-soft); font-size: 0.9rem; }
.feedback .note { color: var(--ink-soft); font-size: 0.85rem; margin-top: 0.3rem; }
.feedback .why { font-size: 0.85rem; margin-top: 0.4rem; }
.feedback .group {
  display: inline-block; margin-top: 0.45rem;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--crimson-text); border: 1px solid rgba(var(--crimson-rgb), 0.35);
  border-radius: 999px; padding: 0.1rem 0.55rem;
}
.feedback em { font-style: normal; text-decoration: underline;
               text-decoration-color: var(--crimson-text);
               text-underline-offset: 3px; }

.drill-actions, .grade { margin-top: 1rem; display: flex; gap: 0.6rem; }
.grade { display: grid; grid-template-columns: 1fr 1fr; }

.btn {
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.92rem;
  cursor: pointer;
}
.btn:hover:not([disabled]) { border-color: var(--ink-soft); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn.good { border-color: rgba(var(--ok-rgb), 0.55); color: var(--ok-text); }
.btn.bad  { border-color: rgba(var(--bad-rgb), 0.5); color: var(--bad-text); }
.btn.primary { background: var(--crimson); border-color: var(--crimson);
               color: #fff; }

.tip { color: var(--ink-soft); font-size: 0.82rem; margin-top: 1.2rem; }

/* ---------- dashboard ---------- */

.week-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.week-head .w { font-size: 1.2rem; font-weight: 600; }
.week-head .dates { color: var(--ink-soft); font-size: 0.85rem; }

.rail { display: flex; gap: 5px; margin: 0.7rem 0 1.2rem; }
.rail span {
  flex: 1; height: 6px; border-radius: 3px; background: var(--line);
}
.rail span.done { background: rgba(var(--crimson-rgb), 0.45); }
.rail span.now  { background: var(--crimson); }

.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--line);
}
.tasks li:last-child { border-bottom: 0; }
.tasks input { margin-top: 0.35rem; accent-color: var(--crimson); flex: none; }
.tasks label { flex: 1; cursor: pointer; font-size: 0.92rem; }
.tasks li.done label { color: var(--ink-soft); text-decoration: line-through; }
.tasks a.jump { font-size: 0.75rem; color: var(--crimson-text);
                text-decoration: none; border: 1px solid rgba(var(--crimson-rgb), 0.35);
                border-radius: 999px; padding: 0.05rem 0.5rem; flex: none; }

.bars { display: grid; gap: 0.55rem; }
.bar { display: grid; grid-template-columns: 6.5rem 1fr 4.2rem; gap: 0.7rem;
       align-items: center; font-size: 0.85rem; }
.bar .track { height: 8px; border-radius: 4px; background: var(--paper-2);
              overflow: hidden; }
.bar .fill { height: 100%; background: var(--crimson); border-radius: 4px; }
.bar .num { color: var(--ink-soft); text-align: right;
            font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.bar a { color: inherit; text-decoration: none; }
.bar a:hover { color: var(--crimson-text); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
         gap: 0.7rem; }
.stat {
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  padding: 0.8rem 0.9rem; text-decoration: none; color: inherit;
  box-shadow: var(--card-ring);
}
.stat:hover { border-color: var(--ink-soft); }
.stat .big { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.stat .lab { font-size: 0.78rem; color: var(--ink-soft); }

/* ---------- schedule & log ---------- */

.week {
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  padding: 0.9rem 1rem; margin-bottom: 0.7rem; box-shadow: var(--card-ring);
}
.week.now { border-color: rgba(var(--crimson-rgb), 0.5); }
.week h3 { margin: 0 0 0.2rem; font-size: 0.98rem; }
.week .dates { color: var(--ink-soft); font-size: 0.8rem; }
.week .target { color: var(--ink-soft); font-size: 0.8rem; margin-top: 0.5rem; }

.grid-form { display: grid; gap: 0.5rem; grid-template-columns: 1fr 1fr; }
.grid-form .full { grid-column: 1 / -1; }
input[type="text"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 0.9rem; font-family: inherit;
}
.rows { margin-top: 0.9rem; display: grid; gap: 0.5rem; }
.row {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  padding: 0.6rem 0.8rem; font-size: 0.87rem; box-shadow: var(--card-ring);
}
.row .head { display: flex; gap: 0.6rem; align-items: baseline; }
.row .when { color: var(--ink-soft); font-size: 0.78rem; }
.row .del { margin-left: auto; background: none; border: 0; cursor: pointer;
            color: var(--ink-soft); font-size: 0.78rem; padding: 0; }
.row .del:hover, .row .del.armed { color: var(--bad-text); }
.row .sub { color: var(--ink-soft); font-size: 0.8rem; }

.mock { display: grid; grid-template-columns: 1fr 5rem 5rem 4.5rem; gap: 0.5rem;
        align-items: center; margin-bottom: 0.45rem; font-size: 0.85rem; }
.mock .verdict { font-size: 0.8rem; text-align: right; }
.mock .pass { color: var(--ok-text); }
.mock .fail { color: var(--bad-text); }

footer {
  margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line);
  display: flex; gap: 1.2rem;
}
footer a { color: var(--ink-soft); text-decoration: none; font-size: 0.82rem; }
footer a:hover { color: var(--ink); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 480px) {
  .wrap { padding: 1.6rem 1rem 1.2rem; }
  .tiles { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 5.5rem 1fr 3.6rem; }
  .grid-form { grid-template-columns: 1fr; }
  .mock { grid-template-columns: 1fr 4.2rem 4.2rem; }
  .mock .verdict { grid-column: 1 / -1; text-align: left; }
}

/* card mode: the hidden half is a Japanese sentence or phrase, so it needs
   room and its own size — the romaji line above it is for typed drills. */
.feedback .back {
  font-size: 1.35rem;
  line-height: 1.6;
  margin-bottom: 0.2rem;
}
