/*
 * The LazyFret brand for every surface: the three typefaces, the colour
 * tokens in both themes, and the wordmark and LF mark. BRAND.md says how to
 * use them; change the brand here, not in an app.
 *
 * Import it first in an app (`import '@lazyfret/brand/brand.css'`) and build
 * the app's own styles on the --lf-* tokens. A theme is chosen with
 * data-theme="light" or "dark" on <html>; with neither, the system's choice
 * applies.
 *
 * Fonts are self-hosted (no request to Google), Latin only, which covers
 * English and French. All three are SIL Open Font License; the licences sit
 * beside the files in fonts/.
 */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('./fonts/bricolage-grotesque.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: 'Figtree';
  src: url('./fonts/figtree.woff2') format('woff2');
  font-weight: 300 900;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('./fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

:root {
  /* The five brand colours. These never change with the theme. */
  --lf-teal: #1e4e5c;
  --lf-orange: #d96d2c;
  --lf-cream: #f4efe6; /* a spruce top, not paper white */
  --lf-night: #0b1a20;
  --lf-nickel: #8a9aa0; /* fret wire */

  /* Type. Display is for the wordmark, product names and headings; body is
     everything else; mono is for frets, tab and numbers that line up. */
  --lf-font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --lf-font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --lf-font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;

  --lf-radius: 12px;
  --lf-radius-small: 6px;

  /* Light theme. Pairs checked for contrast (WCAG): text 12.8:1, muted
     4.7:1, teal 8:1 on --lf-bg; white on --lf-accent only for bold text of
     19px and up (3.4:1) - smaller orange text uses --lf-accent-text. */
  --lf-bg: var(--lf-cream);
  --lf-surface: #fffdf9;
  --lf-sunken: #eae3d7;
  --lf-line: #d9d1c3;
  --lf-text: #1a2b30;
  --lf-muted: #5c6e73;
  --lf-heading: var(--lf-teal);
  --lf-primary: var(--lf-teal);
  --lf-on-primary: #ffffff;
  --lf-primary-soft: #2f6b7a; /* a step off primary, for what sits beside it; takes --lf-on-primary */
  --lf-primary-tint: rgba(30, 78, 92, 0.08); /* a wash of primary over a surface */
  --lf-accent: var(--lf-orange);
  --lf-accent-text: #a44a18;
  --lf-on-accent: #ffffff;
  --lf-on-accent-small: var(--lf-night); /* on orange below 19px bold, in both themes */
  --lf-accent-soft: rgba(217, 109, 44, 0.12);
  --lf-focus: var(--lf-accent-text); /* orange itself is 2.97:1 on cream, under 3:1 */
  /* The lamp from the homepage's living room, as a glow behind something. */
  --lf-lamp-core: #ffdfae;
  --lf-lamp-mid: #f6e7cf;
  --lf-lamp-edge: var(--lf-sunken);

  /* Game feedback: right, close and off. Green and amber because players
     read them that way, in LazyFret's own hues, with text that passes on
     each (white 4.8:1 on right, night 8:1 on close). */
  --lf-right: #2a7f6c;
  --lf-on-right: #ffffff;
  --lf-close: #e0a43a;
  --lf-on-close: var(--lf-night);
  --lf-off: #cfc6b6;
  --lf-on-off: var(--lf-text);
  /* The same two as text, e.g. a result heading: darker on light, lighter on dark. */
  --lf-right-text: #236b5b;
  --lf-close-text: #8a5e0e;
  --lf-hard: #a8431f; /* the HARD badge: weekend puzzles */
  --lf-on-hard: #ffffff;

  color-scheme: light;
}

/* Dark theme. The same values twice: once for the system's choice, once for
   an explicit data-theme="dark", so the toggle wins either way. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --lf-bg: var(--lf-night);
    --lf-surface: #11252d;
    --lf-sunken: #08141a;
    --lf-line: #2a4651;
    --lf-text: #e9eeec;
    --lf-muted: #8fa4a9;
    --lf-heading: var(--lf-cream);
    --lf-primary: #5fa8ba;
    --lf-on-primary: var(--lf-night);
    --lf-primary-soft: #8cc3d1;
    --lf-primary-tint: rgba(95, 168, 186, 0.1);
    --lf-accent: #e57a3a;
    --lf-accent-text: #e57a3a;
    --lf-on-accent: var(--lf-night);
    --lf-accent-soft: rgba(229, 122, 58, 0.12);
    --lf-focus: #e57a3a;
    --lf-lamp-core: #8a5526;
    --lf-lamp-mid: #3a2c20;
    --lf-lamp-edge: var(--lf-night);
    --lf-off: #34474e;
    --lf-on-off: #e9eeec;
    --lf-right-text: #4fb39b;
    --lf-close-text: var(--lf-close);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --lf-bg: var(--lf-night);
  --lf-surface: #11252d;
  --lf-sunken: #08141a;
  --lf-line: #2a4651;
  --lf-text: #e9eeec;
  --lf-muted: #8fa4a9;
  --lf-heading: var(--lf-cream);
  --lf-primary: #5fa8ba;
  --lf-on-primary: var(--lf-night);
  --lf-primary-soft: #8cc3d1;
  --lf-primary-tint: rgba(95, 168, 186, 0.1);
  --lf-accent: #e57a3a;
  --lf-accent-text: #e57a3a;
  --lf-on-accent: var(--lf-night);
  --lf-accent-soft: rgba(229, 122, 58, 0.12);
  --lf-focus: #e57a3a;
  --lf-lamp-core: #8a5526;
  --lf-lamp-mid: #3a2c20;
  --lf-lamp-edge: var(--lf-night);
  --lf-off: #34474e;
  --lf-on-off: #e9eeec;
  --lf-right-text: #4fb39b;
  --lf-close-text: var(--lf-close);
  color-scheme: dark;
}

/*
 * The wordmark: "Lazy" set light and "Fret" set heavy, in the display face,
 * one word. <span class="lf-wordmark">Lazy<b>Fret</b></span>
 * A product name follows it at the light weight: LazyFret Daily.
 */
.lf-wordmark {
  font-family: var(--lf-font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--lf-heading);
  white-space: nowrap;
}

.lf-wordmark b {
  font-weight: 800;
}

/*
 * The LF mark, for app headers and anywhere the wordmark won't fit: the
 * letters on Jack's hoodie, in a teal tile. A stand-in until the artwork
 * is redrawn; keep it the same everywhere until then.
 * <span class="lf-mark" aria-hidden="true">LF</span>
 */
.lf-mark {
  display: inline-grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 22%;
  background: var(--lf-teal);
  color: var(--lf-cream);
  font-family: var(--lf-font-display);
  font-weight: 800;
  font-size: 1em;
  letter-spacing: -0.04em;
  line-height: 1;
  flex: none;
  box-shadow: inset 0 -0.12em 0 var(--lf-orange);
}
/*
 * In every app's header the LF mark is the way home, to lazyfret.com (an
 * absolute address, so it also works from inside a phone app):
 * <a class="lf-home" href="https://www.lazyfret.com/" aria-label="LazyFret home"><span class="lf-mark" aria-hidden="true">LF</span></a>
 */
.lf-home {
  display: inline-flex;
  flex: none;
  border-radius: 22%;
  text-decoration: none;
  transition: transform 0.12s ease;
}
.lf-home:hover {
  transform: translateY(-1px);
}
.lf-home:focus-visible {
  outline: 3px solid var(--lf-focus);
  outline-offset: 2px;
}

/* The Stratis Crest endorsement, set the same way in every footer. */
.lf-endorsement {
  font-family: var(--lf-font-body);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lf-muted);
}

/* Privacy, Terms and Credits, above the endorsement in every app's footer. */
.lf-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin-bottom: 6px;
  font-family: var(--lf-font-body);
  font-size: 12px;
}

