/* Jason's apps — components, v0.4.0
   Needs tokens.css loaded first. No colour literals in this file: every colour
   is a token, or a color-mix() of tokens.

   Everything is prefixed ds- so an app can adopt it one piece at a time
   without clashing with its own class names. demo.html shows each one. */

/* ---------------------------------------------------------------- base ---- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: var(--fs-body); line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.ds-muted { color: var(--muted); }
.ds-faint { color: var(--faint); }

/* ---------------------------------------------------------- title block ---- */
/* The blue band behind every page title. Utility icons sit above it, never in it.
   <header class="ds-title"><div class="ds-title__text"><h1>Plan</h1><p>This week …</p></div></header>
   Today adds arrows: .ds-title--stepper with .ds-arrow before and after the text. */

.ds-title {
  background: var(--title-bg); color: var(--title-text);
  border-radius: var(--radius-lg); margin: 6px 12px 0; padding: 16px 18px 18px;
  display: flex; align-items: center; gap: 12px;
}
.ds-title__text { flex: 1; min-width: 0; }
.ds-title h1 { font-size: var(--fs-title); font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.ds-title p { font-size: var(--fs-small); color: var(--title-muted); margin-top: 3px; }
.ds-title__action {
  height: 40px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: var(--fs-small);
  background: color-mix(in srgb, var(--title-text) 14%, transparent); color: var(--title-text);
}

.ds-title--stepper {
  display: grid; grid-template-columns: var(--tap) 1fr var(--tap); column-gap: 10px; padding: 16px 12px 18px;
}
.ds-title--stepper .ds-title__text { grid-column: 2; }
.ds-title--stepper .ds-title__back { grid-column: 2 / 4; justify-self: end; margin-top: 6px; }
.ds-arrow {
  width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--title-text) 14%, transparent); color: var(--title-text);
}
.ds-arrow:disabled { opacity: .3; cursor: default; }
.ds-arrow svg { width: 22px; height: 22px; }
.ds-title__back {
  height: 30px; padding: 0 12px; border-radius: 999px; font-size: var(--fs-tiny); font-weight: 700;
  background: var(--title-text); color: var(--title-bg);
}

/* --------------------------------------------------------- utility icons ---- */
/* Shopping / notifications / profile: grouped on one pill, top right. */

.ds-topbar { display: flex; justify-content: flex-end; align-items: center; padding: 8px 8px 0; min-height: 56px; }
.ds-topbar__start { margin-right: auto; }
.ds-utils { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 4px; }
.ds-iconbtn { width: 48px; height: 48px; display: grid; place-items: center; position: relative; color: var(--text); }
.ds-iconbtn svg { width: 25px; height: 25px; }
.ds-badge {
  position: absolute; top: 5px; right: 3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--badge); color: var(--badge-text);
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--surface);
}
/* icons are inline SVGs drawn with stroke="currentColor" */
.ds-icon { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* -------------------------------------------------------------- app mark ---- */
/* Which app this is, at the left of the icon row: the app's glyph on a tile of
   its signature colour, then its name. Colour is never the only signal.
   <span class="ds-appmark"><i aria-hidden="true">⌂</i>HomeTracker</span>
   Inside .ds-topbar it pushes the icon pill to the right on its own. */
.ds-appmark { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; padding-left: 4px;
  font-size: 15px; font-weight: 800; letter-spacing: -.2px; color: var(--text); white-space: nowrap; min-width: 0; }
.ds-appmark i { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center;
  font-style: normal; font-size: 15px; background: var(--title-bg); color: var(--title-text); }

/* ------------------------------------------------------ sections & cards ---- */

.ds-section { display: flex; justify-content: space-between; align-items: center; padding: 32px var(--gap) 12px; }
.ds-section h2 { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -.5px; }
.ds-section__hint { font-size: var(--fs-small); color: var(--muted); }
.ds-group-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 20px 20px 8px; }
.ds-group-label--warn { color: var(--warn); }

.ds-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; margin: 0 var(--gap); }
.ds-card--warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.ds-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; margin: 0 var(--gap); }
.ds-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); width: 100%; min-height: 60px;
}
.ds-row:last-child { border-bottom: 0; }
.ds-row__title { font-size: 17px; font-weight: 600; line-height: 1.2; }
.ds-row__sub { font-size: var(--fs-small); color: var(--muted); margin-top: 3px; }
.ds-row__end { text-align: right; }
.ds-row__end b { display: block; font-size: 16.5px; font-weight: 600; }
.ds-row__end span { font-size: var(--fs-tiny); color: var(--muted); }
.ds-row__warn { font-size: var(--fs-tiny); color: var(--warn); font-weight: 600; margin-top: 4px; }

