/* Grandmother's Eternal Lifetime Counter - style.css
   Deep black, graphite surfaces, soft white type, warm gold accents.
   System fonts only: nothing to download, works offline. */

:root {
  color-scheme: dark;
  --black: #000000;
  --graphite: #141413;
  --charcoal: #1e1d1b;
  --line: #2d2a24;
  --gold: #c9a96b;
  --gold-soft: #8e7647;
  --text: #ede8de;
  --muted: #a8a295;
  --alert: #e0735a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(201, 169, 107, 0.09), transparent 70%),
    var(--black);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.page {
  width: min(100%, 60rem);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* ---------- masthead ---------- */

.masthead { text-align: center; }

.title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.35rem, 5.2vw, 2.1rem);
  letter-spacing: 0.3em;
  padding-left: 0.3em; /* balances trailing letter-spacing so the text is truly centred */
}

.subtitle {
  margin: 0.6rem 0 0;
  font-family: var(--serif);
  font-size: clamp(0.8rem, 3vw, 1rem);
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  color: var(--gold);
}

.birth {
  margin: 2rem auto 0;
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}
.birth div { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2rem 0.6rem; }
.birth dt { color: var(--muted); }
.birth dd { margin: 0; }
.birth dt::after { content: ":"; }

/* ---------- main counter ---------- */

.age {
  position: relative;
  margin: 3rem 0 2.5rem;
  padding: 2.5rem 0;
  isolation: isolate;
}

/* the single quiet light: a slow gold glow behind the numbers */
.age::before {
  content: "";
  position: absolute;
  inset: -10% -5%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(201, 169, 107, 0.16), transparent);
  animation: breathe 11s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes breathe {
  from { opacity: 0.45; }
  to   { opacity: 1; }
}

.age-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  animation: appear 1.8s ease-out both;
}

@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

.age-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.25rem;
}
.age-unit + .age-unit { border-left: 1px solid var(--gold-soft); }

.age-num {
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(2.7rem, 13vw, 6.5rem);
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text);
}

.age-label {
  font-family: var(--serif);
  font-size: clamp(0.7rem, 2.6vw, 1rem);
  letter-spacing: 0.22em;
  padding-left: 0.22em;
  color: var(--gold);
}

/* ---------- lifetime totals ---------- */

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

.stat {
  background: var(--graphite);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.1rem 1.25rem 1.2rem;
  min-width: 0;
}

.stat h3 {
  margin: 0 0 0.45rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1rem;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-weight: 300;
  font-size: clamp(1.6rem, 7vw, 2.3rem);
  line-height: 1.2;
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}
.stat-value small {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--gold);
  margin-left: 0.25rem;
}

.stat-wide {
  background: var(--charcoal);
  border-left: 2px solid var(--gold-soft);
}
.stat-ns { font-size: clamp(1.05rem, 5.3vw, 2rem); letter-spacing: -0.01em; min-height: 1.3em; }
.stat-note { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); }

@media (min-width: 720px) {
  .page { padding-top: 4rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .stat-wide { grid-column: 1 / -1; }
}

/* ---------- current Bangladesh time ---------- */

.now {
  margin-top: 3rem;
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.now h2, .notice h2 {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--gold);
}
.now-date { margin: 0; font-size: 1.05rem; }
.now-time {
  margin: 0.25rem 0;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 300;
  font-variant-numeric: lining-nums tabular-nums;
}
.now-zone { margin: 0; color: var(--muted); font-size: 0.9rem; }

.sync { margin: 1.5rem auto 0; max-width: 36rem; }
.sync-badge { margin: 0; display: inline-flex; align-items: center; gap: 0.5rem; }
.sync-badge::before {
  content: "";
  width: 0.6rem; height: 0.6rem;
  border-radius: 50%;
  background: var(--muted);
}
.sync-badge[data-status="synced"]::before   { background: var(--gold); }
.sync-badge[data-status="required"]::before { background: var(--alert); }
.sync-badge strong { font-weight: 600; letter-spacing: 0.06em; }
.sync-detail { margin: 0.5rem 0 1rem; color: var(--muted); font-size: 0.9rem; }

.sync-button {
  min-height: 44px;
  padding: 0.55rem 1.2rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-soft);
  border-radius: 4px;
  cursor: pointer;
}
.sync-button:hover:not(:disabled) { background: rgba(201, 169, 107, 0.1); }
.sync-button:disabled { opacity: 0.55; cursor: default; }
.sync-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- precision notice ---------- */

.notice { margin: 2.5rem auto 0; max-width: 40rem; }
.notice p {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* ---------- error state ---------- */

.error {
  margin: 2rem auto;
  max-width: 36rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--alert);
  border-radius: 4px;
  background: var(--graphite);
}
.error h2 { margin: 0 0 0.5rem; font-family: var(--serif); font-weight: 400; font-size: 1.15rem; }
.error p { margin: 0.4rem 0; }
.error code { color: var(--gold); }

/* ---------- motion and background tabs ---------- */

.is-hidden .age::before { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .age::before, .age-grid { animation: none; }
}
