/* ==========================================================================
   Larsa — layouts

   Four shells: the public site, the signed-in app (console and admin share
   it), the docs, and the centred auth card. Each is a grid, and each collapses
   to one column below the same breakpoint so there is a single place to reason
   about small screens.
   ========================================================================== */

/* ── Shared containers ─────────────────────────────────────────────────── */

.wrap        { inline-size: 100%; max-inline-size: var(--content); margin-inline: auto; padding-inline: var(--s-5); }
.wrap--wide  { max-inline-size: var(--content-wide); }
.wrap--full  { max-inline-size: var(--content-full); }
.wrap--prose { max-inline-size: var(--content-prose); }
.wrap--narrow{ max-inline-size: var(--content-narrow); }

@media (min-width: 48rem) { .wrap { padding-inline: var(--s-7); } }

/* ══════════════════════════════════════════════════════════════════════════
   1. Public site
   ══════════════════════════════════════════════════════════════════════════ */

.site { display: flex; flex-direction: column; min-block-size: 100dvh; }
.site__main { flex: 1 1 auto; }

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-nav);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-block-end: 1px solid transparent;
  transition: border-color var(--dur-base) var(--ease-out),
              background var(--dur-base) var(--ease-out);
}
/* The rule under the header only appears once the page has moved, so the hero
   meets the header edge-to-edge at rest. */
.site-header.is-stuck { border-block-end-color: var(--border); }
@supports not (backdrop-filter: blur(1px)) { .site-header { background: var(--bg); } }

.site-header__inner {
  display: flex; align-items: center; gap: var(--s-6);
  block-size: var(--topbar-h);
}
.site-nav { display: none; align-items: center; gap: var(--s-1); }
.site-nav__link {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: var(--fw-med);
  text-decoration: none;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.site-nav__link:hover { color: var(--text-strong); background: var(--surface-hover); }
.site-nav__link[aria-current] { color: var(--text-strong); }
.site-header__end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s-2); min-inline-size: 0; }

@media (min-width: 62rem) {
  .site-nav { display: flex; }
  .site-header__burger { display: none; }
}

/* On a phone the header ran past the viewport by about twenty pixels and the
   whole document scrolled sideways. The theme and language switches are the
   ones to drop: both are also in the footer and in the drawer, while the brand,
   the primary action and the menu button have nowhere else to be. */
@media (max-width: 30rem) {
  .site-header__end > [data-theme-toggle],
  .site-header__end > [data-lang-menu] { display: none; }
  .site-header__inner { gap: var(--s-3); }
}

.site-drawer {
  position: fixed; inset-block-start: var(--topbar-h); inset-inline: 0; inset-block-end: 0;
  z-index: var(--z-nav);
  background: var(--bg);
  padding: var(--s-5);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s-2);
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.site-drawer[hidden] { display: none; }
.site-drawer .site-nav__link { font-size: var(--fs-base); padding: var(--s-3); }

.site-footer {
  border-block-start: 1px solid var(--border);
  padding-block: var(--s-9) var(--s-7);
  margin-block-start: var(--s-12);
  background: var(--bg-subtle);
}
.site-footer__grid {
  display: grid; gap: var(--s-8);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
}
.site-footer__brand { grid-column: 1 / -1; max-inline-size: 22rem; }
@media (min-width: 62rem) { .site-footer__brand { grid-column: auto; } }
.site-footer__title { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); font-weight: var(--fw-semi); margin-block-end: var(--s-3); }
.site-footer__list { display: flex; flex-direction: column; gap: var(--s-2); list-style: none; padding: 0; }
.site-footer__list a { color: var(--text-muted); font-size: var(--fs-sm); text-decoration: none; }
.site-footer__list a:hover { color: var(--text); }
.site-footer__bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-block-start: var(--s-8);
  padding-block-start: var(--s-5);
  border-block-start: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-faint);
}

