/* ==================================================================
 * Buttons and the back-to-top control (W-15)
 *
 * This sheet is enqueued last on purpose. The button colours have to beat
 * rules spread across main.css, proposal-c.css, proposal-c-page.css and
 * proposal-c-nav.css, several of which are compound selectors of the same
 * specificity — so the only reliable way to have one answer for "what
 * colour is a button" is to answer it after everyone else has spoken.
 *
 * Two families, one behaviour:
 *   - primary actions are amber
 *   - secondary and list controls are blue
 * Both rest at a pale tint and fill to full strength from left to right
 * under the cursor, so a hover is a change of state you can see across the
 * page rather than a shade. The lettering is ink in every state, so the
 * label never loses contrast partway through the sweep.
 * ================================================================== */

/* --- family tokens ------------------------------------------------ */

/*
 * Primary: the amber action buttons.
 *
 * The face carries most of the accent rather than a hint of it, so a button
 * reads as yellow before the cursor arrives. The border moves with it: at
 * the old 38% it would now be no darker than the face and the button would
 * lose its outline.
 */
.c-cta,
.c-menu-cta,
.p-cta,
.p-header__cta {
  --btn-face: color-mix(in srgb, var(--color-accent) 80%, var(--color-base));
  --btn-line: color-mix(in srgb, var(--color-accent-line) 80%, var(--color-base));
  --btn-fill: var(--color-accent);
  --btn-fill-line: var(--color-accent-line);
}

/*
 * Secondary: details links, the NEWS filter and pagination. Declared after
 * the primary block so `.c-cta--details`, which also matches `.c-cta`
 * above, lands in this family.
 */
.c-cta--details,
.news-filter :is(a, button),
.pagination .page-numbers,
.secondary-cta {
  --btn-face: color-mix(in srgb, var(--color-brand) 14%, var(--color-base));
  --btn-line: color-mix(in srgb, var(--color-brand) 42%, var(--color-base));
  --btn-fill: var(--color-brand);
  --btn-fill-line: var(--color-brand-deep);
}

/* --- resting face -------------------------------------------------- */

.c-cta,
.c-information .c-cta,
.c-entry .c-cta,
.c-information .c-cta--details,
.c-schedule .c-cta--details,
.c-menu-cta,
.c-mobile-menu .c-menu-cta,
.c-mobile-menu__foot .c-menu-cta,
.c-footer__cta .c-menu-cta,
.c-rail nav .c-menu-cta,
.c-rail__foot .c-menu-cta,
.p-cta,
.p-entry-cta .p-cta,
.p-header__cta,
.news-filter :is(a, button),
.pagination .page-numbers:not(.dots),
.secondary-cta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: var(--color-ink);
  background: var(--btn-face);
  border: 1px solid var(--btn-line);
  transition: transform 180ms ease-out, box-shadow 180ms ease-out, border-color 260ms ease-out;
}

/*
 * The quieter actions — 入力に戻る, 本文をコピー, 条件を消す — were the one
 * kind of button the palette never reached: white with a square 2px ink
 * outline while everything around them was rounded and tinted. They belong
 * to the blue family, which is where undo-shaped actions sit.
 */
.secondary-cta {
  border-radius: 999px;
}

/* --- the fill, running left to right ------------------------------- */

.c-cta::after,
.c-menu-cta::after,
.p-cta::after,
.p-header__cta::after,
.news-filter :is(a, button)::after,
.pagination .page-numbers:not(.dots)::after,
.secondary-cta::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: var(--btn-fill);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}

.c-cta:hover::after, .c-cta:focus-visible::after, .c-cta:active::after,
.c-menu-cta:hover::after, .c-menu-cta:focus-visible::after, .c-menu-cta:active::after,
.p-cta:hover::after, .p-cta:focus-visible::after, .p-cta:active::after,
.p-header__cta:hover::after, .p-header__cta:focus-visible::after, .p-header__cta:active::after,
.news-filter :is(a, button):hover::after,
.news-filter :is(a, button):focus-visible::after,
.news-filter :is(a, button):active::after,
.pagination .page-numbers:not(.dots):hover::after,
.pagination .page-numbers:not(.dots):focus-visible::after,
.pagination .page-numbers:not(.dots):active::after,
.secondary-cta:hover::after,
.secondary-cta:focus-visible::after,
.secondary-cta:active::after {
  transform: scaleX(1);
}

