@import url("https://fonts.googleapis.com/css2?family=Cascadia+Code:ital,wght@0,200..700;1,200..700&display=swap");

:root {
  --crt-scan__color: #000;
  --primary-color: rgba(147, 27, 53, 0.5);
  --primary-color-full: rgba(147, 27, 53);
  --primary-color-rgb: 147, 27, 53;
  --text-color: #fff;
  --text-contrast: #000;
  --bg-color: #262626;
  --bg-final-color: #000;
  --bg-grid-color: #333;
  --border-color: #fff;
  --border-secondary: rgba(255, 255, 255, 0.3);
  --input-bg: rgba(0, 0, 0, 0.5);
  --grid-line-color: #333;
  --hr-border-color: #000;
  --link-hover-color: #aaaaaa;

  /* Pantalla CRT */
  --crt-bg-color: rgba(0, 0, 0, 0.8);
  --crt-gradient-start: rgba(157, 27, 53, 0.3);
  --crt-scan-line-color: rgba(0, 0, 0, 1);
  --crt-inset-shadow: rgba(157, 27, 53, 0.2);

  /* Blog */
  --blog-list-border: #fff;
  --blog-entry-border: #fff;

  /* Cubo */
  --cube-face-bg: rgba(0, 0, 0, 0.85);
  --cube-face-border-dashed: rgba(255, 255, 255, 0.3);
  --cube-face-border-solid: rgba(255, 255, 255, 0.15);
  --cube-gradient-end: rgba(100, 15, 35, 0.9);
  --cube-text-glow: #fff;

  /* Formulario de contacto */
  --form-bg-gradient-start: rgba(147, 27, 53, 0.3);
  --form-bg-gradient-end: rgba(0, 0, 0, 0.6);
  --form-shadow-color: rgba(147, 27, 53, 0.3);
  --form-inset-shadow: rgba(147, 27, 53, 0.1);
  --form-border: rgba(255, 255, 255, 0.1);
  --input-placeholder-color: rgba(255, 255, 255, 0.4);
  --button-gradient-end: rgba(100, 15, 35, 0.9);
  --button-hover-border: rgba(255, 255, 255, 0.4);
  --button-shine: rgba(255, 255, 255, 0.2);
}

body:has(#theme-toggle:checked) {
  --crt-scan__color: #fff;
  --primary-color: rgba(220, 20, 60, 0.1);
  --primary-color-full: rgba(220, 20, 60);
  --primary-color-rgb: 220, 20, 60;
  --text-color: #1a1a1a;
  --text-contrast: #fff;
  --bg-color: #f0f0f0;
  --bg-final-color: #e0e0e0;
  --bg-grid-color: #d0d0d0;
  --border-color: #333;
  --border-secondary: rgba(0, 0, 0, 0.3);
  --input-bg: rgba(255, 255, 255, 0.9);
  --grid-line-color: #d0d0d0;
  --hr-border-color: #ccc;
  --link-hover-color: #666;

  /* Pantalla CRT */
  --crt-bg-color: rgba(255, 255, 255, 0.8);
  --crt-gradient-start: rgba(220, 20, 60, 0.1);
  --crt-scan-line-color: rgba(255, 255, 255, 0.8);
  --crt-inset-shadow: rgba(220, 20, 60, 0.1);

  /* Blog */
  --blog-list-border: #333;
  --blog-entry-border: #333;

  /* Cubo */
  --cube-face-bg: rgba(255, 255, 255, 0.9);
  --cube-face-border-dashed: rgba(0, 0, 0, 0.3);
  --cube-face-border-solid: rgba(0, 0, 0, 0.15);
  --cube-gradient-end: rgba(200, 0, 40, 0.9);
  --cube-text-glow: #000;

  /* Formulario de contacto */
  --form-bg-gradient-start: rgba(220, 20, 60, 0.1);
  --form-bg-gradient-end: rgba(255, 255, 255, 0.8);
  --form-shadow-color: rgba(220, 20, 60, 0.1);
  --form-inset-shadow: rgba(220, 20, 60, 0.05);
  --form-border: rgba(0, 0, 0, 0.1);
  --input-placeholder-color: rgba(0, 0, 0, 0.5);
  --button-gradient-end: rgba(200, 0, 40, 0.9);
  --button-hover-border: rgba(0, 0, 0, 0.4);
  --button-shine: rgba(255, 255, 255, 0.6);
}

#theme-toggle {
  display: none;
}

