/* --------------------------------
     [ CORE_SYSTEM_VARIABLES ]
  Phosphor Pallete, and CRT base
-------------------------------- */
:root {
  --phosphor-bright: #ffb000;
  --phosphor-dim: #b37b00;
  --phosphor-muted: #755800;
  --phosphor-glow: rgba(255, 176, 0, 0.4);
  --crt-bg: #110c00;
  --crt-off: #050400;
}

@import url("https://fonts.googleapis.com/css2?family=VT323&family=Fira+Code:wght@400;700&display=swap");

html,
body {
  font-family: "VT323", monospace;
  height: 100%;
  width: 100%;
  background-color: #000;
  overflow-x: hidden;
}

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

/* ---------------------------------------
        [ CRT_HARDWARE_EMULATION ]
  Scanlines, Flicker, and Bezel Effects
--------------------------------------- */

/* --- Physical Monitor Overlays --- */

.crt-monitor {
  width: 100%;
  height: 100%;
  position: relative;
  background-color: var(--crt-bg);
  color: var(--phosphor-bright);
  text-shadow:
    0 0 2px var(--phosphor-dim),
    0 0 8px var(--phosphor-bright);
  overflow-y: auto;
  padding: 20px;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
  border-radius: 10px;
  border: 3px solid #222;
}

.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 50%,
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 9999;
}

.screen-flicker {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 176, 0, 0.02);
  opacity: 0;
  z-index: 9998;
  pointer-events: none;
  animation: flicker 0.15s infinite;
}

.bezel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  z-index: 12;
  border-radius: 10px;
}

/* --- Boot Sequence UI --- */

#loading-screen {
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--phosphor-dim);
  padding: 20px;
  background-color: var(--crt-bg);
  height: 100vh;
  overflow: hidden;
}

.skip-hint {
  margin-top: 20px;
  color: var(--phosphor-muted);
  font-style: italic;
  animation: blink 1s infinite;
}

#boot-text {
  white-space: pre-wrap;
  line-height: 1.4;
}

.power-on-anim {
  animation: turnOn 0.8s ease-in-out forwards;
}

body::after {
  content: " ";
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.06),
      rgba(0, 255, 0, 0.02),
      rgba(0, 0, 255, 0.06)
    );
  z-index: 999;
  background-size:
    100% 4px,
    3px 100%;
  pointer-events: none;
}

/* --------------------------------------
          [ NAVI_&_GLOBAL_UI ]
  Sticky Nav, Key Bindings, and Footer
-------------------------------------- */
.tui-nav-row {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 9800;
  background: var(--crt-bg);
  border-bottom: 1px solid var(--phosphor-dim);
  padding: 10px 0;
  pointer-events: auto;
}

.nav-key {
  color: var(--phosphor-bg);
  background: var(--phosphor-dim);
  padding: 0 5px;
  text-decoration: none;
  font-weight: bold;
}

.nav-key.active,
.nav-key:hover {
  background: var(--phosphor-bright);
  color: var(--phosphor-bg);
  box-shadow: 0 0 10px var(--phosphor-glow);
}

.nav-label {
  color: var(--phosphor-bright);
  margin-left: 5px;
}

/* --- Depreciated
.nav-item {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  cursor: pointer;
  pointer-events: auto;
}
--- */

.nav-item {
  color: var(--phosphor-bright);
  text-decoration: none;
  padding: 2px 5px;
  transition: all 0.2s ease;
}

.nav-key {
  background-color: var(--phosphor-muted);
  color: var(--phosphor-bright);
  padding: 0 4px;
  margin-right: 6px;
}

.nav-key,
.nav-label {
  pointer-events: none;
}

.nav-item.active .nav-key,
.nav-item:hover .nav-key {
  background-color: var(--phosphor-bright);
  color: var(--phosphor-bg);
}

.nav-item.active .nav-label,
.nav-item:hover .nav-label {
  color: var(--phosphor-bright);
  text-decoration: underline;
}

.terminal-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  box-sizing: border-box;
  background: var(--crt-bg);
  border-top: 1px solid var(--phosphor-muted);
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  padding: 6px 15px;
  font-size: 0.7rem;
  z-index: 100;
  pointer-events: none;
  color: var(--phosphor-muted);
  margin: 0;
}

