/* ============================================================
   ToyBin Loop — shared components + mobile chrome
   Loaded after styles.css on every page. Desktop refinements
   live in desktop.css. Breakpoint matches styles.css (920px).
   ============================================================ */

/* ---------- Shared loop components (all widths) ---------- */

/* Stat strip: the one-glance state of the collection (dashboard) */
.lp-statstrip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin: 0 0 1.2rem;
}
.lp-ring { position: relative; width: 104px; height: 104px; flex: none; }
.lp-ring svg { transform: rotate(-90deg); display: block; }
.lp-ring .lp-track { stroke: var(--surface-2); }
.lp-ring .lp-meter { stroke: var(--primary); stroke-linecap: round; }
.lp-ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.lp-ring-label b { font-size: 1.3rem; line-height: 1; }
.lp-ring-label small { display: block; font-size: .6rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.lp-statcells { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 18px; }
.lp-statcells a { display: block; padding: 4px 0; border-radius: 8px; }
.lp-statcells a:hover { background: var(--surface-2); }
.lp-statcells small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.lp-statcells b { font-size: 1.3rem; }
.lp-statcells .lp-sub { display: block; font-size: .78rem; color: var(--muted); font-weight: 700; }

/* Progress rows: active runs / checklists, nearest-to-done first */
.lp-progress-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
}
.lp-progress-row h3 { margin: 0; font-size: .98rem; grid-column: 1; grid-row: 1; }
.lp-progress-row h3 a { color: inherit; }
.lp-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; grid-column: 1; grid-row: 2; margin-top: 4px; }
.lp-bar i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.lp-bar.lp-nearly i { background: #b98a2e; }
.lp-progress-count { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-weight: 900; white-space: nowrap; }
.lp-progress-count small { display: block; color: var(--muted); font-weight: 700; }

/* Hunt rows: wishlist targets with market signals */
.lp-hunt-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
}
.lp-hunt-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 9px; background: var(--surface-2); }
.lp-hunt-row h3 { margin: 0; font-size: .98rem; }
.lp-hunt-signal { font-size: .8rem; font-weight: 700; color: var(--muted); }
.lp-hunt-signal.hot { color: var(--accent); }
.lp-hunt-price { text-align: right; font-weight: 900; }
.lp-hunt-price small { display: block; color: var(--muted); font-weight: 700; }
.lp-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 900;
  background: rgba(194, 106, 58, .14);
  color: var(--accent);
}

/* Hunt cards: wishlist row + collapsed manage forms */
.lp-hunt-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
  overflow: hidden;
}
.lp-hunt-card .lp-hunt-row { border: 0; margin: 0; }
.lp-hunt-manage summary {
  cursor: pointer;
  padding: .6rem 14px;
  border-top: 1px dashed var(--line);
  font-weight: 800;
  font-size: .84rem;
  color: var(--primary);
  list-style: none;
}
.lp-hunt-manage summary::-webkit-details-marker { display: none; }
.lp-hunt-manage summary::before { content: "▸ "; }
.lp-hunt-manage[open] summary::before { content: "▾ "; }
.lp-hunt-manage .wishlist-actions { padding: 0 14px 14px; display: grid; gap: .8rem; }

/* Spec table: compact item facts (replaces stacked stat tiles) */
.lp-spec-table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: .8rem 0; }
.lp-spec-table td { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.lp-spec-table td:first-child { color: var(--muted); width: 38%; font-weight: 700; }
.lp-spec-table td:last-child { font-weight: 900; }
.lp-spec-table a { color: var(--primary); }

/* Your copy: the member's relationship to an item */
.lp-your-copy {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: linear-gradient(160deg, rgba(47, 105, 92, .1), var(--surface));
}
.lp-your-copy > strong { display: block; text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--primary); margin-bottom: .1rem; }
.lp-copy-state { display: block; font-size: 1.02rem; margin-bottom: .5rem; }

/* Mobile dashboard handoff: pointer to the desktop command center */
.dash-mobile-handoff {
  display: grid;
  gap: .5rem;
  justify-items: start;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.dash-mobile-handoff p { margin: 0; color: var(--muted); font-size: .88rem; }

/* Section headers in loop voice */
.lp-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 1.6rem 0 .7rem; }
.lp-block-head h2 { margin: 0; font-size: 1.18rem; }
.lp-block-head > a { color: var(--primary); font-weight: 800; font-size: .9rem; white-space: nowrap; }

/* ---------- Bottom tab bar (hidden on desktop) ---------- */
.lp-tabbar { display: none; }

