@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&family=Orbitron:wght@500&display=swap');
@import url('var.css');

body {
  background: darkslategrey;
}

/* --- Animations --- */
@keyframes led-pulse {
  0%, 100% { box-shadow: 0 0 4px red; }
  50% { box-shadow: 0 0 12px red; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to   { opacity: 0; background: var(--lcd-primary); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* --- Console Container --- */
console-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--console-plastic-core, #cfc8b0);
  border-radius: 30px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  margin: 2rem auto;
  min-height: 90dvh;
  max-width: 960px;
  overflow: hidden;
  border: 6px solid #8a8577;
}



/* --- Top Bezel --- */
header {
  width: 100%;
  background: linear-gradient(to bottom, #d9d2be 0%, #bdb49f 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2.5rem;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  gap: 1.5rem;

  red-led {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle, red 0%, darkred 80%);
    box-shadow: 0 0 6px red;
    flex-shrink: 0;
    margin-left: 0.25rem;
    animation: led-pulse 2s infinite;
  }

  h1 {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    color: var(--console-accent, #2d4739);
    text-align: center;
    flex: 1;
    letter-spacing: 1px;
    margin: 0;
  }

  /* --- Navigation --- */
  nav {
    flex-shrink: 0;

    ul {
      display: flex;
      margin: 0;
      padding: 0;
      list-style: none;
    }

    li {
      flex: 1;
    }

    a {
      display: block;
      padding: 0.6rem 1rem;
      background: #bdb49f;
      border: 2px solid #8a8577;
      border-radius: 0;
      border-right: none; /* remove double borders between buttons */
      font-family: var(--font-ui);
      color: var(--console-accent, #2d4739);
      font-size: 0.75rem;
      text-decoration: none;
      text-transform: uppercase;
      text-align: center;
      transition: all 0.15s ease-in-out;
      min-width: 100px;
    }

    /* last button keeps right border */
    li:last-child a {
      border-right: 2px solid #8a8577;
    }

    /* Hover and click effects */
    a:hover {
      background: #a59c89;
      transform: translateY(-1px);
    }

    a:active {
      background: #8a8577;
      transform: translateY(1px);
    }
  }
}

/* Responsive stacking for small screens */
@media (max-width: 1000px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;

    ul {
      flex-wrap: wrap;
    }

    li {
      flex: 1 1 50%;
    }

    a {
      font-size: 0.7rem;
    }
  }
}



/* --- LCD Screen --- */
main::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: brightness(1.05) contrast(0.95);
  background: linear-gradient(120deg, rgba(255,255,255,0.05), rgba(255,255,255,0));
  pointer-events: none;
  z-index: 1;
}

main.screen {
  position: relative;
  background: var(--lcd-primary, #c5dca0);
  color: var(--lcd-secondary, #2d4739);
  width: 90%;
  max-width: 800px;
  min-height: 60dvh;
  padding: 2rem;
  border: 8px inset var(--lcd-border, #1e2f24);
  border-radius: 8px;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.4);
  text-align: center;
  text-shadow: 0 0 2px rgba(45, 71, 57, 0.6);
  margin: 1.5rem auto;
  overflow-y: auto;
  font-family: var(--font-alt);
  font-size: var(--font-size-base);

  h1 {
    font-size: 5rem;
  }

  h2 {
    font-size: 4rem;
  }

  h3 {
    font-size: 3rem;
  }

  p, li {
    font-size: 1.5rem;
  }

  picture img {
    border: 4px solid var(--lcd-border, #1e2f24);
    border-radius: 6px;
    max-width: 100%;
    height: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

loader-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;

  button {
    background: var(--lcd-primary-enhanced);
    border: 4px outset var(--lcd-border);
    color: var(--lcd-seconary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    padding: 0.8rem 2rem;
    margin-top: 1.5rem;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.2);
  }

  button:hover {
    background: var(--lcd-secondary-enhanced);
    color: var(--lcd-primary);
  }

  button:active {
    background: #b4c69a;
    transform: translateY(1px);
    border-style: inset;
  }
}


/* Transitions */
.screen {
  view-transition-name: lcd;
}

@view-transition {
  navigation: auto;
}

::view-transition-old(lcd) {
  animation: fade-out 0.7s ease forwards;
}

::view-transition-new(lcd) {
  animation: fade-in 0.7s ease forwards;
}

@keyframes fade-out {
  from { opacity: 1 }
  to   { opacity: 0 }
}

@keyframes fade-in {
  from { opacity: 0 }
  to   { opacity: 1 }
}



/* --- CRT lines --- */
main::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.06) 0px,
    rgba(0, 0, 0, 0.06) 1px,
    rgba(0, 0, 0, 0) 2px
  );
  background-size: 100% 2px;
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
}



/* ------- Form Styling ------- */

.contact-form, .game-form {
  fieldset {
    border-color: var(--lcd-border, #1e2f24);
  }

  legend {
    font-family: var(--font-main);
    font-size: 1.2rem;
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.3rem;
    color: var(--lcd-secondary);
  }

  label {
    font-family: var(--font-main);
    font-size: 1.2rem;
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.3rem;
    color: var(--lcd-secondary);
  }

  input[type="text"],
  input[type="email"],
  textarea {
    width: 90%;
    max-width: 500px;
    background: var(--lcd-primary);
    border: 3px inset var(--lcd-border);
    color: var(--lcd-secondary);
    font-family: var(--font-alt);
    font-size: 1.4rem;
    padding: 0.6rem;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
    text-shadow: 0 0 2px rgba(45, 71, 57, 0.5);
    border-radius: 4px;
  }

  input:focus,
  textarea:focus {
    outline: 2px solid #2d4739;
    background: var(--lcd-primary-enhanced);
  }

  button[type="submit"] {
    background: var(--lcd-primary-enhanced);
    border: 4px outset var(--lcd-border);
    color: var(--lcd-seconary);
    font-family: var(--font-main);
    font-size: 1.4rem;
    padding: 0.8rem 2rem;
    margin-top: 1.5rem;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.2);
  }

  button:hover {
    background: var(--lcd-secondary-enhanced);
    color: var(--lcd-primary);
  }

  button:active {
    background: #b4c69a;
    transform: translateY(1px);
    border-style: inset;
  }
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-ui);
  font-size: 1.3rem;
  margin: 0.4rem auto;
  width: fit-content;
  cursor: pointer;

  input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--lcd-secondary);
    cursor: pointer;
  }
}

