/* ═══════════════════════════════════════════════════════════════
   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; }
button { -webkit-appearance: none; appearance: none; }

/* ── 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);
}

/* ── Light theme overrides ──────────────────────────────────── */
html[data-theme="light"] {
  --bg0:    #f5f1e8;
  --bg1:    #ece7db;
  --ink:    #1c1724;
  --muted:  #6b6278;
  --dim:    #9a93a7;
  --brass:  #9a6b1a;
  --ember:  #c41e3a;
  --card:   #f0ebe0;
  --card2:  #e8e2d5;
  --stroke: rgba(154,107,26,.22);
  --stroke2:rgba(0,0,0,.08);
  --shadow: 0 20px 60px rgba(0,0,0,.12);
}
html[data-theme="light"] .grain { opacity: 0; }
html[data-theme="light"] select option { background: #ece7db; color: #1c1724; }
html[data-theme="light"] header {
  background: rgba(245,241,232,.88);
  border-bottom-color: rgba(154,107,26,.15);
}
html[data-theme="light"] .profile-drop {
  background: #f0ebe0;
  border-color: rgba(154,107,26,.18);
}
html[data-theme="light"] .profile-drop a { color: #1c1724; }
html[data-theme="light"] .profile-drop a:hover { background: rgba(154,107,26,.08); }
html[data-theme="light"] .drop-divider { border-top-color: rgba(0,0,0,.08); }
html[data-theme="light"] .auth-area .name { color: #2d2438; }
html[data-theme="light"] select,
html[data-theme="light"] input[type="number"] {
  background: #fff;
  border-color: rgba(154,107,26,.45);
  color: #1c1724;
}
html[data-theme="light"] select:focus,
html[data-theme="light"] input[type="number"]:focus {
  border-color: rgba(154,107,26,.75);
  box-shadow: 0 0 0 4px rgba(154,107,26,.12);
}

/* ── 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; }
.profile-drop .theme-toggle-btn {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  padding: 10px 16px; color: var(--ink); font: inherit;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  text-decoration: none; transition: background .12s;
}
.profile-drop .theme-toggle-btn:hover { background: rgba(232,184,109,.08); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  -webkit-appearance: none;
  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-stop {
  border: 1px solid var(--stroke2);
  background: rgba(255,255,255,.03);
  color: var(--muted);
}
.btn-stop:not(:disabled) {
  border-color: rgba(233,69,96,.45);
  background: rgba(233,69,96,.06);
  color: var(--ember);
}
.btn-stop:not(:disabled):hover {
  border-color: rgba(233,69,96,.65);
  background: rgba(233,69,96,.12);
}

.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);
}
select option {
  background: #0b0f22;
  color: #efe9dc;
}

/* ── 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);
}

/* ── Library sidebar shared items ───────────────────────────── */
.comp-item {
  position: relative; padding: 10px 36px 10px 16px; cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .10s, border-color .10s;
  display: flex; flex-direction: column; gap: 3px;
}
.comp-item:hover { background: rgba(255,255,255,.04); }
.comp-item.active { border-left-color: var(--brass); background: rgba(232,184,109,.06); }
.comp-name { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-date { font-size: 10px; color: var(--dim); }
.comp-del {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--dim); font-size: 14px; line-height: 1;
  padding: 3px 5px; border-radius: 4px;
  opacity: 0; transition: opacity .10s, color .10s, background .10s;
}
.comp-item:hover .comp-del { opacity: 1; }
.comp-del:hover { color: var(--ember); background: rgba(233,69,96,.12); }
.section-divider {
  padding: 12px 16px 6px;
  font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--brass);
  border-top: 1px solid rgba(255,255,255,.06);
  margin-top: 4px;
}
.section-divider:first-child { border-top: none; margin-top: 0; }
.comp-loading { padding: 12px 14px; font-size: 11px; color: var(--dim); }

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

/* ── Content tabs (Notation | Files) ────────────────── */
.content-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--stroke);
  padding: 0 20px;
  background: var(--bg1);
  flex-shrink: 0;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  letter-spacing: .08em;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.tab-active { color: var(--brass); border-bottom-color: var(--brass); }

/* ── Notation toolbar ────────────────────────────────── */
.notation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  border-bottom: 1px solid var(--stroke);
  background: var(--bg1);
  flex-shrink: 0;
  gap: 12px;
}
.notation-toolbar-left  { display: flex; align-items: center; gap: 10px; }
.notation-toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ── File grid & cards ───────────────────────────────── */
.files-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.file-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.file-card-del {
  margin-left: auto;
  padding: 4px 6px; font-size: 13px;
  background: none; border: none;
  color: var(--ember);
  cursor: pointer;
  display: flex; align-items: center;
}
.file-card-icon { font-size: 24px; line-height: 1; }
.file-card-name { font-size: 12px; color: var(--ink); word-break: break-all; }
.file-card-meta { font-size: 11px; color: var(--muted); }
.file-card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; flex-wrap: wrap; align-items: center; }
.file-card-actions .btn,
.file-card-actions a.btn { font-size: 10px; padding: 4px 8px; letter-spacing: .08em; }
.upload-zone {
  border: 1.5px dashed var(--stroke2);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.upload-zone:hover { border-color: var(--brass); color: var(--ink); }
.upload-zone.drag-over { border-color: var(--brass); color: var(--ink); background: rgba(232,184,109,.04); }
.upload-error { font-size: 12px; color: var(--ember); padding: 4px 0; }
.files-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 0; }
