/* =========================================================================
   <usermedia> HTML element demo — tech-demos/usermedia-html-element.php
   Loaded after base.css and tech-demos.css.

   Scoped copy of the Hugo static/css/usermedia-html-element.css:
   - every rule is prefixed with #usermedia-html-element
   - the :root tokens live on the wrapper, so base.css keeps its own --ink/--line
   - the global body, h1 and h2 rules were dropped
   - section 0 neutralises base.css components that share a class name here
     (.card, .status, .why) and the base.css <section>/<p> defaults
   ========================================================================= */

/* ---- 0. Wrapper, tokens, base.css neutralisers ---- */
#usermedia-html-element{
  --ink:#222; --muted:#5f6b76; --line:#dfe3e8; --panel:#f7f8f9;
  --brand:#ed341d; --brand-dark:#c72d1c; --blue:#005a9c; --link:#4183c4;
  --warn:#8a6100; --ok:#1f7a4d; --radius:8px;
  color:var(--ink);font-size:16px;line-height:1.55;overflow-wrap:break-word
}
#usermedia-html-element section{padding:0}
#usermedia-html-element p{max-width:none}
#usermedia-html-element .card{display:block;transition:none}
#usermedia-html-element .card:hover{border-color:var(--line);transform:none}
#usermedia-html-element .card p{font-size:inherit;color:inherit}
#usermedia-html-element .status{padding:0;border:0;border-radius:0;align-self:auto}
#usermedia-html-element .why{display:inline;grid-template-columns:none;gap:0}

.page#usermedia-html-element{max-width:79rem;margin:0 auto}

/* ---- 1. Typography ---- */
#usermedia-html-element h3{font-family:var(--body);font-weight:700;color:var(--blue);letter-spacing:.04em;line-height:1.25;text-transform:uppercase;margin:0 0 .6rem;font-size:140%}
#usermedia-html-element h4{color:var(--ink);font-size:1rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;margin:.4rem 0}
#usermedia-html-element p{margin:0 0 1rem}
#usermedia-html-element a{color:var(--link);text-decoration:none}
#usermedia-html-element a:hover,#usermedia-html-element a:focus-visible{color:var(--blue);text-decoration:underline}
#usermedia-html-element code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.88em;background:var(--panel);border:1px solid var(--line);border-radius:4px;padding:.05em .3em}
#usermedia-html-element .byline{color:var(--muted);font-size:.9rem;margin-bottom:1.25rem}

/* ---- 2. Layout ---- */
#usermedia-html-element .card{border:1px solid var(--line);border-radius:var(--radius);padding:1.1rem 1.2rem;margin:0 0 1.25rem;background:#fff}
#usermedia-html-element .card--muted{background:var(--panel)}
#usermedia-html-element .grid-2{display:grid;grid-template-columns:repeat(auto-fit,minmax(17rem,1fr));gap:1.25rem;margin:0 0 1.25rem}
#usermedia-html-element .grid-2>.card{margin:0}
#usermedia-html-element .grid-2--fields{gap:1rem;margin-bottom:0}
#usermedia-html-element .card h2:not(:first-child){margin-top:1.5rem}
#usermedia-html-element .card h3{margin-top:1.4rem}
#usermedia-html-element .card h3:first-child{margin-top:0}
#usermedia-html-element .stack>*+*{margin-top:1rem}
#usermedia-html-element .stack--offset{margin-top:1rem}
#usermedia-html-element .stack--offset-sm{margin-top:.75rem}
#usermedia-html-element #stats{padding-left:0!important}
#usermedia-html-element ul,#usermedia-html-element ol{margin:0 0 1rem;padding-left:1.25rem;list-style:disc}
#usermedia-html-element li+li{margin-top:.2rem}
#usermedia-html-element .hint{color:var(--muted);font-size:.85rem;margin:.35rem 0 20px}
#usermedia-html-element .is-hidden{display:none!important}

