/* Dark fallback (JS-disabled / crawlers) */
:root {
  --bg: #1a1a1a;
  --bg-card: #252525;
  --text: #e0e0e0;
  --text-heading: #ffffff;
  --text-muted: #999;
  --accent: #4a9e7d;
  --accent-hover: #5cb893;
  --nav-bg: #111;
  --border: #333;
  --border-light: #444;
  --radius: 4px;
  --max-width: 1200px;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-card: #252525;
  --text: #e0e0e0;
  --text-heading: #ffffff;
  --text-muted: #999;
  --accent: #4a9e7d;
  --accent-hover: #5cb893;
  --nav-bg: #111;
  --border: #333;
  --border-light: #444;
}

[data-theme="light"] {
  --bg: #f4f3f0;
  --bg-card: #ffffff;
  --text: #2c2c2c;
  --text-heading: #1a1a1a;
  --text-muted: #6b6560;
  --accent: #2d7a5d;
  --accent-hover: #1e5c44;
  --nav-bg: #1a1a1a;
  --border: #d5d0c8;
  --border-light: #c0bab0;
}

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

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

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

/* Header */
.site-header {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  flex-shrink: 0;
  z-index: 100;
  transition: border-color 0.2s;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 60px;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-right: auto;
}

.main-nav { display: flex; gap: 0; }
.main-nav a {
  padding: 0 1rem;
  line-height: 60px;
  color: var(--text-muted);
  transition: color 0.2s;
}
.main-nav a:hover, .main-nav a.active { color: #fff; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 0.5rem; }

/* Theme toggle */
#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

#theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.08);
}

#theme-toggle:active {
  transform: scale(0.95);
}

/* Show/hide icon spans based on current mode */
#theme-toggle .theme-icon-system,
#theme-toggle .theme-icon-light,
#theme-toggle .theme-icon-dark { display: none; }

html[data-theme-mode="system"] #theme-toggle .theme-icon-system { display: inline; }
html[data-theme-mode="light"] #theme-toggle .theme-icon-light { display: inline; }
html[data-theme-mode="dark"] #theme-toggle .theme-icon-dark { display: inline; }

/* Main content */
main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
  overflow-y: auto;
  min-height: 0;
}

/* Hero */
.hero {
  text-align: center;
  padding: 4rem 1rem;
}

.hero h1 {
  font-size: 2.5rem;
  color: var(--text-heading);
  margin-bottom: 1rem;
}

.hero-tagline {
  font-size: 1.3rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-cta {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.8rem 2rem;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  transition: background 0.2s;
}

.hero-cta:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Page title */
.page-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--text-heading);
}

/* Section intro */
.section-intro {
  max-width: 800px;
  margin: 0 auto 2rem;
  line-height: 1.8;
}

.section-intro p + p { margin-top: 1em; }

/* Highlight cards (home page) */
.highlight-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

.highlight-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text);
  transition: transform 0.2s, background 0.2s;
}

.highlight-card:hover { transform: translateY(-4px); }

.highlight-card h3 {
  font-size: 1.2rem;
  color: var(--text-heading);
  margin-bottom: 0.5rem;
}

.highlight-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.highlight-card .card-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
}

.card-link {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.card-link:hover { color: var(--accent-hover); }

/* Service cards */
.service-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.service-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: background 0.2s;
}

.service-card h3 {
  font-size: 1.1rem;
  color: var(--text-heading);
  margin-bottom: 0.5rem;
}

.service-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Skills listing */
.skills-section {
  margin-top: 3rem;
}

.skills-section h2 {
  font-size: 1.4rem;
  color: var(--text-heading);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  transition: border-color 0.2s;
}

.skills-group {
  margin-bottom: 1rem;
}

.skills-group strong {
  color: var(--accent);
}

/* Project cards */
.project-cards {
  display: grid;
  gap: 2rem;
  margin-top: 1.5rem;
}

.project-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  transition: background 0.2s;
}

.project-card h3 {
  font-size: 1.3rem;
  color: var(--text-heading);
  margin-bottom: 0.3rem;
}

.project-card h3 a {
  color: var(--text-heading);
}

.project-card h3 a:hover {
  color: var(--accent);
}

