/* ==========================================================
   Responsive shell v1 — one document, desktop → phone.
   Shared by index.html (app) and console.html (operator).

   Implements the seven shell laws from concepts/shells-v35.html:
     1. The rail is universal — no screen invents its own chrome
     2. The brand mark toggles the rail (and carries the idle beat)
     3. One left-stripe — 2px accent marks the active nav item, nothing else
     4. ⌘K is the principal search, top bar, every screen
     5. Mobile folds, never forks — same rail becomes the drawer. NO BOTTOM TABS
     6. Selection is tint, CTA is fill
     7. Works in black and white first

   Composition law from guidelines/GUIDE.mobile-composition.md:
     - rail costs 0px at phone width (off-canvas)
     - <= 2 rows of chrome above content
     - primary action in the bottom third, sticky
   Card law from DEC-025 (briefs/BRIEF.code-presence.md):
     - Code is the head + the one teal moment when present
     - head CLOSES UP when absent; title never promoted (L3)
     - share action becomes the accent on unshared objects (L2)

   All values from brand/relay-tokens-v35.css. Nothing hardcoded.
========================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  background: var(--rly-bg); color: var(--rly-text);
  font-family: var(--rly-font); font-size: 14px; line-height: 1.6;
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--rly-accent-ui); outline-offset: 2px; border-radius: var(--rly-radius-sm); }

:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --rail: 220px;         /* labeled */
  --rail-icons: 56px;    /* collapsed */
  --topbar-h: 52px;
  --shell-gap: 16px;
}

/* ==========================================================
   SHELL FRAME
========================================================== */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100dvh; }
.shell[data-rail="icons"] { --rail: var(--rail-icons); }

/* ---------- rail ---------- */
.rail {
  grid-column: 1; position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--rly-panel); border-right: 0.5px solid var(--rly-border);
  overflow: hidden; transition: width .22s var(--ease);
}
.rail-head { height: var(--topbar-h); display: flex; align-items: center; gap: 9px; padding: 0 14px; flex-shrink: 0; }
.brandmark { display: inline-flex; align-items: center; gap: 9px; color: var(--rly-accent-ui); }
.brandmark svg { display: block; flex-shrink: 0; }
.brandmark .core { transform-origin: center; animation: beat 3.4s ease-in-out infinite; }
@keyframes beat { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.brand-word { font-family: var(--rly-font-mark); font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: var(--rly-text-bright); white-space: nowrap; }

.rail-scroll { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-group { padding: 10px 0 2px; }
.nav-group-label {
  font-family: var(--rly-font-mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--rly-text-muted);
  padding: 0 16px 6px; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  min-height: 40px; padding: 0 14px;
  border-left: 2px solid transparent;      /* law 3: the ONLY left-stripe */
  color: var(--rly-text-2); white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item:hover { background: var(--rly-surface); color: var(--rly-text); }
.nav-item[aria-current="page"] {
  border-left-color: var(--rly-accent-ui);   /* law 3 */
  background: var(--rly-accent-tint);        /* law 6: selection is tint */
  color: var(--rly-accent-text);
}
.nav-ico { width: 18px; flex-shrink: 0; text-align: center; font-size: 14px; }
.nav-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  font-family: var(--rly-font-mono); font-size: 10px; font-weight: 600;
  background: var(--rly-surface); border: 0.5px solid var(--rly-border);
  border-radius: var(--rly-radius-full); padding: 1px 7px; color: var(--rly-text-2);
}
.shell[data-rail="icons"] .nav-label,
.shell[data-rail="icons"] .nav-badge,
.shell[data-rail="icons"] .nav-group-label,
.shell[data-rail="icons"] .brand-word { display: none; }
.shell[data-rail="icons"] .nav-item { justify-content: center; padding: 0; }

/* ---------- topbar ---------- */
.main { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--shell-gap);
  background: color-mix(in srgb, var(--rly-bg) 88%, transparent);
  backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 0.5px solid var(--rly-border);
}
.menu-btn { display: none; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: var(--rly-radius-sm); color: var(--rly-text-2); }
.menu-btn:hover { background: var(--rly-surface); }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--rly-text-bright); white-space: nowrap; }
.topbar-spacer { flex: 1; }

