/* Smartlinks — minimal, self-hosted, no external assets, no webfonts. */

:root {
  --bg: #ffffff;
  --fg: #111214;
  --muted: #6b7075;
  --line: #e6e7e9;
  --btn-bg: #ffffff;
  --btn-fg: #111214;
  --btn-hover-bg: #111214;
  --btn-hover-fg: #ffffff;
  --accent: #111214;
  --radius: 14px;
  --maxw: 420px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e10;
    --fg: #f2f3f5;
    --muted: #9aa0a6;
    --line: #23262b;
    --btn-bg: #17181b;
    --btn-fg: #f2f3f5;
    --btn-hover-bg: #f2f3f5;
    --btn-hover-fg: #0d0e10;
    --accent: #f2f3f5;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

a { color: inherit; }

/* ------------------------------------------------------------------ */
/* Release (smartlink) page                                            */
/* ------------------------------------------------------------------ */
.link-card {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(32px, 8vh, 72px) 0 32px;
  text-align: center;
}

.cover {
  width: min(300px, 76%);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.release-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 26px 0 2px;
}

.release-artist {
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 1.02rem;
}

.dsp-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  width: min(300px, 76%);   /* same width as the artwork (.cover) */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dsp-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 15px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: background .16s ease, color .16s ease, transform .05s ease;
}

.dsp-button:hover {
  background: var(--btn-hover-bg);
  color: var(--btn-hover-fg);
}

.dsp-button:active { transform: scale(.99); }

.dsp-name { letter-spacing: -0.01em; }

.dsp-cta {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

.dsp-button:hover .dsp-cta { opacity: 0.85; }

.dsp-empty {
  color: var(--muted);
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.release-back {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.release-back:hover { color: var(--fg); }
.release-back span { font-size: 1rem; line-height: 1; }

/* ------------------------------------------------------------------ */
/* Index (release gallery)                                             */
/* ------------------------------------------------------------------ */
.index-wrap {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(40px, 9vh, 90px) 0 40px;
}

/* Off-screen but present for search engines and screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ */
/* Legal pages (privacy policy)                                        */
/* ------------------------------------------------------------------ */
.legal {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 0 32px;
  line-height: 1.65;
}
.legal .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 28px;
}
.legal .back:hover { color: var(--fg); }
.legal h1 { font-size: 1.7rem; letter-spacing: -0.02em; margin: 0 0 6px; }
.legal .updated { color: var(--muted); font-size: 0.85rem; margin: 0 0 8px; }
.legal h2 { font-size: 1.15rem; margin: 34px 0 8px; }
.legal h3 { font-size: 1rem; margin: 22px 0 6px; }
.legal p { margin: 0 0 12px; }
.legal ul { margin: 0 0 12px; padding-left: 22px; }
.legal li { margin: 3px 0; }
.legal address { font-style: normal; margin: 0 0 12px; color: var(--fg); }
.legal a { text-decoration: underline; text-underline-offset: 2px; }

.release-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 26px 20px;
}

.release-grid a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  gap: 8px;
  text-align: center;
}

.grid-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
  transition: transform .18s ease;
}
.release-grid a:hover .grid-cover { transform: translateY(-3px); }

.grid-title { font-weight: 650; font-size: 0.98rem; }
.grid-artist { color: var(--muted); font-size: 0.86rem; margin-top: -4px; }

.empty { color: var(--muted); text-align: center; }
.notfound { display: flex; align-items: center; justify-content: center; }
.text-link { color: var(--muted); text-decoration: none; }
.text-link:hover { color: var(--fg); }

/* ------------------------------------------------------------------ */
/* Footer                                                              */
/* ------------------------------------------------------------------ */
.site-footer {
  text-align: center;
  padding: 28px 0 34px;
  color: var(--muted);
  font-size: 0.82rem;
}
.site-footer nav a { color: var(--muted); text-decoration: none; }
.site-footer nav a:hover { color: var(--fg); text-decoration: underline; }
.site-footer nav span { margin: 0 8px; opacity: 0.5; }
.fineprint { margin: 8px 0 0; opacity: 0.8; }

/* ------------------------------------------------------------------ */
/* Admin                                                               */
/* ------------------------------------------------------------------ */
.page-admin { padding: 0 16px; }
.admin-wrap { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 34px 0; }

