/* ============================================
   THEME & CUSTOM PROPERTIES
   ============================================ */
:root {
  --font-heading: 'Fira Code', monospace;
  --font-body: 'IBM Plex Mono', monospace;
  --max-width: 720px;
  --green: #3fb950;
  --green-dim: #238636;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-terminal: #0d1117;
  --text: #e6edf3;
  --text-dim: #7d8590;
  --text-muted: #484f58;
  --border: #30363d;
  --accent: #3fb950;
  --accent-dim: #238636;
  --link: #58a6ff;
  --skill-bg: #21262d;
  --skill-fill: #3fb950;
  --tag-bg: #1f2328;
  --tag-border: #3fb950;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-terminal: #ffffff;
  --text: #1f2328;
  --text-dim: #656d76;
  --text-muted: #8b949e;
  --border: #d0d7de;
  --accent: #1a7f37;
  --accent-dim: #116329;
  --link: #0969da;
  --skill-bg: #eaeef2;
  --skill-fill: #1a7f37;
  --tag-bg: #dafbe1;
  --tag-border: #1a7f37;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 3rem 0;
}

/* ============================================
   BOOT OVERLAY
   ============================================ */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 2rem;
  cursor: pointer;
}

.boot-overlay.hidden {
  display: none;
}

.boot-text {
  font-family: var(--font-heading);
  font-size: 14px;
  color: #3fb950;
}

.boot-line {
  opacity: 0;
  animation: boot-appear 0.05s forwards;
  animation-delay: calc(var(--delay) * 0.22s);
}

.boot-skip-hint {
  color: #484f58;
  font-size: 12px;
}