/* law 4 — ⌘K principal search */
.ksearch {
  display: flex; align-items: center; gap: 8px; height: 32px; min-width: 0;
  flex: 0 1 340px; padding: 0 11px;
  background: var(--rly-surface); border: 0.5px solid var(--rly-border-input);
  border-radius: var(--rly-radius-full); color: var(--rly-text-muted);
}
.ksearch:hover { border-color: var(--rly-border-hi); }
.ksearch input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--rly-text); font: inherit; font-size: 13px; }
.ksearch input::placeholder { color: var(--rly-text-muted); }
.kbd { font-family: var(--rly-font-mono); font-size: 10px; color: var(--rly-text-muted); border: 0.5px solid var(--rly-border); border-radius: var(--rly-radius-sm); padding: 1px 5px; white-space: nowrap; }
.icon-btn { position: relative; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--rly-radius-full); color: var(--rly-text-2); }
.icon-btn:hover { background: var(--rly-surface); color: var(--rly-text); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--rly-accent-ui); }

/* ---------- content ---------- */
.content { flex: 1; padding: clamp(16px, 3vw, 28px) var(--shell-gap) 96px; max-width: 1080px; width: 100%; }
.screen-head { margin-bottom: 18px; }
.eyebrow { font-family: var(--rly-font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--rly-accent-text); margin-bottom: 8px; }
.screen-head h1 { font-family: var(--rly-font-display); font-style: italic; font-weight: 400; font-size: clamp(26px, 4vw, 38px); line-height: 1.1; color: var(--rly-text-bright); }

/* ==========================================================
   CONTROL ROW + FILTER SHEET  (<= 2 rows of chrome)
========================================================== */
.controlrow { display: flex; align-items: center; gap: 8px; position: sticky; top: var(--topbar-h); z-index: 30; background: var(--rly-bg); padding: 10px 0; }
.ctl {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px;
  background: var(--rly-surface); border: 0.5px solid var(--rly-border);
  border-radius: var(--rly-radius-full); color: var(--rly-text-2); white-space: nowrap;
}
.ctl:hover { border-color: var(--rly-border-hi); color: var(--rly-text); }
.ctl.is-on { background: var(--rly-accent-tint); border-color: var(--rly-accent-ui); color: var(--rly-accent-text); }  /* law 6 */
.ctl-count { font-family: var(--rly-font-mono); font-size: 10px; font-weight: 600; }
.ctl-search { flex: 1 1 auto; min-width: 0; }
.ctl-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--rly-text); font: inherit; font-size: 13px; }
.resultline { font-family: var(--rly-font-mono); font-size: 11px; color: var(--rly-text-muted); padding: 2px 0 12px; }
.resultline b { color: var(--rly-text-2); font-weight: 600; }

/* ==========================================================
   OBJECT CARD — DEC-025 composed
========================================================== */
.list { display: flex; flex-direction: column; gap: 8px; }
.ocard {
  position: relative; display: block; width: 100%; text-align: left;
  background: var(--rly-surface); border: 0.5px solid var(--rly-border);
  border-radius: var(--rly-radius-card); padding: 13px 14px;
  transition: border-color .16s var(--ease);
}
.ocard:hover { border-color: var(--rly-border-hi); }
.ocard-dot { position: absolute; left: 5px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--rly-accent-ui); }
.ocard.is-read .ocard-dot { background: transparent; }

