/* Apps page: hero shelf (each icon opens its app), one tinted story card per app, closing block, dock. */

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

[data-app='deca']    { --tint: #EAF1FB; --accent: #3D5E9C; }
[data-app='bwbuddy'] { --tint: #FAF2DC; --accent: #86621A; }
[data-app='blank']   { --tint: var(--peach); --accent: #B0533C; }
[data-app='qed']     { --tint: #EEEDFA; --accent: #5450B0; }
[data-app='stance']  { --tint: #E8E8FC; --accent: #4B49C8; }
[data-app='yap']     { --tint: #FDEAEE; --accent: #C8264A; }

/* ---------- Hero ---------- */
.apps-hero { padding: calc(var(--nav-h) + clamp(64px, 9vw, 120px)) 0 clamp(64px, 8vw, 112px); text-align: center; }
.apps-hero h1 { font-size: var(--t-hero); letter-spacing: -0.045em; }

.shelf-stage { position: relative; width: max-content; max-width: calc(100% - 2 * var(--gutter)); margin: clamp(96px, 11vw, 140px) auto 0; }
.shelf { position: relative; z-index: 1; display: flex; gap: clamp(14px, 2.6vw, 34px); padding: clamp(14px, 1.8vw, 22px) clamp(16px, 2.4vw, 30px) clamp(12px, 1.4vw, 16px); border-radius: clamp(30px, 3.4vw, 42px); background: rgba(255, 255, 255, 0.7); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 0 0 1px rgba(35, 43, 61, 0.07), var(--shadow-3); }
.shelf a { display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1vw, 12px); border-radius: 26%; -webkit-tap-highlight-color: transparent; animation: shelf-pop 0.9s var(--spring) both; animation-delay: calc(220ms + var(--i) * 90ms); }
.shelf .app-icon { --s: clamp(62px, 8.2vw, 108px); transition: transform 0.5s var(--spring), box-shadow 0.4s; }
.shelf .app-icon.hop { animation: icon-hop 1s var(--out); }
.shelf a { position: relative; }
@media (hover: hover) { .shelf a:hover .app-icon { box-shadow: 0 0 0 1px rgba(35, 43, 61, 0.06), 0 16px 24px -12px rgba(35, 43, 61, 0.45); } }
.shelf a:active .app-icon { transform: scale(0.94); transition-duration: 0.12s; }
.shelf a:focus-visible { outline-offset: 6px; }
.shelf .nm { font-size: clamp(13px, 1.1vw, 15px); font-weight: 800; color: var(--ink); letter-spacing: -0.01em; white-space: nowrap; }
/* Phones: six icons no longer fit in one row, so the shelf becomes two rows of three */
@media (max-width: 540px) {
  .shelf { display: grid; grid-template-columns: repeat(3, auto); gap: 16px 26px; padding: 16px 24px 14px; }
}

/* The mascot peeks over the shelf; the box clips only its bottom so it can rise from behind the edge */
.peek { position: absolute; z-index: 0; left: 62%; bottom: calc(100% - 5px); width: clamp(104px, 13.5vw, 176px); aspect-ratio: 520 / 326; clip-path: inset(-60% -60% 0 -60%); }
.peek img { width: 100%; height: 100%; transform-origin: 50% 92%; rotate: var(--tilt, 0deg); transition: rotate 0.9s var(--spring); animation: peek-rise 1.1s var(--spring) both; animation-delay: 0.85s; }

@keyframes shelf-pop { from { opacity: 0; transform: translateY(28px) scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes peek-rise { from { transform: translateY(102%); } to { transform: none; } }
@keyframes icon-hop {
  0% { transform: none; }
  28% { transform: translateY(-24%); }
  52% { transform: none; }
  66% { transform: translateY(-7%); }
  80%, 100% { transform: none; }
}

/* ---------- One story card per app ---------- */
.stack { padding: 0 clamp(10px, 2vw, 24px); }
.anchor { display: block; height: 0; }
.app { margin: 0 auto clamp(12px, 2vw, 24px); max-width: 1240px; transform-origin: 50% 0; }
.app-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr); align-items: center; gap: clamp(36px, 5vw, 72px); padding: clamp(28px, 5vw, 68px); border-radius: clamp(30px, 3.6vw, 48px); background: var(--tint); }
.flip .app-card { grid-template-columns: minmax(0, 1.14fr) minmax(0, 1fr); }
.flip .app-text { order: 2; }

.app-id { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(22px, 2.4vw, 30px); }
.app-id .app-icon { --s: 60px; }
.app-id b { display: block; font-size: 20px; font-weight: 900; color: var(--ink); letter-spacing: -0.025em; line-height: 1.2; }
.app-id span:not(.app-icon) { display: block; font-size: 15px; font-weight: 800; color: var(--accent); }

.app h2 { font-size: var(--t-h2); }
.app .lead { margin-top: clamp(16px, 1.6vw, 22px); color: var(--text); }
.app .more { margin-top: 12px; font-size: var(--t-body); font-weight: 600; color: var(--muted); }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: clamp(26px, 2.8vw, 34px) 0 clamp(26px, 2.8vw, 34px); padding-top: 18px; border-top: 1px solid rgba(35, 43, 61, 0.1); text-align: center; }
.facts div { padding: 0 8px; }
.facts div + div { border-left: 1px solid rgba(35, 43, 61, 0.1); }
.facts dt { font-size: 14px; font-weight: 800; color: var(--text); line-height: 1.25; hyphens: manual; -webkit-hyphens: manual; }
.facts dd { margin: 0; }
.facts dd:first-of-type { margin-top: 6px; font-size: clamp(18px, 1.7vw, 22px); font-weight: 900; color: var(--ink); letter-spacing: -0.03em; line-height: 1.15; text-wrap: balance; }
.facts dd + dd { margin-top: 4px; font-size: 14px; font-weight: 700; color: var(--muted); line-height: 1.3; text-wrap: balance; hyphens: manual; -webkit-hyphens: manual; }

.app-demo { border-radius: var(--r-xl); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7), var(--shadow-2); }

@media (max-width: 860px) {
  .app-card, .flip .app-card { grid-template-columns: minmax(0, 1fr); }
  .flip .app-text { order: 0; }
  .app-demo { border-radius: calc(var(--r-xl) - 6px); }
  .app-demo .scene { border-radius: calc(var(--r-xl) - 6px); }
}
@media (max-width: 480px) {
  .app-card { padding: 26px 20px 20px; }
  .app h2 { font-size: 34px; }
  .app .lead { font-size: 19px; }
  .facts div { padding: 0 4px; }
  .facts dt { font-size: 13px; }
  .facts dd:first-of-type { font-size: 18px; }
  .facts dd + dd { font-size: 13px; }
  .app .btn { width: 100%; }
}

/* ---------- Closing ---------- */
.apps-end { padding: clamp(88px, 10vw, 128px) 0 clamp(88px, 10vw, 128px); }
.apps-end h2 { font-size: var(--t-h2); text-align: center; }
.end-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 2vw, 24px); margin-top: clamp(36px, 4.6vw, 60px); }
.end-card { display: flex; flex-direction: column; align-items: flex-start; padding: clamp(28px, 3.6vw, 44px); border-radius: var(--r-xl); background: var(--snow); }
.end-card h3 { margin-top: 14px; font-size: var(--t-h3); line-height: 1.15; }
.end-card p { margin-top: 10px; font-weight: 600; color: var(--muted); }
.end-card .link { margin-top: auto; padding-top: 26px; }
.end-card.finance { transition: transform 0.5s var(--spring), box-shadow 0.4s, background 0.3s; }
@media (hover: hover) {
  .end-card.finance:hover { transform: translateY(-4px); background: var(--white); box-shadow: var(--shadow-2); }
  .end-card.finance:hover .link::after { transform: translateX(3px); }
}
.end-card.contact { background: var(--ink); }
.end-card .status { hyphens: manual; -webkit-hyphens: manual; }
.end-card.contact h3 { margin-top: 0; color: var(--white); }
.end-card.contact p { color: rgba(255, 255, 255, 0.72); }
.end-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 28px; }
.end-card.contact .btn { padding: 0 20px; background: var(--white); color: var(--ink); box-shadow: none; }
.end-card.contact .btn.soft { background: rgba(255, 255, 255, 0.12); color: var(--white); }
@media (hover: hover) { .end-card.contact .btn.soft:hover { background: rgba(255, 255, 255, 0.2); } }
@media (max-width: 760px) {
  .end-grid { grid-template-columns: minmax(0, 1fr); }
  .end-card { padding: 28px 24px; }
  .end-card .status { font-size: 13.5px; }
  .end-btns .btn { flex: 1 1 auto; }
}

