/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  font-family: Arial, sans-serif;
  margin: 2rem;
  color: #222;
}

a { color: inherit; }

/* ---------- Header ---------- */
.page-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
  text-decoration: none;
}

.brand img {
  width: 80px;
  height: auto;
}

.brand h1 {
  font-size: 1.8rem;
  margin: 0;
}

.view-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tab {
  padding: 8px 14px;
  text-decoration: none;
  border: 1px solid #2d557c;
  border-radius: 3px;
  background: #fff;
  color: #2d557c;
  font-size: 0.95rem;
}

.tab.is-active {
  background: #2d557c;
  color: #fff;
}

.tab:hover:not(.is-active) {
  background: #eaf1f7;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 8px 16px;
  font-size: 1rem;
  cursor: pointer;
  background: #2d557c;
  color: #fff;
  border: none;
  border-radius: 3px;
}

.btn:hover { background: #1b3a56; }

/* ---------- Playlist title + status ---------- */
.playlist-title {
  margin: 0 0 20px;
  font-size: 1.4rem;
  font-weight: normal;
  text-align: center;
  color: #555;
}

.status {
  text-align: center;
  color: #777;
  padding: 2rem;
}

.status.error {
  color: #b00;
}

/* ====================================================
   START PAGE (index.php)
   ==================================================== */
body.start-page {
  text-align: center;
}

.start-header {
  margin-bottom: 30px;
}

.start-header img {
  width: 200px;
  height: auto;
}

.start-header h1 {
  font-size: 2.5rem;
  margin: 0;
}

.playlist-input {
  border: 1px solid #000;
  padding: 15px;
  margin: 20px auto;
  width: 80%;
  max-width: 500px;
  border-radius: 4px;
}

.playlist-input label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
}

.playlist-input input {
  width: 100%;
  padding: 8px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.playlist-input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.playlist-input-row input {
  flex: 1;
  min-width: 0;
}

.input-help {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: #666;
}

@media (max-width: 600px) {
  .playlist-input-row {
    flex-direction: column;
  }

  .playlist-input-row input,
  .playlist-input-row .btn {
    width: 100%;
  }
}

.featured-section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1.4rem;
  margin: 30px 0 15px;
  color: #2d557c;
}

.featured-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 0 auto;
  max-width: 1100px;
}

