@font-face {
    font-family: "Kode Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/static/kode-mono-500.ttf") format("truetype");
}

body, html {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    background: #000;
    color: #fff;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
}

h1, h2, h4, h6 {
    font-family: "Kode Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 500;
    font-style: normal;
}

.textContent {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#loadingDiv {
    padding: 24px;
    box-sizing: border-box;
}

#loading {
    margin: 0 0 24px;
    font-size: clamp(22px, 5vw, 32px);
}

#downloadProgress {
    width: min(320px, 80vw);
    height: 6px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: #293136;
    accent-color: #aef6df;
    appearance: none;
    -webkit-appearance: none;
}

#downloadProgress::-webkit-progress-bar {
    background: #293136;
    border-radius: 999px;
}

#downloadProgress::-webkit-progress-value {
    background: #aef6df;
    border-radius: 999px;
    transition: width 150ms linear;
}

#downloadProgress::-moz-progress-bar {
    background: #aef6df;
    border-radius: 999px;
}

#downloadProgress:indeterminate {
    background: linear-gradient(90deg, #293136 30%, #aef6df 50%, #293136 70%);
    background-size: 200% 100%;
    animation: download-sweep 1.4s linear infinite;
    opacity: 0.7;
}

#downloadProgress:indeterminate::-webkit-progress-bar {
    background: transparent;
}

#downloadProgress:indeterminate::-moz-progress-bar {
    background: transparent;
}

@keyframes download-sweep {
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    #downloadProgress { animation: none !important; }
    #downloadProgress::-webkit-progress-value { transition: none; }
}

#downloadPercent {
    margin-top: 12px;
    color: #a0a8b1;
    font: 12px system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

#urlInput {
    margin-top: 10px;
    width: 75%;
}

button {
    font-size: 1.5em;
    font-family: "Kode Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 500;
    font-style: normal;
}

/* Landing-page styling only: same copy and elements, no player changes. */
html.landing-page {
    display: block;
    padding: 0;
    background: #0c0e11;
}

body.landing {
    width: 100%;
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    padding: 24px;
    background: radial-gradient(ellipse at 50% 0%, #1b2729 0%, transparent 65%), #0c0e11;
    color: #f4f6f7;
    font-family: system-ui, sans-serif;
}

.landing #link-form {
    box-sizing: border-box;
    width: min(100%, 460px);
    padding: clamp(24px, 5vw, 40px);
    border: 1px solid rgb(255 255 255 / 8%);
    border-radius: 24px;
    background: #15181c;
    box-shadow: 0 24px 80px rgb(0 0 0 / 30%);
}

.landing #siteLogo {
    display: block;
    width: min(100%, 280px);
    height: auto;
    margin-bottom: 0;
}

.landing h6 {
    margin: 16px 0 28px;
    color: #a0a8b1;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
}

.landing #urlInput {
    box-sizing: border-box;
    width: 100%;
    min-height: 54px;
    margin: 0;
    padding: 15px 16px;
    border: 1px solid #383e46;
    border-radius: 12px;
    background: #0d1013;
    color: #f4f6f7;
    font: 16px/1.4 system-ui, sans-serif;
    transition: border-color 150ms, box-shadow 150ms;
}

.landing #urlInput::placeholder {
    color: #7e8995;
}

.landing #link-form br {
    display: none;
}

.landing #submitButton {
    width: 100%;
    min-height: 52px;
    margin-top: 12px;
    padding: 14px 20px;
    border: 0;
    border-radius: 12px;
    background: #e4f4ee;
    color: #14251f;
    font: 600 15px/1.4 system-ui, sans-serif;
    cursor: pointer;
    transition: background 150ms, transform 150ms;
}

@media (hover: hover) {
    .landing #submitButton:hover {
        background: #f3fff9;
        transform: translateY(-1px);
    }
}

.landing #submitButton:active {
    transform: translateY(0);
}

.landing #urlInput:focus-visible, .landing #submitButton:focus-visible {
    outline: 2px solid #99d9c0;
    outline-offset: 3px;
}

.landing #form-error {
    margin: 16px 0 0;
    color: #ffb6ac;
    font-size: 13px;
    line-height: 1.5;
}