/* The border catches up with the fill rather than staying at the tint. */
.c-cta:hover, .c-cta:focus-visible,
.c-information .c-cta:hover, .c-information .c-cta:focus-visible,
.c-entry .c-cta:hover, .c-entry .c-cta:focus-visible,
.c-information .c-cta--details:hover, .c-information .c-cta--details:focus-visible,
.c-schedule .c-cta--details:hover, .c-schedule .c-cta--details:focus-visible,
.c-menu-cta:hover, .c-menu-cta:focus-visible,
.c-mobile-menu .c-menu-cta:hover, .c-mobile-menu .c-menu-cta:focus-visible,
.c-rail nav .c-menu-cta:hover, .c-rail nav .c-menu-cta:focus-visible,
.p-cta:hover, .p-cta:focus-visible,
.p-entry-cta .p-cta:hover, .p-entry-cta .p-cta:focus-visible,
.p-header__cta:hover, .p-header__cta:focus-visible,
.news-filter :is(a, button):hover, .news-filter :is(a, button):focus-visible,
.pagination .page-numbers:not(.dots):hover,
.pagination .page-numbers:not(.dots):focus-visible,
.secondary-cta:hover,
.secondary-cta:focus-visible {
  color: var(--color-ink);
  border-color: var(--btn-fill-line);
}

@media (prefers-reduced-motion: reduce) {
  .c-cta::after,
  .c-menu-cta::after,
  .p-cta::after,
  .p-header__cta::after,
  .news-filter :is(a, button)::after,
  .pagination .page-numbers:not(.dots)::after,
  .secondary-cta::after {
    transition: none;
  }
}

/*
 * The item you are already on keeps its dark face: it is a state, not an
 * offer. Running the light fill across it would put its white lettering on
 * a mid-blue ground, so that one is left out of the sweep and answers the
 * cursor with its border instead.
 */
.news-filter :is(a[aria-current="page"], button[aria-pressed="true"])::after,
.pagination .page-numbers.current::after {
  content: none;
}

.news-filter :is(a[aria-current="page"], button[aria-pressed="true"]):hover,
.news-filter :is(a[aria-current="page"], button[aria-pressed="true"]):focus-visible,
.pagination .page-numbers.current:hover,
.pagination .page-numbers.current:focus-visible {
  border-color: var(--color-accent);
}

/* --- hamburger ------------------------------------------------------
 * The compact header sits on the ink ground with white lettering, so the
 * old near-white hover wash left white text on a white button. It takes
 * the amber fill instead, and turns its lettering to ink to match.
 * ------------------------------------------------------------------ */

.c-header .c-menu-button:hover,
.c-header .c-menu-button:focus-visible,
.c-header .c-menu-button[aria-expanded="true"] {
  color: var(--color-ink);
  background: var(--color-accent);
  border-color: var(--color-accent-line);
}

.c-header .c-menu-button:hover .c-menu-button__label,
.c-header .c-menu-button:focus-visible .c-menu-button__label,
.c-header .c-menu-button[aria-expanded="true"] .c-menu-button__label {
  color: var(--color-ink);
}

/* --- back to top ----------------------------------------------------
 * Fixed to the bottom-right corner on every page, revealed once there is
 * something to scroll back over. It is a real button, not a link, so it
 * never lands in the page's tab order as a destination.
 * ------------------------------------------------------------------ */

.c-to-top {
  position: fixed;
  z-index: 40;
  inset-block-end: clamp(.75rem, 3vw, 1.5rem);
  inset-inline-end: clamp(.75rem, 3vw, 1.5rem);
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  overflow: hidden;
  color: var(--color-ink);
  background: color-mix(in srgb, var(--color-brand) 14%, var(--color-base));
  border: 1px solid color-mix(in srgb, var(--color-brand) 42%, var(--color-base));
  border-radius: 999px;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--color-ink) 14%, transparent),
              0 8px 20px color-mix(in srgb, var(--color-ink) 12%, transparent);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  isolation: isolate;
  opacity: 0;
  visibility: hidden;
  transform: translateY(.5rem);
  transition: opacity 240ms ease-out, transform 240ms ease-out,
              visibility 0s linear 240ms, border-color 260ms ease-out;
}

.c-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 240ms ease-out, transform 240ms ease-out,
              visibility 0s linear 0s, border-color 260ms ease-out;
}

.c-to-top::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: var(--color-brand);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}

.c-to-top:hover::after,
.c-to-top:focus-visible::after,
.c-to-top:active::after {
  transform: scaleX(1);
}

.c-to-top:hover,
.c-to-top:focus-visible {
  border-color: var(--color-brand-deep);
}

/*
 * On the TOP grid the right 200px belong to the rail, and the rail keeps
 * its own apply button at the bottom. Step the control inside the centre
 * column so the two never sit on top of each other.
 */
@media (min-width: 68.75rem) {
  .shell-c--top ~ .c-to-top,
  .shell-c--top .c-to-top {
    inset-inline-end: calc(200px + clamp(.75rem, 3vw, 1.5rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .c-to-top {
    transform: none;
    transition: opacity 240ms ease-out, visibility 0s linear 240ms;
  }

  .c-to-top.is-visible {
    transform: none;
    transition: opacity 240ms ease-out, visibility 0s linear 0s;
  }

  .c-to-top::after {
    transition: none;
  }
}
