/* Funny Elia 3D Viewer */

:root {
  --text-main: #e8f0ff;
  --text-muted: #b8c7e4;
  --panel-bg: rgba(9, 17, 33, 0.72);
  --panel-border: rgba(255, 255, 255, 0.16);
  --panel-strong: rgba(8, 13, 24, 0.92);
  --accent: #63b3ff;
  --accent-soft: rgba(99, 179, 255, 0.34);
  --header-control-min-width: 92px;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-main);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(122, 199, 255, 0.24), transparent 38%),
    radial-gradient(circle at 85% 20%, rgba(79, 116, 198, 0.28), transparent 42%),
    #090f1b;
}

body.loading-active {
  cursor: progress;
}

/* Hard guard: nasconde qualunque file input rimasto da codice legacy. */
input[type="file"] {
  display: none !important;
}

#top-header {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-soft);
}

.brand-title,
.brand-subtitle {
  margin: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions #fps-meter {
  min-width: var(--header-control-min-width);
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #d7e5ff;
}

.header-actions #fps-meter[data-level="high"] {
  color: #b9ffd2;
  border-color: rgba(129, 241, 174, 0.5);
}

.header-actions #fps-meter[data-level="mid"] {
  color: #ffe6b0;
  border-color: rgba(255, 204, 122, 0.5);
}

.header-actions #fps-meter[data-level="low"] {
  color: #ffc0bf;
  border-color: rgba(255, 146, 146, 0.5);
}

.header-buttons button {
  min-width: var(--header-control-min-width);
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.header-buttons button:hover {
  background: rgba(99, 179, 255, 0.2);
  border-color: rgba(99, 179, 255, 0.65);
}

.header-buttons button:active {
  transform: translateY(1px);
}

.header-buttons button:disabled {
  opacity: 0.55;
  cursor: wait;
}

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(5, 9, 17, 0.72);
  backdrop-filter: blur(5px);
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease, visibility 200ms ease;
}

#loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(92vw, 420px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--panel-strong);
  padding: 18px 18px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.loading-kicker {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.loading-card h2 {
  margin: 8px 0 6px;
  font-size: 18px;
}

#loading-message {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.loading-progress {
  margin-top: 14px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

#loading-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #63b3ff 0%, #9dd9ff 100%);
  transition: width 180ms ease;
}

#loading-screen.is-error #loading-progress-bar {
  background: linear-gradient(90deg, #ff7d7d 0%, #ffb48a 100%);
}

canvas {
  display: block;
}

@media (max-width: 1024px) {
  #top-header {
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    /* Evita che il parent crei un containing block per il fixed su mobile. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .brand-block {
    flex: 1;
    min-width: 0;
  }

  .header-actions {
    width: auto;
    justify-content: flex-end;
  }

  .header-buttons {
    position: fixed !important;
    top: auto !important;
    left: 12px;
    right: 12px;
    bottom: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 24;
    padding: 6px;
    gap: 6px;
    flex-wrap: nowrap;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  }

  .header-buttons button {
    flex: 1;
    min-width: 0;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 9px;
  }

  .header-actions #fps-meter {
    width: auto;
    min-height: 28px;
    padding: 4px 8px;
    justify-content: center;
    font-size: 11px;
    border-radius: 8px;
  }
}