.footer-item {
  white-space: nowrap;
  display: flex;
  align-items: center;
  padding: 2px 5px;
  text-transform: uppercase;
}

/* -----------------------------------------
          [ TYPOGRAPHY_&_CONTENT ]
  Headers, Project Lists, and ASCII Blocks
----------------------------------------- */
#main-content {
  padding-bottom: 50px;
  max-width: 1400px;
  width: 95%;
  margin: 0 auto;
  padding: 40px;
  position: relative;
}

.header-main {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 40px;
  margin-bottom: 10px;
}

.header-telemetry {
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: var(--phosphor-dim);
}

.terminal-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  z-index: 10;
}

.audit-section {
  padding-bottom: 5px;
}

.audit-list li {
  list-style: none;
}

.prompt {
  color: var(--phosphor-dim);
  font-weight: bold;
}

.file-link {
  border-bottom: 2px dotted var(--phosphor-muted);
  text-decoration: none;
  color: var(--phosphor-bright);
  min-width: fit-content;
}

h2 {
  margin-bottom: 20px;
  text-transform: uppercase;
  padding-left: 10px;
}

h3 {
  padding-top: 20px;
  padding-bottom: 10px;
  text-transform: uppercase;
}

h4 {
  padding-top: 10px;
  padding-bottom: 10px;
}

.meta {
  font-size: 0.8rem;
  color: var(--phosphor-dim);
  margin-bottom: 10px;
}

.code {
  font-size: 0.85rem;
  margin-top: 5px;
  white-space: pre;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--phosphor-dim) transparent;
}

.blinking-cursor {
  animation: blink 1s step-end infinite;
  margin-left: 5px;
}

.meta-comment {
  color: var(--phosphor-dim);
  font-size: 0.85rem;
  margin-left: 15px;
  font-style: italic;
}

.glitch {
  position: relative;
  font-size: 0.9rem;
  white-space: pre;
  animation: hardware-flicker 4s infinite;
}

.glitch::before,
.glitch::after {
  display: none;
}

.typing-animation {
  animation: scanline-reveal 0.6s steps(30, end);
  overflow: hidden;
  white-space: normal;
  border-left: 2px solid var(--phosphor-bright);
  padding-left: 15px;
}

.log-viewer {
  width: 100%;
  background: rgba(0, 20, 0, 0.1);
  min-height: 50vh;
  padding-top: 15px;
}

#viewscreen-content {
  line-height: 1.6;
  padding-right: 50px;
}

#viewscreen-header {
  padding-bottom: 15px;
}

/* --- Index/Directory Styling --- */
.wide-index {
  margin-top: 20px;
}
.index-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 176, 0, 0.1);
}
.index-details {
  opacity: 0.6;
  font-size: 0.9rem;
  text-align: right;
}
.index-row a {
  text-decoration: none;
  color: var(--phosphor-bright);
  font-weight: bold;
}

/* --- Legacy / Archived Entries --- */
.legacy-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--phosphor-muted);
}

.legacy-row a {
  text-decoration: none;
  color: var(--phosphor-muted);
  font-weight: italic;
}

/* --- Audit/Landing Module --- */
.audit-section {
  padding-bottom: 5px;
}
.audit-list li {
  list-style: none;
  padding-left: 5px;
}

/* Shared Styles */
.audit-grid {
  margin-top: 10px;
}

.audit-row {
  display: flex;
  margin-bottom: 5px;
}

.audit-label {
  color: var(--phosphor-muted);
  width: 120px;
  flex-shrink: 0;
}

.audit-value {
  color: var(--phosphor-bright);
}

/* --- List Styling Modules --- */
.config-list {
  font-size: 0.8rem;
  margin: 10px;
  list-style: none;
}

/* --- Legal/Compliance Note --- */
.compliance {
  color: var(--phosphor-muted);
  font-size: 0.85rem;
  font-style: italic;
  border-left: 2px solid var(--phosphor-dim);
  padding-left: 10px;
  margin-top: 20px;
  opacity: 0.7;
}

/* --- Data Tree Styling --- */
.acl {
  font-size: 0.85rem;
  list-style-type: none;
  padding-left: 10px;
  padding-bottom: 10px;
  padding-top: 10px;
}

.li {
  padding-top: 5px;
  padding-bottom: 5px;
}

