/* Latte Web house style for every demo page.
 *
 * Base element styles live in the `latte-site` cascade layer. Any style a page
 * writes itself is unlayered, so it always wins, whatever its specificity or
 * order: demos keep full control of their own layout.
 *
 * The top bar is unlayered on purpose and uses its own class names, so page
 * resets such as `* { margin: 0; padding: 0 }` cannot flatten it.
 *
 * Demo pages stay light: many demos paint light backgrounds without setting a
 * text colour, and a dark theme would make that text unreadable.
 */

@layer latte-site {
  :root {
    color-scheme: light;
    --latte-bg: #fbf7f2;
    --latte-fg: #2b1d14;
    --latte-muted: #6f5a4a;
    --latte-accent: #8a4b2a;
    --latte-accent-fg: #fffaf4;
    --latte-card: #ffffff;
    --latte-line: #e7dccf;
    --latte-code: #f3ebe1;
    --latte-focus: #c26a35;
    --latte-font:
      system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC',
      'Noto Sans SC', sans-serif;
    --latte-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  }

  html {
    background: var(--latte-bg);
  }

  body {
    font: 17px/1.6 var(--latte-font);
    color: var(--latte-fg);
    background: var(--latte-bg);
  }

  h1 {
    margin: 1.25rem 0 0.75rem;
    font-size: 2rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
  }

  h2 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.3rem;
    line-height: 1.3;
  }

  p {
    margin: 0.5rem 0 1rem;
  }

  a {
    color: var(--latte-accent);
    text-underline-offset: 0.15em;
  }

  code,
  kbd,
  samp,
  pre {
    font-family: var(--latte-mono);
    font-size: 0.9em;
  }

  code {
    padding: 0.1em 0.35em;
    border-radius: 0.3em;
    background: var(--latte-code);
  }

  pre {
    padding: 0.9rem 1rem;
    overflow-x: auto;
    border-radius: 0.5rem;
    background: var(--latte-code);
  }

  pre code {
    padding: 0;
    background: none;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
  }

  /* Only right and bottom margins: positioned demo elements keep their left/top. */
  button {
    margin: 0 0.5rem 0.5rem 0;
    padding: 0.4rem 0.95rem;
    border: 1px solid var(--latte-accent);
    border-radius: 0.5rem;
    background: var(--latte-accent);
    color: var(--latte-accent-fg);
    cursor: pointer;
  }

  button:hover {
    filter: brightness(1.08);
  }

  button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }

  input,
  select,
  textarea {
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--latte-line);
    border-radius: 0.4rem;
    background: var(--latte-card);
    color: var(--latte-fg);
  }

  output {
    display: inline-block;
    margin: 0.25rem 0 0.75rem;
    padding: 0.3rem 0.7rem;
    border-radius: 0.4rem;
    background: var(--latte-code);
    font-family: var(--latte-mono);
  }

  :focus-visible {
    outline: 3px solid var(--latte-focus);
    outline-offset: 2px;
  }

  hr {
    border: 0;
    border-top: 1px solid var(--latte-line);
  }

  /* The one-line summary under the heading of pages built from the catalog. */
  .latte-lead {
    margin-top: -0.25rem;
    color: var(--latte-muted);
    font-size: 1.05rem;
  }
}

/* The page frame is unlayered so that universal resets such as
 * `* { margin: 0; padding: 0 }` do not push content against the window edge.
 * A page's own `body` rules still win: same specificity, and they come later. */
body {
  /* border-box: a page that sets body { width: 100% } must not overflow by the padding. */
  box-sizing: border-box;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* The top bar: brand link to the learning index, and the page's README. */
.latte-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #e7dccf;
  font:
    600 0.9rem/1.4 system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  letter-spacing: 0.01em;
}

/* Pages may style `nav a` (the motion demo makes such links 180 px blocks);
 * the bar keeps its own look. */
.latte-bar a {
  display: inline;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #8a4b2a;
  text-decoration: none;
}

.latte-bar a:hover {
  text-decoration: underline;
}

