/* Solitaire Sanctum — Gracefully Glitching LLC
   Gothic warmth, accessible by default.
   Palette: aubergine, teal, gold, dusty rose. */

:root {
  --aubergine-900: #1c0f20;
  --aubergine-800: #241326;
  --aubergine-700: #311a35;
  --aubergine-600: #432449;
  --aubergine-500: #5a3361;
  --gold: #c9a44a;
  --gold-soft: #e0c989;
  --teal: #2f8f86;
  --teal-soft: #6cc3ba;
  --rose: #c98fa0;
  --rose-soft: #e6c2cd;
  --ink: #1a1016;
  --parchment: #f4ecdd;
  --parchment-dim: #d8cdb8;
  --text: #efe6f2;
  --text-dim: #b9a7c0;
  --red: #b5485f;

  --card-w: clamp(46px, 8.2vw, 78px);
  --card-h: calc(var(--card-w) * 1.4);
  --stack-offset: calc(var(--card-h) * 0.27);
  --radius: 10px;
  --focus: var(--teal-soft);

  --motion: 1; /* set to 0 by reduce-motion */
  --t-fast: calc(120ms * var(--motion));
  --t-med: calc(220ms * var(--motion));
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: "Jost", system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--aubergine-600), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(47,143,134,0.18), transparent 60%),
    linear-gradient(160deg, var(--aubergine-900), var(--aubergine-800) 55%, var(--aubergine-700));
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px; top: 0;
  background: var(--gold);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
  z-index: 50;
}
.skip-link:focus { left: 0; }

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

/* ---------- Header ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(0.75rem, 3vw, 2rem) 0.9rem;
  border-bottom: 1px solid rgba(201,164,74,0.25);
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-mark {
  font-size: 2.1rem;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(201,164,74,0.45);
  line-height: 1;
}
.brand-text h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  margin: 0;
  color: var(--parchment);
}
.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.3px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  background: linear-gradient(180deg, var(--aubergine-600), var(--aubergine-700));
  border: 1px solid rgba(201,164,74,0.35);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--t-fast) ease, background var(--t-fast) ease, border-color var(--t-fast) ease;
}
.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--aubergine-500), var(--aubergine-600));
  border-color: var(--gold);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--gold), #a9863a);
  color: var(--ink);
  border-color: var(--gold-soft);
  font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); }

.deal-count { opacity: 0.75; font-variant-numeric: tabular-nums; }

.select-wrap { display: flex; align-items: center; gap: 0.4rem; }
.select-wrap label { font-size: 0.82rem; color: var(--text-dim); }
.select {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--aubergine-700);
  border: 1px solid rgba(201,164,74,0.35);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ---------- Status bar ---------- */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  padding: 0.7rem clamp(0.75rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(201,164,74,0.15);
}
.stat { display: flex; flex-direction: column; line-height: 1.2; }
.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
}
.stat-value {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.35rem;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- Board ---------- */
main {
  flex: 1;
  padding: 1.2rem clamp(0.5rem, 2.5vw, 2rem) 1.5rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: clamp(4px, 1vw, 12px);
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}
body.left-handed .board { direction: rtl; }
body.left-handed .column { direction: ltr; }

.column {
  position: relative;
  min-height: calc(var(--card-h) + 6 * var(--stack-offset));
  border-radius: var(--radius);
  padding-bottom: 4px;
}

/* Empty column drop slot */
.column-slot {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--card-h);
  border: 2px dashed rgba(201,164,74,0.35);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(201,164,74,0.4);
  font-size: 1.6rem;
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  margin-top: calc(-1 * var(--card-h) + var(--stack-offset));
  border-radius: var(--radius);
  border: 1px solid rgba(0,0,0,0.5);
  cursor: default;
  user-select: none;
  transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease, filter var(--t-fast) ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.card:first-child { margin-top: 0; }

.card.face-down {
  background:
    repeating-linear-gradient(45deg, rgba(201,164,74,0.10) 0 6px, transparent 6px 12px),
    radial-gradient(circle at 50% 40%, var(--aubergine-500), var(--aubergine-700));
  border-color: rgba(201,164,74,0.3);
}
.card.face-down::after {
  content: "\2660";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(201,164,74,0.35);
  font-size: calc(var(--card-w) * 0.42);
}

.card.face-up {
  background: linear-gradient(170deg, var(--parchment), var(--parchment-dim));
  color: var(--ink);
  cursor: pointer;
}
.card.face-up.playable:hover {
  filter: brightness(1.04);
  box-shadow: 0 4px 14px rgba(0,0,0,0.5), 0 0 0 2px rgba(108,195,186,0.5);
}

.card .corner {
  position: absolute;
  font-weight: 600;
  font-family: "Jost", sans-serif;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: calc(var(--card-w) * 0.26);
}
.card .corner.tl { top: 5px; left: 6px; }
.card .corner.br { bottom: 5px; right: 6px; transform: rotate(180deg); }
.card .pip-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.5);
  opacity: 0.9;
}
.card.suit-red { color: var(--red); }
.card.suit-black { color: var(--ink); }

.card.selected {
  box-shadow: 0 0 0 3px var(--gold), 0 6px 18px rgba(0,0,0,0.55);
  filter: brightness(1.06);
  transform: translateY(-4px);
}
.card.hint-source { animation: pulse-gold calc(900ms * var(--motion, 1)) ease 2; }
.card.hint-target { animation: pulse-teal calc(900ms * var(--motion, 1)) ease 2; }

@keyframes pulse-gold {
  0%,100% { box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 0 4px var(--gold), 0 6px 18px rgba(0,0,0,0.55); }
}
@keyframes pulse-teal {
  0%,100% { box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 0 4px var(--teal-soft), 0 6px 18px rgba(0,0,0,0.55); }
}

