/* ==========================================================
   CONTRIBUTION SKYLINE — gaya kartu, disesuaikan dengan kertas map
   ========================================================== */

.cs {
  --cs-bg: #eef0e8;
  --cs-fg: var(--ink);
  --cs-muted: rgba(28, 28, 28, 0.55);
  --cs-border: rgba(28, 28, 28, 0.14);

  position: relative;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--cs-border);
  border-radius: 6px;
  background: var(--cs-bg);
  color: var(--cs-fg);
  font-family: var(--f-mono);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 40px -28px rgba(0, 0, 0, 0.45);
}

.cs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.cs-title {
  margin: 0;
  font-family: var(--f-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
}

.cs-total {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* toggle 2D / 3D */
.cs-toggle {
  position: relative;
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--cs-border);
  border-radius: 6px;
}

.cs-toggle__thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: 32px;
  border-radius: 4px;
  background: var(--cs-fg);
  transition: transform 0.5s;
}

.cs-toggle__btn {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border-radius: 4px;
  color: var(--cs-muted);
  transition: color 0.5s;
}

.cs-toggle__btn[aria-pressed="true"] {
  color: var(--cs-bg);
}

.cs-toggle__btn svg {
  max-width: none;
}

/* bingkai dalam */
.cs-frame {
  position: relative;
  border: 1px solid var(--cs-border);
  border-radius: 5px;
}

.cs-stage-wrap {
  position: relative;
  padding: 16px 16px 0;
}

.cs-stage {
  position: relative;
  width: 100%;
  height: 150px;
  overflow: hidden;
  border-radius: 4px;
}

.cs-stage:has(:focus-visible) {
  outline: 1.5px dashed var(--cs-fg);
  outline-offset: 4px;
}

.cs-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  max-width: none;
  outline: none;
}

/* statistik di pojok saat 3D */
.cs-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 18px;
  pointer-events: none;
  transition-property: opacity, transform;
}

.cs-corner[hidden] {
  display: none;
}

.cs-corner--tr {
  top: 4px;
  right: 4px;
  align-items: flex-end;
}

.cs-corner--bl {
  bottom: 4px;
  left: 4px;
  align-items: flex-start;
}

.cs-stat__label {
  font-size: 11px;
  line-height: 1.2;
  color: var(--cs-muted);
}

.cs-stat__value {
  font-family: var(--f-sans);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  transition: color 0.5s;
}

.cs-stat__unit {
  font-size: 13px;
}

.cs-stat__sub {
  font-size: 11px;
  color: var(--cs-muted);
  white-space: nowrap;
}

.cs-stat--end,
.cs-stat--start {
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  column-gap: 8px;
}

.cs-stat--end .cs-stat__label {
  grid-column: 1;
  text-align: right;
}

.cs-stat--end::after {
  content: "";
  grid-column: 2;
  grid-row: 1;
}

.cs-stat--start .cs-stat__label {
  grid-column: 1 / -1;
}

.cs-stat--end .cs-stat__value,
.cs-stat--start .cs-stat__value {
  text-align: right;
  line-height: 0.95;
}

.cs-stat--end .cs-stat__side,
.cs-stat--start .cs-stat__side {
  padding-bottom: 0.15em;
  line-height: 1.2;
}

.cs-stat--stack {
  min-width: 0;
}

.cs-stat--stack .cs-stat__value {
  display: inline-block;
  margin-top: 4px;
  font-size: 28px;
}

.cs-stat--stack .cs-stat__side {
  display: contents;
}

.cs-stat--stack .cs-stat__unit {
  display: inline-block;
  margin-left: 6px;
}

.cs-stat--stack .cs-stat__sub {
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* tooltip */
.cs-tip {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 20;
  padding: 6px 10px;
  border-radius: 5px;
  background: var(--cs-fg);
  color: var(--cs-bg);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: opacity 0.15s;
}

.cs-tip strong {
  font-weight: 700;
}

.cs-tip__date {
  opacity: 0.75;
}

.cs-tip__arrow {
  position: absolute;
  top: 100%;
  left: var(--arrow, 50%);
  width: 0;
  height: 0;
  margin-left: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--cs-fg);
}

/* baris statistik (tampil di 2D / layar sempit) */
.cs-stats {
  display: grid;
  grid-template-rows: 1fr;
  transition-property: grid-template-rows, opacity;
}

.cs-stats__inner {
  min-height: 0;
  overflow: hidden;
}

.cs-stats__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px 16px 4px;
}

/* footer: hint + legenda */
.cs-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--cs-muted);
}

.cs-hints {
  position: relative;
  display: grid;
  flex: 1;
}

.cs-hints > span {
  grid-area: 1 / 1;
  transition: opacity 0.5s;
}

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

.cs-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.12);
  transition: background-color 0.5s, transform 0.3s;
}

.cs-swatch:hover,
.cs-swatch[aria-pressed="true"] {
  transform: scale(1.25);
}

@media (max-width: 640px) {
  .cs {
    padding: 12px;
  }

  .cs-stage-wrap {
    padding: 12px 12px 0;
  }

  .cs-tip {
    top: 12px;
    left: 12px;
  }

  .cs-stats__grid {
    grid-template-columns: 1fr 1fr;
    padding: 16px 12px 4px;
  }

  .cs-foot {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs * {
    transition: none !important;
  }
}
