/* Rankings framework — mobile portrait first. Matches SailingSA navy system. */
:root {
  --rk-navy: #001f3f;
  --rk-ink: #1a2750;
  --rk-line: #94a3b8;
  --rk-soft: #e9eefb;
  --rk-bg: #f7f8fb;
  --rk-white: #ffffff;
  --rk-accent: #c45c26;
  --rk-muted: #5b6b86;
  --rk-touch: 44px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.rk-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--rk-bg);
  color: var(--rk-ink);
  line-height: 1.35;
}

.rk-header {
  background: var(--rk-navy);
  color: #fff;
  padding: 12px 14px;
}

.rk-header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--rk-touch);
}

.rk-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  min-height: var(--rk-touch);
}

.rk-logo img {
  height: 36px;
  width: auto;
  display: block;
}

.rk-logo-text {
  font-weight: 700;
  font-size: 1rem;
}

.rk-header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.rk-header-links a {
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 8px;
  min-height: var(--rk-touch);
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
}

.rk-header-links a:hover,
.rk-header-links a:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: underline;
}

.rk-beta {
  background: #fff3e6;
  color: #7a3b00;
  border-bottom: 1px solid #f0c49a;
  padding: 10px 14px;
  font-size: 0.9rem;
}

.rk-beta[hidden] { display: none !important; }

.rk-beta-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.rk-beta-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 4px;
  background: #7a3b00;
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.rk-feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--rk-touch);
  padding: 0 14px;
  border-radius: 8px;
  background: var(--rk-navy);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none !important;
  margin-left: auto;
}

.rk-feedback-btn:hover,
.rk-feedback-btn:focus-visible {
  background: #12325f;
}

.rk-title-beta {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #fff3e6;
  color: #7a3b00;
  font-size: 0.75rem;
  vertical-align: middle;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.rk-meta-plain { color: var(--rk-muted); }

.rk-feedback-grid {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.rk-feedback-card {
  display: block;
  background: var(--rk-white);
  border: 1px solid var(--rk-line);
  border-radius: 10px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  min-height: var(--rk-touch);
  cursor: pointer;
}

.rk-feedback-card strong {
  display: block;
  color: var(--rk-navy);
  margin-bottom: 4px;
}

.rk-feedback-card span {
  color: var(--rk-muted);
  font-size: 0.9rem;
}

.rk-feedback-card:hover,
.rk-feedback-card:focus-visible {
  border-color: var(--rk-navy);
  background: #fbfcff;
}

.rk-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px 48px;
}

.rk-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
  color: var(--rk-navy);
}

.rk-sub {
  margin: 0 0 14px;
  color: var(--rk-muted);
  font-size: 0.92rem;
}

.rk-info-hero {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
}

.rk-info-card {
  background: var(--rk-white);
  border: 1px solid var(--rk-line);
  border-radius: 12px;
  padding: 14px;
}

.rk-info-card-compact {
  padding: 12px 14px;
}

