/* Penny's public site. System fonts only; no inline styles anywhere (CSP style-src 'self'). */

:root {
  /* copper penny + verdigris patina, on warm white */
  --paper: #fffbf7;
  --paper-2: #f8efe6;
  --line: #ead9c9;
  --field-border: #9c8270;
  --ink: #2b1d14;
  --muted: #6b5648;
  --copper: #a34a1c;
  --copper-bright: #d97a3e;
  --copper-dark: #7a3412;
  --verdigris: #2c7a68;
  --verdigris-soft: #dcefe8;
  --loss: #a3233a;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-numerals: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-diary: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 14px;
  --gutter: 16px;
}

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

[hidden] {
  display: none !important;
}

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

a {
  color: var(--copper);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--copper-dark);
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main {
  flex: 1 0 auto;
}

.narrow {
  max-width: 720px;
}

.visually-hidden,
.hp {
  position: absolute !important;
  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: var(--gutter);
  top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus {
  top: 0.5rem;
  color: var(--paper);
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-coin {
  font-size: 1.5rem;
  line-height: 1;
}

.ai-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1.5px solid var(--copper);
  color: var(--copper);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.ai-badge:hover {
  background: var(--copper);
  color: #fff;
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--copper);
  text-decoration: underline;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  width: max-content;
  max-width: 100%;
  margin: 1.5rem auto 0;
  padding: 0.25rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-current="page"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(43 29 20 / 0.14);
}

.live-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--loss);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.panel {
  padding-bottom: 3rem;
}

/* ---------- scoreboard (the signature: register counter tiles) ---------- */