dialog {
    background: var(--lcd-primary);
    border: 4px inset var(--lcd-border);
    padding: 1.5rem;
    border-radius: 6px;
    color: var(--lcd-secondary);
    font-family: var(--font-alt);
    box-shadow: inset 0 0 12px rgba(0,0,0,0.4);
    max-width: 500px;
    margin: 2rem auto;
    font-size: 1.3rem;
  }

/* Flash animation for illegal characters */
.flash {
  animation: flash-red 0.15s ease-out;
}

@keyframes flash-red {
  0% { background-color: #ffcccc; }
  100% { background-color: inherit; }
}

/* Error and info output styling */
#inline-error,
#submit-error,
#form-info {
  display: block;
  margin-top: 0.5rem;
  padding: 0.35rem 0.5rem;
  min-height: 1.2rem;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s;
}

#inline-error.visible,
#submit-error.visible {
  color: #a30000;
  background: #ffd4d4;
  opacity: 1;
}

#form-info.visible {
  color: #003f9e;
  background: #dce8ff;
  opacity: 1;
}

/* Character countdown */
#message-counter {
  display: block;
  font-size: 0.85rem;
  margin-top: 0.25rem;
  color: var(--lcd-secondary);
}

#message-counter.warn {
  color: #c47c00;
  font-weight: bold;
}

#message-counter.error {
  color: #a30000;
  font-weight: bold;
}



