/* Lonestar Trace — mobile layout corrections.
   Loaded after the generated bundle. Deliberately unlayered: the bundle keeps
   everything in @layer tokens/base/components/utilities, and unlayered rules
   outrank every layer, so these win without specificity games. */

/* ---------------------------------------------------------------- app bar */

.lt-appbar,
.lt-scrim {
  display: none;
}

@media (max-width: 768px) {
  body.lt-has-shell .lt-appbar {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    position: sticky;
    top: 0;
    /* above the scrim, so the burger stays visible and tappable as the
       close control while the drawer is open */
    z-index: 80;
    height: 56px;
    padding: 0 var(--s-4) 0 var(--s-2);
    background: var(--bg-rail);
    border-bottom: 1px solid #ffffff1f;
  }

  .lt-burger {
    display: grid;
    place-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    padding: 0;
    background: none;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
  }

  .lt-burger:hover {
    background: #ffffff12;
  }

  .lt-burger i {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-on-rail);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .16s;
  }

  body.lt-nav-open .lt-burger i:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  body.lt-nav-open .lt-burger i:nth-child(2) {
    opacity: 0;
  }

  body.lt-nav-open .lt-burger i:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .lt-appbar .brand {
    padding: 0;
    border: 0;
    gap: var(--s-2);
  }

  .lt-appbar .brand b {
    font-size: 1.05rem;
  }

  /* current page, echoed next to the wordmark so the bar is not just chrome */
  .lt-appbar-here {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: .62rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #7c838f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40%;
  }

  .lt-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: #0c0d0dad;
    opacity: 0;
    pointer-events: none;
    transition: opacity .26s;
  }

  body.lt-nav-open .lt-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  body.lt-nav-open {
    overflow: hidden;
  }

  /* ------------------------------------------------------------- drawer */

  /* the bundle flattens .rail into a wrapping blob at this width; restore it
     as a real off-canvas panel */
  body.lt-has-shell .rail {
    position: fixed;
    /* starts below the app bar so the bar is never occluded */
    inset: 56px auto 0 0;
    z-index: 70;
    width: min(86vw, 320px);
    height: auto;
    padding: var(--s-4) var(--s-3) var(--s-5);
    gap: var(--s-4);
    flex-flow: column nowrap;
    align-items: stretch;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: 0 0 40px #00000059;
    transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility .26s;
  }

  body.lt-has-shell.lt-nav-open .rail {
    transform: none;
    visibility: visible;
  }

  /* the app bar already carries the wordmark */
  .rail .brand {
    display: none;
  }

  .rail-group {
    flex-flow: column nowrap;
  }

  /* group headings are the only thing separating Overview / Plant / Stations */
  .rail-label {
    display: block;
  }

  .rail-link {
    min-height: 48px;
  }

  .rail .btn {
    width: 100%;
  }

  .rail .meta {
    padding: 0 var(--s-3);
    overflow-wrap: anywhere;
  }

  .shell {
    min-height: calc(100dvh - 56px);
    /* the drawer is position:fixed, so it no longer occupies a grid row.
       Without this, grid's default stretch splits the leftover height
       between the remaining rows and the demo banner balloons on tall
       windows. Pack to the top instead. */
    align-content: start;
  }

  /* ------------------------------------------------------ other elements */

  .demo-banner {
    padding: var(--s-2) var(--s-4);
    font-size: .66rem;
    line-height: 1.4;
  }

  .main {
    padding: var(--s-5) var(--s-4) var(--s-7);
  }

  .page-head {
    align-items: flex-start;
    gap: var(--s-3);
  }

  /* horizontal scrollers: keep the gesture inside the element and drop the
     scrollbar gutter that eats a row of pixels on small screens */
  .table-wrap,
  .tabs {
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .table-wrap::-webkit-scrollbar,
  .tabs::-webkit-scrollbar {
    display: none;
  }

  /* table cell actions were 14–20px tall — under the 24px AA minimum.
     flex-start keeps the label on the cell's first baseline while the box
     grows downward, so the tap area is 44px without knocking the row's
     columns out of alignment. */
  td a,
  td .link-button {
    display: inline-flex;
    align-items: flex-start;
    min-height: 44px;
  }

  /* inline prose links keep their flow, just enough padding to clear 24px */
  .card-sub a {
    display: inline-block;
    padding-block: 6px;
  }

  .sticky-submit {
    padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px));
  }
}

/* narrow phones: claw back the card gutter */
@media (max-width: 400px) {
  .card {
    padding: var(--s-4);
  }

  .card > h2 {
    margin: calc(var(--s-4) * -1) calc(var(--s-4) * -1) var(--s-4);
    padding: var(--s-3) var(--s-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail,
  .lt-scrim,
  .lt-burger i {
    transition: none;
  }
}