.project-role {
  color: var(--accent);
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.project-card p {
  margin-bottom: 1rem;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tech-tag {
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 0.25rem 0.7rem;
  border-radius: 3px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}

/* About */
.about-content {
  max-width: 800px;
}

.about-content h2 {
  font-size: 1.3rem;
  color: var(--accent);
  margin: 2rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
  transition: border-color 0.2s;
}

.about-content h2:first-of-type { margin-top: 0; }

.about-content p + p { margin-top: 0.8rem; }

.about-content ul {
  list-style: none;
  margin-top: 0.5rem;
}

.about-content ul li {
  padding: 0.3rem 0;
  padding-left: 1.2rem;
  position: relative;
}

.about-content ul li::before {
  content: "\2022";
  color: var(--accent);
  position: absolute;
  left: 0;
}

/* Contact */
.contact-section {
  max-width: 600px;
}

.contact-item {
  margin-bottom: 1.5rem;
}

.contact-item h3 {
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.contact-item p, .contact-item a {
  font-size: 1.1rem;
}

/* Footer */
.site-footer {
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 0.5rem; }

/* Responsive */
@media (max-width: 768px) {
  .highlight-cards { grid-template-columns: 1fr; }
  .service-cards { grid-template-columns: 1fr; }

  .header-inner { flex-wrap: wrap; height: auto; padding: 0.8rem 0; }
  .main-nav { display: none; flex-direction: column; width: 100%; }
  .main-nav.open { display: flex; }
  .main-nav a { line-height: 2.5; }
  .nav-toggle { display: block; }

  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 2rem 0.5rem; }
  .page-title { font-size: 1.4rem; }

  .project-card { padding: 1.5rem; }
}

/* CTA Banner */
.cta-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  margin: 2.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  transition: background 0.2s, border-color 0.2s;
}

.cta-banner-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
}

.cta-banner-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.cta-banner-btn:hover { background: var(--accent-hover); }

@media (max-width: 768px) {
  .cta-banner {
    flex-direction: column;
    text-align: center;
    padding: 1.25rem;
  }
}

/* Chat Widget */
#chat-widget-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: background 0.2s, transform 0.2s;
}

#chat-widget-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

#chat-widget-btn.cw-hidden { display: none; }

#chat-widget-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 91;
  width: 440px;
  height: 600px;
  max-height: calc(100vh - 3rem);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
}

#chat-widget-panel.cw-open { display: flex; }

.cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  transition: border-color 0.2s;
}

.cw-title {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.cw-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.cw-close:hover { color: #fff; }

.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cw-msg {
  max-width: 85%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.cw-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.cw-msg-assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  transition: background 0.2s;
}

.cw-msg-error {
  color: #e57373;
}

.cw-msg-assistant strong { font-weight: 700; color: var(--text-heading); }
.cw-msg-assistant code {
  background: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
}
.cw-msg-assistant a { color: var(--accent); text-decoration: underline; }
.cw-msg-assistant a:hover { color: var(--accent-hover); }
.cw-msg-assistant ul, .cw-msg-assistant ol {
  margin: 0.3em 0;
  padding-left: 1.4em;
}
.cw-msg-assistant li { margin: 0.15em 0; }

.cw-limit-notice {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  transition: border-color 0.2s;
}

.cw-limit-notice a {
  color: var(--accent);
}

.cw-input-row {
  display: flex;
  border-top: 1px solid var(--border);
  padding: 0.5rem;
  gap: 0.5rem;
  transition: border-color 0.2s;
}

#cw-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: background 0.2s, border-color 0.2s;
}

#cw-input:focus {
  border-color: var(--accent);
}

#cw-input:disabled {
  opacity: 0.5;
}

#cw-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

#cw-send:hover { background: var(--accent-hover); }
#cw-send:disabled { opacity: 0.5; cursor: default; }

/* Chat callout bubble */
#cw-callout {
  position: fixed;
  bottom: 4.5rem;
  right: 1.5rem;
  z-index: 89;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s, background 0.2s, border-color 0.2s;
}

#cw-callout.cw-callout-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#cw-callout::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  transform: rotate(45deg);
}

@media (max-width: 768px) {
  #chat-widget-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }

  .cw-header {
    border-radius: 0;
  }
}
