/* Chance me: the pieces the approved mock (docs/mocks/chance-me/chance-me.html,
   round 3) draws that Tailwind utilities don't: headings, cards, band pills,
   the segmented toggle, tabs, the ladder and its tooltip, the share dialog.
   Colours are the site's tokens (core/static/core/css/input.css). It sits
   in the components layer, so a template's Tailwind utilities still win
   (w-[130px] on a .ch-field). */

@layer components {
  .ch { --offer: #178A68; --wait: #B57A14; --none: #7A6FC0; --track: #EEF0EC; }
  .ch [hidden] { display: none !important; }

  .ch-h1 { font-family: var(--font-serif); font-size: 27px; line-height: 1.12; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; margin: 0; }
  .ch-h1.xl { font-size: 30px; }
  .ch-lead { font-size: 16.5px; line-height: 1.5; color: var(--color-muted); margin: 12px 0 0; max-width: 60ch; }
  .ch-fine { font-size: 13px; color: var(--color-faint); margin: 0; }
  .ch-label { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--color-faint); }
  @media (min-width: 768px) {
    .ch-h1 { font-size: 34px; }
    .ch-h1.xl { font-size: 46px; }
  }

  .ch .btn { font-size: 15px; border-radius: 10px; padding: 13px 18px; }
  .ch-field { display: block; width: 100%; border: 1px solid var(--color-line-strong); border-radius: 9px; padding: 10px 12px; font-size: 15px; background: var(--color-card); color: var(--color-body); }
  .ch-field::placeholder { color: #B5BCB7; font-weight: 500; }
  .ch-field:focus { outline: 2px solid var(--color-pine); outline-offset: 1px; }
  select.ch-field { width: auto; padding: 7px 30px 7px 10px; font-size: 14px; font-weight: 600; }

  .ch-card { display: block; width: 100%; text-align: left; background: var(--color-card); border: 1px solid var(--color-line); border-radius: 12px; padding: 14px 16px; box-sizing: border-box; color: inherit; text-decoration: none; }
  a.ch-card { transition: border-color .15s, box-shadow .15s; }
  a.ch-card:hover { border-color: var(--color-pine); box-shadow: 0 6px 18px -10px rgba(7, 13, 28, .3); }
  a.ch-card:focus-visible { outline: 2px solid var(--color-pine); outline-offset: 2px; }
  .ch-card-more { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--color-line); font-size: 13.5px; font-weight: 600; color: var(--color-pine); }
  .ch-card-more .arr { transition: transform .15s; }
  a.ch-card:hover .ch-card-more { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #AADEC9; }
  a.ch-card:hover .ch-card-more .arr { transform: translateX(3px); }
  @media (prefers-reduced-motion: reduce) { a.ch-card, .ch-card-more .arr { transition: none; } }

  /* Band pills */
  .ch-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
  .ch-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .ch-b-most { color: #0E6B54; background: #E4F5EE; border-color: #AADEC9; }
  .ch-b-half { color: #1C2523; background: #F7F7F4; border-color: #CBD1CA; }
  .ch-b-few { color: #8F6215; background: #F9F1E1; border-color: #E3CD9E; }
  .ch-b-low { color: #A93E2C; background: #FAEDE9; border-color: #E4B4A9; }
  .ch-b-none { color: #5C6764; background: #fff; border-color: #CBD1CA; border-style: dashed; }

  /* Segmented toggle (radios or links) */
  .ch-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: #EBEDE7; border-radius: 10px; padding: 4px; }
  .ch-seg > a, .ch-seg > label { display: block; text-align: center; border-radius: 7px; padding: 7px 10px; font-size: 14px; font-weight: 600; color: var(--color-muted); white-space: nowrap; cursor: pointer; text-decoration: none; }
  .ch-seg > a[aria-current="true"], .ch-seg > label:has(input:checked) { background: #fff; color: var(--color-pine); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
  .ch-seg > label:has(input:focus-visible) { outline: 2px solid var(--color-pine); outline-offset: 1px; }
  .ch-seg input { position: absolute; opacity: 0; pointer-events: none; }

  /* Tabs */
  .ch-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--color-line); }
  .ch-tabs button { border: 0; background: none; padding: 10px 0; font-size: 14.5px; font-weight: 600; color: var(--color-faint); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
  .ch-tabs button[aria-selected="true"] { color: var(--color-pine); border-color: var(--color-pine); }

  .ch-radio { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--color-line); border-radius: 10px; background: #fff; font-size: 15px; cursor: pointer; }
  .ch-radio input { margin-top: 4px; accent-color: var(--color-pine); }
  .ch-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--color-pine); background: #fff; border: 1px solid var(--color-line-strong); border-radius: 999px; padding: 6px 12px; text-decoration: none; cursor: pointer; }
  .ch-chip:hover { border-color: var(--color-pine); }
  .ch-link { font-size: 13.5px; font-weight: 600; color: var(--color-pine); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #AADEC9; background: none; border: 0; padding: 0; cursor: pointer; }
  .ch-link:hover { text-decoration-color: var(--color-pine); }
  .ch-error { font-size: 14px; color: var(--color-fix); background: var(--color-fix-tint); border: 1px solid var(--color-fix-line); border-radius: 9px; padding: 9px 12px; }

  /* Key */
  .ch-key { display: flex; flex-wrap: wrap; gap: 3px 14px; font-size: 12.5px; color: var(--color-muted); }
  .ch-key span { display: inline-flex; align-items: center; gap: 6px; }
  .ch-key i { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }

  /* The ladder: one row per point of average */
  .ch-viz { position: relative; }
  .ch-ladder { display: grid; gap: 2px; }
  .ch-lrow, .ch-lhead { display: grid; grid-template-columns: 74px minmax(0, 1fr) 40px; align-items: center; gap: 10px; }
  .ch-ladder.w4 .ch-lrow, .ch-lhead.w4 { grid-template-columns: 74px minmax(0, 1fr) 40px 84px; }
  .ch-lrow { padding: 5px 8px; border-radius: 8px; outline: none; }
  .ch-lrow:hover, .ch-lrow:focus-visible { background: #F3F5F1; }
  .ch-lrow.you { background: #1C2523; color: #fff; }
  .ch-lrow .lab { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--color-muted); white-space: nowrap; }
  .ch-lrow.you .lab { color: #fff; font-weight: 700; }
  .ch-lrow .cnt { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; color: var(--color-body); white-space: nowrap; }
  .ch-lrow.you .cnt { color: #fff; font-weight: 700; }
  .ch-lrow .bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--track); }
  .ch-lrow .bar i { display: block; flex: none; height: 100%; border-radius: 4px; background: var(--offer); }
  .ch-lrow.you .bar i { background: #3CC49B; }
  .ch-lrow .oth { font-size: 12.5px; color: var(--color-faint); text-align: right; font-variant-numeric: tabular-nums; }
  .ch-lrow.you .oth { color: #C9CFCB; }
  .ch-lrow.under .lab { font-style: italic; }
  .ch-ladder.mini .ch-lrow { padding: 3px 8px; }
  .ch-ladder.mini .bar { height: 10px; }
  .ch-lhead { padding: 0 8px 4px; font-size: 11.5px; font-weight: 600; color: var(--color-faint); white-space: nowrap; }
  .ch-lhead span:nth-child(n+3) { text-align: right; }

  .ch-tip { position: absolute; z-index: 10; pointer-events: none; background: #fff; border: 1px solid var(--color-line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; color: var(--color-muted); box-shadow: 0 8px 22px -10px rgba(7, 13, 28, .35); min-width: 190px; }
  .ch-tip .h { font-weight: 600; color: var(--color-body); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
  .ch-tip .r { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
  .ch-tip .r i { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }
  .ch-tip .r b { color: var(--color-body); font-variant-numeric: tabular-nums; min-width: 18px; }

  table.ch-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
  table.ch-table th { text-align: right; font-size: 11.5px; font-weight: 600; color: var(--color-faint); padding: 6px 4px; border-bottom: 1px solid var(--color-line); }
  table.ch-table td { text-align: right; padding: 6px 4px; border-bottom: 1px solid #F0F1EE; color: var(--color-body); }
  table.ch-table th:first-child, table.ch-table td:first-child { text-align: left; }
  table.ch-table tr.you td { background: #F3F5F1; font-weight: 600; }

  /* Requirements */
  .ch-reqs li { padding: 12px 0; border-top: 1px solid var(--color-line); }
  .ch-reqs li:first-child { border-top: 0; }

  /* Share dialog */
  .ch-share { margin: auto; border: 0; padding: 0; background: #3A4142; color: #fff; width: min(460px, 100vw); max-width: 100vw; max-height: 100dvh; border-radius: 16px; }
  .ch-share::backdrop { background: rgba(7, 13, 28, .55); }
  .ch-share img { display: block; width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; background: #fff; }
  @media (max-width: 520px) {
    .ch-share { width: 100vw; height: 100dvh; border-radius: 0; }
  }
}
