/* Global reset and base canvas setup */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Courier New", Courier, monospace;
  transition: all 0.3s ease-in-out;
}

body {
  overflow-x: hidden;
  background-color: #000;
  color: #fff;
}

/* Global state management via hidden inputs */
.state-manager {
  display: none;
}

/* Dynamic theming variables and overrides via sibling combinator */
.app-container {
  --bg-color: #08080a;
  --panel-bg: #111118;
  --text-main: #00ffcc;
  --text-muted: #4d9999;
  --border-color: #ff00ff;
  --accent: #ff00ff;
  --shadow: 0 0 15px rgba(255, 0, 255, 0.4);

  display: grid;
  grid-template-columns: 350px 1fr;
  height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-main);
}

#theme-light:checked ~ .app-container {
  --bg-color: #f4f4f5;
  --panel-bg: #ffffff;
  --text-main: #18181b;
  --text-muted: #71717a;
  --border-color: #d4d4d8;
  --accent: #3b82f6;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#theme-dark:checked ~ .app-container {
  --bg-color: #121212;
  --panel-bg: #1e1e1e;
  --text-main: #e0e0e0;
  --text-muted: #888888;
  --border-color: #333333;
  --accent: #bb86fc;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

/* Layout orchestration for grid and list views */
#layout-grid:checked ~ .app-container .content-wrapper,
#layout-grid:checked ~ .app-container .blueprint-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

#layout-list:checked ~ .app-container .content-wrapper,
#layout-list:checked ~ .app-container .blueprint-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Adapting the internal card structure for list view */
#layout-list:checked ~ .app-container .card {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 2rem;
  height: 120px;
}

/* Blueprint specific alignment for list view for a perfect 3-column dash */
#layout-list:checked ~ .app-container .blueprint-card {
  display: grid;
  grid-template-columns: 250px 1fr 150px;
  align-items: center;
  text-align: left;
  gap: 2rem;
  padding: 1rem 2rem;
}

#layout-list:checked ~ .app-container .blueprint-card h3,
#layout-list:checked ~ .app-container .blueprint-card p {
  margin-bottom: 0;
}

#layout-list:checked ~ .app-container .card {
  height: 120px;
}

#layout-list:checked ~ .app-container .card-img,
#layout-list:checked ~ .app-container .blueprint-diagram {
  height: 100%;
  width: 150px;
  margin-bottom: 0;
  flex-shrink: 0;
}

/* Tab navigation routing logic via display toggling */
.tab-pane {
  display: none;
  animation: fadeIn 0.4s ease-in-out;
}

#tab-blueprint:checked ~ .app-container #pane-blueprint {
  display: block;
}
#tab-execution:checked ~ .app-container #pane-execution {
  display: block;
}

.main-tabs {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  border-bottom: 2px solid var(--border-color);
}

.tab-label {
  padding: 1rem 2rem;
  cursor: pointer;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  transition: all 0.2s;
}

.tab-label:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

/* Illuminating the active tab to match the theme */
#tab-blueprint:checked ~ .app-container label[for="tab-blueprint"],
#tab-execution:checked ~ .app-container label[for="tab-execution"] {
  color: var(--bg-color);
  background: var(--text-main);
  border: 2px solid var(--border-color);
  border-bottom: none;
}

/* Component and interface styling */
.control-panel {
  background-color: var(--panel-bg);
  border-right: 2px solid var(--border-color);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
  position: relative;
}

.control-panel h2 {
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.control-group h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* The interactive buttons which act as labels for our hidden radios */
.btn {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-main);
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--border-color);
  color: var(--bg-color);
  box-shadow: var(--shadow);
}

/* Wiring the sidebar UI to reflect the active internal state visually */
#theme-cyberpunk:checked ~ .app-container label[for="theme-cyberpunk"],
#theme-light:checked ~ .app-container label[for="theme-light"],
#theme-dark:checked ~ .app-container label[for="theme-dark"],
#layout-grid:checked ~ .app-container label[for="layout-grid"],
#layout-list:checked ~ .app-container label[for="layout-list"] {
  background: var(--text-main);
  color: var(--bg-color);
  border-color: var(--text-main);
}

.layout-toggles {
  display: flex;
  gap: 0.5rem;
}

.sys-status {
  position: absolute;
  bottom: 2rem;
  font-size: 0.8rem;
  color: var(--accent);
  animation: blink 2s infinite;
}

.display-area {
  padding: 4rem;
  overflow-y: auto;
}

.hero-header {
  margin-bottom: 3rem;
}

