/* =========================================================
   Ryan Tran — Portfolio
   Design concept: a code editor. Nav = file tabs, hero =
   an open file with a "person" object, sections read like
   commented code blocks. Signature element: the window
   chrome (traffic-light dots + tab bar) that frames the
   whole page.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #12141c;
  --surface: #1a1d29;
  --surface-raised: #20232f;
  --border: #2b2f40;
  --text: #e7e6ea;
  --text-muted: #8b8fa3;
  --accent: #f2b84b;      /* Monkey King gold — nods to Wukong's Journey */
  --accent-soft: #f2b84b26;
  --teal: #6ee7c8;         /* secondary accent, used like a string literal */
  --pink: #ff8fa3;         /* used sparingly, like a keyword */
  --dot-red: #ff5f56;
  --dot-yellow: #ffbd2e;
  --dot-green: #27c93f;
  --shadow: 0 20px 50px -20px rgba(0,0,0,0.5);
  --radius: 10px;
  color-scheme: dark;
}

body.dark-theme {
  /* dark-theme class kept for the existing toggle button;
     the site now defaults to the dark ("editor") theme. */
}

body:not(.dark-theme) {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e3e1da;
  --text: #1c1e27;
  --text-muted: #6b6f80;
  --accent: #b8791a;
  --accent-soft: #b8791a1f;
  --teal: #0f9d78;
  --pink: #d1436a;
  --shadow: 0 20px 50px -25px rgba(20,20,30,0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
  transition: background-color 0.4s ease, color 0.4s ease;
  /* Symmetric horizontal gutter + notch safety. Applied on the body (not the
     shell's margins) so the max-width shell keeps its `auto` centering on
     desktop while still getting a small edge gutter and safe-area inset on
     phones. env() is 0 on non-notched/desktop screens, so this stays even. */
  padding-left: max(clamp(0.5rem, 4vw, 3rem), env(safe-area-inset-left));
  padding-right: max(clamp(0.5rem, 4vw, 3rem), env(safe-area-inset-right));
  /* never let a stray wide element cause sideways scroll on a phone */
  overflow-x: hidden;
}

::selection { background: var(--accent-soft); color: var(--accent); }

.mono {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
}

a { color: inherit; }

/* -------------------- Editor chrome shell -------------------- */

.editor-shell {
  max-width: 1200px;
  /* auto keeps the shell centered on desktop; the horizontal gutter/notch
     spacing lives on the body padding below so it never breaks centering */
  margin: clamp(1rem, 4vw, 3rem) auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--surface);
}

.title-bar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 1rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
}

.dots { display: flex; gap: 0.4rem; flex-shrink: 0; }
.dots span {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block;
}
.dots .red { background: var(--dot-red); }
.dots .yellow { background: var(--dot-yellow); }
.dots .green { background: var(--dot-green); }

.title-bar .filename {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.title-bar .spacer { flex: 1; }

#toggle-theme {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}

#toggle-theme:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

#toggle-theme:focus-visible,
a:focus-visible,
.project:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tab bar acts as the primary nav */
.tab-bar {
  display: flex;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* smooth momentum scroll on iOS + a clean, scrollbar-free file-tab strip */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-bar a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.75rem 1.1rem;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  position: relative;
  scroll-snap-align: start;
  transition: color 0.25s ease, background 0.25s ease;
}

.tab-bar a:hover { color: var(--text); background: var(--surface-raised); }

.tab-bar a.active {
  color: var(--accent);
  background: var(--bg);
}

.tab-bar a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.tab-bar a .dim { color: var(--pink); }

/* -------------------- Hero -------------------- */

.hero {
  padding: clamp(2rem, 8vw, 4rem) clamp(1.25rem, 5vw, 3rem);
  background: linear-gradient(135deg, var(--bg) 0%, var(--surface) 100%);
  position: relative;
  min-height: 50vh;
  display: flex;
  align-items: center;
}

.hero-content {
  width: 100%;
  max-width: 680px;
}

.hero-intro h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.hero-subtitle {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 2rem;
  max-width: 55ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.cta-primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

@media (hover: hover) {
  .cta-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(242, 184, 75, 0.2);
  }

  .cta-secondary:hover {
    background: var(--accent-soft);
    transform: translateY(-2px);
  }
}

.cta-primary:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(242, 184, 75, 0.18);
}

