/* Happiness Festival — Art of Living CI: white surfaces, saffron/orange accent.

   Contrast rules baked into the palette (PRD §37 asks for strong contrast):
     --orange       #F5871F  2.51:1 on white -> FILLS ONLY, always with --ink on top (6.05:1)
     --orange-text  #C2570A  4.50:1 on white -> the orange allowed for text and links
     --ink          #2E2419  15.19:1          -> body text
     --muted        #6B5D4D  6.37:1           -> secondary text
   Never set --orange as a text colour on white; use --orange-text. */

:root {
  --white: #ffffff;
  --cream: #fff9f3;
  --cream-2: #fdf1e4;
  --orange: #f5871f;
  --orange-bright: #ffa53d;
  --orange-deep: #e0700d;
  --orange-text: #c2570a;
  --ink: #2e2419;
  --ink-soft: #5c4f41;
  --muted: #6b5d4d;
  --line: #ecdfd0;
  --line-strong: #dcc9b3;
  --mint: #2e8b6f;
  --sky: #2b6f9e;
  --rose: #c8452f;
  --card: #ffffff;
  --radius: 20px;
  --shadow: 0 6px 20px rgba(90, 60, 20, 0.09);
  --shadow-lift: 0 10px 26px rgba(90, 60, 20, 0.14);
  --tab-h: 68px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(880px 520px at 50% -10%, rgba(245, 135, 31, 0.14), transparent 62%),
    linear-gradient(180deg, var(--cream) 0%, #fffdfb 38%, var(--white) 100%);
  background-attachment: fixed;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

a { color: var(--orange-text); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; color: var(--ink); }
h1 { font-size: 1.7rem; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8rem; }
small { color: var(--muted); }

/* ------------------------------------------------------------- chrome */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .7rem 1rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); min-width: 0; }
/* Official AoL logo is 115x45 — height-constrained, width follows. */
.brand-mark { height: 27px; width: auto; flex: none; display: block; }
.brand-divider {
  width: 1px; height: 26px; flex: none; background: var(--line-strong);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong {
  font-size: .92rem; letter-spacing: -.01em; line-height: 1.15;
}
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex: none; }
.icon-btn, .lang-toggle {
  position: relative; display: grid; place-items: center;
  min-width: 38px; height: 38px; padding: 0 .55rem;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--white); color: var(--ink-soft);
  font-size: .82rem; font-weight: 700;
}
.dot {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--rose); color: #fff; font-size: .66rem; font-weight: 800;
  display: grid; place-items: center;
}

.page { max-width: 640px; margin: 0 auto; padding: 1rem 1rem 2rem; }

/* Home sits in the middle and is deliberately larger — it is the one tab people
   reach for constantly, so it gets a wider column and a raised orange disc. */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr 1fr 1.28fr 1fr 1fr;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
/* Fixed icon row so every icon sits on the same baseline, even when a label
   ("Happiness World") needs two lines. */
.tabbar a {
  display: grid; grid-template-rows: 26px auto; justify-items: center;
  align-content: start; gap: 3px; padding: 9px 2px 0;
  height: var(--tab-h); color: var(--muted);
  font-size: .62rem; font-weight: 600; text-align: center;
  line-height: 1.15; min-width: 0;
}
.tabbar a span { font-size: 1.32rem; line-height: 26px; }
.tabbar a.on { color: var(--orange-text); }
.tabbar a.on span { transform: translateY(-2px); transition: transform .18s; }

.tabbar a.home { font-size: .7rem; font-weight: 700; color: var(--ink-soft); }
.tabbar a.home span {
  font-size: 1.5rem; line-height: 1;
  width: 50px; height: 50px; margin-top: -18px;
  display: grid; place-items: center; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  border: 3px solid var(--white);
  box-shadow: 0 4px 12px rgba(245, 135, 31, .38);
}
.tabbar a.home.on { color: var(--orange-text); }
.tabbar a.home.on span { transform: none; filter: brightness(1.04); }

