:root {
  --color-bg: hsl(240 11.1% 96.5%);
  --color-text: hsl(240 3.3% 11.8%);
  --color-text-dim: hsl(240 2.2% 44.1%);
  --color-accent: hsl(211 100% 50%);
  --color-border: hsla(0 0% 0% / 0.12);
  --color-border-hover: hsla(0 0% 0% / 0.22);
  --color-row: hsla(0 0% 0% / 0.03);

  --color-surface: hsl(0 0% 100%);
  --color-surface-sticky: hsl(240 11.1% 96.5%);
  --color-surface-sticky-hover: hsl(240 8.6% 93.1%);
  --color-surface-bar: hsl(240 5.5% 89.2%);
  --color-fill-subtle: hsla(0 0% 0% / 0.06);
  --color-fill-chord: var(--color-surface);

  --color-kbd-bg: hsl(240 1.7% 23.1%);
  --color-kbd-text: hsl(0 0% 100%);
  --color-kbd-shadow: hsl(240 1.5% 39.4%);

  --border-radius-tiny: 4px;
  --border-radius-small: 6px;
  --border-radius-medium: 8px;
  --border-radius-large: 10px;
  --border-radius-kbd: 5px;
  --border-radius-circle: 999rem;

  --font-size-1: 0.75rem;
  --font-size-2: 0.8rem;
  --font-size-3: 0.9rem;
  --font-size-4: 1rem;
  --font-size-5: 1.1rem;
  --font-size-6: 1.5rem;

  --gap-small: 0.2rem;
  --gap-medium: 0.5rem;
  --gap-large: 1rem;
  --gap-column: 0.3rem;
  --gap-frame-x: 1rem;
  --gap-frame-y: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: hsl(240 3.4% 11.4%);
    --color-text: hsl(240 11.1% 96.5%);
    --color-text-dim: hsl(240 2.7% 64.1%);
    --color-accent: hsl(210 100% 52%);
    --color-border: hsla(0 0% 100% / 0.14);
    --color-row: hsla(0 0% 100% / 0.04);

    --color-surface: hsl(240 3.2% 12.2%);
    --color-surface-sticky: hsl(240 3.4% 17.1%);
    --color-surface-sticky-hover: hsl(240 2.9% 20.6%);
    --color-surface-bar: hsl(240 4.1% 14.3%);
    --color-fill-subtle: hsla(0 0% 100% / 0.08);
    --color-fill-chord: hsl(240 7.1% 5.5%);

    --color-kbd-bg: hsl(240 2.3% 34.5%);
    --color-kbd-text: hsl(240 11.1% 96.5%);
    --color-kbd-shadow: hsl(240 4.8% 8.2%);
  }
}

/* MARK: Setup */
* {
  box-sizing: border-box;
}

html,
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-size: 100%;
  line-height: 1.4;
  padding: var(--gap-frame-y) var(--gap-frame-x);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.hide-visually {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

a,
a:link,
a:visited,
a:hover {
  color: var(--color-accent);
}

a:active {
  color: var(--color-text);
}

button {
  flex: none;
  appearance: none;
  border: none;
  border-radius: var(--border-radius-small);
  background: var(--color-fill-subtle);
  color: var(--color-text-dim);
  font: inherit;
  font-size: var(--font-size-4);
  padding: 6px 10px;
  cursor: pointer;
}

button:hover {
  color: var(--color-text);
}

button[hidden] {
  display: none;
}

input[type='text'] {
  appearance: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-small);
  color: var(--color-text);
  flex: 1;
  font: inherit;
  font-size: var(--font-size-5);
  line-height: 1;
  min-height: 50px;
  min-width: 0;
  padding: 0 1rem;
  transition:
  background-color 250ms ease,
  border-color 250ms ease;

  &:hover,
  &:active {
    border-color: var(--color-border-hover);
  }
}

/* MARK: Page head */
.page-head-lockup {
  display: grid;
  grid-template-columns: 1fr;

  @media (min-width: 725px) {
    grid-template-columns: 1fr 1fr;
  }
}

.page-head-download {
  @media (min-width: 725px) {
    align-self: self-start;
    justify-self: self-end;
  }
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: var(--font-size-6);
  font-weight: 700;
}

.lede {
  margin: 0;
  color: var(--color-text-dim);
  font-size: var(--font-size-3);
  text-wrap: balance;
}

.download {
  background-color: var(--color-accent);
  border-radius: var(--border-radius-circle);
  color: var(--color-kbd-text) !important;
  font-size: var(--font-size-4);
  line-height: 1;
  margin: 1rem 0 0 0;
  padding: 0.5rem 1.2rem;
  position: relative;
  top: 1rem;
  text-decoration: none;
  transition: filter 100ms ease-in;

  &:hover {
    filter: brightness(0.9);
  }

  &:active {
    filter: brightness(0.3);
    transition: none;
  }

  @media (min-width: 725px) {
    margin-top: 0;
    top: 0.25rem;
  }
}

.download-icon {
  height: 1.2rem;
  position: relative;
  top: 0.2rem;
}

/* MARK: Inputs */
.filters {
  background: var(--color-surface-sticky);
  padding: 10px 0;
  margin-top: 2rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-large);

  @media (min-width: 725px) {
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
  }
}