.admin-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.admin-header h1 { font-size: 1.35rem; margin: 0; }
.admin-nav { display: flex; gap: 16px; align-items: baseline; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
  background: var(--btn-bg);
}
.card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 6px;
}
.card-head h2 { margin: 0; }
.sort-form { display: flex; align-items: center; gap: 8px; }
.sort-form select { width: auto; padding: 7px 11px; font-size: 0.85rem; }
.card h3 { margin: 22px 0 4px; font-size: 0.95rem; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 0 0 14px; }
.hint.src { word-break: break-all; margin-top: 14px; }
.opt, .count, .dsp-count { color: var(--muted); font-weight: 400; }
.count { font-size: 0.85rem; margin-left: 6px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1 1 200px; }
.narrow { flex: 0 0 90px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; color: var(--muted); font-weight: 600; }

input[type="text"], input[type="url"], input[type="number"], select {
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--btn-fg);
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.primary:hover { opacity: 0.9; }
.btn.small { padding: 7px 13px; font-size: 0.82rem; }
.btn.danger:hover { border-color: #d33; color: #d33; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 0.9rem; }
.flash.ok { background: rgba(40, 160, 90, 0.12); color: #1f7a48; }
.flash.err { background: rgba(210, 60, 60, 0.12); color: #b02a2a; }

.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.admin-list li {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.admin-list li:first-child { border-top: none; }
.admin-list .drag-handle {
  flex: 0 0 auto; cursor: grab; color: var(--muted); font-size: 1.15rem;
  line-height: 1; user-select: none; padding: 6px 2px; border-radius: 6px;
  touch-action: none; align-self: center;
}
.admin-list .drag-handle:hover { color: var(--fg); background: var(--line); }
.admin-list .drag-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.admin-list li.dragging {
  background: var(--btn-bg); border-radius: 10px; border-top-color: transparent;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22); position: relative; z-index: 2;
}
.admin-list li.dragging .drag-handle { cursor: grabbing; }

/* Smooth reordering: neighbours slide, the floating row tracks the pointer
   1:1 (no transition), and text can't be selected mid-drag. */
.admin-list > li, .link-editor > li {
  transition: transform 160ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
.admin-list > li.dragging, .link-editor > li.dragging {
  transition: none; will-change: transform;
}
.admin-list.reordering, .link-editor.reordering { user-select: none; }
@media (prefers-reduced-motion: reduce) {
  .admin-list > li, .link-editor > li { transition: none; }
}

.reorder-form { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.reorder-form[hidden] { display: none; }
.reorder-hint { color: var(--muted); font-size: 0.82rem; }
.mini-cover { border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.admin-list-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.admin-list-meta strong { font-size: 0.95rem; }
.admin-list-meta span { color: var(--muted); font-size: 0.82rem; }
.admin-list-meta code { font-size: 0.8rem; color: var(--muted); }
.admin-list-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.admin-list-actions form { margin: 0; }

.sound-help {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-top: 14px; line-height: 1.55;
}
.sound-help code { user-select: all; }
.sound-help .btn { vertical-align: baseline; }

.edit-grid { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
.preview { display: flex; flex-direction: column; gap: 12px; text-align: center; }
.preview .cover { width: 100%; box-shadow: none; }
.preview form { margin: 0; }

.artwork-form { display: flex; flex-direction: column; gap: 10px; }
.artwork-preview { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.artwork-preview[hidden] { display: none; }
.artwork-canvas {
  width: 100%; max-width: 180px; height: auto;
  border-radius: var(--radius); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.artwork-actions { display: flex; gap: 8px; justify-content: center; }
.artwork-form .hint { margin: 0; }

.link-editor { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-editor li { display: flex; align-items: center; gap: 10px; }
.link-editor .drag-handle {
  flex: 0 0 auto; cursor: grab; color: var(--muted); font-size: 1.15rem;
  line-height: 1; user-select: none; padding: 6px 4px; border-radius: 6px;
  touch-action: none;
}
.link-editor .drag-handle:hover { color: var(--fg); background: var(--line); }
.link-editor .drag-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.link-editor li.dragging {
  background: var(--btn-bg);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  position: relative; z-index: 2;
}
.link-editor li.dragging .drag-handle { cursor: grabbing; }
.link-editor .chk { padding: 0; }
.link-editor .chk input { width: auto; }
.link-editor .link-label { flex: 0 0 108px; font-size: 0.85rem; font-weight: 600; color: var(--fg); }
.link-editor .profile-tag {
  flex: 0 0 auto; font-size: 0.64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 7px;
}
.link-editor .url { flex: 1; }
.add-platform { align-items: center; }
.add-platform .new-label { flex: 0 0 150px; }
.add-platform .new-label[hidden] { display: none; }
.narrow-select { flex: 0 0 150px; }

@media (max-width: 620px) {
  .edit-grid { grid-template-columns: 1fr; }
  .link-editor li { flex-wrap: wrap; }
  .link-editor .link-label { flex-basis: auto; }
  .link-editor .url { flex-basis: 100%; }
  .admin-list li { flex-wrap: wrap; }
}