.rk-info-head {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.rk-info-title {
  margin: 0 0 4px;
  color: var(--rk-navy);
  font-size: 1.05rem;
}

.rk-info-note {
  margin-bottom: 0;
}

.rk-example-grid {
  display: grid;
  gap: 10px;
}

.rk-example-card {
  border: 1px solid #d8dfef;
  border-radius: 10px;
  padding: 12px;
  background: #fbfcff;
}

.rk-example-card h3 {
  margin: 0 0 4px;
  color: var(--rk-navy);
  font-size: 0.98rem;
}

.rk-example-card p {
  margin: 0;
  color: var(--rk-ink);
  font-size: 0.92rem;
  line-height: 1.45;
}

.rk-info-summary {
  margin: 0;
}

.rk-master-learn {
  margin-top: 10px;
  border: 1px solid #d8dfef;
  border-radius: 10px;
  background: #fbfcff;
  overflow: hidden;
}

.rk-master-learn summary {
  list-style: none;
  cursor: pointer;
  min-height: var(--rk-touch);
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: var(--rk-navy);
  font-weight: 700;
  font-size: 0.92rem;
}

.rk-master-learn summary::-webkit-details-marker {
  display: none;
}

.rk-master-learn summary::after {
  content: '▾';
  margin-left: auto;
  font-size: 0.95rem;
}

.rk-master-learn[open] summary::after {
  transform: rotate(180deg);
}

.rk-master-learn[open] summary {
  border-bottom: 1px solid #d8dfef;
  background: var(--rk-soft);
}

.rk-master-learn-body {
  display: grid;
  gap: 12px;
  padding: 12px 14px 14px;
}

.rk-learn-section h3 {
  margin: 0 0 4px;
  color: var(--rk-navy);
  font-size: 0.96rem;
}

.rk-learn-section p {
  margin: 0 0 8px;
  color: var(--rk-ink);
  font-size: 0.92rem;
  line-height: 1.5;
}

.rk-learn-section p:last-child {
  margin-bottom: 0;
}

.rk-example-card dl {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.rk-example-card dl div {
  display: grid;
  gap: 2px;
}

.rk-example-card dt {
  color: var(--rk-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.rk-example-card dd {
  margin: 0;
  color: var(--rk-ink);
  font-size: 0.92rem;
}

.rk-sub a,
.rk-prose a,
.rk-profile-note a,
.rk-list-meta a,
.rk-dl a {
  color: var(--rk-navy);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rk-sub a:hover,
.rk-prose a:hover,
.rk-profile-note a:hover,
.rk-list-meta a:hover,
.rk-dl a:hover {
  color: var(--rk-accent);
}

.rk-nav-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.rk-nav-tabs a {
  flex: 0 0 auto;
  min-height: var(--rk-touch);
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--rk-line);
  border-radius: 999px;
  background: var(--rk-white);
  color: var(--rk-navy);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.rk-nav-tabs a.is-active,
.rk-nav-tabs a:hover,
.rk-nav-tabs a:focus-visible {
  background: var(--rk-soft);
  border-color: var(--rk-navy);
}

.rk-toolbar {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.rk-search {
  width: 100%;
  min-height: var(--rk-touch);
  padding: 10px 12px;
  font-size: 16px; /* avoid iOS zoom */
  border: 1px solid var(--rk-line);
  border-radius: 8px;
  background: var(--rk-white);
  color: var(--rk-ink);
}

.rk-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.rk-filters select {
  min-height: var(--rk-touch);
  padding: 8px 10px;
  font-size: 16px;
  border: 1px solid var(--rk-line);
  border-radius: 8px;
  background: var(--rk-white);
  color: var(--rk-ink);
}

.rk-sortbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rk-sortbar button {
  min-height: var(--rk-touch);
  padding: 0 12px;
  border: 1px solid var(--rk-line);
  border-radius: 8px;
  background: var(--rk-white);
  color: var(--rk-navy);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.rk-sortbar button.is-active {
  background: var(--rk-soft);
  border-color: var(--rk-navy);
}

.rk-sortbar button:hover,
.rk-sortbar button:focus-visible {
  border-color: var(--rk-navy);
}

.rk-list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 10px;
  font-size: 0.85rem;
  color: var(--rk-muted);
}

.rk-meta-sep { opacity: 0.6; }
.rk-mock-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff3e6;
  color: #7a3b00;
  font-weight: 700;
  font-size: 0.75rem;
}

.rk-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rk-row {
  display: block;
  background: var(--rk-white);
  border: 1px solid var(--rk-line);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  min-height: var(--rk-touch);
  text-decoration: none;
  color: inherit;
}

.rk-row-aged {
  background: #f4f6fa;
  color: #5d6877;
  font-size: 0.94rem;
}

.rk-row-aged .rk-name,
.rk-row-aged .rk-rank,
.rk-row-aged .rk-points,
.rk-row-aged .rk-meta-link {
  color: #566274;
}

.rk-row:hover,
.rk-row:focus-visible {
  border-color: var(--rk-navy);
  background: #fbfcff;
  outline: none;
}

.rk-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
  line-height: 1.2;
}

.rk-rank,
.rk-points,
.rk-audit-ver {
  min-height: 0;
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  color: var(--rk-navy);
  text-decoration: none;
  padding: 2px 0;
}

.rk-rank:hover,
.rk-points:hover,
.rk-audit-ver:hover,
.rk-name:hover,
.rk-meta-link:hover {
  color: var(--rk-accent);
  text-decoration: underline;
}

.rk-points { font-variant-numeric: tabular-nums; white-space: nowrap; }

.rk-rank-status {
  color: #6e7784;
  font-size: 0.82rem;
}

.rk-name {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--rk-navy);
  text-decoration: none;
  min-height: 0;
  line-height: 1.25;
  margin: 1px 0;
}

.rk-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 0;
  font-size: 0.78rem;
  color: var(--rk-muted);
  line-height: 1.25;
}

.rk-rank-summary,
.rk-rank-summary-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 3px;
  color: var(--rk-muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.rk-rank-summary-block {
  margin: 0 0 10px;
}

.rk-meta-link {
  color: var(--rk-muted);
  text-decoration: none;
  font-weight: 600;
  min-height: 0;
  display: inline-flex;
  align-items: center;
  padding: 1px 0;
}

.rk-dot { opacity: 0.55; }

.rk-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}

.rk-status-badge-aged {
  background: #e5e8ee;
  color: #5f6774;
}

.rk-score-details-btn {
  margin-top: 6px;
  min-height: var(--rk-touch);
  border: 1px solid var(--rk-line);
  border-radius: 8px;
  background: #fff;
  color: var(--rk-navy);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0 10px;
  width: max-content;
  cursor: pointer;
}

.rk-score-details-btn:hover,
.rk-score-details-btn:focus-visible {
  border-color: var(--rk-navy);
  background: var(--rk-soft);
  outline: 2px solid transparent;
}

.rk-audit-popup {
  position: fixed;
  z-index: 3000;
  width: min(460px, calc(100vw - 24px));
  max-height: min(80vh, 680px);
  overflow: auto;
  border: 1px solid var(--rk-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 31, 63, 0.22);
}

.rk-audit-popup[hidden] { display: none !important; }

.rk-audit-popup-inner { padding: 10px; }

.rk-audit-popup-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.rk-audit-popup-title {
  margin: 0;
  color: var(--rk-navy);
  font-size: 1rem;
}

.rk-audit-popup-sub {
  margin: 1px 0 0;
  color: var(--rk-muted);
  font-size: 0.8rem;
}

.rk-audit-close {
  border: 1px solid var(--rk-line);
  border-radius: 7px;
  background: #fff;
  min-height: 34px;
  padding: 0 9px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--rk-navy);
}

.rk-audit-pillbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.rk-audit-pillbar span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--rk-soft);
  color: var(--rk-ink);
  padding: 0 8px;
  font-size: 0.72rem;
}

