/* ==========================================================================
   Wanna — absorbed component enhancements (vanilla CSS, no dependencies)
   --------------------------------------------------------------------------
   This file layers refined micro-interactions on top of the site's base
   styles. Every value is driven by the --wanna-* design tokens
   (design/tokens.json v3.0); the fallbacks below only apply when this file
   is used standalone (e.g. components-preview.html).

   Patterns researched on GitHub and rewritten from scratch for this site
   (no third-party code copied; interaction patterns only):
     1. Reveal-on-scroll ......... inspired by michalsnik/aos (MIT)
     2. Count-up statistics ...... pattern after inorganik/countUp.js (MIT)
     3. Button fill sweep ......... after button hovers in uiverse-io/galaxy (MIT)
        Link arrow + underline .... after link patterns in markmead/hyperui (MIT)
     4. Header scrolled pill ...... header patterns in markmead/hyperui (MIT);
        motion scale adapted from argyleink/open-props (MIT)
     5. Hairline card hover ....... border discipline of primer/css (MIT)
                                    + card patterns in markmead/hyperui (MIT)
     6. Form focus-within detail .. form controls in shoelace-style/shoelace
                                    (MIT, now Web Awesome) + markmead/hyperui (MIT)
   All motion honours prefers-reduced-motion; focus and touch specs follow
   tokens.json (2px ring + 2px offset on :focus-visible, targets >= 44px).
   ========================================================================== */