/* -------------------------------------------------------------- cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .9rem;
  box-shadow: var(--shadow);
}
.card.tight { padding: .8rem; }
.card.glow {
  background: linear-gradient(158deg, #fff6ec, #ffffff 62%);
  border-color: rgba(245, 135, 31, .45);
  box-shadow: var(--shadow-lift);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem; margin-bottom: .6rem;
}
.card-head h2, .card-head h3 { margin: 0; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .11em; font-size: .66rem;
  font-weight: 800; color: var(--orange-text); margin-bottom: .3rem;
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .82rem 1.15rem; border-radius: 14px; border: 0;
  font-size: 1rem; font-weight: 700; font-family: inherit;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: var(--ink); cursor: pointer; width: 100%;
  box-shadow: 0 6px 16px rgba(245, 135, 31, .30);
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.975); filter: brightness(1.04); }
.btn.ghost {
  background: var(--white); color: var(--ink);
  border: 1px solid var(--line-strong); box-shadow: none;
}
.btn.slim { width: auto; padding: .55rem .85rem; font-size: .85rem; border-radius: 11px; }
.btn.danger { background: var(--rose); color: #fff; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1 1 auto; }

/* -------------------------------------------------------------- forms */
label { display: block; font-size: .82rem; font-weight: 700; margin: .8rem 0 .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=file], textarea, select {
  width: 100%; padding: .78rem .9rem; font-size: 1rem; font-family: inherit;
  color: var(--ink); background: var(--white);
  border: 1px solid var(--line-strong); border-radius: 13px;
}
input::placeholder, textarea::placeholder { color: #9a8b7a; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent;
}
textarea { min-height: 92px; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: .6rem; margin: .7rem 0; font-weight: 500; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--orange); }
.check label { margin: 0; font-weight: 500; font-size: .92rem; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.errors {
  background: #fdeceb; border: 1px solid rgba(200, 69, 47, .45);
  color: #8d2c1b;
  border-radius: 13px; padding: .7rem .85rem; margin-bottom: .8rem; font-size: .9rem;
}
.notice {
  background: #e9f6f1; border: 1px solid rgba(46, 139, 111, .4);
  color: #1d5c49;
  border-radius: 13px; padding: .7rem .85rem; margin-bottom: .8rem; font-size: .9rem;
}

/* --------------------------------------------------------------- chips */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .5rem .8rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--white);
  font-size: .85rem; font-weight: 600; color: var(--ink); cursor: pointer;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip.on, .chip:has(input:checked) {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: var(--ink); border-color: var(--orange-deep);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}
.chip.static { cursor: default; }
.tag {
  display: inline-block; padding: .22rem .55rem; border-radius: 8px;
  background: var(--cream-2); color: var(--ink-soft);
  font-size: .7rem; font-weight: 700;
}