/* ══════════════════════════════════════════════════════════════════════════
   2. App shell — console and admin
   ══════════════════════════════════════════════════════════════════════════ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-block-size: 100dvh;
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar {
  position: sticky;
  inset-block-start: 0;
  block-size: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-subtle);
  border-inline-end: 1px solid var(--border);
  overflow: hidden;
}
.sidebar__head {
  display: flex; align-items: center; gap: var(--s-3);
  block-size: var(--topbar-h);
  padding-inline: var(--s-4);
  flex-shrink: 0;
}
.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: var(--s-3) var(--s-3) var(--s-6); }
.sidebar__foot { flex-shrink: 0; padding: var(--s-3); border-block-start: 1px solid var(--border); }

.nav-group + .nav-group { margin-block-start: var(--s-5); }
.nav-group__label {
  padding: var(--s-1) var(--s-3) var(--s-2);
  font-size: var(--fs-3xs); font-weight: var(--fw-semi);
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: var(--text-faint);
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: var(--fw-med);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-item + .nav-item { margin-block-start: 1px; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item svg { inline-size: 1.05rem; block-size: 1.05rem; flex-shrink: 0; opacity: 0.75; }
.nav-item__text { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The label wins the row. A "Paid" pill beside "Knowledge bases" pushed the
   label into an ellipsis -- the nav read "Knowledge b..." in English and
   "Bases de conoci..." in Spanish, while the pill sat there at full width.
   In the sidebar the pill collapses to a dot: the signal survives, the
   destination stays readable, and the word itself is on the page it leads to.
   The accessible name is kept, so a screen reader still hears "Paid". */
.nav-item { padding-inline: var(--s-2); gap: var(--s-2); }
.nav-item .lock-pill {
  flex: 0 0 auto;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  padding: 0;
  border-radius: var(--r-full);
  background: var(--warning);
  border-color: transparent;
  overflow: hidden;
  text-indent: -100vw;          /* keeps the text for assistive tech */
  white-space: nowrap;
}
.nav-item__meta { font-size: var(--fs-2xs); color: var(--text-faint); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.nav-item[aria-current="page"] {
  background: var(--surface); color: var(--text-strong);
  box-shadow: var(--shadow-xs);
}
.nav-item[aria-current="page"] svg { opacity: 1; color: var(--accent); }
/* The seal rule, third and last use. */
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block: 22%;
  inline-size: 3px;
  border-radius: var(--r-full);
  background: var(--accent-line);
}

.app[data-sidebar="collapsed"] .nav-item__text,
.app[data-sidebar="collapsed"] .nav-item__meta,
.app[data-sidebar="collapsed"] .nav-group__label,
.app[data-sidebar="collapsed"] .sidebar__head .brand__name,
.app[data-sidebar="collapsed"] .org-switch__body { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; padding-inline: 0; }

.org-switch {
  display: flex; align-items: center; gap: var(--s-3);
  inline-size: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  text-align: start;
  transition: border-color var(--dur-fast);
}
.org-switch:hover { border-color: var(--border-hover); }
.org-switch__body { flex: 1 1 auto; min-inline-size: 0; display: flex; flex-direction: column; }
.org-switch__name { font-size: var(--fs-sm); font-weight: var(--fw-med); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-switch__sub { font-size: var(--fs-2xs); color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app__main { display: flex; flex-direction: column; min-inline-size: 0; }

.topbar {
  position: sticky; inset-block-start: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s-3);
  block-size: var(--topbar-h);
  padding-inline: var(--s-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-block-end: 1px solid var(--border);
  flex-shrink: 0;
}
@supports not (backdrop-filter: blur(1px)) { .topbar { background: var(--bg); } }
.topbar__title { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--text-strong); }
.topbar__end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s-2); }

.content { flex: 1 1 auto; padding: var(--s-7) var(--s-5) var(--s-11); min-inline-size: 0; }
@media (min-width: 62rem) { .content { padding-inline: var(--s-7); } }
.content__inner { max-inline-size: var(--content-wide); margin-inline: auto; }
.content--full .content__inner { max-inline-size: none; }
.content--narrow .content__inner { max-inline-size: var(--content); }

