/* ══════════════════════════════════════════════════════════════
   Dusk design system — shared visual language extracted from the
   weekly planner's "Calm Planner" prototype. Warm dusk-sky hero,
   cream body, Source Serif 4 headings, Albert Sans copy.
   Light = sunset · Dark = night sky (moon + stars).
   Pages using this: onboarding / assessment flow (growing).
   ══════════════════════════════════════════════════════════════ */

:root {
  --dusk-bg:     #faf6f1;
  --dusk-card:   #fff;
  --dusk-card-2: #fffaf5;
  --dusk-ink:    #3a2d27;
  --dusk-copy:   #6f5d52;
  --dusk-muted:  #9a826f;
  --dusk-line:   #eaded1;
  --dusk-rust:   #b5674a;  --dusk-rust-rgb:  181,103,74;
  --dusk-coral:  #c97a58;  --dusk-coral-rgb: 201,122,88;
  --dusk-green:  #7d906c;  --dusk-green-rgb: 125,144,108;
  --dusk-purple: #8b7fa3;  --dusk-purple-rgb:139,127,163;
  --dusk-amber:  #d9a35c;  --dusk-amber-rgb: 217,163,92;
  --dusk-blue:   #7f94ad;  --dusk-blue-rgb:  127,148,173;

  /* dark-pill primary button (from the planner's "Add block") */
  --dusk-pill:      #4b3735;
  --dusk-pill-text: #fffaf4;
  --dusk-pill-icon: #e7a178;

  /* hero (sky) foreground colours */
  --sky-ink:     #f8eee7;
  --sky-eyebrow: #d5b4a8;
  --sky-copy:    #e8d0c1;

  --spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --smooth: cubic-bezier(0.22, 1, 0.36, 1);

  /* App text size — js/dusk-font-scale.js overrides this on <html> and
     sets a matching `zoom`. Anything measured against the viewport must
     divide by it: zoom scales svh/vh too, so 100svh at 1.3 would render
     as 130% of the screen and push content below the fold. */
  --ed-zoom: 1;
}
html.dark {
  --dusk-bg:     #171521;
  --dusk-card:   #211e2c;
  --dusk-card-2: #211e2c;
  --dusk-ink:    #f2edf7;
  --dusk-copy:   #c8bfd0;
  --dusk-muted:  #958a9f;
  --dusk-line:   #373142;
  --dusk-rust:   #d08a6b;  --dusk-rust-rgb:  208,138,107;
  --dusk-coral:  #d79a7e;  --dusk-coral-rgb: 215,154,126;
  --dusk-green:  #98aa88;  --dusk-green-rgb: 152,170,136;
  --dusk-purple: #aaa0c0;  --dusk-purple-rgb:170,160,192;
  --dusk-amber:  #ddb06b;  --dusk-amber-rgb: 221,176,107;
  --dusk-blue:   #9db0c6;  --dusk-blue-rgb:  157,176,198;

  --dusk-pill:      #efe6f2;
  --dusk-pill-text: #2c2335;
  --dusk-pill-icon: #b5674a;

  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: #efe7de; }
html.dark { background: #14131e; }

body {
  background: var(--dusk-bg);
  color: var(--dusk-copy);
  font-family: 'Albert Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s ease, color 0.5s ease;
}
h1, h2, h3, h4 { color: var(--dusk-ink); }
button, input, select, textarea { font-family: 'Albert Sans', sans-serif; }
button { cursor: pointer; }
.material-symbols-rounded { font-variation-settings: 'FILL' 0, 'wght' 400; vertical-align: middle; }

/* ── Dusk hero (sky band) ───────────────────────────────────── */
.dusk-hero {
  position: relative; z-index: 0; isolation: isolate; overflow: hidden;
  padding: calc(18px + env(safe-area-inset-top)) 22px 34px;
  color: var(--sky-copy);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 2px), rgba(0,0,0,.48) calc(100% - 1px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 2px), rgba(0,0,0,.48) calc(100% - 1px), transparent 100%);
  background:
    radial-gradient(140% 110% at 15% -20%, rgba(125,84,110,.62), rgba(125,84,110,0) 55%),
    radial-gradient(120% 100% at 95% -5%, rgba(238,180,137,.5), rgba(238,180,137,0) 52%),
    linear-gradient(168deg, #3e2d47 0%, #6e4550 55%, #a5624e 100%);
}
/* cream wave lapping over the hero's bottom edge */
.dusk-hero::before {
  content: ''; position: absolute; z-index: 2; left: -20%; right: -20%; bottom: -32px; height: 38px;
  pointer-events: none; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: var(--dusk-bg); filter: blur(.7px);
  transition: background 0.5s ease;
}
/* film grain */
.dusk-hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .13;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
}

