/*
 * Design tokens follow the shadcn/ui "zinc" palette (the de facto standard
 * neutral design system on GitHub: near-black primary, flat zinc-gray
 * surfaces, 1px borders instead of soft drop shadows, 8px radius). Primary
 * is kept neutral for all interactive controls; green/red are reserved for
 * semantic status only (success, error, positive/negative delta) rather
 * than used as the "brand" color, matching how shadcn separates the two.
 */
:root {
  --color-bg: #fafafa;       /* zinc-50 */
  --color-card: #ffffff;
  --color-text: #09090b;     /* zinc-950 */
  --color-muted: #71717a;    /* zinc-500 */
  --color-primary: #18181b;  /* zinc-900, used for buttons/interactive accents */
  --color-primary-dark: #000000;
  --color-primary-soft: #f4f4f5; /* zinc-100 */
  --color-border: #e4e4e7;   /* zinc-200 */
  --color-star-on: #d97706;  /* amber-600 */
  --color-star-off: #e4e4e7;
  --color-success: #16a34a;  /* green-600, semantic only */
  --color-success-soft: #f0fdf4;
  --color-danger: #dc2626;   /* red-600, semantic only */
  --color-danger-soft: #fef2f2;
  --radius: 10px;
  --radius-sm: 8px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 112px;
}

header.top {
  padding: 8px 0 20px;
  text-align: center;
  animation: floatUp 0.4s var(--ease-out) both;
}

header.top h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

header.top p {
  margin: 0;
  color: var(--color-muted);
  font-size: 13.5px;
}

/* --- progress dots --- */
.progress-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 18px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-star-off);
  transition: background-color 0.25s var(--ease-out), transform 0.25s var(--ease-out), box-shadow 0.25s;
  position: relative;
  flex: none;
}

.progress-dot.done {
  background: var(--color-primary);
}

.progress-dot.skipped {
  background: transparent;
  border: 2px solid var(--color-muted);
  width: 6px;
  height: 6px;
}

.progress-dot.current {
  background: var(--color-primary);
  transform: scale(1.4);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.progress-line {
  flex: 1 1 auto;
  height: 1px;
  max-width: 28px;
  background: var(--color-border);
}

/* --- card + stage transitions --- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.stage-container {
  position: relative;
}

.stage-card {
  animation: stageInRight 0.3s var(--ease-out) both;
}

.stage-card.leaving-back {
  animation: stageOutRight 0.22s var(--ease-in-out) both;
}

.stage-card.entering-back {
  animation: stageInLeft 0.3s var(--ease-out) both;
}

.stage-card.leaving {
  animation: stageOutLeft 0.22s var(--ease-in-out) both;
}

.stage-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.stage-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.stage-kicker {
  font-size: 11.5px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 2px;
  font-weight: 500;
}

.stage-hint {
  font-size: 13px;
  color: var(--color-muted);
  margin: 2px 0 14px;
}

.criterion-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--color-border);
}

.criterion-row:first-of-type {
  border-top: none;
}

.criterion-row .label {
  font-size: 14px;
  font-weight: 500;
}

.stars {
  display: flex;
  justify-content: space-between;
  gap: 2px;
}

.stars button {
  border: none;
  background: none;
  font-size: 36px;
  line-height: 1;
  color: var(--color-star-off);
  cursor: pointer;
  padding: 4px 5px;
  min-width: 44px;
  min-height: 44px;
  transition: color 0.15s var(--ease-out), transform 0.1s var(--ease-out);
}

.stars button.on {
  color: var(--color-star-on);
}

.stars button.just-set {
  animation: starPop 0.22s var(--ease-out);
}

.stars button:hover {
  transform: translateY(-1px);
}

textarea {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-top: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--color-card);
  color: var(--color-text);
}

textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.category-progress-note {
  font-size: 12.5px;
  color: var(--color-muted);
  margin-top: 14px;
  min-height: 18px;
}

.category-progress-note.complete {
  color: var(--color-success);
  font-weight: 500;
}

/* --- bottom nav bar --- */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.nav-bar-inner {
  width: 100%;
  max-width: 608px;
  display: flex;
  gap: 8px;
}

button.primary,
button.ghost,
button.secondary {
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 11px 16px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
}

button.primary {
  background: var(--color-primary);
  color: #fff;
  border: 1px solid var(--color-primary);
  flex: 1 1 auto;
}

button.primary:disabled {
  background: var(--color-primary-soft);
  color: var(--color-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
  opacity: 0.6;
}

button.primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

button.primary:active:not(:disabled) {
  transform: scale(0.98);
}

button.primary.just-enabled {
  animation: readyPop 0.3s var(--ease-out);
}

/* Ghost buttons are always fully clickable actions (Назад, Пропустить
 * раздел) -- they must read as clearly interactive, with dark legible text
 * and a visible border, so they are never mistaken for the disabled state
 * of the primary button next to them (that confusion is exactly what
 * happened before this rule: both were pale gray-on-gray). */
button.ghost {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-muted);
}

button.ghost:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-text);
}

