* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  min-height: 100%;
  opacity: 0;
  animation: fadeIn 0.8s ease-in forwards;
  color: #fff;
}

body.fade-out {
  animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ---------------------------------------------------
   Page d'accueil : scène plein cadre + porte cliquable
--------------------------------------------------- */
body.home-scene {
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #02030a;
}

.frame {
  position: relative;
  width: min(100vw, calc(100vh * 1619 / 971));
  aspect-ratio: 1619 / 971;
  margin: 0 auto;
}

.frame .scene-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.door-hotspot {
  position: absolute;
  left: 40%;
  top: 26%;
  width: 18%;
  height: 44%;
  cursor: pointer;
  display: block;
}

.door-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70%;
  height: 70%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 40px 20px rgba(120, 190, 255, 0.55);
  opacity: 0.5;
  animation: pulse 2.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: translate(-50%, -50%) scale(0.95); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.08); }
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  color: #cfe8ff;
  font-size: clamp(0.7rem, 2vw, 1rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(120, 190, 255, 0.9);
  animation: hintBlink 2.2s ease-in-out infinite;
  pointer-events: none;
  white-space: nowrap;
}

@keyframes hintBlink {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---------------------------------------------------
   Pièce "après" : image plein écran + panneaux incrustés
--------------------------------------------------- */
body.after-scene {
  height: 100vh;
  overflow: hidden;
  background-image: url("../Images/après.png");
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.back-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 2;
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.5em 1em;
  border-radius: 2em;
  backdrop-filter: blur(4px);
  transition: background 0.2s ease;
}

.back-link:hover {
  background: rgba(0, 0, 0, 0.55);
}

/* Panneau "verre" incrusté dans la photo */
.glass-panel {
  width: 100%;
  max-width: 400px;
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(10, 16, 28, 0.45);
  backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(160, 205, 255, 0.3);
  border-radius: 18px;
  padding: 1.9rem 1.7rem;
  box-shadow: 0 10px 45px rgba(0, 0, 0, 0.4);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.hidden-panel {
  display: none !important;
}

#menu-view.glass-panel {
  max-width: 640px;
}

.glass-panel h1,
.glass-panel h2 {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.glass-panel.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* --- Formulaire de connexion --- */
#login-view h2 {
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
  text-align: center;
  color: #e8f4ff;
}

.glass-panel label {
  display: block;
  font-size: 0.85rem;
  color: #bcdcff;
  margin: 0.9rem 0 0.3rem;
}

.glass-panel input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(120, 190, 255, 0.35);
  background: rgba(5, 10, 20, 0.55);
  color: #fff;
  font-size: 1rem;
}

.glass-panel input:focus {
  outline: none;
  border-color: #5fb4ff;
  box-shadow: 0 0 0 3px rgba(95, 180, 255, 0.25);
}

.error {
  color: #ff8080;
  font-size: 0.85rem;
  margin-top: 0.8rem;
}

.btn-primary {
  width: 100%;
  margin-top: 1.4rem;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #3a8dff, #6fc3ff);
  color: #04101f;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.demo-hint {
  margin-top: 1.1rem;
  font-size: 0.72rem;
  color: #d7e6f7;
  text-align: center;
}

/* --- Menu (après connexion) --- */
.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}

.menu-header h1 {
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
}

.menu-header p {
  margin-top: 0.2rem;
  color: #cfe8ff;
  font-size: 0.9rem;
}

.logout-btn-inline {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 0.45em 1em;
  border-radius: 2em;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease;
}

.logout-btn-inline:hover {
  background: rgba(255, 255, 255, 0.25);
}

.glass-panel h2.section-title {
  font-size: 1rem;
  color: #e8f4ff;
  margin-bottom: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.space-card {
  flex: 1 1 220px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(120, 190, 255, 0.3);
  border-radius: 14px;
  padding: 1.2rem;
  text-decoration: none;
  color: #fff;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.space-card:hover {
  transform: translateY(-3px);
  border-color: #5fb4ff;
  background: rgba(255, 255, 255, 0.14);
}

.space-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  color: #9fd4ff;
}

.space-card p {
  font-size: 0.85rem;
  color: #d7e6f7;
}

.admin-panel {
  background: rgba(255, 190, 100, 0.08);
  border: 1px solid rgba(255, 190, 100, 0.35);
  border-radius: 14px;
  padding: 1.2rem;
}

.admin-panel .section-title {
  color: #ffd699;
}

