/* SAR compare and rankings, layout v3.1.
   Isolated full-width shell — does not use the site layout grid, whose 260px / 620px / 360px
   grid was leaving a leftover sidebar and stacking the header on mobile.
   Uses the same rfsx theme tokens as the rest of the site.
   v3.1: content-hashed CSS hrefs, icon-only theme toggle on narrow screens,
   centered headings and picker, and no horizontal overflow at any width. */

/* --- Shell: slim one-row sticky top bar, then full-width compare --- */

.sar-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* One thin row at every width: brand + small title on the left, Menu and
   Light/Dark on the right. Target 44–52px tall on mobile. */
.sar-shell .sar-topbar,
.sar-topbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 12px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 48px;
  min-height: 48px;
  max-height: 52px;
  padding: 0 16px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg, inherit);
  box-sizing: border-box;
}

.sar-brand {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  max-width: 42%;
  margin: 0;
  padding: 0;
}

.sar-topbar-title,
.sar-shell .sar-topbar-title,
.sar-topbar h1.sar-topbar-title {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.sar-topbar-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: 0 0 auto;
  flex-shrink: 0;
}

/* Menu and theme toggle must not shrink off the row. */
.sar-topbar-actions,
.sar-topbar-actions .sar-menu,
.sar-topbar-actions .sar-menu-toggle,
.sar-topbar-actions .sar-theme-toggle {
  flex-shrink: 0;
}