.data-tree {
  font-family: "Courier New", monospace;
  line-height: 1.4;
  color: var(--phosphor-dim);
}

.tree-branch {
  color: var(--phosphor-muted);
  margin-right: 10px;
  user-select: none;
}

.tree-leaf {
  color: var(--phosphor-bright);
  font-weight: bold;
}

/* --------------------------
  [ MOBILE_RESPONSIVENESS ]
-------------------------- */

@media (max-width: 480px) {
  #main-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 10px 10px 160px 10px;
  }

  h1,
  h2,
  h3,
  h4 {
    font-size: 1rem !important;
    line-height: 1.3;
    word-wrap: break-word;
  }

  .layer-header h2 {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .layer-container {
    padding: 0 10px;
  }

  p {
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: left;
  }

  p,
  li,
  h1,
  h2,
  h3,
  h4 {
    max-width: 100%;
    box-sizing: border-box;
  }

  .meta-comment {
    font-size: 0.8rem;
    margin-top: 5px;
  }

  .crt-container,
  .terminal-body {
    padding: 5px !important;
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box;
  }

  .scanlines {
    opacity: 0.1 !important;
  }

  .tui-header {
    padding-top: 10px;
  }

  .glitch {
    display: flex;
    justify-content: center;
  }

  .header-main {
    overflow: hidden;
  }

  .header-telemetry {
    display: none;
  }

  .tui-nav-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 10px;
    background: var(--crt-bg);
    border-bottom: 2px solid var(--phosphor-dim);
  }

  .nav-item {
    justify-content: flex-start;
    font-size: 0.8rem;
    padding: 6px 4px;
    border: 1px solid var(--phosphor-muted);
  }

  .nav-label {
    font-size: 0.7rem;
  }

  .prompt {
    font-size: 0.85rem;
    padding: 10px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .terminal-footer {
    flex-direction: column;
    height: auto;
    justify-content: center;
    text-align: center;
    padding: 12px 10px;
  }

  .footer-item {
    width: 100%;
    font-size: 0.65rem;
    justify-content: center;
    border-bottom: 1px dotted rgba(255, 174, 0, 0.1);
    padding-bottom: 4px;
  }

  .footer-item:last-child {
    border-bottom: none;
  }

  .mobile-footer-spacer {
    height: 100px;
    width: 100%;
    display: block;
  }

  /* --- Audit/Landing Module --- */
  .audit-section {
    padding-bottom: 5px;
  }
  .audit-list li {
    list-style: none;
    padding-left: 5px;
  }

  /* Shared Styles */
  .audit-grid {
    margin-top: 10px;
  }

  .audit-row {
    display: flex;
    margin-bottom: 5px;
  }

  .audit-label {
    color: var(--phosphor-muted);
    width: 120px;
    flex-shrink: 0;
  }

  .audit-value {
    color: var(--phosphor-bright);
  }

  /* --- Index/Directory Styling --- */
  .index-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .index-details {
    text-align: left;
    padding-top: 5px;
  }
}

/* ---------------------
  [ ANIMATION_ENGINE ]
--------------------- */

@keyframes scanline-reveal {
  from {
    max-height: 0;
    opacity: 0;
  }
  to {
    max-height: 1000px;
    opacity: 1;
  }
}

@keyframes hardware-flicker {
  0% {
    opacity: 1;
    transform: skew(0deg);
  }
  2% {
    opacity: 0.8;
    transform: skew(1deg);
  }
  4% {
    opacity: 1;
    transform: skew(0deg);
  }
  7% {
    opacity: 1;
    transform: translateX(2px);
  }
  8% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 1;
  }
}

@keyframes text-flicker {
  0% {
    opacity: 0.98;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 99;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes flicker {
  0% {
    opacity: 0.8;
  }
  50% {
    opacity: 0.9;
  }
  100% {
    opacity: 0.8;
  }
}

@keyframes turnOn {
  0% {
    transform: scale(1, 0.001);
    opacity: 0;
    filter: brightness(10);
  }
  30% {
    transform: scale(1, 0.001);
    opacity: 1;
  }
  70% {
    transform: scale(1.1, 0.8);
  }
  100% {
    transform: scale(1, 1);
    filter: brightness(1);
  }
}
