@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500;600;700&display=swap');

:root {
  /* Nord - Basic values */
  --bg-main: #2e3440;
  --bg-dim: #3b4252;
  --bg-alt: #434c5e;
  --bg-active: #4c566a;

  /* Nord - Foregrounds */
  --fg-main: #e5e9f0;
  --fg-dim: rgba(216, 222, 233, 0.75);
  --fg-alt: rgba(216, 222, 233, 0.6);

  /* Nord - Frosts */
  --cyan: #88c0d0;
  --cyan-glow: rgba(136, 192, 208, 0.25);
  --cyan-bright: #8fbcbb;
  --blue: #81a1c1;
  --blue-glow: rgba(129, 161, 193, 0.2);

  /* Nord - Accent Colors */
  --magenta: #b48ead;
  --green: #a3be8c;
  --yellow: #ebcb8b;
  --red: #bf616a;
  --accent-tint: rgba(136, 192, 208, 0.12);
  --accent-mark: rgba(136, 192, 208, 0.2);

  /* Selection */
  --selection-bg: #eceff4;
  --selection-fg: #4c566a;

  /* Borders */
  --border: #3b4252;
  --border-active: #81a1c1;

  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(10, 12, 24, 0.5);
  --shadow-md: 0 10px 28px rgba(10, 12, 24, 0.6);

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

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

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

body {
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 15px;
  font-weight: 300;
  color: var(--fg-main);
  background: var(--bg-main);
  line-height: 1.35em;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

strong {
  font-weight: 400;
}


/* ============================================
   LAYOUT
   ============================================ */

/* Header */
#preamble header {
  background: transparent;
  color: var(--fg-dim);
  padding: 0 2.5rem;
  border: none;
  margin: 0 auto;
  max-width: 720px;
  margin-top: 7.5%;
  text-align: left;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2em;
  margin-bottom: 3em;
}

.site-brand {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.site-name {
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 1.25em;
  font-weight: 400;
  color: var(--fg-main);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-name:hover {
  color: var(--cyan);
}

.site-tagline {
  font-size: 0.8em;
  color: var(--fg-alt);
  font-weight: 200;
  letter-spacing: 0.1em;
}

/* Main Content Container */
#content {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 2.5rem 5%;
  margin-bottom: 5%;
  width: 100%;
  position: relative;
  z-index: 1;
}

#preamble {
  text-align: left;
}

/* Hide org-mode generated elements */
#content > header {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

body.home #content h1.title,
#content h1.title:empty {
  display: none;
  margin: 0;
}

/* ============================================
   SEARCH
   ============================================ */

.search-box {
  position: relative;
}

.search-box input[type="search"] {
  background: var(--bg-alt);
  color: var(--fg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5em 0.8em;
  font-size: 0.85em;
  min-width: 200px;
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input[type="search"]::placeholder {
  color: var(--fg-alt);
  opacity: 0.7;
}

.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-glow);
}

.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6em);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 260px;
  max-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 2000;
  padding: 0.4em;
}

.search-results a {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  padding: 0.6em 0.7em;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--fg-dim);
  transition: background 0.2s ease, color 0.2s ease;
}

.search-results a:hover {
  background: var(--accent-tint);
  color: var(--fg-main);
}

.search-results .search-title {
  font-weight: 600;
  font-size: 0.9em;
  color: var(--fg-main);
}

.search-results .search-meta {
  font-size: 0.85em;
  color: var(--fg-alt);
}

.search-results .search-snippet {
  font-size: 0.9em;
  color: var(--fg-alt);
  line-height: 1.4em;
  display: block;
  margin-top: 0.3em;
}