/* Below the breakpoint the sidebar becomes an overlay drawer. */
@media (max-width: 61.999rem) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: var(--sidebar-w);
    z-index: var(--z-dialog);
    box-shadow: var(--shadow-xl);
    transform: translateX(-105%);
    transition: transform var(--dur-base) var(--ease-out);
  }
  :root[dir="rtl"] .sidebar { transform: translateX(105%); }
  .app[data-sidebar="open"] .sidebar { transform: none; }
  .app[data-sidebar="open"] .sidebar__scrim {
    content: ""; position: fixed; inset: 0;
    background: var(--overlay); z-index: calc(var(--z-dialog) - 1);
  }
  .topbar__burger { display: inline-grid; }
}
@media (min-width: 62rem) { .topbar__burger { display: none; } .sidebar__scrim { display: none; } }

/* ══════════════════════════════════════════════════════════════════════════
   3. Docs
   ══════════════════════════════════════════════════════════════════════════ */

.docs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-8);
  max-inline-size: var(--content-full);
  margin-inline: auto;
  padding-inline: var(--s-5);
  align-items: start;
}
@media (min-width: 62rem) {
  .docs { grid-template-columns: var(--docs-nav-w) minmax(0, 1fr); padding-inline: var(--s-7); }
}
@media (min-width: 82rem) {
  .docs { grid-template-columns: var(--docs-nav-w) minmax(0, 1fr) var(--docs-toc-w); }
}

.docs__nav {
  position: sticky;
  inset-block-start: calc(var(--topbar-h) + var(--s-4));
  max-block-size: calc(100dvh - var(--topbar-h) - var(--s-8));
  overflow-y: auto;
  padding-block: var(--s-6);
  padding-inline-end: var(--s-3);
  display: none;
}
@media (min-width: 62rem) { .docs__nav { display: block; } }

.docs__body { padding-block: var(--s-6) var(--s-12); min-inline-size: 0; }

.docs__toc {
  position: sticky;
  inset-block-start: calc(var(--topbar-h) + var(--s-4));
  max-block-size: calc(100dvh - var(--topbar-h) - var(--s-8));
  overflow-y: auto;
  padding-block: var(--s-6);
  display: none;
}
@media (min-width: 82rem) { .docs__toc { display: block; } }

.toc__title { font-size: var(--fs-3xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); font-weight: var(--fw-semi); margin-block-end: var(--s-3); }
.toc__list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); border-inline-start: 1px solid var(--border); }
.toc__link {
  display: block;
  padding: var(--s-1) var(--s-3);
  margin-inline-start: -1px;
  border-inline-start: 1px solid transparent;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-decoration: none;
  line-height: var(--lh-snug);
}
.toc__link:hover { color: var(--text); }
.toc__link.is-active { color: var(--accent); border-inline-start-color: var(--accent); font-weight: var(--fw-med); }
.toc__link--sub { padding-inline-start: var(--s-6); }

/* ── Prose ─────────────────────────────────────────────────────────────────
   Docs body copy. Sized off --fs-base rather than the UI's --fs-md, because
   long-form reading and a dense table want different sizes and this is the
   only place in the product that is long-form.
   ──────────────────────────────────────────────────────────────────────── */

.prose { font-size: var(--fs-base); line-height: var(--lh-body); color: var(--text); max-inline-size: var(--content-prose); }
.prose > * + * { margin-block-start: var(--s-5); }
.prose h2 {
  font-size: var(--fs-2xl); margin-block-start: var(--s-10);
  padding-block-end: var(--s-3); border-block-end: 1px solid var(--border);
  scroll-margin-block-start: calc(var(--topbar-h) + var(--s-5));
}
.prose h3 { font-size: var(--fs-xl); margin-block-start: var(--s-8); scroll-margin-block-start: calc(var(--topbar-h) + var(--s-5)); }
.prose h4 { font-size: var(--fs-lg); margin-block-start: var(--s-6); scroll-margin-block-start: calc(var(--topbar-h) + var(--s-5)); }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-block-start: var(--s-4); }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose li + li { margin-block-start: var(--s-2); }
.prose li > ul, .prose li > ol { margin-block-start: var(--s-2); }
.prose .code { margin-block: var(--s-6); max-inline-size: none; }
.prose table { font-size: var(--fs-sm); margin-block: var(--s-6); }
.prose img { border-radius: var(--r-lg); border: 1px solid var(--border); }
.prose > .alert { margin-block: var(--s-6); }