.theme-toggle-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border: 2px solid var(--text-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.theme-toggle-label:hover {
  border-color: var(--primary-color-full);
  transform: scale(1.1);
}

.theme-toggle-label::before {
  content: "☽";
  font-size: 20px;
  color: var(--text-color);
  transition: all 0.3s ease;
}

body:has(#theme-toggle:checked) .theme-toggle-label::before {
  content: "☀";
}

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

body {
  display: flex;
  height: 100vh;
  flex-direction: column;
  background: var(--bg-color);
  background-image:
    linear-gradient(to bottom, var(--grid-line-color) 1px, transparent 1px),
    linear-gradient(to right, var(--grid-line-color) 1px, transparent 1px);
  background-size: 50px 50px;
  font-family: "Courier New";
  animation: changeBackgroundScroll;
  animation-timeline: scroll(root y);
}

body {
  height: 100vh;
  color: var(--text-color);
}

hr {
  border: solid var(--hr-border-color) 1px;
}

nav {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 20px;
  margin: 20px;
  background-color: var(--primary-color);
  align-items: center;
}

main {
  padding: 20px;
  height: 100vh;
}

a {
  color: var(--text-color);
  padding: 0 20px;
  text-decoration: none;
  transition: 300ms;
}

a:hover {
  color: var(--link-hover-color);
}

.start {
  display: flex;
  flex-direction: row;
}

.profile {
  width: 400px;
  gap: 20px;
  background-color: var(--primary-color);
  border-radius: 10px;
  text-align: center;
}

.profile > img {
  width: 400px;
  padding: 20px;
}

.terminal {
  width: 90%;
  margin: 20px;
  padding-bottom: 20px;
  font-family: "Cascadia Code", sans-serif;
}

.terminal > img {
  margin: 0;
  padding: 0;
  width: 100%;
}

.commands {
  margin: 0;
  padding: 0;
  background-color: var(--bg-final-color);
  width: 100%;
  height: 100%;
  transform: translateY(-5px);
  font-size: small;
  text-align: left;
  padding: 5px;
}

.commands > p > span {
  animation: blink 1s steps(2, start) infinite;
}

.content {
  width: 100%;
  margin-left: 20px;
  background-color: var(--bg-final-color);
  border: solid 2px var(--border-color);
}

.content > img {
  width: 100%;
}

.project {
  display: flex;
  align-items: center;
  place-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  flex-direction: row;
  width: 100%;
  height: 100%;
}

.blog-section {
  display: flex;
  align-items: center;
  place-items: center;
  justify-content: center;
  width: 100%;
  padding: 150px;
}

.crt-screen {
  position: relative;
  width: 60vw;
  height: 70vh;
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow:
    0 0 30px var(--primary-color),
    inset 0 0 20px var(--crt-inset-shadow);
  background-color: var(--crt-bg-color);
  overflow: hidden;
}

.crt-screen::before {
  content: " ";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    var(--crt-gradient-start) 0.1em,
    transparent 0.1em
  );
  background-size: 100% 0.2em;
  pointer-events: none;
  animation: blink 0.07s steps(5, start) infinite;
}

.crt-screen::after {
  content: "";
  background: linear-gradient(
    to bottom,
    transparent,
    transparent 80%,
    var(--crt-scan__color) 100%
  );
  width: 100%;
  height: 100%;
  position: absolute;
  top: -100%;
  animation: 3s linear 1s infinite;
  animation-name: scan-line;
  z-index: -1;
  left: 0;
}

.terminal-text {
  z-index: 4;
}

.terminal-text > h2 {
  border-bottom: solid 4px var(--border-color);
  padding: 10px;
}

.blog-overview {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
}

.blog-entry-list {
  display: flex;
  flex-direction: row;
  width: 10px;
  overflow: hidden;
  border-right: 4px solid var(--blog-list-border);
  transition: 0.5s;
  padding-left: 0;
  padding-right: 30px;
  padding-top: 30px;
  padding-bottom: 30px;
}

.blog-entry-list:hover {
  width: 20%;
}

.blog-entry-list > h2 {
  text-align: right;
  writing-mode: sideways-lr;
  padding-right: 20px;
}

.blog-entry-list:hover + .blog-entry-list > h2 {
  display: none;
}

.entry-content {
  height: 500px;
  flex: 1;
  overflow-y: scroll;
  padding: 30px;
}

.entry-content > h2 {
  border-bottom: 1px solid var(--blog-entry-border);
}

.entry-content > p {
  text-align: justify;
  padding: 20px 0;
}

.blog-entry {
  padding: 20px 0;
  overflow: hidden;
}

.entry-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.entry-info > img {
  width: 200px;
}

.entry-info > p {
  text-align: center;
  font-size: 12px;
}

/*Cubos*/
.projects,
.blog,
.aboutme {
  position: relative;
  cursor: pointer;
}

.projects pre,
.blog pre,
.aboutme pre {
  transition: 0.4s ease;
}

/* Cubo 3D */
.cube-3d {
  position: absolute;
  top: 40%;
  left: 40%;
  transform-style: preserve-3d;
  z-index: 10;
}