.ds-tile-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; }

/* ------------------------------------------------- the icon is the button ---- */
/* A task's icon is what you tap to finish it. The ring fills as its steps get
   done; set --p from 0 to 1. Add .is-done to the row to show the check. */

.ds-tick { width: 56px; height: 56px; position: relative; display: grid; place-items: center; border-radius: 50%; --p: 0; --ring: var(--tone); }
.ds-tick::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 360deg), var(--surface-2) 0);
  -webkit-mask: radial-gradient(circle, transparent 23.5px, currentColor 24px);
          mask: radial-gradient(circle, transparent 23.5px, currentColor 24px);
}
.ds-tick__glyph { font-size: 24px; transition: transform .2s, opacity .2s; }
.ds-tick__check {
  position: absolute; inset: 6px; border-radius: 50%; background: var(--good); color: var(--bg);
  display: grid; place-items: center; transform: scale(0); transition: transform .2s;
}
.ds-tick__check svg { width: 24px; height: 24px; stroke-width: 3; }
.is-done .ds-tick { --p: 1; --ring: var(--good); }
.is-done .ds-tick__check { transform: scale(1); }
.is-done .ds-tick__glyph { opacity: 0; transform: scale(.5); }
.is-done .ds-row__title { color: var(--faint); text-decoration: line-through; }

/* project-sized ring: same idea, bigger */
.ds-ring { width: 64px; height: 64px; position: relative; display: grid; place-items: center; font-size: 26px; --p: 0; --ring: var(--good); }
.ds-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 360deg), var(--surface-2) 0);
  -webkit-mask: radial-gradient(circle, transparent 27px, currentColor 27.5px);
          mask: radial-gradient(circle, transparent 27px, currentColor 27.5px);
}

/* ------------------------------------------------------------- buttons ---- */

.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: 999px; font-weight: 700; font-size: 16px;
  background: var(--text); color: var(--bg);
}
.ds-btn--block { display: flex; width: calc(100% - 2 * var(--gap)); margin: 18px var(--gap) 0; min-height: 54px; }
.ds-btn--go { background: var(--good); color: var(--bg); }
.ds-btn--quiet { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 600; }
.ds-btn--small { min-height: 40px; padding: 0 14px; font-size: var(--fs-small); }
.ds-link { color: var(--accent); font-weight: 600; font-size: 16px; min-height: var(--tap); padding: 0 8px; }
.ds-pill { display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); font-size: 15px; font-weight: 600; }

/* --------------------------------------------------- choosing one of a few ---- */

.ds-seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 16px var(--gap) 0; }
.ds-seg button { min-height: 40px; border-radius: 9px; text-align: center; font-weight: 600; font-size: 15px; color: var(--muted); }
.ds-seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); }
.ds-seg--on-title { background: color-mix(in srgb, var(--title-text) 14%, transparent); margin: 0; }
.ds-seg--on-title button { color: var(--title-muted); padding: 0 14px; }
.ds-seg--on-title button[aria-pressed="true"] { background: var(--title-text); color: var(--title-bg); }

/* filter tiles: count large, label small; fit four across a phone */
.ds-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 16px var(--gap) 0; }
.ds-tiles button { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 10px 4px; text-align: center; min-height: 64px; }
.ds-tiles b { display: block; font-size: 20px; }
.ds-tiles span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ds-tiles button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.ds-tiles button[aria-pressed="true"] span { color: var(--bg); }
.ds-rule { margin: 10px 20px 0; font-size: var(--fs-small); color: var(--muted); line-height: 1.4; }

.ds-switch { width: 50px; height: 30px; border-radius: 15px; background: var(--surface-2); position: relative; transition: background .15s; flex-shrink: 0; }
.ds-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.ds-switch[aria-checked="true"] { background: var(--good); }
.ds-switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--bg); }

/* --------------------------------------------------------- data, simply ---- */