/* The anchor beside a heading. Invisible until the heading is hovered or the
   link itself is focused, so it never competes with the heading at rest. */
.anchor {
  display: inline-block;
  margin-inline-start: var(--s-2);
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
:is(h2, h3, h4):hover > .anchor, .anchor:focus-visible { opacity: 1; }

.docs-nav__group + .docs-nav__group { margin-block-start: var(--s-5); }
.docs-nav__label { font-size: var(--fs-3xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); font-weight: var(--fw-semi); padding-inline: var(--s-3); margin-block-end: var(--s-2); }
.docs-nav__link {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.docs-nav__link svg { inline-size: 1rem; block-size: 1rem; flex-shrink: 0; opacity: 0.7; }
.docs-nav__link:hover { background: var(--surface-hover); color: var(--text); }
.docs-nav__link[aria-current="page"] svg { opacity: 1; }
.docs-nav__link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-fg); font-weight: var(--fw-med); }

.docs-pager { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); margin-block-start: var(--s-10); padding-block-start: var(--s-6); border-block-start: 1px solid var(--border); }
.docs-pager__link { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); text-decoration: none; transition: border-color var(--dur-fast), background var(--dur-fast); }
.docs-pager__link:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.docs-pager__dir { font-size: var(--fs-2xs); color: var(--text-faint); }
.docs-pager__title { font-weight: var(--fw-med); color: var(--text-strong); }
.docs-pager__link--next { text-align: end; }

/* ══════════════════════════════════════════════════════════════════════════
   4. Auth
   ══════════════════════════════════════════════════════════════════════════ */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-block-size: 100dvh;
}
@media (min-width: 68rem) { .auth { grid-template-columns: minmax(0, 1fr) 26rem; } }

.auth__main { display: flex; flex-direction: column; justify-content: center; padding: var(--s-7) var(--s-5) var(--s-9); }
.auth__card { inline-size: 100%; max-inline-size: 24rem; margin-inline: auto; }
.auth__head { margin-block-end: var(--s-7); }
.auth__title { font-size: var(--fs-2xl); font-weight: var(--fw-semi); letter-spacing: var(--tracking-tight); }
.auth__sub { color: var(--text-muted); font-size: var(--fs-sm); margin-block-start: var(--s-2); }
.auth__foot { margin-block-start: var(--s-6); font-size: var(--fs-sm); color: var(--text-muted); text-align: center; }

/* The aside is decoration; it is the first thing to go when the viewport is
   narrow, and it carries no information that is not also in the form. */
.auth__aside {
  display: none;
  position: relative;
  padding: var(--s-9) var(--s-7);
  background: var(--bg-subtle);
  border-inline-start: 1px solid var(--border);
  overflow: hidden;
  flex-direction: column;
  justify-content: center;
}
@media (min-width: 68rem) { .auth__aside { display: flex; } }
.auth__aside::before {
  content: "";
  position: absolute;
  inset-block-start: -30%;
  inset-inline-start: -20%;
  inline-size: 140%; block-size: 90%;
  background: radial-gradient(ellipse at 50% 100%,
              color-mix(in srgb, var(--sun-1) 30%, transparent) 0%,
              transparent 62%);
  pointer-events: none;
}
.auth__quote { position: relative; font-size: var(--fs-lg); line-height: var(--lh-snug); color: var(--text); max-inline-size: 22rem; }
.auth__attrib { position: relative; margin-block-start: var(--s-5); font-size: var(--fs-xs); color: var(--text-muted); }

/* ── Split layout used by settings-style pages ─────────────────────────── */

.split { display: grid; gap: var(--s-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 62rem) { .split { grid-template-columns: 15rem minmax(0, 1fr); gap: var(--s-9); } }
.split__aside { position: sticky; inset-block-start: calc(var(--topbar-h) + var(--s-5)); }