.latte-bar .latte-home::before {
  content: '';
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.45em;
  vertical-align: -0.08em;
  border-radius: 0.2em 0.2em 0.35em 0.35em;
  background: linear-gradient(#fffaf2 0 25%, #e3c7a4 25% 75%, #6b4226 75% 100%);
  box-shadow: inset 0 0 0 1.5px #2b1d14;
}

.latte-bar .latte-crumb {
  color: #6f5a4a;
  font-weight: 500;
}

.latte-bar .latte-links {
  display: flex;
  gap: 1rem;
  margin-left: auto;
}

/* The guide panel beside a demo (assets/guide.js). Unlayered with its own class
 * names, like the top bar, so page styles for `button` or `li` leave it alone. */
.latte-guide {
  box-sizing: border-box;
  margin: 2rem 0 0;
  padding: 1rem 1.1rem;
  border: 1px solid #e7dccf;
  border-radius: 0.8rem;
  background: #fffdf9;
  color: #2b1d14;
  box-shadow: 0 8px 24px rgb(43 29 20 / 8%);
  font:
    400 0.95rem/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    'PingFang SC',
    'Noto Sans SC',
    sans-serif;
  text-align: left;
}

.latte-guide .latte-guide-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.latte-guide .latte-guide-top .latte-guide-head {
  margin: 0;
}

.latte-guide button.latte-guide-lang {
  margin: 0;
  padding: 0.1rem 0.6rem;
  background: transparent;
  color: #8a4b2a;
  font-size: 0.8rem;
}

@media (min-width: 72rem) {
  /* The demo keeps its own width; the panel takes a fixed column on the right. */
  html.latte-guided body {
    max-width: min(64rem, calc(100% - 26rem));
    margin-left: max(0px, calc((100% - 26rem - 64rem) / 2));
    margin-right: 26rem;
  }

  .latte-guide {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 24rem;
    max-height: calc(100vh - 2rem);
    margin: 0;
    overflow: auto;
  }
}

.latte-guide p,
.latte-guide dl,
.latte-guide ol {
  margin: 0 0 0.6rem;
  padding: 0;
}

.latte-guide .latte-guide-head,
.latte-guide .latte-guide-label {
  color: #6f5a4a;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.latte-guide .latte-guide-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.latte-guide code {
  padding: 0.05em 0.3em;
  border-radius: 0.3em;
  background: #f3ebe1;
  font:
    0.9em ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

.latte-guide button {
  margin: 0 0.5rem 0.6rem 0;
  padding: 0.35rem 0.9rem;
  border: 1px solid #8a4b2a;
  border-radius: 0.5rem;
  background: #8a4b2a;
  color: #fffaf4;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}

.latte-guide button.latte-guide-nav {
  margin-bottom: 0;
  background: transparent;
  color: #8a4b2a;
}

.latte-guide .latte-guide-buttons {
  margin-bottom: 0.8rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid #e7dccf;
}

.latte-guide button:disabled {
  opacity: 0.45;
  cursor: default;
}

.latte-guide .latte-guide-watch {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  align-items: baseline;
  font-size: 0.85rem;
}

.latte-guide .latte-guide-watch dt {
  color: #6f5a4a;
}

.latte-guide .latte-guide-watch dd {
  margin: 0;
  font:
    700 0.95em/1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  overflow-wrap: anywhere;
}

/* The line sits on the console, so a page that prints nothing has no stray rule. */
.latte-guide .latte-guide-console {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid #e7dccf;
}

.latte-guide .latte-guide-lines {
  max-height: 16rem;
  overflow: auto;
  list-style: none;
  font:
    0.82rem/1.45 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

.latte-guide .latte-guide-line {
  margin: 0;
  padding: 0.1rem 0.5rem;
  border-left: 3px solid #e7dccf;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.latte-guide .latte-guide-line.warn {
  border-left-color: #c9a227;
}

.latte-guide .latte-guide-line.error {
  border-left-color: #b3261e;
  color: #b3261e;
}

.latte-guide .latte-guide-line.match {
  border-left-color: #8a4b2a;
  background: #f3ebe1;
}
