/* Layouts v2 / v3, shared chart primitives, animations. */

/* ---------- shared shell ---------- */
.v2,
.v3 {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 96px;
  display: grid;
  gap: 18px;
}

.v2 { max-width: 940px; }

/* ---------- entrance animation ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
}

[data-reveal].is-revealed {
  animation: rise 0.55s var(--ease) forwards;
  animation-delay: calc(var(--reveal-i, 0) * 45ms);
}

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- shared bits ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
}

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--pos) 60%, transparent);
  animation: ping 2s infinite;
}

.pill-warn .dot { background: var(--warn); }

@keyframes ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pos) 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.icon-btn:hover {
  transform: translateY(-2px);
  background: var(--surface-3);
}

.chart-empty {
  padding: 24px 0;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

/* ---------- bar chart ---------- */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: var(--bar-h, 150px);
  overflow-x: auto;
  padding-top: 18px;
}

.bar-col {
  flex: 1 1 0;
  min-width: 26px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 4px;
  height: 100%;
  text-align: center;
}

.bar-track {
  display: flex;
  align-items: flex-end;
  height: 100%;
}

.bar-fill {
  width: 100%;
  height: 100%;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 45%, transparent));
  transform: scaleY(var(--v, 0));
  transform-origin: bottom;
  animation: grow 0.65s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 28ms);
  transition: filter 0.2s var(--ease);
}

.bar-col:hover .bar-fill { filter: brightness(1.15); }
.bar-col.neg .bar-fill { background: linear-gradient(180deg, var(--neg), color-mix(in srgb, var(--neg) 40%, transparent)); }

@keyframes grow {
  from { transform: scaleY(0); }
}

.bar-val {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.bar-lbl {
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- trend chart ---------- */
.trend svg {
  width: 100%;
  height: 190px;
  overflow: visible;
}

.trend-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.1s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 180ms);
  vector-effect: non-scaling-stroke;
}

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

.trend-area {
  opacity: 0;
  animation: fade 0.8s var(--ease) 0.5s forwards;
}

@keyframes fade {
  to { opacity: 1; }
}

.chart-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-item i {
  width: 10px;
  height: 3px;
  border-radius: 2px;
}

/* ---------- ring ---------- */
.ring {
  position: relative;
  width: var(--ring-size, 132px);
  height: var(--ring-size, 132px);
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--surface-3);
}

.ring-value {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dashoffset: var(--offset);
  animation: ringIn 1.1s var(--ease) backwards;
  transition: stroke-dashoffset 0.8s var(--ease);
}

@keyframes ringIn {
  from { stroke-dashoffset: var(--dash); }
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 2px;
}

.ring-center strong {
  font-size: 20px;
  color: var(--text-strong);
}

.ring-center span {
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- share bars ---------- */
.shares { display: grid; gap: 14px; }

.share-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
}

.share-head strong { color: var(--text-strong); }

.share-track {
  height: 8px;
  margin: 6px 0 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.share-fill {
  height: 100%;
  width: var(--w);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left;
  animation: slide 0.75s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes slide {
  from { transform: scaleX(0); }
}

.share-row small { font-size: 11px; color: var(--text-dim); }

/* ================= V2 ================= */
.v2-top,
.v3-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 22px;
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: var(--shadow-pop);
}

.v2-brand,
.v3-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.v2-mark,
.v3-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, #f4d88d, var(--gold, #d6b56d));
  color: #111318;
  font-weight: 800;
}

.v2-brand strong,
.v3-brand strong {
  display: block;
  font-size: 17px;
  color: #fff;
}

.v2-brand small,
.v3-brand small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.v2-top-actions,
.v3-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-top .pill,
.v3-top .pill {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.85);
}

.v2-top .icon-btn,
.v3-top .icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.v2-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #111318;
  cursor: pointer;
  transition: transform 0.2s var(--ease);
}

.v2-refresh svg { flex: 0 0 auto; }

.v2-refresh:hover { transform: translateY(-1px); }

.v2-alert,
.v3-alert {
  padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--text);
  font-size: 13px;
}

.v2-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.v2-hero-main p {
  margin: 0 0 6px;
  color: var(--text-dim);
  font-size: 14px;
}

.v2-hero-main strong {
  display: block;
  font-size: clamp(46px, 8vw, 78px);
  line-height: 1;
  font-weight: 750;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.v2-hero-sub {
  display: inline-block;
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-dim);
}

.v2-hero-sub.up { color: var(--pos); }
.v2-hero-sub.down { color: var(--neg); }

.v2-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.v2-tile {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.v2-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.v2-tile span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 13px;
}

.v2-tile strong {
  font-size: clamp(24px, 3.4vw, 34px);
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.v2-tile.pos strong { color: var(--pos); }
.v2-tile.neg strong { color: var(--neg); }

.v2-card,
.v3-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
}

.v2-card-head,
.v3-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.v2-card-head h2,
.v3-card-head h2 {
  margin: 0;
  font-size: 19px;
  color: var(--text-strong);
}

.v2-card-head small,
.v3-card-head small { color: var(--text-dim); font-size: 12px; }

