:root {
  --left-width-desktop: 30%;
  --left-width-mobile: 36%;

  --green: #1e7318;
  --logo-green: #004600;
  --beige: #f0e8d0;

  --modern-blue: #2f80ed;
  --modern-blue-soft: #eef6ff;

  --border-light: #dddddd;
  --row-border: #eeeeee;

  --photo-top-space-desktop: 94px;
  --photo-top-space-mobile: 66px;

  --photo-gap-desktop: 12px;
  --photo-gap-mobile: 5px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: #111;
  background: #ffffff;
}

body {
  display: flex;
  flex-direction: row;
  font-size: clamp(12px, 1.05vw, 16px);
}

/* LEFT LIST */

#listeChiens {
  flex: 0 0 var(--left-width-desktop);
  width: var(--left-width-desktop);
  min-width: 210px;
  max-width: 390px;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--border-light);
  padding: 0 8px 12px 8px;
  background: #ffffff;
  z-index: 20;
}

/* TABLE-LIKE ROWS */

.header,
.row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 54px;
  align-items: center;
  column-gap: 4px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 10px 0;
  border-bottom: 2px solid #000;
  background: #f8f8f8;
  font-weight: bold;
}

.row {
  position: relative;
  padding: 6px 0;
  border-bottom: 1px solid var(--row-border);
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.row:hover {
  background: #f7f9fb;
}

.row.is-bon .cell.nom {
  font-weight: 900;
}

.row.active {
  background: var(--modern-blue-soft);
  box-shadow: inset 3px 0 0 var(--modern-blue);
}

.row.active .cell.nom {
  color: var(--modern-blue);
  font-weight: 900;
}

.row.active .cell.annee,
.row.active .cell.photos {
  color: #4d6f91;
}

/* CELLS */

.cell {
  min-width: 0;
  padding: 4px;
  text-decoration: none;
}

.cell.annee,
.cell.photos {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.cell.photos {
  text-align: center;
}

.header .cell {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.row .cell.nom {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.15;
}

/* TOP CONTROLS */

#topControls {
  position: fixed;
  top: 29px;
  left: calc(var(--left-width-desktop) + 22px);
  z-index: 1000;
}

#quizButton {
  display: inline-block;
  padding: 9px 20px;
  background: #ffffff;
  color: var(--logo-green) !important;
  border: 4px double var(--logo-green);
  border-radius: 999px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0.70;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#quizButton:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 1);
}

#logo {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 80px;
  height: auto;
  opacity: 0.85;
  z-index: 1001;
  pointer-events: none;
}

/* PHOTO AREA */

#photoContainer {
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--photo-top-space-desktop) 14px 18px 14px;
  background: #ffffff;
}

#photoContainer.empty {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: #777;
  text-align: center;
  font-size: 14px;
}

.message {
  padding: 16px;
  line-height: 1.4;
}

.error {
  color: #9b0000;
  font-weight: bold;
}

/* PHOTO LAYOUTS */

.photoLayout {
  width: 100%;
}

.photoLayout.single {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.photoLayout.single .photoFrame {
  width: min(100%, 980px);
}

.photoLayout.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--photo-gap-desktop);
  align-items: start;
}

.photoLayout.masonry {
  column-width: 280px;
  column-gap: var(--photo-gap-desktop);
}

.photoLayout.masonry .photoFrame {
  display: inline-block;
  width: 100%;
  margin: 0 0 var(--photo-gap-desktop) 0;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}

.photoFrame {
  overflow: hidden;
  border-radius: 10px;
  background: #f7f7f5;
  border: 1px solid #eeeeee;
}

.photoFrame img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

/* LARGE SCREENS */

@media (min-width: 1300px) {
  .photoLayout.masonry {
    column-width: 300px;
  }
}

@media (min-width: 1700px) {
  .photoLayout.masonry {
    column-width: 330px;
  }
}

/* SMARTPHONES */

@media (max-width: 768px) {
  body {
    font-size: clamp(9px, 2.25vw, 11.5px);
  }

  #listeChiens {
    flex: 0 0 var(--left-width-mobile);
    width: var(--left-width-mobile);
    min-width: 0;
    max-width: none;
    padding: 0 3px 8px 3px;
  }

  .header,
  .row {
    grid-template-columns: 38px minmax(0, 1fr) 31px;
    column-gap: 1px;
  }

  .header {
    padding: 7px 0;
    font-size: 8.5px;
  }

  .row {
    padding: 5px 0;
    border-radius: 6px;
  }

  .cell {
    padding: 3px 1px;
    min-width: 0;
  }

  .header .cell {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    line-height: 1.05;
    overflow-wrap: anywhere;
  }

  .cell.annee,
  .cell.photos {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
  }

  .cell.photos {
    text-align: center;
  }

  .row .cell.nom {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.15;
  }

  #topControls {
    top: 16px;
    left: calc(var(--left-width-mobile) + 8px);
  }

  #quizButton {
    padding: 6px 12px;
    border-width: 3px;
    border-style: double;
    border-radius: 999px;
    font-size: 13px;
  }

  #logo {
    width: 52px;
    top: 6px;
    right: 6px;
  }

  #photoContainer {
    padding: var(--photo-top-space-mobile) 5px 8px 5px;
  }

  #photoContainer.empty {
    font-size: 12px;
  }

  .photoLayout.grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--photo-gap-mobile);
  }

  .photoLayout.masonry {
    column-count: 1;
    column-width: auto;
    column-gap: var(--photo-gap-mobile);
  }

  .photoLayout.masonry .photoFrame {
    margin-bottom: var(--photo-gap-mobile);
  }

  .photoFrame {
    border-radius: 6px;
  }
}