.projects:hover .cube-3d,
.blog:hover .cube-3d,
.aboutme:hover .cube-3d {
  transform: translate(-50%, -50%) rotateX(-20deg) rotateY(25deg) scale(1);
  animation: cubeFloat 3s ease-in-out infinite;
}

.projects:hover pre,
.blog:hover pre,
.aboutme:hover pre {
  opacity: 0.15;
  transform: scale(0.95);
}

/* Caras del cubo */
.cube-face {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 2px solid var(--primary-color-full);
  background: var(--cube-face-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cinta de botones en las caras laterales */
.cube-face.right,
.cube-face.left,
.cube-face.top,
.cube-face.bottom {
  background: linear-gradient(
    135deg,
    var(--primary-color-full) 0%,
    var(--cube-gradient-end) 100%
  );
  border: 2px solid var(--border-secondary);
}

.cube-face.right a,
.cube-face.left a,
.cube-face.top a,
.cube-face.bottom a {
  pointer-events: auto;
}

.cube-face.right a:hover,
.cube-face.left a:hover,
.cube-face.top a:hover,
.cube-face.bottom a:hover {
  color: var(--text-color);
  text-shadow:
    0 0 15px var(--cube-text-glow),
    0 0 25px var(--primary-color-full);
  transform: scale(1.1);
}

/* Efecto wireframe con bordes ASCII-style - solo en caras con título */
.cube-face.front::before,
.cube-face.back::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border: 1px dashed var(--cube-face-border-dashed);
  pointer-events: none;
}

.cube-face.front::after,
.cube-face.back::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  border: 1px solid var(--cube-face-border-solid);
  pointer-events: none;
}

/* Posicionamiento de cada cara */
.cube-face.front {
  transform: translateZ(60px);
}

.cube-face.back {
  transform: rotateY(180deg) translateZ(60px);
}

.cube-face.right {
  transform: rotateY(90deg) translateZ(60px);
}

.cube-face.left {
  transform: rotateY(-90deg) translateZ(60px);
}

.cube-face.top {
  transform: rotateX(90deg) translateZ(60px);
}

.cube-face.bottom {
  transform: rotateX(-90deg) translateZ(60px);
}

/* Animación de flotación */
@keyframes cubeFloat {
  0%,
  100% {
    transform: translate(-50%, -50%) rotateX(-20deg) rotateY(25deg);
  }

  50% {
    transform: translate(-50%, -50%) rotateX(-25deg) rotateY(45deg) scale(1.05);
  }
}

/* Animación de salida */
.projects:not(:hover) .cube-3d,
.blog:not(:hover) .cube-3d,
.aboutme:not(:hover) .cube-3d {
  animation: cubeExit 0.4s ease forwards;
}

.projects-section {
  padding: 300px;
  width: 100%;
}

.projects-section > h2 {
  text-align: center;
  font-size: 40px;
  padding-bottom: 100px;

  opacity: 0;
  transform: translateY(50px);
  animation: fadeInUp 0.8s ease forwards;
  animation-timeline: view();
  animation-range: entry 50% entry 100%;
}

/* Animación de entrada para los proyectos */
.project-entry {
  opacity: 0;
  transform: translateY(60px);
  animation: fadeInUp 0.6s ease forwards;
  animation-timeline: view();
  animation-range: entry 0% entry 100%;
}

.project-entry:nth-child(1) {
  animation-delay: 0s;
}

.project-entry:nth-child(2) {
  animation-delay: 0.15s;
}

.project-entry:nth-child(3) {
  animation-delay: 0.3s;
}

.project-list {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 30px;
}

.project-entry {
  display: flex;
  flex-direction: column;
  place-items: center;
  width: 300px;
  padding: 30px;
  background-color: var(--bg-final-color);
  border-radius: 5px;
  border: solid var(--text-color) 1px;
}

.project-entry > * {
  padding: 10px;
}

.project-image {
  width: 250px;
}

.github-logo {
  width: 200px;
  cursor: pointer;
}

.project-entry > p {
  text-align: center;
  height: 80%;
}

.project-entry > h2 {
  text-align: center;
}

.contact {
  display: flex;
  flex-direction: column;
  place-items: center;
  padding: 100px 20px;
}

.contact > h2 {
  font-size: 2.5rem;
  margin-bottom: 20px;
}

.contact form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  max-width: 500px;
  padding: 40px;
  background: linear-gradient(
    145deg,
    var(--form-bg-gradient-start) 0%,
    var(--form-bg-gradient-end) 100%
  );
  backdrop-filter: blur(10px);
  border-radius: 15px;
  border: 1px solid var(--form-border);
  box-shadow:
    0 8px 32px var(--form-shadow-color),
    inset 0 0 60px var(--form-inset-shadow);
}

.contact form > label {
  padding-top: 15px;
  font-size: 0.9rem;
  letter-spacing: 2px;
  color: var(--text-color);
  text-transform: uppercase;
}