/* Compact theme toggle: word on wide screens, sun/moon icon on narrow ones. */
.sar-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-height: 36px;
  min-width: 36px;
  box-sizing: border-box;
}
.sar-theme-icon {
  display: none;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.sar-theme-text { white-space: nowrap; }


.sar-main,
.sar-content {
  max-width: 100%;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  box-sizing: border-box;
  overflow-x: clip;
}

/* Footer is inset, not flush against the left edge. */
.sar-footer {
  padding: 16px 20px 28px;
  color: var(--muted);
  font-size: 0.88rem;
}
.sar-footer p { margin: 0; }
.sar-footer a { color: inherit; }

/* Hamburger: sits next to the light/dark toggle, compact enough for a 48px bar. */
.sar-menu { position: relative; }
.sar-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  box-sizing: border-box;
}
.sar-menu-toggle:hover,
.sar-menu-toggle:focus-visible {
  outline: 2px solid var(--accent, #d94000);
  outline-offset: 2px;
}
.sar-menu-toggle[aria-expanded="true"] {
  border-color: var(--accent, #d94000);
}
.sar-menu-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 16px;
  flex: 0 0 16px;
}
.sar-menu-bars span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.sar-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 0;
  width: max(220px, 100%);
  max-width: 320px;
  background: var(--cardSolid, var(--bg, #111));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  z-index: 50;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
.sar-menu-list { list-style: none; margin: 0; padding: 0; }
.sar-menu-list a {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}
.sar-menu-list a:hover,
.sar-menu-list a:focus-visible {
  background: rgba(127, 127, 127, 0.14);
  outline: none;
}

/* --- Page body: compact, full width, comparison sits high --- */

.sar-page {
  max-width: 100%;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 8px 16px 36px;
  color: var(--text);
  box-sizing: border-box;
  overflow-x: clip;
}

/* Rankings still get a short heading; compare puts the title in the top bar. */

.sar-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
  width: 100%;
  max-width: 100%;
  text-align: center;
  white-space: normal;
  box-sizing: border-box;
}

.sar-hero { margin: 4px 0 12px; }
.sar-kicker { color: var(--muted); font-size: 0.88rem; margin: 0 0 4px; }
.sar-kicker a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.sar-hero h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.2;
}
.sar-lead { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; max-width: 54rem; }

.sar-toolbar {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: center;
}
.sar-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.sar-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  background: var(--surface, transparent);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.2;
}
.sar-chip-remove {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
  text-decoration: underline;
  padding: 4px 8px;
  min-height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.sar-chip-remove:hover,
.sar-chip-remove:focus-visible { color: var(--text); }

.sar-missing,
.sar-limit { color: #b45309; font-size: 0.9rem; margin: 0; }
html.dark .sar-missing, html[data-theme="dark"] .sar-missing,
html.dark .sar-limit, html[data-theme="dark"] .sar-limit { color: #fbbf24; }

.sar-pickers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.sar-picker {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 0 1 auto;
}
.sar-picker span { font-size: 0.82rem; font-weight: 650; color: var(--muted); white-space: nowrap; }
.sar-picker select {
  font: inherit;
  color: var(--text);
  background: var(--cardSolid, var(--card, transparent));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 36px;
  min-width: min(148px, 100%);
  max-width: 100%;
  width: auto;
  box-sizing: border-box;
}
.sar-picker-model select { min-width: min(220px, 100%); max-width: 100%; }
.sar-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  width: 100%;
  max-width: 100%;
  text-align: center;
  white-space: normal;
  box-sizing: border-box;
}
.sar-count a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.sar-card {
  background: var(--card, rgba(127, 127, 127, 0.06));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px 12px;
  margin: 0 0 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: clip;
}
.sar-empty { padding: 20px 8px; text-align: center; color: var(--muted); }

.sar-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sar-caption { caption-side: bottom; text-align: left; color: var(--muted); font-size: 0.88rem; padding-top: 12px; line-height: 1.45; }
.sar-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 8px 6px;
  box-sizing: border-box;
}
.sar-table th,
.sar-table td {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.sar-table thead th { vertical-align: top; text-align: center; font-weight: 700; padding: 0; }
.sar-phone-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 8px 8px; }
.sar-phone-name { font-size: 1rem; line-height: 1.3; overflow-wrap: break-word; max-width: 100%; min-width: 0; }
.sar-phone-img {
  width: min(120px, 100%);
  height: auto;
  aspect-ratio: 1;
  max-width: 100%;
  object-fit: contain;
  background: var(--surface, transparent);
  border-radius: 12px;
}
.sar-phone-specs { display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; font-weight: 500; color: var(--muted); text-align: left; width: 100%; max-width: 100%; min-width: 0; overflow-wrap: break-word; }
.sar-phone-specs a { color: inherit; text-decoration: underline; }

.sar-section {
  text-align: center;
  font-size: 0.92rem;
  font-weight: 750;
  padding: 10px 8px 2px;
  border: none;
  color: var(--text);
}
.sar-values td { text-align: center; }
.sar-value {
  border-radius: 12px;
  padding: 12px 8px;
  font-weight: 800;
  font-size: 1.15rem;
  background: rgba(127, 127, 127, 0.1);
}
.sar-num { display: block; }
.sar-mark { display: block; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.02em; margin-top: 2px; text-transform: lowercase; }

.sar-value.is-best { background: rgba(34, 197, 94, 0.72); color: #052e16; }
.sar-value.is-worst { background: rgba(248, 113, 113, 0.85); color: #450a0a; }
.sar-value.is-tie { background: rgba(251, 146, 60, 0.78); color: #431407; }
.sar-value.is-gray, .sar-value.is-empty { background: rgba(127, 127, 127, 0.16); color: var(--text); }

html.dark .sar-value.is-best, html[data-theme="dark"] .sar-value.is-best { background: rgba(34, 197, 94, 0.88); color: #052e16; }
html.dark .sar-value.is-worst, html[data-theme="dark"] .sar-value.is-worst { background: rgba(248, 113, 113, 0.95); color: #1f0505; }
html.dark .sar-value.is-tie, html[data-theme="dark"] .sar-value.is-tie { background: rgba(251, 146, 60, 0.92); color: #2a1004; }

.sar-note { margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.sar-note summary { cursor: pointer; font-weight: 650; color: var(--text); }
.sar-note p { margin: 8px 0 0; }

.sar-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.sar-tabs a {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.9rem;
  text-decoration: none;
}
.sar-tabs a:hover { color: var(--text); }
.sar-tabs a[aria-current="page"] {
  color: var(--text);
  border-color: var(--accent, #d94000);
  box-shadow: inset 0 0 0 1px var(--accent, #d94000);
}

.sar-rank-table { width: 100%; border-collapse: collapse; }
.sar-rank-table th, .sar-rank-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.sar-rank-table th { font-size: 0.82rem; color: var(--muted); font-weight: 700; }
.sar-rank-name { display: inline-flex; align-items: center; gap: 10px; color: inherit; font-weight: 650; text-decoration: none; }
.sar-rank-name:hover { text-decoration: underline; }
.sar-rank-name img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: var(--surface, transparent); }
.sar-unranked { color: var(--muted); }

@media (max-width: 700px) {
  .sar-page { padding: 6px 12px 32px; }
  .sar-shell .sar-topbar,
  .sar-topbar {
    height: 48px;
    min-height: 44px;
    max-height: 52px;
    padding: 0 10px;
    gap: 8px;
    flex-wrap: nowrap;
    flex-direction: row;
  }
  .sar-topbar-title,
  .sar-shell .sar-topbar-title,
  .sar-topbar h1.sar-topbar-title { font-size: 1rem; }
  .sar-brand { font-size: 0.88rem; max-width: 36%; }
  .sar-menu-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .sar-picker select { min-width: 0; max-width: 100%; }
  .sar-picker-model select { min-width: 0; max-width: 100%; }
  .sar-phone-img { width: 92px; height: 92px; }
  .sar-value { font-size: 1.02rem; padding: 10px 4px; }
  .sar-table { border-spacing: 4px 6px; }
  .sar-hero h1 { font-size: 1.2rem; }
  .sar-footer { padding: 16px 16px 28px; }
  .sar-menu-panel {
    position: fixed;
    top: 48px;
    right: 8px;
    left: auto;
    max-width: min(320px, calc(100% - 16px));
  }
}

@media (max-width: 480px) {
  /* Icon-only theme toggle; the word is clipped so the 36px control fits. */
  .sar-theme-icon { display: inline-flex; }
  .sar-theme-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .sar-topbar-actions .sar-theme-toggle {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    padding: 0;
  }
}

@media (max-width: 420px) {
  .sar-page { padding: 4px 10px 28px; }
  .sar-phone-specs { font-size: 0.72rem; }
  .sar-shell .sar-topbar,
  .sar-topbar {
    height: 48px;
    min-height: 44px;
    max-height: 52px;
    padding: 0 8px;
    gap: 6px;
    flex-wrap: nowrap;
    flex-direction: row;
    overflow: visible;
  }
  .sar-brand { max-width: 28%; min-width: 0; font-size: 0.82rem; }
  .sar-topbar-title,
  .sar-shell .sar-topbar-title,
  .sar-topbar h1.sar-topbar-title { font-size: 0.95rem; }
  /* Both Menu and Light/Dark stay in the one row at 360–390px. */
  .sar-topbar-actions {
    flex: 0 0 auto;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow: visible;
  }
  .sar-topbar-actions .sar-menu,
  .sar-topbar-actions .sar-menu-toggle,
  .sar-topbar-actions .sar-theme-toggle {
    flex-shrink: 0;
    display: inline-flex;
  }
}

/* ===== SAR public notice (v2, collapsed details) ======================== */
/* Same shape as .sar-note, but red. Collapsed on every screen size. */
.sar-note.sar-notice {
  margin: 8px 0 0;
  color: #8f1d1d;
  font-size: 0.92rem;
  line-height: 1.5;
}
.sar-note.sar-notice summary {
  cursor: pointer;
  font-weight: 650;
  color: #b42318;
}
.sar-note.sar-notice p { margin: 8px 0 0; }
.sar-notice h2,
.sar-notice #sar-notice-heading {
  margin: 12px 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  color: #9b1c1c;
}
.sar-notice a {
  color: #9b1c1c;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.sar-notice a:hover { color: #7a1410; }

html.dark .sar-note.sar-notice,
html[data-theme="dark"] .sar-note.sar-notice {
  color: #ffb4b0;
}
html.dark .sar-note.sar-notice summary,
html[data-theme="dark"] .sar-note.sar-notice summary {
  color: #ff8a80;
}
html.dark .sar-notice h2,
html.dark .sar-notice #sar-notice-heading,
html[data-theme="dark"] .sar-notice h2,
html[data-theme="dark"] .sar-notice #sar-notice-heading {
  color: #ff9b94;
}
html.dark .sar-notice a,
html[data-theme="dark"] .sar-notice a {
  color: #ffc2be;
}
html.dark .sar-notice a:hover,
html[data-theme="dark"] .sar-notice a:hover {
  color: #ffe0de;
}
