/* Ajo — warm editorial dark. Ink with a plum undertone, bone text,
   clay for actions, indigo for structure, gold strictly for money. */

:root {
  --ink: #191114;
  --ink-2: #211619;
  --surface: #251a1e;
  --surface-2: #2d2025;
  --line: rgba(240, 231, 216, 0.13);
  --line-strong: rgba(240, 231, 216, 0.26);

  --bone: #f0e7d8;
  --bone-dim: #cdbfae;
  --muted: #9c8d80;

  --clay: #c96f4a;
  --clay-bright: #dd8059;
  --clay-deep: #a4532f;
  --indigo: #8b90d8;
  --indigo-dim: #5a5f9e;
  --gold: #e2b457;
  --gold-soft: rgba(226, 180, 87, 0.16);
  --green: #8fb586;
  --red: #d98577;

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;

  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(1100px 700px at 88% -12%, rgba(90, 95, 158, 0.17), transparent 62%),
    radial-gradient(950px 640px at -12% 108%, rgba(201, 111, 74, 0.13), transparent 60%),
    var(--ink);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* faint grain so flat areas don't feel plastic */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app { position: relative; }

::selection { background: var(--clay-deep); color: var(--bone); }

a { color: var(--indigo); }

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

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

/* ---------- layout ---------- */

.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.6rem;
}

.topbar-user {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
}

.topbar-name { color: var(--bone-dim); font-size: 0.92rem; }

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: 0.01em;
  color: var(--bone);
  text-decoration: none;
}

.wordmark-sm { font-size: 1.2rem; }
.wordmark-dot { color: var(--gold); }

.back-link {
  color: var(--bone-dim);
  text-decoration: none;
  font-size: 0.95rem;
}
.back-link:hover { color: var(--bone); }

/* ---------- buttons & inputs ---------- */

.btn {
  font: 600 1rem/1 var(--font-body);
  padding: 0.8rem 1.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease,
              color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled { cursor: default; opacity: 0.55; }

.btn-primary {
  background: var(--clay);
  color: #23130c;
}
.btn-primary:hover:not(:disabled) { background: var(--clay-bright); }

.btn-quiet {
  background: transparent;
  color: var(--bone);
  border-color: var(--line-strong);
}
.btn-quiet:hover:not(:disabled) { border-color: var(--bone-dim); background: rgba(240, 231, 216, 0.05); }
.btn-quiet.is-open, .btn-primary.is-open { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--indigo-dim); }

.btn-gold {
  background: var(--gold);
  color: #241a06;
  font-weight: 700;
}
.btn-gold:hover:not(:disabled) {
  background: #ecc26c;
  box-shadow: 0 4px 22px rgba(226, 180, 87, 0.28);
}

.btn-wide { width: 100%; padding-top: 0.95rem; padding-bottom: 0.95rem; }

.btn-release.is-armed {
  border-color: var(--red);
  color: var(--red);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.92rem;
  color: var(--indigo);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--bone); }

.field { margin-bottom: 1rem; min-width: 0; }
.field[hidden] { display: none; }

.field label {
  display: block;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input,
.field select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--bone);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--clay);
}

.field input::placeholder { color: rgba(156, 141, 128, 0.65); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.input-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.form-error {
  color: var(--red);
  font-size: 0.92rem;
  min-height: 1.2em;
  margin: 0.4rem 0 0.8rem;
}

/* ---------- pills & badges ---------- */

.pill {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  color: var(--bone-dim);
  white-space: nowrap;
}

.pill-forming { color: var(--indigo); border-color: rgba(139, 144, 216, 0.5); }
.pill-active { color: var(--green); border-color: rgba(143, 181, 134, 0.5); }
.pill-completed { color: var(--muted); }

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  white-space: nowrap;
}

.badge-next {
  color: var(--gold);
  border: 1px solid rgba(226, 180, 87, 0.55);
  background: var(--gold-soft);
}

