/* Variáveis de cores */
:root {
  --color-text: rgb(225, 227, 234);
  --color-text-secondary: rgb(158, 158, 158);
  --color-text-light: rgb(238, 238, 238);
  --color-bg-header: rgb(14, 18, 26);
  --color-border: rgb(37, 40, 47);
  --color-lap-title: rgb(140, 139, 149);
  --color-bg-body: rgba(23, 25, 36, 0.904);
  --color-bg-body-variant: rgb(20, 23, 37);
  --color-bg-position: rgb(14, 13, 19);
  --color-tire: rgb(255, 238, 0);
  --color-first-position-bg: #c90705;
  --color-tracking-bg: rgb(24, 44, 83);
  --color-shadow: rgba(0, 0, 0, 0.5);
}

/* Fonte Regular */
@font-face {
  font-family: 'f1Font';
  src: url('/assets/fonts/Formula1-Regular-1.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* Fonte Bold */
@font-face {
  font-family: 'f1Font';
  src: url('/assets/fonts/Formula1-Bold_web.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

html.loading {
  visibility: hidden;
}

html.loaded {
  visibility: visible;
}

* {
  font-family: "f1Font", sans-serif;
  font-variant-ligatures: none;
  color: var(--color-text);
}

html,
body {
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Prevent scrollbars from appearing */
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.5s ease-in-out;
}


@keyframes smooth-blink {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }

  /* Partial fade instead of disappearing completely */
  100% {
    opacity: 1;
  }
}

/* Comp. Fix: In chrome mobile the user agent stylesheet sets it to white by default */
:-webkit-full-screen {
  background-color: transparent;
}

.fixed {
  position: absolute;
  top: 0;
  left: 0;
}

.no_interaction {
  pointer-events: none;
}

.transparent {
  opacity: 0.0;
}

.btransparent {
  opacity: 1.0 !important;
  z-index: 10;
}

.hidden {
  display: none !important;
}

.fadded {
  opacity: 0.5;
}

.blink {
  animation: smooth-blink 2s infinite ease-in-out;
}

.overlay-image {
  position: absolute;
  width: auto;
  /* Maintain aspect ratio */
  transition: height 0.5s ease-in-out;
}

.bottom-left {
  height: 80vh;
  left: 0px;
  bottom: 0px;
}

.bottom-right {
  height: 70vh;
  right: 0px;
  bottom: 0px;
}

.centered {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  flex-direction: column;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#landing-content,
.button-text {
  text-transform: uppercase;
  font-family: 'Ubuntu', sans-serif;
  color: #FFFFFF;
}

#landing-content .logo {
  width: 25vw;
  height: auto;
}

#landing-content .title,
#landing-content .subtitle {
  padding: 0;
  margin: 0;
}

.title {
  font-size: 9vh;
  padding-bottom: -10px !important;
}

.subtitle {
  font-size: 3.5vh;
}

.bold {
  font-weight: bold;
}

.regular {
  font-weight: normal;
}

.light {
  font-weight: 300;
}

.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background-color: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  /* Prevent text selection */
  outline: none;
  /* Remove focus outline */
  margin-top: 1rem;
}

.button-image {
  height: 12vh;
  width: auto;
  transition: transform 0.1s ease-in-out;
}

.button-container:active .button-image {
  transform: scale(0.95);
  /* Shrink effect */
}

.button-container:focus,
.button-container:active {
  outline: none;
  border: none;
}

.button-text {
  margin-top: 0;
  font-size: 3.5vh;
  font-weight: bold;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
  /* Prevent text selection */
}

.instruction-container {
  position: absolute;
  bottom: 1rem;
  /* Adjust spacing from bottom */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0rem;
  /* Adjust spacing between images */
}

.instruction-container img {
  width: 7vw;
  /* Adjust size */
  height: auto;
  padding: 0;
  margin: 0;
}

.loading {
  background: linear-gradient(to right, rgba(255, 255, 255, 1) var(--loading-progress, 0%), rgba(255, 255, 255, 0.2) var(--loading-progress, 0%));
  background-size: 100% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: background 0.3s ease-in-out;
}

/* Use different images for mobile and desktop */
@media (pointer: fine),
(pointer: none) {

  /* Desktop styles */
  .instruction-container img:nth-child(1) {
    content: url('/assets/images/desktop_look.png');
  }

  .instruction-container img:nth-child(2) {
    content: url('/assets/images/desktop_pan.png');
  }

  .instruction-container img:nth-child(3) {
    content: url('/assets/images/desktop_zoom.png');
  }

  .mobile {
    display: none !important;
  }
}

@media (pointer: coarse) {

  /* Mobile styles */
  .instruction-container img:nth-child(1) {
    content: url('/assets/images/mobile_look.png');
  }

  .instruction-container img:nth-child(2) {
    content: url('/assets/images/mobile_pan.png');
  }

  .instruction-container img:nth-child(3) {
    content: url('/assets/images/mobile_zoom.png');
  }

  .desktop {
    display: none !important;
  }
}

@media (orientation: portrait) {
  .bottom-left {
    height: 50vh;
  }

  .bottom-right {
    height: 35vh;
  }

  #landing-content .logo {
    width: 33vw;
    height: auto;
  }

  .title {
    font-size: 5vh;
  }

  .subtitle {
    font-size: 2vh;
  }

  .instruction-container img {
    width: 12vw;
    /* Adjust size */
  }
}

