/* Tokens are supplied by the shared SANO brand.css loaded by each shell. */

* { box-sizing: border-box; }
html { background: var(--ui-canvas); }

body.product-shell {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  grid-template:
    "sidebar header" auto
    "sidebar main"   minmax(0, 1fr)
    / 15.5rem minmax(0, 1fr);
  background: var(--ui-canvas);
  color: var(--ui-text);
  font: var(--ui-text-md)/1.5 var(--ui-font-sans);
  accent-color: var(--ui-accent);
  text-rendering: optimizeLegibility;
}

.product-shell a { color: inherit; text-underline-offset: .15em; }
.product-shell ::selection { background: var(--ui-accent-soft); color: var(--ui-text); }
.product-shell button, .product-shell select, .product-shell input, .product-shell textarea { font: inherit; }
.product-shell :where(a, button, select, input, textarea, summary):focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 2px;
}
.product-shell :where(a, button, select, input, textarea) { touch-action: manipulation; }

/* ========================= Skip link ========================= */

.product-shell__skip-link {
  position: fixed;
  z-index: 100;
  top: var(--ui-space-3);
  left: var(--ui-space-3);
  padding: .65rem .85rem;
  border-radius: var(--ui-radius-control);
  background: var(--ui-accent-active);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-180%);
}
.product-shell__skip-link:focus { transform: translateY(0); }

/* =========================== Sidebar ========================== */

.product-shell__sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  z-index: 20;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-5);
  padding: var(--ui-space-5) var(--ui-space-4);
  border-right: 1px solid var(--ui-divider);
  background: var(--ui-surface);
}

.product-shell__identity, .product-shell__mobile-identity {
  width: fit-content;
  color: var(--ui-text);
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}
.product-shell__identity {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .25rem .35rem;
  font-size: var(--ui-text-lg);
}
.product-shell__identity-wordmark {
  display: block;
  width: 7.8rem;
  height: auto;
}
.product-shell__identity-mark {
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-accent);
  border-radius: 50%;
  background: var(--ui-accent-soft);
  color: var(--ui-accent-hover);
  font-size: var(--ui-text-sm);
  font-weight: 800;
}

/* ---- Navigation: three grouped destinations ----------------
   Group headings are visible text labels; active state is
   background + left bar + weight (never color alone). --------- */

.product-shell__nav { display: grid; gap: var(--ui-space-5); min-width: 0; }
.product-shell__nav-group { display: grid; gap: var(--ui-space-1); min-width: 0; }
.product-shell__nav-group-title {
  padding: 0 var(--ui-space-3);
  color: var(--ui-text-quiet);
  font-size: .6875rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.product-shell__nav-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  list-style: none;
}
.product-shell__nav-list > li { min-width: 0; }

.product-shell__nav-link {
  position: relative;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  padding: .55rem .75rem;
  border-radius: var(--ui-radius-control);
  color: var(--ui-text-secondary);
  font-size: var(--ui-text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--ui-motion-fast) var(--ui-ease-standard),
    color var(--ui-motion-fast) var(--ui-ease-standard);
}
.product-shell__nav-link::before {
  content: "";
  width: .4rem;
  height: .4rem;
  flex: 0 0 auto;
  align-self: center;
  margin-right: .65rem;
  border-radius: 50%;
  background: transparent;
  transition: background-color var(--ui-motion-fast) var(--ui-ease-standard),
    transform var(--ui-motion-fast) var(--ui-ease-standard);
}
.product-shell__nav-link:hover { background: var(--ui-surface-muted); color: var(--ui-text); }
.product-shell__nav-link:active { background: var(--ui-accent-soft); color: var(--ui-accent-active); }
.product-shell__nav-link.is-active {
  background: var(--ui-accent-soft);
  color: var(--ui-accent-hover);
  font-weight: 700;
}
.product-shell__nav-link.is-active::before { background: var(--ui-accent); transform: scale(1.2); }

/* ============================ Header ========================== */

