/* The two typefaces, served from the site itself (not from Google), so a visit sends nothing to anyone else. Both are
   variable fonts under the SIL Open Font License (the licences are beside them in /assets/fonts/): Bricolage
   Grotesque for headings, Instrument Sans for text. Each comes in two parts, and a page only fetches the second
   (Latin Extended: Polish, Czech, Turkish...) if it has letters from it. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url(/piano-guide/assets/fonts/bricolage-grotesque-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url(/piano-guide/assets/fonts/bricolage-grotesque-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/piano-guide/assets/fonts/instrument-sans-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/piano-guide/assets/fonts/instrument-sans-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* The site's colours are the materials of a well-kept piano: ivory and key-white surfaces, lacquered ebony, the red
   felt along the back of the keys (used sparingly: the main button, the active key, focus), and a touch of brass. */
:root {
  --bg: #fafaf9; /* ivory: the page */
  --bg-alt: #f3f2ef; /* a shade deeper: quiet panels, hovers */
  --surface: #ffffff; /* key white: cards */
  --placeholder: #ebe9e5;
  --text: #1c1917; /* ebony */
  --muted: #57534e; /* graphite */
  --accent: #b3302d; /* felt */
  --accent-ink: #962622; /* felt, dark enough for text */
  --accent-light: #f6dcd8; /* felt, as a fill for marked white keys */
  --accent-soft: rgba(179, 48, 45, 0.08);
  --brass: #a8895a; /* small details only: too light for text on ivory */
  --line: #e7e5e1; /* hairline */
  --line-strong: #d3d0ca;
  --ebony-text: #fafaf9; /* text on ebony */
  --ebony-muted: #a8a29e;

  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;

  --radius: 12px;
  --pad: 20px;

  /* cards sit just above the page: a contact shadow and a soft drop, deeper when lifted */
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.05), 0 8px 24px -12px rgba(28, 25, 23, 0.14);
  --shadow-lift: 0 2px 4px rgba(28, 25, 23, 0.06), 0 18px 36px -14px rgba(28, 25, 23, 0.24);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  --accent-deep: #962622; /* the felt button under the pointer */
  --strong: #1c1917; /* a chosen option button or tab, filled */
  --on-strong: #ffffff;
  --ink-faint: rgba(18, 19, 22, 0.16); /* a faint dividing line */
  --footer: #1c1917;

  /* The piano itself looks the same in both themes: ebony, key-white keys, felt */
  --ebony: #1c1917;
  --key-white: #ffffff;
  --key-lit: #f6dcd8; /* a marked white key */
  --key-ink: #962622; /* felt red written on a white key, or a key picked */
  --key-muted: #6b655f;
  --paper: #faf7f0; /* the sheet the music is printed on, on a dark screen */
  --case-top: #2b2623; /* the lacquered case: light catches the top */
  --case-mid: #1c1917;
  --case-bottom: #161311;
  --case-edge: transparent;
  color-scheme: light;
}

/* Dark: the room with the lights down. Ivory turns to a warm near-black, the felt brightens a little to keep its
   glow, and the piano stays as it is. Screen only, so a printed fingering chart is always dark ink on white. The
   theme is set on <html> by the script in the <head> (the toggle in the header, or else the device's setting). */