html,
body,
#container {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
}


#container {
  width: 100vw;
  /* Full viewport width */
  height: 100vh;
  /* Full viewport height */
  display: block;
  /* Ensure it behaves like a block element */
}

/* Optional: Directly style the canvas if needed, though container usually suffices */
#container canvas {
  display: block;
  /* Prevent potential inline spacing issues */
  width: 100%;
  height: 100%;
}

#credits {
  user-select: none;
  position: absolute;
  bottom: 10px;
  left: 10px;
  color: var(--color-text-light);
  font-size: 10px;
  text-shadow: 1px 1px 2px var(--color-shadow);
}

/* Scoreboard */

#scoreboard {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 210px;
  color: white;

  user-select: none;
  /* transform: scale(0.85); */
  transform-origin: top left;
  transition: all 0.1s ease-in-out;
}

.scoreboard-header {
  display: flex;
  align-items: center;
  flex-direction: column;
  background-color: var(--color-bg-header);
  justify-content: space-between;
  border-radius: 10px 10px 0 0;
}

.scoreboard-header .lap-container {
  border-top: 3px solid var(--color-border);
}

.lap-container .lap-title {
  color: var(--color-lap-title);
}

.f1-logo {
  width: 45%;
  height: auto;
  margin: auto;
}

.lap-info {
  font-weight: bold;
  font-size: 16px;
}

.scoreboard-body {
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg-body);
  backdrop-filter: blur(10px);
  border-radius: 0 0 10px 10px;
  max-height: 725px;
}

.driver-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(5vh - 8px);
  border-radius: 5px;
  margin-bottom: 1px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.driver-row:hover {
  scale: 1.05;
  background-color: var(--color-bg-header);
  z-index: 999;
}

.driver-row.show {
  opacity: 1;
  transform: translateY(0);
}


.driver-row:first-child .position-container {
  background-color: var(--color-first-position-bg);
}

.driver-row:last-child {
  border-radius: 0 0 10px 10px;
  overflow: hidden;
  margin-bottom: 0px;
}


.position-container {
  background-color: var(--color-bg-position);
  cursor: pointer;
}

.driver-row p {
  margin: 0;
  font-size: 13px;
}

.driver-row .position {
  width: 18px;
  text-align: right;
}

.driver-row .team-logo {
  aspect-ratio: 1 / 1;
  width: 24px;
  height: 24px;
}

.driver-row .acronym {
  width: 40px;
  font-weight: bold;
  color: white;
  font-size: 13px;
}

.driver-row .interval {
  flex-grow: 1;
  text-align: right;
  font-size: 13px;
  color: var(--color-text);
}

.driver-row .cam-driver {
  width: max-content;
  height: max-content;
  display: flex;
  align-items: center;
  justify-content: center;
}

.driver-row .tire {
  color: var(--color-tire);
  font-size: 13px;
  text-transform: capitalize;
}