.badge-collected {
  color: var(--bone-dim);
  border: 1px solid var(--line);
}

/* ---------- auth / landing ---------- */

.auth-page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 3.2rem 1.25rem 4rem;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 3.5rem;
  align-items: center;
  min-height: 88vh;
}

.auth-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 5.5vw, 3.6rem);
  line-height: 1.08;
  margin: 1.6rem 0 1.1rem;
}

.auth-sub {
  color: var(--bone-dim);
  font-size: 1.06rem;
  max-width: 34rem;
  margin: 0 0 1.8rem;
}

.auth-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.8rem;
  color: var(--bone-dim);
  font-size: 0.97rem;
  max-width: 32rem;
}

.auth-points li {
  padding-left: 1.1rem;
  position: relative;
}

.auth-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clay);
}

.auth-points strong { color: var(--bone); font-weight: 600; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.8rem 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.auth-form-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin: 0 0 1.3rem;
}

.auth-switch { text-align: center; margin-top: 1.1rem; }

/* ---------- dashboard ---------- */

.dash-hero { margin-bottom: 1.6rem; }

.dash-greeting {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0.4rem 0 1.2rem;
}

.dash-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.panel-host { margin-bottom: 1.6rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.3rem;
  max-width: 30rem;
  animation: panel-in 180ms ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0 0 0.2rem;
}

.panel-hint {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 1.1rem;
}

.circle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 1rem;
}

.circle-card {
  display: block;
  text-decoration: none;
  color: var(--bone);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem 1.1rem;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.circle-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-pot {
  font-family: var(--font-display);
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold);
  margin: 0.55rem 0 0.15rem;
}

.card-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.6rem;
}

.card-position {
  font-size: 0.9rem;
  color: var(--bone-dim);
  margin: 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.card-position.is-next { color: var(--gold); font-weight: 600; }
.card-position.is-done { color: var(--green); }

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2.2rem 1.8rem;
  max-width: 32rem;
}

.empty-state h2 { font-family: var(--font-display); margin: 0 0 0.5rem; }
.empty-state p { color: var(--bone-dim); margin: 0; }

/* ---------- circle page ---------- */

.circle-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}

.circle-title-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.circle-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 700;
  margin: 0;
}

.circle-desc {
  color: var(--muted);
  margin: 0.3rem 0 0;
  max-width: 36rem;
}

.invite-host {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-2);
}

.invite-label {
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.02rem;
  letter-spacing: 0.14em;
  color: var(--bone);
}

/* the pot — the whole show */