@media screen {
  :root[data-theme="dark"] {
    --bg: #141210;
    --bg-alt: #1c1917;
    --surface: #201c1a;
    --placeholder: #2a2623;
    --text: #ede9e4;
    --muted: #a8a19a;
    --accent: #c4403a;
    --accent-ink: #f0928b;
    --accent-light: rgba(196, 64, 58, 0.24);
    --accent-soft: rgba(212, 82, 76, 0.16);
    --accent-deep: #a8332e;
    --brass: #c9a978;
    --line: #2f2a27;
    --line-strong: #453e3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px -12px rgba(0, 0, 0, 0.55);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 36px -14px rgba(0, 0, 0, 0.7);
    --strong: #ede9e4;
    --on-strong: #1c1917;
    --ink-faint: rgba(237, 233, 228, 0.16);
    --footer: #0d0b0a;
    --key-white: #f4f1ec;
    --case-top: #342e2a;
    --case-mid: #25211e;
    --case-bottom: #1f1b19;
    --case-edge: rgba(250, 250, 249, 0.08);
    --search-icon: url(/piano-guide/assets/icons/search-light.svg);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
.logo {
  font-family: var(--font-display);
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

img {
  max-width: 100%;
  display: block;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.logo-mark {
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

/* a link to a part of a page (/scales/#minor-scales) stops below the sticky header instead of under it */
[id] {
  scroll-margin-top: 84px;
}

/* Mobile */

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px var(--pad);
  background: var(--bg);
  border-top: 3px solid var(--accent); /* the felt strip */
  border-bottom: 1px solid var(--line);
}

.logo {
  font-size: 1.3rem;
}

/* the first thing the Tab key reaches: hidden above the page until then */
.skip-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--strong);
  color: var(--on-strong);
  font-size: 0.9rem;
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

main:focus {
  outline: none;
}

.header-links,
.search-form {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 1rem var(--pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 18px 28px -22px rgba(28, 25, 23, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

/* shown at once on opening (not at the end of the fade), so what is in it can take the keyboard straight away */
.header-links.is-open,
.search-form.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

/* the menu on a phone and a tablet: every page as a large button, two or four to a row, the one you are on in felt */
.header-links ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}

.header-links a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

.header-links a:active {
  background: var(--bg-alt);
}

.header-links a[aria-current="page"] {
  background: var(--bg-alt);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--text);
}

.header-btn-container {
  display: flex;
  gap: 4px;
}

.header-btn-container > button {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.header-btn-container > button:active {
  transform: scale(0.9);
}

/* the light and dark toggle: a moon in light, a sun in dark */
.theme-btn svg {
  width: 17px;
  height: 17px;
}

/* the menu button: three lines, a cross while the menu is open */
.menu-btn svg {
  width: 18px;
  height: 18px;
}

.menu-btn .menu-close,
.menu-btn[aria-expanded="true"] .menu-open {
  display: none;
}

.menu-btn[aria-expanded="true"] .menu-close {
  display: block;
}

/* "/" in the search box, to say it is the key that gets there (desktop only, and gone once the box is in use) */
.search-key {
  display: none;
}

.theme-btn .sun,
:root[data-theme="dark"] .theme-btn .moon {
  display: none;
}

:root[data-theme="dark"] .theme-btn .sun {
  display: block;
}

/* the icons drawn in ink, and the logo's ebony square, show up on a dark screen */
@media screen {
  :root[data-theme="dark"] .header-btn-container img,
  :root[data-theme="dark"] .way-icon img {
    filter: invert(0.92);
  }

  :root[data-theme="dark"] header .logo-mark rect:first-child {
    fill: #2c2825;
  }
}

.search-form input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface) url(/piano-guide/assets/icons/search.svg) no-repeat 14px center;
  background-image: var(--search-icon, url(/piano-guide/assets/icons/search.svg));
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-form input::placeholder {
  color: var(--muted);
}

/* Suggestions as you type (search.js): the best matches, each with its kind, and a link to all of them. On a phone
   they sit under the box in the panel that opens; on a desktop they hang below the box. */
.search-suggest {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}

.search-suggest[hidden] {
  display: none;
}

.suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 0.88rem;
}

.suggest-item strong {
  min-width: 0;
  font-weight: 600;
}

/* "= C♯ major" after D♭ major, when it was found by that spelling */
.search-also {
  font-weight: 400;
  color: var(--muted);
}

/* with nothing typed: a few things to try */
.suggest-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.suggest-hints button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.suggest-hints button:hover,
.suggest-hints button:focus-visible {
  border-color: var(--line-strong);
  background: var(--bg-alt);
  outline: none;
}

.suggest-item:hover,
.suggest-item:focus-visible {
  background: var(--bg-alt);
  outline: none;
}

.search-kind {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.suggest-item:hover .search-kind,
.suggest-item:focus-visible .search-kind {
  background: var(--surface);
}

.suggest-none {
  margin: 0;
  padding: 9px 10px;
  font-size: 0.86rem;
  color: var(--muted);
}

.suggest-all {
  margin-top: 4px;
  padding: 10px 10px 6px;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-ink);
}

.suggest-all::after {
  content: " \203A";
}

.suggest-all:hover,
.suggest-all:focus-visible {
  color: var(--text);
  outline: none;
}

.search-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Section headers */
.section-header {
  margin-bottom: 18px;
}

.section-header h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.section-header p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

/* a key's root note in a circle: filled for a major key, outlined for a minor key. Used on the cards of the
   lists and in the homepage's "Pick a key", where each one is a link */
.key-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.key-badge.is-minor {
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}

a.key-badge {
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

a.key-badge:hover {
  background: var(--strong);
  color: var(--on-strong);
}

a.key-badge.is-minor:hover {
  box-shadow: none;
}

a.key-badge:active {
  transform: scale(0.94);
}

/* a small label over a heading */
.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow-brass {
  color: var(--brass);
}

/* Buttons: one main button per view (felt), the rest quiet */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(150, 38, 34, 0.25), 0 8px 18px -8px rgba(150, 38, 34, 0.5);
}

.btn-quiet {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn:active {
  transform: scale(0.98);
}

/* parts of a page fade up as they come into view (main.js); without JavaScript, or with reduced motion, they are
   simply there */
.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    opacity: 1;
    transform: none;
  }
}

/* a link inside running text */
.text-link {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Footer: lacquered ebony */
footer {
  padding: 40px var(--pad) 28px;
  background: var(--footer);
  color: var(--ebony-text);
}

.footer-top {
  display: grid;
  gap: 28px;
}

footer .logo {
  font-size: 1.15rem;
}

/* the mark's ebony square, a shade lighter so it shows on the ebony */
footer .logo-mark rect:first-child {
  fill: #2c2825;
}

.footer-brand p {
  max-width: 36ch;
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ebony-muted);
}

footer nav ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 24px;
  font-size: 0.92rem;
}

/* a taller line to tap than the words alone */
footer nav a {
  display: inline-block;
  padding: 7px 0;
  color: var(--ebony-text);
  transition: color 0.2s var(--ease);
}

footer a:focus-visible {
  outline-color: var(--ebony-text);
}

.footer-bottom {
  display: grid;
  gap: 6px;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid rgba(250, 250, 249, 0.12);
}

.footer-bottom p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ebony-muted);
}