.search-results .search-snippet mark {
  background: var(--accent-mark);
  color: var(--cyan);
  font-weight: 500;
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

.search-results .search-empty {
  padding: 0.6em 0.7em;
  font-size: 0.85em;
  color: var(--fg-alt);
}

/* ============================================
   POST LIST (INDEX PAGE)
   ============================================ */

.post-list {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
}

.post-list li {
  padding-bottom: 2em;
  margin-bottom: 0;
}

.post-list li strong,
.post-list-title {
  display: block;
  font-weight: 400;
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-list-title:hover {
  color: var(--cyan-bright);
}

.post-excerpt {
  margin-top: 0.75em;
  margin-bottom: 0.5em;
  color: var(--fg-main);
  line-height: 1.35em;
}

.post-date {
  font-size: 0.85em;
  color: var(--fg-alt);
}

/* ============================================
   POST PAGES
   ============================================ */

/* Post metadata (date at top of post) */
.post-meta {
  margin: 0 0 2em 0;
}

.post-meta .post-date {
  font-size: 0.85em;
  color: var(--fg-alt);
  display: block;
}

.post-meta .reading-time {
  font-size: 0.85em;
  color: var(--fg-alt);
  display: block;
}

/* Post footer */
.post-tags-footer {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 1px solid var(--border);
  text-align: right;
}

.back-to-top {
  font-size: 0.85em;
  color: var(--fg-alt);
  text-decoration: none;
  transition: color 0.2s ease;
}

.back-to-top:hover {
  color: var(--cyan);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.title {
  text-align: left;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 16px;
  color: var(--fg-main);
  font-weight: 500;
  margin-top: 2em;
  line-height: 1.35em;
  text-align: left;
}

h1 {
  font-size: 1.5em;
  margin-top: 0;
  margin-bottom: 0.5em;
  font-weight: 500;
}

h2 {
  font-size: 1.35em;
  margin-top: 3.5em;
  margin-bottom: 1.5em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

h3 {
  font-size: 1.2em;
  margin-top: 2.5em;
  margin-bottom: 0.5em;
  padding-bottom: 0.3em;
}

h4 {
  font-size: 1.05em;
  margin-bottom: 0.5em;
  padding-bottom: 0.3em;
  padding-top: 0.3em;
}

p {
  margin-bottom: 1em;
  color: var(--fg-main);
  line-height: 1.35em;
}

/* Links */
a,
a:visited {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--cyan-bright);
}

a:focus {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Lists */
ul, ol {
  padding-left: 2em;
  margin: 1em 0;
  color: var(--fg-main);
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

li {
  padding-bottom: 0.5em;
}

li::marker {
  color: var(--cyan);
  font-weight: 400;
}

/* Horizontal rules */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  margin: 3em 0;
  opacity: 0.5;
}

/* ============================================
   CODE BLOCKS & SYNTAX
   ============================================ */

pre, code {
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 1em;
}

code {
  padding: 0.3em 0.6em;
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--cyan-bright);
  border: 1px solid var(--border);
  font-weight: 400;
}

pre {
  padding: 1em;
  overflow-x: auto;
  line-height: 1.35em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 2em 0;
  background: var(--bg-alt);
}

pre code {
  padding: 0;
  background: none;
  color: var(--fg-main);
  border: none;
  font-weight: 300;
}

/* Syntax highlighting - htmlize CSS classes */
.org-comment,
.org-comment-delimiter {
  color: var(--fg-alt);
  font-style: italic;
}

.org-string {
  color: var(--green);
}

.org-doc {
  color: var(--green);
  font-style: italic;
}

.org-keyword {
  color: var(--magenta);
  font-weight: 600;
}

.org-builtin {
  color: var(--cyan);
}

.org-function-name {
  color: var(--blue);
  font-weight: 600;
}

.org-variable-name {
  color: var(--cyan);
}

.org-type {
  color: var(--yellow);
}

.org-constant {
  color: var(--magenta);
}

.org-preprocessor {
  color: var(--red);
}

.org-negation-char {
  color: var(--red);
}

.org-warning {
  color: var(--red);
  font-weight: 600;
}

.org-regexp-grouping-backslash,
.org-regexp-grouping-construct {
  color: var(--yellow);
}

/* ============================================
   CONTENT BLOCKS
   ============================================ */

blockquote {
  margin: 2em 0;
  padding: 1.5em 1.5em 1em 2em;
  border-left: 3px solid var(--cyan);
  background: var(--bg-alt);
  color: var(--fg-main);
  font-style: italic;
  position: relative;
  border-radius: var(--radius-sm);
}

blockquote::before {
  content: '"';
  position: absolute;
  top: 0.5em;
  left: 0.5em;
  font-size: 2em;
  color: var(--cyan);
  opacity: 0.3;
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  line-height: 1;
  font-style: normal;
}

blockquote::after {
  content: '"';
  position: absolute;
  bottom: 0.5em;
  right: 0.5em;
  font-size: 2em;
  color: var(--cyan);
  opacity: 0.3;
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  line-height: 1;
  font-style: normal;
}

blockquote p {
  margin-bottom: 0;
  line-height: 1.35em;
}

/* Info boxes */
.info-box {
  margin: 2em 0;
  padding: 1em 1.5em;
  border-left: 3px solid var(--cyan);
  background: var(--bg-alt);
  color: var(--fg-main);
  border-radius: var(--radius-sm);
}

.info-box p {
  margin-bottom: 0.8em;
  line-height: 1.35em;
}

.info-box p:last-child {
  margin-bottom: 0;
}

.info-box strong {
  color: var(--cyan);
  font-weight: 400;
}

/* Warning boxes */
.warning-box {
  margin: 2em 0;
  padding: 1em 1.5em;
  border-left: 3px solid var(--magenta);
  background: var(--bg-alt);
  color: var(--fg-main);
  border-radius: var(--radius-sm);
}

.warning-box strong {
  color: var(--magenta);
  font-weight: 400;
}

/* ============================================
   TABLES
   ============================================ */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2em 0;
  font-size: 0.95em;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  padding: 1em;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-dim);
  color: var(--cyan);
  font-weight: 400;
  font-size: 0.85em;
  text-align: left;
}

tr:hover {
  background: var(--accent-tint);
}

tr:last-child td {
  border-bottom: none;
}

/* ============================================
   IMAGES
   ============================================ */

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  margin: 2em 0;
  box-shadow: var(--shadow-md);
}

