/*
 * guidestar-controls.css
 *
 * Styles that must live in the main document (outside Shadow DOM)
 * because they target elements inside the consumer's HTML.
 *
 * The play/pause/restart button styles are inside the Shadow DOM
 * (see guidestar-controller.js) and are themeable via CSS
 * custom properties — see README for the full list.
 */

/* ── Container base ──────────────────────────────────────────────── */

[data-guidestar] {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* ── Content root ────────────────────────────────────────────────── */

/*
 * .gs-content holds the injected wireframe HTML.
 * transform-origin is set here so viewport-scale mode (transform: scale())
 * always anchors to the top-left corner of the container.
 */

.gs-content {
    transform-origin: top left;
}

/* ── Fullscreen button ───────────────────────────────────────────── */

/*
 * .gs-fullscreen-host wraps the fullscreen toggle button in the
 * top-right corner of the container.  It is a plain DOM element
 * (not Shadow DOM) so it inherits the same --gs-control-* custom
 * properties used by the play/pause controls.
 *
 * Visibility: hidden by default; revealed on container hover or when
 * the demo is paused (JS adds .gs-fullscreen-host--visible).
 *
 * Themeable via the same --gs-control-* custom properties as the
 * bottom-right controls.  Use --gs-control-top to adjust the offset
 * (default: 12px).
 */

.gs-fullscreen-host {
    position: absolute;
    top: var(--gs-control-top, 12px);
    right: var(--gs-control-right, 12px);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

[data-guidestar]:hover .gs-fullscreen-host,
.gs-fullscreen-host--visible {
    opacity: 1;
    pointer-events: auto;
}

.gs-fullscreen-btn {
    width: var(--gs-control-size, 44px);
    height: var(--gs-control-size, 44px);
    border-radius: var(--gs-control-radius, 8px);
    border: var(--gs-control-border, none);
    padding: 0;
    background: var(--gs-control-bg, rgba(0, 0, 0, 0.55));
    color: var(--gs-control-color, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    position: relative;
}

.gs-fullscreen-btn:hover {
    background: var(--gs-control-bg-hover, rgba(0, 0, 0, 0.75));
    transform: scale(1.05);
}

.gs-fullscreen-btn svg {
    width: var(--gs-control-icon-size, 22px);
    height: var(--gs-control-icon-size, 22px);
    fill: currentColor;
}

.gs-fullscreen-btn:focus-visible {
    outline: 2px solid var(--gs-control-color, #fff);
    outline-offset: 2px;
}

/* Tooltip (appears to the left of the button) */
.gs-fullscreen-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
    background: var(--gs-control-tooltip-bg, rgba(0, 0, 0, 0.8));
    color: var(--gs-control-tooltip-color, #fff);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.gs-fullscreen-btn:hover::after {
    opacity: 1;
}

/* When the container itself is fullscreen, fill the screen */
[data-guidestar]:fullscreen,
[data-guidestar]:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
}

@media (prefers-reduced-motion: reduce) {
    .gs-fullscreen-btn {
        transition: none;
    }
    .gs-fullscreen-btn:hover {
        transform: none;
    }
}

/* ── Resize handle ───────────────────────────────────────────────── */

/*
 * .gs-resize-handle — 16×16 px drag target in the bottom-right corner.
 * Shows a standard se-resize cursor; a grippy diagonal-lines visual
 * (using a repeating-linear-gradient) mirrors the browser/devtools style.
 *
 * .gs-resize-badge — live "W × H" label shown only while dragging.
 */

.gs-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    z-index: 10001;
    /* diagonal grip dots */
    background-image: repeating-linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.45) 0px,
        rgba(255, 255, 255, 0.45) 1px,
        transparent 1px,
        transparent 4px
    );
    background-size: 16px 16px;
    background-position: bottom right;
    border-radius: 0 0 2px 0;
    opacity: 0;
    transition: opacity 0.2s;
}

[data-guidestar]:hover .gs-resize-handle {
    opacity: 1;
}

