/* Site-wide Settings */
:root {
  /* Typography */
  --font-family: "Merriweather", Georgia, "Times New Roman", serif;
  --font-size-base: 16px;
  --line-height: 1.6;
  
  /* Base Colors */
  --c-white: #ffffff;
  --c-black: #1a1a1a;
  --c-cream: rgb(253, 234, 207);
  --c-cream-dark: rgb(233, 214, 187);
  --c-cream-darker: rgb(213, 194, 167);
  --c-navy-dark: #090438;
  --c-navy-darker: #030117;
  --c-orange-200: #fed7aa;
  --c-orange-300: #fdba74;
  
  /* Layout */
  --max-width: 42rem;
  --padding-page: 1.5rem;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
}

/* Theme Classes */
.c--theme-light {
  --color-bg: linear-gradient(155deg, #F4F3EC, #F4F3EC);
  --color-text: var(--c-navy-darker);
  --color-text-secondary: var(--c-navy-dark);
  --color-link: var(--c-navy-darker);
  --color-link-hover: #d57d1e;
  --color-border: rgb(230, 230, 230);
}

.c--theme-dark {
  --color-bg: linear-gradient(155deg, var(--c-navy-darker), var(--c-navy-dark));
  --color-text: var(--c-cream);
  --color-text-secondary: rgba(253, 234, 207, 0.7);
  --color-link: var(--c-cream);
  --color-link-hover: var(--c-white);
  --color-border: rgba(253, 234, 207, 0.15);
}

/* Base Styles */
html {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-y: scroll; /* Always show scrollbar */
  scrollbar-gutter: stable; /* Reserve space for scrollbar */
}

body {
  margin: 0 auto;
  padding: 0 var(--padding-page);
  width: 672px;
  line-height: var(--line-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--color-bg);
  color: var(--color-text);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-family: var(--font-family);
  font-weight: 700;
  margin: var(--space-lg) 0 var(--space-md);
}

p, li, span {
  color: var(--color-text);
  margin: var(--space-md) 0;
}

/* Links */
a,
a:link,
a:visited,
a:hover,
a:active,
.site-name,
button,
[role="button"],
.theme-toggle {
  cursor: pointer !important;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--color-link);
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

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

/* Remove any existing -webkit-any-link styles */
:-webkit-any-link {
  cursor: pointer !important;
}

/* Ensure pointer cursor persists during interaction */
*:hover {
  cursor: inherit;
}

/* Navigation */
.main-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-group-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

.nav-links li {
  margin: 0;
  display: flex;
  align-items: center;
}

.site-name {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.1rem;
  cursor: pointer !important;
}

.site-name a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.site-logo {
  margin-right: 0;
  color: var(--color-text);
  display: block;
}

/* Interactive Elements */
a,
button,
.site-name,
[role="button"],
[onclick] {
  cursor: pointer;
}

/* Interactive Elements Base Styles */
button,
.theme-toggle,
.site-name,
[role="button"] {
  cursor: pointer !important;
}

/* About Page */
.about-wrapper {
  margin: 2rem 0;
}

.about-content {
  margin-top: var(--space-md);
}

/* Post Content Images */
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--space-lg) auto;
}

.post-content figure {
  margin: var(--space-lg) 0;
  width: 100%;
}

.post-content figure img {
  width: 100%;
  height: auto;
  margin: 0;
}

.post-content figure figcaption {
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  padding: 0 var(--padding-page);
}

/* Post Items */
.post-item time, 
.stream-item time {
  color: var(--color-text-secondary);
}

.post-item h2 a,
.project-card h2 a {
  color: var(--color-text);
  transition: color 0.2s ease;
}

.post-item h2 a:hover,
.project-card h2 a:hover {
  color: var(--color-link-hover);
}

.post-item p,
.project-description {
  color: var(--color-text-secondary);
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  margin: var(--space-lg) 0;
  width: 100%;
}

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

.project-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-text);
}

.project-image {
  width: 100%;
  aspect-ratio: 1/1;
  overflow: hidden;
  border-radius: 3px;
  position: relative;
}

.project-image a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.3s ease;
}

.project-card:hover .project-image img,
.project-image a:hover img,
.project-image a:focus img {
  transform: scale(1.02);
}

.project-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.project-card h2 {
  margin: 0;
  font-size: 1.25rem;
  text-align: center;
}

.project-card .project-description {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.technology-list {
  list-style: none;
  padding: 0;
  margin: var(--space-sm) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.technology-tag {
  font-size: 0.8rem;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-border);
  border-radius: 3px;
  color: var(--color-text);
  margin: 0;
}

/* Utility Classes */
.mt-1 { margin-top: var(--space-md); }
.mb-1 { margin-bottom: var(--space-md); }
.p-1 { padding: var(--space-md); }
.text-center { text-align: center; }
.bold { font-weight: 700; }

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  width: 1.2rem;
  height: 1.2rem;
  color: var(--color-text);
}

