/* ── Custom Font ── */
@font-face {
  font-family: 'PortfolioFont';
  src: url('PxPlus_IBM_VGA_8x16.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --amber: #ffaa00;
  --amber-dim: #e07800;
  --amber-bright: #ffd280;
  --amber-glow: #ff8800;
  --bg: #0a0400;
  --bg-mid: #0f0600;
}

html, body {
  height: 100%;
  width: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'PortfolioFont', 'Courier New', Courier, monospace;
}

/* ── CRT Wrapper ── */
.crt-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

/* Vignette effect */
.crt-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 60%,
    rgba(0,0,0,0.3) 82%,
    rgba(0,0,0,0.65) 100%);
  pointer-events: none;
  z-index: 10;
}

/* Screen curvature shimmer */
.crt-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,140,0,0.03) 0%,
    transparent 50%,
    rgba(255,140,0,0.01) 100%
  );
  pointer-events: none;
  z-index: 11;
  animation: shimmer 8s ease-in-out infinite alternate;
}

@keyframes shimmer {
  0%   { opacity: 0.3; }
  100% { opacity: 1; }
}

/* ── Scanlines ── */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.18) 2px,
    rgba(0,0,0,0.18) 4px
  );
  pointer-events: none;
  z-index: 9;
}

/* ── Screen ── */
.screen {
  position: absolute;
  inset: 0;
  padding: 2.5rem 3rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Global text glow */
.screen, .screen * {
  color: var(--amber);
  text-shadow:
    0 0 4px var(--amber-glow),
    0 0 10px rgba(255, 106, 0, 0.4);
  letter-spacing: 0.03em;
}

/* ── Boot Sequence ── */
#boot {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}

#boot-text {
  white-space: pre;
  font-size: 0.97rem;
  line-height: 1.6;
}

/* ── Terminal ── */
.terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#output {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dim) transparent;
  padding-bottom: 0.5rem;
}

#output::-webkit-scrollbar { width: 4px; }
#output::-webkit-scrollbar-track { background: transparent; }
#output::-webkit-scrollbar-thumb { background: var(--amber-dim); }

/* ── Output Lines ── */
.line {
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre;
}

.line.echo {
  color: var(--amber-bright);
  text-shadow: 0 0 6px var(--amber-bright), 0 0 14px rgba(255,179,71,0.5);
}

.line.blank { min-height: 1.4em; }

.line.dim {
  color: var(--amber-dim);
  text-shadow: 0 0 3px rgba(196,106,0,0.4);
}

.line.bright {
  color: var(--amber-bright);
  text-shadow: 0 0 8px var(--amber-bright), 0 0 18px rgba(255,179,71,0.6);
}

.line.error {
  color: #ff4500;
  text-shadow: 0 0 6px rgba(255,69,0,0.7);
}

/* ── Input Line ── */
.input-line {
  display: flex;
  align-items: center;
  margin-top: 0.4rem;
  flex-shrink: 0;
}

.prompt {
  white-space: nowrap;
  font-size: 0.95rem;
  flex-shrink: 0;
}

#cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'PortfolioFont', 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  color: var(--amber-bright);
  text-shadow: 0 0 6px var(--amber-bright), 0 0 14px rgba(255,179,71,0.5);
  caret-color: var(--amber-bright);
}

/* Blinking cursor via input caret animation */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Flicker animation for the whole screen */
@keyframes flicker {
  0%   { opacity: 1; }
  92%  { opacity: 1; }
  93%  { opacity: 0.96; }
  94%  { opacity: 1; }
  96%  { opacity: 0.98; }
  97%  { opacity: 0.94; }
  98%  { opacity: 1; }
  100% { opacity: 1; }
}

.screen {
  animation: flicker 6s linear infinite;
}

/* ── Typing cursor on output ── */
.typing-cursor::after {
  content: '█';
  animation: blink 0.8s step-end infinite;
  color: var(--amber-bright);
}

/* ── Responsive ──
   Boot/terminal lines are fixed-width ASCII box art (66 chars wide
   including borders), so on narrow phones the font must shrink enough
   for a full line to fit or the box borders break. #cmd-input is kept
   at 16px regardless of tier — anything smaller triggers iOS Safari's
   auto-zoom-on-focus. */
@media (max-width: 640px) {
  .screen { padding: 1.2rem 1rem; }
  .line, .prompt, #boot-text { font-size: 0.78rem; }
  #cmd-input { font-size: 16px; }
}

@media (max-width: 480px) {
  .line, .prompt, #boot-text { font-size: 0.68rem; }
}

@media (max-width: 400px) {
  .line, .prompt, #boot-text { font-size: 0.55rem; }
}

/* ════════════════════════════════════════════════════════════════
   PROJECTS APPLICATION
   ════════════════════════════════════════════════════════════════ */

.projects-app {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  outline: none;
}