.gs-resize-badge {
    position: absolute;
    bottom: 20px;
    right: 4px;
    background: var(--gs-control-tooltip-bg, rgba(0, 0, 0, 0.8));
    color: var(--gs-control-tooltip-color, #fff);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10002;
    opacity: 0;
    transition: opacity 0.15s;
}

.gs-resize-badge--visible {
    opacity: 1;
}

/* ── Branding badge ──────────────────────────────────────────────── */

/*
 * .gs-branding — small "demopowered by guidestar" link badge in the
 * bottom-left corner, to the left of the timeline track.
 *
 * Visible on container hover, hidden otherwise (same rhythm as the
 * timeline).  Hidden by default; set config.branding to false to
 * suppress entirely.
 *
 * The tooltip text ("demo powered by guidestar") appears above the badge
 * via a CSS ::after pseudo-element.
 */

.gs-branding {
    position: absolute;
    bottom: var(--gs-control-bottom, 12px);
    left: var(--gs-control-left, 12px);
    z-index: 10000;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    text-decoration: none;
}

[data-guidestar]:hover .gs-branding,
.gs-branding--visible {
    opacity: 1;
    pointer-events: auto;
}

.gs-branding svg {
    width: 24px;
    height: 24px;
    display: block;
    border-radius: 4px;
    transition: transform 0.15s ease;
}

.gs-branding:hover svg {
    transform: scale(1.1);
}

/* Tooltip above the badge — left-aligned to the badge's left edge so it
   extends rightward and does not overlap the timeline track */
.gs-branding::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: var(--gs-control-tooltip-bg, rgba(0, 0, 0, 0.8));
    color: var(--gs-control-tooltip-color, #fff);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.gs-branding:hover::after {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .gs-branding {
        transition: none;
    }
    .gs-branding svg {
        transition: none;
    }
    .gs-branding:hover svg {
        transform: none;
    }
}

/* ── Highlight animation applied to targeted elements ────────────── */

@keyframes gs-highlight-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 152, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); }
}