.v2-progress-track {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.v2-progress-fill {
  height: 100%;
  width: var(--w);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left;
  animation: slide 0.9s var(--ease);
}

.v2-progress-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.v2-progress-meta span {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 4px;
}

.v2-progress-meta strong { font-size: 19px; color: var(--text-strong); }

.v2-verdicts { display: grid; gap: 10px; }

.v2-verdict {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.v2-verdict i {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-style: normal;
  font-weight: 700;
  flex: 0 0 auto;
}

.v2-verdict p { margin: 0; font-size: 15px; color: var(--text); }
.v2-verdict.good i { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.v2-verdict.bad i { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.v2-verdict.warn i { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.v2-verdict.flat i { background: var(--surface-3); color: var(--text-dim); }

.v2-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
  color: var(--text-dim);
  font-size: 12px;
}

.v2-foot a { color: var(--accent); }

/* ================= V3 ================= */
.k-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.k-cell {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease);
}

.k-cell:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.k-cell span {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  margin-bottom: 6px;
}

.k-cell strong {
  display: block;
  font-size: 21px;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.k-cell small { color: var(--text-dim); font-size: 10px; }
.k-cell.pos strong { color: var(--pos); }
.k-cell.neg strong { color: var(--neg); }
.k-cell.accent strong { color: var(--accent); }
.k-cell.warn strong { color: var(--warn); }

.v3-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.v3-row .wide { grid-column: span 1; }
.v3-card.wide { min-width: 0; }

.v3-ring-wrap { display: grid; place-items: center; padding: 8px 0 16px; }

.v3-mini {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.v3-mini > div {
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-3);
}

.v3-mini span { display: block; color: var(--text-dim); font-size: 11px; }
.v3-mini strong { color: var(--text-strong); font-size: 16px; }

.rec-list, .prod-list { display: grid; gap: 10px; }

.rec {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-3);
}

.rec span { color: var(--text-dim); font-size: 13px; }
.rec strong { font-size: 18px; color: var(--text-strong); }
.rec small { color: var(--text-dim); font-size: 11px; }
.rec.pos strong { color: var(--pos); }
.rec.neg strong { color: var(--neg); }

.prod { padding: 14px; border-radius: 14px; background: var(--surface-3); }

.prod-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.prod-head span { color: var(--text); font-size: 14px; }
.prod.pos .prod-head strong { color: var(--pos); }
.prod.neg .prod-head strong { color: var(--neg); }

.prod-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.prod-stats span { display: block; color: var(--text-dim); font-size: 11px; }
.prod-stats strong { font-size: 14px; color: var(--text-strong); }

.v3-insights { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }

.v3-insights li {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-3);
  font-size: 13px;
  border-left: 3px solid var(--text-dim);
}

.v3-insights li.good { border-left-color: var(--pos); }
.v3-insights li.warn { border-left-color: var(--warn); }
.v3-insights li.bad { border-left-color: var(--neg); }

.v3-source { display: grid; gap: 10px; }
.v3-source a { color: var(--accent); }

.v3-source > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.v3-source span { color: var(--text-dim); }
.v3-source strong { color: var(--text-strong); }

.v3-alerts { display: grid; gap: 8px; }

/* year archive (v3) */
.y-block { display: grid; gap: 12px; margin-bottom: 18px; }

.y-head { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.y-head > div { padding: 14px; border-radius: 16px; background: var(--surface-3); }
.y-head span { display: block; color: var(--text-dim); font-size: 12px; }
.y-head strong { display: block; font-size: 24px; color: var(--text-strong); }
.y-head small { color: var(--text-dim); font-size: 11px; }

.y-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }

.y-cell {
  position: relative;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  min-height: 88px;
  transition: transform 0.2s var(--ease);
}

.y-cell:hover { transform: translateY(-2px); }
.y-cell span { display: block; color: var(--text-dim); font-size: 11px; }
.y-cell strong { display: block; font-size: 16px; color: var(--text-strong); }
.y-cell small { color: var(--text-dim); font-size: 10px; }
.y-cell.pos strong { color: var(--pos); }
.y-cell.neg strong { color: var(--neg); }
.y-cell.empty { background: var(--surface-3); opacity: 0.6; }

.y-edit {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.y-cell:hover .y-edit { opacity: 1; }

.y-form { display: grid; gap: 6px; }
.y-form label { display: grid; gap: 2px; font-size: 10px; color: var(--text-dim); }

.y-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
}

.y-form-actions { display: flex; gap: 4px; }

.y-form-actions button {
  flex: 1;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}

/* ================= responsive ================= */
@media (max-width: 1080px) {
  .k-grid { grid-template-columns: repeat(3, 1fr); }
  .y-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 860px) {
  .v3-row { grid-template-columns: 1fr; }
  .v2-tiles { grid-template-columns: 1fr; }
  .v2-hero { flex-direction: column; align-items: flex-start; }
  .v2-progress-meta { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .v2, .v3 { width: calc(100% - 20px); padding-bottom: 90px; }
  .k-grid { grid-template-columns: repeat(2, 1fr); }
  .y-grid { grid-template-columns: repeat(3, 1fr); }
  .v2-top, .v3-top { flex-direction: column; align-items: stretch; gap: 12px; }
  .v2-top-actions, .v3-top-actions { justify-content: space-between; }
}