/* night overlay — fades in when dark mode is on */
.dusk-night {
  position: absolute; inset: 0; z-index: -3; pointer-events: none; opacity: 0;
  background:
    radial-gradient(120% 90% at 18% -12%, rgba(93,89,148,.5), rgba(93,89,148,0) 56%),
    radial-gradient(100% 85% at 92% 5%, rgba(123,91,133,.35), rgba(123,91,133,0) 55%),
    linear-gradient(168deg, #151627 0%, #25233b 53%, #443044 100%);
  transition: opacity .9s ease;
}
html.dark .dusk-night { opacity: 1; }

/* star field (dark mode) */
.dusk-stars {
  position: absolute; inset: 0; z-index: -2; pointer-events: none; opacity: 0;
  background-image:
    radial-gradient(circle at 13% 22%, rgba(255,255,255,.78) 0 1px, transparent 1.4px),
    radial-gradient(circle at 31% 13%, rgba(232,225,255,.72) 0 .8px, transparent 1.2px),
    radial-gradient(circle at 47% 29%, rgba(255,255,255,.62) 0 .7px, transparent 1.1px),
    radial-gradient(circle at 68% 17%, rgba(235,226,255,.75) 0 1px, transparent 1.4px),
    radial-gradient(circle at 84% 34%, rgba(255,255,255,.55) 0 .7px, transparent 1.1px),
    radial-gradient(circle at 92% 12%, rgba(255,255,255,.8) 0 .9px, transparent 1.3px);
  transition: opacity .9s ease;
}
html.dark .dusk-stars { opacity: .88; }
.dusk-stars::before,
.dusk-stars::after { content: ''; position: absolute; inset: 0; pointer-events: none; }
.dusk-stars::before {
  background-image:
    radial-gradient(circle at 18% 36%, rgba(255,255,255,.85) 0 .8px, transparent 1.25px),
    radial-gradient(circle at 39% 8%, rgba(224,218,255,.88) 0 1px, transparent 1.45px),
    radial-gradient(circle at 57% 38%, rgba(255,255,255,.75) 0 .7px, transparent 1.1px),
    radial-gradient(circle at 75% 26%, rgba(236,228,255,.82) 0 .85px, transparent 1.3px);
  animation: duskTwinkleA 4.6s ease-in-out infinite;
}
.dusk-stars::after {
  background-image:
    radial-gradient(circle at 8% 14%, rgba(235,229,255,.82) 0 .7px, transparent 1.1px),
    radial-gradient(circle at 27% 29%, rgba(255,255,255,.76) 0 .9px, transparent 1.35px),
    radial-gradient(circle at 62% 12%, rgba(255,255,255,.9) 0 .8px, transparent 1.25px),
    radial-gradient(circle at 49% 45%, rgba(224,217,255,.8) 0 .75px, transparent 1.2px);
  animation: duskTwinkleB 6.2s ease-in-out -2.4s infinite;
}
.dusk-twinkle {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #f7f3ff; pointer-events: none;
  animation: duskStarSpark 3.8s ease-in-out infinite;
}
.dusk-twinkle:nth-child(1) { left: 17%; top: 30%; animation-delay: -.4s; }
.dusk-twinkle:nth-child(2) { left: 38%; top: 12%; animation-delay: -2.1s; animation-duration: 4.7s; }
.dusk-twinkle:nth-child(3) { left: 56%; top: 34%; animation-delay: -1.2s; animation-duration: 3.4s; }
.dusk-twinkle:nth-child(4) { left: 72%; top: 18%; animation-delay: -3.3s; animation-duration: 5.1s; }
.dusk-twinkle:nth-child(5) { left: 82%; top: 8%; animation-delay: -2.6s; animation-duration: 4.2s; }

/* sun (light) / moon (dark)
   `top` clears the icon row deliberately: at 62px the disc sat 8px under the
   account button, in the same column, and read as something hanging off the
   avatar rather than a sun in the sky. Keep `right` aligned with the icons —
   the vertical gap is what separates them. */
.dusk-disc {
  position: absolute; z-index: -1; right: 26px; top: 86px; width: 52px; height: 52px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 35%, #ffe8c6, #f2b57e 72%);
  box-shadow: 0 0 38px rgba(242,181,126,.65);
  animation: duskFloatY 6s ease-in-out infinite;
  /* No transition: the sun→moon swap must be instant, and it happens
     while the disc is below the horizon mid-animation. */
}
html.dark .dusk-disc {
  background: radial-gradient(circle at 62% 35%, #f6f2ff, #cfc4ec 70%);
  box-shadow: 0 0 26px rgba(207,196,236,.55);
}

/* Sunset / moonrise — the disc dips below the horizon, the theme flips
   while it's out of sight, then the other body rises. Driven by
   js/dusk-theme.js, which stamps these classes on <html>. */
html.theme-setting .dusk-disc { animation: celestialSet .5s ease-in forwards; }
html.theme-rising  .dusk-disc { animation: celestialRise .85s cubic-bezier(.22,.61,.36,1) both; }
/* block re-entry mid-animation */
html.theme-animating .icon-btn[onclick*="toggleDark"],
html.theme-animating #theme-toggle { pointer-events: none; }

/* ── Hero typography ────────────────────────────────────────── */
.dusk-wordmark {
  color: var(--sky-ink); font-family: 'Source Serif 4', serif;
  font-size: 17px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
}
.dusk-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--sky-eyebrow);
}
.dusk-hero h1 {
  color: var(--sky-ink); font-family: 'Source Serif 4', serif;
  font-size: 28px; line-height: 1.12; font-weight: 600; letter-spacing: -.025em;
}
.dusk-hero .dusk-lede { color: var(--sky-copy); font-size: 12.5px; line-height: 1.55; }

