/* The tutorial video player (assets/js/tutorial-player.js) and the /tutorials/ page layout.
   A dark stage with the site's teal for progress and focus, and the site's white card for menus. It is the website
   twin of the player in Trace. Captions and menus size to the player, so they stay readable in a column, on a phone
   and full screen. */

.tvp {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius-lg, 12px);
    background: #11161d;
    color: #ffffff;
    font-family: var(--font, "Geist", system-ui, sans-serif);
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    container-type: size;
}

.tvp:focus-visible {
    outline: 2px solid var(--primary-ink, #086a71);
    outline-offset: 3px;
}

.tvp.is-idle { cursor: none; }

.tvp.is-fullscreen,
.tvp:fullscreen {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}

.tvp:-webkit-full-screen {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}

.tvp-video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #11161d;
}

/* ---- the picture's own states ---------------------------------------------------------------------- */

.tvp-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 76px;
    height: 76px;
    margin: -38px 0 0 -38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 0 4px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-ink, #086a71);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    animation: tvp-center-in 200ms ease-out;
    transition: transform 160ms ease, background-color 160ms ease;
}

.tvp-center svg { width: 30px; height: 30px; }
.tvp-center:hover { transform: scale(1.06); background: #ffffff; }
.tvp-center:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }
.tvp.is-ended .tvp-center { padding-left: 0; }
.tvp.is-playing .tvp-center,
.tvp.is-failed .tvp-center { display: none; }

.tvp-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border: 3px solid rgba(255, 255, 255, 0.28);
    border-top-color: #ffffff;
    border-radius: 50%;
    pointer-events: none;
    animation: tvp-spin 800ms linear infinite;
}

.tvp-loading[hidden] { display: none; }

/* The video could not be loaded or played. */
.tvp-failed {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: #11161d;
    color: rgba(255, 255, 255, 0.88);
    font-size: 14px;
    text-align: center;
}

.tvp-failed[hidden] { display: none; }
.tvp-failed-text { margin: 0; line-height: 1.5; }
.tvp-failed-link { color: #8ae6ec; font-weight: 600; text-decoration: underline; }
.tvp-failed-text { max-width: 36ch; }

.tvp-failed-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 18px;
}