@keyframes boot-appear {
  to { opacity: 1; }
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  z-index: 900;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 13px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

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

/* ============================================
   HERO
   ============================================ */
.hero {
  padding-top: 5rem;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.md-marker {
  color: var(--accent);
  user-select: none;
}

.hero-subtitle {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.hero-subtitle a {
  color: var(--accent);
}

.social-badges {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.social-badges a {
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  transition: color 0.2s, border-color 0.2s;
  text-decoration: none;
}

.social-badges a:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

/* ============================================
   BLINKING CURSOR
   ============================================ */
.cursor.blink {
  display: inline-block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  animation: blink-cursor 1s step-end infinite;
  margin-top: 0.5rem;
}

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

/* ============================================
   DIVIDERS
   ============================================ */
.divider {
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 12px;
  padding: 1.5rem 0;
  letter-spacing: 0.1em;
}

/* ============================================
   TERMINAL COMPONENTS
   ============================================ */
.terminal-prompt {
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  word-break: break-all;
}

.prompt-user {
  color: var(--accent);
}

.prompt-path {
  color: var(--link);
}

.terminal-window {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.terminal-window.small .terminal-body {
  padding: 1rem 1.25rem;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.terminal-dot.red { background: #ff5f57; }
.terminal-dot.yellow { background: #febc2e; }
.terminal-dot.green { background: #28c840; }

.terminal-titlebar-text {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.terminal-body {
  padding: 1.5rem;
}

.terminal-body p {
  margin-bottom: 1rem;
}

.terminal-body p:last-child {
  margin-bottom: 0;
}

/* ============================================
   ABOUT
   ============================================ */
.about-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.about-text {
  flex: 1;
}

.about-photo {
  flex-shrink: 0;
}

.polaroid {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.6rem 0.6rem 2rem;
  transform: rotate(2deg);
  width: 180px;
  transition: transform 0.3s ease;
}

.polaroid:hover {
  transform: rotate(0deg);
}

.polaroid img {
  width: 100%;
  display: block;
}

.polaroid-caption {
  display: block;
  text-align: center;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

/* ============================================
   SKILLS / RPG CHARACTER SHEET
   ============================================ */
.character-sheet-header {
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--accent);
  line-height: 1.5;
  overflow-x: auto;
}

.rpg-heading {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin: 2rem 0 1rem;
}

.pip-list {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 0.5rem;
}

.pip-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-heading);
  font-size: 13px;
}

.pip-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.pip-table tbody td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.pip-table tbody tr:last-child td {
  border-bottom: none;
}

.pip-table tbody tr:hover {
  background: var(--skill-bg);
}

.pip-table td:first-child {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.pip-table td:nth-child(2) {
  color: var(--accent);
  white-space: nowrap;
}

.pip-table td:nth-child(3) {
  color: var(--text-dim);
}

.pip-table .dim {
  color: var(--text-muted);
}

.achievements {
  list-style: none;
  font-family: var(--font-heading);
  font-size: 13px;
}

.achievements li {
  padding: 0.3rem 0;
}

.checkbox {
  color: var(--accent);
  margin-right: 0.25rem;
}

.verified {
  color: var(--accent);
  font-size: 11px;
}

.passive-abilities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ability-tag {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--tag-border);
  background: var(--tag-bg);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

/* ============================================
   GIT LOG / EXPERIENCE
   ============================================ */
.git-log {
  padding-left: 0.5rem;
}

.git-entry {
  display: flex;
  gap: 1rem;
  padding-bottom: 1.5rem;
}

.git-entry:last-child {
  padding-bottom: 0;
}

.git-graph {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
  position: relative;
}

.git-line {
  font-family: var(--font-heading);
  color: var(--border);
  line-height: 0;
  position: absolute;
  top: 0;
  bottom: 0;
}

.git-entry:not(:last-child) .git-graph::after {
  content: '';
  position: absolute;
  top: 16px;
  bottom: -1.5rem;
  width: 2px;
  background: var(--border);
  left: 50%;
  transform: translateX(-50%);
}

.git-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-top: 4px;
}

.git-dot.current {
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.git-details {
  flex: 1;
  min-width: 0;
}

.git-hash {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--accent);
  margin-right: 0.5rem;
}

.git-ref {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--link);
}

.git-details strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 14px;
  margin-top: 0.2rem;
}

.git-meta {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 0.15rem 0 0.4rem;
}

.git-details p {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0;
}

/* ============================================
   PUBLICATIONS
   ============================================ */
.section-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.section-quote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.publications {
  padding-left: 1.25rem;
}

.publications li {
  margin-bottom: 1.25rem;
  font-size: 14px;
  line-height: 1.6;
}

.pub-tag {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--accent);
  background: var(--tag-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ============================================
   HOBBIES / LS OUTPUT
   ============================================ */
.ls-output {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
}

.ls-table {
  font-family: var(--font-heading);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

/* ============================================
   CONTACT
   ============================================ */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.contact-item {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--text);
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border-color 0.2s, color 0.2s;
  text-decoration: none;
}

.contact-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  font-family: var(--font-heading);
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .boot-line {
    animation: none;
    opacity: 1;
  }

  .cursor.blink {
    animation: none;
    opacity: 1;
  }

  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .hero {
    padding-top: 3.5rem;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .about-content {
    flex-direction: column;
  }

  .about-photo {
    order: -1;
    align-self: center;
  }

  .polaroid {
    width: 160px;
    transform: rotate(1deg);
  }

  .pip-table thead {
    display: none;
  }

  .pip-table,
  .pip-table tbody,
  .pip-table tr,
  .pip-table td {
    display: block;
  }

  .pip-table tbody tr {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
  }

  .pip-table tbody tr:last-child {
    border-bottom: none;
  }

  .pip-table tbody td {
    padding: 0;
    border-bottom: none;
  }

  /* Package name + frequency on one line */
  .pip-table td:first-child {
    display: inline;
  }

  .pip-table td:nth-child(2) {
    display: inline;
  }

  .pip-table td:nth-child(2)::before {
    content: ' · ';
    color: var(--text-muted);
  }

  /* Notes on the next line */
  .pip-table td:nth-child(3) {
    display: block;
    margin-top: 0.2rem;
    font-size: 12px;
  }

  .character-sheet-header {
    font-size: 11px;
  }

  .git-details strong {
    font-size: 13px;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .section {
    padding: 2rem 0;
  }

  .ls-table {
    font-size: 11px;
  }
}

@media (max-width: 380px) {
  .container {
    padding: 0 1rem;
  }

  .social-badges a {
    font-size: 12px;
    padding: 0.15rem 0.4rem;
  }
}