/* translucent circle icon buttons inside the hero */
.dusk-icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--sky-ink); border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.09);
  transition: background .2s ease, transform .25s var(--spring);
}
.dusk-icon-btn:hover { background: rgba(255,255,255,.18); }
.dusk-icon-btn:active { transform: scale(.9); }
.dusk-icon-btn .material-symbols-rounded { font-size: 17px; }

/* thin progress bar (sits inside the hero) */
.dusk-progress {
  position: relative; height: 3px; border-radius: 999px;
  background: rgba(255,255,255,.16); overflow: hidden;
}
.dusk-progress > div {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #f1c7a5, #e7a178);
  box-shadow: 0 0 12px rgba(241,199,165,.55);
  transition: width 0.7s var(--smooth);
}

/* ── Cards ──────────────────────────────────────────────────── */
.dusk-card {
  position: relative;
  background: var(--dusk-card);
  border: 1px solid var(--dusk-line);
  border-radius: 17px;
  box-shadow: 0 1px 2px rgba(58,45,39,.03), 0 16px 34px -24px rgba(58,45,39,.3);
  transition: background-color .5s ease, border-color .5s ease, box-shadow .3s ease, transform .3s var(--spring);
}
html.dark .dusk-card { box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 16px 34px -24px rgba(0,0,0,.55); }
/* paper grain on every card */
.dusk-card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit; opacity: .4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.05'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html.dark .dusk-card::after { opacity: .2; }

/* ── Section label (app pages) ──────────────────────────────── */
.dusk-sec-label {
  display: block; margin-bottom: 11px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--dusk-muted);
}

/* ── Floating dock nav (app pages) ──────────────────────────── */
.dusk-dock {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  display: flex; gap: 4px; padding: 6px;
  background: var(--dusk-card-2); border: 1px solid var(--dusk-line); border-radius: 999px;
  box-shadow: 0 12px 36px -12px rgba(58,45,39,.4);
  transition: background-color .5s ease, border-color .5s ease;
}
html.dark .dusk-dock { box-shadow: 0 12px 36px -12px rgba(0,0,0,.65); }
.dusk-dock a {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: 999px;
  color: var(--dusk-muted); text-decoration: none;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  transition: color .2s, background-color .25s;
}
.dusk-dock a .material-symbols-rounded { font-size: 18px; }
.dusk-dock a.active { color: var(--dusk-pill-text); background: var(--dusk-pill); }
.dusk-dock a.active .material-symbols-rounded { color: var(--dusk-pill-icon); font-variation-settings: 'FILL' 1; }
.dusk-dock a:not(.active):hover { color: var(--dusk-ink); }
@media (max-width: 520px) {
  .dusk-dock a { padding: 10px 13px; }
  .dusk-dock a:not(.active) > span:last-child { display: none; }
}