button.ghost:active {
  transform: scale(0.98);
}

/* --- status banner --- */
.status-banner {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13.5px;
  border: 1px solid transparent;
  animation: floatUp 0.25s var(--ease-out) both;
}

.status-banner.success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-color: #bbf7d0;
}

.status-banner.error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: #fecaca;
}

.hidden {
  display: none !important;
}

/* --- success screen --- */
.success-screen {
  text-align: center;
  padding: 40px 16px 20px;
  animation: floatUp 0.35s var(--ease-out) both;
}

.success-check {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
}

.success-check circle {
  fill: none;
  stroke: var(--color-success);
  stroke-width: 3;
  stroke-dasharray: 252;
  stroke-dashoffset: 252;
  animation: circleDraw 0.45s var(--ease-out) forwards;
}

.success-check path {
  fill: none;
  stroke: var(--color-success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 54;
  stroke-dashoffset: 54;
  animation: checkDraw 0.3s var(--ease-out) 0.4s forwards;
}

.success-screen h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}

.success-screen p {
  color: var(--color-muted);
  margin: 0;
  font-size: 13.5px;
}

/* --- keyframes: motion design (kept short and purposeful, not decorative) --- */
@keyframes floatUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes stageInRight {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes stageOutLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-16px); }
}

@keyframes stageInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes stageOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(16px); }
}

@keyframes starPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes readyPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes circleDraw {
  to { stroke-dashoffset: 0; }
}

@keyframes checkDraw {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- admin dashboard --- */
.admin-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.admin-toolbar select,
.admin-toolbar input {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--color-card);
  color: var(--color-text);
}

button.secondary {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

button.secondary:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-muted);
}

table.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.stats-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.stats-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--color-border);
}

.badge-delta.up {
  color: var(--color-success);
}

.badge-delta.down {
  color: var(--color-danger);
}

.comment-item {
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
  font-size: 13.5px;
}

/* Section badge in front of a comment, so the reader can tell a complaint
   about Супы from one about Гарниры without opening the review. */
.comment-scope {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 11.5px;
  color: var(--color-muted);
  background: var(--color-primary-soft);
  white-space: nowrap;
  vertical-align: baseline;
}

#aiSummaryBox {
  font-size: 13.5px;
  line-height: 1.55;
}

#aiSummaryBox p {
  margin: 0 0 12px;
}

#aiSummaryBox p:last-child {
  margin-bottom: 0;
}

#aiSummaryBox strong {
  font-weight: 600;
}

/* --- self-hosted bar chart (no external JS dependency, no CDN needed) --- */
.simple-chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.simple-chart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.simple-chart-label {
  grid-column: 1 / -1;
  font-weight: 500;
  color: var(--color-text);
}

.simple-chart-track {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--color-primary-soft);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.simple-chart-fill {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.5s var(--ease-out);
}

.simple-chart-value {
  grid-column: 1 / -1;
  color: var(--color-muted);
  font-size: 12px;
  margin-top: -4px;
}

.simple-chart-empty {
  color: var(--color-muted);
  font-size: 13.5px;
}