.ds-meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.ds-meter > span { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--tone); border-radius: 3px; }
.ds-meter--good > span { background: var(--good); }
.ds-steps { display: flex; gap: 6px; }
.ds-steps i { flex: 1; max-width: 30px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.ds-steps i.is-done { background: var(--good); }
.ds-hero { font-size: var(--fs-hero); font-weight: 700; letter-spacing: -2px; line-height: 1; }
.ds-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 12px; text-align: center; }
.ds-stat b { display: block; font-size: 22px; }
.ds-stat span { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------- feature cards ---- */
/* One suggestion, one button. Never more than one on a screen. */

.ds-feature {
  margin: 22px var(--gap) 0; border-radius: var(--radius-lg); padding: 22px 20px; position: relative; overflow: hidden;
  background: var(--feature-bg); color: var(--feature-text);
}
.ds-feature__why { font-size: 12.5px; font-weight: 700; color: var(--feature-muted); text-transform: uppercase; letter-spacing: .6px; }
.ds-feature h3 { font-size: 19px; font-weight: 700; margin-top: 6px; max-width: 64%; }
.ds-feature p { font-size: 16px; margin-top: 4px; line-height: 1.38; color: var(--feature-muted); max-width: 64%; }
.ds-feature__cta { margin-top: 16px; min-height: 46px; padding: 0 22px; border-radius: 999px; background: var(--feature-cta); color: var(--feature-cta-text); font-weight: 700; box-shadow: 0 2px 8px var(--shadow); }
.ds-feature__close { position: absolute; top: 6px; right: 6px; width: 48px; height: 48px; display: grid; place-items: center; color: var(--feature-text); }
.ds-feature__art { position: absolute; right: 0; bottom: 20px; width: 120px; height: 130px; }
.ds-trophy { margin: 10px var(--gap) 0; border-radius: var(--radius-lg); padding: 18px; background: linear-gradient(135deg, var(--feature-bg), var(--feature-bg-2)); color: var(--feature-text); }
.ds-trophy p { color: var(--feature-muted); font-size: var(--fs-small); margin-top: 2px; }

/* -------------------------------------------------- sheet & confirmation ---- */

.ds-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
.ds-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .25s ease;
}
.is-sheet-open .ds-scrim { opacity: 1; pointer-events: auto; }
.is-sheet-open .ds-sheet { transform: none; }
.ds-sheet__grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-2); margin: 0 auto 14px; }
.ds-sheet h3 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.ds-toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 14px); z-index: 30; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); border-radius: 16px; padding: 14px 18px; font-weight: 600;
  opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100% - 32px);
}
.ds-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- shell ---- */
/* Phone: bottom tab bar, icons only. 1000px and up: a left sidebar with labels
   and the active projects, and the page gets the width. Same markup for both:
   <div class="ds-app"><nav class="ds-nav">…</nav><main class="ds-main">…</main></div> */

.ds-app { min-height: 100dvh; }
.ds-main { padding-bottom: calc(var(--tabbar-h) + 24px); }
.ds-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
}
.ds-nav__brand, .ds-nav__extra, .ds-nav__foot { display: none; }
.ds-nav__item { display: grid; place-items: center; height: 60px; color: var(--faint); position: relative; text-decoration: none; }
.ds-nav__item svg { width: 28px; height: 28px; stroke-width: 2; }
.ds-nav__item span { display: none; }
.ds-nav__item[aria-current="page"] { color: var(--text); }

@media (min-width: 1000px) {
  body { background: var(--bg); }
  .ds-app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .ds-main { padding: 0 28px 40px; min-width: 0; }
  .ds-nav {
    position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
    padding: 20px 14px; border-top: 0; border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  }
  .ds-nav__brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; padding: 0 8px 22px; }
  .ds-nav__brand i { width: 32px; height: 32px; border-radius: 9px; background: var(--title-bg); color: var(--title-text); display: grid; place-items: center; font-style: normal; }
  .ds-nav__item {
    display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 12px; border-radius: 12px;
    font-size: 15.5px; font-weight: 600; color: var(--muted);
  }
  .ds-nav__item svg { width: 22px; height: 22px; }
  .ds-nav__item span { display: inline; }
  .ds-nav__item:hover { background: var(--surface); }
  .ds-nav__item[aria-current="page"] { background: var(--title-bg); color: var(--title-text); }
  .ds-nav__extra { display: block; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
  .ds-nav__foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: var(--fs-tiny); }

  /* page furniture gets a little tighter on a wide screen */
  .ds-title { margin: 20px 0 0; padding: 16px 22px; }
  .ds-title h1 { font-size: 32px; }
  .ds-section { padding: 26px 0 12px; }
  .ds-section h2 { font-size: 21px; }
  .ds-card, .ds-list, .ds-feature, .ds-trophy { margin-left: 0; margin-right: 0; }
  .ds-columns { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 24px; }
  .ds-toast { bottom: 28px; }
  .ds-sheet { left: auto; right: 24px; bottom: 24px; width: 420px; border-radius: 22px; }
}
