/* IRT theme. Mobile first; colours from the Android app (spec: Current system architecture). */
:root {
  --irt-green: #34b63c;
  --irt-green-dark: #1f7a2a;
  --irt-orange: #f77a26;
  --irt-orange-dark: #b3440a;
  --irt-on-accent: #ffffff;
  --irt-snackbar: #323232;
  --irt-khaki: #deddad;
  --irt-text: #1f2a1f;
  --irt-text-muted: #4d5a4d;
  --irt-surface: #ffffff;
  --irt-background: #f7f6ec;
  /* Two-tone focus ring (WCAG technique C40): 9:1 apart, so one of the two reaches 3:1 on any background, the
     green header and the dark snackbar included. The bright orange can't pair with anything at 9:1. */
  --irt-focus-outer: #1f2a1f;
  --irt-focus-inner: #ffffff;
  --irt-radius: 8px;
  --irt-gutter: 16px;
  --irt-max-width: 960px;
  --irt-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--irt-font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--irt-text);
  background: var(--irt-background);
}

a {
  color: var(--irt-green-dark);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--irt-focus-outer);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--irt-focus-inner);
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: var(--irt-gutter);
  top: var(--irt-gutter);
  z-index: 20;
  padding: 8px 12px;
  background: var(--irt-surface);
}

.app-header {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 var(--irt-gutter);
  background: var(--irt-green-dark);
  color: #ffffff;
}

.app-brand {
  color: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  display: block;
}

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

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--irt-khaki);
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
  color: inherit;
  font: inherit;
}

.search-input:focus-visible {
  border-color: var(--irt-green);
  outline: 3px solid var(--irt-focus-outer);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--irt-focus-inner);
}

.search-status {
  margin: 12px 0 0;
}

.search-results {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.search-result a {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  min-height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--irt-khaki);
  color: inherit;
  text-decoration: none;
}

.search-result-meta {
  opacity: 0.75;
}

.tune-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.tune-row a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  min-height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--irt-khaki);
  color: inherit;
  text-decoration: none;
}

.tune-row-key {
  margin-left: auto;
  font-size: 0.8rem;
  opacity: 0.75;
}

.badge-free {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--irt-green-dark);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.pager[hidden] {
  display: none;
}

.tune-list-loading {
  padding: 12px 14px;
  text-align: center;
}

.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: var(--irt-gutter) 0;
  padding: 0;
  list-style: none;
}

.type-card {
  display: block;
  height: 100%;
  padding: 14px 16px;
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
  border-left: 6px solid var(--irt-green);
  box-shadow: 0 1px 3px rgb(0 0 0 / 15%);
  color: inherit;
  text-decoration: none;
}

.type-card:hover {
  border-left-color: var(--irt-orange);
}

.type-card-title {
  margin: 0 0 6px;
  font-size: 1.125rem;
  color: var(--irt-green-dark);
}

.type-card-names {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--irt-text-muted);
  font-size: 0.9375rem;
}

.proverb {
  margin: 24px 0 0;
  padding: 12px 16px;
  border-left: 4px solid var(--irt-orange);
  background: var(--irt-khaki);
  border-radius: var(--irt-radius);
  font-style: italic;
}

.proverb p {
  margin: 0;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--irt-max-width);
  margin: 0 auto;
  padding: var(--irt-gutter);
}

.app-footer {
  padding: var(--irt-gutter);
  font-size: 0.875rem;
  color: var(--irt-text-muted);
  background: var(--irt-khaki);
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
}

.button {
  display: inline-block;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: var(--irt-radius);
  background: var(--irt-orange-dark);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* Snackbar: bottom of the screen, 5 s by default (static/js/snackbar.js). */
.snackbar {
  position: fixed;
  left: var(--irt-gutter);
  right: var(--irt-gutter);
  bottom: var(--irt-gutter);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 12px 12px 16px;
  border-radius: var(--irt-radius);
  background: var(--irt-snackbar);
  color: #ffffff;
  box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
}

.snackbar[hidden] {
  display: none;
}

.snackbar-text {
  flex: 1;
}

.snackbar-close,
.snackbar-action {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--irt-orange);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.snackbar-action:disabled {
  opacity: 0.6;
  cursor: default;
}

/* The update prompt (static/js/pwa.js) sits at the top, so it never covers a snackbar message. */
.update-prompt {
  top: var(--irt-gutter);
  bottom: auto;
  z-index: 11;
}

/* Offline page (static/js/offline-page.js). */
.offline-notice {
  font-weight: 600;
}

.offline-saved-list {
  padding-left: 1.25rem;
}

.offline-saved-list li {
  margin: 8px 0;
}

/* Changes saved on this device wait for their account to sign in again (static/js/offline-account.js). */
.signin-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin: 0;
  padding: 8px var(--irt-gutter);
  background: var(--irt-khaki);
  color: var(--irt-text);
}

.signin-prompt[hidden] {
  display: none;
}

.signin-prompt a {
  font-weight: 600;
}

/* Tune page (static/js/tune-page.js). */
.tune-meta {
  margin: 0 0 12px;
  color: var(--irt-text-muted);
}

.view-toggle {
  display: inline-flex;
  margin-bottom: 12px;
  border: 2px solid var(--irt-green-dark);
  border-radius: var(--irt-radius);
  overflow: hidden;
}

