/**
 * HA Recruit Banner — fixed banner image at the top-right
 *
 * Sits just below the theme's fixed header, at the right edge, small enough
 * not to cover the body text or the call/entry buttons. The photo (made in
 * ChatGPT, no text) fills the card; the headline is HTML text laid over it on
 * a dark gradient. Positions are CSS variables so a theme can override them:
 *   :root {
 *     --ha-recruit-banner-top: 72px;       (phone)
 *     --ha-recruit-banner-bottom-pc: calc(50vh - 94px); (768px and wider; the
 *       card's bottom edge, kept just above the theme's fixed ENTRY tab)
 *     --ha-recruit-banner-width: 150px;    (phone)
 *     --ha-recruit-banner-width-pc: 240px; (768px and wider)
 *   }
 *
 * @package HA_WP_Plugin
 * @since   0.34.0
 */

/* Closed: by the checkbox (no script) or remembered for N days. */
body:has(#ha-recruit-banner-dismiss:checked) #ha-recruit-banner,
html.ha-recruit-banner-dismissed #ha-recruit-banner {
    display: none;
}

#ha-recruit-banner {
    position: fixed;
    top: calc(var(--ha-recruit-banner-top, 68px) + var(--ha-pickup-bar-height, 0px));
    right: 8px;
    z-index: 9998;
    width: var(--ha-recruit-banner-width, 150px);
}

/* Fades out after auto_hide_seconds (not remembered like the close button):
   the timer ring empties for that long, then a soft gradient edge sweeps
   across the card from left to right and wipes it away. The mask is three times
   the card's width: opaque on the right, transparent on the left,
   with a 30% ramp between them. */
#ha-recruit-banner.ha-recruit-banner--autohide {
    -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000 65%);
    mask-image: linear-gradient(90deg, transparent 35%, #000 65%);
    -webkit-mask-size: 300% 100%;
    mask-size: 300% 100%;
    -webkit-mask-position: 100% 0;
    mask-position: 100% 0;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    animation: ha-recruit-banner-autohide 1.2s ease-in-out var(--ha-recruit-banner-autohide, 8s) forwards;
}

@keyframes ha-recruit-banner-autohide {
    100% {
        -webkit-mask-position: 0 0;
        mask-position: 0 0;
        visibility: hidden;
    }
}

#ha-recruit-banner .ha-recruit-banner__timer {
    position: absolute;
    top: auto;
    left: auto;
    max-width: none;
    right: 6px;
    bottom: 6px;
    z-index: 1;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 105, 159, 0.35); /* the photo's right side is bright */
    transform: rotate(-90deg); /* start at 12 o'clock, empty clockwise */
}

.ha-recruit-banner__timer circle {
    fill: none;
    stroke-width: 2.5;
}

.ha-recruit-banner__timer-track {
    stroke: rgba(255, 255, 255, 0.2);
}

.ha-recruit-banner__timer-ring {
    stroke: rgba(255, 255, 255, 0.6);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
    animation: ha-recruit-banner-timer linear var(--ha-recruit-banner-autohide, 8s) forwards;
}

/* Full at first; the gap opens at 12 o'clock and grows clockwise. */
@keyframes ha-recruit-banner-timer {
    to {
        stroke-dashoffset: -100;
    }
}

@media (min-width: 768px) {
    /* PC: flush with the right edge, a little above the middle of the screen
       (the hero's top-right holds the building sign) and just above the
       theme's fixed ENTRY tab, which is centered on the right edge. */
    #ha-recruit-banner {
        top: var(--ha-recruit-banner-bottom-pc, calc(50vh - 94px));
        right: 0;
        width: var(--ha-recruit-banner-width-pc, 240px);
        transform: translateY(-100%);
    }

    #ha-recruit-banner .ha-recruit-banner__link {
        border-radius: 10px 0 0 10px;
    }

    #ha-recruit-banner .ha-recruit-banner__close {
        top: 6px;
        right: 6px;
    }
}

/* Visually hidden but focusable checkbox (Space toggles it). */
.ha-recruit-banner__toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ha-recruit-banner__link {
    position: relative;
    display: block;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    border-radius: 10px;
    /* 影（box-shadow）は付けない: PDF にすると macOS のプレビューでカードの周りに黒い四角として描かれる */
    color: #fff;
    text-decoration: none;
}

.ha-recruit-banner__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: right center;
}