.cta-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cta-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.cta-secondary:active {
  transform: translateY(0);
}

.cta-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .hero-cta {
    flex-direction: column;
    width: 100%;
  }
  
  .cta-button {
    width: 100%;
  }
}

/* -------------------- Sections -------------------- */

section {
  padding: 2.25rem clamp(1.25rem, 5vw, 3rem);
  border-top: 1px solid var(--border);
}

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--teal);
  margin: 0 0 0.9rem;
  letter-spacing: 0.02em;
}

.section-label::before { content: "// "; color: var(--text-muted); }

h2 {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1.4rem;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

section#about p {
  max-width: 60ch;
  color: var(--text);
}

/* About — experience timeline */

.timeline-heading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--teal);
  letter-spacing: 0.02em;
  margin: 2rem 0 1.25rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

/* the vertical rail */
.timeline::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 7px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding: 0 0 1.6rem 2rem;
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-body {
  flex: 1;
  min-width: 0;
}

/* experience logo on the right of each item */
.timeline-logo {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  padding: 6px;
  align-self: center;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

@media (hover: hover) {
  .timeline-item:hover .timeline-logo {
    border-color: var(--accent);
    transform: translateY(-2px);
  }

  .timeline-item:hover::before {
    background: var(--accent);
    transform: scale(1.15);
  }
}

@media (max-width: 560px) {
  .timeline-logo {
    width: 48px;
    height: 48px;
  }
}

/* the node on the rail */
.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
  transition: background 0.25s ease, transform 0.25s ease;
}

.timeline-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin: 0 0 0.5rem;
}

.timeline-body h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}

.timeline-org {
  color: var(--accent);
  font-weight: 500;
}

.timeline-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* Projects */

.projects-grid {
  display: grid;
  /* min() lets the track shrink below 320px on narrow phones instead of
     forcing a fixed 320px column that overflows the editor shell */
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.project-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.project-image-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.4rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: -0.01em;
}

@media (hover: hover) {
  .project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
  }

  /* subtle zoom on the real cover image, matching the placeholder's hover scale */
  .project-card:hover .project-image {
    transform: scale(1.04);
  }

  .project-card:hover .project-placeholder {
    opacity: 0.25;
    transform: scale(1.05);
  }
}

.project-visual {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: var(--border);
  flex-shrink: 0;
}

.project-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--text);
  opacity: 0.15;
  transition: all 0.3s ease;
}

/* Theme colors for project placeholders */
.project-placeholder[data-theme="purple"] {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: rgba(255, 255, 255, 0.2);
}

.project-placeholder[data-theme="pink"] {
  background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
  color: rgba(255, 255, 255, 0.2);
}

.project-placeholder[data-theme="teal"] {
  background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  color: rgba(255, 255, 255, 0.2);
}

.project-placeholder[data-theme="gold"] {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: rgba(255, 255, 255, 0.2);
}

.project-placeholder[data-theme="green"] {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: rgba(255, 255, 255, 0.2);
}

.project-placeholder[data-theme="orange"] {
  background: linear-gradient(135deg, #ff700a 0%, #ea580c 100%);
  color: rgba(255, 255, 255, 0.2);
}

.project-content {
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-content h3 {
  margin: 0 0 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.project-content p {
  margin: 0.4rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.project-content .stack-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--teal);
  margin: 0.8rem 0 1rem;
  font-weight: 500;
}

.project-content a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
  margin-top: auto;
}

.project-content a:hover {
  border-color: var(--accent);
}

.project-content a::after {
  content: "→";
  transition: transform 0.2s ease;
}

.project-content a:hover::after {
  transform: translateX(2px);
}

/* Skills */

.skills-grid {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0;
  margin: 0;
}

.skills-grid li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem 0.5rem 0.6rem;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

@media (hover: hover) {
  .skills-grid li:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    background: var(--surface-raised);
  }
}

