/* appteczka.eu — scroll story (agent S). Everything here lives inside .story, plus the .story-pill canvas
   and the landing state of the footer sign (.foot-logo).
   Progressive enhancement:
   - without JS (no html.js) the chapters are plain blocks with a static gradient per scene, panels and
     phones fully visible, the footer sign complete;
   - html.js turns chapters into 250vh scroll rooms with a sticky .pin and hides panels/phones until
     story.js fades them in (through the custom properties --in/--out/--ph-in/--ph-out/--drift);
   - story.js adds html.has-story when it runs; only then is the top arm of the footer sign empty
     (waiting for the capsule). If the canvas is unavailable it adds .story-off and everything shows.
   Panels never use theme tokens: their colours are fixed per data-tone, so they read the same in the
   light and the dark theme of the page. Breakpoint: 900px, the same query as in story.js. */

.story { position: relative; isolation: isolate; }
.story-bg { display: none; }
.story-pill { display: none; }
.story-hint { margin: 0; padding: 28px 16px 0; text-align: center; font: 700 12px/1.4 var(--body, "Schibsted Grotesk", system-ui, sans-serif);
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink2, #4A5B73); }

/* ---------- chapters: static layout (no JS) ---------- */
.chapter { position: relative; z-index: 1; }
.pin { box-sizing: border-box; display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr) minmax(0, 280px); align-items: center; gap: 24px;
  padding: 64px max(20px, calc((100% - 1240px) / 2)); }