/* ---------- Mobile loop chrome ---------- */
@media (max-width: 920px) {
  body { padding-bottom: 74px; }

  /* Touch header: brand/account on top, full search below */
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .55rem .7rem;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: .5rem .9rem .72rem;
  }
  .site-header .main-nav { display: none; }             /* tab bar replaces it */
  .site-header .brand { grid-column: 1; grid-row: 1; min-width: 0; }
  .site-header .top-search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .site-header .account-nav { grid-column: 2; grid-row: 1; justify-content: flex-end; flex-wrap: nowrap; }
  .site-header .brand small { display: none; }
  .site-header .brand strong { font-size: 1rem; }
  .top-search { margin: 0; min-width: 0; }
  .top-search input {
    width: 100%;
    min-height: 42px;
    box-sizing: border-box;
    padding: .62rem 1rem;
    font-size: .94rem;
    border-radius: 999px;
    background: #fffdf7;
    border-color: rgba(47, 105, 92, .28);
    box-shadow: 0 2px 10px rgba(33, 50, 58, .08);
  }
  .account-nav { gap: .45rem; }
  .account-nav .support-link, .account-nav > a[href="/messages"] { display: none; } /* live in More sheet */
  .user-menu summary b { display: none; }

  /* Density: tighter bands and grids */
  .band { margin: 1.5rem auto; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .hero { min-height: 420px; }
  .hero h1, .page-title h1, .detail-main h1 { font-size: 1.9rem; }
  .lp-statstrip { grid-template-columns: auto 1fr; padding: 14px; gap: 14px; }
  .lp-ring { width: 86px; height: 86px; }
  .lp-ring svg { width: 86px; height: 86px; }
  .lp-statcells { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .lp-statcells b { font-size: 1.05rem; }

  /* Tab bar: the loop is the navigation */
  .lp-tabbar {
    display: block;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    height: 64px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(45, 38, 29, .1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .lp-tabbar-inner { display: grid; grid-template-columns: repeat(5, 1fr); height: 64px; max-width: 560px; margin: 0 auto; }
  .lp-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: .66rem; font-weight: 800; color: var(--muted); text-decoration: none;
  }
  .lp-tab i { font-style: normal; font-size: 1.3rem; line-height: 1; }
  .lp-tab.active { color: var(--primary); }
  .lp-tab-add { position: relative; }
  .lp-tab-add b {
    position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
    width: 52px; height: 52px; border-radius: 999px;
    background: var(--primary); color: #fff;
    display: grid; place-items: center;
    font-size: 1.6rem; font-weight: 400;
    border: 3px solid var(--paper);
    box-shadow: 0 8px 20px rgba(45, 38, 29, .25);
  }
  .lp-tab-add span { margin-top: 28px; }

  /* More sheet (details-based, opens above the bar) */
  .lp-more { position: relative; display: flex; }
  .lp-more summary {
    list-style: none; cursor: pointer; flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: .66rem; font-weight: 800; color: var(--muted);
  }
  .lp-more summary::-webkit-details-marker { display: none; }
  .lp-more summary i { font-style: normal; font-size: 1.3rem; line-height: 1; }
  .lp-more[open] summary { color: var(--primary); }
  .lp-sheet {
    position: fixed;
    left: .6rem; right: .6rem; bottom: 74px;
    max-height: 62vh; overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: .6rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem;
    z-index: 60;
  }
  .lp-sheet a, .lp-sheet button {
    display: block; width: 100%; text-align: left;
    padding: .65rem .75rem;
    border: 0; background: transparent;
    border-radius: 8px;
    font-weight: 800; font-size: .9rem; color: var(--ink);
    min-height: auto;
  }
  .lp-sheet a:active, .lp-sheet a:hover, .lp-sheet button:hover { background: var(--surface-2); }
  .lp-sheet .lp-sheet-label {
    grid-column: 1 / -1;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
    color: var(--muted); font-weight: 900; padding: .5rem .75rem .1rem;
  }
  .lp-sheet form { display: contents; }

  /* Wishlist → Hunt density */
  .wishlist-list article { border-radius: var(--radius); }
  .wishlist-list article > a img { height: 160px; }

  /* Item page */
  .detail-layout { gap: 1rem; }
  .action-panels { gap: .8rem; }

  /* Admin on a phone: stack, scroll, breathe */
  .admin-shell { grid-template-columns: 1fr; }
  .admin-shell > * { min-width: 0; }
  .admin-main > *, .admin-panel, .admin-panel > * { min-width: 0; }
  .admin-panel .table-wrap { max-width: 100%; }
  .admin-shell .stat-grid, .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-action-board, .admin-help, .admin-dashboard-details, .launch-checklist { grid-template-columns: 1fr; }
  .admin-shell img { max-width: 100%; height: auto; }
  .admin-nav {
    display: flex; align-items: center; gap: .3rem;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: .5rem .6rem; border-radius: 12px;
  }
  .admin-nav-title { flex: none; font-size: .78rem; opacity: .8; padding-right: .2rem; }
  .admin-nav-group { display: contents; }
  .admin-nav-group > span { display: none; }
  .admin-nav-group a { flex: none; white-space: nowrap; padding: .45rem .75rem; border-radius: 999px; font-size: .84rem; }
  .admin-panel { padding: .9rem; }
  .settings-grid, .admin-form, .compact-admin-form .settings-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-shell .table-wrap table { min-width: 640px; }
  .admin-panel .button, .admin-panel button { width: 100%; }
  .admin-head, .section-heading { flex-direction: column; align-items: flex-start; gap: .5rem; }

  /* Footer sits above the tab bar visually */
  .site-footer { margin-bottom: .5rem; }
}

@media (max-width: 560px) {
  .collection-dynamic-region {
    min-width: 0;
    width: 100%;
    max-width: calc(100vw - 2rem);
    overflow-x: clip;
  }
  .collection-stats {
    grid-template-columns: minmax(0, 1fr);
    justify-self: stretch;
    min-width: 0;
    width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
  }
  .collection-stats .stat-card {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .mobile-collection-workspace {
    display: grid;
    gap: 1rem;
    margin: 1rem 0 1.25rem;
  }
  .mobile-collection-tools,
  .mobile-latest-shelf {
    display: grid;
    gap: .7rem;
    min-width: 0;
  }
  .mobile-tool-card,
  .mobile-shelf-card {
    background: rgba(255, 250, 241, .82);
    border: 1px solid rgba(47, 105, 92, .18);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(33, 50, 58, .08);
    overflow: hidden;
  }
  .mobile-tool-card summary,
  .mobile-shelf-card summary {
    min-height: 48px;
    cursor: pointer;
    list-style: none;
  }
  .mobile-tool-card summary::-webkit-details-marker,
  .mobile-shelf-card summary::-webkit-details-marker {
    display: none;
  }
  .mobile-tool-card summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem .85rem;
    font-weight: 900;
    color: var(--ink);
  }
  .mobile-tool-card summary::after,
  .mobile-shelf-card summary::after {
    content: ">";
    color: var(--primary);
    font-weight: 900;
    transition: transform .16s ease;
  }
  .mobile-tool-card[open] summary::after,
  .mobile-shelf-card[open] summary::after {
    transform: rotate(90deg);
  }
  .mobile-tool-links,
  .mobile-filter-form {
    display: grid;
    gap: .55rem;
    padding: 0 .85rem .85rem;
  }
  .mobile-tool-links a {
    display: grid;
    gap: .12rem;
    padding: .7rem .75rem;
    border: 1px solid rgba(47, 105, 92, .14);
    border-radius: 8px;
    background: rgba(255, 253, 247, .78);
    color: inherit;
    text-decoration: none;
  }
  .mobile-tool-links a.active {
    border-color: rgba(47, 105, 92, .45);
    background: rgba(47, 105, 92, .1);
  }
  .mobile-tool-links small {
    color: var(--muted);
    font-weight: 700;
  }
  .mobile-filter-form input,
  .mobile-filter-form select {
    width: 100%;
    min-height: 44px;
  }
  .mobile-tool-actions,
  .mobile-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
  }
  .mobile-section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: .8rem;
  }
  .mobile-section-head h2 {
    margin: .15rem 0 0;
    font-size: 1.2rem;
  }
  .mobile-section-head small {
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
  }
  .mobile-shelf-stack {
    display: grid;
    gap: .65rem;
  }
  .mobile-shelf-card summary {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: .75rem;
    align-items: center;
    padding: .75rem;
  }
  .mobile-shelf-card img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--surface-2);
  }
  .mobile-shelf-card summary span {
    display: grid;
    gap: .12rem;
    min-width: 0;
  }
  .mobile-shelf-card summary small {
    color: var(--accent);
    font-weight: 900;
    text-transform: uppercase;
    font-size: .68rem;
  }
  .mobile-shelf-card summary strong {
    overflow-wrap: anywhere;
    line-height: 1.1;
  }
  .mobile-shelf-card summary em,
  .mobile-shelf-details p {
    color: var(--muted);
    font-style: normal;
    line-height: 1.35;
  }
  .mobile-shelf-details {
    display: grid;
    gap: .65rem;
    padding: 0 .85rem .85rem;
  }
  .mobile-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
  }
  .mobile-chip-row b {
    padding: .18rem .48rem;
    border-radius: 999px;
    background: rgba(47, 105, 92, .12);
    color: var(--primary);
    font-size: .78rem;
  }
  .mobile-more-link {
    display: block;
    padding: .75rem .85rem;
    border: 1px solid rgba(47, 105, 92, .22);
    border-radius: 8px;
    background: rgba(255, 250, 241, .86);
    color: var(--primary);
    font-weight: 900;
    text-align: center;
    text-decoration: none;
  }
  .collection-shelf-divider,
  .collection-table-band.collection-view-shelf {
    display: none !important;
  }
}

@media (min-width: 561px) {
  .mobile-collection-workspace {
    display: none;
  }
}
