/* ==========================================================================
   今日の教養 — スタイル
   コンセプト: 和紙と印章（はんこ）。静かな紙の上に、今日の一頁が置かれている感覚。
   ========================================================================== */

:root {
  --paper: #E7E3D5;
  --paper-deep: #DDD8C6;
  --card-bg: #FBF9F2;
  --ink: #23291F;
  --ink-soft: #5B5F52;
  --ink-faint: #8B8D7D;
  --line: #CFC9B4;
  --accent: #B9862E;
  --accent-deep: #8C5F1E;
  --accent-bg: #F3E7CF;
  --danger: #A14636;
  --safe: #3D6B5C;

  --cat-politics: #7A5C3E;
  --cat-economy: #3D6B5C;
  --cat-society: #5C6B8C;
  --cat-history: #9C5B3C;
  --cat-science: #3E6B8C;
  --cat-law: #6B4C6B;
  --cat-culture: #8C3E4C;

  --font-display: "Shippori Mincho", serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;

  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 15% 8%, rgba(185,134,46,0.06), transparent 40%),
    radial-gradient(circle at 85% 92%, rgba(92,107,140,0.05), transparent 40%);
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--ink-soft);
  font-size: 14px;
}

.fallback-note {
  margin: 0;
  padding: 10px 14px;
  background: rgba(161,70,54,0.08);
  border: 1px solid rgba(161,70,54,0.25);
  border-radius: 10px;
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.6;
}

.error-screen {
  padding: 32px 20px;
  color: var(--ink-soft);
  line-height: 1.8;
}

/* ---------- ヘッダー ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.app-header__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:active { background: var(--paper-deep); }
.icon-btn-spacer { width: 32px; display: inline-block; }

/* ---------- カード共通 ---------- */

main {
  flex: 1;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  box-shadow: 0 1px 0 rgba(35,41,31,0.02);
  animation: fade-in 0.35s ease both;
}

.card--muted {
  background: var(--accent-bg);
  border-color: rgba(140,95,30,0.25);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-label {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  font-weight: 500;
}

/* ---------- 今日の教養（ヒーロー） ---------- */

.hero-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.hanko {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-deep);
  box-shadow: inset 0 0 0 2px rgba(140,95,30,0.12);
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--ink-faint);
}
.dot--politics { background: var(--cat-politics); }
.dot--economy { background: var(--cat-economy); }
.dot--society { background: var(--cat-society); }
.dot--history { background: var(--cat-history); }
.dot--science { background: var(--cat-science); }
.dot--law { background: var(--cat-law); }
.dot--culture { background: var(--cat-culture); }

.meta-text {
  font-size: 12.5px;
  color: var(--ink-soft);
}

.hero-title {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.5;
  margin: 4px 0 10px;
  font-weight: 700;
}

.hero-teaser {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.8;
  margin: 0 0 16px;
}

.done-mark {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--safe);
}

/* ---------- ボタン ---------- */

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  padding: 13px 20px;
  width: 100%;
  text-align: center;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--ink);
  color: var(--paper);
}

.btn--ghost {
  background: transparent;
  color: var(--accent-deep);
  border: 1px solid var(--line);
  padding: 10px 16px;
}

/* ---------- 今日の1ワード ---------- */

.word-term {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 6px;
}

.word-teaser {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.8;
  margin: 0 0 12px;
}

.word-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.word-detail.is-open {
  max-height: 400px;
  margin-top: 14px;
}
.word-detail dl {
  margin: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.word-detail dt {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 10px;
}
.word-detail dt:first-child { margin-top: 0; }
.word-detail dd {
  margin: 3px 0 0;
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- 今日の1問 ---------- */

.quiz-question {
  font-size: 14.5px;
  line-height: 1.8;
  margin: 0 0 14px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.quiz-option:active { background: var(--paper-deep); }
.quiz-option:disabled { cursor: default; }

.quiz-option.is-correct {
  border-color: var(--safe);
  background: rgba(61,107,92,0.1);
  color: var(--safe);
  font-weight: 700;
}
.quiz-option.is-wrong {
  border-color: var(--danger);
  background: rgba(161,70,54,0.08);
  color: var(--danger);
}

.quiz-feedback {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.quiz-feedback__label {
  font-weight: 700;
  font-size: 13.5px;
  margin: 0 0 4px;
}
.quiz-feedback.is-correct .quiz-feedback__label { color: var(--safe); }
.quiz-feedback.is-wrong .quiz-feedback__label { color: var(--danger); }
.quiz-feedback__text {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------- 記事画面 ---------- */

.article-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 2px 4px;
}

.article-title {
  font-family: var(--font-display);
  font-size: 23px;
  line-height: 1.55;
  margin: 6px 2px 18px;
  font-weight: 700;
}

.article-section {
  padding: 14px 2px;
  border-top: 1px solid var(--line);
}
.article-section:first-of-type { border-top: none; padding-top: 0; }

.article-section__heading {
  font-size: 12.5px;
  color: var(--accent-deep);
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  font-weight: 700;
}

.article-section__body {
  font-size: 15px;
  line-height: 1.95;
  margin: 0;
  color: var(--ink);
}

.article .btn { margin-top: 12px; }

/* ---------- 学習状況画面 ---------- */

.status-today {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.status-today__label { font-size: 14px; color: var(--ink-soft); }
.status-today__value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.status-total {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 16px;
}

.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: 76px 1fr 24px;
  align-items: center;
  gap: 10px;
}
.stat-row__label { font-size: 13px; color: var(--ink-soft); }
.stat-row__bar {
  height: 6px;
  background: var(--paper-deep);
  border-radius: 999px;
  overflow: hidden;
}
.stat-row__bar-fill {
  height: 100%;
  border-radius: 999px;
}
.stat-row__count {
  font-size: 13px;
  text-align: right;
  color: var(--ink-soft);
}

.status-note {
  margin: 16px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.7;
}

.recommend-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 6px;
}
.recommend-desc {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.recommend-reason {
  font-size: 12px;
  color: var(--accent-deep);
  margin: 0;
}

/* ---------- レスポンシブ / アクセシビリティ ---------- */

@media (min-width: 481px) {
  body { background: var(--paper-deep); }
  .app-shell {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(35,41,31,0.12);
  }
}

:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