.rk-audit-section {
  margin-top: 8px;
  border: 1px solid #d8dfef;
  border-radius: 8px;
  padding: 8px;
}

.rk-audit-section h4 {
  margin: 0 0 6px;
  color: var(--rk-navy);
  font-size: 0.88rem;
}

.rk-audit-row-item {
  border-top: 1px solid #edf1fa;
  padding: 7px 0;
}

.rk-audit-row-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.rk-audit-row-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--rk-ink);
}

.rk-audit-row-meta {
  color: var(--rk-muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.rk-audit-row-grid {
  margin-top: 4px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  font-size: 0.74rem;
}

.rk-audit-row-grid span { color: var(--rk-muted); }
.rk-audit-row-grid strong { color: var(--rk-ink); font-weight: 700; }

.rk-audit-row-reason {
  margin-top: 4px;
  font-size: 0.74rem;
  color: #7a3b00;
}

.rk-audit-totals {
  margin-top: 8px;
  border-top: 1px dashed #cad3e8;
  padding-top: 6px;
  font-size: 0.79rem;
  display: grid;
  gap: 2px;
}

.rk-audit-mismatch {
  margin-top: 6px;
  border: 1px solid #b42318;
  border-radius: 7px;
  padding: 6px;
  font-size: 0.74rem;
  color: #b42318;
  font-weight: 800;
}

.rk-audit-muted,
.rk-audit-popup-loading,
.rk-audit-popup-error {
  color: var(--rk-muted);
  font-size: 0.8rem;
}

.rk-audit-change,
.rk-audit-tech {
  display: grid;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--rk-ink);
}

.rk-audit-updated {
  margin-top: 8px;
  border: 1px solid #16a34a;
  border-radius: 7px;
  padding: 6px;
  font-size: 0.75rem;
  color: #166534;
  background: #f0fdf4;
}

.rk-audit-popup.is-mobile {
  width: 100%;
  max-width: 100%;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  max-height: min(72vh, 560px);
  border-radius: 12px 12px 0 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.rk-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.rk-btn {
  min-height: var(--rk-touch);
  min-width: var(--rk-touch);
  padding: 0 14px;
  border: 1px solid var(--rk-navy);
  border-radius: 8px;
  background: var(--rk-navy);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.rk-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rk-btn-ghost {
  background: var(--rk-white);
  color: var(--rk-navy);
}

.rk-page-label {
  font-size: 0.9rem;
  color: var(--rk-muted);
  min-height: var(--rk-touch);
  display: inline-flex;
  align-items: center;
}

.rk-loading,
.rk-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--rk-muted);
  background: var(--rk-white);
  border: 1px dashed var(--rk-line);
  border-radius: 10px;
}

.rk-loading[hidden],
.rk-empty[hidden] { display: none !important; }

.rk-spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 10px;
  border: 3px solid var(--rk-soft);
  border-top-color: var(--rk-navy);
  border-radius: 50%;
  animation: rk-spin 0.7s linear infinite;
}

