/* style.css (SHARED) */

/* ===== Base ===== */
:root{
  --bg:#ffffff;
  --fg:#000000;
  --focus:#005fcc;
  --font:"Helvetica Neue", Helvetica, Arial, sans-serif;
}

*{ box-sizing:border-box; }

html, body{
  height:100%;
}

body{
  margin:0;
  font-family:var(--font);
  background:var(--bg);
  color:var(--fg);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

/* Safer “centered” layout without iOS 100vh weirdness */
.shell{
  width:100%;
  max-width:420px;
  margin:0 auto;
  padding:24px 20px;
  min-height:100svh; /* modern mobile-safe viewport */
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.player .shell{
  max-width:280px;
}

/* ===== Accessibility ===== */
button:focus-visible,
select:focus-visible,
input:focus-visible{
  outline:3px solid var(--focus);
  outline-offset:3px;
}

summary:focus-visible{
  outline:3px solid var(--focus);
  outline-offset:3px;
}

[hidden]{ display:none !important; }

/* Screen-reader only */
.sr-only{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* ===== Typography ===== */
.title-style{
  font-weight:400;
  font-size:2rem;
  text-transform:uppercase;
  letter-spacing:0.3em;
  text-align:center;
  padding-left:0.3em; /* optical centering */
  margin:0 0 2.5rem 0;
  padding-bottom:1rem;
  border-bottom:1px solid var(--fg);
}

/* ===== Launcher ===== */
.launchOnly{
  text-align:center;
}

.hint{
  margin:14px 0 0 0;
  font-size:0.85rem;
  line-height:1.4;
}

/* ===== Form Layout ===== */
#controls{
  display:flex;
  flex-direction:column;
  gap:1.5rem;
}

#songForm{
  display:flex;
  flex-direction:column;
  gap:1.5rem;
}

.form-group{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:12px;
  width:100%;
}

.form-group > label{
  text-align:center;
  font-weight:600;
}

.form-group + .form-group{
  margin-top:24px; /* 24px form gap + 24px = 48px between setting groups */
}

.tone-group{
  gap:4px;
}

.tone-control{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
  flex-shrink:0;
}

/* An 88px touch target surrounds the restrained 64px dial face. */
.tone-dial{
  --tone-angle:-135deg;
  position:relative;
  width:88px;
  height:88px;
}

.tone-dial input[type="range"]{
  position:absolute;
  inset:0;
  z-index:1;
  width:100%;
  height:100%;
  margin:0;
  padding:0;
  border:0;
  -webkit-appearance:none;
  appearance:none;
  opacity:0;
  cursor:ns-resize;
  touch-action:none;
  user-select:none;
  -webkit-user-select:none;
}

.tone-dial-face{
  position:absolute;
  inset:12px;
  border:1px solid var(--fg);
  border-radius:50%;
  pointer-events:none;
}

.tone-dial-marker{
  position:absolute;
  inset:0;
  transform:rotate(var(--tone-angle));
}

.tone-dial-marker::before{
  content:"";
  position:absolute;
  width:2px;
  height:12px;
  top:6px;
  left:calc(50% - 1px);
  background:var(--fg);
}

.tone-dial input:focus-visible + .tone-dial-face{
  outline:3px solid var(--focus);
  outline-offset:4px;
}

.tone-dial input:disabled{
  cursor:not-allowed;
  touch-action:auto;
}

.tone-dial input:disabled + .tone-dial-face,
.tone-control:has(input:disabled) .tone-readout{
  opacity:0.45;
}

.tone-readout{
  align-self:stretch;
  text-align:center;
  font-size:1rem;
  line-height:1.2;
  font-variant-numeric:tabular-nums;
}

label{
  font-size:1rem;
  white-space:nowrap;
}

select{
  width:180px;
  max-width:100%;
  flex-shrink:0;
  margin:0;
  align-self:center;
  background:#fff;
  background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%226%22%20viewBox%3D%220%200%2010%206%22%3E%3Cpath%20d%3D%22M1%201L5%205L9%201%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
  background-size:10px 6px;
  border:1px solid var(--fg);
  color:var(--fg);
  padding:8px 32px;
  font-family:inherit;
  font-size:1rem;
  border-radius:0;
  cursor:pointer;
  text-align:center;
  text-align-last:center;
  -webkit-appearance:none;
  appearance:none;
}

select:disabled{
  opacity:0.45;
  cursor:not-allowed;
}

.form-actions{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:12px;
  margin-top:1.5rem;
}

.form-actions.shared-ready{
  grid-template-columns:minmax(0, 1fr);
  margin-top:0;
}

.shared-ready .btn{
  font-size:0.75rem;
  letter-spacing:0.04em;
  padding:15px 8px;
}

.shared-ready #playNow{
  background:var(--fg);
  color:var(--bg);
}

/* The study selector uses the same compact player and shared stylesheet. */
.studies{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-bottom:2rem;
  font-size:0.85rem;
  line-height:1.5;
}

.studies h2{ margin:0; font-size:1rem; font-weight:400; }
.studies p{ margin:0; }
.studies select{ width:100%; font-size:0.85rem; }
.studies .btn{ padding:12px 8px; font-size:0.75rem; }
.studies label{ font-size:0.85rem; }
.study-return{ margin:0 0 1.5rem; font-size:0.8rem; }
a{ color:inherit; }

/* ===== Buttons ===== */
.btn{
  font-family:inherit;
  font-weight:400;
  font-size:0.9rem;
  text-transform:uppercase;
  letter-spacing:0.1em;
  padding:15px 0;
  cursor:pointer;
  border:1px solid var(--fg);
  border-radius:0;
  background:#fff;
  color:var(--fg);
  transition:opacity 0.12s ease;
}

/* Filled = active/selected */
.btn.filled{
  background:var(--fg);
  color:var(--bg);
}

.btn:hover{ opacity:0.82; }
.btn:disabled{ opacity:0.45; cursor:not-allowed; }

.btn-replay{
  font-size:0.75rem;
  letter-spacing:0.08em;
}

/* Launcher button matches title aesthetic */
.btn-launch{
  font-size:2rem;
  font-weight:400;
  letter-spacing:0.3em;
  text-transform:uppercase;
  padding:25px 50px;
  padding-left:calc(50px + 0.3em);
}

/* ===== Footer ===== */
.revisit{
  border-top:1px solid var(--fg);
  padding-top:1rem;
  font-size:0.85rem;
}

.revisit summary{
  cursor:pointer;
  padding:8px 0;
}

.revisit-content,
.revisit-fallback{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.revisit-content{ margin-top:12px; }

.revisit label{
  font-size:0.85rem;
  white-space:normal;
}

.revisit input{
  width:100%;
  min-width:0;
  padding:10px 8px;
  border:1px solid var(--fg);
  border-radius:0;
  background:var(--bg);
  color:var(--fg);
  font-family:inherit;
  font-size:1rem;
}

.revisit-help{
  margin:0;
  font-size:0.8rem;
  line-height:1.5;
  overflow-wrap:anywhere;
}

.revisit-actions{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.revisit .btn{
  font-size:0.75rem;
  padding:12px 8px;
}

#credits{
  margin-top:1.5rem;
  border-top:1px solid var(--fg);
  padding-top:1.25rem;
  text-align:left;
  font-size:0.7rem;
  line-height:1.5;
  text-transform:uppercase;
  letter-spacing:0.05em;
}

/* ===== Small screens ===== */
@media (max-width:360px){
  .shell{ padding:18px 16px; }
}