.landing #shortcutLink {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 12px;
    color: #aef6df;
    font-size: 13px;
    text-underline-offset: 4px;
    text-decoration-color: rgb(174 246 223 / 45%);
}

.landing #shortcutLink:hover {
    text-decoration-color: currentColor;
}

.landing #shortcutLink:focus-visible {
    outline: 2px solid #99d9c0;
    outline-offset: 3px;
    border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .landing #urlInput, .landing #submitButton { transition: none; }
}

#videoDiv {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

video {
    display: block;
    width: auto;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    object-fit: contain;
}

#videoStage {
    position: relative;
    max-width: 100%;
}

#videoFrame {
    position: relative;
}

#videoUrlLink {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 4;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgb(0 0 0 / 35%);
}

#videoUrlLink img {
    display: block;
    object-fit: contain;
}

#videoUrlLink:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

#customControls button {
    border: 0;
    color: #fff;
    font-family: system-ui, sans-serif;
    cursor: pointer;
    touch-action: manipulation;
}

#playToggle {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    display: grid;
    place-items: center;
    z-index: 1;
}

#playGlyph {
    display: grid;
    place-items: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgb(0 0 0 / 35%);
    pointer-events: none;
}

#playIcon {
    width: 0;
    height: 0;
    margin-left: 5px;
    border-top: 17px solid transparent;
    border-bottom: 17px solid transparent;
    border-left: 27px solid #fff;
}

#pauseIcon {
    width: 24px;
    height: 32px;
    border-left: 8px solid #fff;
    border-right: 8px solid #fff;
    box-sizing: border-box;
}

#playerBuffer {
    display: grid;
    place-items: center;
    pointer-events: none;
}

.spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgb(255 255 255 / 30%);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
}

#videoSeek {
    position: absolute;
    left: 12px;
    bottom: env(safe-area-inset-bottom, 0px);
    z-index: 3;
    width: calc(100% - 24px);
    height: 36px;
    margin: 0;
    padding: 0;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

#videoSeek::-webkit-slider-runnable-track {
    height: 3px;
    background: linear-gradient(to right, #fff var(--progress, 0%), rgb(255 255 255 / 35%) var(--progress, 0%));
    border-radius: 2px;
}

#videoSeek::-moz-range-track {
    height: 3px;
    background: rgb(255 255 255 / 35%);
    border-radius: 2px;
}

#videoSeek::-moz-range-progress {
    height: 3px;
    background: #fff;
}

#videoSeek::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    margin-top: -4.5px;
    border-radius: 50%;
    background: #fff;
}

#videoSeek::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 50%;
    background: #fff;
}

#playbackInfo {
    position: absolute;
    left: 14px;
    bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    z-index: 2;
    color: #fff;
    font: 12px system-ui, sans-serif;
    text-shadow: 0 1px 3px #000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

#fullscreenToggle {
    position: absolute;
    right: 4px;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    z-index: 3;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    font-size: 28px;
    text-shadow: 0 1px 3px #000;
}

#customControls button:focus-visible, #videoSeek:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -3px;
}

#videoStage:fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#videoStage:fullscreen video {
    max-height: 100vh;
    max-height: 100dvh;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

#videoCaption {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    color: #fff;
    text-align: left;
    font-family: system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    text-shadow: 0 1px 4px #000, 0 1px 2px #000;
    pointer-events: none;
    z-index: 3;
}

#videoCreator {
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#captionCopy {
    position: relative;
}

#videoDescription {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin: 0;
    padding-right: 3.5em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

#captionToggle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 3.5em;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-shadow: inherit;
    text-align: right;
    cursor: pointer;
    pointer-events: auto;
}

#captionCopy.expanded #videoDescription {
    display: block;
    -webkit-line-clamp: unset;
    max-height: 35vh;
    max-height: 35dvh;
    overflow-y: auto;
    padding-right: 0;
    pointer-events: auto;
}

#captionCopy.expanded #captionToggle {
    position: static;
    display: block;
    margin-left: auto;
    margin-top: 3px;
}

#captionToggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}