.chapter[data-scene="poranek"] { background: linear-gradient(180deg, #D7E3F4, #F6E3D3); }
.chapter[data-scene="skaner"]  { background: linear-gradient(180deg, #0E223D, #173C66); }
.chapter[data-scene="pudelka"] { background: linear-gradient(180deg, #EEF2F8, #DCE4EF); }
.chapter[data-scene="rodzina"] { background: linear-gradient(180deg, #172848, #383C6C); }
.chapter[data-scene="dziecko"] { background: linear-gradient(180deg, #08152B, #132A4C); }

/* ---------- panels: fixed colours per tone ---------- */
.story .panel { grid-column: 1; position: relative; padding: 30px 32px; border-radius: 26px; color: #0B1B33;
  background: rgba(255, 255, 255, .78); -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .85); box-shadow: 0 30px 60px -36px rgba(11, 27, 51, .45); }
.story .panel .kicker { margin: 0 0 12px; font: 700 12.5px/1.3 var(--body, "Schibsted Grotesk", system-ui, sans-serif); letter-spacing: .14em; text-transform: uppercase; color: #C24400; }
.story .panel h2 { margin: 0 0 14px; font: 700 clamp(28px, 3.1vw, 42px)/1.06 var(--display, "Bricolage Grotesque", system-ui, sans-serif); letter-spacing: -.02em; color: inherit; text-wrap: balance; }
.story .panel .lead { margin: 0; font: 400 17.5px/1.5 var(--body, "Schibsted Grotesk", system-ui, sans-serif); color: #33445C; }
.story .panel .ticks { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.story .panel .ticks li { position: relative; padding-left: 30px; font: 500 15.5px/1.45 var(--body, "Schibsted Grotesk", system-ui, sans-serif); color: #0B1B33; }
.story .panel .ticks li::before { content: ""; position: absolute; left: 0; top: .12em; width: 19px; height: 19px; border-radius: 50%;
  background: #F85800 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.3l2.2 2.2 4.6-4.9' fill='none' stroke='%23fff' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; }
.chapter[data-tone="dark"] .panel { color: #F4F7FB; background: rgba(11, 27, 51, .6); border-color: rgba(255, 255, 255, .13); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6); }
.chapter[data-tone="dark"] .panel .kicker { color: #FF8A3D; }
.chapter[data-tone="dark"] .panel .lead { color: #BAC7D9; }
.chapter[data-tone="dark"] .panel .ticks li { color: #E6ECF4; }
.story .panel a { color: inherit; }

/* ---------- phones ---------- */
.story .ph { grid-column: 3; justify-self: end; margin: 0; }
.story .ph .phone { width: min(260px, 20vw); }
.story .ph .phone-screen { display: block; width: 100%; height: auto; }

/* ---------- scroll story (JS on) ---------- */
html.js .story:not(.story-off) .story-bg { display: block; position: sticky; top: 0; z-index: 0; width: 100%; height: 100vh; height: 100lvh; margin-bottom: -100vh; margin-bottom: -100lvh; }
html.js .story-pill { display: block; position: fixed; inset: 0; width: 100%; height: 100vh; height: 100lvh; z-index: 30; pointer-events: none; }
html.js .story.story-off ~ .story-pill { display: none; }
html.js .story:not(.story-off) .story-hint { position: absolute; top: 18svh; left: 0; right: 0; z-index: 2; padding-top: 0; color: var(--ink2, #4A5B73); opacity: var(--hint, 1); }
html.js .story:not(.story-off) .chapter { height: 250vh; height: 250svh; background: none; }
html.js .story:not(.story-off) { overflow: clip; } /* the sticky canvas never paints past the story */
html.js .story:not(.story-off)::after { content: ""; display: block; height: 70vh; height: 70svh; } /* the page colour rises over the last scene here */
html.js .story:not(.story-off) .pin { position: sticky; top: 0; height: 100vh; height: 100svh; padding: 88px max(20px, calc((100% - 1240px) / 2)) 40px; pointer-events: none; }
html.js .story:not(.story-off) .panel { pointer-events: auto; will-change: opacity, transform; --in: 0; --out: 0;
  opacity: calc(var(--in) * (1 - var(--out)));
  transform: translate3d(0, calc((1 - var(--in)) * 28px - var(--out) * 20px), 0); }
/* staggered entrance of the panel's lines: kicker, title, lead, ticks (each starts ~0.12 later) */
html.js .story:not(.story-off) .panel > * { --k: clamp(0, calc(var(--in) * 1.8 - var(--i, 0) * .22), 1);
  opacity: var(--k); transform: translate3d(0, calc((1 - var(--k)) * 12px), 0); }
html.js .story .panel > :nth-child(2) { --i: 1; }
html.js .story .panel > :nth-child(3) { --i: 2; }
html.js .story .panel > :nth-child(n+4) { --i: 3; }
html.js .story:not(.story-off) .ph { will-change: opacity, transform; --ph-in: 0; --ph-out: 0; --drift: 0;
  opacity: calc(var(--ph-in) * (1 - var(--ph-out)));
  transform: translate3d(calc((1 - var(--ph-in)) * 48px), calc(var(--drift) * 28px - var(--ph-out) * 24px), 0) rotate(calc((1 - var(--ph-in)) * 3deg)); }
html.js .story:not(.story-off) .ph .phone { width: min(260px, 20vw, calc((100svh - 170px) * .44)); }

/* ---------- footer sign: the capsule lands in the empty top arm ---------- */
.foot-logo { position: relative; }
.foot-logo [data-part="ramie-gora"] { transition: opacity .32s cubic-bezier(.16, 1, .3, 1); }
.foot-logo [data-part="ramie-gora-obrys"] { opacity: 0; transition: opacity .25s ease; }
html.has-story .foot-logo:not(.landed) [data-part="ramie-gora"] { opacity: 0; transition-duration: .12s; }
html.has-story .foot-logo:not(.landed) [data-part="ramie-gora-obrys"] { opacity: 1; }
.foot-logo .landing { position: absolute; left: var(--land-x, 50%); top: var(--land-y, 30%); width: 140%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(248, 88, 0, .42), rgba(248, 88, 0, .12) 38%, rgba(248, 88, 0, 0) 68%); opacity: 0; scale: .35; }
.foot-logo.landed .landing { animation: story-landing 1.1s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes story-landing { 0% { opacity: 0; scale: .35; } 18% { opacity: 1; } 100% { opacity: 0; scale: 1.25; } }
.foot-logo.landed svg { animation: story-landed .6s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes story-landed { 0% { scale: 1; } 35% { scale: 1.05; } 100% { scale: 1; } }

/* ---------- phones and small screens ---------- */
@media (max-width: 900px) {
  .pin { grid-template-columns: minmax(0, 1fr); padding: 40px 16px; gap: 20px; }
  .story .ph { grid-column: 1; justify-self: center; }
  .story .ph .phone { width: min(220px, 62vw); }
  .story .panel { grid-column: 1; padding: 22px 22px 20px; border-radius: 22px; }
  .story .panel h2 { font-size: clamp(24px, 6.6vw, 30px); margin-bottom: 10px; }
  .story .panel .lead { font-size: 16px; }
  .story .panel .ticks { margin-top: 14px; gap: 7px; }
  .story .panel .ticks li { font-size: 14.5px; }
  html.js .story:not(.story-off) .chapter { height: 230vh; height: 230svh; }
  /* the scene draws in the upper part, the text sits at the bottom on a translucent card; the real
     screenshot is shown elsewhere on the page, so the phone is left out of the small layout */
  html.js .story:not(.story-off) .pin { align-content: end; padding: 72px 16px max(16px, env(safe-area-inset-bottom)); }
  html.js .story:not(.story-off) .ph { display: none; }
  html.js .story:not(.story-off) .story-hint { top: 12svh; }
}
@media (max-width: 380px) {
  .story .panel { padding: 18px 18px 16px; }
  .story .panel .lead { font-size: 15.5px; }
}

/* ---------- accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html.js .story .panel, html.js .story .panel > *, html.js .story .ph { transform: none !important; }
  .foot-logo [data-part="ramie-gora"], .foot-logo [data-part="ramie-gora-obrys"] { transition: none; }
  .foot-logo.landed .landing { animation: story-landing-still .8s ease-out both; }
  .foot-logo.landed svg { animation: none; }
  @keyframes story-landing-still { 0% { opacity: 0; scale: 1; } 25% { opacity: .8; } 100% { opacity: 0; scale: 1; } }
}
@media (prefers-reduced-transparency: reduce) {
  .story .panel { background: #FFFFFF; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .chapter[data-tone="dark"] .panel { background: #0F2340; }
}
@media (prefers-contrast: more) {
  .story .panel { background: #FFFFFF; border-color: #0B1B33; }
  .chapter[data-tone="dark"] .panel { background: #0B1B33; border-color: #EEF2F8; }
  .story .panel .lead { color: #0B1B33; }
  .chapter[data-tone="dark"] .panel .lead { color: #EEF2F8; }
}
