/* ===========================================================================
   Kaunta — static site stylesheet
   Design tokens, component classes and animations, ported 1:1 from the
   Kaunta Design System (colors / typography / spacing / effects) so the static
   site renders identically without the design-compiler runtime.
   =========================================================================== */

/* --- Webfonts (Nunito + Noto Sans JP). External; degrades to system stack. --- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,700&family=Noto+Sans+JP:wght@400;500;700;900&display=swap');

:root {
  /* --- Brand --- */
  --brand-blue: #007aef;
  --brand-blue-deep: #2b70c9;
  --brand-red: #e63329;

  /* --- Screen backgrounds --- */
  --bg-home: #a0ddf1;
  --bg-learn: #2b70c9;
  --bg-learn-soft: #afe3f0;
  --bg-drill: #f1655e;
  --bg-drill-soft: #f4857f;
  --bg-review: #f97316;
  --bg-settings: #6366f1;
  --bg-feedback: #4f46e5;
  --bg-splash: #007aef;

  /* --- Core palette --- */
  --blue-500: #3b82f6;
  --blue-600: #2b70c9;
  --coral: #f1655e;
  --coral-soft: #f4857f;
  --orange-500: #f97316;
  --orange-400: #fb923c;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --amber: #fbbf24;
  --grass: #58cc02;

  /* --- Semantic feedback --- */
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --success-fg: #16a34a;
  --success-panel: #dcfce7;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --error-fg: #dc2626;
  --error-panel: #fee2e2;
  --cursor: #1cb0f6;

  /* --- Strength / status dots --- */
  --dot-fresh: #4ade80;
  --dot-due: #fb923c;
  --dot-overdue: #f87171;
  --dot-empty: #d1d5db;

  /* --- Neutrals --- */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --black: #000000;

  /* --- Semantic aliases --- */
  --text-strong: var(--gray-900);
  --text-body: var(--gray-700);
  --text-muted: var(--gray-500);
  --surface-card: var(--white);
  --surface-inset: var(--gray-50);
  --surface-glass: rgba(255, 255, 255, 0.2);
  --border-card: var(--gray-200);

  /* --- Type families & weights --- */
  --font-sans: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system,
    'Segoe UI', Roboto, sans-serif;
  --font-jp: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo,
    sans-serif;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;
  --fw-black: 900;

  /* --- Type scale --- */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --leading-tight: 1.15;

  /* --- Spacing --- */
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --pad-panel: var(--space-4);
  --gap-inline: var(--space-2);
  --hit-target-min: 44px;

  /* --- Radii --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* --- Push-button ledge --- */
  --press-depth: 4px;
  --press-depth-choice: 3px;
  --ledge-color: rgba(0, 0, 0, 0.1);
  --ledge-color-choice: rgba(0, 0, 0, 0.15);
  --shadow-push: 0 6px 0 var(--ledge-color);
  --shadow-push-choice: 0 5px 0 var(--ledge-color-choice);
  --shadow-card: 0 2px 0 rgba(0, 0, 0, 0.1);
  --ring-focus: 0 0 0 3px rgba(0, 122, 239, 0.4);

  /* --- Motion --- */
  --press-in: 100ms;
  --ease-default: ease;
}

/* --- Base --- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* safety net against accidental horizontal scroll */
}
.jp { font-family: var(--font-jp); }
a { color: var(--blue-600); }
a:hover { color: var(--brand-blue); }
img { max-width: 100%; }
h1, h2, h3, p { text-wrap: pretty; }

/* --- Layout helpers --- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.wrap { max-width: 480px; margin: 0 auto; width: 100%; }
.wrap-wide { max-width: 640px; margin: 0 auto; width: 100%; }
.stack { display: flex; flex-direction: column; }

/* --- Brand lockup --- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 2px 0 rgba(0,0,0,0.1); }
.brand-name { font-size: 22px; font-weight: 900; color: var(--gray-900); line-height: 1.1; }
.brand-kana { font-size: 13px; font-weight: 700; color: var(--gray-700); font-family: var(--font-jp); }

/* ===========================================================================
   Button — the 3D "physical key" (ported from Button.jsx)
   =========================================================================== */
.k-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; width: 100%; border: none; border-radius: var(--radius-lg);
  padding: 20px 24px; min-height: var(--hit-target-min);
  background: var(--blue-500); color: var(--white);
  font-family: var(--font-sans); cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-push);
  transition: transform var(--press-in) var(--ease-default), box-shadow var(--press-in) var(--ease-default);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.k-btn:hover { color: var(--white); }
.k-btn:active { transform: translateY(var(--press-depth)); box-shadow: 0 2px 0 var(--ledge-color); }
.k-btn.has-subtitle { gap: 2px; }
.k-btn__label {
  display: flex; align-items: center; gap: var(--gap-inline);
  font-size: var(--text-lg); font-weight: var(--fw-black); line-height: var(--leading-tight);
}
.k-btn__subtitle { font-size: var(--text-sm); font-weight: var(--fw-medium); opacity: 0.9; }
.k-btn svg { width: 22px; height: 22px; display: block; flex-shrink: 0; }

/* ===========================================================================
   ChoiceButton — multiple-choice tile (ported from ChoiceButton.jsx)
   =========================================================================== */
