/* ---- Color palettes ----
   Each theme's colors live under an [data-theme="..."] selector.
   JS will set this attribute on <html>, and because every rule below
   references var(--bg), var(--accent) etc., the whole page updates
   instantly when the attribute changes — no other CSS needed. */
:root,
[data-theme="dracula"] {
  --app-bg:#4A4D5E;          
  --bg: #282a36;
  --fg: #f8f8f2;
  --prompt-color: #50fa7b;
  --command-color: #f8f8f2;
  --link-color: #8be9fd;
  --accent: #bd93f9;
  --muted: #9DADE1;
}

[data-theme="nord"] {
  --app-bg: #3b4252;          /* Slightly lighter than terminal #2e3440 */
  --bg: #2e3440;
  --fg: #eceff4;
  --prompt-color: #a3be8c;
  --command-color: #eceff4;
  --link-color: #88c0d0;
  --accent: #b48ead;
  --muted: #A6B4CE;
}

[data-theme="gruvbox"] {
  --app-bg: #3c3836;          /* Slightly lighter than terminal #282828 */
  --bg: #282828;
  --fg: #ebdbb2;
  --prompt-color: #b8bb26;
  --command-color: #ebdbb2;
  --link-color: #83a598;
  --accent: #fe8019;
  --muted: #928374;
}

[data-theme="tokyo-night"] {
  --app-bg: #273471;          /* Slightly lighter than terminal #1a1b26 */
  --bg: #1a1b26;
  --fg: #c0caf5;
  --prompt-color: #9ece6a;
  --command-color: #c0caf5;
  --link-color: #7dcfff;
  --accent: #bb9af7;
  --muted: #7C88C1;
}

[data-theme="catppuccin"] {
  --app-bg: #3C3C5C;          /* Slightly lighter than terminal #1e1e2e */
  --bg: #1e1e2e;
  --fg: #cdd6f4;
  --prompt-color: #a6e3a1;
  --command-color: #cdd6f4;
  --link-color: #89dceb;
  --accent: #cba6f7;
  --muted: #848AA6;
}

[data-theme="solarized"] {
  --app-bg: #073642;          /* Slightly lighter than terminal #002b36 */
  --bg: #002b36;
  --fg: #839496;
  --prompt-color: #859900;
  --command-color: #93a1a1;
  --link-color: #2aa198;
  --accent: #6c71c4;
  --muted: #7597A2;
}

/* ---- Halftone dot-grid cursor effect ---- */
canvas.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ---- Reset & base ---- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem 1rem;
  background: var(--app-bg);
  color: var(--fg);
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;        
  align-items: center;            
  transition: background 0.3s ease; /* Keeps the transition smooth */
}

/* ---- The window frame ---- */
.window {
  width: 95%;
  position: fixed;
  max-width: 1000px;
  max-height: calc(92vh - 2.5rem); /* leaves clearance so the fixed credit bar never overlaps the window's content */
  display: flex;                 /* NEW: lets the title bar stay fixed while .terminal scrolls independently */
  flex-direction: column;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;             /* clips the title bar's corners and anything inside to match */
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5); /* soft drop shadow — this alone sells the "floating window" illusion */
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.window-titlebar {
  flex-shrink: 0;                /* NEW: keeps the title bar from shrinking or scrolling away with the content */
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  background: rgba(255, 255, 255, 0.04); /* very subtle contrast from the window body */
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;           /* a square div with 50% radius becomes a perfect circle */
}