.pot-card {
  position: relative;
  text-align: center;
  background:
    radial-gradient(560px 260px at 50% 0%, rgba(226, 180, 87, 0.09), transparent 70%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.1rem 1.5rem 1.7rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: box-shadow 300ms ease, border-color 300ms ease;
}

.pot-label {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.3rem;
}

.pot-amount {
  font-family: var(--font-display);
  font-variant-numeric: lining-nums tabular-nums;
  font-size: clamp(2.9rem, 9vw, 4.6rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 0 34px rgba(226, 180, 87, 0.25);
}

.pot-sub {
  color: var(--bone-dim);
  margin: 0.5rem 0 1rem;
  font-size: 0.98rem;
}

.pot-card .btn-wide { max-width: 22rem; margin: 0.4rem auto 0; display: block; }

.pot-note {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.7rem 0 0;
}

.pot-card .form-error { margin-bottom: 0; }

@keyframes pot-grew-kf {
  0% { box-shadow: 0 0 0 0 rgba(226, 180, 87, 0); border-color: var(--line); }
  30% { box-shadow: 0 0 70px 6px rgba(226, 180, 87, 0.28); border-color: rgba(226, 180, 87, 0.6); }
  100% { box-shadow: 0 0 0 0 rgba(226, 180, 87, 0); border-color: var(--line); }
}
.pot-grew { animation: pot-grew-kf 1.2s ease-out; }

@keyframes pot-drained-kf {
  0% { box-shadow: 0 0 0 0 rgba(139, 144, 216, 0); }
  30% { box-shadow: 0 0 60px 4px rgba(139, 144, 216, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(139, 144, 216, 0); }
}
.pot-drained { animation: pot-drained-kf 1.2s ease-out; }

@keyframes pot-payout-kf {
  0% { transform: scale(1); }
  12% { transform: scale(1.015); box-shadow: 0 0 90px 10px rgba(226, 180, 87, 0.35); }
  40% { transform: scale(1); }
  100% { box-shadow: 0 0 0 0 rgba(226, 180, 87, 0); }
}
.pot-payout { animation: pot-payout-kf 2.2s ease-out; }

.celebration-host { min-height: 0; }

.payout-banner {
  display: inline-block;
  margin-bottom: 0.9rem;
  padding: 0.45rem 1rem;
  border-radius: 99px;
  background: var(--gold-soft);
  border: 1px solid rgba(226, 180, 87, 0.55);
  color: var(--bone);
  font-size: 0.95rem;
  animation: panel-in 220ms ease-out;
}

.payout-banner strong { color: var(--gold); }

.cycle-dots {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  transition: background-color 200ms ease, border-color 200ms ease;
}

.dot-done { background: var(--indigo-dim); border-color: var(--indigo-dim); }

.dot-now {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(226, 180, 87, 0.6);
}

.cycle-text { color: var(--muted); font-size: 0.9rem; }

.admin-host { margin-top: 1.2rem; }

.admin-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding-top: 1.1rem;
  border-top: 1px dashed var(--line);
}

.admin-hint { color: var(--muted); font-size: 0.85rem; margin: 0; max-width: 26rem; }

/* rotation + feed columns */

.circle-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  align-items: start;
}

.circle-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
}

.col-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  margin: 0 0 0.9rem;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.member {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.member + .member { margin-top: 0.2rem; }

.member.is-next {
  border-color: rgba(226, 180, 87, 0.4);
  background: rgba(226, 180, 87, 0.06);
}

.member-pos {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--bone-dim);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-variant-numeric: tabular-nums;
}

.member.is-next .member-pos {
  color: var(--gold);
  border-color: var(--gold);
}

.member-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-you { color: var(--muted); font-style: normal; font-size: 0.88rem; }

.member-badges {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.paid-mark {
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: all 200ms ease;
}

.paid-mark.on {
  color: #1d2a1a;
  background: var(--green);
  border-color: var(--green);
}

.member-open { opacity: 0.75; }

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 26rem;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.6rem 0.2rem 0.6rem 0.8rem;
  border-left: 2px solid var(--line);
  font-size: 0.93rem;
}

.feed-item + .feed-item { margin-top: 0.15rem; }

.feed-contribution { border-left-color: var(--green); }
.feed-payout { border-left-color: var(--gold); }
.feed-member_joined { border-left-color: var(--indigo-dim); }
.feed-circle_activated, .feed-circle_created { border-left-color: var(--clay); }
.feed-reminder { border-left-color: var(--red); }

.feed-new { animation: feed-in 350ms ease-out; }

@keyframes feed-in {
  from { opacity: 0; transform: translateX(-8px); background: var(--gold-soft); }
  to { opacity: 1; transform: none; background: transparent; }
}

.feed-msg { color: var(--bone-dim); min-width: 0; }

.feed-side {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.feed-amount {
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.feed-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .auth-page {
    grid-template-columns: 1fr;
    gap: 2.4rem;
    padding-top: 2.2rem;
    min-height: 0;
  }
  .auth-card { max-width: 30rem; }
}

@media (max-width: 720px) {
  .circle-columns { grid-template-columns: 1fr; }
  .circle-head { flex-direction: column; }
  .pot-card { padding: 1.7rem 1.1rem 1.4rem; }
  .feed-list { max-height: none; }
}

@media (max-width: 420px) {
  .page { padding-left: 1rem; padding-right: 1rem; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .dash-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