.k-choice {
  display: block; width: 100%; box-sizing: border-box;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--gray-300); background: var(--white); color: var(--gray-900);
  font-family: var(--font-sans); font-size: var(--text-lg); font-weight: var(--fw-bold);
  text-align: center; cursor: pointer;
  box-shadow: var(--shadow-push-choice);
  transition: transform var(--press-in) var(--ease-default), box-shadow var(--press-in) var(--ease-default);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.k-choice:active { transform: translateY(var(--press-depth-choice)); box-shadow: 0 2px 0 var(--ledge-color-choice); }
.k-choice.is-correct { background: var(--success); border-color: var(--success); color: var(--white); }
.k-choice.is-wrong { background: var(--error); border-color: var(--error); color: var(--white); }
.k-choice.is-dimmed { color: var(--gray-700); opacity: 0.6; }
.k-choice[disabled] { cursor: default; }
.k-choice.is-answered { cursor: default; box-shadow: none; }

/* ===========================================================================
   GlassPanel — frosted panel on a color field (ported from GlassPanel.jsx)
   =========================================================================== */
.k-glass {
  background: var(--surface-glass); border-radius: var(--radius-lg);
  padding: var(--pad-panel); font-family: var(--font-sans);
}
.k-glass__label {
  font-size: var(--text-sm); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: 0.03em; color: rgba(255,255,255,0.8); margin-bottom: var(--space-2);
}

/* ===========================================================================
   White content card + inset rows
   =========================================================================== */
.card {
  background: var(--white); border-radius: var(--radius-lg); padding: 24px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
  display: flex; flex-direction: column; gap: 14px;
}
.eyebrow {
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--gray-500);
}
.inset-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--gray-50); border-radius: 12px; padding: 14px 16px;
}
.inset-row .emoji { font-size: 30px; }
.inset-row .term { font-size: 18px; font-weight: 900; color: var(--gray-900); font-family: var(--font-jp); }
.inset-row .reading { font-size: 14px; font-weight: 700; color: var(--gray-500); }
.inset-row .desc { font-size: 13px; font-weight: 600; color: var(--gray-500); }

/* ===========================================================================
   Drill widget (the interactive try-it card) — driven by js/drill.js
   =========================================================================== */
.drill-q { display: flex; align-items: center; gap: 14px; }
.drill-emoji { font-size: 48px; line-height: 1; }
.drill-prompt { font-size: 18px; font-weight: 800; color: var(--gray-900); }
.drill-choices { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; min-width: 0; }
.drill-choices .k-choice { min-width: 0; padding-left: 8px; padding-right: 8px; }
.drill-feedback { border-radius: 12px; overflow: hidden; }
.drill-feedback.good { background: var(--success-panel); color: var(--success-fg); animation: kaunta-pop-big 0.45s ease-out; }
.drill-feedback.bad  { background: var(--error-panel);   color: var(--error-fg);   animation: kaunta-pop 0.3s ease-out; }
.drill-feedback__row { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drill-feedback__title { font-weight: 900; }
.drill-feedback.good .drill-feedback__title { font-size: 20px; }
.drill-feedback.bad  .drill-feedback__title { font-size: 16px; }
.drill-feedback__note { font-size: 14px; font-weight: 600; font-family: var(--font-jp); }
.drill-next {
  border: none; background: transparent; cursor: pointer; color: inherit;
  display: flex; align-items: center; gap: 4px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 800;
}
.drill-next svg { width: 18px; height: 18px; }
.drill-countdown { height: 4px; background: currentColor; opacity: 0.5; border-radius: 999px; animation: kaunta-countdown 2.6s linear forwards; }

/* ===========================================================================
   Footer
   =========================================================================== */
.site-footer { background: var(--gray-900); padding: 32px 20px 40px; }
.site-footer .row { display: flex; gap: 20px; font-size: 14px; font-weight: 700; flex-wrap: wrap; }
.site-footer a { color: var(--gray-300); text-decoration: none; }
.site-footer a:hover { color: var(--white); }
.site-footer .brand-mini { display: flex; align-items: center; gap: 10px; }
.site-footer .muted { font-size: 12px; font-weight: 600; color: var(--gray-500); }

/* --- Back link --- */
.back-link {
  display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 800;
  color: var(--gray-800); text-decoration: none; align-self: flex-start;
}
.back-link svg { width: 18px; height: 18px; }

/* ===========================================================================
   Article / legal prose
   =========================================================================== */
.prose h2 { margin: 8px 0 0; font-size: var(--text-2xl); font-weight: 900; color: var(--gray-900); }
.prose p { margin: 0; font-size: 17px; font-weight: 600; color: var(--gray-700); line-height: 1.65; }
.prose ul { margin: 0; padding: 0 0 0 20px; font-size: 16px; font-weight: 600; color: var(--gray-700); line-height: 1.7; }
.prose li { margin: 4px 0; }
.prose strong { font-weight: 900; color: var(--gray-800); }

/* ===========================================================================
   Animations
   =========================================================================== */
@keyframes kaunta-pop { 0% { transform: scale(0.7); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes kaunta-pop-big { 0% { transform: scale(0.5); } 45% { transform: scale(1.15); } 70% { transform: scale(0.96); } 100% { transform: scale(1); } }
@keyframes kaunta-countdown { from { width: 100%; } to { width: 0%; } }

@media (prefers-reduced-motion: reduce) {
  .k-btn, .k-choice { transition: none; }
  .drill-feedback, .drill-countdown { animation: none; }
}