.skills-grid img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.skills-grid span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text);
}

/* Frameworks */

.frameworks-grid {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0;
  margin: 1.5rem 0 0;
}

.frameworks-grid li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem 0.5rem 0.6rem;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

@media (hover: hover) {
  .frameworks-grid li:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    background: var(--surface-raised);
  }
}

.frameworks-grid img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.frameworks-grid span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text);
}

/* Contact */

.contact-section {
  border-top: none;
}

.contact-intro {
  color: var(--text-muted);
  max-width: 50ch;
  margin-top: -0.4rem;
  margin-bottom: 1.5rem;
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
}

.contact-list li {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

@media (hover: hover) {
  .contact-list li:hover { border-color: var(--accent); transform: translateX(3px); }
}

.contact-list .key { color: var(--teal); flex-shrink: 0; }
.contact-list a { color: var(--accent); text-decoration: none; word-break: break-all; }
.contact-list a:hover { text-decoration: underline; }

/* Footer / status bar */

footer {
  padding: 0.7rem 1.25rem;
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

footer .status-ok { color: var(--dot-green); }

/* Scroll reveal */

/* Only hide when JS is running (html.js is set by index.js), so content can
   never get stuck invisible if the script fails to load. */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* -------------------- Responsive / mobile -------------------- */

@media (max-width: 560px) {
  .code-block { font-size: 0.78rem; }
  .line-no { width: 1.6em; }
  h2 { font-size: 1.2rem; }

  /* tighten section rhythm so more content is reachable per screen */
  section { padding: 1.75rem clamp(1rem, 5vw, 3rem); }

  /* the hero subtitle can run edge-to-edge on a phone */
  .hero-subtitle { font-size: 1.02rem; }

  /* stack each timeline logo under its text instead of squeezing a 48px
     thumbnail beside a full paragraph on a ~320px screen */
  .timeline-item {
    flex-direction: column;
    gap: 0.9rem;
  }
  .timeline-logo {
    width: 44px;
    height: 44px;
    align-self: flex-start;
  }
}

/* Coarse pointer (touch): guarantee comfortable 44px tap targets.
   Keyed on input method, not screen width, so a touch laptop benefits too. */
@media (pointer: coarse) {
  .tab-bar a {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
  }

  #toggle-theme {
    padding: 0.6rem 0.8rem;
  }

  .project-content a {
    padding: 0.35rem 0;
  }

  /* give the section-nav dots and skill/framework pills a bit more height */
  .skills-grid li,
  .frameworks-grid li {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }
}

/* -------------------- Scroll progress / section nav -------------------- */

.scroll-nav {
  position: fixed;
  top: 50%;
  left: clamp(0.75rem, 2vw, 1.75rem);
  transform: translateY(-50%);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

/* revealed once the user scrolls past the hero */
.scroll-nav.is-shown {
  opacity: 1;
  visibility: visible;
}

.scroll-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  position: relative;
}

/* the vertical rail connecting the nodes — mirrors the About timeline */
.scroll-nav ul::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 7px;
  width: 2px;
  background: var(--border);
}

.scroll-nav li {
  position: relative;
}

.scroll-nav a {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
}

.scroll-nav-dot {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-muted);
  box-shadow: 0 0 0 4px var(--bg);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.scroll-nav-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
}

/* reveal the label on hover / focus / for the active section */
.scroll-nav a:hover .scroll-nav-label,
.scroll-nav a:focus-visible .scroll-nav-label,
.scroll-nav a.active .scroll-nav-label {
  opacity: 1;
  transform: translateX(0);
}

.scroll-nav a:hover .scroll-nav-dot,
.scroll-nav a:focus-visible .scroll-nav-dot {
  border-color: var(--accent);
  transform: scale(1.15);
}

.scroll-nav a.active .scroll-nav-dot {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}

.scroll-nav a.active .scroll-nav-label {
  color: var(--accent);
}

.scroll-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-nav,
  .scroll-nav-dot,
  .scroll-nav-label {
    transition: none;
  }
}

/* hide on narrow screens where it would overlap content */
@media (max-width: 720px) {
  .scroll-nav { display: none; }
}