.gs-highlight {
    animation: gs-highlight-pulse 0.8s ease-out;
    outline: 2px solid rgba(255, 152, 0, 0.7);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Caption overlay ─────────────────────────────────────────────── */

/*
 * Themeable via CSS custom properties:
 *   --gs-caption-bg           Background (default: rgba(0,0,0,0.72))
 *   --gs-caption-color        Text color (default: #fff)
 *   --gs-caption-font-size    Font size (default: 14px)
 *   --gs-caption-padding      Padding (default: 10px 16px)
 *   --gs-caption-inset        Left & right inset — keeps the caption
 *                              clear of the control button (default: 68px)
 */

.gs-caption {
    position: absolute;
    left: var(--gs-caption-inset, 68px);
    right: var(--gs-caption-inset, 68px);
    z-index: 9998;
    min-height: var(--gs-control-size, 44px);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: var(--gs-caption-bg, rgba(0, 0, 0, 0.72));
    color: var(--gs-caption-color, #fff);
    font-size: var(--gs-caption-font-size, 14px);
    line-height: 1.4;
    text-align: center;
    pointer-events: none;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gs-caption--top {
    top: 12px;
    bottom: auto;
}

.gs-caption--bottom {
    bottom: 34px;
    top: auto;
    transition: bottom 0.3s ease, opacity 0.3s ease;
}

.gs-caption--bottom.gs-caption--timeline-visible {
    bottom: 84px;
}

.gs-caption--visible {
    opacity: 1;
}

/* ── Controls host positioning ───────────────────────────────────── */

.gs-controls-host {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10000;
}

/* ── Timeline overlay ────────────────────────────────────────────── */

/*
 * Themeable via CSS custom properties:
 *   --gs-timeline-bg           Track background (default: rgba(0,0,0,0.5))
 *   --gs-timeline-dot-color    Dot border & fill color (default: #fff)
 *   --gs-timeline-dot-size     Dot diameter (default: 10px)
 *   --gs-timeline-line-color   Connecting line color (default: rgba(255,255,255,0.3))
 */

.gs-timeline {
    position: absolute;
    bottom: 12px;
    left: var(--gs-caption-inset, 68px);
    right: var(--gs-caption-inset, 68px);
    z-index: 9999;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    background: var(--gs-timeline-bg, rgba(0, 0, 0, 0.5));
    border-radius: 6px 6px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.gs-timeline--visible {
    opacity: 1;
    pointer-events: auto;
}

/* Connecting line behind dots */
.gs-timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 12px;
    right: 12px;
    height: 2px;
    background: var(--gs-timeline-line-color, rgba(255, 255, 255, 0.3));
    transform: translateY(-50%);
    pointer-events: none;
}

.gs-timeline__dot {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    z-index: 1;
    flex-shrink: 0;
    /* The visual dot is rendered by ::after; this element is just the hit area */
}

/* Visual dot circle rendered as pseudo-element */
.gs-timeline__dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--gs-timeline-dot-size, 10px);
    height: var(--gs-timeline-dot-size, 10px);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid var(--gs-timeline-dot-color, var(--gs-control-color, #fff));
    background: transparent;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
}

.gs-timeline__dot:hover::after {
    transform: translate(-50%, -50%) scale(1.3);
}

.gs-timeline__dot--filled::after {
    background: var(--gs-timeline-dot-color, var(--gs-control-color, #fff));
}

.gs-timeline__dot--current::after {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.gs-timeline__dot--current:hover::after {
    transform: translate(-50%, -50%) scale(1.4);
}

/* ── Timeline dot hover tooltip ──────────────────────────────────── */

.gs-timeline-tooltip {
    position: absolute;
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--gs-control-bg, rgba(0, 0, 0, 0.55));
    border-radius: var(--gs-control-radius, 8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Invisible bridge extending below the tooltip to cover the gap to the dot */
.gs-timeline-tooltip::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.gs-timeline-tooltip--visible {
    opacity: 1;
    pointer-events: auto;
}

.gs-timeline-tooltip__btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--gs-control-color, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}

.gs-timeline-tooltip__btn[hidden] {
    display: none;
}

.gs-timeline-tooltip__btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.gs-timeline-tooltip__btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.gs-timeline-tooltip__btn--play {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.gs-timeline-tooltip__btn--play:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Scroll indicator ────────────────────────────────────────────────────── */

@keyframes gs-scroll-flash {
    0%   { opacity: 0; transform: translateY(-6px) scale(0.85); }
    18%  { opacity: 1; transform: translateY(0)    scale(1);    }
    65%  { opacity: 1; transform: translateY(0)    scale(1);    }
    100% { opacity: 0; transform: translateY(4px)  scale(0.9);  }
}

.gs-scroll-indicator {
    position: absolute;
    z-index: 9992;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gs-control-bg, rgba(0, 0, 0, 0.55));
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
}

.gs-scroll-indicator--active {
    animation: gs-scroll-flash 0.75s ease-out forwards;
}

.gs-scroll-indicator svg {
    width: 20px;
    height: 20px;
    fill: var(--gs-control-color, #fff);
}

/* ── Restart overlay ─────────────────────────────────────────────────────── */

@keyframes gs-restart-expand {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.5); }
}

.gs-restart-overlay {
    position: absolute;
    inset: 0;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
}

.gs-restart-overlay--active {
    animation: gs-restart-expand 0.7s ease-out forwards;
}

.gs-restart-overlay__icon {
    width: 72px;
    height: 72px;
    border-radius: var(--gs-control-radius, 8px);
    background: var(--gs-control-bg, rgba(0, 0, 0, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
}

.gs-restart-overlay__icon svg {
    width: 40px;
    height: 40px;
    fill: var(--gs-control-color, #fff);
}

/* ── Focus indicators ────────────────────────────────────────────── */

.gs-timeline__dot:focus-visible {
    outline: 2px solid var(--gs-timeline-dot-color, var(--gs-control-color, #fff));
    outline-offset: 2px;
}

.gs-timeline-tooltip__btn:focus-visible {
    outline: 2px solid var(--gs-control-color, #fff);
    outline-offset: 1px;
}

/* ── Reduced motion ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .gs-highlight {
        animation: none;
    }
    .gs-caption {
        transition: none;
    }
    .gs-caption--bottom {
        transition: none;
    }
    .gs-timeline {
        transition: none;
    }
    .gs-timeline__dot::after {
        transition: none;
    }
    .gs-timeline__dot:hover::after {
        transform: translate(-50%, -50%);
    }
    .gs-timeline__dot--current::after {
        transform: translate(-50%, -50%);
    }
    .gs-timeline-tooltip {
        transition: none;
    }
    .gs-timeline-tooltip__btn {
        transition: none;
    }
    .gs-restart-overlay--active {
        animation: none;
        opacity: 0;
    }
    .gs-scroll-indicator--active {
        animation: none;
        opacity: 0;
    }
}

/* Config-driven reduced motion (reduceMotion: true) */
.gs-reduce-motion .gs-highlight {
    animation: none;
}
.gs-reduce-motion .gs-caption,
.gs-reduce-motion .gs-caption--bottom {
    transition: none;
}
.gs-reduce-motion .gs-timeline,
.gs-reduce-motion .gs-timeline__dot::after,
.gs-reduce-motion .gs-timeline-tooltip,
.gs-reduce-motion .gs-timeline-tooltip__btn {
    transition: none;
}
.gs-reduce-motion .gs-timeline__dot:hover::after,
.gs-reduce-motion .gs-timeline__dot--current::after {
    transform: translate(-50%, -50%);
}
.gs-reduce-motion .gs-restart-overlay--active {
    animation: none;
    opacity: 0;
}
.gs-reduce-motion .gs-scroll-indicator--active {
    animation: none;
    opacity: 0;
}
