/*!
 * Estec CTA - Frontend CSS
 * すべてのクラスに ec- プレフィックス。SWELL/他テーマと非衝突。
 */

:root {
    --ec-brand: #0E5BA8;
    --ec-accent: #FF8A00;
    --ec-text: #1F2937;
    --ec-radius: 14px;
    --ec-shadow: 0 8px 24px rgba(15, 23, 42, .18);
    --ec-shadow-sm: 0 2px 8px rgba(15, 23, 42, .12);
    --ec-z: 9999;
    --ec-easing: cubic-bezier(.34, 1.56, .64, 1);
}

/* ============================================================
 * Floating Trigger
 * ============================================================ */
.ec-floating {
    position: fixed;
    z-index: var(--ec-z);
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}
.ec-floating[hidden] {
    display: none !important;
}
.ec-pos-bottom-right { right: 18px; bottom: 18px; }
.ec-pos-bottom-left  { left: 18px;  bottom: 18px; }
.ec-pos-middle-right { right: 18px; top: 50%; transform: translateY(-50%); }
.ec-pos-middle-left  { left: 18px;  top: 50%; transform: translateY(-50%); }

.ec-floating > * {
    pointer-events: auto;
}

/* WP admin bar offset */
body.admin-bar .ec-pos-bottom-right,
body.admin-bar .ec-pos-bottom-left {
    /* Don't push up - let the JS handle hide_on_admin_bar */
}

.ec-floating-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    background: var(--ec-brand);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ec-shadow);
    transition: transform .3s var(--ec-easing), background .25s ease;
    position: relative;
    padding: 0;
}
.ec-floating-trigger:hover {
    transform: scale(1.08);
    background: var(--ec-accent);
}
.ec-floating-trigger:focus-visible {
    outline: 3px solid var(--ec-accent);
    outline-offset: 4px;
}
.ec-floating-trigger-icon {
    display: flex;
    width: 28px;
    height: 28px;
    transition: transform .3s var(--ec-easing), opacity .2s ease;
}
.ec-floating-trigger-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}
.ec-floating-trigger-label {
    display: none;
}

.ec-floating[aria-expanded="true"] .ec-floating-trigger-icon {
    transform: rotate(135deg);
    opacity: .85;
}

/* Pulse animation when idle */
.ec-floating-trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 var(--ec-brand);
    animation: ec-pulse 2.4s infinite ease-out;
}
@keyframes ec-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(14, 91, 168, .55); }
    70%  { box-shadow: 0 0 0 18px rgba(14, 91, 168, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 91, 168, 0); }
}
.ec-floating[aria-expanded="true"] .ec-floating-trigger::before {
    animation: none;
}

/* Tooltip bubble */
.ec-tooltip {
    position: absolute;
    background: #1F2937;
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: var(--ec-shadow-sm);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: none;
}
.ec-pos-bottom-right .ec-tooltip,
.ec-pos-middle-right .ec-tooltip {
    right: 78px;
    bottom: 50%;
    transform: translate(8px, 50%);
}
.ec-pos-bottom-left .ec-tooltip,
.ec-pos-middle-left .ec-tooltip {
    left: 78px;
    bottom: 50%;
    transform: translate(-8px, 50%);
}
.ec-floating[data-tooltip-shown="1"] .ec-tooltip {
    opacity: 1;
    transform: translate(0, 50%);
}
.ec-floating[aria-expanded="true"] .ec-tooltip {
    opacity: 0 !important;
}
.ec-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    transform: translateY(-50%);
}
.ec-pos-bottom-right .ec-tooltip::after,
.ec-pos-middle-right .ec-tooltip::after {
    right: -12px;
    border-left-color: #1F2937;
}
.ec-pos-bottom-left .ec-tooltip::after,
.ec-pos-middle-left .ec-tooltip::after {
    left: -12px;
    border-right-color: #1F2937;
}

/* Items expansion */
.ec-floating-items {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transform: scale(.6) translateY(20px);
    transform-origin: bottom right;
    transition: opacity .25s ease, transform .3s var(--ec-easing);
    pointer-events: none;
}
.ec-pos-bottom-right .ec-floating-items { right: 0; bottom: 76px; }
.ec-pos-bottom-left  .ec-floating-items { left: 0; bottom: 76px; transform-origin: bottom left; }
.ec-pos-middle-right .ec-floating-items { right: 0; bottom: 76px; }
.ec-pos-middle-left  .ec-floating-items { left: 0; bottom: 76px; transform-origin: bottom left; }

