/* split-view.css — the shared adaptive list-detail kit (askblitz-24f2585b8b50efac).
 *
 * Canonical copy: /home/ainur/Apps/.tools/split-phone/split-view.css
 * The pattern is the spolia of two sources, both cited in the rule library
 * (.ainur/SPOLIA/split-phone/rules.jsonl):
 *   - Android Developers, "Canonical layouts" (list-detail):
 *     "The layout divides the app window into two side-by-side panes: one for the
 *      list, one for the detail."
 *   - Apple Human Interface Guidelines, "Layout":
 *     "A consistent layout that adapts across display sizes, orientations, and
 *      multitasking configurations helps people understand and enjoy your app or
 *      game on all their devices."
 *
 * Breakpoints follow the Android window size classes: compact < 600px,
 * medium 600-839px, expanded >= 840px. Safe-area insets follow the iOS
 * notched-display rules. Motion has reduced-motion parity.
 *
 * Two layers:
 *   1. A page baseline, so ANY page that links this file reserves the device safe
 *      area on the inline axis and honours reduced motion.
 *   2. The .sv component, the list-detail grammar the Mobbin corpus shows.
 *
 * Markup contract:
 *   <div class="sv" data-split-view>
 *     <nav class="sv-list" aria-label="...">  ...list items... </nav>
 *     <section class="sv-detail" tabindex="-1" aria-live="polite"> ...detail... </section>
 *   </div>
 * A compact-width back control is provided by split-view.js and rendered into
 * .sv-detail as <button class="sv-back">.
 */

/* ------------------------------------------------------------------ page baseline */

:root {
  --sv-safe-t: env(safe-area-inset-top, 0px);
  --sv-safe-b: env(safe-area-inset-bottom, 0px);
  --sv-safe-l: env(safe-area-inset-left, 0px);
  --sv-safe-r: env(safe-area-inset-right, 0px);
}

/* The page reserves the device safe area on the inline axis. In a split-screen half
 * or a notched landscape display that is the edge the content can actually reach, so
 * the page never runs under a rounded corner or a sensor housing. */
html {
  padding-left: var(--sv-safe-l);
  padding-right: var(--sv-safe-r);
}

/* Motion explains state continuity only, and it is disabled when the reader asks
 * for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ .sv component */

.sv {
  --sv-compact-max: 599px;
  --sv-medium-max: 839px;
  --sv-gap: 16px;
  --sv-motion: 180ms;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "detail";
  min-height: 0;
  padding-top: var(--sv-safe-t);
  padding-bottom: var(--sv-safe-b);
}

.sv-list,
.sv-detail {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-left: var(--sv-safe-l);
  padding-right: var(--sv-safe-r);
}

.sv-list { grid-area: list; }
.sv-detail { grid-area: detail; }

/* Compact (phone, portrait): one pane at a time. The list is shown first; the
 * detail takes over the pane and a back control returns to the list. */
@media (max-width: 599px) {
  .sv {
    grid-template-areas: "list";
  }
  .sv[data-split-state="detail"] {
    grid-template-areas: "detail";
  }
  .sv[data-split-state="detail"] .sv-list {
    display: none;
  }
  .sv[data-split-state="list"] .sv-detail {
    display: none;
  }
  .sv-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    margin: 0 0 8px;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
  }
  .sv-back[hidden] { display: none; }
}

/* Medium (tablet, split-screen half, landscape phone): list and detail
 * side by side. This is the canonical list-detail layout. */
@media (min-width: 600px) {
  .sv {
    grid-template-columns: minmax(220px, 320px) 1fr;
    grid-template-areas: "list detail";
    gap: var(--sv-gap);
  }
  .sv-back { display: none; }
}

/* Expanded (large tablet, desktop): list, detail and an optional rail. */
@media (min-width: 840px) {
  .sv {
    grid-template-columns: minmax(240px, 340px) 1fr;
  }
  .sv[data-split-rail="on"] {
    grid-template-columns: minmax(240px, 340px) 1fr minmax(240px, 320px);
    grid-template-areas: "list detail rail";
  }
  .sv-rail {
    grid-area: rail;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding-left: var(--sv-safe-l);
    padding-right: var(--sv-safe-r);
  }
}

/* Every interactive control keeps a 44px minimum target (iOS HIG minimum). */
.sv button,
.sv a,
.sv [role="button"],
.sv [role="tab"] {
  min-height: 44px;
}

/* The list is a list of things; keep the rows reachable and legible. */
.sv-list [role="listitem"] + [role="listitem"] {
  border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}