/* ---- 3. Form controls ---- */
#usermedia-html-element .field{display:flex;flex-direction:column;gap:.3rem;min-width:0}
#usermedia-html-element .field>label{font-size:.8rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.03em}
#usermedia-html-element .field>label code{text-transform:none;letter-spacing:0}
#usermedia-html-element select,#usermedia-html-element input[type="text"],#usermedia-html-element textarea{width:100%;font:inherit;font-size:.95rem;color:inherit;padding:.5rem .6rem;border:1px solid var(--line);border-radius:5px;background:#fff}
#usermedia-html-element textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.8rem;line-height:1.5;resize:vertical;tab-size:2}
#usermedia-html-element textarea.is-invalid{border-color:var(--brand);background:rgba(237,52,29,.04)}
#usermedia-html-element select:disabled,#usermedia-html-element input[type="text"]:disabled,#usermedia-html-element textarea:disabled{background:var(--panel);color:var(--muted)}
#usermedia-html-element .checkbox{display:flex;align-items:flex-start;gap:.5rem;font-size:.9rem;line-height:1.4}
#usermedia-html-element .checkbox input{margin:.25rem 0 0;flex:none}
#usermedia-html-element :where(button,select,input,textarea,a):focus-visible{outline:2px solid var(--blue);outline-offset:2px}

/* ---- 4. Buttons ---- */
#usermedia-html-element .controls{display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:20px}
#usermedia-html-element .button{flex:1 1 9rem;min-height:2.75rem;padding:.5rem 1rem;border:1px solid var(--brand);border-radius:5px;background:var(--brand);color:#fff;font:inherit;font-weight:600;font-size:.95rem;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;gap:.4rem}
#usermedia-html-element .button:hover:not(:disabled){background:var(--brand-dark);border-color:var(--brand-dark)}
#usermedia-html-element .button:active:not(:disabled){transform:translateY(1px)}
#usermedia-html-element .button:disabled{cursor:not-allowed;opacity:.5}
#usermedia-html-element .button--secondary{background:#fff;color:var(--ink);border-color:var(--line)}
#usermedia-html-element .button--secondary:hover:not(:disabled){background:var(--panel);border-color:var(--muted);color:var(--ink)}
#usermedia-html-element .button--small{flex:0 0 auto;min-height:2rem;padding:.25rem .7rem;font-size:.82rem;font-weight:500}
#usermedia-html-element .button--active{border-color:var(--blue);box-shadow:inset 0 0 0 1px var(--blue)}

/* ---- 5. The capability elements themselves ----
   Only properties Chrome allows on <usermedia>/<camera>/<microphone> are used
   here. Anything outside the allowlist is either corrected or, worse, makes the
   element refuse clicks — so this stays deliberately plain. */
.has-usermedia #usermedia-html-element usermedia:not(#playgroundUserMedia),
.has-camera #usermedia-html-element camera,
.has-microphone #usermedia-html-element microphone{color:#ffffff;background-color:var(--brand);border:2px solid var(--brand-dark);border-radius:6px;font-size:1rem;font-weight:600;padding:.5rem 1.1rem}
.has-usermedia #usermedia-html-element usermedia:not(#playgroundUserMedia):granted,
.has-camera #usermedia-html-element camera:granted,
.has-microphone #usermedia-html-element microphone:granted{background-color:var(--ok);border-color:#17603b}
#usermedia-html-element .element-stage{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:1rem;border:1px dashed var(--line);border-radius:6px;background:var(--panel);margin:0 0 1rem;min-height:4.5rem}
#usermedia-html-element .element-stage--playground{position:relative;margin:0;overflow:hidden}
#usermedia-html-element .occluder{position:absolute;inset:.75rem;background:rgba(0,90,156,.75);border-radius:4px;color:#fff;font-size:.8rem;display:flex;align-items:center;justify-content:center;text-align:center;padding:.5rem}