/* Darkens the left side so the white text reads on any part of the photo. */
.ha-recruit-banner__link::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0, 105, 159, 0.72) 0%, rgba(0, 105, 159, 0.3) 60%, rgba(0, 105, 159, 0) 100%);
}

.ha-recruit-banner__text {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 8px 12px;
    box-sizing: border-box;
    line-height: 1.35;
    text-align: left;
    /* text-shadow はぼかしが文字の塊ごとの矩形で描かれ、黒い箱が出る（Chrome・Zen Maru Gothic）。影は層全体に drop-shadow で掛ける */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

/* A space in the headline is the only place it breaks (keep-all), so the
   facility decides the line break: "HPから直接ご応募で 入社祝い金30万円". */
#ha-recruit-banner .ha-recruit-banner__headline {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    word-break: keep-all;
    overflow-wrap: normal;
}

#ha-recruit-banner .ha-recruit-banner__note {
    margin-top: 4px;
    font-size: 10.5px;
    letter-spacing: 0;
}

.ha-recruit-banner__link:hover,
.ha-recruit-banner__link:focus {
    color: #fff;
    text-decoration: none;
}

a.ha-recruit-banner__link:hover .ha-recruit-banner__image,
a.ha-recruit-banner__link:focus .ha-recruit-banner__image {
    transform: scale(1.03);
}

@media (min-width: 768px) {
    .ha-recruit-banner__text {
        padding: 12px 16px;
    }

    #ha-recruit-banner .ha-recruit-banner__headline {
        font-size: 18px;
    }

    #ha-recruit-banner .ha-recruit-banner__note {
        font-size: 12px;
    }
}

/* Close button: a 24px dark circle overlapping the card's top-right corner.
   The × is drawn with two bars (not the &times; glyph, whose position in the
   circle shifts with the font) so it sits exactly at the center. */
.ha-recruit-banner__close {
    position: absolute;
    top: -8px;
    right: -6px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.65);
    font-size: 0;
    line-height: 0;
    cursor: pointer;
}

.ha-recruit-banner__close::before,
.ha-recruit-banner__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 2px;
    border-radius: 1px;
    background-color: #fff;
}

.ha-recruit-banner__close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.ha-recruit-banner__close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.ha-recruit-banner__close:hover,
.ha-recruit-banner__toggle:focus-visible ~ .ha-recruit-banner__close {
    background-color: rgba(0, 0, 0, 0.85);
}

.ha-recruit-banner__toggle:focus-visible ~ .ha-recruit-banner__close {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

/* WP admin bar: shift below it when logged in. */
body.admin-bar #ha-recruit-banner {
    margin-top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar #ha-recruit-banner {
        margin-top: 46px;
    }
}

/* ---------------------------------------------------------------
 * Inline banner (the page the floating banner links to): a wide strip
 * printed where the theme calls do_action( 'ha_recruit_banner_inline' ).
 * Not a link and no close button.
 * ------------------------------------------------------------- */
.ha-recruit-banner-inline {
    position: relative;
    display: block;
    width: min(100% - 32px, 1000px);
    height: 120px;
    margin: 32px auto 0;
    overflow: hidden;
    border-radius: 12px;
    color: #fff;
}

/* Element + class beats the theme rules on page images (they set width:auto). */
.ha-recruit-banner-inline img.ha-recruit-banner-inline__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-width: none;
    object-position: 75% 55%;
}

.ha-recruit-banner-inline::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0, 105, 159, 0.72) 0%, rgba(0, 105, 159, 0.3) 60%, rgba(0, 105, 159, 0) 100%);
}

.ha-recruit-banner-inline__text {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 0 20px;
    box-sizing: border-box;
    line-height: 1.4;
    text-align: left;
    /* text-shadow はぼかしが文字の塊ごとの矩形で描かれ、黒い箱が出る（Chrome・Zen Maru Gothic）。影は層全体に drop-shadow で掛ける */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.ha-recruit-banner-inline .ha-recruit-banner-inline__headline {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
    word-break: keep-all;
    overflow-wrap: normal;
}

.ha-recruit-banner-inline .ha-recruit-banner-inline__note {
    margin-top: 4px;
    font-size: 12px;
    letter-spacing: 0;
}

@media (min-width: 768px) {
    .ha-recruit-banner-inline {
        height: 160px;
        margin-top: 48px;
    }

    .ha-recruit-banner-inline__text {
        padding: 0 48px;
    }

    .ha-recruit-banner-inline .ha-recruit-banner-inline__headline {
        font-size: 30px;
    }
}