/* L2 — the Code is the one teal moment when the object is shared */
.ocard-code {
  font-family: var(--rly-font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.10em; color: var(--rly-accent-text);
  display: block; margin-bottom: 3px;
}
/* L3 — title keeps the same slot/size/weight/colour in BOTH states.
   Two lines, legible. Never promoted, never a 4-char stub. */
.ocard-title {
  font-size: 14px; font-weight: 500; color: var(--rly-text-bright); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.ocard-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-family: var(--rly-font-mono); font-size: 11px; color: var(--rly-text-muted); }
.ocard-meta .sep { opacity: .5; }
/* badges: exceptions only (never ACTIVE / PRIVATE / PERSONAL) */
.ex { font-size: 9px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; border-radius: var(--rly-radius-sm); padding: 2px 6px; border: 0.5px solid; }
.ex-expired { color: var(--rly-warning); border-color: color-mix(in srgb, var(--rly-warning) 40%, transparent); }
.ex-org { color: var(--rly-indigo); border-color: color-mix(in srgb, var(--rly-indigo) 40%, transparent); background: var(--rly-indigo-dim); }
.ocard-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { font-size: 11px; color: var(--rly-text-2); background: var(--rly-panel); border: 0.5px solid var(--rly-border); border-radius: var(--rly-radius-sm); padding: 1px 7px; }
.tag-more { color: var(--rly-text-muted); }
/* L2 — on an UNSHARED object the share action is the accent, and the head closed up */
.ocard-share {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px;
  background: var(--rly-accent-fill); color: var(--rly-on-accent);
  border-radius: var(--rly-radius-full); font-size: 12px; font-weight: 600;
}

/* ==========================================================
   SHEET — transform-only (SPEC.app-components.md)
========================================================== */
.scrim { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--rly-deep) 55%, transparent); opacity: 0; pointer-events: none; transition: opacity .22s var(--ease); }
.scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--rly-panel); border-top: 0.5px solid var(--rly-border);
  border-radius: var(--rly-radius-card) var(--rly-radius-card) 0 0;
  padding: 8px var(--shell-gap) calc(var(--shell-gap) + env(safe-area-inset-bottom));
  max-height: 82dvh; overflow-y: auto;
  transform: translateY(101%);                       /* transform-only, never height */
  transition: transform .22s var(--ease);
}
.sheet.is-open { transform: translateY(0); }
@media (min-width: 861px) { .sheet { left: auto; right: 24px; bottom: 24px; width: 380px; border-radius: var(--rly-radius-card); border: 0.5px solid var(--rly-border); } }
.grabber { width: 36px; height: 4px; border-radius: var(--rly-radius-full); background: var(--rly-border-hi); margin: 4px auto 12px; }
.sheet h2 { font-size: 13px; font-weight: 600; color: var(--rly-text-bright); margin-bottom: 12px; }
.facet { padding: 10px 0; border-top: 0.5px solid var(--rly-border); }
.facet:first-of-type { border-top: none; }
.facet-label { font-family: var(--rly-font-mono); font-size: 9px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rly-text-muted); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 12px; display: inline-flex; align-items: center; background: var(--rly-surface); border: 0.5px solid var(--rly-border); border-radius: var(--rly-radius-full); font-size: 12px; color: var(--rly-text-2); }
.chip.is-on { background: var(--rly-accent-tint); border-color: var(--rly-accent-ui); color: var(--rly-accent-text); }
.sheet-actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding-top: 12px; background: var(--rly-panel); }
.btn { flex: 1; height: 44px; border-radius: var(--rly-radius-full); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--rly-accent-fill); color: var(--rly-on-accent); }
.btn-ghost { border: 0.5px solid var(--rly-border); color: var(--rly-text-2); }

/* ==========================================================
   STATE BLOCK
========================================================== */
.stateblock { text-align: center; padding: 40px 16px; border: 0.5px dashed var(--rly-border); border-radius: var(--rly-radius-card); }
.stateblock h3 { font-size: 14px; font-weight: 600; color: var(--rly-text-bright); margin-bottom: 5px; }
.stateblock p { font-size: 13px; color: var(--rly-text-2); max-width: 42ch; margin: 0 auto 14px; }

/* ==========================================================
   MOBILE — the rail FOLDS, it does not fork. No bottom tabs.
========================================================== */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }               /* rail costs 0px */
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 80; width: min(84vw, var(--rail-icons-off, 280px));
    transform: translateX(-101%); transition: transform .22s var(--ease);
    border-right: 0.5px solid var(--rly-border);
  }
  .shell[data-drawer="open"] .rail { transform: translateX(0); }
  .shell[data-rail="icons"] .nav-label,
  .shell[data-rail="icons"] .nav-badge,
  .shell[data-rail="icons"] .nav-group-label,
  .shell[data-rail="icons"] .brand-word { display: revert; }   /* drawer is always labeled */
  .shell[data-rail="icons"] .nav-item { justify-content: flex-start; padding: 0 14px; }
  .main { grid-column: 1; }
  .menu-btn { display: inline-flex; }
  .ksearch { flex: 1 1 auto; }
  .ksearch .kbd { display: none; }
  .topbar-title { display: none; }
  .content { padding-bottom: 112px; }
  /* primary action in the bottom third, sticky */
  .fab {
    position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
    height: 52px; padding: 0 20px; border-radius: var(--rly-radius-full);
    background: var(--rly-accent-fill); color: var(--rly-on-accent);
    font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
    box-shadow: 0 6px 24px color-mix(in srgb, var(--rly-deep) 30%, transparent);
  }
}
@media (min-width: 861px) { .fab { display: none; } }
@media (max-width: 430px) {
  :root { --shell-gap: 12px; }
  .ocard { padding: 12px; }
}

/* touch targets — law: >=44px, >=8px apart */
@media (pointer: coarse) {
  .nav-item { min-height: 48px; }
  .ctl, .chip { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- specimen chrome (prototype only, not part of the shell) ---------- */
.spec-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--rly-text-bright); color: var(--rly-bg);
  font-family: var(--rly-font-mono); font-size: 10px; letter-spacing: 0.05em; }
.spec-bar a { color: var(--rly-bg); text-decoration: underline; }
.spec-bar .w { opacity: .7; }
body.has-specbar { padding-bottom: 40px; }