/* ---- 6. Capture preview ---- */
#usermedia-html-element .capture{display:grid;grid-template-columns:minmax(0,1fr);gap:1rem;margin-bottom:20px}
@media (min-width:48rem){
  #usermedia-html-element .capture{grid-template-columns:minmax(0,22rem) minmax(0,1fr);align-items:start}
}
#usermedia-html-element #videoContainer{position:relative;border-radius:6px;overflow:hidden;background:#222;aspect-ratio:4/3}
#usermedia-html-element #videoContainer.is-audio-only{aspect-ratio:16/5}
#usermedia-html-element video{display:block;width:100%;height:100%;object-fit:contain;background:#222}
#usermedia-html-element .mini-video{border-radius:6px;overflow:hidden;background:#222;aspect-ratio:4/3;margin:.5rem 0}
#usermedia-html-element .audio-only-note{position:absolute;inset:0;display:none;align-items:center;justify-content:center;color:#fff;font-size:.85rem;text-align:center;padding:1rem;margin:0}
#usermedia-html-element #videoContainer.is-audio-only .audio-only-note{display:flex}

/* ---- 7. Status / meter ---- */
#usermedia-html-element .status{display:flex;align-items:center;gap:.5rem;font-size:.9rem;color:var(--muted);margin:0}
#usermedia-html-element .dot{width:.6rem;height:.6rem;border-radius:50%;background:var(--muted);flex:none}
#usermedia-html-element .status.is-live .dot{background:var(--brand);animation:pulse 1.2s ease-in-out infinite}
#usermedia-html-element .status.is-live{color:var(--brand-dark);font-weight:600}
@keyframes pulse{50%{opacity:.25}}
@media (prefers-reduced-motion:reduce){
  #usermedia-html-element .status.is-live .dot{animation:none}
}
#usermedia-html-element .meter{height:.5rem;border-radius:999px;background:var(--line);overflow:hidden}
#usermedia-html-element .meter--tall{height:.75rem;margin:.5rem 0}
#usermedia-html-element .meter>span{display:block;height:100%;width:0%;background:var(--blue);transition:width 80ms linear}

/* ---- 8. Stats ---- */
#usermedia-html-element .stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(6.5rem,1fr));gap:.75rem;list-style:none;padding:0;margin:0}
#usermedia-html-element .stats li{margin:0;border:1px solid var(--line);border-radius:6px;padding:.5rem .65rem;background:var(--panel);list-style:none}
#usermedia-html-element .stats .stat-label{font-size:.7rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
#usermedia-html-element .stats .stat-value{font-variant-numeric:tabular-nums;font-size:1.05rem;font-weight:600;overflow-wrap:anywhere}

/* ---- 9. Support / property tables ---- */
#usermedia-html-element .support{display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));gap:.25rem 1.5rem;margin:0 0 20px;font-size:.88rem}
#usermedia-html-element .support div{display:flex;justify-content:space-between;gap:1rem;padding:.3rem 0;border-bottom:1px solid var(--line)}
#usermedia-html-element .support dt{color:var(--muted)}
#usermedia-html-element .support dd{margin:0;text-align:right;font-weight:600;min-width:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
#usermedia-html-element .support dd.yes{color:var(--ok)}
#usermedia-html-element .support dd.no{color:var(--brand-dark)}
#usermedia-html-element .support dd.partial{color:var(--warn)}

/* ---- 10. Data tables ---- */
#usermedia-html-element .table-scroll{overflow-x:auto;border:1px solid var(--line);border-radius:6px;margin-bottom:20px}
#usermedia-html-element .data-table{border-collapse:collapse;width:100%;font-size:.85rem;min-width:30rem}
#usermedia-html-element .data-table th,#usermedia-html-element .data-table td{text-align:left;vertical-align:top;padding:.45rem .7rem;border-bottom:1px solid var(--line)}
#usermedia-html-element .data-table thead th{background:var(--panel);font-size:.72rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);white-space:nowrap}
#usermedia-html-element .data-table tbody tr:last-child td{border-bottom:0}
#usermedia-html-element .data-table td.is-corrected{color:var(--warn);font-weight:600}
#usermedia-html-element .data-table td.is-ok{color:var(--ok)}
#usermedia-html-element .data-table code{background:none;border:0;padding:0}
#usermedia-html-element .data-table .why{color:var(--muted);font-size:.72rem;white-space:nowrap}

