/* ═══════════════════════════════════════════════════════════════
   shared.css — Sargam Player shared styles
   Loaded by: player.html, library.html, composer.html, admin.html
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Root variables ─────────────────────────────────────────── */
:root {
  --bg0:    #070914;
  --bg1:    #0b0f22;
  --ink:    #efe9dc;
  --muted:  #9a93a7;
  --dim:    #5c5870;
  --brass:  #e8b86d;
  --ember:  #e94560;
  --card:   #0c1024;
  --card2:  #0f1633;
  --stroke: rgba(232,184,109,.18);
  --stroke2:rgba(255,255,255,.08);
  --shadow: 0 20px 60px rgba(0,0,0,.45);
}

/* ── Base ───────────────────────────────────────────────────── */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "DM Mono", ui-monospace, Menlo, Monaco, "Cascadia Mono",
               "Segoe UI Mono", "Roboto Mono", monospace;
  background: var(--bg0);
  color: var(--ink);
  overflow-x: hidden;
}

/* ── Grain overlay ──────────────────────────────────────────── */
.grain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(232,184,109,.10), transparent 60%),
    radial-gradient(900px 500px at 110% 10%,  rgba(233,69,96,.10),   transparent 55%),
    radial-gradient(800px 700px at 40% 120%,  rgba(120,170,255,.09), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 30%, rgba(0,0,0,.12));
  filter: saturate(1.05) contrast(1.03);
  opacity: .95;
}
.grain::after {
  content: "";
  position: absolute; inset: -30%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: overlay; opacity: .18; transform: rotate(7deg);
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(7,9,20,.94), rgba(7,9,20,.65));
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  gap: 14px;
}
.leftNav {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
a.back {
  text-decoration: none;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,.10);
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: border-color .12s, transform .12s, color .12s;
}
a.back:hover  { transform: translateY(-1px); border-color: rgba(232,184,109,.30); color: #d7d1c6; }
a.back:active { transform: translateY(0) scale(.99); }

/* ── Brand ──────────────────────────────────────────────────── */
.brand { display: flex; align-items: baseline; gap: 10px; user-select: none; }
.brand .sig {
  font-family: "Cormorant Garamond", serif;
  font-weight: 700; font-size: 20px;
  letter-spacing: .02em;
  color: var(--brass);
  text-shadow: 0 0 50px rgba(232,184,109,.18);
}
.brand .sub {
  font-size: 11px; color: var(--muted);
  letter-spacing: .18em; text-transform: uppercase;
}

/* ── Auth / profile dropdown ────────────────────────────────── */
.auth-area {
  display: flex; align-items: center; gap: 10px;
  min-height: 34px;
}
.auth-area img {
  width: 30px; height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(232,184,109,.22);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.auth-area .name {
  font-size: 12px; color: #d7d1c6;
  max-width: 38vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-wrap { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  padding: 4px 8px 4px 4px; border-radius: 10px;
  color: inherit; font-family: inherit;
  transition: background .12s;
}
.profile-btn:hover { background: rgba(255,255,255,.06); }
.profile-btn .chevron { font-size: 10px; color: var(--muted); transition: transform .15s; }
.profile-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.profile-drop {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 150px;
  background: #0f1326;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  overflow: hidden; z-index: 100;
}
.profile-drop a {
  display: block; padding: 10px 16px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; font-family: inherit;
  transition: background .1s;
}
.profile-drop a:hover { background: rgba(255,255,255,.06); }
.drop-divider { border: none; border-top: 1px solid rgba(255,255,255,.06); margin: 2px 0; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  appearance: none;
  font-family: inherit; font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase;
  padding: 7px 13px; border-radius: 9px; cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
  white-space: nowrap;
}
.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }

.btn-brass {
  border: 1px solid rgba(232,184,109,.35);
  background: linear-gradient(180deg, rgba(232,184,109,.14), rgba(232,184,109,.05));
  color: var(--ink);
}
.btn-brass:hover { border-color: rgba(232,184,109,.55); }

.btn-ghost {
  border: 1px solid var(--stroke2);
  background: rgba(255,255,255,.03);
  color: var(--muted);
}
.btn-ghost:hover { border-color: rgba(255,255,255,.18); color: var(--ink); }

.btn-ember {
  border: 1px solid rgba(233,69,96,.40);
  background: linear-gradient(180deg, rgba(233,69,96,.18), rgba(233,69,96,.07));
  color: var(--ink);
}
.btn-ember:hover { border-color: rgba(233,69,96,.60); }

.btn-stop-style {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--muted);
}
.btn-stop-style:hover { background: rgba(255,255,255,.08); color: var(--ink); }

/* ── Form controls ──────────────────────────────────────────── */
select, input[type="number"] {
  width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  padding: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  -webkit-appearance: none;
  transition: border-color .12s, box-shadow .12s;
}
select:focus, input[type="number"]:focus {
  border-color: rgba(232,184,109,.45);
  box-shadow: 0 0 0 4px rgba(232,184,109,.12);
}

/* ── Performance drawer ─────────────────────────────────────── */
details.drawer {
  border-top: 1px solid rgba(255,255,255,.06);
  padding-top: 10px;
  margin-top: 8px;
}
details.drawer summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
}
details.drawer summary::-webkit-details-marker { display: none; }
.drawerGrid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  padding-bottom: 10px;
}
.field {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* ── Transport ──────────────────────────────────────────────── */
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.transportMeta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}
.timeDisplay {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: .12em;
  white-space: nowrap;
}

/* ── Piano visualization ────────────────────────────────────── */
#piano-container {
  overflow-x: auto;
  overflow-y: hidden;
  line-height: 0;
  padding: 10px 0 4px;
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
#piano-container::-webkit-scrollbar { height: 3px; }
#piano-container::-webkit-scrollbar-track { background: transparent; }
#piano-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }
#piano-canvas { display: block; cursor: default; }

/* ── Lyric display ──────────────────────────────────────────── */
@keyframes lyric-slide-in {
  from { transform: translateX(24px); opacity: .4; }
  to   { transform: translateX(0);    opacity: 1;  }
}
#lyric-display {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.2rem;
  min-height: 2.6rem;
  padding: 6px 0 10px;
}
#lyric-display.lyric-animating { animation: lyric-slide-in .2s cubic-bezier(.25,.46,.45,.94); }
#lyric-display span { white-space: nowrap; }
#lyric-display span:nth-child(1),
#lyric-display span:nth-child(5) { font-size: .85rem; color: var(--muted); }
#lyric-display span:nth-child(2),
#lyric-display span:nth-child(4) { font-size: 1.1rem; color: rgba(215,209,198,.7); }
#lyric-display span:nth-child(3) { font-size: 1.6rem; font-weight: 700; color: var(--ink); letter-spacing: .04em; }

/* ── View toggle (player / newplayer) ───────────────────────── */
.view-toggle {
  display: flex;
  align-self: flex-start;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.view-opt {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  font-family: inherit;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.view-opt:hover { color: var(--ink); }
.view-opt[aria-current="page"] {
  background: rgba(232,184,109,.14);
  color: var(--brass);
  border: 1px solid rgba(232,184,109,.22);
}

/* ── Shared responsive ──────────────────────────────────────── */
@media (max-width: 620px) {
  .top { padding: 12px 14px; }
  .auth-area .name { display: none; }
}
