/* Create By Asking: classroom noise meter. Loaded after style.css, tools.css and family.css. */

#noise-tool { scroll-margin-top: 84px; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; gap: 22px 28px; --zone: #5BD48F; }
#noise-tool[data-zone="near"] { --zone: #FFB04D; }
#noise-tool[data-zone="over"] { --zone: #FF6B5E; }
.noise > * { min-width: 0; }
.nm-main { display: grid; gap: 12px; }
.nm-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }

/* the stage: balls, traffic light or meter */
.nm-stage { position: relative; height: clamp(300px, 42vw, 440px); border-radius: 14px; background: rgba(255, 255, 255, 0.03); overflow: hidden; }
.nm-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.nm-light { position: absolute; inset: 0; display: grid; place-items: center; }
.nm-light-box { height: 88%; aspect-ratio: 0.42; background: #0B061C; border-radius: 999px; padding: 6% 0; display: grid; grid-template-rows: repeat(3, 1fr); justify-items: center; align-items: center; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.07); }
.nm-light-box i { width: 72%; aspect-ratio: 1; border-radius: 50%; transition: background 0.2s, box-shadow 0.2s; }
.nm-light-box .r { background: #3A1820; }
.nm-light-box .a { background: #3A2C14; }
.nm-light-box .g { background: #133224; }
.nm-light[data-on="over"] .r { background: #FF4D4D; box-shadow: 0 0 40px rgba(255, 77, 77, 0.6); }
.nm-light[data-on="near"] .a { background: #FFB04D; box-shadow: 0 0 40px rgba(255, 176, 77, 0.55); }
.nm-light[data-on="ok"] .g { background: #4FD98A; box-shadow: 0 0 40px rgba(79, 217, 138, 0.5); }
.noise:not(.is-live) .nm-light i { background-color: #1B1433; box-shadow: none; }
.nm-meter { position: absolute; inset: 0; display: grid; align-content: center; padding: 0 clamp(16px, 5vw, 48px); gap: 10px; }
.nm-bar { position: relative; height: clamp(56px, 12vw, 120px); border-radius: 18px; background: rgba(255, 255, 255, 0.08); }
.nm-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 18px; background: var(--zone); transition: background 0.2s; }
.nm-bar-line { position: absolute; top: -10px; bottom: -10px; width: 4px; margin-left: -2px; border-radius: 2px; background: #fff; }
.nm-scale { display: flex; justify-content: space-between; font: 600 0.75rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #A597CC; }

/* start, error and "Shh" layers */
.nm-layer { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 20px; text-align: center; background: rgba(15, 8, 39, 0.82); z-index: 2; }
.nm-layer p { margin: 0; max-width: 36em; color: #CBBFE8; font-size: var(--step--1); }
.nm-layer strong { color: #fff; font: 700 var(--step-1)/1.2 var(--display); }
.nm-start .btn { font-size: 1.05rem; padding: 14px 22px; }
.nm-private { display: flex; gap: 8px; align-items: flex-start; text-align: left; max-width: 30em; }
.nm-private svg { flex: none; width: 18px; height: 18px; margin-top: 2px; stroke: #5BD48F; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nm-error strong { color: #FFC93C; }
.nm-shh { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; pointer-events: none; background: rgba(15, 8, 39, 0.55); }
.nm-shh span { font: 400 clamp(3.4rem, 14vw, 9rem)/1 Shrikhand, var(--display); color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.45); animation: nm-shh 0.5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes nm-shh { from { transform: scale(0.7); opacity: 0; } }

/* status: word, quiet time, stars */
.nm-status { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; align-items: center; }
.nm-word { font: 800 clamp(1.4rem, 4vw, 2rem)/1.1 var(--display); color: var(--zone); transition: color 0.15s; }
.noise:not(.is-live) .nm-word { color: #A597CC; }
.nm-quiet { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nm-quiet .score { padding: 8px 12px; min-width: 98px; }
.nm-quiet .score strong { font-size: 1.5rem; }
.nm-quiet .nm-stars { display: flex; align-items: center; gap: 2px; min-height: 1.1em; color: #FFC93C; font-size: 1.5rem; flex-wrap: wrap; }
.nm-stars i.none { color: rgba(255, 255, 255, 0.2); animation: none; }
.nm-stars em { font-style: normal; }
.nm-stars [data-stars] { display: flex; gap: 2px; }
.nm-stars i { font-style: normal; animation: nm-star 0.5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes nm-star { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.nm-stars [data-star-count] { font: 600 0.85rem/1 var(--mono); color: #FFC93C; margin-left: 4px; }
.nm-small { border: 0; background: none; padding: 0; color: #A597CC; font: 500 0.78rem/1 var(--body); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.nm-small:hover { color: #fff; }

/* settings */
.nm-side { display: grid; gap: 16px; align-content: start; }
.nm-side .f-row > span { flex-basis: 100%; margin-bottom: 2px; }
.nm-range { display: grid; gap: 6px; }
.nm-range > div { display: flex; justify-content: space-between; font-size: var(--step--1); color: #CBBFE8; }
.nm-range output { color: #fff; font: 600 0.85rem/1.4 var(--mono); }
.tool-shell .nm-range input { width: 100%; padding: 0; background: none; accent-color: #FFC93C; height: 28px; }
.nm-range small { color: #A597CC; font-size: 0.75rem; }
.nm-check { display: flex !important; align-items: center; gap: 10px !important; cursor: pointer; color: #F2ECFF !important; }
.nm-check input { width: 18px; height: 18px; accent-color: #FFC93C; padding: 0; margin: 0; }
.noise > .tool-note { grid-column: 1 / -1; margin: 0; }

/* full screen for the board (native, or a fixed overlay where phones don't support it) */
#noise-tool.is-full { position: fixed; inset: 0; z-index: 1000; border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding: 16px; }
.noise.is-full .nm-side, .noise.is-full > .tool-note { display: none; }
.noise.is-full .nm-main { grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
.noise.is-full .nm-stage { height: auto; min-height: 200px; }
.noise.is-full .nm-word { font-size: clamp(1.8rem, 5vw, 3.2rem); }
.noise.is-full .nm-quiet .score strong { font-size: 2.2rem; }
.noise.is-full .nm-quiet .nm-stars { font-size: 2.2rem; }
.noise:fullscreen { width: 100%; height: 100%; }
html.nm-lock, html.nm-lock body { overflow: hidden; }

@media (max-width: 860px) {
  #noise-tool { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .nm-status { grid-template-columns: minmax(0, 1fr); }
  .nm-quiet { justify-content: flex-start; }
  .nm-light-box { height: 84%; }
}
@media (prefers-reduced-motion: reduce) {
  .nm-shh span, .nm-stars i { animation: none; }
}