.contact form > input,
.contact > form > textarea {
  width: 100%;
  padding: 15px 20px;
  font-size: 16px;
  font-family: "Courier New", monospace;
  color: var(--text-color);
  background: rgba(0, 0, 0, 0.01);
  border: 2px solid rgba(147, 27, 53, 0.5);
  border-radius: 8px;
  outline: none;
  transition: all 0.3s ease;
}

.contact form > input::placeholder,
.contact > form > textarea::placeholder {
  color: var(--input-placeholder-color);
  font-style: italic;
}

.contact form > input:hover,
.contact > form > textarea:hover {
  border-color: var(--primary-color-full);
  background: var(--bg-final-color);
}

.contact form > input:focus,
.contact > form > textarea:focus {
  border-color: var(--primary-color-full);
  background: var(--bg-final-color);
}

.contact > form > textarea {
  height: 150px;
  resize: vertical;
  min-height: 100px;
  max-height: 300px;
}

.contact > form > button {
  margin-top: 25px;
  width: 100%;
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 18px 40px;
  background: linear-gradient(
    135deg,
    var(--primary-color-full) 0%,
    var(--button-gradient-end) 100%
  );
  border-radius: 8px;
  border: 2px solid var(--primary-color-full);
  color: var(--text-color);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.contact > form > button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    var(--button-shine),
    transparent
  );
  transition: left 0.5s ease;
}

.contact > form > button:hover {
  transform: translateY(-3px);
  border-color: var(--button-hover-border);
}

.contact > form > button:hover::before {
  left: 100%;
}

footer {
  background-color: var(--bg-final-color);
  padding: 30px 0;
  width: 100%;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.link-box > img {
  width: 100px;
  height: 100px;
}

.link-box {
  padding: 15px 25px;
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.link-box:hover {
  border-color: var(--primary-color-full);
  transform: translateY(-5px);
}

.footer-bottom {
  width: 100%;
  text-align: center;
  padding-top: 30px;
}

.footer-line {
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary-color-full),
    transparent
  );
  margin-bottom: 30px;
}

@keyframes scan-line {
  from {
    top: -100%;
  }

  to {
    top: 100%;
  }
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

@keyframes small {
  0% {
    width: 100px;
    height: 100px;
  }

  50% {
    width: 50px;
    height: 50px;
  }

  100% {
    width: 100px;
    height: 100px;
  }
}

@keyframes terminal-text {
  from {
    height: 0;
  }

  to {
    height: 100%;
  }
}

@keyframes cubeExit {
  from {
    transform: translate(-50%, -50%) rotateX(-20deg) rotateY(25deg) scale(1);
    opacity: 1;
  }

  to {
    transform: translate(-50%, -50%) rotateX(-20deg) rotateY(-30deg) scale(0);
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(60px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes changeBackgroundScroll {
  from {
    background-color: var(--bg-color);
  }

  to {
    background-color: var(--bg-final-color);
  }
}

@media (max-width: 1350px) {
  .blog-entry-list:hover {
    width: 30%;
  }

  .entry-info > img {
    width: 100px;
  }

  .entry-info {
    padding: 10px;
  }
}

@media (max-width: 910px) {
  .blog-entry-list:hover {
    width: 40%;
  }

  .entry-info {
    width: 80px;
  }

  .profile {
    width: 100%;
  }

  .profile > img {
    width: 100%;
  }

  .content {
    display: none;
  }
}

@media (max-width: 950px) {
  .projects-section {
    padding: 50px 10px;
    overflow-x: hidden;
  }
}

@media (max-width: 775px) {
  .blog-section {
    padding: 50px 10px;
  }

  .crt-screen {
    width: 100%;
    height: auto;
    min-height: 70vh;
  }

  .blog-overview {
    flex-direction: column;
  }

  .blog-entry-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-right: none;
    border-bottom: 4px solid #fff;
    padding: 20px;
    border-right: none;
  }

  .blog-entry-list:hover {
    width: 100%;
  }

  .blog-entry-list > h2 {
    writing-mode: horizontal-tb;
    text-align: left;
    padding-bottom: 10px;
  }

  .entry-content {
    max-height: 400px;
  }

  .entry-info {
    width: 100%;
  }

  .entry-info > img {
    width: 100px;
  }
}

@media (max-width: 550px) {
  .nav-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 890px) {
  .project-entry {
    width: 100%;
    max-width: 500px;
    overflow: hidden;
  }
}

@media (max-width: 600px) {
  nav {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .project {
    display: none;
  }

  .projects-section > h2 {
    padding-bottom: 40px;
  }

  .contact {
    padding: 50px 10px;
  }

  .contact > h2 {
    font-size: 1.5rem;
  }

  .contact form {
    padding: 20px;
  }

  .link-box > img {
    width: 50px;
    height: 50px;
  }
}
