/* =========================================================================
   Web Speech API speech recognition demo — tech-demos/web-speech-api-demo.php
   Loaded after base.css and tech-demos.css.

   Scoped copy of the inline <style> from the Hugo layout
   themes/spydea-hugo/layouts/tech-demos/web-speech-api-demo.html:
   - every rule is prefixed with #web-speech-api-demo
   - the :root tokens live on the wrapper, so base.css keeps its own --ink/--line
   - the global body, h1, h2 and .announcement rules were dropped
   - the buttons relied on Tailwind colour classes; they now take the same
     brand/secondary colours as the <usermedia> demo
   - section 0 neutralises base.css components that share a class name here
     (.card, .status) and the base.css <section>/<p> defaults
   ========================================================================= */

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

/* ---- 1. Typography ---- */
#web-speech-api-demo h3{font-family:var(--body);font-weight:700;color:#005a9c;font-size:140%;line-height:1.25;letter-spacing:.01em;text-transform:uppercase;padding:20px 0}
#web-speech-api-demo ul,#web-speech-api-demo ol{list-style:disc;margin-left:30px}
#web-speech-api-demo p{margin:0 0 1rem}
#web-speech-api-demo a{color:var(--link);text-decoration:none}
#web-speech-api-demo a:hover,#web-speech-api-demo a:focus-visible{color:var(--blue);text-decoration:underline}
#web-speech-api-demo 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}

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

/* ---- 3. Form controls ---- */
#web-speech-api-demo .field{display:flex;flex-direction:column;gap:.3rem;min-width:0}
#web-speech-api-demo .field>label{font-size:.8rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.03em}
#web-speech-api-demo select,#web-speech-api-demo input[type="text"]{width:100%;font:inherit;font-size:.95rem;color:inherit;padding:.5rem .6rem;border:1px solid var(--line);border-radius:5px;background:#fff}
#web-speech-api-demo select:disabled,#web-speech-api-demo input[type="text"]:disabled{background:var(--panel);color:var(--muted)}
#web-speech-api-demo .checkbox{display:flex;align-items:flex-start;gap:.5rem;font-size:.9rem;line-height:1.4}
#web-speech-api-demo .checkbox input{margin:.25rem 0 0;flex:none}
#web-speech-api-demo :where(button,select,input,a):focus-visible{outline:2px solid var(--blue);outline-offset:2px}

/* ---- 4. Buttons ---- */
#web-speech-api-demo .controls{display:flex;flex-wrap:wrap;gap:.5rem}
#web-speech-api-demo .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;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;gap:.4rem}
#web-speech-api-demo .button:hover:not(:disabled){background:var(--brand-dark);border-color:var(--brand-dark)}
#web-speech-api-demo .button:active:not(:disabled){transform:translateY(1px)}
#web-speech-api-demo .button:disabled{pointer-events:none;opacity:.5}
#web-speech-api-demo .button--secondary{background:#fff;color:var(--ink);border-color:var(--line)}
#web-speech-api-demo .button--secondary:hover:not(:disabled){background:var(--panel);border-color:var(--muted);color:var(--ink)}
#web-speech-api-demo .button--small{flex:0 0 auto;min-height:2rem;padding:.25rem .7rem;font-size:.82rem;font-weight:500}

/* ---- 5. Capture ---- */
#web-speech-api-demo .capture{display:grid;grid-template-columns:minmax(0,1fr);gap:1rem}
@media (min-width:48rem){
  #web-speech-api-demo .capture{grid-template-columns:minmax(0,22rem) minmax(0,1fr);align-items:start}
}
#web-speech-api-demo #videoContainer{position:relative;border-radius:6px;overflow:hidden;background:#222;aspect-ratio:4/3}
#web-speech-api-demo #videoContainer.is-audio-only{aspect-ratio:16/5}
#web-speech-api-demo video{display:block;width:100%;height:100%;object-fit:contain;background:#222}
#web-speech-api-demo .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}
#web-speech-api-demo #videoContainer.is-audio-only .audio-only-note{display:flex}
#web-speech-api-demo #subtitles{position:absolute;bottom:.75rem;left:50%;transform:translateX(-50%);width:min(92%,34rem);color:#fff;font-size:.95rem;text-align:center;background-color:rgba(0,0,0,.72);border-radius:4px;padding:.2rem .5rem;min-height:0}
#web-speech-api-demo #subtitles:empty,#web-speech-api-demo #subtitles.is-empty{background:transparent}
#web-speech-api-demo .subtitle-line{margin:0}

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

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