.driver-row.driver-tracking:first-child {
  background-color: var(--color-tracking-bg);
}

.driver-row .fastest-lap {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: -25px;
  pointer-events: none;
  display: none;
  z-index: 2;
}

.driver-row .checkered-flag {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: -17px;
  pointer-events: none;
  display: none;
  z-index: 2;
}

.driver-row .fastest-lap img {
  width: 22px;
  height: 22px;
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  display: block;
}

.driver-row .checkered-flag img {
  height: 20px;
  width: auto;
  border-radius: 3px;
  display: blo;
}

#scoreboard .scoreboard-body {
  overflow: visible;
}

.driver-row {
  position: relative;
  overflow: visible;
  z-index: 0;
}

.driver-row:last-child {
  overflow: visible;
  z-index: 5;
}

.driver-row .checkered-flag[style*="display:block"],
.driver-row .checkered-flag[style*="display: block"]~.fastest-lap[style*="display:block"],
.driver-row .checkered-flag[style*="display: block"]~.fastest-lap[style*="display: block"] {
  transform: translate(-10px, -50%);
}

.driver-row .fastest-lap,
.driver-row .checkered-flag {
  opacity: 0;
  transform: translate(-14px, -50%);
}

.driver-row .fastest-lap[style*="display:block"],
.driver-row .fastest-lap[style*="display: block"] {
  animation: fastestEnter .60s ease forwards;
}

.driver-row .checkered-flag[style*="display:block"],
.driver-row .checkered-flag[style*="display: block"] {
  animation: flagEnter .60s ease forwards;
}

@keyframes fastestEnter {
  from {
    opacity: 0;
    transform: translate(-14px, -50%);
  }

  to {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

@keyframes flagEnter {
  from {
    opacity: 0;
    transform: translate(-14px, -50%);
  }

  to {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

#scoreboard-view,
#weather-view {
  display: none;
}

.checkbox-label {
  user-select: none;
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;

  background-color: var(--color-bg-body);
  backdrop-filter: blur(10px);
  padding: 5px;
  border-radius: 8px;
  color: white;
}

/* Lateral controll bar */

/* Driver details */

#driver-details {
  width: 25%;
  position: absolute;
  right: 30px;
  bottom: 30px;
  display: none;
}

.details-container {
  background-color: var(--color-bg-header);
  border-radius: 10px 10px 0px 0px;
}

.details-container p {
  color: var(--color-text-light);
}

.details-container .bar {
  width: 5px;
  height: 1.1rem;
  border-radius: 50px;
}

.details-container .drs {
  border: 2px solid #9a9697;
  font-size: 12px;
  user-select: none;
}

.details-container .drs.active {
  border: 2px solid #5daf5a;
  font-size: 12px;
}

.details-container .drs p {
  color: #9a9697;
}

.details-container .drs.active p {
  color: #5daf5a;
}

.details-container .close-button {
  cursor: pointer;
}

.ic-details {
  border: 2px solid #9a9697;
}

.driver-statistics {
  background-color: var(--color-bg-body-variant);
  border-radius: 0px 0px 10px 10px;
}

.driver-statistics .label {
  color: #9a9697;
}

.driver-statistics .driver-img {
  border-right: 4px solid var(--color-border);
  aspect-ratio: 1/1;
}

.driver-statistics .driver-img img {
  aspect-ratio: 1/1;
  object-fit: cover;
}

.driver-statistics .cam-button {
  cursor: pointer;
  position: absolute;
  left: 15px;
  top: 15px;
  user-select: none;
}

.driver-statistics .driver-timings {
  border-right: 4px solid var(--color-border);
}

.driver-statistics .driver-timings .separation {
  border-bottom: 1px solid #292838;
}

.driver-timings .fastest-lap-time .label {
  font-size: 11px;
}


.driver-statistics .cam-view .btn-preview-camera {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.driver-statistics .label-cam {
  transform-origin: center;
  /* transition: transform 0.3s; */
}

.driver-statistics .label-cam svg,
.driver-statistics .label-cam p {
  fill: var(--color-lap-title);
}

.driver-statistics .label-cam .bi-camera-video-off-fill,
.driver-statistics .label-cam.active .bi-camera-video-fill {
  display: none;
}

.driver-statistics .label-cam.active {
  top: 0px !important;
  left: 5px !important;
  transform: scale(0.4) translate(-50%, -50%) !important;
  z-index: 10;
  user-select: none;
}

.driver-statistics .label-cam.active .bi-camera-video-off-fill {
  display: block;
}

.driver-statistics .label-cam.active .label {
  display: none;
}

/* --------------------------- */

@media (max-width: 1440px) {
  #scoreboard {
    transform: scale(0.74);
    transform-origin: top left;
  }
}

@media (max-width: 320px) {
  #scoreboard {
    transform: scale(0.74);
    transform-origin: top left;
  }
}

.scoreboard-body.xr {
  max-height: max-content !important;
  overflow-y: initial !important;
  overflow-x: initial !important;
}

/* Esconde o scoreboard via transform apenas em telas pequenas (smartphones) */
@media only screen and (max-width: 600px),
only screen and (max-height: 600px) {
  .scoreboard-body {
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    overflow-x: visible;
    /* deixa elementos “saltar” para o lado */
  }

  .driver-row {
    flex: 0 0 auto;
    height: auto;
  }

  #scoreboard-view:checked~#scoreboard {
    transform: scale(0);
    transform-origin: top left;
  }

  #weather-view:checked~#race-view {
    transform: scale(0);
    transform-origin: top right;
  }

  #race-view {
    top: 90px !important;
  }

  .checkbox-label,
  .weather-info {
    display: block !important;
  }

  #driver-details {
    width: 90%;
    left: 50%;
    bottom: 70px;
    transform: translateX(-50%) !important;
  }

  #driver-details .driver-statistics .driver-timings p,
  #driver-details .driver-statistics .driver-timings b {
    font-size: 12px;
  }

  #driver-details .fastest-lap-time .label {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .driver-statistics .cam-view svg {
    width: 32px;
    height: 32px;
  }

  .driver-statistics .cam-view p {
    font-size: 12px;
  }
}