/* ---- Local aliases (resolve to the site tokens when the base CSS loads) -- */
:root {
  --wc-background: var(--wanna-background, #ffffff);
  --wc-surface:    var(--wanna-surface, #f1f5fa);
  --wc-text:       var(--wanna-text, #17212b);
  --wc-muted:      var(--wanna-muted, #526277);
  --wc-border:     var(--wanna-border, #d4dee9);
  --wc-action:     var(--wanna-action, #075ccb);
  --wc-on-action:  var(--wanna-on-action, #ffffff);
  --wc-hover:      var(--wanna-hover, #084da6);
  --wc-pressed:    var(--wanna-pressed, #073d82);
  --wc-focus:      var(--wanna-focus, #0969da);
  --wc-link:       var(--wanna-link, #075ccb);
  --wc-brand:      var(--wanna-brand, #095bc9);

  /* Motion scale adapted from argyleink/open-props (MIT): restrained
     ease-out curves and a 3-step duration ladder. */
  --wc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --wc-ease:     cubic-bezier(0.25, 0, 0.3, 1);
  --wc-dur-1: 180ms;
  --wc-dur-2: 320ms;
  --wc-dur-3: 640ms;

  --wc-shadow-card: 0 14px 34px -18px rgb(23 33 43 / 0.22);
  --wc-shadow-pill: 0 10px 30px -14px rgb(23 33 43 / 0.28);
}
@media (prefers-color-scheme: dark) {
  :root {
    --wc-background: var(--wanna-background, #0d1520);
    --wc-surface:    var(--wanna-surface, #152231);
    --wc-text:       var(--wanna-text, #f2f6fc);
    --wc-muted:      var(--wanna-muted, #b5c3d4);
    --wc-border:     var(--wanna-border, #53677d);
    --wc-action:     var(--wanna-action, #176ad6);
    --wc-hover:      var(--wanna-hover, #0f5bc2);
    --wc-pressed:    var(--wanna-pressed, #084da6);
    --wc-focus:      var(--wanna-focus, #a5ceff);
    --wc-link:       var(--wanna-link, #87baff);
    --wc-shadow-card: 0 14px 34px -18px rgb(0 0 0 / 0.65);
    --wc-shadow-pill: 0 10px 30px -14px rgb(0 0 0 / 0.7);
  }
}

/* ==========================================================================
   1. Reveal-on-scroll — inspired by michalsnik/aos (MIT)
   Elements start visible in the raw HTML; JS adds .wc-armed only when
   IntersectionObserver is available, so no-JS / no-IO still shows content.
   Usage: <div data-reveal> ... </div>
          <div data-reveal data-reveal-delay="120"> ... </div>
   ========================================================================== */
[data-reveal].wc-armed {
  opacity: 0;
  transform: translateY(14px);
}
[data-reveal].wc-armed.wc-in {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity var(--wc-dur-3) var(--wc-ease-out),
    transform var(--wc-dur-3) var(--wc-ease-out);
  transition-delay: var(--wc-reveal-delay, 0ms);
}

/* ==========================================================================
   2. Count-up statistics — pattern after inorganik/countUp.js (MIT)
   Usage: <span class="wc-countup" data-countup="501">0</span>万円
   The suffix/unit stays outside the counting span so only digits animate.
   ========================================================================== */
.wc-countup {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ==========================================================================
   3a. Primary button fill sweep — after uiverse-io/galaxy button hovers (MIT)
   A panel in the hover colour rises from the bottom edge; the label stays
   above it. Colour change only — no gradients, no glow.
   Usage: add .wc-btn-sweep to the primary button element.
   ========================================================================== */
.wc-btn-sweep {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.wc-btn-sweep::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--wc-hover);
  transform: translateY(101%);
  transition: transform var(--wc-dur-2) var(--wc-ease-out);
}
.wc-btn-sweep:hover::before,
.wc-btn-sweep:focus-visible::before {
  transform: translateY(0);
}
.wc-btn-sweep:active::before {
  background: var(--wc-pressed);
}

/* ==========================================================================
   3b. Text link: arrow slide + underline grow — after markmead/hyperui (MIT)
   Usage: <a class="wc-link-arrow" href="...">詳しく見る <span class="wc-arrow" aria-hidden="true">→</span></a>
   The underline is a background gradient in currentColor (not a colour
   gradient — a hard-stop mask that grows from 0% to 100% width).
   ========================================================================== */
.wc-link-arrow {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  color: var(--wc-link);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size var(--wc-dur-2) var(--wc-ease-out);
  padding-block: 0.35em; /* keeps the hit area generous without layout shift */
  margin-block: -0.35em;
}
.wc-link-arrow:hover,
.wc-link-arrow:focus-visible {
  background-size: 100% 1px;
}
.wc-link-arrow .wc-arrow {
  display: inline-block;
  transition: transform var(--wc-dur-2) var(--wc-ease-out);
}
.wc-link-arrow:hover .wc-arrow,
.wc-link-arrow:focus-visible .wc-arrow {
  transform: translateX(4px);
}

/* ==========================================================================
   4. Header scrolled pill — header patterns in markmead/hyperui (MIT),
      motion scale adapted from argyleink/open-props (MIT)
   Structure: <header class="wc-header"><div class="wc-header-inner">…</div></header>
   JS toggles .is-scrolled on the header after ~24px of scroll; the inner
   bar contracts into a floating, hairline-bordered pill (per Figma's
   Review / Header / Scrolled specimen).
   ========================================================================== */
.wc-header {
  position: sticky;
  top: 0;
  z-index: 50;
}
.wc-header-inner {
  border: 1px solid transparent;
  border-radius: 0;
  transition:
    margin var(--wc-dur-2) var(--wc-ease),
    border-radius var(--wc-dur-2) var(--wc-ease),
    background-color var(--wc-dur-2) var(--wc-ease),
    border-color var(--wc-dur-2) var(--wc-ease),
    box-shadow var(--wc-dur-2) var(--wc-ease);
}
.wc-header.is-scrolled .wc-header-inner {
  margin-top: 10px;
  border-radius: 20px;
  background: var(--wc-background);
  border-color: var(--wc-border);
  box-shadow: var(--wc-shadow-pill);
}

/* ==========================================================================
   5. Hairline card hover — border discipline of primer/css (MIT),
      card patterns in markmead/hyperui (MIT)
   1px hairline at rest; on hover-capable pointers the card lifts 2px and
   the border takes a restrained mix of the action colour. No heavy shadow.
   Usage: add .wc-card to business / category / article cards.
   ========================================================================== */
.wc-card {
  border: 1px solid var(--wc-border);
  background: var(--wc-background);
  transition:
    transform var(--wc-dur-2) var(--wc-ease-out),
    border-color var(--wc-dur-2) var(--wc-ease),
    box-shadow var(--wc-dur-2) var(--wc-ease);
}
@media (hover: hover) and (pointer: fine) {
  .wc-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--wc-action) 45%, var(--wc-border));
    box-shadow: var(--wc-shadow-card);
  }
}
/* Whole-card links keep the token focus ring. */
a.wc-card:focus-visible,
.wc-card a:focus-visible {
  outline: 2px solid var(--wc-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   6. Form focus-within detail — form controls in shoelace-style/shoelace
      (MIT) and markmead/hyperui (MIT)
   Layout stays exactly as the Figma Field components (label above input);
   only the *state rendering* is enriched: the label tints to the action
   colour and the field border eases to the action colour while the field
   group has focus. Global :focus-visible ring (tokens) is untouched.
   Usage: <div class="wc-field"><label …>…</label><input …></div>
   ========================================================================== */
.wc-field label {
  transition: color var(--wc-dur-1) var(--wc-ease);
}
.wc-field:focus-within label {
  color: var(--wc-action);
}
.wc-field input,
.wc-field select,
.wc-field textarea {
  transition:
    border-color var(--wc-dur-1) var(--wc-ease),
    box-shadow var(--wc-dur-1) var(--wc-ease);
}
.wc-field:focus-within input,
.wc-field:focus-within select,
.wc-field:focus-within textarea {
  border-color: var(--wc-action);
  box-shadow: inset 0 -2px 0 0 var(--wc-action);
}
.wc-field input:focus,
.wc-field select:focus,
.wc-field textarea:focus {
  outline: none; /* the :focus-visible ring below carries keyboard focus */
}
.wc-field input:focus-visible,
.wc-field select:focus-visible,
.wc-field textarea:focus-visible {
  outline: 2px solid var(--wc-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   Reduced motion — every absorbed pattern degrades to its static end state.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  [data-reveal].wc-armed {
    opacity: 1;
    transform: none;
  }
  [data-reveal].wc-armed.wc-in {
    transition: none;
  }
  .wc-btn-sweep::before,
  .wc-link-arrow,
  .wc-link-arrow .wc-arrow,
  .wc-header-inner,
  .wc-card,
  .wc-field label,
  .wc-field input,
  .wc-field select,
  .wc-field textarea {
    transition: none;
  }
  .wc-card:hover {
    transform: none;
  }
}

/* Print: reveal end state is always visible. */
@media print {
  [data-reveal].wc-armed {
    opacity: 1;
    transform: none;
  }
}