.lf-legal a { color: var(--lf-muted); }
.lf-legal a:hover { color: var(--lf-text); }

/* Browsers give form controls their own system font; on a LazyFret page
   they speak in the brand's like everything else. */
button,
input,
select,
textarea {
  font-family: inherit;
}

/* Pro controls in a free build (src/locked.ts): in view, marked, and a tap says so. */
.lf-free [data-pro]:not([data-pro="quiet"]) {
  opacity: 0.7;
}
.lf-free [data-pro]:not([data-pro="quiet"]):not(input)::after {
  content: "Pro";
  margin-left: 0.4em;
  padding: 0.05em 0.35em;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: var(--lf-font-mono);
  font-size: 0.65em;
  font-weight: 600;
  vertical-align: 0.1em;
}
.lf-locked-dialog {
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--lf-line);
  border-radius: 12px;
  background: var(--lf-surface);
  color: var(--lf-text);
}
.lf-locked-dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}
.lf-locked-dialog h2 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}
.lf-locked-dialog p {
  margin: 0 0 1rem;
}
.lf-locked-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.lf-locked-actions a {
  color: inherit;
}
.lf-locked-actions button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--lf-line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/*
 * The way between the tools, in Pro: an ellipsis in the header (src/tools.ts).
 */
.lf-menu { position: relative; flex: none; font-family: var(--lf-font-body); }

.lf-menu summary {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--lf-text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  list-style: none;
}

.lf-menu summary::-webkit-details-marker { display: none; }
.lf-menu summary:hover, .lf-menu[open] summary { background: var(--lf-accent-soft); }

.lf-menu nav {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--lf-line);
  border-radius: 10px;
  background: var(--lf-surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

.lf-menu a {
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--lf-text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}

.lf-menu a:hover { background: var(--lf-accent-soft); }
.lf-menu a[aria-current] { color: var(--lf-accent-text); }

/* The one theme choice, for every tool (src/theme.ts). */
.lf-menu-choice { display: grid; gap: 6px; padding: 10px 6px 6px; }
.lf-menu-choice:first-of-type { margin-top: 6px; border-top: 1px solid var(--lf-line); }
.lf-menu-choice span { font-size: 12px; font-weight: 700; color: var(--lf-muted); }
.lf-menu-choice div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 8px; background: var(--lf-sunken); }
.lf-menu-two div { grid-template-columns: repeat(2, 1fr); }
.lf-menu-choice button { padding: 7px 4px; border: 0; border-radius: 6px; background: none; color: var(--lf-text); font: 700 13px var(--lf-font-body); cursor: pointer; }
.lf-menu-choice button[aria-pressed="true"] { background: var(--lf-primary); color: var(--lf-on-primary); }
