/* Martin Frič — personal site */

:root {
  /* Light mode — refined cream/navy with sharper contrast + vibrant accent */
  --bg: #FCFCFA;
  --bg-alt: #F2EFE8;
  --text: #14181F;
  --text-muted: #5E6470;
  --heading: #0D1B33;
  --accent: #1E5DBD;
  --accent-hover: #103F8A;
  --border: #E3E0D8;
  --rule: #C2BDB0;

  --header-bg: rgba(252, 252, 250, 0.88);
  --code-color: #5C3A14;
  --shadow-soft: rgba(13, 27, 51, 0.08);

  --serif: 'Source Serif 4', 'Charter', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --content-width: 720px;
  --wide-width: 920px;
}

/* Auto dark mode — applies only when no manual theme override */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161D;
    --bg-alt: #1A2029;
    --text: #DEE2EA;
    --text-muted: #8C95A3;
    --heading: #EAF0FB;
    --accent: #6FA3FF;
    --accent-hover: #9EBFFF;
    --border: #2A323F;
    --rule: #3A4452;

    --header-bg: rgba(17, 22, 29, 0.88);
    --code-color: #E3B47C;
    --shadow-soft: rgba(0, 0, 0, 0.4);
  }
}

/* Manual dark mode — always wins */
:root[data-theme="dark"] {
  --bg: #11161D;
  --bg-alt: #1A2029;
  --text: #DEE2EA;
  --text-muted: #8C95A3;
  --heading: #EAF0FB;
  --accent: #6FA3FF;
  --accent-hover: #9EBFFF;
  --border: #2A323F;
  --rule: #3A4452;

  --header-bg: rgba(17, 22, 29, 0.88);
  --code-color: #E3B47C;
  --shadow-soft: rgba(0, 0, 0, 0.4);
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 0;
  margin-left: 14px;
  vertical-align: middle;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
  display: block;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px;
}

.container-wide {
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
header.site-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
  margin-bottom: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
}

header.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px;
}

header.site-header .logo {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--heading);
  text-decoration: none;
  letter-spacing: -0.005em;
}

header.site-header .logo .logo-bracket {
  color: var(--text-muted);
  font-weight: 400;
}

.hero-implements {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  margin: 0 0 28px;
  display: block;
}

.hero-implements .impl-keyword {
  color: var(--accent);
}

.hero-implements .impl-generic {
  color: var(--text-muted);
  opacity: 0.75;
}

header.site-header nav {
  display: flex;
  gap: 28px;
}

header.site-header nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

header.site-header nav a:hover,
header.site-header nav a.active {
  color: var(--heading);
}

/* Headings */
h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--heading);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin-top: 2em;
  margin-bottom: 0.6em;
}

h1 {
  font-size: 2.5rem;
  margin-top: 0;
  margin-bottom: 0.4em;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.6rem;
  padding-bottom: 0.2em;
  margin-top: 2.4em;
}

h3 {
  font-size: 1.25rem;
  margin-top: 1.8em;
}

h4 {
  font-size: 1.05rem;
  margin-top: 1.4em;
}

p {
  margin: 0 0 1.1em;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

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

/* Hero */
.hero {
  padding: 24px 0 40px;
}

.hero-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 15%;
  display: block;
  margin-bottom: 24px;
  border: 3px solid var(--bg);
  box-shadow: 0 4px 20px var(--shadow-soft);
}

/* Sticky table of contents for long-form posts */
@media (min-width: 1024px) {
  main.container.with-toc {
    max-width: 1080px;
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 60px;
    align-items: start;
  }

  main.container.with-toc > article {
    min-width: 0;
  }

  .toc {
    position: sticky;
    top: 96px;
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 8px;
    border-left: 1px solid var(--border);
    padding-left: 18px;
  }

  .toc-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--heading);
    margin-bottom: 14px;
    font-weight: 600;
  }

  .toc nav {
    display: flex;
    flex-direction: column;
  }

  .toc a {
    display: block;
    padding: 6px 12px 6px 0;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.4;
    font-size: 0.85rem;
    border-left: 2px solid transparent;
    padding-left: 14px;
    margin-left: -16px;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  }

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

  .toc a.active {
    color: var(--heading);
    border-left-color: var(--accent);
    font-weight: 500;
  }

  /* Scrollbar styling for the TOC */
  .toc::-webkit-scrollbar {
    width: 4px;
  }
  .toc::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 2px;
  }
}

@media (max-width: 1023px) {
  .toc {
    display: none;
  }
}

/* Prev/next post navigation */
.post-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin: 56px 0 0;
  padding: 24px 0 0;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.92rem;
}

.post-nav .nav-prev {
  text-align: left;
}

.post-nav .nav-index {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.post-nav .nav-next {
  text-align: right;
}

.post-nav a {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--rule);
  padding-bottom: 2px;
}

.post-nav a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

.post-nav .nav-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  font-weight: 500;
}