.theme-toggle:hover {
  opacity: 0.7;
}

.theme-toggle-icon {
  stroke: currentColor;
  fill: currentColor;
}

.sun-icon {
  display: none;
  stroke: var(--color-text);
  fill: none;
  stroke-width: 1.5;
}

.moon-icon {
  display: block;
}

.post-list {
  margin: 2rem 0;
}

.post-item {
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
  align-items: baseline;
}

.post-item time {
  color: var(--color-text);
  white-space: nowrap;
}

.post-item .post-title {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.post-item .post-title:hover {
  color: var(--color-link-hover);
}

/* Images and Captions */
.post-image {
  margin: var(--space-lg) auto;
  width: 100%;
  max-width: var(--max-width);
}

.post-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.post-image figcaption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  font-family: var(--font-family);
  font-weight: 400;
  line-height: 1.4;
}

/* Regular blockquotes */
.post blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--color-text);
}

/* Image groups */
.post figure + figure {
  margin-top: var(--space-md);
}

/* Remove any default blockquote styling when used as caption */
.post img + blockquote::before,
.post img + blockquote::after {
  content: none;
}

/* Footnotes */
.footnote-ref a,
.footnote-backref {
  text-decoration: none;
  color: var(--color-text);
}

.footnote-ref a:hover,
.footnote-backref:hover {
  text-decoration: underline;
  color: var(--color-link-hover);
}

/* Remove brackets from footnote references */
.footnote-ref::before,
.footnote-ref::after {
  display: none;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-lg) 0;
  font-size: 0.9em;
}

th, td {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-text);
}

th {
  background-color: rgba(var(--color-text), 0.05);
  font-weight: 700;
  text-align: left;
}

/* Center table headers */
th.text-center {
  text-align: center;
}

tr:nth-child(even) {
  background-color: rgba(var(--color-text), 0.02);
}

/* Mobile Optimizations */
@media screen and (max-width: 768px) {
  :root {
    --font-size-base: 16px;
    --padding-page: 1rem;
  }

  body {
    width: 100%;
    padding: 0 var(--padding-page);
    font-size: var(--font-size-base);
  }

  .post-item {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
  }

  .post-item time {
    font-size: 0.9rem;
  }

  .nav-links {
    gap: var(--space-md);
  }

  .main-nav {
    padding: var(--space-sm) 0;
  }

  .site-name,
  .site-name a {
    font-size: 0.95rem;
  }

  .nav-links a {
    font-size: 0.95rem;
  }

  h1 {
    font-size: 1.8rem;
    line-height: 1.3;
  }

  h2 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  p, li {
    font-size: var(--font-size-base);
    line-height: 1.7;
  }

  .post-image {
    margin: var(--space-md) -var(--padding-page);
    width: calc(100% + (var(--padding-page) * 2));
    max-width: none;
  }

  .post-image img {
    border-radius: 0;
  }

  .post-image figcaption {
    padding: 0 var(--padding-page);
    font-size: 0.9rem;
  }

  footer {
    margin-top: var(--space-lg);
    padding: var(--space-md) 0;
  }

  footer p {
    flex-wrap: wrap;
    justify-content: center;
  }

  .post-content img,
  .post-content figure {
    margin: var(--space-md) -var(--padding-page);
    width: calc(100% + (var(--padding-page) * 2));
    max-width: 100%;
  }

  .post-content figure img {
    border-radius: 0;
  }

  .post-content figure figcaption {
    margin-top: var(--space-xs);
    padding: 0 var(--padding-page);
    font-size: 0.85rem;
    line-height: 1.4;
  }
}

.site-name a,
.nav-links a {
  color: var(--color-text);
  text-decoration: none;
  position: relative;
  font-size: 0.9rem;
}

.site-name a:hover,
.nav-links a:hover {
  color: var(--color-link-hover);
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  height: 2px;
  width: 0;
  background-color: var(--color-link-hover);
  border-radius: 1px;
  transition: width 0.3s ease, transform 0.3s ease;
  transform: translateY(2px);
}

.nav-links a:hover::after {
  width: 100%;
  transform: translateY(0) rotate(-2deg);
}

/* Header */
header {
  margin: 2rem 0 3rem;
}

/* Main Content */
main {
  width: 100%;
  height: 100%;
  margin: 0 auto;
}

/* Footer */
footer {
  margin-top: var(--space-xl);
  padding-bottom: var(--space-md);
  font-size: 0.9rem;
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

footer p {
  margin: var(--space-sm) 0;
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

footer a {
  color: var(--color-text);
  text-decoration: none;
  line-height: 0;
}

footer a:hover {
  color: var(--color-link-hover);
}

footer .icon {
  display: block;
}

.post h1 {
  margin-bottom: var(--space-xs);
}

.post h2 {
  margin-top: 0;
  color: var(--color-text-secondary);
  font-weight: 400;
  font-size: 1.3rem;
}
