@import './fonts.css';
@import './post.css';

:root {
  /* Min Content Width */
  --content-width: 25rem;

  /* Typography */
  --sans: 'Inter Variable', Inter, system-ui, sans-serif;
  --serif: 'Lora Italic Variable', Lora, Georgia, serif;
  --mono: 'Iosevka Fixed Curly Extended Medium', ui-monospace, monospace;

  --font-size-s: 0.8125rem;
  --font-size-m: 0.9375rem;
  --font-size-l: 1.0625rem;

  --font-weight-light: 350;
  --font-weight-regular: 400;
  --font-weight-bold: 500;

  --spacing-s: -0.08em;
  --spacing-m: -0.02em;

  /* Light Mode Colors (Default) */
  --bg: #ffffff;
  --text-primary: rgba(0, 0, 0, 0.85);
  --text-secondary: rgba(0, 0, 0, 0.4);
  --text-tertiary: rgba(0, 0, 0, 0.24);
  --border: rgba(0, 0, 0, 0.1);
  --selection: rgba(0, 0, 0, 0.08);
  --code-bg: rgba(0, 0, 0, 0.04);
  --mark: #f3ffc4;

  /* Zed One Light syntax theme */
  --astro-code-foreground: #0c0f13;
  --astro-code-background: #f8f5f1;
  --astro-code-token-constant: #df8251;
  --astro-code-token-string: #3c9339;
  --astro-code-token-comment: #9c8d81;
  --astro-code-token-keyword: #a449ab;
  --astro-code-token-parameter: #d32240;
  --astro-code-token-function: #3480df;
  --astro-code-token-string-expression: #3c9339;
  --astro-code-token-punctuation: #242529;
  --astro-code-token-link: #3882b7;
  --code-highlight-line: #ebebec;
  --code-highlight-word: #1d67f611;
}

/* Light Mode (Explicit) */
html.light {
  --bg: #ffffff;
  --text-primary: rgba(0, 0, 0, 0.85);
  --text-secondary: rgba(0, 0, 0, 0.4);
  --text-tertiary: rgba(0, 0, 0, 0.24);
  --border: rgba(0, 0, 0, 0.1);
  --selection: rgba(0, 0, 0, 0.08);
  --code-bg: rgba(0, 0, 0, 0.04);
  --mark: #f3ffc4;

  /* Zed One Light syntax theme */
  --astro-code-foreground: #0c0f13;
  --astro-code-background: #f8f5f1;
  --astro-code-token-constant: #df8251;
  --astro-code-token-string: #3c9339;
  --astro-code-token-comment: #9c8d81;
  --astro-code-token-keyword: #a449ab;
  --astro-code-token-parameter: #d32240;
  --astro-code-token-function: #3480df;
  --astro-code-token-string-expression: #3c9339;
  --astro-code-token-punctuation: #242529;
  --astro-code-token-link: #3882b7;
  --code-highlight-line: #ebebec;
  --code-highlight-word: #1d67f611;
}

/* Dark Mode (Explicit) */
html.dark {
  --bg: #1c1c1c;
  --text-primary: rgba(255, 255, 255, 0.9);
  --text-secondary: rgba(255, 255, 255, 0.4);
  --text-tertiary: rgba(255, 255, 255, 0.24);
  --border: rgba(255, 255, 255, 0.1);
  --selection: rgba(255, 255, 255, 0.08);
  --code-bg: rgba(255, 255, 255, 0.04);
  --mark: #545b37;

  /* Zed Dark syntax theme */
  --astro-code-foreground: #d0d3da;
  --astro-code-background: #080a0d;
  --astro-code-token-constant: #ffac5e;
  --astro-code-token-string: #96cd6f;
  --astro-code-token-comment: #515a6a;
  --astro-code-token-keyword: #be83fa;
  --astro-code-token-parameter: #ea999c;
  --astro-code-token-function: #96b6ee;
  --astro-code-token-string-expression: #96cd6f;
  --astro-code-token-punctuation: #949cbb;
  --astro-code-token-link: #8caaee;
  --code-highlight-line: #1a1d23;
  --code-highlight-word: #0751cf50;
}

html {
  background-color: var(--bg);
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease-out;
}

body {
  font-family: var(--sans);
  font-feature-settings: 'ss03' 1;
  font-size: var(--font-size-m);
  line-height: 1.75;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  letter-spacing: var(--spacing-m);
  margin: 0;
  width: 100%;
  overscroll-behavior-y: contain;
  text-autospace: normal;
  text-spacing-trim: space-first;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

body[data-centered='true'] {
  padding: 6rem 1.5rem 1.5rem;
}

body[data-centered='false'] {
  padding: 3.5rem;
}

@media (max-width: 900px) {
  body[data-centered='true'],
  body[data-centered='false'] {
    padding: 4rem 1.35rem 1.35rem;
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

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

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 1.5px dashed var(--text-tertiary);
  border-radius: 0.25rem;
}

body[data-width] {
  max-width: var(--content-width);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

body[data-fade-animation='true'] main {
  view-transition-name: serein-content;
}

body[data-fade-animation='true'] footer {
  view-transition-name: serein-footer;
}

.date {
  margin: 0;
  font-weight: var(--font-weight-light);
  color: var(--text-secondary);
  opacity: 0.75;
  flex-shrink: 0;
  letter-spacing: var(--spacing-s);
  font-variant-numeric: tabular-nums;
  font-feature-settings:
    'tnum' 1,
    'zero' 0,
    'cv01' 1,
    'cv02' 1,
    'calt' 1,
    'ss03' 1,
    'ordn' 1;
}

.date .month {
  letter-spacing: var(--spacing-m);
}

.sr-only {
  border: 0;
  padding: 0;
  margin: 0;
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px 1px 1px 1px);
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  white-space: nowrap;
}

@supports (view-transition-name: none) {
  @media not (prefers-reduced-motion: reduce) {
    ::view-transition-group(*) {
      animation-duration: 180ms;
      animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
    }

    ::view-transition-old(*) {
      animation: serein-content-hide 0.4s cubic-bezier(0.6, 0, 0.8, 1) forwards;
    }

    ::view-transition-new(*) {
      opacity: 0;
      animation: serein-content-appear 0.6s ease 0.2s forwards;
    }

    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation: none;
    }

    ::view-transition-old(serein-content) {
      animation: serein-content-hide 0.4s cubic-bezier(0.6, 0, 0.8, 1) forwards;
    }

    ::view-transition-new(serein-content) {
      opacity: 0;
      animation: serein-content-appear 0.6s ease 0.2s forwards;
    }

    ::view-transition-old(serein-rail) {
      animation: serein-rail-hide 320ms ease forwards;
    }

    ::view-transition-new(serein-rail) {
      opacity: 0;
      animation: serein-rail-appear 320ms ease forwards;
    }

    ::view-transition-group(serein-footer) {
      animation-duration: 360ms;
      animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
    }

    ::view-transition-old(serein-footer) {
      animation: serein-footer-hide 140ms ease-out forwards;
    }

    ::view-transition-new(serein-footer) {
      opacity: 0;
      animation: serein-footer-appear 240ms ease-out 360ms forwards;
    }
  }
}

@keyframes serein-content-hide {
  from {
    opacity: 1;
    filter: blur(0);
  }
  to {
    opacity: 0;
    filter: blur(4px);
  }
}

@keyframes serein-content-appear {
  from {
    opacity: 0;
    filter: blur(4px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes serein-rail-hide {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes serein-rail-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes serein-footer-hide {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes serein-footer-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