/* ── App bar ── */
.projects-app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.4rem;
  border-bottom: 1px solid var(--amber-dim);
  flex-shrink: 0;
  background: rgba(255, 140, 0, 0.05);
}

.app-bar-title {
  font-size: 0.82rem;
  color: var(--amber-bright);
  text-shadow: 0 0 8px var(--amber-bright), 0 0 18px rgba(255,179,71,0.4);
  letter-spacing: 0.06em;
}

.app-bar-hint {
  font-size: 0.72rem;
  color: var(--amber-dim);
  text-shadow: none;
}

/* ── Body split ── */
.projects-app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.projects-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--amber-dim);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dim) transparent;
}

.projects-sidebar::-webkit-scrollbar { width: 3px; }
.projects-sidebar::-webkit-scrollbar-thumb { background: var(--amber-dim); }

.proj-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(196, 106, 0, 0.18);
  transition: background 0.1s;
}

.proj-item:hover {
  background: rgba(255, 140, 0, 0.07);
}

.proj-item.active {
  background: rgba(255, 140, 0, 0.13);
  border-left: 2px solid var(--amber);
  padding-left: calc(1rem - 2px);
}

.proj-item-num {
  font-size: 0.7rem;
  color: var(--amber-dim);
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.proj-item-name {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--amber);
}

.proj-item.active .proj-item-name {
  color: var(--amber-bright);
  text-shadow: 0 0 6px var(--amber-bright);
}

/* ── Detail panel ── */
.projects-detail {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dim) transparent;
}

.projects-detail::-webkit-scrollbar { width: 3px; }
.projects-detail::-webkit-scrollbar-thumb { background: var(--amber-dim); }

/* ── Image ── */
.proj-img-wrap {
  width: 100%;
  height: 340px;
  margin-bottom: 1.2rem;
  border: 1px solid var(--amber-dim);
  overflow: hidden;
  position: relative;
}

.proj-img-wrap img.proj-photo {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: sepia(1) hue-rotate(-10deg) saturate(5) brightness(0.72) contrast(1.1);
}

.proj-img-wrap.loaded img.proj-photo {
  display: block;
}

.proj-img-wrap.loaded .proj-placeholder {
  display: none;
}

.proj-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 140, 0, 0.03),
    rgba(255, 140, 0, 0.03) 1px,
    transparent 1px,
    transparent 10px
  );
  color: var(--amber-dim);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

.proj-placeholder-border {
  border: 1px solid rgba(196, 106, 0, 0.4);
  padding: 0.4rem 1.2rem;
}

/* ── Detail content ── */
.proj-detail-title {
  font-size: 1.05rem;
  color: var(--amber-bright);
  text-shadow: 0 0 8px var(--amber-bright), 0 0 20px rgba(255,179,71,0.4);
  margin-bottom: 0.15rem;
}

.proj-detail-subtitle {
  font-size: 0.82rem;
  color: var(--amber);
  margin-bottom: 0.2rem;
}

.proj-detail-year {
  font-size: 0.75rem;
  color: var(--amber-dim);
  margin-bottom: 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(196, 106, 0, 0.25);
}

.proj-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.proj-tag {
  border: 1px solid rgba(196, 106, 0, 0.5);
  padding: 0.1rem 0.55rem;
  font-size: 0.7rem;
  color: var(--amber-dim);
  letter-spacing: 0.04em;
}

.proj-body {
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--amber);
}

.proj-body p {
  margin-bottom: 0.8rem;
}

.proj-awards {
  margin-top: 1rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(196, 106, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.proj-award {
  font-size: 0.8rem;
  color: var(--amber-bright);
  text-shadow: 0 0 6px rgba(255,179,71,0.4);
}

/* ── Side layout (image right, text left) ── */
.proj-side-layout {
  display: flex;
  gap: 1.5rem;
  min-height: 100%;
}

.proj-side-left {
  flex: 1;
  min-width: 0;
}

.proj-side-right {
  width: 400px;
  flex-shrink: 0;
}

.proj-side-right .proj-img-wrap {
  height: calc(100vh - 8rem);
  max-height: 680px;
  margin-bottom: 0;
}

/* Stack the side layout before the fixed-width image column starts
   squeezing the text column (happens anywhere below ~900px). */
@media (max-width: 900px) {
  .proj-side-layout { flex-direction: column; }
  .proj-side-right { width: 100%; }
  .proj-side-right .proj-img-wrap {
    height: 340px;
    max-height: none;
    margin-bottom: 1.2rem;
  }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .projects-app-body { flex-direction: column; }
  .projects-sidebar { width: 100%; height: 160px; border-right: none; border-bottom: 1px solid var(--amber-dim); }
  .projects-detail { padding: 0.8rem 1rem; }
  .proj-img-wrap { height: 200px; }
  .proj-side-right .proj-img-wrap { height: 200px; }
}