.playlist-card {
  border: 1px solid #ccc;
  padding: 10px;
  width: 23%;
  border-radius: 5px;
  text-align: center;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.playlist-card h3 {
  margin: 10px 0 5px;
  font-size: 1.1rem;
}

.playlist-card p {
  margin: 5px 0;
  font-size: 0.9rem;
  color: #666;
}

.playlist-card img {
  width: 100%;
  height: auto;
  border-radius: 3px;
  margin-top: 8px;
}

.playlist-card .btn {
  display: inline-block;
  margin-top: 5px;
  padding: 5px 10px;
  text-decoration: none;
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .playlist-card { width: 45%; }
}

@media (max-width: 500px) {
  .playlist-card { width: 90%; }
}

/* --- Instructions / about section on the start page --- */
.instructions {
  max-width: 800px;
  margin: 50px auto 30px;
  padding: 0 20px;
  text-align: left;
  line-height: 1.6;
  color: #333;
}

.instructions .section-title {
  text-align: left;
  margin-top: 30px;
}

.instructions p {
  margin: 0 0 16px;
}

.instructions-list {
  padding-left: 22px;
  margin: 0 0 16px;
}

.instructions-list li {
  margin-bottom: 12px;
}

.instructions .fineprint {
  font-size: 0.9rem;
  color: #666;
  border-top: 1px solid #e2e6ea;
  padding-top: 16px;
  margin-top: 8px;
}

/* ====================================================
   QUIZ VIEW — vertical list with full track details
   ==================================================== */
body[data-view="quiz"] .track {
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 15px;
  border-radius: 4px;
}

body[data-view="quiz"] .track img {
  max-width: 100px;
  max-height: 100px;
}

body[data-view="quiz"] .track-details {
  flex: 1;
}

body[data-view="quiz"] .track-details h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

body[data-view="quiz"] .track-details p {
  margin: 2px 0;
  font-size: 0.95rem;
  color: #555;
}

body[data-view="quiz"] .qr-code {
  margin-left: 20px;
}

body[data-view="quiz"] .track--clickable {
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

body[data-view="quiz"] .track--clickable:hover {
  background: #f5f7fa;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body[data-view="quiz"] .track--clickable:focus {
  outline: 2px solid #2d557c;
  outline-offset: 2px;
}

body[data-view="quiz"] .spotify-song-link {
  display: inline-block;
  margin-top: 6px;
  color: #2d557c;
  text-decoration: underline;
  font-size: 0.9rem;
}

body[data-view="quiz"] .spotify-song-link:hover {
  color: #1b3a56;
}

/* Phones: song image, details and QR code must fit the screen width
   (a 200px QR code next to the text made the page wider than the phone). */
@media (max-width: 600px) {
  body[data-view="quiz"] .track {
    flex-wrap: wrap;
    gap: 10px;
  }

  body[data-view="quiz"] .track img {
    max-width: 64px;
    max-height: 64px;
  }

  body[data-view="quiz"] .track-details {
    flex: 1 1 calc(100% - 80px);
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body[data-view="quiz"] .qr-code {
    margin: 0 auto;
  }

  body[data-view="quiz"] .qr-code canvas {
    width: 160px;
    height: auto;
  }
}

/* ====================================================
   PRINT VIEW — grid of A4-sized printable cards
   ==================================================== */
body[data-view="print"] #content {
  width: 190mm;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1mm;
  align-items: center;
}

body[data-view="print"] .card {
  width: 63mm;
  height: 88mm;
  border: 1px dotted black;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 5mm;
  break-inside: avoid;
}

body[data-view="print"] .card .qr-code {
  width: 80%;
  height: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5mm;
}

body[data-view="print"] .card .card-text {
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.3;
}

/* Detail-card variant (the "back side" cards) */
body[data-view="print"] .card.card--details {
  justify-content: flex-start;
  padding: 4mm;
  border-color: white;
}

body[data-view="print"] .card--details img {
  max-width: 100%;
  max-height: 40mm;
  margin-bottom: 3mm;
}

body[data-view="print"] .card--details h3 {
  margin: 0 0 2mm;
  font-size: 0.95rem;
  text-align: center;
}

body[data-view="print"] .card--details p {
  margin: 1mm 0;
  font-size: 0.85rem;
  text-align: center;
  color: #444;
}

/* Blank pad cards: keep the grid slot but render nothing visible.
   Border is transparent so cutting guides don't appear in empty spots. */
body[data-view="print"] .card.card--blank {
  border-color: transparent;
}

/* Test mode position labels (mode=test). Shown on both front and back to
   help diagnose double-sided alignment by holding a sheet to the light. */
body[data-view="print"] .card-position {
  font-size: 0.7rem;
  color: #b00;
  text-align: center;
  font-family: monospace;
  margin-bottom: 2mm;
}

/* One A4 page rendered for "Download PDF" (built by quiz.js, same grid as #content) */
.pdf-sheet {
  width: 190mm;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1mm;
  align-items: center;
}

/* Force a new printed page after each 18-card block */
body[data-view="print"] .page-break {
  grid-column: 1 / -1;
  height: 0;
  break-before: page;
  page-break-before: always;
}

/* Optional backside alignment offset.
   Use with JS/CSS variables:
   --back-x: 2mm;
   --back-y: -1mm;
*/
body[data-view="print"] .card--back {
  transform: translate(var(--back-x, 0mm), var(--back-y, 0mm));
}

/* Hide chrome when printing */
@media print {
  body { margin: 0; }
  .page-header,
  .playlist-title,
  .playlist-notice,
  .deck-options,
  .share-dialog,
  .site-footer,
  .cookie-banner { display: none !important; }
}

/* Footer with the "Cookie settings" link (rendered by analytics.php) */
.site-footer {
  margin: 40px auto 24px;
  text-align: center;
  font-size: 0.9rem;
}

/* Deck options above the cards: duplicates checkbox + MusicBrainz years */
.deck-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  max-width: 900px;
  margin: 0 auto 16px;
  padding: 0 16px;
}

.deck-options[hidden],
.deck-options [hidden],
.header-actions [hidden] {
  display: none;
}

/* Visitor's own edit of a song name/year (quiz view; not saved) */
button.link-button.track-edit-btn {
  margin-left: 8px;
  font-size: 0.85rem;
}

button.link-button[hidden] {
  display: none;
}

.track-edit-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  background: #f5f8fb;
  border: 1px solid #d7dee6;
  border-radius: 6px;
}