.scoreboard {
  text-align: center;
  padding: 2.25rem 0 1rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.counter {
  margin: 0;
  font-family: var(--font-numerals);
  font-size: clamp(2.4rem, 13vw, 6.5rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.counter.is-long {
  font-size: clamp(2rem, 9.5vw, 5.5rem);
}

.nowrap {
  white-space: nowrap;
}

.counter-loading {
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 600;
}

.counter-tiles {
  display: inline-flex;
  gap: 0.08em;
  align-items: stretch;
}

.tile {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0.78em;
  padding: 0.1em 0.06em 0.12em;
  border: 0.045em solid var(--copper);
  border-radius: 0.14em;
  background: linear-gradient(180deg, #fff6ec 0%, #fbe5d1 49%, #f5d6bb 51%, #fbe9d9 100%);
  color: var(--copper-dark);
  box-shadow:
    inset 0 -0.05em 0 rgb(122 52 18 / 0.18),
    0 0.04em 0.08em rgb(43 29 20 / 0.12);
  animation: tile-in 520ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.tile::after {
  content: "";
  position: absolute;
  left: 0.06em;
  right: 0.06em;
  top: 50%;
  height: 0.02em;
  background: rgb(122 52 18 / 0.22);
}

.tile-sep {
  min-width: 0;
  padding-left: 0.02em;
  padding-right: 0.02em;
  border-color: transparent;
  background: none;
  box-shadow: none;
  color: var(--copper);
}

.tile-sep::after {
  display: none;
}

.tile:nth-child(2) { animation-delay: 40ms; }
.tile:nth-child(3) { animation-delay: 80ms; }
.tile:nth-child(4) { animation-delay: 120ms; }
.tile:nth-child(5) { animation-delay: 160ms; }
.tile:nth-child(6) { animation-delay: 200ms; }
.tile:nth-child(7) { animation-delay: 240ms; }
.tile:nth-child(8) { animation-delay: 280ms; }
.tile:nth-child(n + 9) { animation-delay: 320ms; }

@keyframes tile-in {
  from {
    transform: translateY(-0.25em) rotateX(70deg);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.counter.is-negative .tile {
  color: var(--loss);
  border-color: var(--loss);
}

.subline {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.goal {
  max-width: 520px;
  margin: 1.5rem auto 0;
}

.progress {
  display: block;
  height: 14px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--verdigris), #3f9b84);
  transition: width 700ms ease-out;
}

.goal-text {
  margin: 0.5rem 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.streams {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.75rem;
  margin: 1.75rem 0 0;
  font-variant-numeric: tabular-nums;
}

.stream {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

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

.stream dd {
  margin: 0;
  font-weight: 700;
}

.ff-note {
  margin: 0.6rem auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-label {
  margin: 2.5rem 0 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.scoreboard .section-label {
  text-align: left;
}

.experiments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: 0.75rem;
  text-align: left;
}

.experiment {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.experiment-name {
  font-size: 1rem;
}

.experiment-net {
  margin: 0.35rem 0 0;
  font-family: var(--font-numerals);
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.is-negative {
  color: var(--loss);
}

.experiment-status {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.status-winning .experiment-status {
  color: var(--verdigris);
  font-weight: 700;
}

.status-stopped {
  background: var(--paper-2);
}

.coffee-row {
  margin: 1.75rem 0 0;
}

/* ---------- buttons ---------- */

.button {
  display: inline-block;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button-coin,
.coffee {
  background: var(--copper);
  color: #fff;
}

.button-coin:hover,
.coffee:hover {
  background: var(--copper-dark);
  color: #fff;
}

.button-quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.button-quiet:hover {
  border-color: var(--copper);
  color: var(--copper);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- diary ---------- */

.diary {
  max-width: 68ch;
  margin: 1rem auto 0;
  border-top: 1px solid var(--line);
}

.entry {
  padding: 1.75rem 0;
  border-bottom: 1px dashed var(--line);
}

.entry-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.6rem;
}

.entry-day {
  color: var(--copper);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.entry-title {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.entry p {
  margin: 0.6rem 0 0;
}

.entry > p:not([class]) {
  font-family: var(--font-diary);
  font-size: 1.12rem;
  line-height: 1.65;
}

.entry-label {
  font-weight: 700;
  color: var(--muted);
}

.tried {
  margin: 0.3rem 0 0;
  padding-left: 1.4rem;
}

.asked {
  font-style: italic;
}

.asked .entry-label {
  font-style: normal;
}

.entry-cost {
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.diary .button {
  margin-top: 1.25rem;
}

.notice {
  color: var(--muted);
  margin: 1rem 0;
}

/* ---------- live ---------- */

.live {
  max-width: 760px;
  margin: 2rem auto 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.status::before {
  content: "";
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--muted);
}

.status[data-state="working"]::before {
  background: var(--verdigris);
  box-shadow: 0 0 0 0.3rem var(--verdigris-soft);
  animation: pulse 1.6s ease-in-out infinite;
}

.live-hint {
  margin: 0.35rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.feed-item {
  display: grid;
  grid-template-columns: 4.6rem 1.8rem minmax(0, 1fr);
  align-items: start;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.feed-time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  padding-top: 0.2rem;
}

.feed-icon {
  font-size: 1.1rem;
  line-height: 1.4;
  text-align: center;
}

.feed-body p {
  margin: 0;
}

.thought {
  font-style: italic;
  color: var(--muted);
}

.money-line {
  font-weight: 700;
  color: var(--verdigris);
}

.money-line.is-negative {
  color: var(--loss);
}

.kind-milestone .feed-body {
  font-weight: 800;
}

.code {
  margin: 0.5rem 0 0;
  padding: 0.75rem 0.9rem;
  max-height: 22rem;
  overflow: auto;
  background: #2b1d14;
  color: #fbeee2;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre;
  overflow-wrap: normal;
}

.live .button {
  margin-top: 1.25rem;
}

/* ---------- pages: ask & about ---------- */

.page-title {
  margin: 2.25rem 0 0.5rem;
  font-size: clamp(2rem, 7vw, 2.75rem);
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.fine-print {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1rem 0.9rem 2.2rem;
  background: var(--paper-2);
  border-radius: var(--radius);
  color: var(--ink);
}

.ask-form {
  display: grid;
  gap: 1.1rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-weight: 700;
}

.field textarea,
.field input[type="email"],
.field select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1.5px solid var(--field-border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.field textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--copper);
}

.field-check {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.6rem;
}

.field-check input {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0.2rem 0 0;
  accent-color: var(--copper);
}

.field-check label {
  font-weight: 600;
}

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

.turnstile {
  min-height: 65px;
}

.ask-form .button {
  justify-self: start;
}

.form-message {
  margin: 1.25rem 0 0;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: var(--paper-2);
  font-weight: 600;
}

.form-message[data-kind="error"] {
  background: #fbe9ec;
  color: var(--loss);
}

.form-message[data-kind="success"] {
  background: var(--verdigris-soft);
  color: #1d5a4c;
}

.rules {
  margin-top: 2rem;
}

.rules h2,
.about-money h2 {
  font-size: 1.25rem;
  margin-bottom: 0.6rem;
}

.rules ul {
  margin: 0;
  padding-left: 1.3rem;
}

.rules li {
  margin: 0.25rem 0;
}

.rules-never {
  padding: 1.1rem 1.25rem;
  border: 1.5px solid var(--loss);
  border-radius: var(--radius);
}

.rules-never h2 {
  color: var(--loss);
}

.about-money {
  margin-top: 2rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0 3rem;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  padding: 1.5rem var(--gutter) 2rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.legal-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.1rem;
}

.legal-links a {
  color: var(--muted);
}

.disclosure {
  margin: 0.8rem 0 0;
}

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  .site-nav {
    margin-left: 0;
    width: 100%;
  }

  .brand {
    font-size: 0.95rem;
  }

  .tab {
    padding: 0.5rem 0.8rem;
  }

  .feed-item {
    grid-template-columns: 1.6rem minmax(0, 1fr);
  }

  .feed-time {
    grid-column: 1 / -1;
    padding-top: 0;
  }
}

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