/* Service pages, top to bottom (PLAN.md section 4). Steps, rows and the call to action band are shared
   components. */

/* 1. Hero: number seal, name, promise, Start a project. On wide screens the right half shows the
   service's Services-menu drawing, large, built in once, and the sub-services under it. */

.service-hero {
  padding-block: var(--space-2xl) var(--space-xl);
}

.service-hero__main {
  display: grid;
  justify-items: start;
  gap: var(--space-m);
}

/* Beside the title on wide screens only (the sub-services are listed in full further down). */
.service-hero__side {
  display: none;
}

@media (min-width: 900px) {
  .service-hero__inner {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
    align-items: end;
    gap: var(--space-2xl);
  }

  .service-hero__side {
    display: block;
  }

  .service-hero__art {
    margin-bottom: var(--space-xl);
  }

  /* The menu's own drawing, scaled up; its lines stay as fine as in the menu. */
  .service-hero__art .art {
    display: block;
    width: 100%;
    height: auto;
  }

  .service-hero__art .art * {
    vector-effect: non-scaling-stroke;
  }

  .service-hero__list {
    margin-top: var(--space-s);
    border-top: var(--border);
    font-family: var(--font-sans);
    font-size: var(--step--1);
  }

  .service-hero__list li {
    padding-block: var(--space-xs);
    border-bottom: var(--border);
  }
}

.service-hero__top {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  font-family: var(--font-sans);
  font-size: var(--step--1);
}

/* The number is pressed like a seal as the page opens. */
.service-hero__num {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  background: var(--vermilion);
  color: var(--on-accent);
  font-variant-numeric: tabular-nums;
}

.service-hero__crumb {
  color: var(--ink-2);
  text-decoration: none;
}

.service-hero__crumb:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.service-hero__title {
  font-size: var(--step-5);
  font-weight: 350;
  letter-spacing: -0.02em;
}

.service-hero__promise {
  max-width: 22ch;
  font-size: var(--step-3);
  line-height: var(--leading-snug);
  color: var(--ink-2);
}

.service-hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-m) var(--space-l);
  margin-top: var(--space-s);
}

.service-hero__actions .link-arrow {
  min-height: 2.75rem;
}

.link-arrow--down .arrow {
  rotate: 90deg;
}

@media (prefers-reduced-motion: no-preference) {
  .service-hero__num {
    animation: seal-press var(--dur-fast) var(--ease-out) 150ms both;
  }

  /* The drawing builds in the way it does in the menu, once, and then stays. */
  .service-hero__art .art * {
    animation-iteration-count: 1;
  }

  .service-hero__art .art :is(.draw, .grow, .pop) {
    animation-duration: var(--dur);
  }

  .service-hero__art .art .draw {
    animation-name: art-in-x;
  }

  .service-hero__art .art .grow {
    animation-name: art-in-y;
  }

  .service-hero__art .art .pop {
    animation-name: art-in-pop;
  }
}

@keyframes art-in-x {
  from {
    transform: scaleX(0);
  }
}

@keyframes art-in-y {
  from {
    transform: scaleY(0);
  }
}

@keyframes art-in-pop {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes seal-press {
  0% {
    opacity: 0;
    transform: scale(1.12);
  }

  70% {
    opacity: 1;
    transform: scale(0.94);
  }
}

/* Services overview (/services/): the list follows the hero closely. */
.overview {
  padding-top: var(--space-xl);
}

/* 2. Try it: the one interactive demo (its own CSS is in demo-*.css) */

.try {
  padding-top: var(--space-xl);
}

.try__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xl);
}

.try__intro h2 {
  font-size: var(--step-4);
}

.try__intro p {
  max-width: 34ch;
  margin-top: var(--space-s);
  font-size: var(--step-1);
  line-height: var(--leading-snug);
}

.try__intro .try__note {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  line-height: var(--leading-body);
  color: var(--ink-2);
}

/* "Demo built by Hope Takumi", shown on every demo. */
.demo-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-2);
}

.demo-label img {
  width: 1.25rem;
  height: 1.25rem;
}

/* Segmented switch used by demos: real radio buttons, so arrow keys move between options. */

.switch {
  display: inline-flex;
  justify-self: start;
  min-inline-size: 0;
  margin: 0;
  padding: 3px;
  border: var(--border);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: var(--step--1);
}