.track-edit-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: #555;
  gap: 2px;
}

.track-edit-form input[name="name"] {
  min-width: 14em;
  padding: 4px 6px;
}

.track-edit-form input[name="year"] {
  width: 5.5em;
  padding: 4px 6px;
}

.track-edit-form .btn,
.track-edit-form button {
  padding: 4px 10px;
  font-size: 0.85rem;
}

.track-edit-form__note {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.8rem;
  color: #777;
}

.deck-options__check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.deck-options__status {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.9rem;
  color: #555;
}

.deck-options .btn:disabled {
  opacity: 0.7;
  cursor: default;
}

/* Notice above the cards, e.g. "showing the first 1000 of 2816 songs" */
.playlist-notice {
  max-width: 760px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #f0d68a;
  border-radius: 6px;
  color: #5c4500;
  text-align: center;
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  background: #fff;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner p {
  margin: 6px 0 0;
  color: #555;
  line-height: 1.4;
}

.cookie-banner__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-secondary {
  background: #fff;
  color: #2d557c;
  border: 1px solid #2d557c;
}

.btn-secondary:hover {
  background: #eaf1f7;
}

@media (max-width: 700px) {
  .cookie-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-banner__actions {
    justify-content: flex-start;
  }
}

button.link-button,
button.link-button:visited {
  appearance: none;
  -webkit-appearance: none;
  display: inline;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  color: #2d557c;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  vertical-align: baseline;
}

button.link-button:hover {
  background: transparent;
  color: #1b3a56;
  text-decoration: underline;
}

button.link-button:focus {
  outline: 2px solid #2d557c;
  outline-offset: 2px;
}

button.link-button:active {
  background: transparent;
}

/* How to play */
.howto-image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px auto 28px;
  max-width: 900px;
}

.howto-image-grid img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 800px) {
  .howto-image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 620px;
  }
}

@media (max-width: 500px) {
  .howto-image-grid {
    grid-template-columns: 1fr;
    max-width: 320px;
  }
}
/* Privacy policy page */
.legal {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 24px;
  line-height: 1.55;
}

.legal h2 {
  margin-bottom: 4px;
}

.legal h3 {
  margin-top: 28px;
  color: #2d557c;
}

.legal h4 {
  margin: 18px 0 4px;
}

.legal__updated {
  margin-top: 0;
  color: #777;
  font-size: 0.9rem;
}

.legal__summary {
  padding: 12px 14px;
  background: #eaf1f7;
  border-left: 4px solid #2d557c;
  border-radius: 4px;
}

.legal code {
  font-size: 0.9em;
}

.site-footer a {
  color: #2d557c;
}

/* Share dialog (quiz page) */
.share-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px 22px 18px;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.share-dialog::backdrop {
  background: rgba(20, 35, 50, 0.55);
}

.share-dialog h2 {
  margin: 0 0 4px;
  color: #2d557c;
}

.share-dialog__close {
  position: absolute;
  top: 10px;
  right: 14px;
  margin: 0;
}

.share-dialog__close button {
  font-size: 1.2rem;
  text-decoration: none;
}

.share-dialog__name {
  margin: 0 0 12px;
  color: #555;
}

.share-dialog__qr {
  display: flex;
  justify-content: center;
  min-height: 240px;
}

.share-dialog__qr canvas,
.share-dialog__qr svg {
  width: 240px;
  max-width: 100%;
  height: auto;
}

.share-dialog__hint {
  margin: 8px 0 14px;
  font-size: 0.85rem;
  color: #666;
}

.share-dialog__link {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.share-dialog__link input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 0.85rem;
  border: 1px solid #ccd5de;
  border-radius: 4px;
}

.share-dialog__link .btn-small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.share-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.share-dialog__actions [hidden] {
  display: none;
}

.share-dialog__social {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  font-size: 0.95rem;
}

.share-dialog__social a {
  color: #2d557c;
}

.share-dialog__status {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: #2d557c;
}
