/* Arcana & Number — Shared Stylesheet
 * Editorial parchment-and-ink (light) & slate-and-brass (dark)
 * Mobile-first, zero external dependencies, WCAG AA contrast
 */

:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-alt: #F2ECE2;
  --border: #DDD5C7;
  --text: #1C1917;
  --text-muted: #57534E;
  --accent: #7C4D12;
  --accent-contrast: #FFFFFF;
  --accent-soft: #F5E9D3;
  --secondary: #314468;
  --danger: #9F2A2A;
  --shadow: 0 4px 16px rgba(28, 25, 23, 0.06);

  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --container-max: 1080px;
}

:root[data-theme="dark"] {
  --bg: #111318;
  --surface: #191D26;
  --surface-alt: #222834;
  --border: #2F3748;
  --text: #F3F1EC;
  --text-muted: #A9B0BE;
  --accent: #D9A441;
  --accent-contrast: #111318;
  --accent-soft: #2C261A;
  --secondary: #8EA8D8;
  --danger: #F08A8A;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.75rem;
  color: var(--text);
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

h2 {
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
}

h3 {
  font-size: clamp(1.1rem, 2vw, 1.3rem);
}

p {
  margin: 0 0 1rem;
}

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

a:hover {
  opacity: 0.85;
}

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

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.75rem 1rem;
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header & Navigation */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.75rem 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  min-height: 44px;
}

.brand-link svg {
  color: var(--accent);
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-alt);
  opacity: 1;
}

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

/* Theme Toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 40px;
  min-width: 44px;
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: calc(var(--radius-md) - 3px);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.theme-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Main Layout */
main {
  flex: 1;
  padding: 1.75rem 0 3rem;
}

.section {
  margin-bottom: 2.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

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

.mono {
  font-family: var(--font-mono);
}

/* Buttons */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-alt);
  opacity: 1;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.08);
}

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

.btn-sm {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
}

/* Hero & Grid */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.hero-lead {
  font-size: 1.075rem;
  color: var(--text-muted);
  max-width: 65ch;
  margin-bottom: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .hero {
    padding: 2.25rem 2rem;
  }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Feature Cards & Principles */
.feature-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.feature-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.principle-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .principle-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.principle-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-width: 0;
}

.principle-item h3 {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.principle-item p {
  margin: 0;
  font-size: 0.925rem;
  color: var(--text-muted);
}

/* Disclaimer Banner */
.disclaimer-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--secondary);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  font-size: 0.925rem;
  color: var(--text);
}

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

/* Badges & Pills */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.85rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
  color: var(--secondary);
  border: 1px solid var(--border);
}

.badge-reversed {
  color: var(--danger);
}

.badge-master {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="number"],
.field input[type="search"] {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.field-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.error-box {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  background: var(--surface-alt);
  color: var(--danger);
  font-weight: 600;
}

.status-line {
  margin-top: 0.75rem;
  font-size: 0.925rem;
  color: var(--text-muted);
  min-height: 1.4em;
}

/* Tarot Spread Stage */
.tarot-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.spread-stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .spread-stage {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.spread-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.slot-header {
  text-align: center;
}

.slot-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.slot-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.tarot-card-btn {
  width: 100%;
  max-width: 230px;
  aspect-ratio: 2 / 3;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.tarot-card-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.tarot-card-btn.is-shuffling {
  animation: cardShuffle 0.38s ease-in-out;
}

@keyframes cardShuffle {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-1.5deg); }
  75% { transform: translateX(6px) rotate(1.5deg); }
  100% { transform: translateX(0); }
}

.tarot-card-back {
  width: 100%;
  height: 100%;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  gap: 0.65rem;
  color: var(--accent);
}

.tarot-card-back span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tarot-card-front {
  width: 100%;
  height: 100%;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  background: var(--surface);
}

.tarot-card-numeral {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.tarot-emblem {
  width: 84px;
  height: 84px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
}

.tarot-emblem.is-reversed {
  transform: rotate(180deg);
}

.tarot-card-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.tarot-card-title {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}

.question-quote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.9rem;
  margin: 0 0 1rem;
  background: var(--surface-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

.reflection-callout {
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0.9rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.75rem 0;
  font-size: 0.95rem;
}

details.contrast-details {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

details.contrast-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--secondary);
  min-height: 36px;
  display: flex;
  align-items: center;
}

/* Deck Guide */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-btn {
  min-height: 40px;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
}

.filter-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-width: 0;
}

.guide-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Numerology Results */
.num-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.num-badge-lg {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--accent);
}

.list-compact {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.25rem;
}

.list-compact li {
  margin-bottom: 0.25rem;
}

.math-steps {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  overflow-x: auto;
  margin-top: 0.5rem;
}

.math-steps p {
  margin: 0 0 0.4rem;
}

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

.chart-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

.chart-table th,
.chart-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: center;
}

.chart-table th {
  background: var(--surface-alt);
  font-weight: 700;
}

.chart-table tr.is-highlighted td {
  background: var(--accent-soft);
  font-weight: 600;
}

/* Rune Glyphs */
.rune-glyph-lg {
  font-size: 3.25rem;
  line-height: 1;
  color: var(--accent);
  font-weight: 700;
}

.rune-glyph-back {
  font-size: 2.25rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.85;
}

.rune-glyph-sm {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