.product-shell__header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-4);
  padding: .5rem clamp(var(--ui-space-4), 3vw, var(--ui-space-6));
  border-bottom: 1px solid var(--ui-divider);
  background: var(--ui-surface);
}
.product-shell__header-start { min-width: 0; display: flex; align-items: center; gap: var(--ui-space-3); }
.product-shell__menu-button, .product-shell__mobile-identity { display: none; }
.product-shell__mobile-identity img { display: block; width: 7.1rem; height: auto; }

/* ---- Person context rail: "Who am I viewing?" -------------- */

.product-shell__person {
  min-width: 0;
  max-width: 26rem;
  display: flex;
  align-items: baseline;
  gap: var(--ui-space-2);
  padding: .3rem .65rem;
  border: 1px solid var(--ui-divider);
  border-radius: var(--ui-radius-notice);
  background: var(--ui-surface-muted);
}
.product-shell__person-label {
  flex: 0 0 auto;
  color: var(--ui-text-quiet);
  font-size: .6875rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.product-shell__person-status {
  min-width: 0;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-shell__person-status:empty { display: none; }

/* ---- Locale control (EN/RU; cookie semantics unchanged) ---- */

.product-shell__locale {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  color: var(--ui-text-secondary);
  font-size: var(--ui-text-xs);
  font-weight: 700;
}
.product-shell__locale select {
  min-height: 2.5rem;
  padding: .3rem 2rem .3rem .6rem;
  border: 1px solid var(--ui-divider-strong);
  border-radius: var(--ui-radius-control);
  background: var(--ui-surface);
  color: var(--ui-text);
  cursor: pointer;
  transition: background-color var(--ui-motion-fast) var(--ui-ease-standard);
}
.product-shell__locale select:hover { background: var(--ui-surface-muted); }

/* ============================= Main =========================== */

.product-shell__main {
  grid-area: main;
  width: 100%;
  min-width: 0;
  max-width: 90rem;
  margin-inline: auto;
  padding: clamp(var(--ui-space-4), 3vw, var(--ui-space-6));
  scroll-margin-top: 4.5rem;
}

/* ========================= Menu button ======================== */

.product-shell__menu-button {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  padding: .7rem;
  border: 1px solid var(--ui-divider-strong);
  border-radius: var(--ui-radius-control);
  background: var(--ui-surface);
  color: var(--ui-text);
  cursor: pointer;
  transition: background-color var(--ui-motion-fast) var(--ui-ease-standard);
}
.product-shell__menu-button span { width: 100%; height: 2px; display: block; margin-block: .22rem; border-radius: 2px; background: currentColor; }
.product-shell__menu-button:hover { background: var(--ui-surface-muted); }
.product-shell__menu-button:active { background: var(--ui-accent-soft); }

/* ======================== Responsiveness ======================
   Structural changes only; no page-level horizontal overflow.
   ============================================================= */

/* Laptop: narrower sidebar, navigation remains persistent. */
@media (max-width: 68rem) {
  body.product-shell { grid-template-columns: 13.5rem minmax(0, 1fr); }
}

/* Tablet / mobile: single-column shell, collapsed navigation. */
@media (max-width: 52rem) {
  body.product-shell {
    grid-template:
      "header"  auto
      "sidebar" auto
      "main"    minmax(0, 1fr)
      / minmax(0, 1fr);
  }
  .product-shell__header { gap: var(--ui-space-2); padding-inline: var(--ui-space-4); }
  .product-shell__menu-button, .product-shell__mobile-identity { display: block; }
  .product-shell__mobile-identity { display: inline-flex; align-items: center; min-height: 2.75rem; }
  .product-shell__sidebar {
    position: relative;
    max-height: none;
    overflow-y: visible;
    padding: var(--ui-space-3) var(--ui-space-4) var(--ui-space-4);
    border-right: 0;
    border-bottom: 1px solid var(--ui-divider);
  }
  .product-shell__identity { display: none; }
  .product-shell__nav { gap: var(--ui-space-4); }
  .product-shell__nav-link { min-height: 2.75rem; }
  .product-shell__main { padding: var(--ui-space-4); }
  .product-shell--enhanced[data-navigation-open="false"] .product-shell__sidebar { display: none; }
}

/* Phone (390px): header reflows to two rows; Person context
   stays visible; everything one column. */
@media (max-width: 34rem) {
  .product-shell__header { flex-wrap: wrap; }
  .product-shell__header-start { flex-wrap: wrap; min-width: 0; }
  .product-shell__person {
    flex: 1 1 100%;
    order: 3;
    max-width: none;
  }
  .product-shell__locale { order: 2; }
  .product-shell__locale select { min-height: 2.75rem; }
}

/* ====================== Shared primitives =====================
   Small R1 vocabulary for the shell + immediate R2 migration.
   State contract: default / hover / focus-visible (global above)
   / active / disabled everywhere; loading on buttons/skeletons.
   Status is never communicated by color alone.
   ============================================================= */

/* ---- Buttons ------------------------------------------------ */

.ui-button {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-2);
  padding: .5rem var(--ui-space-4);
  border: 1px solid transparent;
  border-radius: var(--ui-radius-control);
  color: var(--ui-text);
  background: var(--ui-surface-muted);
  font-size: var(--ui-text-sm);
  font-weight: 650;
  cursor: pointer;
  transition: background-color var(--ui-motion-fast) var(--ui-ease-standard),
    border-color var(--ui-motion-fast) var(--ui-ease-standard),
    color var(--ui-motion-fast) var(--ui-ease-standard);
}
.ui-button--primary {
  border-color: var(--ui-accent);
  background: var(--ui-accent);
  color: #fff;
}
.ui-button--primary:hover { border-color: var(--ui-accent-hover); background: var(--ui-accent-hover); }
.ui-button--primary:active { border-color: var(--ui-accent-active); background: var(--ui-accent-active); }
.ui-button--secondary {
  border-color: var(--ui-divider-strong);
  background: var(--ui-surface);
  color: var(--ui-text);
}
.ui-button--secondary:hover { background: var(--ui-surface-muted); }
.ui-button--secondary:active { background: var(--ui-accent-soft); border-color: var(--ui-accent); color: var(--ui-accent-active); }
.ui-button--danger {
  border-color: var(--ui-danger);
  background: var(--ui-surface);
  color: var(--ui-danger);
}
.ui-button--danger:hover { background: var(--ui-danger-soft); }
.ui-button--danger:active { background: var(--ui-danger); color: #fff; }
.ui-button:disabled, .ui-button[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}
.ui-button[aria-busy="true"] { cursor: progress; }
.ui-button[aria-busy="true"]::before {
  content: "";
  width: .8em;
  height: .8em;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-block-start-color: transparent;
  border-radius: 50%;
  animation: ui-spin .8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---- Shared control base (inputs, selects, textareas) ------- */

.ui-control {
  min-height: 2.75rem;
  width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--ui-divider-strong);
  border-radius: var(--ui-radius-control);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: var(--ui-text-sm);
}
select.ui-control { cursor: pointer; }
textarea.ui-control { min-height: 6rem; resize: vertical; }
.ui-control:hover { border-color: var(--ui-text-quiet); }
.ui-control:disabled { opacity: .55; cursor: not-allowed; background: var(--ui-surface-muted); }
.ui-control[aria-invalid="true"] { border-color: var(--ui-danger); border-width: 2px; }

/* ---- Status badge (text label is the primary cue; color is
   a reinforcement, never the only signal) ---------------------- */

.ui-status {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  padding: .1rem .55rem;
  border: 1px solid var(--ui-divider-strong);
  border-radius: 999px;
  background: var(--ui-surface-muted);
  color: var(--ui-text);
  font-size: var(--ui-text-xs);
  font-weight: 700;
  white-space: nowrap;
}
.ui-status::before {
  content: "";
  width: .5em;
  height: .5em;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}
.ui-status--success { border-color: rgb(29 107 79 / .45); background: var(--ui-success-soft); color: var(--ui-success); }
.ui-status--warning { border-color: rgb(118 82 15 / .45); background: var(--ui-warning-soft); color: var(--ui-warning); }
.ui-status--danger  { border-color: rgb(143 59 51 / .45); background: var(--ui-danger-soft); color: var(--ui-danger); }
.ui-status--info    { border-color: rgb(36 95 122 / .45); background: var(--ui-info-soft); color: var(--ui-info); }

/* ---- Inline notice ----------------------------------------- */

.ui-notice {
  padding: var(--ui-space-3) var(--ui-space-4);
  border: 1px solid var(--ui-divider-strong);
  border-left: 4px solid var(--ui-divider-strong);
  border-radius: var(--ui-radius-notice);
  background: var(--ui-surface-muted);
  color: var(--ui-text);
  overflow-wrap: anywhere;
}
.ui-notice--info    { border-color: rgb(36 95 122 / .4); border-left-color: var(--ui-info); background: var(--ui-info-soft); }
.ui-notice--success { border-color: rgb(29 107 79 / .4); border-left-color: var(--ui-success); background: var(--ui-success-soft); }
.ui-notice--warning { border-color: rgb(118 82 15 / .4); border-left-color: var(--ui-warning); background: var(--ui-warning-soft); }
.ui-notice--danger  { border-color: rgb(143 59 51 / .4); border-left-color: var(--ui-danger); background: var(--ui-danger-soft); }

/* ---- Data row: rows before cards (default content grammar) -- */

.ui-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ui-space-2) var(--ui-space-4);
  padding: var(--ui-space-3) var(--ui-space-2);
  border-top: 1px solid var(--ui-divider);
  overflow-wrap: anywhere;
}
.ui-row:last-child { border-bottom: 1px solid var(--ui-divider); }
.ui-row--interactive { border-radius: var(--ui-radius-control); cursor: pointer; transition: background-color var(--ui-motion-fast) var(--ui-ease-standard); }
.ui-row--interactive:hover { background: var(--ui-surface-muted); }
.ui-row[aria-selected="true"] {
  background: var(--ui-accent-soft);
  box-shadow: inset 3px 0 0 var(--ui-accent);
}
.ui-row__title { font-weight: 650; }
.ui-row__meta { color: var(--ui-text-secondary); font-size: var(--ui-text-xs); }

