/* Minimal CSS for IPFS-compatible static site
   - Pure CSS
   - Responsive (desktop & mobile)
   - Dark mode toggle using CSS :has() selector
   - Based on Tailwind styling from Next.js version */

/* ---------- Design tokens (Light mode default) ---------- */
:root {
  --color-bg: #f9fafb;
  --color-bg-card: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-anchor: #2563eb;
  --color-anchor-hover: #1d4ed8;
  --color-heading: #111827;
  --color-divider: #e5e7eb;
  --color-border: #e5e7eb;
  --color-shadow: rgba(0, 0, 0, 0.1);
  --color-gradient-from: #2563eb;
  --color-gradient-to: #4f46e5;
  --color-blockquote-from: #f9fafb;
  --color-blockquote-to: #eff6ff;
  --color-blockquote-border: #3b82f6;
}

/* Pure CSS dark mode using :has() selector - when checkbox #switch is checked */
body:has(#switch:checked) {
  --color-bg: #111827;
  --color-bg-card: #1f2937;
  --color-text: #ffffff;
  --color-text-muted: #9ca3af;
  --color-anchor: #60a5fa;
  --color-anchor-hover: #93c5fd;
  --color-heading: #ffffff;
  --color-divider: #374151;
  --color-border: #374151;
  --color-shadow: rgba(0, 0, 0, 0.3);
  --color-blockquote-from: #1f2937;
  --color-blockquote-to: rgba(30, 58, 138, 0.2);
  --color-blockquote-border: #60a5fa;
}

/* Fallback for users that prefer a dark scheme and toggle is unchecked */
@media (prefers-color-scheme: dark) {
  body:not(:has(#switch)) {
    --color-bg: #111827;
    --color-bg-card: #1f2937;
    --color-text: #ffffff;
    --color-text-muted: #9ca3af;
    --color-anchor: #60a5fa;
    --color-anchor-hover: #93c5fd;
    --color-heading: #ffffff;
    --color-divider: #374151;
    --color-border: #374151;
    --color-shadow: rgba(0, 0, 0, 0.3);
    --color-blockquote-from: #1f2937;
    --color-blockquote-to: rgba(30, 58, 138, 0.2);
    --color-blockquote-border: #60a5fa;
  }
}

/* ---------- Global element styles ---------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

/* Links */
a {
  color: var(--color-anchor);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover, a:focus {
  color: var(--color-anchor-hover);
  text-decoration: underline;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-heading);
  line-height: 1.25;
  margin-top: 1.2em;
  margin-bottom: 0.6em;
  font-weight: 700;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* Images */
img, svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Layout ---------- */
.container {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

@media (min-width: 640px) {
  .container {
    padding: 2rem 1.5rem;
  }
}

/* Main content area */
main {
  background: var(--color-bg);
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px var(--color-shadow);
}

/* ---------- Navigation ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 1px 3px var(--color-shadow);
  backdrop-filter: blur(8px);
  opacity: 0.98;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

@media (min-width: 640px) {
  .nav-links {
    gap: 1.5rem;
  }
}

.nav-link {
  position: relative;
  color: var(--color-anchor);
  font-weight: 600;
  padding: 0.25rem 0.5rem;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: var(--color-anchor);
  transition: width 0.2s;
}

.nav-link:hover::after {
  width: 100%;
}

.nav-link:hover {
  text-decoration: none;
}

/* ---------- Pure CSS Color mode switch ---------- */
#color-mode-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  gap: 4px;
}

/* Sun and Moon icons */
#color-mode-switch svg {
  width: 24px;
  height: 24px;
  margin: 0 4px;
  stroke: var(--color-text);
  transition: opacity 0.3s;
}

/* Hide checkbox but keep it functional */
#color-mode-switch input[type=checkbox] {
  height: 0;
  width: 0;
  margin: 0;
  visibility: hidden;
  position: absolute;
}

/* Toggle switch label */
#color-mode-switch label {
  cursor: pointer;
  text-indent: -9999px;
  width: 42px;
  height: 21px;
  border-radius: 30px;
  background: var(--color-anchor);
  display: block;
  position: relative;
  margin: 0;
  transition: background 0.3s;
}

/* Toggle switch button */
#color-mode-switch label:after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  background: #fff;
  border-radius: 90px;
  transition: 0.3s;
}

/* Move toggle when checked */
#color-mode-switch input:checked + label:after {
  left: calc(100% - 3px);
  transform: translateX(-100%);
}

/* Optional: fade sun/moon icons based on mode */
body:has(#switch:checked) #color-mode-switch svg:first-child {
  opacity: 0.5;
}