.glitch-text {
  font-size: 3rem;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  position: relative;
  display: inline-block;
  text-shadow: 2px 2px 0px var(--accent);
}

/* The primary content modules */
.card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 1rem;
  box-shadow: 5px 5px 0px rgba(0, 0, 0, 0.3);
  cursor: default;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 10px 10px 0px rgba(0, 0, 0, 0.5);
  border-color: var(--accent);
}

.card-img {
  height: 150px;
  width: 100%;
  background: var(--text-muted);
  opacity: 0.8;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.trigger-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: bold;
  font-size: 0.8rem;
  text-transform: uppercase;
  transition: all 0.2s;
}

.trigger-link:hover {
  letter-spacing: 1px;
  text-shadow: var(--shadow);
}

/* Terminal concept display styling */
.concept-terminal {
  background: #050505;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 3rem;
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.8),
    var(--shadow);
}

.terminal-header {
  background: #1a1a1a;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: #888;
  font-size: 0.8rem;
}

.terminal-body {
  padding: 2rem;
}

.term-text {
  color: var(--text-main);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.term-list {
  list-style-type: none;
  padding-left: 1rem;
  border-left: 2px dashed var(--text-muted);
  margin-left: 1rem;
}

.term-list li {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.term-list span:first-child {
  color: var(--accent);
  font-weight: bold;
}

.highlight {
  color: var(--text-main);
  background: rgba(0, 255, 204, 0.1);
  padding: 0 4px;
}

.blinking-cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
}

/* Blueprint diagram cards */
.blueprint-card {
  text-align: center;
  border: 1px dashed var(--border-color);
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.blueprint-card h3 {
  font-size: 1.1rem;
  color: var(--text-main);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.blueprint-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.blueprint-diagram {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
}

.state-light {
  width: 20px;
  height: 20px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: pulse 1s infinite alternate;
}

/* Pure css modal logic using target */
.css-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

.css-modal:target {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--panel-bg, #111118);
  border: 2px solid var(--border-color, #ff00ff);
  padding: 3rem;
  max-width: 600px;
  width: 90%;
  position: relative;
  transform: translateY(50px);
  transition: transform 0.3s ease;
  box-shadow: 20px 20px 0px rgba(0, 0, 0, 0.8);
}

.modal-content h2 {
  color: var(--text-main, #00ffcc);
  margin-bottom: 1rem;
}

.modal-content p {
  color: var(--text-muted, #4d9999);
  line-height: 1.6;
}

.css-modal:target .modal-content {
  transform: translateY(0);
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: #ff3333;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.2rem;
}

.close-modal:hover {
  color: white;
  background: #ff3333;
}

.placeholder-graph {
  height: 100px;
  margin-top: 2rem;
  opacity: 0.5;
}

/* Keyframe animations */
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0px var(--accent);
  }
  100% {
    box-shadow:
      0 0 15px var(--accent),
      0 0 30px var(--accent);
  }
}

/* Mobile responsiveness module */
@media (max-width: 850px) {
  /* Stack the main container */
  .app-container {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  /* Reposition control panel to the top */
  .control-panel {
    border-right: none;
    border-bottom: 2px solid var(--border-color);
    padding: 1.5rem;
    gap: 1.5rem;
  }

  /* Shrink glitch text to prevent horizontal overflow */
  .glitch-text {
    font-size: 2rem;
  }

  /* Reduce padding on the main display area */
  .display-area {
    padding: 2rem 1.5rem;
  }

  /* Stack tabs vertically on small screens */
  .main-tabs {
    flex-direction: column;
    gap: 0.5rem;
  }

  .tab-label {
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
  }

  /* Fix border overriding on active stacked tabs */
  #tab-blueprint:checked ~ .app-container label[for="tab-blueprint"],
  #tab-execution:checked ~ .app-container label[for="tab-execution"] {
    border-bottom: 2px solid var(--border-color);
  }

  /* Fix list view breaking on small screens */
  #layout-list:checked ~ .app-container .card {
    flex-direction: column;
    height: auto;
    text-align: center;
    gap: 1rem;
  }

  #layout-list:checked ~ .app-container .card-img {
    width: 100%;
    height: 150px;
  }

  /* Fix blueprint list view breaking */
  #layout-list:checked ~ .app-container .blueprint-card {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 1.5rem;
  }

  /* Adjust modal padding */
  .modal-content {
    padding: 1.5rem;
  }

  /* Hide the system status to save space on mobile */
  .sys-status {
    position: static;
    margin-top: 1rem;
    text-align: center;
  }
}
