/* Cosmic Age – friendly space theme */
:root {
  --bg: #0A0F24;
  --bg-2: #121A3A;
  --bg-3: #1A2350;
  --line: #2A3566;
  --text: #EEF1FF;
  --text-2: #C3CAE8;
  --muted: #9CA6D0;
  --mars: #FF6B4A;
  --cyan: #4CC9F0;
  --sun: #FFC857;
  --violet: #9B8CFF;
  --green: #5BE49B;
  --radius: 24px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden;
  background: radial-gradient(120% 80% at 80% -10%, #1B1650 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--text); font: 400 1.05rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; color: #fff; margin: 0; line-height: 1.1; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--cyan); text-underline-offset: 3px; }
a:hover { color: #8FDDF5; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 10px; }

.skip-link { position: absolute; left: 16px; top: -60px; z-index: 20; background: var(--sun); color: #1A1400; padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Sky: stars (parallax via JS) + comets ---------- */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.layer { position: absolute; left: 0; right: 0; top: 0; height: 300%; will-change: transform; }
.l1 { background-image: radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,.6), transparent 60%), radial-gradient(1px 1px at 130px 90px, rgba(255,255,255,.45), transparent 60%), radial-gradient(1px 1px at 200px 170px, rgba(200,215,255,.55), transparent 60%), radial-gradient(1px 1px at 70px 210px, rgba(255,255,255,.4), transparent 60%); background-size: 240px 240px; }
.l2 { background-image: radial-gradient(1.5px 1.5px at 50px 80px, rgba(255,255,255,.8), transparent 60%), radial-gradient(1.5px 1.5px at 260px 210px, rgba(255,220,180,.7), transparent 60%), radial-gradient(1.5px 1.5px at 170px 330px, rgba(255,255,255,.65), transparent 60%); background-size: 380px 380px; }
.l3 { background-image: radial-gradient(2.2px 2.2px at 90px 120px, #fff, transparent 60%), radial-gradient(2.2px 2.2px at 420px 380px, rgba(180,220,255,.95), transparent 60%); background-size: 560px 560px; animation: twinkle 3.5s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }

.comet { position: absolute; top: 0; left: 0; width: 160px; height: 2px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.9));
  transform: rotate(-28deg); animation: comet 16s linear infinite; }
.comet::after { content: ""; position: absolute; right: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 12px 4px rgba(140,220,255,.7); }
.c1 { --x0: 105vw; --y0: 8vh; animation-delay: 1s; }
.c2 { --x0: 80vw; --y0: -5vh; animation-delay: 7s; animation-duration: 19s; }
.c3 { --x0: 120vw; --y0: 30vh; animation-delay: 12s; animation-duration: 23s; }
@keyframes comet {
  0% { opacity: 0; transform: translate(var(--x0), var(--y0)) rotate(-28deg); }
  2% { opacity: 1; }
  9% { opacity: 0; transform: translate(calc(var(--x0) - 70vw), calc(var(--y0) + 37vw)) rotate(-28deg); }
  100% { opacity: 0; transform: translate(calc(var(--x0) - 70vw), calc(var(--y0) + 37vw)) rotate(-28deg); }
}

/* ---------- Layout ---------- */
.top, main, .foot { width: min(100% - 40px, 1100px); margin-inline: auto; }
.top { padding-top: 20px; }
.crumbs { display: flex; gap: 8px; align-items: center; font-size: .92rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--line); }
.crumbs a { color: var(--text-2); text-decoration: none; display: inline-flex; min-height: 44px; align-items: center; }
.crumbs a:hover { color: #fff; text-decoration: underline; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; padding: clamp(24px, 6vw, 64px) 0 24px; }
.badge { display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(255, 200, 87, .12); color: var(--sun); font-weight: 800; font-size: .85rem; letter-spacing: .03em; margin-bottom: 18px; }
.hero h1 { font-size: clamp(2.6rem, 6.5vw, 4.6rem); font-weight: 700; letter-spacing: -.01em; }
.mars-word { color: var(--mars); display: inline-block; }
.lead { margin-top: 18px; font-size: clamp(1.08rem, 1.8vw, 1.25rem); color: var(--text-2); max-width: 52ch; }

.panel { margin-top: 28px; padding: 22px; border-radius: var(--radius); background: rgba(18, 26, 58, .85); border: 1px solid var(--line); display: grid; gap: 10px; max-width: 520px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.panel label { font-family: var(--display); font-weight: 600; font-size: 1.15rem; color: #fff; }
.ask-row { display: flex; flex-wrap: wrap; gap: 10px; }
input[type="date"] {
  flex: 1 1 200px; min-height: 56px; padding: 0 18px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--bg); color: #fff; font: 700 1.1rem var(--font); color-scheme: dark;
}
input[type="date"]:hover { border-color: #3B4A8A; }
input[type="date"]:focus-visible { border-color: var(--sun); outline: none; box-shadow: 0 0 0 3px rgba(255, 200, 87, .35); }
input[aria-invalid="true"] { border-color: var(--mars); }
.hint { font-size: .92rem; color: var(--muted); }
.error { color: #FF9C86; font-weight: 700; }
.error:empty { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 26px; border-radius: 16px; border: 2px solid transparent; cursor: pointer; font-weight: 800; font-size: 1.05rem; transition: transform .15s, background .2s, border-color .2s; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-go { background: var(--mars); color: #1C0600; box-shadow: 0 8px 24px rgba(255, 107, 74, .35); }
.btn-go:hover { background: #FF8A6E; }
.btn-ghost { background: transparent; color: #fff; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--cyan); }
.btn-link { background: none; color: var(--muted); text-decoration: underline; padding: 0 10px; min-height: 44px; }
.btn-link:hover { color: #fff; transform: none; }

/* Animated orrery */
.orrery { position: relative; width: min(100%, 460px); aspect-ratio: 1; justify-self: center; }
.sun { position: absolute; left: 50%; top: 50%; width: 15%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #FFF3C4, var(--sun) 45%, #FF9F1C 100%);
  box-shadow: 0 0 40px 10px rgba(255, 200, 87, .45), 0 0 120px 40px rgba(255, 159, 28, .18); animation: glow 4s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 55px 16px rgba(255, 200, 87, .55), 0 0 140px 50px rgba(255, 159, 28, .22); } }
.ring { position: absolute; left: 50%; top: 50%; border-radius: 50%; border: 1.5px dashed rgba(156, 166, 208, .28); transform: translate(-50%, -50%); animation: spin linear infinite; }
.ring .pl { position: absolute; left: 50%; top: 0; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: inset -4px -4px 8px rgba(0, 0, 0, .45); }
.r1 { animation-delay: -2s; width: 28%; height: 28%; animation-duration: 6s; }
.r2 { animation-delay: -7s; width: 41%; height: 41%; animation-duration: 11s; }
.r3 { animation-delay: -4s; width: 54%; height: 54%; animation-duration: 17s; }
.r4 { animation-delay: -19s; width: 67%; height: 67%; animation-duration: 26s; }
.r5 { animation-delay: -11s; width: 83%; height: 83%; animation-duration: 48s; }
.r6 { animation-delay: -52s; width: 98%; height: 98%; animation-duration: 80s; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Planet looks (shared by orrery, map, chips, detail) */
.mercury { width: 12px; height: 12px; background: radial-gradient(circle at 35% 35%, #DCD6CF, #8F8A84); }
.venus { width: 18px; height: 18px; background: radial-gradient(circle at 35% 35%, #FFE4A8, #E0A94A); }
.earth { width: 20px; height: 20px; background: radial-gradient(circle at 35% 35%, #9BE7FF, #2E86DE 60%, #1B4F9C); }
.mars { width: 16px; height: 16px; background: radial-gradient(circle at 35% 35%, #FFB199, #E04A2C); }
.jupiter { width: 34px; height: 34px; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), transparent 50%), repeating-linear-gradient(170deg, #E8C9A0 0 4px, #C98E5B 4px 7px, #F1DDC0 7px 11px); }
.saturn { width: 28px; height: 28px; background: radial-gradient(circle at 35% 35%, #FFF0C2, #D9B86A); }
.saturn::after { content: ""; position: absolute; left: 50%; top: 50%; width: 190%; height: 46%; border: 2px solid rgba(240, 220, 160, .8); border-radius: 50%; transform: translate(-50%, -50%) rotate(-20deg); }
.uranus { width: 24px; height: 24px; background: radial-gradient(circle at 35% 35%, #DFFBFF, #6FD3DF); }
.neptune { width: 24px; height: 24px; background: radial-gradient(circle at 35% 35%, #A9B8FF, #3D52E0); }

/* ---------- Results ---------- */
.summary { margin-top: 40px; padding: 26px 28px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(255, 107, 74, .16), rgba(76, 201, 240, .1)); border: 1px solid var(--line); font-family: var(--display); font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 500; color: #fff; line-height: 1.35; }
.summary:focus { outline: none; }
.summary strong { color: var(--sun); font-weight: 700; }
.block { margin-top: 72px; display: grid; gap: 18px; }
.block h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sub { color: var(--text-2); max-width: 65ch; }

/* Solar system map */
.system { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.map { position: relative; width: 100%; aspect-ratio: 1; }
.orbits { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sun-big { position: absolute; left: 50%; top: 50%; width: 9%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle at 40% 38%, #FFF3C4, var(--sun) 45%, #FF9F1C); box-shadow: 0 0 30px 8px rgba(255, 200, 87, .45); }
.mp { position: absolute; width: 48px; height: 48px; transform: translate(-50%, -50%); border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.mp .pl { position: relative; display: block; border-radius: 50%; box-shadow: inset -4px -4px 8px rgba(0, 0, 0, .45); transition: transform .2s; }
.mp:hover .pl { transform: scale(1.25); }
.mp[aria-pressed="true"] .pl { transform: scale(1.35); }
.mp[aria-pressed="true"]::before { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 2px solid #fff; animation: ping 1.6s ease-out infinite; }
@keyframes ping { 0% { transform: scale(.8); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
.mp-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: .78rem; font-weight: 800; color: var(--text-2); white-space: nowrap; pointer-events: none; margin-top: -4px; text-shadow: 0 1px 3px #000; }

.detail { padding: 28px; border-radius: var(--radius); background: rgba(18, 26, 58, .9); border: 1px solid var(--line); display: grid; gap: 14px; }
.d-head { display: flex; align-items: center; gap: 16px; }
.d-orb { flex-shrink: 0; width: 64px; height: 64px; display: grid; place-items: center; }
.d-orb .pl { position: relative; transform: scale(2.2); border-radius: 50%; box-shadow: inset -4px -4px 8px rgba(0, 0, 0, .45); }
.d-name { font-family: var(--display); font-size: 1.6rem; font-weight: 600; color: #fff; }
.d-year { color: var(--muted); font-size: .92rem; }
.d-age { font-family: var(--display); font-size: clamp(2.6rem, 6vw, 3.6rem); font-weight: 700; color: #fff; line-height: 1; font-variant-numeric: tabular-nums; }
.d-age small { font-size: 1.1rem; font-weight: 500; color: var(--text-2); }
.bar { height: 12px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .8s ease; }
.d-next { color: var(--text-2); }
.d-next b { color: var(--sun); }
.d-tags { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.d-tag { padding: 12px 14px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); font-size: .92rem; color: var(--text-2); }
.d-tag b { display: block; font-family: var(--display); font-size: 1.3rem; color: #fff; font-weight: 600; }
.d-fact { color: var(--text-2); font-size: .95rem; }
.d-joke { font-weight: 800; color: var(--cyan); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px; border-radius: 999px; border: 2px solid var(--line); background: rgba(18, 26, 58, .85); color: #fff; font-weight: 700; cursor: pointer; }
.chip .pl { position: relative; width: 16px; height: 16px; border-radius: 50%; }
.chip .pl.saturn::after { width: 170%; }
.chip:hover { border-color: var(--cyan); }
.chip[aria-pressed="true"] { border-color: var(--sun); background: rgba(255, 200, 87, .12); }

/* Live counters */
.live { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font); font-size: .8rem; font-weight: 800; color: var(--mars); text-transform: uppercase; letter-spacing: .1em; padding: 4px 12px; border-radius: 999px; background: rgba(255, 107, 74, .12); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mars); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ct { position: relative; padding: 20px; border-radius: 20px; background: rgba(18, 26, 58, .88); border: 1px solid var(--line); display: grid; gap: 4px; overflow: hidden; }
.ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 6px; }
.ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ct-heart .ic { background: rgba(255, 107, 74, .16); color: var(--mars); }
.ct-heart .ic svg { fill: currentColor; stroke: none; animation: beat .75s ease-in-out infinite; }
@keyframes beat { 30% { transform: scale(1.18); } 60% { transform: scale(1); } }
.ct-breath .ic { background: rgba(76, 201, 240, .14); color: var(--cyan); }
.ct-blink .ic { background: rgba(155, 140, 255, .16); color: var(--violet); }
.ct-sec .ic { background: rgba(91, 228, 155, .14); color: var(--green); }
.ct-sun .ic { background: rgba(255, 200, 87, .16); color: var(--sun); }
.ct-gal .ic { background: rgba(155, 140, 255, .16); color: var(--violet); }
.c-label { color: var(--muted); font-size: .95rem; font-weight: 600; }
.c-val { font-family: var(--display); font-size: clamp(1.3rem, 2.6vw, 1.75rem); font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.facts li { padding: 16px 18px; border-radius: 18px; border: 1px dashed var(--line); color: var(--text-2); }
.facts b { color: #fff; font-variant-numeric: tabular-nums; }

/* Timeline */
.timeline { position: relative; display: grid; gap: 14px; padding-left: 34px; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--line), var(--violet), var(--line)); border-radius: 2px; }
.tl { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 18px; align-items: center; padding: 16px 20px; border-radius: 18px; background: rgba(18, 26, 58, .88); border: 1px solid var(--line); }
.tl::before { content: ""; position: absolute; left: -30px; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translateY(-50%); background: var(--bg); border: 3px solid var(--violet); }
.tl.past { opacity: .72; }
.tl.past::before { background: var(--violet); }
.tl.soon { border-color: var(--green); }
.tl.soon::before { border-color: var(--green); box-shadow: 0 0 0 6px rgba(91, 228, 155, .18); }
.tl-title { font-family: var(--display); font-weight: 600; font-size: 1.15rem; color: #fff; }
.tl-sub { color: var(--muted); font-size: .92rem; }
.tl-date { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-weight: 800; color: var(--sun); }
.tl-date small { display: block; font-weight: 600; color: var(--text-2); }
.tl.past .tl-date { color: var(--text-2); }

/* Older than */
.score { font-family: var(--display); font-size: 1.35rem; color: var(--text-2); }
.score b { color: var(--sun); }
.older { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.older li { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(18, 26, 58, .88); color: var(--text-2); }
.older .mark { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.older .yes .mark { background: rgba(91, 228, 155, .18); color: var(--green); }
.older .no .mark { background: rgba(255, 107, 74, .16); color: var(--mars); }
.older .yes { color: #fff; }
.older .when { margin-left: auto; font-size: .85rem; color: var(--muted); font-weight: 700; }

/* Share */
.share-text { padding: 20px 22px; border-radius: 20px; border: 2px dashed var(--line); color: var(--text); white-space: pre-line; background: rgba(10, 15, 36, .7); }
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* FAQ */
.faq details { border-radius: 18px; border: 1px solid var(--line); background: rgba(18, 26, 58, .88); }
.faq summary { cursor: pointer; padding: 18px 22px; font-family: var(--display); font-weight: 600; font-size: 1.15rem; color: #fff; list-style: none; display: flex; justify-content: space-between; gap: 16px; align-items: center; min-height: 44px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.5rem; color: var(--sun); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 22px 20px; color: var(--text-2); }

.foot { padding: 72px 0 36px; color: var(--muted); font-size: .95rem; }

.pop { animation: pop .55s cubic-bezier(.2, .8, .3, 1.2) both; }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero, .system { grid-template-columns: 1fr; }
  .orrery { width: min(80%, 360px); order: -1; }
  .counters, .facts, .older { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .counters, .facts, .older { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .btn-link { width: auto; }
  .d-tags { grid-template-columns: 1fr; }
  .mp-label { display: none; }
  .tl { grid-template-columns: 1fr; }
  .tl-date { grid-column: 1; grid-row: auto; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .comet { display: none; }
}
@media print {
  .sky, .hero .orrery, .share-actions, .panel { display: none !important; }
  body { background: #fff; color: #000; }
}
