/* ============================================================
   White Noise Generator - Pi7
   Scoped under .wn-stage. Generator tool - no upload box.

   One white card, two columns: Sounds | Player + Save as MP3.
   - The sound tiles ARE the controls: tap to add or remove, a small
     volume slider shows on each active tile.
   - Only Play is a filled button. Mix, timer and length are dropdowns.
   ============================================================ */

.wn-stage{
  margin: 12px auto 0;
  padding: 6px 12px;
}

.wn-card{
  background: #fff;
  border: 1px solid #e9ebf4;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(34, 37, 90, 0.04), 0 6px 20px rgba(34, 37, 90, 0.05);
  padding: 20px 0 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
  grid-template-areas:
    "sounds side"
    "safety safety";
  row-gap: 16px;
}
.wn-sounds{ grid-area: sounds; padding: 0 22px; min-width: 0; }
.wn-side{
  grid-area: side;
  padding: 0 22px;
  border-left: 1px solid #eef0f6;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.wn-safety{ grid-area: safety; margin: 0 20px !important; padding-top: 12px; border-top: 1px solid #eef0f6; }

.wn-sr-only{
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.wn-section-label{
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #7a7f95;
}
.wn-hint{
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* ==================== Sound tiles ==================== */
.wn-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.wn-tile{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  border: 1px solid #e6e8f2;
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.wn-tile:hover{ border-color: #cfd2ef; }
.wn-tile-btn{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 2px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  color: #2d3150;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
}
.wn-tile-btn:focus-visible{ outline: 2px solid #8a90d9; outline-offset: 2px; }
.wn-ic{
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f1f2fa;
  color: var(--pcolor);
  transition: background 0.15s, color 0.15s;
}
.wn-ic svg{ width: 21px; height: 21px; }
.wn-ic-white{ background: #f2f3f7; color: #5b6275; }
.wn-ic-pink{ background: #fde8ef; color: #c2185b; }
.wn-ic-brown{ background: #f3e9df; color: #8a5a2b; }
.wn-tile-name{ min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wn-tile.on{
  border-color: var(--pcolor);
  background: #f6f7fe;
  box-shadow: 0 0 0 1px var(--pcolor) inset;
}
.wn-tile.on .wn-ic{ background: var(--pcolor); color: #fff; }
.wn-tile.on .wn-tile-name{ color: var(--pcolor); }

/* Slider keeps its space when off, so the grid never jumps */
.wn-tile-vol{ width: 100%; margin: 0; accent-color: var(--pcolor); }
.wn-tile-vol:disabled{ visibility: hidden; }

/* Sound being built for the first time */
.wn-tile.loading .wn-ic{ animation: wn-pulse 0.9s ease-in-out infinite; }
@keyframes wn-pulse{ 50% { opacity: 0.45; } }

/* ==================== Player ==================== */
.wn-player{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wn-now{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f6f7fc;
}
.wn-bars{
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
  flex-shrink: 0;
}
.wn-bars span{
  width: 4px;
  height: 25%;
  border-radius: 2px;
  background: #c4c7ee;
}
.wn-now.playing .wn-bars span{
  background: var(--pcolor);
  animation: wn-bar 1.3s ease-in-out infinite;
}
.wn-now.playing .wn-bars span:nth-child(2){ animation-delay: -0.3s; }
.wn-now.playing .wn-bars span:nth-child(3){ animation-delay: -0.7s; }
.wn-now.playing .wn-bars span:nth-child(4){ animation-delay: -0.15s; }
.wn-now.playing .wn-bars span:nth-child(5){ animation-delay: -0.5s; }
@keyframes wn-bar{
  0%, 100% { height: 25%; }
  50% { height: 95%; }
}
@media (prefers-reduced-motion: reduce){
  .wn-now.playing .wn-bars span{ animation: none; height: 60%; }
  .wn-tile.loading .wn-ic{ animation: none; opacity: 0.6; }
}
.wn-now-text{ display: flex; flex-direction: column; min-width: 0; }
.wn-now-label{
  font-size: 13px;
  font-weight: 600;
  color: #4a4f6a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wn-now-time{
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  color: #2d3150;
  font-variant-numeric: tabular-nums;
}

/* Primary action - the only filled button */
.wn-play-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 10px 24px;
  border: none;
  border-radius: 999px;
  background: var(--pcolor);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(68, 73, 166, 0.25);
  transition: background 0.15s, box-shadow 0.15s;
}
.wn-play-btn:hover{ background: #3a3f96; box-shadow: 0 6px 16px rgba(68, 73, 166, 0.32); }
.wn-play-btn:focus-visible{ outline: 3px solid #b9bdff; outline-offset: 3px; }
.wn-play-btn svg{ width: 15px; height: 15px; flex-shrink: 0; }
.wn-play-btn .wn-ic-pause{ display: none; }
.wn-play-btn.playing{ background: #c2185b; box-shadow: 0 4px 12px rgba(194, 24, 91, 0.25); }
.wn-play-btn.playing:hover{ background: #a3134c; }
.wn-play-btn.playing .wn-ic-play{ display: none; }
.wn-play-btn.playing .wn-ic-pause{ display: block; }

.wn-vol{
  display: flex;
  align-items: center;
  gap: 10px;
  color: #7a7f95;
}
.wn-vol svg{ width: 17px; height: 17px; flex-shrink: 0; }
.wn-vol input[type="range"]{ flex: 1; min-width: 0; margin: 0; accent-color: var(--pcolor); }
.wn-vol-value{
  min-width: 38px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #4a4f6a;
  font-variant-numeric: tabular-nums;
}
.wn-vol.hide{ display: none; }

/* Label left, small control right */
.wn-row{
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
}
.wn-row-label{
  flex: 0 0 96px;
  font-size: 14px;
  font-weight: 600;
  color: #2d3150;
}
.wn-select{
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 34px 0 12px;
  border: 1px solid #e1e3ef;
  border-radius: 8px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%237a7f95' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: #2d3150;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wn-select:hover{ border-color: #c9ccf0; }
.wn-select:focus-visible{ outline: none; border-color: var(--pcolor); box-shadow: 0 0 0 3px rgba(68, 73, 166, 0.15); }

/* ==================== Save as MP3 ==================== */
.wn-download{
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #eef0f6;
}
.wn-download .wn-section-label{ margin-bottom: 0; }
.wn-download .wn-row-label{ flex-basis: auto; }
.wn-make-btn{
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--pcolor);
  background: #fff;
  color: var(--pcolor);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.wn-make-btn:hover:not(:disabled){ background: var(--pcolor); color: #fff; }
.wn-make-btn:disabled{ opacity: 0.5; cursor: not-allowed; }

.processing{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #f6f7fc;
  border-radius: 8px;
  color: var(--pcolor);
  font-size: 13px;
  font-weight: 600;
}
.processing.hide{ display: none; }
.proc-spin{
  width: 16px;
  height: 16px;
  border: 2px solid var(--pcolor);
  border-top-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: wn-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes wn-spin{ to { transform: rotate(360deg); } }
.cancel-btn{
  margin-left: auto;
  padding: 4px 2px;
  border: none;
  background: none;
  color: #b00d44;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.cancel-btn:disabled{ opacity: 0.4; cursor: not-allowed; }

.result-card{
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: #f6f7fc;
  border-radius: 8px;
}
.result-card.hide{ display: none; }
.result-card audio{ width: 100%; height: 38px; }
.result-side{ display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.result-meta{ font-size: 13px; color: #3f4460; font-weight: 600; }
.result-actions{ display: flex; gap: 12px; align-items: center; }
.result-actions .download-btn{
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--pcolor);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.result-actions .download-btn:hover{ background: #3a3f96; }
.result-actions .ctrl-btn{
  padding: 4px 2px;
  border: none;
  background: none;
  color: #4a4f6a;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ==================== Safety line ==================== */
.wn-safety{
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: #7a7f95;
}
.wn-safety svg{ width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }

/* ==================== Article (content pass) ==================== */
.illus{
  margin: 24px 0 36px;
  display: flex;
  justify-content: center;
}
.illus img{
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(68, 73, 166, 0.14);
}
.wn-table-wrap{ overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 18px 0; }
.articlesec table{
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 15px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(68, 73, 166, 0.06);
}
.articlesec thead{ background: var(--pcolor); color: #fff; }
.articlesec th{ text-align: left; padding: 12px 14px; font-weight: 600; font-size: 14px; }
.articlesec td{ padding: 11px 14px; border-top: 1px solid #eef0fa; color: #262626; vertical-align: top; }
.articlesec tbody tr:nth-child(even){ background: #f8f9ff; }

/* ==================== Narrow screens: one column ==================== */
@media screen and (max-width: 900px){
  .wn-card{
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "sounds"
      "side"
      "safety";
  }
  .wn-side{
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px 28px;
    align-items: start;
    margin: 0 22px;
    padding: 16px 0 0;
    border-left: none;
    border-top: 1px solid #eef0f6;
  }
  .wn-download{ margin-top: 0; padding-top: 0; border-top: none; }
}

@media screen and (max-width: 640px){
  .wn-stage{ padding: 4px 4px; }
  .wn-card{ padding: 14px 0 12px; border-radius: 14px; }
  .wn-sounds{ padding: 0 12px; }
  .wn-grid{ gap: 8px; margin-bottom: 14px; }
  /* Icon above the name so all 9 tiles fit three across */
  .wn-tile{ padding: 8px 6px; }
  .wn-tile-btn{
    flex-direction: column;
    gap: 4px;
    min-height: 64px;
    text-align: center;
    font-size: 14px;
  }
  .wn-tile-name{ max-width: 100%; }
  .wn-side{ display: flex; margin: 0 14px; }
  .wn-download{ padding-top: 16px; border-top: 1px solid #eef0f6; }
  .wn-safety{ margin: 0 14px !important; }
  .wn-play-btn{ min-height: 48px; }
  .wn-row{ min-height: 44px; }
  .wn-select{ height: 44px; }
  .wn-make-btn{ height: 44px; }
  .articlesec th{ padding: 10px 10px; font-size: 13px; }
  .articlesec td{ padding: 9px 10px; font-size: 14px; }
}
