/* Shared interactive controls and surfaces. Both the public site and account
   pages load these components; /style-guide contains working examples. */
@layer tokens, base, components, sections;
@import url('tokens.css');

@layer base {
  [hidden] {
    display: none !important;
  }
}

@layer components {
  .Button,
  .Field {
    box-sizing: border-box;
    height: var(--control-height);
    padding: 0 var(--control-pad-inline, .75rem);
    font: inherit;
    line-height: 1.25;
    vertical-align: middle;
  }
  .Button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    border: 1px solid color-mix(in srgb, var(--button-fill, var(--accent)),
      var(--ink) 30%);
    border-radius: var(--button-radius, .45rem);
    background: linear-gradient(to bottom, color-mix(in srgb, var(--button-fill,
      var(--accent)), var(--rim) 12%), var(--button-fill, var(--accent)));
    color: var(--button-ink, var(--on-accent));
    box-shadow: inset 0 1px color-mix(in srgb, var(--rim) 35%, transparent), 0
      2px 0 color-mix(in srgb, var(--button-fill, var(--accent)), var(--ink)
      40%), 0 3px 5px var(--shade);
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
  }
  .Button:hover {
    filter: brightness(1.05);
  }
  .Button:active:not(:disabled),
  .Button[aria-pressed='true'] {
    transform: translateY(1px);
    box-shadow: var(--inset);
  }
  .Button:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
    filter: none;
  }
  .Button-quiet {
    --button-fill: var(--paper);
    --button-ink: var(--ink);
  }
  .Field {
    min-width: 0;
    max-width: 100%;
    border: 1px solid var(--edge);
    border-radius: .45rem;
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--inset);
  }
  select.Field {
    background: linear-gradient(var(--paper), var(--ground));
    box-shadow: inset 0 1px var(--rim), 0 1px 2px var(--shade);
    cursor: pointer;
  }
  select.Field:not(:disabled):hover {
    border-color: var(--accent);
  }
  textarea.Field {
    height: auto;
    min-height: calc(var(--control-height) * 2);
    padding-block: .5rem;
    vertical-align: top;
  }
  .Field:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
  }
  /* Pills: a soft chip, and a row of them that wraps like a handful of
     notes. The list is the same shape whether the chips are words (the home
     page) or links (the help page's questions). */
  .Pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
  }

  .Pill {
    display: inline-block;
    padding: var(--pill-pad, .3rem .75rem);
    border: var(--pill-edge, 1px solid var(--line));
    border-radius: var(--pill-radius, var(--pill));
    background: var(--pill-fill, var(--paper));
    color: var(--pill-ink, var(--ink));
    font-family: var(--pill-font, inherit);
    font-size: var(--pill-size, var(--small));
    font-weight: var(--pill-weight, 600);
    line-height: 1.4;
    vertical-align: middle;
    text-decoration: none;
  }

  a.Pill {
    --pill-ink: var(--accent);
    --pill-edge: 1px solid var(--edge);
    --pill-weight: 700;
    box-shadow: inset 0 1px var(--rim), 0 1px 2px var(--shade);
    text-decoration: underline;
    text-underline-offset: .18em;
  }
  a.Pill:hover {
    --pill-edge: 1px solid var(--accent);
    --pill-fill: color-mix(in srgb, var(--accent) 7%, var(--paper));
  }
  a.Pill:active {
    transform: translateY(1px);
    box-shadow: var(--inset);
  }
  a.Pill:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--pill-radius, var(--pill));
  }
  .Pill_Tag {
    margin-left: .5rem;
    color: var(--soft-ink);
    font-weight: 400;
    font-size: .85em;
  }

  /* A quiet label, such as the address in a window bar. */
  .Pill-quiet {
    --pill-fill: var(--ground);
    --pill-ink: var(--soft-ink);
    --pill-edge: 0;
    --pill-pad: 0.2rem 0.9rem;
    --pill-size: var(--small);
    --pill-weight: 600;
  }

  /* A URL somebody has to copy. */
  .Pill-code {
    --pill-pad: .2rem .5rem;
    --pill-radius: .35rem;
    --pill-fill: var(--ground);
    --pill-edge: 0;
    --pill-font: var(--mono);
    --pill-size: var(--small);
  }

  .Address {
    color: var(--soft-ink);
    font-weight: 400;
  }
  .Address_Name {
    color: var(--ink);
    font-weight: 800;
  }

  .Card {
    padding: var(--card-pad, 1.75rem);
    border: 1px solid var(--edge);
    border-radius: var(--card-radius, .85rem);
    background-color: var(--card-fill, var(--paper));
    box-shadow: var(--card-shadow, var(--raised));
  }

  .Card-sectioned {
    display: block;
    padding: 0;
    overflow: clip;
  }
  .Card_Header,
  .Card_Body,
  .Card_Footer {
    padding: var(--card-pad, 1.75rem);
  }
  .Card_Header,
  .Card_Footer {
    padding-block: .85rem;
    background: color-mix(in srgb, var(--ground), var(--paper) 55%);
  }
  .Card_Header {
    border-bottom: 1px solid var(--line);
  }
  .Card_Footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    border-top: 1px solid var(--line);
  }
  .Card_Header > :last-child,
  .Card_Body > :last-child,
  .Card_Footer > :last-child {
    margin-bottom: 0;
  }
  .Card_Header > :first-child,
  .Card_Body > :first-child,
  .Card_Footer > :first-child {
    margin-top: 0;
  }

  /* A report belongs to the page; its header, chart and rankings provide
     hierarchy without an enclosing card. */
  .Stats {
    display: grid;
    gap: 1.25rem;
    padding-block: 1.75rem;
    border-top: 1px solid var(--line);
  }
  .Stats_Head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }
  .Stats_Title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.3;
  }
  .Stats_Title a {
    color: var(--ink);
    text-decoration: none;
  }
  .Stats_Title a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: .18em;
  }
  .Stats_Total {
    flex: none;
    margin: 0;
    color: var(--ink);
    font-size: 1.8rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
  }
  .Stats_Unit {
    color: var(--soft-ink);
    font-size: .85rem;
    font-weight: 400;
  }
  .Stats_Plot {
    display: grid;
    gap: .35rem;
    margin: 0;
  }
  .Stats_Chart {
    display: block;
    width: 100%;
    height: 5rem;
    border-bottom: 1px solid var(--line);
  }
  .Stats_Bar {
    fill: var(--accent);
  }
  .Stats_Span {
    display: flex;
    justify-content: space-between;
    color: var(--soft-ink);
    font-size: .8rem;
  }
  .Stats_Tops {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
  }
  .Stats_Column h3 {
    margin: 0 0 .5rem;
    color: var(--soft-ink);
    font-size: .8rem;
    font-weight: 700;
  }
  .Stats_List {
    display: grid;
    gap: .4rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .9rem;
  }
  .Stats_List li {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
  }
  .Stats_List span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .Stats_List b {
    font-variant-numeric: tabular-nums;
  }
  @media (max-width: 600px) {
    .Stats_Tops {
      grid-template-columns: minmax(0, 1fr);
      gap: 1rem;
    }
  }

  /* One row of physical tabs meets one sheet. Native radios own selection,
     including arrow keys, so the component works without JavaScript. */
  .Tabs {
    display: flex;
    flex-wrap: wrap;
    column-gap: .3rem;
    position: relative;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .Tabs_Legend {
    margin-bottom: 1rem;
    padding: 0;
    color: var(--ink);
    font-weight: 800;
    text-align: left;
  }
  .Tabs_Item {
    display: contents;
  }
  .Tabs_Item > input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }
  .Tabs_Tab {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
    min-height: 3rem;
    overflow-wrap: normal;
    margin: .35rem 0 -1px;
    padding: .55rem .45rem;
    border: 1px solid var(--edge);
    border-radius: .65rem .65rem 0 0;
    background: linear-gradient(var(--ground), color-mix(in srgb, var(--ground),
      var(--line) 60%));
    box-shadow: inset 0 1px var(--rim);
    color: var(--soft-ink);
    font-size: .85rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    z-index: 1;
  }
  @media (max-width: 480px) {
    .Tabs_Tab {
      padding-inline: .3rem;
      font-size: .8rem;
    }
  }
  .Tabs_Tab:hover {
    color: var(--ink);
  }
  .Tabs_Panel {
    --card-radius: 0 0 .85rem .85rem;
    order: 1;
    flex: 1 1 100%;
    min-width: 0;
    display: none;
    position: relative;
    margin: 0;
    text-align: left;
  }
  .Tabs_Item > input:checked ~ .Tabs_Tab {
    margin-top: 0;
    padding-top: .9rem;
    border-bottom-color: var(--paper);
    background: linear-gradient(var(--accent) 4px, var(--paper) 4px)
      padding-box;
    color: var(--ink);
    box-shadow: inset 0 1px var(--rim);
    z-index: 2;
  }
  .Tabs_Item > input:checked ~ .Tabs_Tab::after {
    position: absolute;
    content: '';
    right: 0;
    bottom: -2px;
    left: 0;
    height: 3px;
    background: var(--paper);
  }
  .Tabs_Item > input:checked ~ .Tabs_Panel {
    display: block;
  }
  .Tabs_Item > input:focus-visible ~ .Tabs_Tab {
    outline: 3px solid var(--accent);
    outline-offset: -5px;
  }

  .Icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    flex: none;
    vertical-align: -.15em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* --nav-panel is the panel this nav leans against: the current row merges
     into it, which is what makes it read as the page you are on. A nav with
     nothing beside it points both at transparent (.Docs_Nav). */
  .SideNav {
    --nav-panel: var(--paper);
    --nav-edge: var(--edge);
    display: grid;
    gap: .4rem;
    border-right: 1px solid var(--nav-edge);
  }
  .SideNav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: 0 -1px 0 .35rem;
    padding: .6rem .8rem;
    border: 1px solid var(--edge);
    border-radius: .6rem 0 0 .6rem;
    background: linear-gradient(to right, var(--ground), color-mix(in srgb,
      var(--ground), var(--line) 35%));
    color: var(--soft-ink);
    font-size: .95rem;
    text-decoration: none;
  }
  .SideNav a:hover {
    color: var(--ink);
    background: var(--paper);
  }
  .SideNav a[aria-current='page'] {
    margin-left: 0;
    background: linear-gradient(to right, var(--accent) 4px, var(--paper) 4px)
      padding-box;
    border-right-color: var(--nav-panel);
    color: var(--ink);
    font-weight: 800;
    z-index: 1;
  }
  .SideNav a[aria-current='page']::after {
    position: absolute;
    content: '';
    inset: 0 -2px 0 auto;
    width: 3px;
    background: var(--nav-panel);
  }
  .SideNav hr {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--edge);
    box-shadow: 0 1px var(--rim);
    margin: 1rem 0;
  }
  @media (max-width: 700px) {
    .SideNav {
      display: flex;
      flex-wrap: wrap;
      border: 0;
    }
    .SideNav a {
      margin: 0;
      border-color: transparent;
      border-radius: .3rem;
      background: none;
    }
    .SideNav a[aria-current='page'] {
      border-color: transparent;
      background: color-mix(in srgb, var(--accent) 10%, transparent);
      box-shadow: inset 3px 0 var(--accent);
    }
    .SideNav a[aria-current='page']::after {
      display: none;
    }
  }

  .Choice {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-height: var(--control-height);
    line-height: 1.4;
    cursor: pointer;
  }
  .Choice input {
    appearance: none;
    display: grid;
    place-content: center;
    box-sizing: border-box;
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    margin: 0;
    border: 1px solid var(--edge);
    border-radius: .25rem;
    background: var(--paper);
    box-shadow: var(--inset);
    cursor: inherit;
  }
  .Choice input[type='radio'] {
    border-radius: 50%;
  }
  .Choice input::before {
    content: '';
    width: .45rem;
    height: .45rem;
    transform: scale(0);
  }
  .Choice input[type='checkbox']::before {
    width: .3rem;
    height: .6rem;
    margin-top: -.15rem;
    border: solid var(--on-accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
  }
  .Choice input[type='radio']::before {
    border-radius: 50%;
    background: var(--on-accent);
  }
  .Choice input:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: inset 0 1px var(--shade);
  }
  .Choice input:checked::before {
    transform: scale(1);
  }
  .Choice input[type='checkbox']:checked::before {
    transform: rotate(45deg) scale(1);
  }
  .Choice:has(input:disabled) {
    opacity: .55;
    cursor: not-allowed;
  }
  .Choice input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
  }

  .Connections {
    display: grid;
    gap: var(--half-gap);
    margin: 0 0 var(--gap);
    padding: 0;
    list-style: none;
  }
  .Connections-links {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin: 0;
  }
  .Connections_Row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--half-gap) var(--gap);
    padding: var(--gap);
    border: 1px solid var(--edge);
    border-radius: var(--small-radius);
    background: var(--paper);
    box-shadow: inset 0 1px var(--rim);
    text-align: left;
  }
  .Connections_Info {
    display: grid;
    flex: 1 1 10rem;
    gap: var(--quarter-gap);
    min-width: 0;
    color: var(--ink);
    overflow-wrap: anywhere;
  }
  .Connections_State,
  .Connections_Open {
    display: inline-flex;
    align-items: center;
    gap: var(--quarter-gap);
    color: var(--accent);
    font-size: var(--small);
  }
  .Connections_Open {
    font-weight: 700;
    text-underline-offset: .18em;
    white-space: nowrap;
  }
}