/* ---- 8. Transcript ---- */
#web-speech-api-demo .transcript{border:1px solid var(--line);border-radius:6px;background:var(--panel);padding:.75rem;min-height:6rem;max-height:22rem;overflow-y:auto}
#web-speech-api-demo .transcript .placeholder{color:var(--muted);font-size:.9rem;margin:0}
#web-speech-api-demo .phrase{display:grid;grid-template-columns:auto 1fr auto;gap:.15rem .6rem;align-items:baseline;padding:.35rem 0;border-top:1px solid var(--line)}
#web-speech-api-demo .phrase:first-child{border-top:0}
#web-speech-api-demo .phrase-time,#web-speech-api-demo .phrase-confidence{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.75rem;color:var(--muted);white-space:nowrap}
#web-speech-api-demo .phrase-text{min-width:0}
#web-speech-api-demo .phrase.is-interim .phrase-text{color:var(--muted);font-style:italic}
#web-speech-api-demo .phrase-alts{grid-column:2/-1;font-size:.78rem;color:var(--muted)}
#web-speech-api-demo details.json-view{margin-top:.75rem}
#web-speech-api-demo details.json-view summary{cursor:pointer;font-size:.85rem;color:var(--muted)}
#web-speech-api-demo 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}

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

/* ---- 10. Event log ---- */
#web-speech-api-demo .log-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .9rem;margin-bottom:.75rem}
#web-speech-api-demo .log-filters{display:flex;flex-wrap:wrap;gap:.75rem;font-size:.82rem}
#web-speech-api-demo .log-filters label{display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;white-space:nowrap}
#web-speech-api-demo .log-toolbar .spacer{flex:1 1 auto}
#web-speech-api-demo .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:20rem;overflow:auto;padding:.4rem 0}
#web-speech-api-demo .log-empty{color:var(--muted);padding:.4rem .75rem;margin:0}
#web-speech-api-demo .log-row{display:grid;grid-template-columns:auto 4.2rem 1fr;gap:.6rem;padding:.2rem .75rem;border-left:3px solid transparent}
#web-speech-api-demo .log-row+.log-row{border-top:1px solid #ebeef1}
#web-speech-api-demo .log-time{color:var(--muted);white-space:nowrap}
#web-speech-api-demo .log-level{text-transform:uppercase;font-size:.68rem;letter-spacing:.05em;align-self:center;color:var(--muted)}
#web-speech-api-demo .log-message{min-width:0;overflow-wrap:anywhere}
#web-speech-api-demo .log-detail{grid-column:3;margin:.2rem 0 .1rem;color:var(--muted);white-space:pre-wrap;overflow-wrap:anywhere;font-size:.74rem}
#web-speech-api-demo .log-row.level-error{border-left-color:var(--brand);background:rgba(237,52,29,.05)}
#web-speech-api-demo .log-row.level-error .log-level,#web-speech-api-demo .log-row.level-error .log-message{color:var(--brand-dark)}
#web-speech-api-demo .log-row.level-warn{border-left-color:var(--warn);background:rgba(138,97,0,.06)}
#web-speech-api-demo .log-row.level-warn .log-level,#web-speech-api-demo .log-row.level-warn .log-message{color:var(--warn)}
#web-speech-api-demo .log-row.level-info{border-left-color:var(--link)}
#web-speech-api-demo .log-row.level-debug .log-message{color:var(--muted)}
#web-speech-api-demo .log.hide-error .log-row.level-error,
#web-speech-api-demo .log.hide-warn .log-row.level-warn,
#web-speech-api-demo .log.hide-info .log-row.level-info,
#web-speech-api-demo .log.hide-debug .log-row.level-debug{display:none}

/* ---- 11. Notices, download link ---- */
#web-speech-api-demo .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}
#web-speech-api-demo .notice strong{color:var(--warn)}
#web-speech-api-demo .notice.notice--error{border-left-color:var(--brand);background:rgba(237,52,29,.06)}
#web-speech-api-demo .notice.notice--error strong{color:var(--brand-dark)}
#web-speech-api-demo a#downloadLink{display:inline-block;font-size:.9rem}
#web-speech-api-demo a#downloadLink:empty{display:none}

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