/* =========================================================
   Simple Budget - Reviews (shared: index.html, ch.html,
   index_horizontal.html). Same "night ledger" language as
   the website and the how-to guides. Theme follows the
   device by default (these pages run inside the app's
   WebView) and honours html[data-theme] when set.
   ========================================================= */

:root {
  --bg:          #f4f7fd;
  --surface:     #ffffff;
  --surface-2:   #eef3fc;
  --ink:         #14203c;
  --ink-dim:     #55618a;
  --ink-faint:   #8791b3;
  --line:        rgba(20, 40, 90, 0.12);
  --line-strong: rgba(20, 40, 90, 0.20);
  --accent:      #2f6bff;
  --accent-ink:  #ffffff;
  --accent-weak: rgba(47, 107, 255, 0.10);
  --star:        #e0a026;
  --star-off:    rgba(20, 40, 90, 0.22);
  --shadow:      0 14px 34px -16px rgba(20, 40, 90, 0.20);

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --maxw: 900px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0a1326;
    --surface:     #12203c;
    --surface-2:   #16264a;
    --ink:         #eaf0ff;
    --ink-dim:     #9db0d6;
    --ink-faint:   #6b7da3;
    --line:        rgba(150, 172, 224, 0.16);
    --line-strong: rgba(150, 172, 224, 0.30);
    --accent:      #5b8cff;
    --accent-ink:  #0a1326;
    --accent-weak: rgba(91, 140, 255, 0.16);
    --star:        #f4b740;
    --star-off:    rgba(150, 172, 224, 0.30);
    --shadow:      0 18px 40px -16px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --bg:          #0a1326;
  --surface:     #12203c;
  --surface-2:   #16264a;
  --ink:         #eaf0ff;
  --ink-dim:     #9db0d6;
  --ink-faint:   #6b7da3;
  --line:        rgba(150, 172, 224, 0.16);
  --line-strong: rgba(150, 172, 224, 0.30);
  --accent:      #5b8cff;
  --accent-ink:  #0a1326;
  --accent-weak: rgba(91, 140, 255, 0.16);
  --star:        #f4b740;
  --star-off:    rgba(150, 172, 224, 0.30);
  --shadow:      0 18px 40px -16px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background .25s var(--ease), color .25s var(--ease);
}

a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

.rv-wrap { max-width: var(--maxw); margin: 0 auto; padding: 24px 18px 40px; }

/* ---------- header ---------- */
.rv-head { text-align: left; margin-bottom: 20px; }
.rv-head h1 {
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.rv-head p { margin-top: 6px; color: var(--ink-dim); font-size: 0.98rem; }

/* ---------- aggregate summary ---------- */
.rv-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px;
  margin-bottom: 24px;
  background: var(--accent-weak);
  border: 1px solid var(--line);
  border-radius: 18px;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .18s var(--ease);
}
.rv-summary:active { transform: scale(0.99); }
.rv-summary .score {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
}
.rv-summary .meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rv-summary .stars { font-size: 1.05rem; letter-spacing: 2px; }
.rv-summary .count {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-dim);
}

/* ---------- reviews grid ---------- */
.rv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

.rv-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.rv-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.rv-card:active { transform: scale(0.99); }

.rv-card .rv-author {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
  margin-bottom: 6px;
}
.rv-card .rv-stars {
  font-size: 0.95rem;
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.s-on  { color: var(--star); }
.s-off { color: var(--star-off); }

.rv-card .rv-text {
  color: var(--ink-dim);
  font-size: 0.96rem;
  line-height: 1.6;
}
.rv-card .rv-date {
  display: block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
}

/* ---------- states ---------- */
.rv-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.98rem;
}
.rv-spinner {
  width: 26px; height: 26px;
  margin: 0 auto 14px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: rv-spin 0.8s linear infinite;
}
@keyframes rv-spin { to { transform: rotate(360deg); } }

/* ---------- horizontal variant (index_horizontal.html) ---------- */
.rv-grid.is-horizontal {
  display: flex;
  grid-template-columns: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
}
.rv-grid.is-horizontal .rv-card {
  flex: 0 0 auto;
  width: 300px;
  scroll-snap-align: start;
}
.rv-grid.is-horizontal::-webkit-scrollbar { height: 8px; }
.rv-grid.is-horizontal::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }

@media (max-width: 560px) {
  .rv-wrap { padding: 20px 14px 32px; }
  .rv-grid { grid-template-columns: 1fr; }
  .rv-summary { gap: 14px; padding: 16px; }
  .rv-summary .score { font-size: 2rem; }
}

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