/* ---- 11. Constraint sanitizer ---- */
#usermedia-html-element .sanitizer{display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));gap:1rem;margin-top:.5rem}
#usermedia-html-element .sanitizer-group{border:1px solid var(--line);border-radius:6px;overflow:hidden}
#usermedia-html-element .sanitizer-group>h4{margin:0;padding:.35rem .7rem;background:var(--panel);border-bottom:1px solid var(--line);font-size:.72rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
#usermedia-html-element .sanitizer-row{display:grid;grid-template-columns:auto 1fr;gap:.5rem;padding:.3rem .7rem;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.76rem;border-bottom:1px solid #ebeef1;align-items:baseline}
#usermedia-html-element .sanitizer-row:last-child{border-bottom:0}
#usermedia-html-element .sanitizer-row .mark{font-weight:700}
#usermedia-html-element .sanitizer-row.is-kept{background:rgba(31,122,77,.07)}
#usermedia-html-element .sanitizer-row.is-kept .mark{color:var(--ok)}
#usermedia-html-element .sanitizer-row.is-dropped{background:rgba(237,52,29,.05)}
#usermedia-html-element .sanitizer-row.is-dropped .mark{color:var(--brand-dark)}
#usermedia-html-element .sanitizer-row .why{color:var(--muted);font-family:system-ui,-apple-system,"Segoe UI",sans-serif;font-size:.76rem}
#usermedia-html-element .sanitizer-empty{padding:.5rem .7rem;color:var(--muted);font-size:.8rem;margin:0}

/* ---- 12. Track list ---- */
#usermedia-html-element .track-list{border:1px solid var(--line);border-radius:6px;background:var(--panel);padding:.5rem .75rem}
#usermedia-html-element .track-list .placeholder{color:var(--muted);font-size:.9rem;margin:0}
#usermedia-html-element .track{padding:.5rem 0;border-top:1px solid var(--line)}
#usermedia-html-element .track:first-child{border-top:0}
#usermedia-html-element .track-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:.5rem;font-size:.9rem}
#usermedia-html-element .track-kind{font-weight:600;text-transform:uppercase;font-size:.7rem;letter-spacing:.04em;color:#fff;background:var(--blue);border-radius:3px;padding:.05rem .35rem}
#usermedia-html-element .track-kind.is-audio{background:var(--brand-dark)}
#usermedia-html-element .track-label{font-weight:600;min-width:0;overflow-wrap:anywhere}
#usermedia-html-element .track-flags{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.3rem}
#usermedia-html-element .flag{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.7rem;border:1px solid var(--line);border-radius:3px;padding:.05rem .3rem;background:#fff;color:var(--muted)}
#usermedia-html-element .flag.is-on{color:var(--ok);border-color:rgba(31,122,77,.4)}
#usermedia-html-element .flag.is-off{color:var(--brand-dark);border-color:rgba(237,52,29,.4)}
#usermedia-html-element .track-settings{margin-top:.35rem;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.74rem;color:var(--muted);overflow-wrap:anywhere}

/* ---- 13. Code blocks ---- */
#usermedia-html-element .code-block{margin:0 0 1rem;padding:.75rem;background:var(--panel);border:1px solid var(--line);border-radius:6px;overflow-x:auto;font-size:.8rem;line-height:1.55}
#usermedia-html-element .code-block code{background:none;border:0;padding:0;font-size:inherit;white-space:pre}
#usermedia-html-element details.json-view{margin-top:.75rem}
#usermedia-html-element details.json-view summary{cursor:pointer;font-size:.85rem;color:var(--muted);margin-bottom:20px}
#usermedia-html-element details.json-view pre{margin:.5rem 0 0;padding:.75rem;background:var(--panel);border:1px solid var(--line);border-radius:6px;max-height:20rem;overflow:auto;font-size:.8rem}