.footer-bottom a {
  padding: 8px 0; /* taller to tap, without moving the line */
  color: var(--ebony-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

 /* Tablet */
@media (min-width: 768px) {
  :root {
    --pad: 40px;
    --radius: 18px;
  }

  /* Header */
  header {
    padding: 13px var(--pad);
  }

  .logo {
    font-size: 1.4rem;
  }

  /* Section headers */
  .section-header {
    margin-bottom: 24px;
  }

  .section-header h2 {
    font-size: 1.8rem;
  }

  .section-header p {
    font-size: 1rem;
  }

  /* Footer */
  footer {
    padding: 52px var(--pad) 32px;
  }

  .footer-top {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  footer nav ul {
    grid-template-columns: repeat(3, auto);
    gap: 0 40px;
  }

  .footer-bottom {
    grid-template-columns: auto 1fr;
    justify-items: end;
    gap: 24px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  [id] {
    scroll-margin-top: 108px;
  }

  :root {
    --pad: 48px;
    --container: 1200px;
    --gutter: max(var(--pad), calc((100% - var(--container)) / 2));
  }

  /* Header */
  header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    padding: 20px var(--gutter);
  }

  .header-links,
  .search-form {
    position: static;
    padding: 0;
    background: transparent;
    border: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .header-links ul {
    display: flex;
    gap: 32px;
  }

  /* each link as tall as the header row, so it is easy to hit */
  .header-links a {
    position: relative;
    display: block;
    min-height: 0;
    padding: 10px 0;
    border-radius: 0;
    font-size: 0.92rem;
    font-weight: 400;
    color: var(--muted);
    transition: color 0.2s ease;
  }

  .header-links a:active {
    background: none;
  }

  .header-links a[aria-current="page"] {
    background: none;
    box-shadow: none;
    font-weight: 600;
  }

  /* the page you are on: a short felt line under its name */
  .header-links a[aria-current="page"]::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 1px;
    left: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
  }

  .header-btn-container {
    justify-self: end;
  }

  .header-btn-container .search-btn,
  .header-btn-container .menu-btn {
    display: none;
  }

  /* beside the search box, the toggle gets the same height and outline */
  .header-btn-container {
    align-items: center;
    gap: 8px;
  }

  .header-btn-container .theme-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: var(--surface);
  }

  .search-form input {
    width: 220px;
  }

  /* in the header row beside the toggle, holding the suggestions that hang below it. The phone layout's place for
     it (top: 100%, under the header) must not carry over: Safari would move it down by that much. */
  .search-form {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
  }

  @media (hover: hover) and (pointer: fine) {
    .search-key {
      position: absolute;
      top: 50%;
      right: 10px;
      display: grid;
      place-items: center;
      width: 20px;
      height: 20px;
      border: 1px solid var(--line);
      border-radius: 5px;
      background: var(--bg);
      color: var(--muted);
      font: inherit;
      font-size: 0.72rem;
      font-weight: 600;
      line-height: 1;
      pointer-events: none;
      transform: translateY(-50%);
      transition: opacity 0.15s ease;
    }

    .search-form input:focus ~ .search-key,
    .search-form input:not(:placeholder-shown) ~ .search-key {
      opacity: 0;
    }
  }

  .search-suggest {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: max(100%, 400px);
    margin: 0;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-lift);
  }

  /* Section headers */
  .section-header h2 {
    font-size: 2rem;
  }

  /* Footer */
  footer {
    padding: 64px var(--gutter) 36px;
  }
}

/* Small desktops: the menu and the search box sit closer, so all seven menu items fit beside them and the toggle */
@media (min-width: 1024px) and (max-width: 1279px) {
  .header-links ul {
    gap: 16px;
  }

  .search-form input {
    width: 140px;
  }
}

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--accent-deep);
    transform: translateY(-1px);
  }

  .btn-quiet:hover {
    border-color: var(--text);
    transform: translateY(-1px);
  }

  footer nav a:hover {
    color: var(--ebony-muted);
  }
}

@media (min-width: 1024px) and (hover: hover) {
  .header-links a:hover {
    color: var(--text);
  }
}

/* touch: every button at least 44px tall */
@media (pointer: coarse) {
  .btn {
    min-height: 48px;
  }
}