/* Learn Japanese — shared app shell.
   Loaded by index.html and by every module page. It only styles the shell
   chrome (app bar, menu, install button); each module keeps its own CSS. */

:root {
  --bg: #f5f0e8;
  --card: #fffcf5;
  --border: #d4cfc4;
  --ink: #2b2722;
  --ink-soft: #6b6459;
  --shell-h: 52px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* ---------- app bar injected into every module page ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--shell-h);
  padding: 0 calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  padding-top: var(--safe-t);
  box-sizing: content-box;
  background: rgba(255, 252, 245, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.appbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  height: 44px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  font: 600 13px/1 "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.appbar__back:hover,
.appbar__back:focus-visible {
  background: var(--bg);
}

.appbar__back svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.appbar__title {
  margin: 0;
  font: 600 14px/1.2 "Noto Sans JP", system-ui, sans-serif;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar__title span {
  color: var(--ink-soft);
  font-weight: 400;
  margin-left: 7px;
}

@media (max-width: 420px) {
  .appbar__back span { display: none; }
  .appbar__back { padding: 0 11px; }
}

/* ---------- main menu (index.html) ---------- */

.menu-page {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", system-ui, -apple-system, sans-serif;
  padding:
    calc(28px + var(--safe-t))
    calc(20px + var(--safe-r))
    calc(40px + var(--safe-b))
    calc(20px + var(--safe-l));
}

.menu-wrap {
  max-width: 900px;
  margin: 0 auto;
}

.menu-head {
  text-align: center;
  margin-bottom: 26px;
}

.menu-head h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.menu-head h1 .jp {
  display: block;
  font-size: 0.52em;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.menu-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.menu-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, var(--border));
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}

/* Hover feedback only latches on devices that actually have hover, so it
   cannot stick after a tap on touch; keyboard focus keeps a real outline. */
@media (hover: hover) {
  .tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  }
}

.tile:focus-visible {
  outline: 2px solid var(--accent, var(--ink));
  outline-offset: 2px;
}

.tile:active { transform: translateY(0); }

.tile__glyph {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
}

@supports not (background: color-mix(in srgb, red 10%, white)) {
  .tile__glyph { background: rgba(0, 0, 0, 0.05); }
}

.tile__body { min-width: 0; }

.tile__body h3 {
  margin: 0 0 3px;
  font-size: 16px;
  font-weight: 650;
}

.tile__body p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.menu-foot {
  margin-top: 30px;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.menu-foot a { color: inherit; }

/* ---------- app credit, injected by shell.js on every page ---------- */

.lj-shell-foot {
  padding: 0 calc(12px + var(--safe-r)) calc(16px + var(--safe-b)) calc(12px + var(--safe-l));
  box-sizing: border-box;
}

.lj-credit {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-soft);
  opacity: 0.85;
}

.lj-credit a {
  color: inherit;
  text-decoration: underline;
}

#installBtn {
  display: none;
  margin: 18px auto 0;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  font: 600 13px/1 "DM Mono", ui-monospace, monospace;
  cursor: pointer;
}

#installBtn.is-ready { display: block; }

.offline-note {
  display: none;
  margin: 14px auto 0;
  max-width: 420px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff6e0;
  font-size: 12.5px;
  text-align: center;
  color: var(--ink-soft);
}

.offline-note.is-on { display: block; }

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
}