.switch label {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding-inline: 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.switch label:hover {
  color: var(--link-hover);
}

.switch label:has(:checked) {
  background: var(--ink);
  color: var(--paper);
}

.switch label:has(:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch label:has(:disabled) {
  cursor: default;
}

@media (min-width: 1024px) {
  .try__grid {
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    gap: var(--space-3xl);
  }

  .try__intro {
    padding-top: var(--space-l);
  }

  /* Wide demos sit below the introduction, which runs in two columns. */
  .try__grid--wide {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-xl);
  }

  .try__grid--wide .try__intro {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    column-gap: var(--space-3xl);
    padding-top: 0;
  }

  .try__grid--wide .try__intro h2 {
    grid-row: span 2;
  }

  .try__grid--wide .try__intro p {
    grid-column: 2;
    margin-top: 0;
  }

  .try__grid--wide .try__intro .try__note {
    margin-top: var(--space-s);
  }
}

/* 3. Concepts: three cards. The whole card opens the concept large in a lightbox (pages/service.js).
   With a mouse (or keyboard focus) the image scales a little inside its frame and the label presses
   like a vermilion stamp. Nothing else moves. */

.concepts__list {
  display: grid;
  gap: var(--space-xl) var(--space-m);
}

.concept {
  position: relative;
}

.concept__media {
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.concept__media img {
  width: 100%;
  height: auto;
}

.concept__label {
  display: inline-block;
  margin-top: var(--space-s);
  padding: 0.125rem 0.625rem;
  border: var(--border);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-2);
}

.concept__title {
  margin-top: var(--space-xs);
  font-size: var(--step-2);
}

.concept__text {
  margin-top: var(--space-2xs);
  color: var(--ink-2);
}

.concept__open:not(:disabled)::after {
  cursor: zoom-in;
}

.concept:has(.concept__open:focus-visible) .concept__label {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: var(--on-accent);
}

@media (hover: hover) {
  .concept:hover .concept__label {
    background: var(--vermilion);
    border-color: var(--vermilion);
    color: var(--on-accent);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .concept__media img {
    transition: transform var(--dur-zoom) var(--ease-out);
  }

  .concept:has(.concept__open:focus-visible) .concept__media img {
    transform: scale(1.03);
  }

  .concept:has(.concept__open:focus-visible) .concept__label {
    animation: press var(--dur-press) var(--ease-out);
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .concept:hover .concept__media img {
    transform: scale(1.03);
  }

  .concept:hover .concept__label {
    animation: press var(--dur-press) var(--ease-out);
  }
}

@keyframes press {
  50% {
    transform: scale(0.94);
  }
}

@media (min-width: 768px) {
  .concepts__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Lightbox (a modal <dialog>): the concept large, with its title, description and the other two a
   key or click away. Opens with a short fade and scale; without motion it simply appears. */

.lightbox {
  width: min(100vw - 2 * var(--gutter), 66rem, (100svh - 15rem) * 1.6);
  margin: auto; /* centred (the reset removes the browser's own margin) */
  max-width: none;
  max-height: calc(100svh - 2 * var(--space-s));
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border: 0;
  border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.lightbox::backdrop {
  background: var(--scrim);
}

.lightbox__inner {
  position: relative;
}

.lightbox__frame {
  aspect-ratio: 16 / 10;
  background: var(--paper-2);
  border-bottom: var(--border);
}

.lightbox__frame img {
  width: 100%;
  height: 100%;
}

.lightbox__close {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.lightbox__close svg {
  width: 1rem;
  height: 1rem;
}

.lightbox__close:hover {
  color: var(--link-hover);
}

.lightbox__body {
  display: grid;
  gap: var(--space-m);
  padding: var(--space-m);
}

.lightbox__label,
.lightbox__count {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-2);
}

.lightbox__title {
  margin-top: var(--space-2xs);
  font-size: var(--step-3);
}

.lightbox__text {
  max-width: 52ch;
  margin-top: var(--space-2xs);
  color: var(--ink-2);
}

.lightbox__nav {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}

.lightbox__count {
  min-width: 3.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lightbox__step {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: var(--border);
  border-radius: 50%;
}

.lightbox__step:hover {
  border-color: var(--ink);
}

.lightbox__step--prev .arrow {
  rotate: 180deg;
}

/* The page behind stays where it is (pages/service.js keeps the scrollbar's space). */
.lightbox-open {
  overflow: hidden;
  padding-right: var(--scrollbar, 0);
}

@media (min-width: 768px) {
  .lightbox__body {
    grid-template-columns: 1fr auto;
    align-items: end;
    padding: var(--space-l);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] {
    animation: lightbox-in var(--dur-fast) var(--ease-out);
  }

  .lightbox[open]::backdrop {
    animation: fade-in var(--dur-fast) var(--ease-out);
  }
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* 5. Packages */

.packages {
  background: var(--paper-2);
}

.packages__list {
  display: grid;
  gap: var(--space-m);
}

.package {
  display: flex;
  flex-direction: column;
  align-items: start;
  padding: var(--space-l) var(--space-m);
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
}

.package__name {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.package__price {
  margin-top: var(--space-s);
  font-size: var(--step-3);
  line-height: var(--leading-tight);
}

.package__from {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-2);
}

.package__note {
  margin-top: var(--space-2xs);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-2);
}

.package__text {
  margin-top: var(--space-xs);
  color: var(--ink-2);
}

.package__list {
  align-self: stretch;
  margin-block: var(--space-m) var(--space-l);
  border-top: var(--border);
  font-family: var(--font-sans);
  font-size: var(--step--1);
}

.package__list li {
  display: flex;
  gap: var(--space-xs);
  padding-block: var(--space-xs);
  border-bottom: var(--border);
}

.package__list li::before {
  content: "";
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  margin-top: 0.5em;
  background: var(--ink);
}

.package .btn {
  margin-top: auto;
}

@media (min-width: 768px) {
  .packages__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .package {
    padding: var(--space-xl);
  }
}

/* 6. How it works: one thin ink line draws through the four steps, in reading order, the first time the
   list is seen (pages/service.js adds .is-inked), and each number is stamped as a vermilion seal as the
   line reaches it. Without JS, or with reduced motion, the list is shown drawn and stamped. */

.steps--ink .step {
  position: relative;
  border-top: 0;
}

.steps--ink .step:nth-child(2) { --i: 1; }
.steps--ink .step:nth-child(3) { --i: 2; }
.steps--ink .step:nth-child(4) { --i: 3; }

.steps--ink .step::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 1px solid var(--ink);
  transform-origin: 0 50%;
}

.steps--ink .step::before {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--vermilion);
  border-radius: var(--radius);
  color: var(--vermilion-ink);
  font-variant-numeric: tabular-nums;
}

.steps--ink .step h3 {
  margin-top: var(--space-m);
}

/* Where steps share a row, the line runs on across the gap, so it reads as one line. */
@media (min-width: 600px) {
  .steps--ink .step:nth-child(odd)::after {
    right: calc(-1 * var(--space-l));
  }
}

@media (min-width: 1024px) {
  .steps--ink .step:not(:last-child)::after {
    right: calc(-1 * var(--space-l));
  }
}

@media (prefers-reduced-motion: no-preference) {
  .js .steps--ink:not(.is-inked) .step::after {
    transform: scaleX(0);
  }

  .js .steps--ink:not(.is-inked) .step::before {
    opacity: 0;
  }

  .steps--ink .step::after {
    transition: transform var(--dur-fast) linear calc(var(--i, 0) * var(--dur-fast));
  }

  .steps--ink.is-inked .step::before {
    animation: seal-press var(--dur-press) var(--ease-out) calc(var(--i, 0) * var(--dur-fast)) both;
  }
}

/* 7. Tools we use */

.tools__grid {
  display: grid;
  gap: var(--space-xl);
}

.tools h2 {
  font-size: var(--step-4);
}

.tools__list {
  border-top: var(--border);
}

.tools__list div {
  display: grid;
  gap: var(--space-3xs) var(--space-m);
  padding-block: var(--space-s);
  border-bottom: var(--border);
}

.tools__list dt {
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--ink-2);
}

.tools__list dd {
  margin: 0;
  font-size: var(--step-1);
}

@media (min-width: 600px) {
  .tools__list div {
    grid-template-columns: 10rem 1fr;
    align-items: baseline;
  }
}

@media (min-width: 1024px) {
  .tools__grid {
    grid-template-columns: 1fr 2fr;
  }
}

/* 8. FAQ: the shared accordion (components.css). */

/* 10. Next service: one large ink row to the next service in menu order (the last loops to the first). */

.next {
  padding-block: var(--space-xl);
}

.row--next .row__body {
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  row-gap: var(--space-2xs);
  padding-block: var(--space-l);
}

.next__label {
  grid-column: 1 / -1;
  font-size: var(--step-1);
  color: var(--row-muted);
}

.row--next .row__title {
  font-size: var(--step-3);
}

@media (min-width: 600px) {
  .row--next .row__body {
    grid-template-columns: auto 2.25rem minmax(0, 1fr) auto;
    column-gap: var(--space-m);
  }

  .next__label {
    grid-column: auto;
    font-size: var(--step-4);
  }

  .row--next .row__title {
    font-size: var(--step-4);
  }
}