.card.cleared { animation: dissolve calc(360ms * var(--motion, 1)) ease forwards; }
@keyframes dissolve {
  to { opacity: 0; transform: translateY(-12px) scale(0.92); }
}

/* drop-eligible column highlight */
.column.droppable .column-slot,
.column.droppable > .card:last-child {
  box-shadow: 0 0 0 3px var(--teal-soft);
}

/* ---------- Hint line ---------- */
.hint-line {
  max-width: 1180px;
  margin: 1.1rem auto 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
  min-height: 1.2em;
}

/* ---------- How to play ---------- */
.how-to-play {
  max-width: 760px;
  margin: 1rem auto 0;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(201,164,74,0.25);
  border-radius: var(--radius);
  padding: 0.4rem 1.1rem;
}
.how-to-play summary {
  cursor: pointer;
  padding: 0.6rem 0.2rem;
  font-weight: 500;
  color: var(--gold-soft);
  list-style: none;
}
.how-to-play summary::-webkit-details-marker { display: none; }
.how-to-play summary::before { content: "\25B8"; margin-right: 0.5rem; color: var(--gold); }
.how-to-play[open] summary::before { content: "\25BE"; }
.how-to-body { padding: 0.2rem 0.2rem 0.8rem; color: var(--text-dim); line-height: 1.6; }
.how-to-body ul { margin: 0.2rem 0 0.8rem; padding-left: 1.2rem; }
.how-to-body li { margin-bottom: 0.5rem; }
.how-to-body strong { color: var(--text); }
.how-to-tip { font-style: italic; margin: 0; }
.how-to-body kbd {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82em;
  background: var(--aubergine-600);
  border: 1px solid rgba(201,164,74,0.4);
  border-radius: 5px;
  padding: 0.05em 0.4em;
  color: var(--gold-soft);
}

/* ---------- Funnel / signup ---------- */
.funnel {
  border-top: 1px solid rgba(201,164,74,0.2);
  background: rgba(0,0,0,0.16);
  padding: 1.4rem clamp(0.75rem, 3vw, 2rem);
}
.funnel-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 2.5rem;
  align-items: center;
  justify-content: space-between;
}
.funnel-pitch { max-width: 38ch; }
.funnel-pitch h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.5rem;
  margin: 0 0 0.3rem;
  color: var(--parchment);
}
.funnel-pitch p { margin: 0 0 0.5rem; color: var(--text-dim); line-height: 1.5; }
.funnel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.1rem; }
.funnel-link { color: var(--teal-soft); font-weight: 500; text-decoration: none; }
.funnel-link:hover { color: var(--gold-soft); text-decoration: underline; }

.tip-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: 1px solid var(--gold-soft);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  transition: transform var(--t-fast) ease, filter var(--t-fast) ease;
}
.tip-link:hover { transform: translateY(-1px); filter: brightness(1.05); }
.tip-heart { color: var(--red); font-size: 0.95em; }
body.high-contrast .tip-link { border-color: #000; }

.signup-form { flex: 1 1 320px; max-width: 420px; }
.signup-label { display: block; font-size: 0.9rem; color: var(--text); margin-bottom: 0.45rem; }
.signup-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.signup-row input[type="email"] {
  flex: 1 1 180px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--aubergine-700);
  border: 1px solid rgba(201,164,74,0.35);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
}
.signup-row input[type="email"]::placeholder { color: var(--text-dim); }
.signup-note { font-size: 0.78rem; color: var(--text-dim); margin: 0.5rem 0 0; }
.signup-note.success { color: var(--teal-soft); }
.signup-note.error { color: var(--rose-soft); }
/* Honeypot field — hidden from humans, visible to bots. */
.hp-field { position: absolute; left: -5000px; }

/* ---------- Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,5,12,0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: linear-gradient(170deg, var(--aubergine-700), var(--aubergine-800));
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 2.2rem 2rem;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.overlay-mark { font-size: 2.6rem; color: var(--gold); }
.overlay-card h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.9rem;
  margin: 0.4rem 0 0.6rem;
  color: var(--parchment);
}
.overlay-card p { color: var(--text-dim); line-height: 1.5; margin-bottom: 1.4rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid rgba(201,164,74,0.2);
  padding: 1rem clamp(0.75rem, 3vw, 2rem) 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.6rem;
  align-items: center;
  justify-content: space-between;
}
.footer-controls { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--text-dim);
  cursor: pointer;
}
.switch input { width: 1.05rem; height: 1.05rem; accent-color: var(--teal); cursor: pointer; }
.colophon {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  max-width: 30ch;
  line-height: 1.45;
}

/* ---------- High contrast mode ---------- */
body.high-contrast {
  --text: #ffffff;
  --text-dim: #e8e0ec;
  --parchment: #ffffff;
  --parchment-dim: #efefef;
  --red: #d4203f;
  --gold: #ffd34d;
  --gold-soft: #ffe48a;
}
body.high-contrast .card.face-up { border: 2px solid #000; }
body.high-contrast .card .corner,
body.high-contrast .card .pip-center { font-weight: 700; }
body.high-contrast .btn { border-color: var(--gold); }
body.high-contrast .tagline,
body.high-contrast .hint-line { color: var(--text); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { --motion: 0; }
}
body.reduce-motion { --motion: 0; }
body.reduce-motion * { animation: none !important; transition: none !important; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  :root { --stack-offset: calc(var(--card-h) * 0.22); }
  .site-header { flex-direction: column; align-items: flex-start; }
  .toolbar { width: 100%; }
  .stat-value { font-size: 1.1rem; }
  .card .corner { font-size: calc(var(--card-w) * 0.3); }
}
