/* ==========================================================================
   moderncss.css — site-wide stylesheet for johnarcher pages
   Light + dark palettes, system font stack, cards, buttons, sticky header.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: rgba(0, 0, 0, 0.08);

  --accent: #0071e3;
  --accent-hover: #0060c2;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --on-accent: #ffffff;
  --danger: #d70015;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.05), 0 24px 60px rgba(0, 0, 0, 0.12);

  --max-width: 1100px;
  --gutter: clamp(16px, 4vw, 40px);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0b0b0d;
    --surface: #161618;
    --surface-2: #222226;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: rgba(255, 255, 255, 0.1);

    --accent: #2997ff;
    --accent-hover: #5fb0ff;
    --accent-soft: rgba(41, 151, 255, 0.16);
    --on-accent: #0b0b0d;
    --danger: #ff453a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 1em;
}

code,
pre {
  font-family: var(--font-mono);
}

.muted {
  color: var(--muted);
}

/* ---------- JavaScript gate (kept from the original site) ---------- */
.content {
  display: none;
}

.no-js {
  display: block;
  max-width: 560px;
  margin: 80px auto;
  padding: 24px 28px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--danger);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.page {
  padding-block: clamp(32px, 6vw, 72px);
}

.section {
  margin-top: clamp(40px, 7vw, 80px);
}

.section:first-child {
  margin-top: 0;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  min-height: 64px;
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  object-fit: cover;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-inline-start: auto;
}

.nav a {
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.nav a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav .btn {
  margin-inline-start: 8px;
}

/* ---------- Language switcher (populated by i18n.js) ---------- */
.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.lang-switcher:hover {
  background: var(--surface-2);
}

.lang-switcher:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.lang-switcher svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--muted);
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  padding: 0 22px 0 0;
  max-width: 170px;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right center / 16px 16px;
  color: inherit;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  text-overflow: ellipsis;
}

.lang-select:focus {
  outline: none;
}

.lang-select option {
  color: initial;
  background: initial;
}

@media (prefers-color-scheme: dark) {
  .lang-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23a1a1a6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

/* ---------- Right-to-left languages (Arabic, Hebrew, Urdu) ---------- */
[dir="rtl"] .lang-switcher {
  padding: 6px 12px 6px 8px;
}

[dir="rtl"] .lang-select {
  padding: 0 0 0 22px;
  background-position: left center;
}

[dir="rtl"] .link-list a::after {
  content: "←";
}

[dir="rtl"] .link-list a:hover {
  transform: translateX(-3px);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease),
    transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-lg {
  padding: 14px 26px;
  font-size: 1.05rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-block: 16px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  gap: 20px;
  justify-items: center;
  text-align: center;
  padding-block: clamp(16px, 4vw, 40px) clamp(32px, 6vw, 64px);
}

.hero .lead {
  max-width: 620px;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--muted);
}

.avatar {
  width: clamp(140px, 24vw, 200px);
  height: clamp(140px, 24vw, 200px);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--surface);
}

.page-title {
  margin-bottom: clamp(20px, 4vw, 40px);
}

.page-title p {
  color: var(--muted);
  max-width: 640px;
}

/* ---------- Cards and grids ---------- */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

.grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

a.card {
  color: inherit;
}

a.card:hover {
  text-decoration: none;
  color: inherit;
}

.card-media {
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  padding: 18px;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.card-body {
  padding: 18px 20px 20px;
  display: grid;
  gap: 6px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0;
}

.card-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-link {
  margin-top: 6px;
  font-weight: 600;
}

/* Feature panel (large image + text side by side) */
.panel {
  display: grid;
  gap: 24px;
  align-items: center;
  padding: clamp(20px, 4vw, 36px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 760px) {
  .panel {
    grid-template-columns: 1.1fr 1fr;
  }
}

.panel img {
  width: 100%;
  border-radius: var(--radius-sm);
}

.panel p:last-child {
  margin-bottom: 0;
}

/* ---------- Link lists (education, nav-style lists) ---------- */
.link-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list a,
.link-list .plain {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.link-list a::after {
  content: "→";
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.link-list a:hover {
  background: var(--surface-2);
  text-decoration: none;
  transform: translateX(3px);
}

.link-list .plain {
  color: var(--muted);
}

.link-list .note {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Facts / definition lists ---------- */
.facts {
  display: grid;
  gap: 12px;
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.facts div {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.facts dt {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.facts dd {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

/* ---------- Comparison tables (JNA-Compare.html) ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.compare {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.compare th,
.compare td {
  padding: 14px 20px;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.compare tr:last-child > * {
  border-bottom: 0;
}

.compare thead th {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
}

.compare tbody th {
  width: 28%;
  font-weight: 600;
  color: var(--muted);
}

.compare td {
  width: 36%;
  font-weight: 500;
}

.compare .none {
  color: var(--muted);
  font-weight: 400;
}

/* App-vs-app comparison (MysteryDecisions.html) */
.compare caption {
  caption-side: top;
  padding: 18px 20px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: start;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.compare .app-head {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.compare .app-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}

.compare-apps tbody th {
  color: var(--text);
}

/* Single-column panel (text only) */
.panel-stack {
  grid-template-columns: 1fr;
}

/* ---------- App page (FamilyWishlist.html) ---------- */
.app-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.app-hero img {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.app-hero .eyebrow {
  margin-bottom: 6px;
}

.app-hero h1 {
  margin: 0;
}

.features {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.features div {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.features h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.features p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.faq-section {
  margin-top: 32px;
}

.faq-section h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.faq-section h3 svg {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--muted);
}

.faq-group {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.faq {
  border-bottom: 1px solid var(--border);
}

.faq:last-child {
  border-bottom: 0;
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: -5px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease), margin 0.2s var(--ease);
}

.faq[open] summary::after {
  margin-top: 5px;
  transform: rotate(225deg);
}

.faq summary:hover {
  background: var(--surface-2);
}

.faq p {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
}

.table-wrap + .panel {
  margin-top: 20px;
}

/* ---------- Callouts ---------- */
.callout {
  padding: 18px 22px;
  background: var(--accent-soft);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-sm);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-warn {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-inline-start-color: var(--danger);
}

/* ---------- Code / addresses ---------- */
.code-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.code-block code {
  flex: 1 1 200px;
  font-size: 0.95rem;
  word-break: break-all;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: clamp(48px, 8vw, 96px);
  padding-block: 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
}

.footer-inner a {
  color: var(--muted);
}

.footer-inner a:hover {
  color: var(--accent);
}

/* ---------- Utilities ---------- */
.text-center {
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
