/* ── Design tokens ──────────────────────────────────────────
   Light is the default. html[data-theme="dark"] is set by the
   early script in each page head (saved ra-theme, else system).
   Newsreader and Public Sans load from Google Fonts in each head.
   ─────────────────────────────────────────────────────────── */
:root {
  --ink: #000000;
  --paper: #ffffff;
  --green: #0C874C;
  --card: #ffffff;
  --line: rgba(0, 0, 0, 0.16);
  --muted: rgba(0, 0, 0, 0.62);
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", serif;
  --sans: "Public Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;

  /* App-only: error text, control radii */
  --error: #B42318;
  --radius-sm: 2px;
  --radius-md: 4px;
}

html[data-theme="dark"] {
  --ink: #ffffff;
  --paper: #000000;
  --card: #141414;
  --line: rgba(255, 255, 255, 0.2);
  --muted: rgba(255, 255, 255, 0.68);
  color-scheme: dark;

  --error: #F97066;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

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

body {
  font-family: var(--sans);
  font-weight: 400;
  background-color: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

::selection {
  background: var(--green);
  color: #ffffff;
}

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

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--green);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--green);
}

p {
  color: var(--ink);
}

strong { font-weight: 600; }

small, .muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Icons (inline SVG, currentColor) ───────────────────── */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: -0.15em;
}

.icon--spin { animation: icon-spin 0.9s linear infinite; }

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

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--green);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--green);
  color: #ffffff;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.btn-secondary {
  background-color: var(--card);
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.btn-ghost {
  background-color: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Inputs ─────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  background-color: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-family: var(--sans);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="search"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.375rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

/* ── Cards / Panels ─────────────────────────────────────── */
.card {
  background-color: var(--card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--line);
}

.panel {
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

/* ── Layout helpers ─────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-narrow {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (max-width: 768px) {
  .container,
  .container-narrow {
    padding: 0 1.25rem;
  }
}

.page {
  padding: 3rem 0;
}

/* ── Site header ────────────────────────────────────────── */
.site-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 12px 24px;
  background: var(--paper);
  flex-shrink: 0;
}

/* Range Green rule fading right, as on rystedtadvisory.com */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background-image: linear-gradient(90deg, var(--green), transparent 92%);
  pointer-events: none;
}

.site-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

@media (max-width: 480px) {
  .site-header { padding: 12px 16px; gap: 12px; }
  .site-header__actions { gap: 12px; }
}

/* Logo plate. Copied from rystedtadvisory.com styles.css; header logo is 40px here. */
.logo-plate {
  display: inline-flex;
  align-items: center;
  background: var(--paper);
  flex: 0 0 auto;
  line-height: 0;
}

.site-header .logo-plate img { height: 40px; width: auto; animation: none; }

.site-footer .logo-plate img { height: 34px; width: auto; }

.logo-white { display: none; }

html[data-theme="dark"] .logo-standard { display: none; }

html[data-theme="dark"] .logo-white { display: block; }

/* Physical lightswitch. Range Green marks the side that is on. */
.nav-lightswitch {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.lightswitch__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: inline-flex;
  color: rgba(0, 0, 0, 0.28);
  transition: color 0.25s ease;
}

.lightswitch__icon svg { width: 100%; height: 100%; display: block; }

.lightswitch__icon--sun { color: var(--green); }

html[data-theme="dark"] .lightswitch__icon--sun { color: rgba(255, 255, 255, 0.28); }

.lightswitch__icon--moon { color: rgba(0, 0, 0, 0.28); }

html[data-theme="dark"] .lightswitch__icon--moon { color: #ffffff; }

.lightswitch {
  display: inline-flex;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 7px;
}

.lightswitch__plate,
.lightswitch__track {
  box-sizing: content-box;
}

.lightswitch__plate {
  position: relative;
  width: 54px;
  height: 24px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.32);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.lightswitch:hover .lightswitch__plate {
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

html[data-theme="dark"] .lightswitch__plate {
  background: #000000;
  border-color: var(--green);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.lightswitch__screw {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffffff, #b6b6b6 55%, #7c7c7c 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}

html[data-theme="dark"] .lightswitch__screw {
  background: radial-gradient(circle at 35% 32%, #4a4a4a, #1c1c1c 60%, #050505 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.lightswitch__track {
  position: relative;
  width: 36px;
  height: 14px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  flex-shrink: 0;
}

html[data-theme="dark"] .lightswitch__track {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.65);
}

.lightswitch__rocker {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, #2e2e2e, #050505);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease, box-shadow 0.25s ease;
}

html[data-theme="dark"] .lightswitch__rocker {
  transform: translateX(18px);
  background: var(--green);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* ── Status badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.badge-draft    { color: var(--muted); }
.badge-sent     { color: var(--ink); border-color: var(--ink); }
.badge-viewed   { color: var(--ink); border-color: var(--ink); background: var(--line); }
.badge-signed   { color: #ffffff; border-color: var(--green); background: var(--green); }
.badge-expired  { color: var(--muted); border-style: dashed; }
.badge-lost     { color: var(--error); border-color: var(--error); }

/* ── Divider ────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.5rem 0;
}

/* ── Utilities ──────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-ink    { color: var(--ink); }
.text-green  { color: var(--green); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

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