/* ---- 14. Iframes ---- */
#usermedia-html-element .demo-frame{width:100%;height:15rem;border:1px solid var(--line);border-radius:6px;background:#fff}

/* ---- 15. Event log ---- */
#usermedia-html-element .log-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .9rem;margin-bottom:.75rem}
#usermedia-html-element .log-filters{display:flex;flex-wrap:wrap;gap:.75rem;font-size:.82rem}
#usermedia-html-element .log-filters label{display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;white-space:nowrap}
#usermedia-html-element .log-toolbar .spacer{flex:1 1 auto}
#usermedia-html-element .log{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.78rem;line-height:1.5;border:1px solid var(--line);border-radius:6px;background:var(--panel);max-height:24rem;overflow:auto;padding:.4rem 0}
#usermedia-html-element .log-empty{color:var(--muted);padding:.4rem .75rem;margin:0}
#usermedia-html-element .log-row{display:grid;grid-template-columns:auto 4.2rem 1fr;gap:.6rem;padding:.2rem .75rem;border-left:3px solid transparent}
#usermedia-html-element .log-row+.log-row{border-top:1px solid #ebeef1}
#usermedia-html-element .log-time{color:var(--muted);white-space:nowrap}
#usermedia-html-element .log-level{text-transform:uppercase;font-size:.68rem;letter-spacing:.05em;align-self:center;color:var(--muted)}
#usermedia-html-element .log-message{min-width:0;overflow-wrap:anywhere}
#usermedia-html-element .log-detail{grid-column:3;margin:.2rem 0 .1rem;color:var(--muted);white-space:pre-wrap;overflow-wrap:anywhere;font-size:.74rem}
#usermedia-html-element .log-row.level-error{border-left-color:var(--brand);background:rgba(237,52,29,.05)}
#usermedia-html-element .log-row.level-error .log-level,#usermedia-html-element .log-row.level-error .log-message{color:var(--brand-dark)}
#usermedia-html-element .log-row.level-warn{border-left-color:var(--warn);background:rgba(138,97,0,.06)}
#usermedia-html-element .log-row.level-warn .log-level,#usermedia-html-element .log-row.level-warn .log-message{color:var(--warn)}
#usermedia-html-element .log-row.level-info{border-left-color:var(--link)}
#usermedia-html-element .log-row.level-debug .log-message{color:var(--muted)}
#usermedia-html-element .log.hide-error .log-row.level-error,
#usermedia-html-element .log.hide-warn .log-row.level-warn,
#usermedia-html-element .log.hide-info .log-row.level-info,
#usermedia-html-element .log.hide-debug .log-row.level-debug{display:none}

/* ---- 16. Notices ---- */
#usermedia-html-element .notice{border-left:3px solid var(--warn);background:rgba(138,97,0,.06);padding:.75rem 1rem;border-radius:0 6px 6px 0;margin:0 0 1.25rem;font-size:.92rem}
#usermedia-html-element .notice strong{color:var(--warn)}
#usermedia-html-element .notice.notice--error{border-left-color:var(--brand);background:rgba(237,52,29,.06)}
#usermedia-html-element .notice.notice--error strong{color:var(--brand-dark)}
#usermedia-html-element .notice.notice--ok{border-left-color:var(--ok);background:rgba(31,122,77,.06)}
#usermedia-html-element .notice.notice--ok strong{color:var(--ok)}
#usermedia-html-element .notice p:last-child{margin-bottom:0}

/* ---- 17. Responsive ---- */
@media (max-width:30rem){
  #usermedia-html-element .card{padding:.9rem}
  #usermedia-html-element .button{flex:1 1 100%}
  #usermedia-html-element .log-row{grid-template-columns:auto 1fr;gap:.2rem .5rem}
  #usermedia-html-element .log-message,#usermedia-html-element .log-detail{grid-column:1/-1}
}
