/* ============================================
   TEC Updates - share bar, inline video, file cards
   --------------------------------------------
   Loaded (after main.css / theme.css) by the three detail pages:
     pages/research/article.php
     pages/research/publication.php
     pages/events/detail.php
   Sections:
     0. Images inside article / event / publication text
     1. Share bar
     2. Inline video player
     3. File (PDF / DOC ...) download cards
   ============================================ */

/* ---------------- 0. IMAGES IN CONTENT ---------------- */

.article-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.25rem auto;
    border-radius: var(--radius, 8px);
}

/* ---------------- 1. SHARE BAR ---------------- */

.tec-share {
    margin: 2.5rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}
.tec-share-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.tec-share-label {
    font-family: var(--font-heading, inherit);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-500, #6b7280);
    margin-right: 0.35rem;
}
.tec-share-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--gray-500, #6b7280) !important;
    text-decoration: none !important;
    border: 1px solid var(--gray-200, #e5e7eb);
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(.34,1.56,.64,1),
                background 0.18s ease,
                color 0.18s ease,
                border-color 0.18s ease,
                box-shadow 0.18s ease;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.tec-share-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 6px 16px rgba(15,23,42,.14);
    border-color: transparent;
}
.tec-share-btn:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 2px 6px rgba(15,23,42,.10);
}
.tec-share-btn:focus-visible {
    outline: 2px solid var(--primary-blue, #1e40af);
    outline-offset: 2px;
}
.tec-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.tec-share-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tec-share-letter {
    font-family: var(--font-heading, inherit);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
}

.tec-share-facebook:hover { background: #1877F2; color: #fff !important; }
.tec-share-x:hover        { background: #000000; color: #fff !important; }
.tec-share-linkedin:hover { background: #0A66C2; color: #fff !important; }
.tec-share-whatsapp:hover { background: #25D366; color: #fff !important; }
.tec-share-telegram:hover { background: #0088CC; color: #fff !important; }
.tec-share-email:hover    { background: #ea580c; color: #fff !important; }
.tec-share-native:hover   { background: var(--primary-blue, #1e40af); color: #fff !important; }
.tec-share-copy:hover     { background: var(--gray-700, #374151); color: #fff !important; }

.tec-share-copy.is-copied {
    background: #065f46 !important;
    color: #fff !important;
    border-color: transparent;
}
.tec-share-copy .tec-share-icon-check { display: none; }
.tec-share-copy.is-copied .tec-share-icon-copy  { display: none; }
.tec-share-copy.is-copied .tec-share-icon-check { display: inline-flex; }

.tec-share-toast {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #065f46;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.tec-share-toast.is-visible { opacity: 1; }

@media (max-width: 600px) {
    .tec-share-btn { width: 40px; height: 40px; }
    .tec-share-icon { width: 17px; height: 17px; }
}
@media (prefers-reduced-motion: reduce) {
    .tec-share-btn,
    .tec-share-btn:hover,
    .tec-share-btn:active {
        transition: background 0.18s ease, color 0.18s ease;
        transform: none;
    }
}

/* ---------------- 2. INLINE VIDEO PLAYER ---------------- */
/* The editor stores a plain <video class="tec-inline-video" ...> tag.
   assets/js/tec-share.js wraps it in .tec-video and adds the custom
   controls. Until the script runs (or if it fails) the browser's own
   controls stay visible, so the video is always usable. */

video.tec-inline-video {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
    max-height: 540px;
    margin: 1.75rem auto;
    border-radius: var(--radius-lg, 12px);
    background: #000;
}

.tec-video {
    position: relative;
    display: block;
    width: min(900px, 100%);
    margin: 1.75rem auto;
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,.12), 0 4px 6px -2px rgba(0,0,0,.06));
    line-height: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
.tec-video > video.tec-inline-video {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 540px;
    margin: 0;
    border-radius: 0;
    background: #000;
    object-fit: contain;
    cursor: pointer;
}

/* small "unmute" badge - only while the video is still on its first, silent run */
.tec-video-hint {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: rgba(10, 17, 32, 0.78);
    color: #fff;
    font-family: var(--font-heading, inherit);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 999px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.2s ease;
}
.tec-video-hint svg { width: 16px; height: 16px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tec-video.is-active .tec-video-hint { opacity: 0; }

/* big play icon: shown when the visitor paused it, or the browser blocked autoplay */
.tec-video-center {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.tec-video-center span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(10, 17, 32, 0.7);
    color: #fff;
}
.tec-video-center svg { width: 28px; height: 28px; margin-left: 3px; fill: currentColor; stroke: none; }
.tec-video.is-blocked .tec-video-center,
.tec-video.is-active.is-paused .tec-video-center { display: flex; }

/* control bar: seek slider + mute button (+ play / time / fullscreen) */
.tec-video-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 1.75rem 0.75rem 0.55rem;
    background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0));
    line-height: normal;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.tec-video.is-active.show-bar .tec-video-bar,
.tec-video.is-active.is-paused .tec-video-bar {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}
.tec-video-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}
.tec-video-btn:hover { background: rgba(255,255,255,.2); }
.tec-video-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.tec-video-btn svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tec-video-btn .ic-pause, .tec-video-btn .ic-vol { display: none; }
.tec-video.is-playing .tec-video-btn .ic-play { display: none; }
.tec-video.is-playing .tec-video-btn .ic-pause { display: block; }
.tec-video.is-unmuted .tec-video-btn .ic-mute { display: none; }
.tec-video.is-unmuted .tec-video-btn .ic-vol { display: block; }

.tec-video-time {
    flex: 0 0 auto;
    color: #fff;
    font-family: var(--font-heading, inherit);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tec-video-seek {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-width: 0;
    height: 18px;
    margin: 0 0.25rem;
    padding: 0;
    background: transparent;
    cursor: pointer;
    outline: none;
}
.tec-video-seek::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, #fff var(--p, 0%), rgba(255,255,255,.35) var(--p, 0%));
}
.tec-video-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    margin-top: -4px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}
.tec-video-seek::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.35); }
.tec-video-seek::-moz-range-progress { height: 4px; border-radius: 2px; background: #fff; }
.tec-video-seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }
.tec-video-seek:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.tec-video:fullscreen { width: 100%; margin: 0; border-radius: 0; display: flex; align-items: center; justify-content: center; }
.tec-video:fullscreen > video.tec-inline-video { max-height: none; height: 100%; }
.tec-video:-webkit-full-screen { width: 100%; margin: 0; border-radius: 0; }
.tec-video:-webkit-full-screen > video.tec-inline-video { max-height: none; height: 100%; }

@media (max-width: 520px) {
    .tec-video-time { display: none; }
    .tec-video-btn { width: 38px; height: 38px; }
}

/* ---------------- 3. FILE DOWNLOAD CARDS ---------------- */
/* The editor stores:  <a class="tec-inline-file" href="..." download="x.pdf">x.pdf</a>
   The card (file icon + file name + Download button) is drawn by CSS only. */

a.tec-inline-file {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 1.25rem 0;
    padding: 0.85rem 1rem;
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15,23,42,.05);
    color: var(--charcoal, #1f2937) !important;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.35;
    word-break: break-word;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.tec-inline-file:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(15,23,42,.12);
    border-color: var(--primary-blue, #1e40af);
}
a.tec-inline-file:focus-visible {
    outline: 2px solid var(--primary-blue, #1e40af);
    outline-offset: 2px;
}

/* file icon tile (type label under a page icon) */
a.tec-inline-file::before {
    content: "FILE";
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 48px;
    height: 56px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 7px;
    border-radius: 10px;
    background-color: #64748b;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center 9px;
    background-size: 22px 22px;
    color: #fff;
    font-family: var(--font-heading, inherit);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
}
a.tec-inline-file[href$=".pdf" i]::before  { content: "PDF"; background-color: #dc2626; }
a.tec-inline-file[href$=".doc" i]::before,
a.tec-inline-file[href$=".docx" i]::before { content: "DOC"; background-color: #2563eb; }
a.tec-inline-file[href$=".xls" i]::before,
a.tec-inline-file[href$=".xlsx" i]::before { content: "XLS"; background-color: #16a34a; }
a.tec-inline-file[href$=".csv" i]::before  { content: "CSV"; background-color: #16a34a; }
a.tec-inline-file[href$=".ppt" i]::before,
a.tec-inline-file[href$=".pptx" i]::before { content: "PPT"; background-color: #ea580c; }
a.tec-inline-file[href$=".txt" i]::before  { content: "TXT"; background-color: #64748b; }

/* download button */
a.tec-inline-file::after {
    content: "Download";
    margin-left: auto;
    flex: 0 0 auto;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    background: var(--primary-blue, #1e40af);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    transition: background 0.15s ease;
}
a.tec-inline-file:hover::after { background: var(--navy, #0a1120); }

@media (max-width: 520px) {
    a.tec-inline-file { padding: 0.7rem 0.8rem; gap: 0.7rem; font-size: 0.9rem; }
    a.tec-inline-file::after {
        content: "\2193";
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        font-size: 1.15rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    a.tec-inline-file, a.tec-inline-file:hover { transition: none; transform: none; }
}