@media only screen and (max-height: 600px) {
  #driver-details {
    width: 40%;
    left: 97%;
    bottom: 50px;
    transform: translateX(-97%) !important;
  }

  #driver-details .driver-statistics .driver-timings p,
  #driver-details .driver-statistics .driver-timings b {
    font-size: 12px;
  }

  #weather-view:checked~#race-view {
    transform: scale(0);
    transform-origin: top right;
  }

  #race-view {
    top: 0px !important;
    right: 40px !important;
    transform: scale(0.8);
  }
}

@keyframes blink-red {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

.cam-button.active svg {
  fill: red;
  animation: blink-red 1s infinite ease-in-out;
}

#race-view {
  width: 280px;
  transform-origin: top right;
  transition: all 0.1s ease-in-out;
}

#race-view .title-race {
  background-color: var(--color-bg-header);

  border-radius: 5px;
}

/* #race-view .title-race .ic-sync {
    transition: all 0.2s;
    cursor: pointer;
    border-radius: 50px;
    padding: 4px;
    user-select: none;
  }
    #race-view .title-race .ic-sync:hover {
      background-color: rgba(99, 98, 107, 0.644);
    } */


#weather-conditions {
  border-radius: 8px;
  overflow: hidden;
}

#weather-conditions .top-bar {
  background-color: var(--color-bg-header);
}

#weather-conditions .top-bar p {
  font-size: 14px;
}

#weather-conditions .body-conditions {
  background-color: var(--color-bg-body);
}

#weather-conditions .body-conditions p {
  color: var(--color-text);
}

#weather-conditions #conditions {
  background-color: var(--color-bg-body);
}

#weather-conditions #conditions p {
  font-size: 12px;
  color: var(--color-text-secondary);
}

#weather-conditions #conditions .infos .humidity p {
  color: #4b96d0;
}

#race-view #track-conditions {
  overflow: hidden;
  border-radius: 8px;
}

#race-view #track-conditions .top-bar {
  background-color: var(--color-bg-header);
}

#race-view #track-conditions .top-bar p {
  font-size: 14px;
}