@keyframes rk-spin { to { transform: rotate(360deg); } }

.rk-prose {
  color: #333;
  font-size: 0.98rem;
  line-height: 1.55;
  margin: 0 0 12px;
}

.rk-prose h2,
.rk-section-title {
  font-size: 1.05rem;
  color: var(--rk-navy);
  margin: 1.2rem 0 0.4rem;
  border-bottom: 2px solid var(--rk-accent);
  padding-bottom: 0.2rem;
}

.rk-dl {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  background: var(--rk-white);
  border: 1px solid var(--rk-line);
  border-radius: 10px;
  padding: 12px;
}

.rk-dl > div {
  display: grid;
  gap: 2px;
}

.rk-dl dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rk-muted);
  font-weight: 700;
}

.rk-dl dd {
  margin: 0;
  font-size: 0.95rem;
  color: var(--rk-ink);
}

.rk-bullets {
  margin: 0;
  padding-left: 1.1rem;
}

.rk-profile-note {
  font-size: 0.9rem;
  color: var(--rk-muted);
  margin: 12px 0 0;
}

.rk-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 12px 32px;
  text-align: center;
  color: var(--rk-muted);
  font-size: 0.85rem;
  border-top: 1px solid #e0e0e0;
}

.rk-footer a {
  color: var(--rk-navy);
  font-weight: 600;
  text-decoration: none;
}

.rk-footer a:hover { text-decoration: underline; }

@media (min-width: 640px) {
  .rk-example-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rk-example-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
  }
  .rk-filters {
    grid-template-columns: repeat(3, 1fr);
  }
  .rk-logo img { height: 42px; }
  .rk-title { font-size: 1.55rem; }
  .rk-dl > div {
    grid-template-columns: 200px 1fr;
    gap: 10px;
    align-items: start;
  }
}
