/* Number Pyramid — presentation only. */

:root {
  color-scheme: light dark;

  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg: #fdf7f9;
  --glow-a: #fbe4ee;
  --glow-b: #f4ecfa;
  --card: #fffcfd;
  --line: #f4e1ea;
  --ink: #3a2733;
  --muted: #8e7586;
  --accent: #c25b84;
  --accent-ink: #fffafc;
  --track: #f9edf3;
  --blush: #fdf0f6;
  --row-mid: #7e6374;
  --shadow: 0 1px 2px rgb(122 58 86 / .05), 0 18px 40px -18px rgb(122 58 86 / .28);
  --radius: 26px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191016;
    --glow-a: #2b1722;
    --glow-b: #221826;
    --card: #221721;
    --line: #36232f;
    --ink: #f7ecf2;
    --muted: #b89cab;
    --accent: #e98cb1;
    --accent-ink: #1c1016;
    --track: #2c1c26;
    --blush: #2a1a24;
    --row-mid: #a98a9c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 22px 50px -24px rgb(0 0 0 / .7);
  }
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background:
    radial-gradient(48rem 26rem at 12% -8%, var(--glow-a), transparent 68%),
    radial-gradient(44rem 24rem at 92% 108%, var(--glow-b), transparent 66%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  width: min(34rem, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.35rem, 3.4vw, 2rem);
  display: grid;
  gap: 1.2rem;
}

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

.head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.05rem;
}

.head::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent);
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: .005em;
  line-height: 1.15;
}

.brand h1 em {
  font-style: italic;
  color: var(--accent);
}

.brand .sub {
  margin: .35rem 0 0;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  gap: .15rem;
  padding: .25rem;
  background: var(--track);
  border-radius: 999px;
}

.seg__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-family: var(--serif);
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .02em;
  padding: .4rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}

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

.seg__btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 8px -2px rgb(194 91 132 / .55);
}

.seg__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- result ---------- */

.stat {
  display: grid;
  justify-items: center;
  gap: .1rem;
  padding: 1.15rem 1rem 1.05rem;
  border-radius: 20px;
  border: 1px solid rgb(194 91 132 / .16);
  background:
    radial-gradient(22rem 8rem at 50% 0%, rgb(194 91 132 / .10), transparent 70%),
    linear-gradient(180deg, var(--blush), transparent);
}

.stat__label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat__value {
  font-family: var(--serif);
  font-size: 2.15rem;
  font-weight: 500;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat.is-empty .stat__value {
  font-size: 1.5rem;
  color: var(--muted);
}

/* ---------- input ---------- */

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

.field__label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

#input {
  width: 100%;
  padding: .85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: .18em;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s ease, box-shadow .2s ease;
}

#input::placeholder {
  color: var(--muted);
  font-style: italic;
  letter-spacing: .02em;
}

#input:focus {
  outline: none;
  border-color: rgb(194 91 132 / .5);
  box-shadow: 0 0 0 4px rgb(194 91 132 / .12);
}

/* ---------- pyramid ---------- */

.pyramid {
  min-height: 9rem;
  display: grid;
  align-content: center;
  gap: .2rem;
  overflow-x: auto;
  padding: .3rem 0 .6rem;
}

.empty {
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: .9375rem;
  color: var(--muted);
}

.row {
  display: flex;
  justify-content: center;
  gap: .55em;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.55;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  animation: rise .3s cubic-bezier(.2, .7, .3, 1) both;
  animation-delay: calc(var(--i) * 30ms);
}

.row span { min-width: .66em; text-align: center; }

.row:first-child { color: var(--ink); }
.row:not(:first-child) { color: var(--row-mid); }
.row:last-child {
  font-size: 1.45rem;
  font-style: italic;
  color: var(--accent);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .row { animation: none; }
  .seg__btn, #input { transition: none; }
}

@media (max-width: 26rem) {
  .head { flex-direction: column; align-items: stretch; gap: .75rem; }
  .seg { align-self: flex-start; }
  .row { gap: .4em; font-size: 1rem; }
  .brand h1 { font-size: 1.35rem; }
}

/* short viewports: don't force a scroll just for padding */
@media (max-height: 44rem) {
  body { padding: .75rem; }
  .app { padding: 1.1rem; gap: .9rem; }
  .pyramid { min-height: 6.5rem; }
}