/* ---- Empty state (preserves layout, names the next step) --- */

.ui-empty-state {
  max-width: 46ch;
  margin-inline: auto;
  padding: var(--ui-space-6) var(--ui-space-4);
  border: 1px dashed var(--ui-divider-strong);
  border-radius: var(--ui-radius-surface);
  color: var(--ui-text-secondary);
  text-align: center;
}
.ui-empty-state h3, .ui-empty-state p { margin: 0; }
.ui-empty-state h3 { margin-bottom: var(--ui-space-2); color: var(--ui-text); font-size: var(--ui-text-lg); }

/* ---- Skeleton / loading (static under reduced motion) ------ */

.ui-skeleton {
  min-height: 1em;
  border-radius: var(--ui-radius-control);
  background: var(--ui-surface-muted);
  animation: ui-pulse 1.6s var(--ui-ease-standard) infinite alternate;
}
@keyframes ui-pulse { from { opacity: 1; } to { opacity: .45; } }

/* ---- Disclosure (native details/summary) ------------------- */

.ui-disclosure { border-top: 1px solid var(--ui-divider); padding-top: var(--ui-space-2); }
.ui-disclosure > summary {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  color: var(--ui-accent-hover);
  font-weight: 650;
  cursor: pointer;
}
.ui-disclosure > summary:hover { color: var(--ui-accent-active); }

/* ====================== Reduced motion ======================== */

@media (prefers-reduced-motion: reduce) {
  .product-shell *, .product-shell *::before, .product-shell *::after,
  .ui-button, .ui-row--interactive {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.product-shell__nav-separator { border-top: 1px solid var(--border, #d8e1db); margin: 14px 12px; }

.family-access-page[data-sano-view="family"] #account-settings { display: none; }
.family-access-page[data-sano-view="settings"] #product-main > :not(#account-settings):not(#family-access-status) { display: none; }