.dot-red    { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green  { background: #27c93f; }

.window-title {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.credit {
  position: absolute;      
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.6rem 1rem;
  opacity: 0.95;
  color: var(--accent);
  background: var(--bg);
  font-size: 0.7rem;
  text-align: center;
  z-index: 50;          
}

.terminal {
  padding: 1.5rem;
  padding-bottom: 3.5rem;
  flex: 1;             /* fills whatever space is left under the title bar */
  overflow-y: auto;    /* scrolls internally once content exceeds the available height */
  min-height: 0;       /* flex items default to a min-height that ignores this — same gotcha as min-width, just for the vertical axis */
}

/* ---- ASCII art ----
   Now that it lives inside a bounded window instead of the full page,
   it just needs to fit that window's width — fitAsciiArt() in script.js
   measures this element's own clientWidth, so no viewport-breakout trick
   is needed here anymore. */
.ascii-art {
  color: var(--accent);
  font-size: 10px;    /* fallback if JS doesn't run; JS overrides this with the exact fit */
  line-height: 1.2;
  margin: 0;
  white-space: pre;
  overflow-x: hidden; /* JS guarantees a fit, so no scrollbar should ever be needed */
  text-align: center;
}

.intro {
  color: var(--fg);
  margin: 0 0 1rem 0;
}

/* ---- Theme toggle button ---- */
.theme-switcher {
  position: relative;         /* so the dropdown can be positioned relative to this */
  display: inline-block;
  margin-bottom: 2rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--muted);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 0.3rem);   /* sit just below the button */
  left: 0;
  min-width: 140px;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 4px;
  list-style: none;
  margin: 0;
  padding: 0.3rem 0;
  display: none;               /* hidden until .open is added */
  z-index: 10;
}

.theme-menu.open {
  display: block;
}

.theme-menu li {
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.theme-menu li:hover {
  background: var(--muted);
}

.theme-menu li.active {
  color: var(--accent);
}

/* ---- Command blocks ---- */
.command-block {
  margin-bottom: 0.5rem;
}

.prompt {
  color: var(--prompt-color);
  margin: 0;
}

#workPromptLine {
  cursor: pointer;
  display: inline-block;
}

#workPromptLine:hover {
  text-decoration: underline;
}

.output-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.5rem;   /* indent output under the prompt, like a shell */
}

.output-list li {
  margin-bottom: 0.5rem;
}

.output-list a {
  color: var(--link-color);
  text-decoration: none;
}

.output-list a:hover {
  text-decoration: underline;
}

.output-list .date {
  color: var(--accent);
  margin-right: 0.75rem;
}

.output-list .details {
  color: var(--muted);
  display: block;
  margin-left: 0;
}

.output-list strong {
  color: var(--fg);
}

/* ---- Fade-in for output revealed by JS ---- */
.fade-in {
  animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- Blinking cursor ---- */
.cursor-line {
  margin-top: 3rem;
}

.cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---- Interactive input line ---- */
.input-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.prompt-label {
  color: var(--prompt-color);
  white-space: nowrap;
}

.terminal-input {
  flex: 1;
  min-width: 0;               /* flex items default to a min-width that ignores their container — this overrides that */
  background: none;
  border: none;
  outline: none;              /* remove the browser's default focus ring */
  color: var(--command-color);
  font-family: inherit;
  font-size: inherit;
  caret-color: var(--prompt-color); /* colors the blinking text cursor */
}

/* ---- Output printed by typed commands ---- */
#terminalOutput pre {
  font-family: inherit;
  white-space: pre-wrap;      /* preserves line breaks but still wraps on narrow screens */
  margin: 0 0 0.3rem 0;
}

#terminalOutput .echo-line {
  color: var(--prompt-color);
  margin-top: 1rem;
}

#terminalOutput .output-line {
  color: var(--fg);
}

/* ---- Small screens (phones) ---- */
@media (max-width: 480px) {
  body {
    padding: 1.25rem 0.75rem;  /* less wasted edge space than the default 2rem/1rem */
    font-size: 14px;
  }

  .output-list {
    padding-left: 1rem;        /* slightly less indent so text has more room */
  }

  .theme-menu {
    left: auto;
    right: 0;                  /* anchor to the right edge so it can't run off-screen on the left cutoff */
  }

  .work-split.split-active {
    flex-direction: column;
    gap: 0.75rem;
  }

  .work-split.split-active .work-list {
    flex: none;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 0;
    padding-bottom: 0.75rem;
    position: static;   /* Cancels the sticky positioning from desktop */
  }

  /* ================================================================== */
  /* NEW: Hide the folders/directory list when a project is selected  */
  /* ================================================================== */
  
  /* When the detail pane has actual project content, hide the folder list completely */
  .work-split.split-active:has(.case-study-title) .work-list {
    display: none !important;
  }

  /* Make sure the detail pane takes up the full width and handles display correctly */
  .work-split.split-active:has(.case-study-title) .work-detail {
    flex: 1 1 100%;
    max-width: 100%;
    opacity: 1;
  }

  .cursor-switcher {
    display: none !important;
  }
}

