/**
 * Player CSS for Auto Salesman 247
 * Full-screen, responsive presentation player.
 */

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a0a0f;
    color: #e0e0e0;
}

/* ===== Player Container ===== */
.as247-player-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ===== Start Screen ===== */
.as247-start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0f0f19;
    z-index: 100;
    animation: as247-fadeIn 0.5s ease;
    overflow: hidden;
}

.as247-start-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.as247-start-bg-blur {
    filter: blur(8px);
    transform: scale(1.1);
}

.as247-start-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.as247-start-title {
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0 2rem;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.as247-start-desc {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 0 2rem;
    max-width: 700px;
    line-height: 1.8;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.as247-start-desc p {
    margin-bottom: 1rem;
}

.as247-start-desc p:last-child {
    margin-bottom: 0;
}

.as247-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.as247-start-btn:hover {
    transform: translateY(-2px);
}

.as247-start-btn:active {
    transform: translateY(0);
}

.as247-start-btn .as247-play-icon {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #fff;
}

/* ===== Password Screen ===== */
.as247-password-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    z-index: 100;
    animation: as247-fadeIn 0.5s ease;
}

.as247-password-box {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 2.5rem;
    width: min(90%, 400px);
    text-align: center;
}

.as247-password-box h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 1.5rem;
}

.as247-password-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    color: #fff;
    outline: none;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.as247-password-input:focus {
    border-color: #667eea;
}

.as247-password-submit {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.as247-password-submit:hover {
    transform: translateY(-1px);
}

.as247-password-error {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 1rem;
    display: none;
}

.as247-password-error.visible {
    display: block;
    animation: as247-shake 0.3s ease;
}

/* ===== Slide Area ===== */
.as247-slide-area {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
    min-height: 0;
}

.as247-slide-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.as247-slide-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.4s ease;
}

.as247-slide-image.loading {
    opacity: 0;
}

/* ===== Overlay Container (branches + CTA on image) ===== */
.as247-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 24px 24px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7) 40%);
    pointer-events: none;
}

.as247-overlay>* {
    pointer-events: auto;
}

/* ===== Branch Buttons ===== */
.as247-branches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    animation: as247-slideUp 0.4s ease;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.as247-branches.layout-many {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
}

.as247-branches.layout-many .as247-branch-btn {
    font-size: clamp(0.65rem, 2.2vw, 0.85rem);
    padding: 6px 10px;
    min-width: 0;
}

.as247-branch-btn {
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
    max-width: 450px;
    padding: 10px 16px;
    font-size: clamp(0.75rem, 2.5vw, 1rem);
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.as247-branch-btn:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 3px;
}

/* Primary */
.as247-branch-btn.style-primary {
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.as247-branch-btn.style-primary:hover {
    transform: translateY(-2px);
}

/* Secondary */
.as247-branch-btn.style-secondary {
    color: #fff;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.as247-branch-btn.style-secondary:hover {
    transform: translateY(-2px);
}

/* Outline */
.as247-branch-btn.style-outline {
    color: #fff;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.7);
}

.as247-branch-btn.style-outline:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    transform: translateY(-2px);
}

.as247-branch-btn.custom-color {
    background-image: none !important;
    /* Remove gradient if custom color is specified */
    border-color: transparent !important;
}

.as247-branch-btn.custom-color[style*="color:"] {
    color: inherit;
    /* Handled via inline style */
}

