/* The introduction stays in view as the three demonstrations scroll past. */
.service-story-section {
  --story-rule: #766b6433;
  --story-surface: #f7f1eb;
  --story-ink: #2d282c;
  --story-muted: #635962;
  --story-inbound: #fff;
  --story-demo-height: clamp(330px, 30vw, 392px);
  padding-block: 100px 80px;
}

html[data-theme="dark"] .service-story-section {
  --story-rule: #e6dfd82e;
}

.service-story-layout {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: clamp(40px, 6vw, 80px);
  align-items: start;
}

.service-story-intro {
  position: sticky;
  top: clamp(112px, 21svh, 150px);
  padding-top: 24px;
}

.service-story-intro h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(36px, 4.1vw, 60px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.045em;
}

.service-story-intro h2 span { display: block; }

.service-story-caption {
  max-width: 390px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
  text-wrap: pretty;
}

.service-story-stories {
  display: grid;
  grid-auto-rows: 1fr;
  min-width: 0;
}

.service-story-item {
  min-height: min(74svh, 720px);
  padding: 34px 0 72px;
  border-top: 1px solid var(--story-rule);
}

.story-demo { height: var(--story-demo-height); }

.story-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-bottom: 7px;
}

.story-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 2.1vw, 30px);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.035em;
}

.story-caption {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  text-wrap: pretty;
}

.story-channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.story-channel {
  --story-channel-tint: #efe6df;
  min-width: 0;
  padding: clamp(9px, 1.4vw, 16px);
  border: 1px solid var(--story-rule);
  border-radius: 18px;
  background: var(--story-surface);
  color: var(--story-ink);
  box-shadow: inset 0 1px #ffffff75;
}

