/*! Meridian UI app v0.1.0 | MIT | every class is mk- namespaced */
/* @meridian/app — application shell layout.
   Separate from core because it is opinionated about page structure:
   a fixed header over a sidebar + scrolling main. Apps with their own
   chrome should take @meridian/core alone. */
@layer meridian.components {
  .mk-app {
    height: 100vh;
    display: grid;
    grid-template-rows: var(--header-h) 1fr;
    overflow: hidden;
  }

  .mk-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 10px 0 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: var(--z-header);
  }

  .mk-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 8px 4px 6px;
    border-radius: var(--r-md);
    text-decoration: none;
    color: inherit;
  }
  .mk-brand:hover { background: var(--surface-3); }

  .mk-mark {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    background: linear-gradient(150deg, var(--accent), var(--epic));
    display: grid;
    place-items: center;
    color: #fff;
    flex: none;
  }
  .mk-mark svg {
    width: 14px;
    height: 14px;
    stroke: #fff;
    stroke-width: 2.2;
    fill: none;
  }

  .mk-wordmark {
    font-family: var(--font-brand);
    font-size: 17px;
    letter-spacing: .01em;
    font-weight: 600;
  }

  .mk-header-search {
    position: relative;
    flex: 1;
    max-width: 380px;
    margin-left: 6px;
  }
  .mk-header-search .mk-ic {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
  }
  .mk-header-search input {
    width: 100%;
    height: 32px;
    padding: 0 46px 0 31px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--text);
  }
  .mk-header-search input:hover { background: var(--surface-3); }
  .mk-header-search input:focus {
    background: var(--surface);
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .mk-header-search .mk-kbd {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
  }

  .mk-header-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
  }

  /* `auto`, not `var(--nav-w)`: the Sidebar owns its own width and animates it,
     so the shell had to be told the collapsed state to keep a second copy of the
     same fact in step. It no longer is. */
  .mk-shell {
    display: grid;
    grid-template-columns: auto 1fr;
    min-height: 0;
  }

  .mk-main {
    overflow: auto;
    min-width: 0;
    position: relative;
  }

  .mk-view { display: none; }
  .mk-view.is-active { display: block; }
}

/* The sidebar used to live here as `.mk-nav*`. It moved to @meridian/core as
   `Sidebar` when it became a component: a collapsible vertical nav is the same
   control in a docs site or an admin panel, which is the reusability test this
   project applies — and it is the same move `.mk-crumbs` made for Breadcrumbs.
   What stayed behind is the page-level layout below. */
@layer meridian.components {
  .mk-page {
    padding: 20px 24px 56px;
    max-width: 1320px;
  }

  /* The trail itself moved to core — it is the same control anywhere. What
     stays here is where the page puts it. */
  .mk-page .mk-crumbs { margin-bottom: 8px; }

  .mk-page-head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
  .mk-page-title {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 660;
    letter-spacing: -.012em;
  }
  .mk-page-sub {
    margin: 4px 0 0;
    color: var(--text-2);
    font-size: var(--fs-sm);
    max-width: 62ch;
  }
  .mk-page-actions {
    margin-left: auto;
    display: flex;
    gap: var(--space-2);
    align-items: center;
  }
}

@layer meridian.components {
  /* The two-column "saved views + content" layout used to live here as
     `.mk-filters-layout` with a media query. It is `.mk-aside` in core now — the
     same control in any two-column page — and what stayed behind is the rail's
     own look. */
  .mk-saved-rail { position: sticky; top: 0; }
  /* Stuck to the top only while there is a column to stick in. `.mk-aside` is a
     container, so this asks about the layout rather than about the window. */
  /* Once the aside has wrapped, the rail is full width and sticking it to the top
     would park it over the content. `.mk-aside` is a query container for exactly
     this: a descendant asking about the layout it is in. */
  @container (max-width: 480px) {
    .mk-saved-rail { position: static; }
  }
  .mk-rail-group { margin-bottom: 16px; }

  /* The rail borrowed the sidebar's `.mk-nav-label` for its headings until the
     sidebar became a core component. Reaching into another component's
     vocabulary is what made that a breaking change, so it owns this now. */
  .mk-rail-label {
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 8px 5px;
    white-space: nowrap;
  }

  .mk-rail-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 8px;
    border: 0;
    background: none;
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    color: var(--text-2);
    text-align: left;
    cursor: pointer;
  }
  .mk-rail-item .mk-ic { width: 14px; height: 14px; color: var(--text-3); flex: none; }
  .mk-rail-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mk-rail-item:hover { background: var(--surface-3); color: var(--text); }
  .mk-rail-item.is-on {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 620;
  }
  .mk-rail-item.is-on .mk-ic { color: var(--accent); }

  .mk-rail-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    color: var(--text-3);
  }

}

@layer meridian.components {
  /* This file used to re-lay-out the sidebar, the shell and the field rows on
     the window's width. All three now answer their own container: `Sidebar`'s
     `railBelow`, `.mk-shell`'s `auto 1fr`, and `.mk-field-row`'s `auto-fit`.
     What is left is the two rules that are genuinely about the window. */
  @media (max-width: 720px) {
    .mk-header-search { max-width: none; }
    .mk-wordmark { display: none; }
    .mk-page { padding: 16px 14px 48px; }
  }
}