/* ---------- Floating dock: jump between the apps ---------- */
.dock { position: fixed; z-index: 40; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 6px; padding: 7px; border-radius: 24px; background: rgba(255, 255, 255, 0.72); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); box-shadow: 0 0 0 1px rgba(35, 43, 61, 0.07), 0 14px 34px -14px rgba(35, 43, 61, 0.42); transform: translate(-50%, calc(100% + 30px)); opacity: 0; transition: transform 0.55s var(--spring), opacity 0.3s; pointer-events: none; }
.dock[hidden] { display: none; }
.dock.on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.dock a { position: relative; display: flex; padding: 3px; border-radius: 14px; -webkit-tap-highlight-color: transparent; }
.dock a::after { content: ''; position: absolute; left: 50%; bottom: -3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ink); opacity: 0; transform: scale(0.4); transition: opacity 0.25s, transform 0.4s var(--spring); }
.dock a[aria-current='true']::after { opacity: 1; transform: none; }
.dock .app-icon { --s: 40px; display: block; transition: transform 0.45s var(--spring); }
@media (hover: hover) { .dock a:hover .app-icon { transform: translateY(-3px) scale(1.06); } }
.dock a[aria-current='true'] .app-icon { transform: scale(1.1); }
.dock a:active .app-icon { transform: scale(0.92); transition-duration: 0.12s; }

/* Wide screens: the dock is a rail on the right edge, clear of the cards */
@media (min-width: 1000px) {
  .dock { left: auto; right: 18px; top: 50%; bottom: auto; flex-direction: column; transform: translate(calc(100% + 30px), -50%); }
  .dock.on { transform: translate(0, -50%); }
  .dock a::after { left: -4px; top: 50%; bottom: auto; margin: -2px 0 0; }
  .stack { padding-right: 92px; padding-left: 92px; }
}
@media (min-width: 1000px) and (max-width: 1180px) { .dock .app-icon { --s: 36px; } }

@media (prefers-reduced-motion: reduce) {
  .shelf a, .peek img, .shelf .app-icon.hop { animation: none; }
  .peek img { transition: none; }
  .dock { transition: opacity 0.2s; }
}
@media print { .dock, .shelf-stage { display: none !important; } }