/* ===== CTA Button ===== */
.as247-cta-btn {
    display: inline-block;
    padding: 10px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.as247-cta-btn:hover {
    transform: translateY(-2px);
    color: #fff;
}

/* Ending CTA — larger */
.as247-cta-btn.ending-cta {
    padding: 16px 48px;
    font-size: 1.2rem;
    animation: as247-pulse 2s ease-in-out infinite;
}

/* ===== Subtitle Area ===== */
.as247-subtitle-area {
    background: rgba(15, 15, 25, 0.95);
    padding: 10px 20px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.as247-subtitle-area.hidden {
    display: none !important;
}

.as247-subtitle-text {
    font-size: 1rem;
    line-height: 1.7;
    color: #c0c0c0;
    text-align: center;
    max-width: 800px;
}

.as247-subtitle-text .highlight {
    color: #fff;
    background: rgba(102, 126, 234, 0.3);
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

/* ===== Control Bar ===== */
.as247-control-bar {
    background: linear-gradient(180deg, rgba(20, 20, 35, 0.98) 0%, rgba(10, 10, 20, 1) 100%);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
}

.as247-ctrl-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #c0c0c0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.as247-ctrl-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.as247-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.as247-ctrl-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.as247-ctrl-btn.active {
    background: rgba(102, 126, 234, 0.25);
    color: #667eea;
    border-color: rgba(102, 126, 234, 0.4);
}

/* Speed buttons group */
.as247-speed-group {
    display: flex;
    gap: 2px;
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 2px;
}

.as247-speed-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #888;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
    height: auto;
    width: auto;
}

.as247-speed-btn:hover {
    color: #ccc;
    background: rgba(255, 255, 255, 0.08);
}

.as247-speed-btn.active {
    color: #fff;
    background: rgba(102, 126, 234, 0.35);
    font-weight: 700;
}

/* Slide counter */
.as247-slide-counter {
    font-size: 0.85rem;
    color: #888;
    margin-left: 12px;
    font-variant-numeric: tabular-nums;
}

/* ===== Progress bar ===== */
.as247-progress-wrapper {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    order: 10;
}

.as247-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0;
}

/* End-of-slide Restart button */
.as247-restart-btn {
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.as247-restart-btn:hover {
    transform: translateY(-2px);
}

/* ===== Ending Screen ===== */
.as247-ending-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10;
    gap: 24px;
    animation: as247-fadeIn 0.5s ease;
}

.as247-ending-message {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 700;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ===== No Slides ===== */
.as247-no-slides {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 1.2rem;
    color: #888;
}

/* ===== Animations ===== */
@keyframes as247-fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes as247-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes as247-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

@keyframes as247-pulse {

    0%,
    100% {
        box-shadow: 0 4px 16px rgba(245, 87, 108, 0.4);
    }

    50% {
        box-shadow: 0 6px 32px rgba(245, 87, 108, 0.7);
    }
}

/* ===== Responsive (< 768px) ===== */
@media (max-width: 768px) {
    .as247-branches {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
        width: 100%;
        padding: 0 10px;
    }

    /* If only 1 or small screen, stick to 1 col if needed, but auto-fit is better */
    .as247-branch-btn {
        width: 100%;
        min-width: 0;
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .as247-subtitle-text {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .as247-subtitle-area {
        padding: 6px 12px;
        min-height: 40px;
    }

    .as247-control-bar {
        padding: 6px 10px;
        gap: 4px;
    }

    .as247-ctrl-btn {
        width: 40px;
        height: 40px;
    }

    .as247-speed-group {
        margin-top: 4px;
        width: 100%;
        justify-content: space-between;
    }

    .as247-speed-btn {
        flex: 1;
        padding: 4px;
        font-size: 0.7rem;
    }

    .as247-overlay {
        padding: 12px;
        max-height: 50%;
        justify-content: flex-end;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .as247-subtitle-area {
        position: absolute;
        bottom: 44px;
        /* Height of control bar */
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        border-top: none;
        pointer-events: none;
        min-height: 0;
        padding: 4px 10px;
        z-index: 5;
    }

    .as247-subtitle-text {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .as247-control-bar {
        padding: 4px 8px;
        height: 44px;
        flex-wrap: nowrap;
    }

    .as247-ctrl-btn {
        width: 32px;
        height: 32px;
        border-radius: 6px;
        padding: 4px;
    }

    .as247-ctrl-btn svg {
        width: 16px;
        height: 16px;
    }

    .as247-overlay {
        padding: 6px;
        max-height: calc(100% - 60px);
        /* Leave room for subtitle/ctrl */
        flex-direction: row;
        align-items: flex-end;
        justify-content: center;
        background: transparent;
        bottom: 50px;
        /* Default low position when subtitles are hidden */
        transition: bottom 0.3s ease;
    }

    .as247-player-container.as247-subtitles-visible .as247-overlay {
        bottom: 90px;
        /* High position when subtitles are visible */
    }

    .as247-branches {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 6px;
        width: auto;
        max-width: 100%;
    }

    .as247-branch-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
        min-width: 0;
    }

    .as247-speed-group {
        display: none;
        /* Hide speed group in tight landscape to save space */
    }

    .as247-slide-counter {
        display: none;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}