.tvp-failed-retry {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    background: #09adb7;
    color: #ffffff;
    font: 600 14px var(--font, "Geist", system-ui, sans-serif);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.tvp-failed-retry:hover { background: #089da5; }
.tvp-failed-retry:focus-visible { outline: 2px solid #8ae6ec; outline-offset: 2px; }

.tvp-captions {
    position: absolute;
    left: 50%;
    bottom: 18px;
    max-width: 78%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    transition: bottom 220ms ease;
}

.tvp-captions[hidden] { display: none; }

/* Clear of the control bar while it is showing. */
.tvp:not(.is-idle):not(.is-fresh) .tvp-captions { bottom: 84px; }

/* Small, so a caption never covers much of the screen being shown. */
.tvp-caption-text {
    display: inline;
    padding: 1px 7px;
    border-radius: 4px;
    background: rgba(17, 22, 29, 0.78);
    color: #ffffff;
    font-size: clamp(12px, 1.7cqw, 26px);
    line-height: 1.55;
    white-space: pre-line;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* ---- controls --------------------------------------------------------------------------------------- */

.tvp-scrim {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: min(140px, 70cqh);
    background: linear-gradient(to top, rgba(10, 14, 20, 0.85) 0%, rgba(10, 14, 20, 0.5) 45%, rgba(10, 14, 20, 0) 100%);
    pointer-events: none;
    transition: opacity 220ms ease;
}

.tvp-bar {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0 14px 10px;
    transition: opacity 220ms ease, transform 220ms ease;
}

.tvp.is-idle .tvp-scrim,
.tvp.is-idle .tvp-bar {
    opacity: 0;
    pointer-events: none;
}

.tvp.is-idle .tvp-bar { transform: translateY(6px); }

/* Before the first play only the poster and the play button show. */
.tvp.is-fresh .tvp-scrim,
.tvp.is-fresh .tvp-bar,
.tvp.is-failed .tvp-scrim,
.tvp.is-failed .tvp-bar { display: none; }

.tvp-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
}

.tvp-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #ffffff;
    font: inherit;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.tvp-btn:hover { background: rgba(255, 255, 255, 0.16); }
.tvp-btn[hidden] { display: none; }

.tvp-btn:focus-visible,
.tvp-menu-item:focus-visible {
    outline: 2px solid #8ae6ec;
    outline-offset: 2px;
}

/* Captions on, or a speed other than normal. */
.tvp-btn.is-on {
    background: rgba(9, 173, 183, 0.26);
    color: #8ae6ec;
}

.tvp-btn.is-on:hover { background: rgba(9, 173, 183, 0.38); }

/* After the video ends, replay is the one thing to do. */
.tvp-btn.tvp-btn-replay { background: #09adb7; }
.tvp-btn.tvp-btn-replay:hover { background: #089da5; }

.tvp-speed-btn {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tvp-time {
    margin-left: 6px;
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    opacity: 0.92;
}

.tvp-time-divider { opacity: 0.55; }
.tvp-spacer { flex: 1; }

/* The volume bar slides out beside the speaker on hover or focus. Touch screens use the device's volume. */
.tvp-volume { display: flex; align-items: center; }

.tvp-volume-slider {
    box-sizing: border-box;
    width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transition: width 200ms ease, opacity 200ms ease, padding 200ms ease;
}

.tvp-volume:hover .tvp-volume-slider,
.tvp-volume:focus-within .tvp-volume-slider {
    width: 84px;
    padding: 0 8px;
    opacity: 1;
}

@media (hover: none) {
    .tvp-volume-slider { display: none; }
}

/* ---- sliders ---------------------------------------------------------------------------------------- */

.tvp-scrubber,
.tvp-volume-slider {
    position: relative;
    display: flex;
    align-items: center;
    height: 20px;
    cursor: pointer;
    touch-action: none;
    outline: none;
}

.tvp-scrubber { width: 100%; }

.tvp-scrubber:focus-visible,
.tvp-volume-slider:focus-visible {
    outline: 2px solid #8ae6ec;
    outline-offset: 2px;
    border-radius: 6px;
}

.tvp-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.28);
    transition: height 120ms ease;
}

.tvp-scrubber:hover .tvp-track,
.tvp-scrubber.is-active .tvp-track,
.tvp-scrubber:focus-visible .tvp-track { height: 6px; }

.tvp-track-buffered,
.tvp-track-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    border-radius: inherit;
}

.tvp-track-buffered { background: rgba(255, 255, 255, 0.34); }
.tvp-track-fill { background: #09adb7; }

.tvp-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(9, 173, 183, 0.45), 0 1px 4px rgba(0, 0, 0, 0.4);
    transform: scale(0);
    transition: transform 120ms ease;
}

.tvp-scrubber:hover .tvp-thumb,
.tvp-scrubber.is-active .tvp-thumb,
.tvp-scrubber:focus-visible .tvp-thumb,
.tvp-volume-slider .tvp-thumb { transform: scale(1); }

.tvp-tip {
    position: absolute;
    bottom: 24px;
    transform: translateX(-50%);
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(17, 22, 29, 0.94);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

.tvp-tip[hidden] { display: none; }

/* ---- menus (captions, speed) ------------------------------------------------------------------------ */

.tvp-menu-wrap { position: relative; display: flex; }
.tvp-menu-wrap[hidden] { display: none; }

.tvp-menu {
    position: absolute;
    right: 0;
    /* Clear of the seek bar above the buttons. */
    bottom: calc(100% + 26px);
    min-width: 128px;
    max-height: min(310px, calc(100cqh - 120px));
    padding: 4px;
    overflow-y: auto;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text-dark, #222933);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.3);
    transform-origin: bottom right;
    animation: tvp-menu-in 140ms ease-out;
}

.tvp-menu-title {
    padding: 4px 8px 2px;
    color: var(--text-light, #6b7280);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tvp-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 30px;
    padding: 0 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: 500 13px var(--font, "Geist", system-ui, sans-serif);
    text-align: left;
    cursor: pointer;
}

.tvp-menu-item svg { width: 14px; height: 14px; flex: none; }
.tvp-menu-item:hover { background: rgba(9, 173, 183, 0.1); }
.tvp-menu-item:focus-visible { outline-color: #086a71; }
.tvp-menu-item.is-on { color: #086a71; font-weight: 600; }

/* ---- small players and touch ------------------------------------------------------------------------ */

@container (max-width: 480px) {
    .tvp-bar { padding: 0 10px 6px; }
    .tvp-btn { width: 36px; height: 36px; }
    .tvp-time { margin-left: 2px; font-size: 12px; }
    .tvp-center { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
    .tvp-center svg { width: 26px; height: 26px; }
    .tvp:not(.is-idle):not(.is-fresh) .tvp-captions { bottom: 76px; }

    /* A phone gives the player little height, so an open menu uses nearly all of it, in two columns. */
    .tvp-menu-wrap { position: static; }

    .tvp-menu {
        right: 8px;
        bottom: 8px;
        left: 8px;
        min-width: 0;
        max-height: calc(100cqh - 16px);
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-content: start;
        gap: 0 4px;
        transform-origin: bottom center;
    }

    .tvp-menu-title { grid-column: 1 / -1; padding-top: 4px; }
    .tvp-menu .tvp-menu-item { min-height: 32px; }
}

/* Too short for a big play badge above the controls: the bar's play button and a click on the picture remain. */
@container (max-height: 170px) {
    .tvp-center { display: none; }
}

@media (pointer: coarse) {
    .tvp-btn { width: 44px; height: 44px; }
    .tvp-scrubber { height: 28px; }
    .tvp-menu .tvp-menu-item { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    .tvp-center,
    .tvp-menu { animation: none; }

    .tvp-scrim,
    .tvp-bar,
    .tvp-captions,
    .tvp-track,
    .tvp-thumb,
    .tvp-volume-slider { transition: none; }

    .tvp-loading { animation-duration: 1600ms; }
}

@keyframes tvp-center-in {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes tvp-menu-in {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tvp-spin {
    to { transform: rotate(360deg); }
}

/* ===== The /tutorials/ page ============================================================================ */

/* The dark page hero (.pg-dark) is shared with the blog, changelog and pricing pages. Kept compact so the player
   starts on the first screen. */
.tv-page-hero { padding: 56px 0 52px; }
.tv-page-hero .hero-inner { max-width: 760px; }
.tv-page-hero h1 { text-wrap: balance; }
.tv-page-hero .lead { margin-bottom: 0; max-width: 640px; }
.tv-stage-section { padding-top: 48px; padding-bottom: 72px; }

.tv-theater {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 372px;
    gap: 40px;
    align-items: start;
}

.tv-main { min-width: 0; }

.tv-main .tvp {
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 16px 44px rgba(15, 23, 42, .16);
}

.tv-now { margin-top: 22px; }

.tv-now-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    font-size: 13.5px;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

.tv-now-tag {
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
}

.tv-now-title {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-dark);
    text-wrap: balance;
}

.tv-now-desc {
    margin: 0;
    max-width: 62ch;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-medium);
}

.tv-now-note {
    margin: 14px 0 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-light);
}

.tv-now-note kbd {
    padding: 0 5px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--bg-light);
    font: 600 12px var(--font, "Geist", system-ui, sans-serif);
    color: var(--text-medium);
}

/* Keyboard hints mean nothing on a touch screen. */
@media (hover: none) {
    .tv-keys { display: none; }
}

.tv-list-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
}

.tv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tv-item {
    display: grid;
    grid-template-columns: 156px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 8px 12px 8px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-white);
    color: inherit;
    cursor: default;
}

/* The video on the stage now. */
.tv-item[aria-current="true"] {
    border-color: var(--primary);
    background: var(--primary-light);
}

.tv-item-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: #0a0f16;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .08);
}

.tv-item-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.tv-item-time {
    position: absolute;
    right: 5px;
    bottom: 5px;
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(17, 22, 29, .82);
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tv-item-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tv-item-tag { font-size: 12px; font-weight: 700; color: var(--primary-ink); }
.tv-item-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; color: var(--text-dark); }

.tv-about .section-title { margin-bottom: 32px; }

.tv-about-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.tv-about-item {
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--bg-white);
}

.tv-about-item h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--text-dark); }
.tv-about-item p { margin: 0; font-size: 14.5px; line-height: 1.65; color: var(--text-medium); }

@media (max-width: 1024px) {
    .tv-theater { grid-template-columns: minmax(0, 1fr); gap: 28px; }
    .tv-about-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
    .tv-page-hero { padding: 40px 0 36px; }
    .tv-page-hero .lead { font-size: 15px; line-height: 1.6; }
    .tv-stage-section { padding-top: 28px; padding-bottom: 56px; }
    .tv-now-title { font-size: 1.375rem; }
    .tv-now-desc { font-size: 15px; }
    .tv-item { grid-template-columns: 128px minmax(0, 1fr); }
    .tv-main .tvp, .tvp { border-radius: var(--radius-lg, 12px); }
}