.admin-menu {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.admin-menu li a {
  display: block;
  padding: 0.55em 0.95em;
  background: rgba(255, 190, 100, 0.12);
  border: 1px solid rgba(255, 190, 100, 0.4);
  border-radius: 8px;
  color: #ffdca8;
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.2s ease;
}

.admin-menu li a:hover {
  background: rgba(255, 190, 100, 0.25);
}

/* ---------------------------------------------------
   Module Documentation (dossiers + fichiers)
--------------------------------------------------- */
body.doc-page {
  background: #0a1220;
  min-height: 100vh;
}

.doc-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(120, 190, 255, 0.15);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.back-link-static {
  color: #9fc4ec;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link-static:hover {
  text-decoration: underline;
}

.doc-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.user-label {
  font-size: 0.85rem;
  color: #cfe8ff;
}

.doc-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.doc-main h1 {
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  margin-bottom: 0.75rem;
  color: #e8f4ff;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.crumb {
  color: #5fb4ff;
  text-decoration: none;
}

.crumb:hover {
  text-decoration: underline;
}

.crumb.current {
  color: #cfe8ff;
  font-weight: 600;
}

.crumb-sep {
  color: #4a5c76;
}

.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn-secondary {
  background: rgba(95, 180, 255, 0.12);
  border: 1px solid rgba(95, 180, 255, 0.4);
  color: #bcdcff;
  padding: 0.55em 1.1em;
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(95, 180, 255, 0.22);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.5rem;
}

.folder-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(120, 190, 255, 0.2);
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
}

.folder-open {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  color: #fff;
  padding: 0.4rem 0.3rem;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s ease;
  min-width: 0;
}

.folder-open:hover {
  background: rgba(255, 255, 255, 0.06);
}

.folder-icon {
  font-size: 1.3rem;
}

.folder-name {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.folder-card .item-actions {
  justify-content: flex-end;
}

.icon-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cfe8ff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.section-title-plain {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9fc4ec;
  margin: 1.75rem 0 0.9rem;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(120, 190, 255, 0.15);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  flex-wrap: wrap;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.file-icon {
  font-size: 1.2rem;
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-name {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  font-size: 0.75rem;
  color: #7f96b3;
}

.empty-state {
  color: #7f96b3;
  font-size: 0.88rem;
  padding: 0.5rem 0 1rem;
}

/* ---------------------------------------------------
   Visualiseur de documents
--------------------------------------------------- */
.viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 5, 15, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 1.5rem;
}

.viewer-box {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: auto;
  background: #10151f;
  border: 1px solid rgba(120, 190, 255, 0.25);
  border-radius: 14px;
  padding: 1.5rem;
}

.viewer-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: #9fc4ec;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.viewer-title {
  font-size: 1rem;
  color: #e8f4ff;
  margin-bottom: 1rem;
  padding-right: 1.5rem;
  word-break: break-word;
}

.viewer-content img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  margin: 0 auto;
  border-radius: 8px;
}

.viewer-content iframe {
  width: 100%;
  height: 75vh;
  border: none;
  border-radius: 8px;
  background: #fff;
}

.viewer-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: #d7e6f7;
  font-size: 0.85rem;
  max-height: 70vh;
  overflow: auto;
}

.viewer-fallback {
  color: #9fc4ec;
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
}

/* ---------------------------------------------------
   Sélecteur de fond de page (admin)
--------------------------------------------------- */
.bg-picker-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s ease;
}

.bg-picker-btn:hover {
  background: rgba(0, 0, 0, 0.65);
}

.bg-picker-panel {
  position: fixed;
  right: 1rem;
  bottom: 4.2rem;
  z-index: 20;
  width: 220px;
  background: rgba(10, 16, 28, 0.92);
  border: 1px solid rgba(120, 190, 255, 0.3);
  border-radius: 14px;
  padding: 1rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.bg-picker-panel h3 {
  font-size: 0.85rem;
  color: #e8f4ff;
  margin-bottom: 0.8rem;
}

.bg-preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.bg-swatch {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.bg-swatch:hover {
  border-color: #5fb4ff;
}

.bg-upload-label {
  display: block;
  font-size: 0.78rem;
  color: #9fc4ec;
  cursor: pointer;
}

.bg-upload-input {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: #cfe8ff;
  width: 100%;
}

.bg-picker-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: none;
  border: none;
  color: #9fc4ec;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---------------------------------------------------
   Pages placeholder (concours / documentation)
--------------------------------------------------- */
body.placeholder {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a1220;
  text-align: center;
  padding: 1.5rem;
}

.placeholder-box h1 {
  font-size: clamp(1.3rem, 4vw, 2rem);
  margin-bottom: 0.6rem;
  color: #e8f4ff;
}

.placeholder-box p {
  color: #9fc4ec;
  margin-bottom: 1.5rem;
}

.placeholder-box a {
  color: #5fb4ff;
  text-decoration: none;
  font-size: 0.95rem;
}

.placeholder-box a:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------
   Responsive
--------------------------------------------------- */
@media (max-width: 640px) {
  .glass-panel {
    padding: 1.4rem 1.2rem;
    border-radius: 14px;
  }
  .cards {
    flex-direction: column;
  }
  .admin-menu {
    flex-direction: column;
  }
  .folder-grid {
    grid-template-columns: 1fr;
  }
  .file-row {
    align-items: flex-start;
  }
}