.bio-photo {
  width: 120px;
  height: 120px;
  float: right;
  margin: 0 0 1.5em 1.5em;
  border-radius: 50%;
  object-fit: cover;
}

/* Bio section spacing */
#content > p:first-of-type {
  margin-bottom: 3em;
}

/* ============================================
   FOOTER
   ============================================ */

.site-footer {
  margin: 0 auto;
  max-width: 720px;
  margin-bottom: 5%;
  padding: 0 2.5rem;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2em;
  margin-bottom: 2em;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.footer-logo {
  font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 1em;
  font-weight: 200;
  color: var(--fg-alt);
  display: block;
  white-space: normal;
  word-break: break-word;
}

.footer-tagline {
  font-size: 0.8em;
  color: var(--fg-alt);
  font-weight: 200;
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1em;
  align-items: center;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  color: var(--fg-alt);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.footer-link svg {
  transition: transform 0.3s ease;
}

.footer-link:hover svg {
  transform: scale(1.1);
}

.footer-bottom {
  padding: 2em 0 1em;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--fg-alt);
  font-size: 0.9em;
  line-height: 1.35em;
}

.footer-bottom p {
  margin: 0;
  color: var(--fg-alt);
  font-size: 0.9em;
  font-weight: 200;
}

.footer-bottom a {
  color: var(--fg-alt);
}

.footer-bottom a:hover {
  color: var(--cyan);
}

.footer-copyright {
  font-size: 0.9em;
  font-weight: 200;
}

.postamble {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--fg-alt);
  font-size: 0.9rem;
  text-align: center;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   FOOTNOTES
   ============================================ */

.footdef {
  display: flex;
  gap: 0.5em;
  margin-bottom: 1em;
  align-items: flex-start;
}

.footdef sup {
  flex-shrink: 0;
}

.footpara {
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================
   SCROLLBAR & ACCESSIBILITY
   ============================================ */

html {
  scroll-behavior: smooth;
}

#preamble header,
#content,
.site-footer {
  animation: riseIn 0.8s ease both;
}

#content {
  animation-delay: 0.05s;
}

.site-footer {
  animation-delay: 0.1s;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-active);
  border-radius: 5px;
}

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

button:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  #preamble header,
  #content,
  .site-footer {
    animation: none;
  }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 900px) {
  #preamble header {
    margin-top: 5%;
    padding: 0 2rem;
  }

  #content {
    padding: 0 2rem 5%;
  }

  body {
    font-size: 15px;
  }
}

@media (max-width: 768px) {
  #preamble header {
    padding: 0 1.5rem;
  }

  #content {
    padding: 0 1.5rem 5%;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5em;
  }

  .search-box {
    width: 100%;
  }

  .search-box input[type="search"] {
    width: 100%;
  }

  .search-results {
    right: auto;
    left: 0;
    width: 100%;
    max-width: 100%;
  }

  .site-footer {
    padding: 0 1.5rem;
  }

  .footer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1em;
  }

  .bio-photo {
    float: none;
    display: block;
    margin: 0 auto 1.5em;
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  #preamble header {
    padding: 0 1rem;
  }

  #content {
    padding: 0 1rem 5%;
  }

  .site-footer {
    padding: 0 1rem;
  }

  .footer-content {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
    line-height: 1.5;
  }

  .site-footer,
  .footer-links,
  .post-tags-footer {
    display: none;
  }

  header {
    margin-top: 2rem;
  }

  .footer-logo {
    color: black;
  }

  .footer-tagline {
    color: #666;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
    color: #000;
  }

  h1 {
    font-size: 24pt;
  }

  h2 {
    font-size: 18pt;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.25rem;
  }

  h3 {
    font-size: 14pt;
  }

  h1::after {
    display: none;
  }

  p, li {
    orphans: 3;
    widows: 3;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 90%;
    color: #555;
    word-wrap: break-word;
  }

  a[href^="#"]::after,
  a[href^="mailto:"]::after,
  .site-name::after,
  .footer-link::after {
    content: "";
  }

  pre {
    border: 1px solid #ccc;
    background: #f5f5f5;
    padding: 1rem;
    page-break-inside: avoid;
    overflow: visible;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  code {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 0.1rem 0.3rem;
    font-size: 10pt;
  }

  pre code {
    border: none;
    padding: 0;
    background: none;
  }

  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  table {
    page-break-inside: avoid;
    border-collapse: collapse;
  }

  th, td {
    border: 1px solid #ccc;
    padding: 0.5rem;
  }

  blockquote {
    border-left: 3px solid #ccc;
    padding-left: 1rem;
    font-style: italic;
    page-break-inside: avoid;
  }

  .footer-bottom {
    display: block;
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid #ccc;
    margin-top: 2rem;
  }
}