body:has(#switch:checked) #color-mode-switch svg:last-child {
  opacity: 1;
}

body:not(:has(#switch:checked)) #color-mode-switch svg:first-child {
  opacity: 1;
}

body:not(:has(#switch:checked)) #color-mode-switch svg:last-child {
  opacity: 0.5;
}

/* ---------- Sections ---------- */
section {
  padding-bottom: 2rem;
  margin-bottom: 2rem;
}

.section-border {
  border-bottom: 1px solid var(--color-divider);
}

.section-header {
  margin-bottom: 1.5rem;
}

.section-header h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.gradient-bar {
  height: 4px;
  width: 15rem;
  background: linear-gradient(to right, var(--color-gradient-from), var(--color-gradient-to));
  border-radius: 9999px;
}

/* ---------- Profile section ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: center;
}

@media (min-width: 640px) {
  .profile-grid {
    grid-template-columns: 1fr 2fr;
  }
}

.profile-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2.5rem;
}

.profile-img {
  width: 12rem;
  height: 12rem;
  border-radius: 9999px;
  border: 4px solid var(--color-border);
  box-shadow: 0 10px 15px -3px var(--color-shadow);
  transition: box-shadow 0.3s;
  object-fit: cover;
}

.profile-img:hover {
  box-shadow: 0 20px 25px -5px var(--color-shadow);
}

.social-links {
  display: flex;
  gap: 1.25rem;
  padding-top: 1rem;
}

.social-icon {
  width: 1.5rem;
  height: 1.5rem;
  transition: transform 0.3s;
  fill: var(--color-text);
}

.social-icon:hover {
  transform: scale(1.1);
}

/* Hide dark images in light mode, show light images */
body:not(:has(#switch:checked)) img[data-logo][src*="-dark"] {
  display: none !important;
}

body:not(:has(#switch:checked)) img[data-logo][src*="-light"] {
  display: inline-block !important;
}

/* Hide light images in dark mode, show dark images */
body:has(#switch:checked) img[data-logo][src*="-light"] {
  display: none !important;
}

body:has(#switch:checked) img[data-logo][src*="-dark"] {
  display: inline-block !important;
}

/* Default to light mode for systems without :has() support */
@media (prefers-color-scheme: dark) {
  body:not(:has(#switch)) img[data-logo][src*="-light"] {
    display: none !important;
  }

  body:not(:has(#switch)) img[data-logo][src*="-dark"] {
    display: inline-block !important;
  }
}

/* Calendar icon for writings page - handled by .writing-meta img below */

.profile-bio {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Blockquote */
blockquote {
  background: linear-gradient(to right, var(--color-blockquote-from), var(--color-blockquote-to));
  border-left: 4px solid var(--color-blockquote-border);
  padding: 1.5rem;
  font-style: italic;
  margin: 1rem 0;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px var(--color-shadow);
  text-align: justify;
  line-height: 1.75;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-bg-card);
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px var(--color-shadow);
  border: 1px solid var(--color-border);
  transition: box-shadow 0.3s;
}

.card:hover {
  box-shadow: 0 10px 15px -3px var(--color-shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Interest lists ---------- */
.interest-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.interest-list li {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
}

.interest-list .icon {
  font-size: 1.25rem;
  margin-right: 0.75rem;
}

/* ---------- Portfolio layout ---------- */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
  }
}

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

.work-item h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.work-date {
  font-size: 0.875rem;
  color: var(--color-anchor);
  font-weight: 600;
  margin-bottom: 1rem;
}

.work-description {
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--color-text);
}

.project-border {
  padding-left: 1rem;
  border-left: 4px solid var(--color-anchor);
  margin-bottom: 1rem;
}

.project-border h5 {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
}

/* ---------- Writings ---------- */
.writing-item {
  border-bottom: 1px solid var(--color-divider);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}

.writing-item:last-child {
  border-bottom: none;
}

.writing-meta {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.writing-meta img {
  width: 20px;
  height: 20px;
  margin-right: 0.5rem;
}

/* ---------- Footer ---------- */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-divider);
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

footer p {
  margin: 0.5rem 0;
}

/* ---------- Utility classes ---------- */
.text-muted {
  color: var(--color-text-muted);
}

.font-medium {
  font-weight: 500;
}

.font-bold {
  font-weight: 700;
}

.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

/* ---------- Responsive typography (portrait mode) ---------- */
@media only screen and (orientation: portrait) and (min-width: 768px) {
  h1 { font-size: 3rem; }
  h2 { font-size: 2.5rem; }
  h3 { font-size: 1.75rem; }
  body { font-size: 1.1rem; }
}