/* ============================================================
   Seth W. Barton Blog — Main Stylesheet
   ============================================================ */

/* --- Reset & Base --- */

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

:root {
  --color-bg: #fafafa;
  --color-surface: #f0f0f0;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-accent: #2a7a68;
  --color-accent-glow: rgba(42, 122, 104, 0.15);
  --color-accent-2: #c4553a;
  --color-accent-3: #1a6b8a;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-blockquote-bg: rgba(42, 122, 104, 0.05);
  --color-link-underline: rgba(42, 122, 104, 0.3);
  --color-img-shadow: rgba(0, 0, 0, 0.08);
  --color-scrollbar-hover: rgba(0, 0, 0, 0.2);
  --color-aurora-2: rgba(196, 85, 58, 0.08);
  --color-aurora-3: rgba(26, 107, 138, 0.06);
  --grain-opacity: 0.15;
  --font-body: "Georgia", "Times New Roman", serif;
  --font-heading: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", monospace;
  --max-width: 720px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-bg: #0a0a0f;
  --color-surface: #12121a;
  --color-text: #e8e6e3;
  --color-text-muted: #8a8a9a;
  --color-accent: #3db89e;
  --color-accent-glow: rgba(61, 184, 158, 0.2);
  --color-accent-2: #e8745a;
  --color-accent-3: #4a9aba;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-blockquote-bg: rgba(61, 184, 158, 0.06);
  --color-link-underline: rgba(61, 184, 158, 0.3);
  --color-img-shadow: rgba(0, 0, 0, 0.3);
  --color-scrollbar-hover: rgba(255, 255, 255, 0.12);
  --color-aurora-2: rgba(232, 116, 90, 0.12);
  --color-aurora-3: rgba(74, 154, 186, 0.08);
  --grain-opacity: 0.4;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--color-accent-3);
}

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

.blog-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 25vh;
  overflow: hidden;
  background: var(--color-bg);
}

.blog-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, var(--color-accent-glow), transparent 50%),
    radial-gradient(ellipse at 80% 20%, var(--color-aurora-2), transparent 50%),
    radial-gradient(ellipse at 50% 80%, var(--color-aurora-3), transparent 50%);
  animation: aurora 20s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes aurora {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  33% {
    transform: translate(2%, -3%) rotate(1deg) scale(1.02);
  }
  66% {
    transform: translate(-1%, 2%) rotate(-0.5deg) scale(0.98);
  }
  100% {
    transform: translate(1%, -1%) rotate(0.5deg) scale(1.01);
  }
}

.hero-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to top, var(--color-bg), transparent);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 2rem 1.5rem;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-accent) 50%, var(--color-accent-3) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 8s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.hero-tagline {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

/* --- Grain texture overlay --- */

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
}

/* --- Main Content --- */

.blog-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* --- Post Article --- */

.post {
  animation: fade-up 0.6s ease-out;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.post-header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-3));
  border-radius: 1px;
}

.post-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --- Post Body (Action Text content) --- */

.post-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--color-text);
}

.post-body h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.post-body h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.post-body p {
  margin-bottom: 1.5rem;
}

.post-body blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  background: var(--color-blockquote-bg);
  border-radius: 0 6px 6px 0;
  font-style: italic;
}

.post-body pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.post-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.post-body ul,
.post-body ol {
  margin: 1rem 0 1.5rem 1.5rem;
}

.post-body li {
  margin-bottom: 0.4rem;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
  box-shadow: 0 4px 24px var(--color-img-shadow);
}

.post-body a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}

.post-body a:hover {
  text-decoration-color: var(--color-accent);
}

.post-body hr {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: 2.5rem 0;
}

/* --- No Posts State --- */

.no-posts {
  text-align: center;
  padding: 4rem 0;
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

/* --- Post separators for endless scroll --- */

.post + .post {
  margin-top: 4rem;
  padding-top: 4rem;
  border-top: 1px solid var(--color-border);
  position: relative;
}

.post + .post::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
  border-radius: 1px;
}

/* --- Loading Spinner (endless scroll) --- */

.loading-spinner {
  text-align: center;
  padding: 3rem 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.loading-spinner span {
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* --- Footer --- */

.blog-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

/* --- Scrollbar --- */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-scrollbar-hover);
}

/* --- Selection --- */

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

/* --- Responsive --- */

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .blog-hero {
    min-height: 40vh;
  }

  .blog-main {
    padding: 2rem 1.25rem 3rem;
  }

  .post-header::after {
    width: 40px;
  }
}

/* --- Theme Transition --- */

body,
.blog-hero,
.post-body pre,
.post-body code,
.post-body blockquote {
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

/* --- Theme Toggle --- */

.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  background: none;
  border: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle-scene {
  width: 28px;
  height: 28px;
  position: relative;
}

/* Sun */
.theme-toggle-sun {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.theme-toggle-sun svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--color-text);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Moon */
.theme-toggle-moon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.theme-toggle-moon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--color-text);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Light mode: show sun, hide moon */
.theme-toggle-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-toggle-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

/* Dark mode: hide sun, show moon */
[data-theme="dark"] .theme-toggle-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] .theme-toggle-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Hover effect: gentle glow */
.theme-toggle:hover .theme-toggle-scene {
  filter: drop-shadow(0 0 6px var(--color-accent));
}

/* Click bounce */
.theme-toggle:active .theme-toggle-scene {
  transform: scale(0.85);
  transition: transform 0.1s ease;
}

.theme-toggle-scene {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
}

/* ============================================================
   Admin Styles (functional, not fancy)
   ============================================================ */

.admin-body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #222;
  line-height: 1.5;
}

.admin-body::after {
  display: none;
}

.admin-nav {
  background: #222;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.admin-nav a {
  color: #ccc;
  text-decoration: none;
}

.admin-nav a:hover {
  color: #fff;
}

.admin-nav button,
.admin-nav input[type="submit"] {
  background: none;
  border: 1px solid #555;
  color: #ccc;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.admin-nav button:hover,
.admin-nav input[type="submit"]:hover {
  border-color: #fff;
  color: #fff;
}

.admin-main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.admin-form {
  max-width: 100%;
}

.admin-form .field {
  margin-bottom: 1.25rem;
}

.admin-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="password"],
.admin-form input[type="datetime-local"],
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}

.admin-form input:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.btn {
  display: inline-block;
  background: #222;
  color: #fff;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.btn:hover {
  background: #444;
  color: #fff;
}

.admin-actions {
  margin: 1rem 0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #ddd;
}

.admin-table th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
}

.admin-table td a {
  color: #4a90d9;
  margin-right: 0.75rem;
}

.admin-table td button,
.admin-table td input[type="submit"] {
  background: none;
  border: none;
  color: #d9534f;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.flash-notice {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.flash-alert {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.errors {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.errors ul {
  margin: 0.5rem 0 0 1.25rem;
}

/* --- Action Text in admin --- */

.admin-form lexxy-editor {
  min-height: 60vh;
  width: 100%;
}

/* --- Action Text content styling for blog --- */

.lexxy-content {
  font-family: var(--font-body);
}
