/* The DIY intro's three screens (diy-intro.js): one at a time, a bar above each fills while it shows. Glossy cards in
   one blue, the F.I.R.E screen's cobalt (founder, 27 Nov 2026), for every wash, glow, meter and shimmer; the portal's
   type: Foliyo Sans, figures in tabular-nums, sentence case. Full screen (body.onb-full): the cards fill the height. */

.diy {
  --diy-ink: #0F2D21;
  --diy-muted: #5C6E64;
  --diy-line: rgba(15, 45, 33, 0.10);
  --diy-green: #0F8A62;
  --diy-cobalt: #1F5FD6;
  --diy-blue-deep: #1748A8;
  --diy-sh: rgba(31, 95, 214, 0.07);
  --diy-sh-hi: rgba(31, 95, 214, 0.16);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

/* Bars: one per screen, the current one fills over its time on screen. */
.diy-bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 0 2px; }
.diy-bar {
  position: relative; height: 20px; padding: 0; border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.diy-bar::before, .diy-bar i {
  content: ''; position: absolute; left: 0; top: 8px; height: 4px; border-radius: 9999px;
}
.diy-bar::before { right: 0; background: rgba(31, 95, 214, 0.14); }
.diy-bar i { width: 0; background: var(--diy-cobalt); }
.diy-bar.done i { width: 100%; }
.diy-bar.run i { animation: diy-fill var(--diy-dwell, 5200ms) linear forwards; }
.diy.paused .diy-bar.run i { animation-play-state: paused; }
@keyframes diy-fill { from { width: 0; } to { width: 100%; } }

/* The screens side by side, one in view; swipeable. Padding gives the cards' shadows room inside the scroller. */
.diy-track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  margin: -6px -16px -18px;
  padding: 6px 0 18px;
}
.diy-track::-webkit-scrollbar { display: none; }
.diy-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  padding: 0 16px;
  display: flex;
}