/*******************************************/
/* Styling for interactive sub-directories */
/*******************************************/
.clickable-dir {
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s ease;
}
.clickable-dir:hover {
  background: rgba(255, 255, 255, 0.08);
}
.dir-indicator {
  color: var(--link-color);
}
.hint-text {
  display: block;
  font-size: 0.85em;
  opacity: 0.8;
  margin: 0 0 0.75rem 0;
  color: var(--muted);
}
.back-line {
  color: var(--link-color);
  cursor: pointer;
  margin: 0 0 0.75rem 0;
}

.back-line:hover {
  text-decoration: underline;
}

.nested-prompt {
  margin: 4px 0;
  word-break: break-all;      /* NEW: Forces long strings like paths to break at any character if they run out of room */
  overflow-wrap: break-word;
}
.typed-command {
  color: #fff;
}
.meta-info {
  opacity: 0.5;
  margin-bottom: 8px;
}

/* ---- Split view for the work directory ----
   Starts as a single full-width column, matching the plain list look.
   Only once a directory is selected (.work-split.split-active) does the
   list narrow and the detail pane slide in beside it. */
.work-split {
  display: flex;
  gap: 0;
  margin-top: 0.75rem;
  transition: gap 0.35s ease;
}

.work-split.split-active {
  gap: 1.5rem;
}

.work-list {
  flex: 1 1 100%;
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
  border-right: 1px solid transparent;
  transition: flex-basis 0.35s ease, max-width 0.35s ease, border-color 0.35s ease, padding-right 0.35s ease;
}

.work-split.split-active .work-list {
  flex: 0 0 42%;
  max-width: 42%;
  padding-right: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.work-item {
  border-left: 2px solid transparent;
}

.work-item.active {
  background: rgba(255, 255, 255, 0.08);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
}

.work-detail {
  flex: 0 0 0%;
  max-width: 0;
  min-width: 0;
  padding-left: 0 !important;
  opacity: 0;
  overflow: hidden;
  transition: flex-basis 0.35s ease, max-width 0.35s ease, opacity 0.25s ease;
}

.work-split.split-active .work-detail {
  flex: 1 1 0%;
  max-width: 100%;
  opacity: 1;
  transition: flex-basis 0.35s ease, max-width 0.35s ease, opacity 0.3s ease 0.1s;
}

.detail-placeholder {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 480px) {
  .work-split.split-active {
    flex-direction: column;
    gap: 0.75rem;
  }

  .work-split.split-active .work-list {
    flex: none;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 0;
    padding-bottom: 0.75rem;
    position: static;   /* ADD THIS — cancels the sticky positioning from desktop */
  }

  .work-split.split-active .work-detail {
    max-width: 100%;
  }
}
.case-study-title {
  color: var(--accent);
  font-size: 0.95rem;
  margin: 0 0 0.75rem 0;
  font-weight: bold;

}

.case-study-meta {
  color: var(--fg);
  font-size: 0.8rem;
  margin: 0 0 1rem 0;
  line-height: 1.6;
}

.case-study-meta strong {
  color: var(--fg);
}

.tldr-label {
  color: var(--prompt-color);
  font-size: 0.8rem;
  font-weight: bold;
  margin: 0 0 0.4rem 0;
}

.tldr-text {
  color: var(--fg);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0 0 2rem 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent);
  background-color: rgba(255,255,255, 0.12);
}

.overview-label {
  color: var(--fg);
  font-size: 0.8rem;
  font-weight: bold;
  margin: 0 0 0.4rem 0;
}

.case-study-body p {
  color: var(--fg);
  font-size: 0.85rem;
  line-height: 1.7;
  margin: 0 0 0.9rem 0;
}

.case-study-gallery-wrapper {
  position: relative;
  margin: 0 0 1.1rem 0;
}

.case-study-gallery {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
}