.ec-dir-left .ec-floating-items {
    flex-direction: row-reverse;
    bottom: 0 !important;
    right: 76px !important;
    align-items: center;
    transform-origin: right center;
}
.ec-pos-bottom-left.ec-dir-left .ec-floating-items,
.ec-pos-middle-left.ec-dir-left .ec-floating-items {
    flex-direction: row;
    right: auto !important;
    left: 76px !important;
    transform-origin: left center;
}

.ec-floating[aria-expanded="true"] .ec-floating-items {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.ec-floating-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--ec-btn, var(--ec-brand));
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--ec-shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
    white-space: nowrap;
    border: 0;
    line-height: 1.2;
}
.ec-floating-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--ec-shadow);
    color: #fff !important;
}
.ec-floating-item-icon {
    display: flex;
    width: 22px;
    height: 22px;
}
.ec-floating-item-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}
.ec-floating-item-label {
    color: #fff;
}

/* Radial expansion */
.ec-dir-radial .ec-floating-items {
    display: block;
    width: 0;
    height: 0;
}
.ec-dir-radial .ec-floating-item {
    position: absolute;
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
}
.ec-dir-radial .ec-floating-item-label {
    display: none;
}
.ec-dir-radial.ec-pos-bottom-right .ec-floating-items,
.ec-dir-radial.ec-pos-middle-right .ec-floating-items {
    right: 5px; bottom: 5px;
}
.ec-dir-radial.ec-pos-bottom-left .ec-floating-items,
.ec-dir-radial.ec-pos-middle-left .ec-floating-items {
    left: 5px; bottom: 5px;
}
/* Radial position calculated by JS via CSS variables */
.ec-dir-radial .ec-floating-item {
    --ec-radial-x: 0;
    --ec-radial-y: 0;
    transform: translate(0, 0) scale(0);
}
.ec-floating[aria-expanded="true"].ec-dir-radial .ec-floating-item {
    transform: translate(var(--ec-radial-x), var(--ec-radial-y)) scale(1);
}

/* ============================================================
 * Button group (sidebar widget + shortcode output)
 * ============================================================ */
.ec-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-family: inherit;
}
.ec-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--ec-btn, var(--ec-brand));
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--ec-shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
    line-height: 1.2;
    border: 0;
}
.ec-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--ec-shadow);
    color: #fff !important;
}
.ec-button-icon {
    display: flex;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.ec-button-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* Layouts */
.ec-layout-card {
    flex-direction: column;
    align-items: stretch;
}
.ec-layout-card .ec-button {
    justify-content: flex-start;
    width: 100%;
    padding: 14px 18px;
}

.ec-layout-list {
    flex-direction: column;
    gap: 6px;
}
.ec-layout-list .ec-button {
    justify-content: flex-start;
    width: 100%;
    border-radius: 8px;
    background: transparent;
    color: var(--ec-btn, var(--ec-brand)) !important;
    box-shadow: none;
    border: 1px solid currentColor;
    padding: 10px 14px;
}
.ec-layout-list .ec-button:hover {
    background: var(--ec-btn, var(--ec-brand));
    color: #fff !important;
}

.ec-layout-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.ec-layout-grid .ec-button {
    flex-direction: column;
    text-align: center;
    padding: 16px 10px;
    font-size: 13px;
}
.ec-layout-grid .ec-button-icon {
    width: 28px;
    height: 28px;
}

.ec-layout-icons {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}
.ec-layout-icons .ec-button {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
}
.ec-layout-icons .ec-button-label,
.ec-no-label .ec-button-label {
    display: none;
}

/* SWELL widget block compatibility */
.estec_cta_widget {
    /* SWELL applies its own widget styles; we override only the inner buttons */
}
.estec_cta_widget .ec-buttons {
    margin-top: 8px;
}

/* Print: hide CTA */
@media print {
    .ec-floating, .estec_cta_widget { display: none !important; }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .ec-floating-trigger {
        width: 52px;
        height: 52px;
    }
    .ec-floating-trigger-icon {
        width: 24px;
        height: 24px;
    }
    .ec-pos-bottom-right { right: 14px; bottom: 14px; }
    .ec-pos-bottom-left  { left: 14px; bottom: 14px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ec-floating-trigger::before { animation: none; }
    .ec-floating-trigger,
    .ec-floating-item,
    .ec-button,
    .ec-floating-items { transition: none; }
}