/* ── The card: a tinted wash from the top, a soft glow and a glass sheen ─────────────────────────────────────────── */
.diy-card {
  --tint: #E9EFFC;
  --glow: rgba(31, 95, 214, 0.20);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 1;
  min-height: 452px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--tint) 0%, #FFFFFF 52%);
  border: 1px solid rgba(15, 45, 33, 0.08);
  box-shadow: 0 1px 2px rgba(15, 45, 33, 0.06), 0 18px 36px -20px rgba(15, 45, 33, 0.30);
}
.diy-card::before {   /* glow, top right */
  content: ''; position: absolute; z-index: -1; top: -90px; right: -70px; width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 68%);
}
.diy-card::after {    /* sheen across the top edge */
  content: ''; position: absolute; z-index: -1; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 26%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.diy-head { display: flex; align-items: center; gap: 12px; }
.diy-head-t { flex: 1; min-width: 0; }
.diy-name { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; color: var(--diy-ink); }
.diy-cap { margin: 1px 0 0; font-size: 13px; line-height: 1.4; color: var(--diy-muted); }

/* The first second: a shimmering placeholder card, then the screens fade in (diy-intro.js FIRST_WAIT). */
.diy-skel { display: none; }
.diy.loading .diy-skel { display: flex; }
.diy.loading .diy-track { display: none; }
.diy-skel .diy-card { gap: 12px; }
.diy-skel .sk-name { width: 46%; height: 16px; }
.diy-skel .sk-cap { width: 64%; height: 12px; margin-top: -4px; }
.diy-skel .sk-hero { width: 100%; flex: 1; min-height: 160px; border-radius: 18px; margin: 10px 0; }
.diy-skel .sk-line { width: 100%; height: 10px; }
.diy-skel .sk-line.short { width: 62%; }
.diy-track { animation: diy-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes diy-appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Shimmer: placeholders for what will be the client's own funds and amounts. */
.sh {
  display: block; height: 10px; border-radius: 9999px;
  background: linear-gradient(90deg, var(--diy-sh) 20%, var(--diy-sh-hi) 40%, var(--diy-sh) 60%) 0 0 / 300% 100%;
  animation: diy-shimmer 1.6s linear infinite;
}
@keyframes diy-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ── Portfolio health ─────────────────────────────────────────────────────────────────────────────────────────── */
.g-wrap { display: flex; flex-direction: column; align-items: center; }
.g-svg { width: 100%; max-width: 250px; height: auto; display: block; overflow: visible; }
.g-track, .g-fill { fill: none; stroke-width: 14; stroke-linecap: round; }
.g-track { stroke: rgba(31, 95, 214, 0.10); }
.g-fill { stroke: #9DB9F2; filter: drop-shadow(0 3px 8px rgba(31, 95, 214, 0.25)); }
.g-tick { stroke: rgba(15, 45, 33, 0.18); stroke-width: 1.5; stroke-linecap: round; }
.g-tick.major { stroke: rgba(15, 45, 33, 0.32); stroke-width: 2; }
.g-end { font-size: 10px; font-weight: 600; fill: var(--diy-muted); }
.g-needle path { fill: var(--diy-ink); }
.g-hub { fill: var(--diy-ink); }
.g-hub-dot { fill: #FFFFFF; }
.g-read { display: flex; align-items: baseline; gap: 2px; margin-top: 4px; color: var(--diy-ink); }
.g-num { font-size: 40px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; min-width: 1.4em; text-align: right; }
.g-of { font-size: 15px; font-weight: 600; color: var(--diy-muted); }
.g-word { margin: 4px 0 0; font-size: 13.5px; font-weight: 700; color: var(--diy-blue-deep); }

.h-rows { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.h-rows li { display: grid; grid-template-columns: 118px minmax(0, 1fr) 30px; align-items: center; gap: 10px; }
.h-name { font-size: 14px; font-weight: 600; color: var(--diy-ink); white-space: nowrap; }
.h-bar { position: relative; height: 8px; border-radius: 9999px; background: rgba(31, 95, 214, 0.08); overflow: hidden; }
.h-bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background-color: var(--diy-cobalt); transition: background-color 0.5s ease; }
.h-num { transition: color 0.5s ease; }
/* Once a line has stopped (diy-intro.js): yellow for a fair score, red for a poor one. */
.h-rows li.warn .h-bar i { background-color: #E5A50A; }
.h-rows li.warn .h-num { color: #A16B00; }
.h-rows li.bad .h-bar i { background-color: #D64545; }
.h-rows li.bad .h-num { color: #B42318; }
.h-bar::after {   /* the shimmer running over each line */
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.65) 50%, transparent 100%) -60% 0 / 50% 100% no-repeat;
  animation: diy-sweep 1.8s ease-in-out infinite;
  animation-delay: calc(var(--k, 0) * 180ms);
}
@keyframes diy-sweep { from { background-position: -60% 0; } to { background-position: 160% 0; } }
.h-num { font-size: 14px; font-weight: 700; text-align: right; color: var(--diy-ink); }

/* ── F.I.R.E ──────────────────────────────────────────────────────────────────────────────────────────────────── */
.f-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.f-k { margin: 0; font-size: 13px; font-weight: 600; color: var(--diy-muted); }
.f-year { margin: 2px 0 0; font-size: 44px; font-weight: 800; letter-spacing: -0.045em; line-height: 1; color: var(--diy-ink); }
.f-age {
  margin-bottom: 4px; padding: 6px 11px; border-radius: 9999px; font-size: 13px; font-weight: 700; white-space: nowrap;
  color: #0B6E4E; background: rgba(15, 138, 98, 0.10); border: 1px solid rgba(15, 138, 98, 0.18);
}
.f-prog p { margin: 0 0 7px; font-size: 13.5px; color: var(--diy-ink); }
.f-prog b { font-weight: 700; }
.f-track { height: 8px; border-radius: 9999px; background: rgba(15, 45, 33, 0.08); overflow: hidden; }
.f-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #13A374, var(--diy-green)); }
.f-chart { width: 100%; height: auto; display: block; overflow: visible; }
.f-grid { stroke: rgba(15, 45, 33, 0.06); stroke-width: 1; }
.f-base { stroke: rgba(15, 45, 33, 0.14); stroke-width: 1; }
.f-wealth { fill: none; stroke: var(--diy-green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.f-need { fill: none; stroke: var(--diy-cobalt); stroke-width: 2; stroke-dasharray: 5 5; opacity: 0; }
.f-area { opacity: 0; }
.f-mark { opacity: 0; }
.f-vline { stroke: var(--diy-green); stroke-width: 1.2; stroke-dasharray: 2 4; }
.f-dot { fill: var(--diy-green); stroke: #FFFFFF; stroke-width: 2.5; }
.f-lab { font-size: 11px; font-weight: 700; fill: #0B6E4E; }
.f-ax { font-size: 10px; font-weight: 600; fill: var(--diy-muted); }
.diy-slide.on .f-wealth { animation: diy-draw 1.5s cubic-bezier(0.33, 1, 0.68, 1) 0.15s forwards; }
.diy-slide.on .f-need { animation: diy-in 0.6s ease-out 0.1s forwards; }
.diy-slide.on .f-area { animation: diy-in 0.9s ease-out 0.9s forwards; }
.diy-slide.on .f-mark { animation: diy-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 1.45s forwards; transform-origin: center; transform-box: fill-box; }
@keyframes diy-draw { to { stroke-dashoffset: 0; } }
@keyframes diy-in { to { opacity: 1; } }
@keyframes diy-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.f-key { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--diy-muted); }
.f-key li { display: inline-flex; align-items: center; gap: 7px; }
.f-key i { width: 16px; height: 0; border-top: 3px solid var(--diy-green); border-radius: 2px; }
.f-key i.k-n { border-top: 2px dashed var(--diy-cobalt); }

/* ── Rebalance ────────────────────────────────────────────────────────────────────────────────────────────────── */
.r-tabs {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px;
  background: rgba(15, 45, 33, 0.06);
}
.r-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--diy-muted);
}
.r-tab.on { background: #FFFFFF; color: var(--diy-ink); box-shadow: 0 1px 2px rgba(15, 45, 33, 0.10), 0 4px 10px -6px rgba(15, 45, 33, 0.25); }
.r-tab em {
  font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 9999px; display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #FFFFFF; background: var(--diy-cobalt);
}
.r-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.r-list li {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 68px; align-items: center; gap: 12px;
  padding: 14px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.92); border: 1px solid var(--diy-line);
}
.r-logo.sh { width: 36px; height: 36px; border-radius: 11px; }
.r-txt { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.r-line { display: flex; align-items: center; min-height: 12px; }
.r-line .sh { height: 11px; }
.r-amt { display: flex; justify-content: flex-end; }
.r-amt .sh { width: 100%; height: 14px; }
.r-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 9999px;
  font-style: normal; font-size: 12px; font-weight: 700; line-height: 1.3;
}
.r-tag svg { width: 13px; height: 13px; }
.r-tag.lag { color: #8A4B08; background: #FEF3E2; border: 1px solid #F7DDB2; }
.r-tag.com { color: #B42318; background: #FDEDEC; border: 1px solid #F8D0CC; }
.r-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px;
  border-top: 1px solid var(--diy-line); font-size: 14px; font-weight: 700; color: var(--diy-ink);
}
.r-foot .sh { width: 92px; height: 14px; }
.diy-slide .r-list li { opacity: 0; }
.diy-slide.on .r-list li { animation: diy-row 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; animation-delay: calc(0.15s + var(--k, 0) * 0.14s); }
@keyframes diy-row { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Full screen: the card takes the height left between the title and the dock; its contents spread to fill it. */
body.onb-full .diy-card { min-height: calc(100dvh - 290px); }   /* fits above the buttons on a phone */
body.onb-full .g-wrap { flex: 1; justify-content: center; }
body.onb-full .g-svg { max-width: 290px; }
body.onb-full .h-rows { gap: 16px; }
body.onb-full .f-chart { margin-top: auto; }
body.onb-full .r-list li { padding: 18px 12px; }

/* Desktop: keep the screens phone-sized rather than stretched across the column. */
@media (min-width: 861px) {
  .diy { max-width: 480px; }
  body.onb-full .diy-card { min-height: min(560px, calc(100dvh - 330px)); }
  body.onb-full .g-svg { max-width: 240px; }
  .f-chart { max-height: 210px; }   /* it scales with the card's width; the screens all take the tallest one's height */
  body.onb-full .r-list li { padding: 12px; }
}

/* Short phones (640-700px tall): a smaller gauge and chart so a screen fits above the dock. */
@media (max-height: 720px) {
  .diy-card { min-height: 0; gap: 10px; }
  .g-svg { max-width: 190px; }
  .g-num { font-size: 32px; }
  .h-rows { gap: 9px; }
  .f-year { font-size: 36px; }
  .r-list li { padding: 10px 12px; }
}

/* Narrow phones (360px and under): tighter rows. */
@media (max-width: 370px) {
  .h-rows li { grid-template-columns: 108px minmax(0, 1fr) 28px; gap: 8px; }
  .h-name { font-size: 13px; }
  .diy-card { padding: 14px 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .diy-bar.run i { animation: none; width: 100%; }
  .diy-track { animation: none; }
  .sh, .h-bar::after { animation: none; }
  .f-wealth { stroke-dashoffset: 0; }
  .f-need, .f-area, .f-mark, .diy-slide .r-list li { opacity: 1; }
  .diy-slide.on .f-wealth, .diy-slide.on .f-need, .diy-slide.on .f-area, .diy-slide.on .f-mark, .diy-slide.on .r-list li { animation: none; }
}

/* Short phones: the full-screen card's height rule (above) wins over the short-screen one, so undo it here. */
@media (max-height: 720px) {
  body.onb-full .diy-card { min-height: 0; }
  body.onb-full .g-svg { max-width: 180px; }
  body.onb-full .h-rows { gap: 9px; }
  body.onb-full .r-list li { padding: 10px 12px; }
  .f-chart { max-height: 150px; }
  .r-list li:nth-child(n+4) { display: none; }   /* three funds to sell are enough to show the idea on a short phone */
}