.case-study-gallery::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.case-study-gallery img {
  flex: 0 0 auto;
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.case-study-gallery img:hover {
  opacity: 0.85;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.85);
  border: none;
  color: var(--bg);
  font-size: 1.3rem;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.85;
  z-index: 2;
  font-family: inherit;
}

.gallery-nav:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.35);
}

.gallery-prev { left: 4px; }
.gallery-next { right: 4px; }


.case-study-gallery img:hover {
  opacity: 0.85;
}

.image-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}

.image-modal.open {
  display: flex;
}

.image-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 90vw;
  cursor: default;
}

/*** newly added **/
.image-modal-img-wrapper {
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  scrollbar-width: none;
  transition: max-width 0.15s ease, max-height 0.15s ease;
}

.image-modal-img-wrapper::-webkit-scrollbar {
  display: none;
}

.image-modal-img-wrapper.zoomed {
  max-width: 96vw;
  max-height: 90vh;
  align-items: flex-start;
  justify-content: flex-start;
  cursor: grab;
  overflow: visible;
}

.image-modal-img-wrapper.zoomed.dragging {
  cursor: grabbing;
}
.image-modal img {
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.image-modal img.zoomed {
  cursor: zoom-out;
}

.image-modal-zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 24px;
  z-index: 1001;
}

.zoom-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.85;
  font-family: inherit;
}

.zoom-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}

.zoom-level {
  color: #fff;
  font-size: 0.8rem;
  opacity: 0.75;
  min-width: 42px;
  text-align: center;
  font-family: inherit;
}
/** **/

.image-modal-caption {
  color: var(--muted, #ccc);
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
  max-width: 70ch;
  font-family: inherit;
}

.image-modal-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 2rem;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  opacity: 0.8;
}

.image-modal-close:hover {
  opacity: 1;
}

.image-modal-counter {
  position: absolute;
  top: 24px;
  left: 30px;
  color: #fff;
  font-size: 0.85rem;
  opacity: 0.7;
  font-family: inherit;
}

.image-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.8;
  font-family: inherit;
}

.image-modal-nav:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}

.image-modal-prev {
  left: 20px;
}

.image-modal-next {
  right: 20px;
}

.case-study-link a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.case-study-link a:hover {
  text-decoration: underline;
}

.figma-link, .case-study-link {
  margin: 0 !important;
}

.figma-link a {
  color: var(--link-color);
  text-decoration: none;
  font-size: 0.85rem;
}

.figma-link a:hover {
  text-decoration: underline;
}


.work-split.split-active .work-list {
  position: sticky;
  top: 0;
  align-self: flex-start; 
}

/** video**/
.gallery-video-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 100px;
  height: 100px;
  cursor: pointer;
}
.gallery-video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.gallery-video-thumb .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 1.4rem;
  text-shadow: 0 0 6px rgba(0,0,0,0.7);
}

.gallery-figma-thumb .figma-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
}

@media (max-width: 480px) {
  .image-modal-nav {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .image-modal-prev {
    left: 8px;
  }

  .image-modal-next {
    right: 8px;
  }
}

/* Custom Cursor Active Classes */
body.cursor-wand,
body.cursor-wand * {
  cursor: url('img/wand.png') 0 0, auto !important;
}

body.cursor-sword,
body.cursor-sword * {
  cursor: url('img/sword.png') 0 0, auto !important;
}

/* Floating Widget Container */
.cursor-switcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg); /* Adapts automatically to your active terminal theme */
  border: 4px double var(--accent); /* Double border matching your theme accent */
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-family: inherit;
  z-index: 99999; /* Floats above the terminal window and background canvas */
}

.switcher-title {
  margin: 0 0 6px 0;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.cursor-options {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Cursor Buttons */
.cursor-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer !important;
  transition: all 0.2s ease;
}

.cursor-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  pointer-events: none;
}

.default-icon {
  font-size: 16px;
  font-weight: bold;
  color: var(--fg);
}

.cursor-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--muted);
}

.cursor-btn.active {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--prompt-color);
  box-shadow: 0 0 0 2px rgba(80, 250, 123, 0.25);
}

.cursor-btn.active .default-icon {
  color: var(--prompt-color);
}
