/* ============================================================
   Binaural Beats Generator - Pi7
   Scoped under .bb-stage. Generator tool - no upload box.

   One white card, three columns: Goal | Now playing | Settings.
   Clean-up rules:
   - Few visible buttons. Only Play is filled. One-choice settings are
     small dropdowns, not rows of buttons.
   - Goal options are a light list (no box per option), selected row
     gets a soft highlight.
   - Settings read as a list: label left, small control right.
   - Thin dividers instead of coloured panels.
   ============================================================ */

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

.bb-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(190px, 220px) minmax(240px, 280px) minmax(0, 1fr);
  grid-template-areas:
    "presets player side"
    "safety  safety safety";
  row-gap: 16px;
  align-items: stretch;
}
.bb-presets-wrap{ grid-area: presets; padding: 0 18px; }
.bb-player{ grid-area: player; padding: 0 22px; border-left: 1px solid #eef0f6; border-right: 1px solid #eef0f6; }
.bb-side{ grid-area: side; padding: 0 22px; }
.bb-safety{ grid-area: safety; margin: 0 20px !important; padding-top: 12px; border-top: 1px solid #eef0f6; }

.bb-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;
}

.bb-section-label{
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #7a7f95;
}
.bb-hint{
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* ==================== Left: goal list ==================== */
.bb-presets-wrap{ display: flex; flex-direction: column; }
.bb-presets{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bb-preset{
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #2d3150;
  cursor: pointer;
  transition: background 0.15s;
}
.bb-preset svg{
  grid-row: 1 / 3;
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 8px;
  background: #f1f2fa;
  color: var(--pcolor);
  box-sizing: border-box;
  transition: background 0.15s, color 0.15s;
}
.bb-preset-name{ align-self: end; font-size: 15px; font-weight: 600; line-height: 1.25; }
.bb-preset-sub{ align-self: start; font-size: 12px; color: #7a7f95; line-height: 1.3; }
.bb-preset:hover{ background: #f7f8fc; }
.bb-preset:focus-visible{ outline: 2px solid #8a90d9; outline-offset: 1px; }
.bb-preset.selected{ background: #eff0fb; }
.bb-preset.selected svg{ background: var(--pcolor); color: #fff; }
.bb-preset.selected .bb-preset-name{ color: var(--pcolor); font-weight: 700; }
.bb-preset-desc{
  margin: 14px 2px 0;
  font-size: 14px;
  line-height: 1.55;
  color: #4a4f6a;
}

/* ==================== Centre: now playing ==================== */
.bb-player{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.bb-player-side{
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* The one colour accent. Slow 10 s breathing cycle only - never tied to
   the beat rate (10-40 Hz motion = photosensitive risk). */
.bb-orb{
  position: relative;
  width: 136px;
  height: 136px;
  margin-top: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #b4b8fb 0%, #8187e3 42%, #5c62c7 78%, #4f55b9 100%);
  box-shadow:
    0 0 0 11px rgba(80, 87, 192, 0.06),
    0 0 0 22px rgba(80, 87, 192, 0.03),
    0 12px 26px rgba(68, 73, 166, 0.22);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-shadow: 0 1px 2px rgba(30, 33, 90, 0.3);
  transform: scale(0.94);
  transition: transform 0.8s ease;
}
.bb-orb.playing{ animation: bb-breathe 10s ease-in-out infinite; }
@keyframes bb-breathe{
  0%   { transform: scale(0.88); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(0.88); }
}
@media (prefers-reduced-motion: reduce){
  .bb-orb.playing{ animation: none; transform: scale(0.96); }
}
.bb-orb-label{ font-size: 12px; font-weight: 700; opacity: 0.95; }
.bb-orb-time{
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.bb-orb-band{ font-size: 12px; opacity: 0.92; }

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

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

/* Headphones line - text plus a text-link test, no extra button chrome */
.bb-hp{
  width: 100%;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding-top: 12px;
  border-top: 1px solid #eef0f6;
  font-size: 13px;
  line-height: 1.4;
  color: #4a4f6a;
}
.bb-hp > svg{ width: 16px; height: 16px; flex-shrink: 0; color: #7a7f95; }
.bb-check-status{ color: var(--pcolor); font-weight: 600; text-align: center; }
.bb-check-status:empty{ display: none; }
/* The check message takes the place of the headphones text */
.bb-check-status:not(:empty) + .bb-hp-text{ display: none; }
.bb-check-btn{
  padding: 4px 2px;
  border: none;
  background: none;
  color: var(--pcolor);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  white-space: nowrap;
}
.bb-check-btn:hover{ color: #2b2f78; }

/* ==================== Right: settings list ==================== */
.bb-side{
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.bb-settings{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bb-row{
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
}
.bb-row-label{
  flex: 0 0 136px;
  font-size: 14px;
  font-weight: 600;
  color: #2d3150;
}
.bb-row input[type="range"]{ flex: 1; min-width: 60px; margin: 0; accent-color: var(--pcolor); }
.bb-value{
  min-width: 40px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: #4a4f6a;
  font-variant-numeric: tabular-nums;
}
.bb-value-wide{ min-width: 112px; }
.bb-disabled{ opacity: 0.4; }

/* Compact dropdown with a drawn chevron */
.bb-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;
}
.bb-select:hover{ border-color: #c9ccf0; }
.bb-select:focus-visible{ outline: none; border-color: var(--pcolor); box-shadow: 0 0 0 3px rgba(68, 73, 166, 0.15); }

/* Advanced - quiet text toggle */
.bb-advanced{ margin-top: 2px; }
.bb-advanced summary{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--pcolor);
  padding: 2px 0;
}
.bb-advanced summary::-webkit-details-marker{ display: none; }
.bb-advanced summary::before{
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  margin-right: 2px;
}
.bb-advanced[open] summary::before{ transform: rotate(45deg); }
.bb-advanced summary:hover{ text-decoration: underline; }
.bb-advanced-body{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bb-adv-row{
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.bb-adv-row label{ min-width: 76px; font-weight: 600; color: #2d3150; }
.bb-adv-row input[type="range"]{ flex: 1; min-width: 0; margin: 0; accent-color: var(--pcolor); }

/* Save as MP3: same card, a divider above it */
.bb-download{
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #eef0f6;
}
.bb-download .bb-section-label{ margin-bottom: 0; }
.bb-make-btn{
  flex-shrink: 0;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--pcolor);
  background: #fff;
  color: var(--pcolor);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.bb-make-btn:hover:not(:disabled){ background: var(--pcolor); color: #fff; }
.bb-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: bb-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes bb-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;
  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;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

/* ==================== Article hero image ==================== */
.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);
}

/* ==================== Article tables (content pass) ==================== */
.articlesec table{
  width: 100%;
  border-collapse: collapse;
  margin: 18px 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; }
/* Tables scroll sideways inside their own box if a phone is too narrow */
.bb-table-wrap{ overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 18px 0; }
.bb-table-wrap table{ margin: 0; }
@media screen and (max-width: 760px){
  .articlesec th{ padding: 10px 10px; font-size: 13px; }
  .articlesec td{ padding: 9px 10px; font-size: 14px; }
}

/* ==================== Tablet / narrow desktop ==================== */
@media screen and (max-width: 1100px){
  .bb-card{
    grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
    grid-template-areas:
      "presets player"
      "side    side"
      "safety  safety";
  }
  .bb-player{ border-right: none; }
  .bb-side{
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px 28px;
    align-items: start;
    margin: 0 20px;
    padding: 16px 0 0;
    border-top: 1px solid #eef0f6;
  }
  .bb-download{ margin-top: 0; padding-top: 0; border-top: none; }
  .bb-row-label{ flex-basis: 120px; }
  .bb-download .bb-row{ gap: 10px; }
  .bb-download .bb-row-label{ flex-basis: auto; }
  .bb-download .bb-select{ min-width: 110px; }
  .bb-make-btn{ padding: 0 12px; }
}

/* ==================== Phones: one column ==================== */
@media screen and (max-width: 760px){
  .bb-stage{ padding: 4px 4px; }
  .bb-card{
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "presets"
      "player"
      "side"
      "safety";
    padding: 14px 0 12px;
    row-gap: 16px;
    border-radius: 14px;
  }
  .bb-presets-wrap{ padding: 0 12px; }
  .bb-side{ display: flex; align-items: stretch; margin: 0 14px; padding: 16px 0 0; border-top: 1px solid #eef0f6; }
  .bb-download .bb-row-label{ flex-basis: auto; }
  .bb-download .bb-select{ min-width: 0; }
  .bb-download{ margin-top: 0; padding-top: 16px; border-top: 1px solid #eef0f6; }
  .bb-safety{ margin: 0 14px !important; }

  /* Goal: 2 x 2 compact rows, icon left of name */
  .bb-presets{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .bb-preset{ min-height: 52px; padding: 7px 8px; column-gap: 10px; background: #f7f8fc; }
  .bb-preset.selected{ background: #eff0fb; box-shadow: 0 0 0 1.5px var(--pcolor) inset; }
  .bb-preset-desc{ margin-top: 10px; }

  /* Player: orb left, Play + volume right, headphones line below */
  .bb-player{
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    row-gap: 12px;
    margin: 0 14px;
    padding: 16px 0 0;
    border-left: none;
    border-right: none;
    border-top: 1px solid #eef0f6;
  }
  .bb-orb{ width: 100px; height: 100px; margin: 4px 0 4px 16px; }   /* room for the glow rings */
  .bb-orb-time{ font-size: 20px; }
  .bb-orb-label{ font-size: 11px; }
  .bb-orb-band{ font-size: 11px; }
  .bb-player-side{ align-items: stretch; gap: 10px; }
  .bb-play-btn{ width: 100%; min-height: 48px; }
  .bb-vol{ max-width: none; }
  .bb-hp{ grid-column: 1 / -1; margin-top: 0; }
  .bb-check-btn{ min-height: 44px; }

  .bb-row{ min-height: 44px; }
  .bb-row-label{ flex-basis: 118px; font-size: 14px; }
  .bb-select{ height: 44px; }
  .bb-make-btn{ height: 44px; }
}