/* ── Account menu (works with js/user-menu.js hooks) ────────── */
.acct-wrap { position: relative; }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 190px; padding: 7px;
  background: var(--dusk-card-2); border: 1px solid var(--dusk-line); border-radius: 16px;
  box-shadow: 0 18px 44px rgba(58,45,39,.18);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .2s, visibility .2s, transform .2s var(--spring);
  z-index: 120;
}
html.dark .acct-menu { box-shadow: 0 18px 44px rgba(0,0,0,.5); }
.acct-menu a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 11px;
  color: var(--dusk-copy); text-decoration: none;
  font-size: 13px; font-weight: 600;
  transition: background .15s, color .15s;
}
.acct-menu a:hover { background: rgba(var(--dusk-rust-rgb), .08); color: var(--dusk-ink); }
.acct-menu a .material-symbols-rounded { font-size: 18px; color: var(--dusk-muted); }
.acct-divider { height: 1px; background: var(--dusk-line); margin: 5px 0; }
/* user-menu.js injects a purple avatar ring — re-tone it for dusk
   (extra specificity so it wins over the runtime-injected sheet) */
.dusk-hero .acct-wrap .icon-btn.has-avatar {
  border-color: rgba(255,255,255,.4);
  box-shadow: 0 0 0 2px rgba(231,161,120,.35);
}

/* ── Buttons ────────────────────────────────────────────────── */
.dusk-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  border-radius: 999px; padding: 13px 24px; border: none;
  transition: opacity .18s, transform .2s var(--spring), box-shadow .25s ease, background-color .25s ease, color .25s ease;
}
.dusk-btn:active { transform: scale(0.95); }
.dusk-btn .material-symbols-rounded { font-size: 18px; transition: transform .25s var(--spring); }

.dusk-btn-primary {
  background: var(--dusk-pill); color: var(--dusk-pill-text);
  box-shadow: 0 10px 26px -12px rgba(58,45,39,.55);
}
.dusk-btn-primary .material-symbols-rounded { color: var(--dusk-pill-icon); }
.dusk-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -12px rgba(58,45,39,.6); }
.dusk-btn-primary:hover .material-symbols-rounded { transform: translateX(3px); }
.dusk-btn-primary:disabled {
  color: #b5a89f; background: #e6ddd6; box-shadow: none; cursor: default; transform: none;
}
.dusk-btn-primary:disabled .material-symbols-rounded { color: #b5a89f; transform: none; }
html.dark .dusk-btn-primary:disabled { color: #6e6579; background: #2b2738; }

.dusk-btn-ghost {
  background: var(--dusk-card-2); color: var(--dusk-copy);
  border: 1px solid var(--dusk-line); padding: 12px 23px;
}
.dusk-btn-ghost:hover { border-color: var(--dusk-rust); color: var(--dusk-ink); }
.dusk-btn-ghost:disabled { opacity: .45; cursor: default; }
.dusk-btn-ghost:disabled:hover { border-color: var(--dusk-line); color: var(--dusk-copy); }

/* ── Shared keyframes ───────────────────────────────────────── */
@keyframes duskFloatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes celestialSet  { to { transform: translateY(120px); opacity: 0; } }
@keyframes celestialRise { from { transform: translateY(120px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes duskTwinkleA {
  0%,100% { opacity: .12; filter: brightness(.62); }
  28% { opacity: .82; filter: brightness(1.35) drop-shadow(0 0 1.5px rgba(235,228,255,.42)); }
  53% { opacity: .24; filter: brightness(.76); }
  78% { opacity: 1; filter: brightness(1.55) drop-shadow(0 0 2px rgba(243,238,255,.55)); }
}
@keyframes duskTwinkleB {
  0%,100% { opacity: .88; filter: brightness(1.35) drop-shadow(0 0 1.5px rgba(235,228,255,.4)); }
  34% { opacity: .15; filter: brightness(.66); }
  67% { opacity: .96; filter: brightness(1.5) drop-shadow(0 0 2px rgba(243,238,255,.52)); }
  84% { opacity: .28; filter: brightness(.78); }
}
@keyframes duskStarSpark {
  0%,100% { opacity: .2; transform: scale(.65); box-shadow: 0 0 0 rgba(238,232,255,0); }
  46% { opacity: .95; transform: scale(1.35); box-shadow: 0 0 5px rgba(238,232,255,.72); }
  62% { opacity: .48; transform: scale(.9); box-shadow: 0 0 2px rgba(238,232,255,.28); }
}
@keyframes duskRiseIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes duskFadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