/* --- Bottom Bezel --- */
footer {
  padding: 2rem 4rem;
  width: 100%;
  background: linear-gradient(to top, #d9d2be 0%, #bdb49f 100%);
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  padding: 2rem 3rem;

  display: grid;
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto auto;
  grid-template-areas:
    "dpad speaker ab"
    ".    .       home";
  align-items: center;
  justify-content: center;
  gap: 3rem;

  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);

  d-pad {
    --dpad-size: 160px;
    grid-area: dpad;
    margin-left: 3.5rem;
    width: var(--dpad-size);
    height: var(--dpad-size);
    position: relative;
    display: inline-block;

    background: radial-gradient(circle at 35% 30%, #555 0%, #2b2b2b 80%);
    border-radius: 50%;
    box-shadow:
      inset 0 4px 6px rgba(255, 255, 255, 0.08),
      inset 0 -6px 8px rgba(0, 0, 0, 0.4),
      0 4px 10px rgba(0, 0, 0, 0.25);
  }

  d-pad::before,
  d-pad::after {
    content: "";
    position: absolute;
    background: #3a3a3a;
    border-radius: 6px;
    box-shadow:
      inset 0 3px 4px rgba(255, 255, 255, 0.06),
      inset 0 -3px 4px rgba(0, 0, 0, 0.4),
      0 3px 5px rgba(0, 0, 0, 0.3);
  }

  /* Vertical bar */
  d-pad::before {
    width: 28%;
    height: 72%;
    top: 14%;
    left: 36%;
  }

  /* Horizontal bar */
  d-pad::after {
    width: 72%;
    height: 28%;
    top: 36%;
    left: 14%;
  }

  /* Optional: Add a tiny circular center nub */
  d-pad > .center {
    position: absolute;
    width: 24%;
    height: 24%;
    top: 38%;
    left: 38%;
    background: radial-gradient(circle, #444 0%, #1a1a1a 80%);
    border-radius: 50%;
    box-shadow:
      inset 0 2px 4px rgba(255, 255, 255, 0.07),
      inset 0 -3px 5px rgba(0, 0, 0, 0.45);
  }


  speaker-grate {
    width: 140px;
    height: 70px;
    background: repeating-linear-gradient(
      45deg,
      #444 0 2px,
      transparent 2px 4px
    );
    opacity: 0.5;
    border-radius: 10px;
    grid-area: speaker;
    justify-self: center;
    transform: translateX(12px);
  }

  ab-cluster {
    grid-area: ab;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    height: 140px;
  }

  toggle-btn {
    width: 70px;
    height: 70px;
    background: radial-gradient(circle at 30% 30%, #a74363 0%, #752238 80%);
    border-radius: 50%;
    box-shadow: 0 3px 0 #53101f, inset 0 -2px 4px rgba(255,255,255,0.2);
    cursor: pointer;
    transition: all 0.1s ease-in-out;
  }

  toggle-btn:active {
    box-shadow: 0 1px 0 #420d19, inset 0 2px 4px rgba(0,0,0,0.5);
    background: radial-gradient(circle at 30% 30%, #86364f 0%, #5e1b2d 80%);
  }

  .btn-a {
    transform: translate(40px, 20px); /* move right + slightly up */
  }

  .btn-b {
    transform: translate(-40px, 20px); /* move left + slightly down */
  }

  .btn-a:active {
    transform: translate(40px, 25px);
  }

  .btn-b:active {
    transform: translate(-40px, 25px);
  }


  p {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: var(--console-accent, #2d4739);
    grid-area: home;
    justify-self: center;
  }
}



/* --- Minimal LCD mode for small screens --- */
@media (max-width: 600px) {
  body {
    background: var(--lcd-primary, #c5dca0); /* Match the screen color */
    margin: 0;
  }

  .console {
    background: none;
    border: none;
    box-shadow: none;
    margin: 0;
    border-radius: 0;
  }

  .console-top,
  .console-bottom {
    display: none; /* Hide bezels */
  }

  main.screen {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 1rem;
  }

  .console nav {
    display: flex;
    justify-content: center;
    background: var(--lcd-secondary, #2d4739);
    padding: 0.5rem;
  }

  .console nav ul {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .console nav a {
    background: var(--lcd-primary, #c5dca0);
    border: 2px solid var(--lcd-secondary, #2d4739);
    color: var(--lcd-secondary, #2d4739);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
  }
}