.story-channel-line { --story-channel-tint: #d7efdc; }
.story-channel-messenger { --story-channel-tint: #dce9ff; }
.story-channel-instagram { --story-channel-tint: #efe6de; }

.story-channel h4 {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 33px;
  margin: 0 0 10px;
  color: var(--story-ink);
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 700;
  line-height: 1.3;
}

.story-channel-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 9px;
  background: var(--story-channel-tint);
}

.story-channel-icon img { display: block; object-fit: contain; }

.story-channel-chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.story-bubble {
  max-width: 96%;
  margin: 0;
  padding: 7px 10px;
  border-radius: 11px 11px 11px 3px;
  background: var(--story-inbound);
  font-size: clamp(12px, 1.1vw, 14px);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.story-bubble-reply {
  align-self: flex-end;
  border-radius: 11px 11px 3px 11px;
  background: var(--story-channel-tint);
}

.story-phone-stage,
.story-web-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--story-rule);
  border-radius: 22px;
  isolation: isolate;
}

.story-phone-stage {
  display: grid;
  align-content: end;
  justify-items: center;
  padding-top: 20px;
  background: radial-gradient(ellipse at 50% 30%, #b3a49684, transparent 70%), #ebe3e0;
}

.story-phone {
  position: relative;
  width: min(93%, calc(var(--story-demo-height) - 20px));
  container-type: inline-size;
}

.story-phone-hardware {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) sepia(.8);
}

.story-phone-status {
  position: absolute;
  top: 10%;
  right: 14%;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fef9f5;
  font: 650 10px/1 system-ui, sans-serif;
}

.story-phone-battery {
  width: 15px;
  height: 7px;
  border: 1px solid #fef9f5ae;
  border-radius: 2px;
  background: linear-gradient(90deg, #fef9f5 72%, transparent 72%) content-box;
  padding: 1px;
}

.story-phone-clock {
  position: absolute;
  inset: 29% 12% auto;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: #fef9f5;
  font-size: clamp(10px, 4.2cqw, 15px);
  line-height: 1.3;
  text-shadow: 0 1px 4px #16112780;
}

.story-phone-clock strong {
  font: 650 clamp(40px, 17cqw, 64px)/1 system-ui, sans-serif;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
}

.story-push {
  position: absolute;
  top: 20%;
  z-index: 1;
  inset-inline: 12%;
  padding: clamp(8px, 3.1cqw, 12px);
  border: 1px solid #ffffff9e;
  border-radius: clamp(12px, 5cqw, 17px);
  background: linear-gradient(145deg, rgb(251 244 233 / .72), rgb(224 193 157 / .58));
  color: #312a23;
  box-shadow: 0 12px 28px #100b2b61, 0 2px 7px #100b2b35, inset 0 1px #fff9;
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  backdrop-filter: blur(24px) saturate(145%);
  font-size: clamp(11px, 4cqw, 14px);
  line-height: 1.4;
}

.story-push-heading {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  color: #594e44;
  font-size: .84em;
  font-weight: 650;
}

.story-push-heading small { margin-left: auto; font-size: 1em; }
.story-push p { margin: 3px 0 0; font-size: .93em; }

.story-web-stage,
.story-theme-choice {
  --story-theme: #63442f;
  --story-theme-light: #f1dfcc;
}

:is([data-chat-theme="gold"], [data-story-chat-color="gold"]) {
  --story-theme-fill: linear-gradient(125deg, #523726, #855c3f);
  --story-theme-swatch: var(--gold-fill);
}

:is([data-chat-theme="blue"], [data-story-chat-color="blue"]) {
  --story-theme: #19466d;
  --story-theme-light: #dcecff;
}

:is([data-chat-theme="green"], [data-story-chat-color="green"]) {
  --story-theme: #275448;
  --story-theme-light: #dceee5;
}

.story-web-stage {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 17px;
  background: #f8f4ed;
  color: var(--story-ink);
}

.story-web-background {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #faf6f0;
}

.story-web-photograph {
  height: 64%;
  border-bottom: 1px solid #5846363d;
  background: linear-gradient(105deg, #2d211b54, #47332816), url("assets/service-support.webp") center 53% / cover;
}

.story-web-copy {
  display: grid;
  gap: 6px;
  width: 47%;
  padding: 15px 0 0 18px;
  color: #68564e;
  font-size: 12px;
}

.story-web-copy strong { color: var(--story-ink); font-size: clamp(15px, 2vw, 24px); }
.story-web-copy i { display: block; width: 85%; height: 5px; border-radius: 999px; background: #ded4cb; }
.story-web-copy i:last-child { width: 65%; }

.story-widget-panel {
  position: absolute;
  right: 17px;
  bottom: 76px;
  width: min(310px, calc(100% - 34px));
  overflow: hidden;
  border: 1px solid #4d403426;
  border-radius: 17px;
  background: #fff;
  color: var(--story-ink);
  box-shadow: 0 16px 34px #2e221735;
  transform-origin: bottom right;
}

.story-widget-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 12px;
  background: var(--story-theme-fill, var(--story-theme));
  color: #fff;
  font-size: 14px;
}

.story-widget-heading img { display: block; object-fit: contain; }

.story-widget-conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: clamp(158px, 13.5vw, 182px);
  padding: 15px;
  background: linear-gradient(#fff, #fcf9f7);
}

.story-widget-message {
  width: fit-content;
  max-width: 93%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px 12px 12px 3px;
  background: #f1eeeb;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.story-widget-message[hidden] { display: none; }
.story-widget-customer { align-self: flex-end; border-radius: 12px 12px 3px 12px; background: var(--story-theme-light); }

.story-widget-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 45px;
  padding: 6px 9px;
  border-top: 1px solid #4d403420;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

.story-widget-composer [data-story-draft] {
  flex: 1;
  min-width: 0;
  padding-left: 3px;
  overflow-wrap: anywhere;
}

.story-widget-composer [data-story-draft]:empty::before { content: "輸入訊息…"; color: var(--story-muted); }
.story-widget-composer.is-typing [data-story-draft]::after { content: ""; border-right: 1px solid var(--story-theme); margin-left: 2px; }

.story-widget-send {
  display: grid;
  flex: none;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 8px;
  background: var(--story-theme-fill, var(--story-theme));
  color: #fff;
  transition: transform 150ms ease;
}

.story-widget-send .icon { width: 15px; height: 15px; }
.story-widget-composer.is-sending .story-widget-send { transform: scale(.82); }
.story-widget-message.is-arriving { animation: story-appear 280ms both ease-out; }

html[data-theme] body.glass-site .story-widget-toggle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #fff4;
  border-radius: 50%;
  background: var(--story-theme-fill, var(--story-theme));
  color: #fff;
  box-shadow: 0 8px 18px #2e221740;
  transform: none;
}

html[data-theme] body.glass-site .story-widget-toggle:hover { background: color-mix(in srgb, var(--story-theme), white 16%); }
html[data-theme] body.glass-site .story-widget-toggle:focus-visible { outline: 2px solid var(--story-theme); outline-offset: 3px; }
.story-widget-toggle .icon { width: 21px; height: 21px; }
.story-widget-toggle[aria-expanded="true"] .story-widget-open-icon,
.story-widget-toggle[aria-expanded="false"] .story-widget-close-icon { display: none; }

.story-theme-picker { display: flex; align-items: center; gap: 3px; }

html[data-theme] body.glass-site .story-theme-choice {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.story-theme-choice::before {
  content: "";
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--story-theme-swatch, var(--story-theme));
  border: 1px solid #fff8;
}

html[data-theme] body.glass-site .story-theme-choice:is(:hover, [aria-pressed="true"]) { border-color: var(--text); }
html[data-theme] body.glass-site .story-theme-choice:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.story-ready .story-channel-grid:not(.is-playing) .story-bubble,
.story-ready .story-phone-stage:not(.is-playing) .story-push { opacity: 0; }
.story-channel-grid.is-playing .story-bubble { animation: story-appear 370ms var(--arrival) both cubic-bezier(.18,.8,.35,1); }
.story-channel-grid.is-playing .story-bubble-reply { animation-delay: calc(var(--arrival) + 570ms); }
.story-phone-stage.is-playing .story-push { animation: story-push 540ms 150ms both cubic-bezier(.19,.88,.33,1.12); }
.story-ready .story-widget-panel:not([hidden]) { animation: story-appear 350ms both cubic-bezier(.18,.8,.35,1); }

@keyframes story-appear {
  from { opacity: 0; transform: translateY(7px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes story-push {
  from { opacity: 0; transform: translateY(-8px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 1600px) {
  .service-story-layout {
    grid-template-columns: minmax(0, 448px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .service-story-section { padding-block: 76px 64px; }
  .service-story-layout { grid-template-columns: minmax(0, 1fr); gap: 34px; max-width: 640px; margin-inline: auto; }
  .service-story-intro { position: static; padding: 0; }
  .service-story-intro h2 { font-size: clamp(34px, 5vw, 48px); }
  .service-story-caption { max-width: 520px; }
  .service-story-item { min-height: 0; padding: 26px 0 48px; }
}

@media (max-width: 520px) {
  .service-story-section { --story-demo-height: 350px; padding-block: 64px 46px; }
  .service-story-caption { margin-top: 16px; font-size: 15px; }
  .story-channel { border-radius: 13px; }
  .story-bubble { padding-inline: 7px; }
  .story-channel-icon { width: 25px; height: 25px; }
  .story-channel-icon img { width: 15px; height: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .service-story-section :is(.story-bubble, .story-push, .story-widget-panel, .story-widget-message, .story-widget-send) {
    animation: none !important;
    transition: none !important;
  }
}