/* ------------------------------------------------------------ progress */
.meter { height: 10px; border-radius: 999px; background: var(--cream-2); overflow: hidden; }
.meter > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--orange-bright), var(--orange-deep));
  transition: width .5s ease;
}
.meter.connection > i { background: linear-gradient(90deg, #ffb45c, #ef6f2a); }
.meter.growth > i { background: linear-gradient(90deg, #7ecfae, #2e8b6f); }
.meter.impact > i { background: linear-gradient(90deg, #ffc46b, #e0700d); }
.track-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .65rem; }
.track-row .track-icon { font-size: 1.25rem; width: 1.7rem; text-align: center; }
.track-row .track-body { flex: 1; min-width: 0; }
.track-row .track-top {
  display: flex; justify-content: space-between; gap: .5rem;
  font-size: .78rem; margin-bottom: .25rem;
}
.track-row .track-top b { font-weight: 700; }
.track-row .track-top span { color: var(--muted); }

/* --------------------------------------------------------- journey map */
.journey { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.journey-track {
  display: flex; align-items: flex-start; gap: 0; padding: 1.1rem .2rem .4rem;
  min-width: max-content;
}
/* Milestone labels are one short word (see content.SHORT_THEMES), so 80px fits
   them on a single line and shows more of the road at once. */
.stop { text-align: center; width: 80px; flex: none; position: relative; }
.stop::before {
  content: ""; position: absolute; top: 17px; left: -40px; width: 80px; height: 3px;
  background: var(--line);
}
.stop:first-child::before { display: none; }
.stop.done::before { background: linear-gradient(90deg, var(--orange-bright), var(--orange)); }
.stop b {
  display: grid; place-items: center; width: 36px; height: 36px; margin: 0 auto .3rem;
  border-radius: 50%; font-size: .8rem; position: relative; z-index: 1;
  background: var(--white); border: 1px solid var(--line-strong); color: var(--muted);
}
.stop.done b {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: var(--ink); border-color: var(--orange-deep);
  box-shadow: 0 2px 8px rgba(245, 135, 31, .40);
}
.stop.now b {
  outline: 3px solid var(--orange); outline-offset: 2px;
  background: var(--cream-2); color: var(--ink); font-weight: 800;
}
.stop small {
  font-size: .74rem; color: var(--ink-soft); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; padding: 0 3px; overflow-wrap: break-word;
}
.stop.now small { color: var(--ink); font-weight: 700; }
.stop .flag { font-size: 1.3rem; }

/* ---------------------------------------------------------- challenges */
.challenge-card { display: flex; gap: .8rem; align-items: flex-start; }
.challenge-card .emoji {
  font-size: 1.6rem; width: 2.6rem; height: 2.6rem; flex: none; border-radius: 14px;
  display: grid; place-items: center; background: var(--cream-2);
}
.challenge-card .body { flex: 1; min-width: 0; }
.challenge-card h3 { margin: 0 0 .2rem; font-size: 1rem; color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.meta .tag.done { background: #dcf0e8; color: #1d5c49; }

.filters { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .6rem; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: none; }

/* ------------------------------------------------------------ celebrate */
.celebrate { text-align: center; padding: 2rem 1rem; }
.celebrate .burst { font-size: 4.2rem; animation: pop .55s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes pop { 0% { transform: scale(.2); opacity: 0; } 70% { transform: scale(1.18); } 100% { transform: scale(1); opacity: 1; } }
.points-pill {
  display: inline-flex; align-items: center; gap: .35rem; margin: .25rem;
  padding: .5rem .85rem; border-radius: 999px; font-weight: 800; font-size: .9rem;
  background: var(--cream-2); color: var(--ink);
}
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; width: 9px; height: 14px; border-radius: 2px; opacity: .9;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(680deg); opacity: 0; } }

/* --------------------------------------------------------- quote screen */
.quote-overlay {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  padding: 1.5rem; text-align: center;
  background:
    radial-gradient(620px 420px at 50% 24%, rgba(245, 135, 31, .20), transparent 68%),
    linear-gradient(180deg, var(--cream), var(--white));
  animation: fadein .4s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.quote-overlay blockquote {
  font-family: Georgia, "Times New Roman", serif; font-style: italic;
  font-size: 1.5rem; line-height: 1.45; margin: 0 0 1rem; max-width: 22rem;
  color: var(--ink);
}
.quote-overlay cite {
  color: var(--orange-text); font-style: normal; font-weight: 700; letter-spacing: .08em;
}
.quote-actions { margin-top: 2rem; display: grid; gap: .6rem; width: min(22rem, 100%); }

/* --------------------------------------------------------------- feed */
.feed-item .who { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid;
  place-items: center; font-size: 1.15rem; background: var(--cream-2);
}
.avatar.sm { width: 28px; height: 28px; font-size: .9rem; }
.feed-photo { width: 100%; border-radius: 14px; margin: .55rem 0; display: block; }
.reactions { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .55rem; }
.react {
  border: 1px solid var(--line-strong); background: var(--white); color: var(--ink-soft);
  border-radius: 999px; padding: .35rem .7rem; font-size: .82rem; cursor: pointer;
  font-family: inherit;
}
.react.on { background: #ffeed9; border-color: var(--orange); color: var(--ink); }

/* -------------------------------------------------------------- lists */
.list { display: grid; gap: .55rem; }
.row {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .8rem; border-radius: 14px;
  background: var(--white); border: 1px solid var(--line);
}
.row .grow { flex: 1; min-width: 0; }
.row .rank { width: 1.9rem; text-align: center; font-weight: 800; color: var(--orange-text); }
.row strong { display: block; font-size: .95rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.segmented {
  display: flex; gap: .3rem; background: var(--cream-2); padding: .25rem;
  border-radius: 13px; margin-bottom: .8rem;
}
.segmented a {
  flex: 1; text-align: center; padding: .5rem; border-radius: 10px;
  font-size: .84rem; font-weight: 700; color: var(--ink-soft);
}
.segmented a.on {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: var(--ink);
}

/* -------------------------------------------------------- knowledge cards */
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.kcard {
  border-radius: 16px; padding: .85rem; min-height: 132px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(158deg, #fff3e5, #ffffff 70%);
  border: 1px solid rgba(245, 135, 31, .40); font-size: .86rem; color: var(--ink);
}
.kcard.locked {
  background: var(--white); border-style: dashed;
  border-color: var(--line-strong); color: var(--muted);
}
.kcard .src { font-size: .68rem; color: var(--orange-text); font-weight: 700; letter-spacing: .06em; }

/* --------------------------------------------------------------- misc */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .9rem; }
.duo > *, .two-col > *, .stat-grid > *, .kgrid > * { min-width: 0; }
.duo > .card { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(94px, 1fr)); gap: .5rem; }
.stat {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: .7rem; text-align: center;
}
.stat b { display: block; font-size: 1.35rem; color: var(--ink); }
.stat small { font-size: .68rem; }
.center { text-align: center; }
.muted { color: var(--muted); }
.spacer { height: .8rem; }
.hero-title { font-size: 2rem; letter-spacing: -.03em; }
.countdown { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--orange-text); }
.badge-pill {
  display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .6rem;
  border-radius: 999px; background: var(--cream-2); color: var(--ink);
  font-size: .76rem; font-weight: 700; white-space: nowrap;
}
.pass {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: var(--ink);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }

/* ---------------------------------------------------------- onboarding */
.steps { display: flex; gap: .3rem; margin-bottom: 1rem; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--orange); }
.q { margin-bottom: 1.1rem; }
.q p { font-weight: 700; margin-bottom: .5rem; }

/* ---------------------------------------------------------------- admin */
body.admin { background: #faf7f3; }
body.admin .page { max-width: 1100px; }
.admin-nav { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.admin-nav a {
  padding: .42rem .7rem; border-radius: 10px; background: var(--white);
  border: 1px solid var(--line-strong); font-size: .8rem; color: var(--ink-soft);
  font-weight: 600;
}
.admin-nav a.on {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: var(--ink); border-color: var(--orange-deep);
}

@media (min-width: 720px) {
  .page { padding: 1.5rem; }
  h1 { font-size: 2rem; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; align-items: start; }
}

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