@media (max-width: 640px) {
  .post-nav {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .post-nav .nav-prev,
  .post-nav .nav-next,
  .post-nav .nav-index {
    text-align: left;
  }
}

.hero-age {
  font-family: var(--sans);
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.55em;
  letter-spacing: 0;
  vertical-align: middle;
  margin-left: 4px;
}

.hero h1 {
  margin-bottom: 16px;
}

.hero .tagline {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 32px;
  line-height: 1.4;
}

.hero .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.hero .meta a {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--rule);
}

.hero .meta a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Section dividers */
.section {
  margin: 64px 0;
}

.section-label {
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--heading);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
  margin-bottom: 24px;
}

/* Post list */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.post-list li:last-child {
  border-bottom: none;
}

.post-list .post-meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.post-list .post-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.post-list .post-title a {
  color: var(--heading);
  border-bottom: none;
}

.post-list .post-title a:hover {
  color: var(--accent);
}

.post-list .post-summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Article */
article {
  padding-bottom: 80px;
}

article .post-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}

article .post-header h1 {
  margin-bottom: 12px;
}

article .post-meta {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

article p,
article ul,
article ol {
  font-size: 1.05rem;
}

article ul, article ol {
  padding-left: 1.4em;
  margin: 0 0 1.3em;
}

article li {
  margin-bottom: 0.4em;
}

article blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.4em 0 0.4em 1.4em;
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-alt);
  padding-right: 1em;
}

article hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3em 0;
}

/* Code */
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-alt);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--code-color);
}

pre {
  background: var(--bg-alt);
  border-left: 3px solid var(--rule);
  padding: 18px 22px;
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.88rem;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
  border-radius: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.8em 0;
  font-size: 0.95rem;
}

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

th {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--heading);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-alt);
}

/* CV layout */
.cv-entry {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 28px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.cv-entry:last-child {
  border-bottom: none;
}

.cv-entry .cv-date {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 4px;
  letter-spacing: 0.02em;
}

.cv-entry h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.cv-entry .cv-org {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 8px;
  font-style: italic;
}

.cv-entry ul {
  margin: 8px 0 12px;
  padding-left: 1.2em;
  font-size: 0.95rem;
}

.cv-entry .cv-stack {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.cv-skills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 32px;
  font-size: 0.95rem;
  margin: 16px 0;
}

.cv-skills .cv-skill {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.cv-skills .cv-skill .level {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Project cards (experience page) */
.project {
  margin-bottom: 56px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.project:last-child {
  border-bottom: none;
}

.project-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--heading);
  margin: 0 0 4px;
  letter-spacing: -0.015em;
  font-weight: 600;
  line-height: 1.3;
}

.project-employer {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 14px;
}

.project-description {
  margin: 0 0 14px;
  line-height: 1.7;
  font-size: 1.02rem;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 14px 0;
}

.project-tech img {
  height: 26px;
  width: 26px;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.project-tech img:hover {
  opacity: 1;
  transform: scale(1.08);
}

.tech-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  padding: 4px 10px;
  background: var(--bg-alt);
  border-radius: 3px;
  border: 1px solid var(--border);
}

.project-essays {
  margin: 16px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 0.85rem;
  align-items: baseline;
}

/* CV → blog post receipts links */
.essay-link {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  margin-left: 6px;
  text-decoration: none;
  border-bottom: 1px dotted var(--rule);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.essay-link:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

/* Footer */
footer.site-footer {
  margin-top: 100px;
  padding: 32px 0 48px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

footer.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

footer.site-footer a {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--rule);
}

footer.site-footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Production anchor — credibility card on the home page */
.production-anchor {
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  padding: 22px 26px;
  margin: 24px 0 56px;
}

.production-anchor .section-label {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 10px;
}

.production-anchor .proof-line {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--heading);
  margin-bottom: 10px;
  line-height: 1.45;
}

.production-anchor p:last-child {
  margin-bottom: 0;
  color: var(--text-muted);
}

.production-anchor a {
  font-weight: 500;
}

/* Callout */
.callout {
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  padding: 16px 22px;
  margin: 1.8em 0;
  font-size: 0.97rem;
}

.callout strong {
  color: var(--heading);
}

/* TL;DR box */
.tldr {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 18px 24px;
  margin: 0 0 32px;
  font-size: 0.97rem;
  border-radius: 2px;
}

.tldr strong {
  color: var(--heading);
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.tldr p {
  margin: 8px 0 0;
}

/* Talk outline list */
.talk-outline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.talk-outline li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.talk-outline .time {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

.talk-outline .segment {
  font-size: 0.97rem;
}

.talk-outline .segment strong {
  color: var(--heading);
  display: block;
  margin-bottom: 4px;
}

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

/* Responsive */
@media (max-width: 640px) {
  html {
    font-size: 16px;
  }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.4rem; }
  .cv-entry,
  .talk-outline li {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .cv-entry .cv-date {
    font-size: 0.8rem;
  }
  .cv-skills {
    grid-template-columns: 1fr;
  }
  header.site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  header.site-header nav {
    gap: 20px;
  }
}
