/*
 * ferrell.rocks
 * Dracula-inspired light/dark theme
 */

@view-transition { navigation: auto; }

/* View transition: default cross-fade for all named elements */
::view-transition-old,
::view-transition-new {
  animation-duration: 200ms;
  animation-timing-function: ease-in-out;
}
::view-transition-old {
  animation-name: fade-out;
}
::view-transition-new {
  animation-name: fade-in;
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

:root {
  /* Alucard Classic - Light mode */
  --bg: #FFFBEB;
  --bg-secondary: #ECE9DF;
  --fg: #1F1F1F;
  --fg-muted: #6C664B;
  --border: #CECCC0;
  --surface: #EFEDDC;
  --surface-hover: #ECE9DF;
  --code-bg: #1F1F1F;
  --code-fg: #FFFBEB;

  /* Primitives */
  --pink: #A3144D;
  --purple: #644AC9;
  --cyan: #036A96;
  --green: #14710A;
  --orange: #A34D14;
  --red: #CB3A2A;
  --yellow: #846E15;

  /* Semantic: links */
  --link: var(--cyan);
  --underline: var(--yellow);
  --link-hover: var(--green);
  --underline-hover: var(--yellow);

  /* Semantic: accent (nav active, focus, selection) */
  --accent: var(--purple);
  --accent-hover: var(--purple);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --measure: 40rem;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dracula Classic - Dark mode */
    --bg: #282A36;
    --bg-secondary: #21222C;
    --fg: #F8F8F2;
    --fg-muted: #919bba;
    --border: #44475A;
    --surface: #343746;
    --surface-hover: #424450;
    --code-bg: #21222C;
    --code-fg: #F8F8F2;

    /* Primitives */
    --pink: #FF79C6;
    --purple: #BD93F9;
    --cyan: #8BE9FD;
    --green: #50FA7B;
    --orange: #FFB86C;
    --red: #FF5555;
    --yellow: #F1FA8C;

    /* Semantic: links */
    --link: var(--purple);
    --underline: var(--green);
    --link-hover: var(--green);
    --underline-hover: var(--purple);

    /* Semantic: accent */
    --accent: var(--purple);
    --accent-hover: var(--purple);
  }
}

/* Reset */

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

html { font-size: 100%; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Type */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.375rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.125rem; margin-bottom: 0.5rem; }

p { margin-bottom: 1rem; }

a { color: var(--link); text-decoration: underline; text-decoration-color: var(--underline); text-underline-offset: 2px; font-weight: 600; }
a:hover { color: var(--link-hover); text-decoration-color: var(--underline-hover); }

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: inherit; text-decoration: none; font-weight: inherit; }
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover { color: inherit; }

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

hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

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

:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}

/* Header */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.site-header__title {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-header__title:hover { color: var(--link-hover); text-decoration-color: var(--underline-hover); }

.site-nav { display: flex; gap: 1.25rem; }

.site-nav a {
  color: var(--fg);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 150ms;
}

.site-nav a:hover { color: var(--link-hover); text-decoration: underline; text-decoration-color: var(--underline-hover); }
.site-nav a[aria-current="page"] { color: var(--link-hover); }

/* Main */

.site-main {
  flex: 1;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

/* Homepage intro */

.homepage-intro {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.homepage-intro p:last-child { margin-bottom: 0; }

/* Post listing */

.post-listing {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.post-listing__item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-listing__item * { margin: 0; }

.post-listing__image { margin: 0; }

.post-listing__image img {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin: 0;
}

.post-listing__title {
  font-size: 1.375rem;
  line-height: 1.25;
  margin: 0;
}

.post-listing__title a {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
}

.post-listing__title a:hover { color: var(--link-hover); text-decoration: underline; text-decoration-color: var(--underline-hover); }

.post-listing__date {
  display: block;
  font-size: 1rem;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}

.post-listing__description {
  color: var(--fg-muted);
  font-size: 1rem;
  line-height: 1.55;
}

/* Page header (H1 + featured image) */

.page-header { margin-bottom: 2.5rem; }
.page-header__title { margin-bottom: 0.5rem; }

.page-header__date {
  display: block;
  font-size: 1rem;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
}

.page-header__image { margin: 0; }

.page-header__image img {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* Article content (from Tiptap/HTML) */

article { line-height: 1.7; }
article h2 { margin-top: 2.5rem; }
article h3 { margin-top: 2rem; }

article ul, article ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

article ul:has(> li em) {
  list-style: none;
  padding-left: 0;
}

article ul:has(> li em) li {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}

article ul:has(> li em) li:last-child {
  border-bottom: none;
}

article ul:has(> li em) li::before {
  content: none;
}

article li { margin-bottom: 0.375rem; }
article li:last-child { margin-bottom: 0; }

article blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--fg-muted);
  font-style: italic;
}

article pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.5;
}

article code { font-family: var(--font-mono); font-size: 1em; }

article :not(pre) > code {
  background: var(--surface);
  padding: 0.125em 0.375em;
  border-radius: 3px;
  font-size: 1em;
}

article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 1rem;
}

article th, article td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

article th {
  background: var(--surface);
  font-weight: 600;
  font-size: 1rem;
}

article:not(.post-listing__item) img {
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

article a { text-decoration: underline; text-decoration-color: var(--underline); text-underline-offset: 2px; font-weight: 600; }
article a:hover { color: var(--link-hover); text-decoration-color: var(--underline-hover); }

/* Pagination */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.pagination__link {
  color: var(--link);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-underline-offset: 2px;
  border-radius: var(--radius);
  transition: color 150ms;
}

.pagination__link:hover { color: var(--link-hover); text-decoration-color: var(--underline-hover); }

.pagination__link--current {
  color: var(--link-hover);
  font-weight: 600;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
}

.site-footer__links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.site-footer__links a {
  color: var(--fg);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms;
}

.site-footer__links a:hover { color: var(--link-hover); text-decoration: underline; text-decoration-color: var(--underline-hover); }

.site-footer__copyright {
  font-size: 1rem;
  color: var(--fg-muted);
}

/* 404 */

.not-found {
  text-align: center;
  padding: 3rem 0;
}

/* Responsive */

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .site-main { padding: 2rem 1rem; }

  .site-nav { gap: 1rem; }

  h1 { font-size: 1.625rem; }
  h2 { font-size: 1.25rem; }

  .post-listing__title { font-size: 1.25rem; }

  .pagination { gap: 0.125rem; }
}
