/* Canton profile (templates/canton.html, static/js/pages/canton.js). Uses the tokens of app.css. */

/* head */

.cp-head__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-2);
  font-size: clamp(1.9rem, 1.2rem + 3vw, 3.25rem);
  line-height: 1.05;
}

.cp-head__plate {
  box-shadow: var(--shadow-1);
}

.cp-head__links {
  margin-top: var(--s-4);
}

/* sticky control bar */

.cp-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  border-block: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}

.cp-bar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding-block: var(--s-2);
}

.cp-bar__group {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  max-width: 100%;
}

.cp-bar__label {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .cp-bar {
    position: static;
  }

  .cp-bar__group:first-child .cp-bar__label {
    display: none;
  }
}

/* native select with a drawn chevron (follows the theme) */

.cp-select {
  position: relative;
  display: inline-flex;
  min-width: 0;
}

.cp-select select {
  min-width: 0;
  max-width: 15rem;
  min-height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--r-s);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.cp-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 13px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.cp-select select:hover {
  border-color: var(--text-3);
}

@media (pointer: coarse) {
  .cp-select select {
    min-height: 44px;
  }
}

/* "Tell your friends" facts */

.cp-facts {
  margin-bottom: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-l);
  background: var(--surface);
}

.cp-facts__title {
  color: var(--accent-text);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cp-facts__list {
  display: grid;
  gap: var(--s-3) var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  margin: var(--s-3) 0 0;
  padding: 0;
  list-style: none;
}

.cp-fact {
  display: grid;
  align-content: start;
  gap: 4px;
}

.cp-fact__value {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cp-fact__text {
  color: var(--text-2);
  font-size: var(--fs-m);
}

.cp-fact__text strong {
  color: var(--text);
  font-weight: 650;
}

.cp-fact__link {
  justify-self: start;
  font-size: var(--fs-s);
}

/* comparison tiles */

.cp-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: var(--s-3);
  margin: 0;
  padding: 0;
  list-style: none;
  transition: opacity 0.18s ease;
}

.cp-tiles.is-refreshing {
  opacity: 0.55;
}

.cp-tiles > li {
  display: flex;
  min-width: 0;
}

.cp-tiles__empty {
  grid-column: 1 / -1;
}

.cp-tile-skel {
  height: 148px;
}

.cp-tile {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.cp-tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

.cp-tile.is-top {
  border-color: color-mix(in srgb, var(--data) 45%, var(--border));
}

.cp-tile__label {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cp-tile__value {
  font-size: 1.5rem;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cp-tile__unit {
  margin-top: -3px;
  color: var(--text-2);
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
}

.cp-tile__swiss {
  color: var(--text-2);
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
}

.cp-tile__rank {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
  color: var(--text-3);
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
}

.cp-tile__rank-n {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.cp-tile__rank.is-top .cp-tile__rank-n {
  color: var(--data);
}

.cp-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--data);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cp-badge--low {
  background: var(--surface-3);
  color: var(--text-2);
}

/* dot strip: every canton on one line, this canton in accent, the Swiss value as a tick */

.cp-strip {
  position: relative;
  display: block;
  height: 14px;
  margin: 6px 5px 0;
}

.cp-strip::before {
  content: "";
  position: absolute;
  inset: 6px 0 auto;
  height: 2px;
  border-radius: 1px;
  background: var(--grid);
}

.cp-strip__dot,
.cp-strip__ref {
  position: absolute;
  top: 3px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--data-dim);
}

.cp-strip__ref {
  top: 0;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--text-3);
}

.cp-strip__dot.is-me {
  z-index: 1;
  top: 1px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border: 2px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* fuel comparison */

.cp-fuel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2) var(--s-3);
}

.cp-fuel__name {
  color: var(--text-2);
  font-size: var(--fs-s);
  font-weight: 650;
  text-align: center;
}

.cp-fuel__bar {
  min-width: 0;
}

.cp-mini {
  width: 100%;
  margin-top: var(--s-3);
  border-collapse: collapse;
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
}

.cp-mini th,
.cp-mini td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 500;
}

.cp-mini thead th {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cp-mini tbody th {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cp-mini .num {
  text-align: right;
}

.cp-mini tr:last-child > * {
  border-bottom: 0;
}

.cp-mini__idx {
  font-size: 0.7em;
}

.cp-mini__idx.is-up {
  color: var(--good);
}

.cp-mini__idx.is-down {
  color: var(--text-3);
}

/* moves */

.cp-stay {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.cp-stay__value {
  font-size: var(--fs-xl);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.cp-stay__text {
  color: var(--text-2);
  font-size: var(--fs-s);
}

/* foot: call to action, previous / next */

.cp-foot {
  display: grid;
  gap: var(--s-4);
  margin-block: var(--s-7) var(--s-6);
}

.cp-foot__cta {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--accent);
  border-radius: var(--r-l);
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}

.cp-foot__cta:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.cp-foot__cta > span:last-child {
  display: grid;
  gap: 2px;
}

.cp-foot__cta-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cp-foot__cta-sub {
  color: var(--text-2);
}

.cp-foot__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.cp-foot__step {
  display: grid;
  gap: 4px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.cp-foot__step:hover {
  border-color: var(--border-strong);
}

.cp-foot__step--next {
  text-align: right;
}

.cp-foot__step--next .cp-foot__name {
  justify-content: flex-end;
}

.cp-foot__dir {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cp-foot__name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-weight: 650;
}

@media (prefers-reduced-motion: reduce) {
  .cp-tile:hover,
  .cp-foot__cta:hover {
    transform: none;
  }
}

/* longer German texts: labels, captions and fact sentences wrap instead of overflowing */

.cp-tile__label,
.cp-tile__swiss,
.cp-tile__rank,
.cp-fact__text,
.cp-stay__text,
.cp-foot__cta-title {
  overflow-wrap: anywhere;
  -webkit-hyphens: auto;
  hyphens: auto;
}

@media (max-width: 480px) {
  .cp-bar__end {
    flex-wrap: wrap;
  }

  .cp-select select {
    max-width: min(15rem, 60vw);
  }
}