#race-view #track-conditions .infos {
  background-color: var(--color-bg-body);
  backdrop-filter: blur(2px);
}

#race-view #track-conditions .infos .info-item {}

#race-view #track-conditions .infos .info-item p {
  font-size: 13px;
}

.weather-info {
  user-select: none;
  cursor: pointer;
  position: absolute;
  top: 60px;
  right: 10px;
  display: none;

  background-color: var(--color-bg-body);
  backdrop-filter: blur(10px);
  padding: 5px;
  border-radius: 8px;
  color: white;
  border: none !important;
}

#race-view {
  transform-origin: top right;
  transition: all 0.1s ease-in-out;
}

/* on the svg element set up a default value for the --stroke-dash and --stroke-dash-negative attributes
46 roughly being the length of the longest path.air
*/

#loading-screen {
  width: 100vw;
  height: 101vh;
  position: absolute;
  top: 0;
  background: #003DA5;
  background-image: url('/assets/images/bg_hor.jpg');
  z-index: 9999;
}


#loading-screen>svg {
  width: 300px;
  height: auto;
  --stroke-dash: 46;
  --stroke-dash-negative: -46;
}

/* animate the car to move slightly forwards and backwards */
g#car {
  transform: translateX(-3px);
  animation: translate 2s ease-in-out infinite;
}

/* animate the shadow to skew  toward the left */
path#shadow {
  animation: skew 2s ease-in-out infinite;
}

/* animate the wheels to spin  clockwise*/
g.wheels use {
  animation: rotate 2s linear infinite;
}

/* animate the dashes of air to briefly show them and then hide them from view */
path.air {
  /* starting from the values described by the --stroke-dash property
  ! the property is updated for each path in the script
  */
  stroke-dasharray: var(--stroke-dash);
  stroke-dashoffset: var(--stroke-dash);
  /* ! the delay of the animation is also set up in the script  */
  animation: offset 2s linear infinite;
  /* opacity to hide the obnoxious dots otherwise shown on firefox and edge */
  opacity: 0;
}

/* keyframe animations
! be sure to have the animations overlap as to show a realistic behavior
- as the car moves right the wheels spin faster, the shadow skews left, the dashes of air appear in sequence
- as the car moves left the wheels spin slower while the shadow returns to its resting place
*/
@keyframes translate {
  50% {
    transform: translateX(3px);
  }

  100% {
    transform: translateX(-3px);
  }
}

@keyframes skew {
  50% {
    transform: skewX(-20deg);
  }
}

@keyframes rotate {
  50% {
    transform: rotate(4turn);
  }

  100% {
    transform: rotate(6turn);
  }
}

/* beside animating the stroke-dashoffset property rapidly change the opacity to show the dashes and hide them when they are removed by changing the offset property
otherwise the dashes would still be partially visible on firefox and edge (at least)
*/
@keyframes offset {
  1% {
    opacity: 1;
  }

  15% {
    stroke-dashoffset: 0;
    opacity: 1;
  }

  24% {
    opacity: 1;
  }

  25% {
    opacity: 0;
    /* ! on chrome and firefox the calc() function allows to compute the negative value, but Edge seems to prefer having another variable instead */
    /* stroke-dashoffset: calc(var(--stroke-dash) * -1px); */
    stroke-dashoffset: var(--stroke-dash-negative);
  }

  100% {
    stroke-dashoffset: var(--stroke-dash-negative);
  }
}

.hidden {
  display: none !important;
}

.info {
  opacity: 0;
  transform: translateX(-90px);
  transition: 0.5s linear(0 0%, 0 1.8%, 0.01 3.6%, 0.03 6.35%, 0.07 9.1%, 0.13 11.4%, 0.19 13.4%, 0.27 15%, 0.34 16.1%, 0.54 18.35%, 0.66 20.6%, 0.72 22.4%, 0.77 24.6%, 0.81 27.3%, 0.85 30.4%, 0.88 35.1%, 0.92 40.6%, 0.94 47.2%, 0.96 55%, 0.98 64%, 0.99 74.4%, 1 86.4%, 1 100%);
}

.info.show {
  opacity: 1;
  transform: translateX(0px);
}