.field label {
  display: block;
  font-size: var(--font-size-3);
  font-weight: 600;
  margin-bottom: 5px;
  margin-left: 3px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-chord {
  text-align: center;
  cursor: default;
  caret-color: transparent;
  padding-left: 28px;

  &:hover {
    background: var(--color-surface-sticky);
    cursor: text;
  }
}

.input-hint {
  color: var(--color-text-dim);
  font-size: var(--font-size-2);
  margin-top: 0.5rem;
  margin-left: 3px;
}

.input-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  appearance: none;
  border: none;
  border-radius: var(--border-radius-tiny);
  background: transparent;
  color: var(--color-text-dim);
  cursor: pointer;

  &:hover {
    color: var(--color-text);
  }

  &[hidden] {
    display: none;
  }
}

.input-clear svg {
  width: 14px;
  height: 14px;
}

.results-status {
  margin: 1rem 0 0 0;
  font-size: var(--font-size-2);
  color: var(--color-text-dim);
  margin-bottom: 1rem;
}

/* MARK: Rows */
.row.pressed kbd,
.row.pressed .kbd-plus,
.row.pressed .seq-sep {
  position: relative;
  top: 1px;
}

.segment-head {
  display: flex;
  align-items: center;
  gap: var(--gap-medium);
  padding: 6px 0;
  cursor: pointer;
  list-style: none;
  border-top: 1px solid var(--color-border);

  &::-webkit-details-marker {
    display: none;
  }
}

.caret {
  width: 0;
  height: 0;
  flex: none;
  border-left: 5px solid var(--color-text-dim);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 120ms ease;
}

details[open] > .segment-head .caret {
  transform: rotate(90deg);
}

.segment-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-3);
  font-weight: 700;
  color: var(--color-text-dim);
  margin: 0;
}

.count {
  margin-left: auto;
  font-size: var(--font-size-1);
  font-weight: 600;
  color: var(--color-text-dim);
  background: var(--color-fill-subtle);
  border-radius: var(--border-radius-large);
  padding: 1px 7px;
}

.reader-meta {
  display: flex;
  flex-direction: column;
  gap: var(--gap-small);
  justify-content: space-between;
  margin: 0.75rem 0.75rem 1.5rem 0.75rem;

  @media (min-width: 725px) {
    flex-direction: row;
  }
}

.reader-note,
.reader-skip {
  font-size: var(--font-size-1);
  color: var(--color-text-dim);
}

.rows {
  list-style: none;
  margin: 8px 0 7px;
  padding: 0;
  border-radius: var(--border-radius-medium);
  overflow: hidden;
  display: grid;
  grid-template-columns: fit-content(40%) 1fr;
  column-gap: var(--gap-column);
}

.row {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  padding: 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;

  &:hover {
    background: var(--color-row);
  }

  &:last-child {
    border-bottom: none;
    border-radius: 0 0 var(--border-radius-medium) var(--border-radius-medium);
    margin-bottom: 4rem;
  }
}

.row-button {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  color: inherit;

  &:focus {
    outline: none;
  }

  &:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 8px;
  }
}


/* MARK: Keyboard styling */
kbd {
  font-family: Helvetica, Arial, sans-serif;
  font-size: var(--font-size-4);
  font-weight: 400;
  color: var(--color-kbd-text);
  background: var(--color-kbd-bg);
  border-radius: var(--border-radius-kbd);
  padding: 2px 7px;
  min-width: 24px;
  justify-self: start;
  text-align: center;
  white-space: nowrap;
  filter: drop-shadow(0px 2px 0px var(--color-kbd-shadow));
}

.kbd-secondary {
  background-color: transparent;
  border: 1px solid var(--color-surface-bar);
  color: unset;
  filter: none;
  font-size: unset;
  padding: 2px 6px;
}

.kbd-seq {
  justify-self: start;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: var(--gap-small);
  column-gap: 0;
}

.kbd-text {
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.kbd-plus {
  color: var(--color-text-dim);
  font-size: var(--font-size-4);
  white-space: nowrap;
}

.seq-sep {
  color: var(--color-text-dim);
  font-size: var(--font-size-4);
  padding-right: 0.35em;
  white-space: nowrap;
}

.desc {
  min-width: 0;
  font-size: var(--font-size-3);
  line-height: 1.3;
  color: var(--color-text);
  -webkit-user-select: none;
  user-select: none;
}

.empty {
  color: var(--color-text-dim);
  padding: 16px 0;
}

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.icon {
  width: 12rem;
}

/* MARK: Footer */
.secondary-content {
  display: flex;
  flex-direction: row;
  gap: var(--gap-large);
  list-style-type: none;
  margin: 1.5rem 0 0 0;
}

.secondary-content a {
  color: var(--color-text);

  &:hover,
  &:visited {
    color: var(--color-text);
  }

  &:hover,
  &:focus {
    text-decoration: none;
  }

  &:active {
    color: var(--color-text);
    position: relative;
      top: 1px;
  }
}

.copyright {
  font-size: var(--font-size-3);
  color: var(--color-text-dim);
}

/* MARK: Misc */
.copied,
.copied.show {
  display: none;
}