.toggle-button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  background: var(--irt-surface);
  color: var(--irt-green-dark);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.toggle-button[aria-pressed="true"] {
  background: var(--irt-green-dark);
  color: #ffffff;
}

.tune-sheet,
.tune-abc {
  margin: 0 0 16px;
  padding: 8px;
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
  overflow-x: auto;
}

.tune-sheet[hidden],
.tune-abc[hidden] {
  display: none !important;
}

.tune-abc {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.tune-play-row,
.tune-tempo-row {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.tune-play-row [hidden],
.tune-tempo-row [hidden],
.tune-loading[hidden] {
  display: none;
}

.link-button {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--irt-green-dark);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:disabled {
  color: var(--irt-text-muted);
  text-decoration: none;
  cursor: default;
  opacity: 0.5;
}

.tune-credit {
  color: var(--irt-text-muted);
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  :root {
    --irt-gutter: 24px;
  }
}

/* Learn player (static/js/learn-page.js). */
.learn-page [hidden] {
  display: none !important;
}

.learn-heading {
  margin-bottom: 12px;
}

.learn-expanded .learn-heading,
.learn-expanded .view-toggle {
  display: none;
}

.learn-step-row,
.learn-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.learn-nav #next-button {
  margin-left: auto;
}

.learn-step {
  margin: 0;
  font-weight: 600;
}

.learn-arrow {
  min-width: 64px;
  font-size: 1.25rem;
}

.learn-hint {
  margin: 0 0 12px;
  color: var(--irt-text-muted);
}

.learn-paywall {
  margin: 0 0 16px;
  padding: 16px;
  border: 2px solid var(--irt-orange);
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
}

.learn-instrument select {
  min-height: 44px;
  margin-left: 8px;
  font: inherit;
}

/* Header navigation, bookmark markers and My Tunebook (static/js/tunebook-*.js). */
.app-header {
  justify-content: space-between;
  gap: 12px;
}

.app-nav a {
  display: inline-block;
  padding: 10px 4px;
  color: inherit;
  font-weight: 600;
}

.bookmark,
.tune-bookmark {
  color: var(--irt-orange-dark);
  font-weight: 600;
}

.tune-bookmark {
  margin: 0 0 12px;
}

.tunebook-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.tunebook-row {
  position: relative;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border-bottom: 1px solid var(--irt-khaki);
}

.tunebook-row-content {
  flex: 1;
  min-width: 0;
  touch-action: pan-y;
  transition: transform 0.15s ease-out;
}

.tunebook-link {
  display: block;
  min-height: 56px;
  padding: 10px 14px;
  color: inherit;
  text-decoration: none;
}

.tunebook-name,
.tunebook-meta {
  display: block;
}

.tunebook-name {
  font-weight: 600;
}

.tunebook-meta {
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--irt-text-muted);
}

.tunebook-bar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--irt-khaki);
}

.tunebook-bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--irt-green-dark);
}

.tunebook-remove,
.tunebook-danger {
  min-width: 88px;
  min-height: 44px;
  border: 0;
  background: #c62828;
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tunebook-remove {
  align-self: center;
  margin: 0 8px;
  border-radius: var(--irt-radius);
}

/* Touch screens: Remove sits behind the row and a swipe to the left slides the row aside. */
@media (hover: none) {
  .tunebook-remove {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    border-radius: 0;
  }

  .tunebook-row-content {
    position: relative;
    background: var(--irt-background);
  }

  .tunebook-row-swiped .tunebook-row-content {
    transform: translateX(-88px);
  }
}

.tunebook-tip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 4px 12px;
  border: 1px solid var(--irt-khaki);
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
}

.tunebook-tip[hidden] {
  display: none;
}

.tunebook-error {
  color: #c62828;
}

.tunebook-dialog {
  max-width: 420px;
  border: 0;
  border-radius: var(--irt-radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 30%);
}

.tunebook-dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.tunebook-dialog .tunebook-danger {
  border-radius: var(--irt-radius);
}

/* Sign-in and account pages (M4.1). */
.auth-page {
  max-width: 420px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  min-height: 44px;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 1px solid var(--irt-text-muted);
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
  color: var(--irt-text);
  font: inherit;
}

.auth-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.auth-form .button {
  align-self: flex-start;
}

.auth-hint {
  margin: -4px 0 8px;
  color: var(--irt-text-muted);
  font-size: 0.875rem;
}

.auth-notice {
  padding: 12px 16px;
  border: 1px solid var(--irt-text-muted);
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
}

/* Pricing (M5.2) */
.pricing-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.pricing-plan {
  padding: 16px;
  border: 1px solid var(--irt-text-muted);
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
}

.pricing-plan-featured {
  border-width: 3px;
}

.pricing-badge {
  margin: 0;
  font-weight: bold;
}

.pricing-price {
  margin: 8px 0 16px;
  font-size: 2.5rem;
  line-height: 1.1;
}

.pricing-price small {
  font-size: 1rem;
}

.pricing-note {
  font-size: 0.9rem;
}

.auth-error {
  padding: 12px 16px;
  border: 1px solid #b3261e;
  border-radius: var(--irt-radius);
  background: var(--irt-surface);
  color: #b3261e;
}
